Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Tutorial Requests Goto page Previous 1, 2, 3, 4, 5 Next

| Inside3d Forums Forum Index -> General Discussion

View previous topic :: View next topic
Author | Message
--- | ---
redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Sat Sep 08, 2007 7:37 pm Post subject: |

Could someone create a tutorial for when you fire too many nails in a row for the super-nailgun it explodes? I'm trying, but I'm not quite the coder I'd like to be.....yet!

Code:
if (self.ammo_nails <= 10 && self.ammo_nails >= 9) { centerprint(self, "Your nailgun jammed!\n"); T_Damage (self, self, self, 500); }

I put this at the bottom of void() PlayerPostThink =
I know the first line is way off, but I needed a way to activate it to test the rest of the code. I'd like that if you fired 50 consecutive nails then it would explode.
When I test it, the damage is coming from myself. I want the damage to come from the super-nail gun.
In: T_Damage, what do the 3 "selfs" stand for?
Any help would be appreciated?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

Orion Joined: 12 Jan 2007 Posts: 413 Location: Brazil |

Posted: Sat Sep 08, 2007 8:30 pm Post subject: |

redrum: In T_Damage() the first self stands for the target, who will take the damage. The second self is for the inflictor, who will do the damage. And the third self is for the attacker, who will gain a frag after killing the target (if a player).
E.g.: In T_MissileTouch() you'll see the T_Damage (other, self, self.owner, damg); where "other" is the entity that the rocket is touching, "self" is the rocket itself, and "self.owner" is who launched the rocket.
So, the touched entity will take the damage, the rocket will do the damage and the owner will gain the frag when killing the enemy.
And about nailgun jamming, it's not that hard to do that. First at the very bottom of defs.qc you should create (.float fired_nails;) for example.
Then, at PlayerPostThink() you replace the ammo_nails "if" by this (if (self.fired_nails >= 10)).
Now open player.qc and scroll down to player_nail1(), and add this (self.fired_nails = self.fired_nails + 1, add the same line at player_nail2() too.
Finally, scroll up to player_run() and add this at the very top (self.fired_nails = 0 and it should work.
And if you want to your nailgun to "explode", you shouldn't call T_Damage(), and yes, T_RadiusDamage(). So, your statement at PlayerPostThink() Should look like this:

Code:
local entity exp; // explosion effect (optional) if (self.fired_nails >= 10) { centerprint (self, "Your nailgun jammed!\n"); T_RadiusDamage (self, self, 500, world);
sound (self, CHAN_AUTO, "weapons/r_exp3.wav", 1, ATTN_NORM);
particle (self.origin, '0 0 0', 75, 255);
exp = spawn ();
setorigin (exp, self.origin);
exp.nextthink = time;
exp.think = BecomeExplosion;
}

_________________
There's no signature here. Stop looking for one.

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Mon Sep 10, 2007 1:54 am Post subject: |

I get 3 errors. 1) unknown value "particle" 2) unknown value "BecomeExplosion. 3) type mismatch for = (pointer and _variant) all in client.qc.
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

Orion Joined: 12 Jan 2007 Posts: 413 Location: Brazil |

Posted: Mon Sep 10, 2007 2:12 am Post subject: |

Sorry, now I remember that particle() and BecomeExplosion() aren't used in QW. Just replace that whole statement with this one:

Code:
if (self.fired_nails >= 10) { centerprint (self, "Your nailgun jammed!\n"); T_RadiusDamage (self, self, 500, world); WriteByte (MSG_MULTICAST, SVC_TEMPENTITY);
WriteByte (MSG_MULTICAST, TE_EXPLOSION);
WriteCoord (MSG_MULTICAST, self.origin_x);
WriteCoord (MSG_MULTICAST, self.origin_y);
WriteCoord (MSG_MULTICAST, self.origin_z);
multicast (self.origin, MULTICAST_PHS);
}

Now it should work...
_________________
There's no signature here. Stop looking for one.

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Mon Sep 10, 2007 2:51 am Post subject: |

ok, thats working better. In my mod you get a +1 frag for gibbing someone. I have this in client obituary:

Code:
if (targ.health < -40) //EXTRA FRAG FOR GIBBING attacker.frags = attacker.frags + 1; if (targ.health < -40) centerprint(attacker, "Nice shot! +1 Frag!\n");

I am getting credit for gibbing myself!
Also the "Nice shot! +1 Frag!" overrides the "Your nailgun jammed!"
How can I fix this?
Thanks for the help!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Mon Sep 10, 2007 3:11 am Post subject: |

A lso, when I respawn I keep blowing up! _________________ Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Mon Sep 10, 2007 3:21 am Post subject: |

Keeps applying the damage over and over again. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Mon Sep 10, 2007 3:25 am Post subject: |

redrum wrote:
ok, thats working better. In my mod you get a +1 frag for gibbing someone. I have this in client obituary: Code: if (targ.health < -40) //EXTRA FRAG FOR GIBBING
attacker.frags = attacker.frags + 1;
if (targ.health < -40)
centerprint(attacker, "Nice shot! +1 Frag!\n");
I am getting credit for gibbing myself!
Also the "Nice shot! +1 Frag!" overrides the "Your nailgun jammed!"
How can I fix this?
Thanks for the help!
A lso, when I respawn I keep blowing up!

This would be because you need to not just check the target's health, you need to make sure it's NOT yourself, ala:

Code:
if (targ.health < -40 && targ != self)

This basically means: If my target's health is less than -40 AND my target isn't myself, do it. Additionally, you don't need to do two checks, you can do it in one by simply placing the code together like this:

Code:
if (targ.health < -40 && targ != self) { attacker.frags = attacker.frags + 1; // EXTRA FRAG FOR GIBBING centerprint(attacker, "Nice Shot +1 Frag!\n"); }

Note the brackets. These are what work such wonders.
Now, for the second problem. To fix this you need to reset your shot counter variable whenever you respawn. Additionally, you'll need to add some sort of reduction timer so that your shot counter gets reduced when not firing for a bit.
_________________
"Roboto suggests Plasma Bazooka."

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Tue Sep 11, 2007 12:05 am Post subject: |

Thanks. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Tue Sep 11, 2007 3:02 am Post subject: |

As for overriding "Your nailgun jammed", you can only have 1 centerprint at a time. There are ways to combine them.....

Back to top |

scar3crow Inside3D Staff Joined: 18 Jan 2005 Posts: 837 Location: Las Vegas, NV

Posted: Tue Sep 11, 2007 7:54 pm Post subject: |

Sajt had some real cool centerprint appending in one of his unreleased mods, it looked dj jazzy jeff.

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Tue Sep 11, 2007 11:29 pm Post subject: |

I don't remember exactly, but it probably was FrikaC's prydon method (either that or the mod was darkplaces only) _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Wed Sep 12, 2007 4:08 pm Post subject: |

Prydon method is overkill, you can just use the centerprint7 method - passing in more parameters to the centerprint builtin.

Back to top |

pfhorce1 Joined: 15 Sep 2007 Posts: 1 |

Posted: Sat Sep 15, 2007 3:47 am Post subject: Re: Tutorial Requests |

scar3crow wrote:
This is a thread to request tutorials you would like to see tackled by any of the coders in this community - submitting something does not mean a tutorial will be written for it, there is nothing compulsory about it, it is to serve as motivation and inspiration to those coders willing to share their knowledge.
Keep in mind that the point of a tutorial is to learn, not how to get the code for something. I for one would like to see something on creating a rounds based system where the level resets, but does not reload, or a good spectating system or entities like CTF flags or domination control points. Compare this with some of our older tutorials which are more cut and paste jobs.
Requesters - Let loose, be creative, but be open in terms of the subject matter.
Writers - Explain the code line for line, the variances therein, and why it goes down the way it does. This is a chance to share knowledge and continue Quake!

I need help with getting single player monsters to exit water pools
my mod has an amphibian monster but can not find the 1.06 fix any
where someone must know... there you have it
MONSTERS UNABLE TO EXIT WATER POOLS QC 1.06 FIX

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Sat Sep 15, 2007 1:41 pm Post subject: Re: Tutorial Requests |

pfhorce1 wrote:
I need help with getting single player monsters to exit water pools my mod has an amphibian monster but can not find the 1.06 fix any where someone must know... there you have it MONSTERS UNABLE TO EXIT WATER POOLS QC 1.06 FIX

http://qexpo2005.quakedev.com/booths.php?tag=frag-machine
Here you can find my monster pack mod, and they can swim and jump out of water. Source code included.
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> General Discussion | All times are GMT Goto page Previous 1, 2, 3, 4, 5 Next
Page 3 of 5

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group