Tutorial Requests
Moderator: InsideQC Admins
66 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
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!
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?
I'm trying, but I'm not quite the coder I'd like to be.....yet!
- Code: Select all
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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:
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: Select all
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;
}
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
Sorry, now I remember that particle() and BecomeExplosion() aren't used in QW.
Just replace that whole statement with this one:
Now it should work...
Just replace that whole statement with this one:
- Code: Select all
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...
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
ok, thats working better.
In my mod you get a +1 frag for gibbing someone.
I have this in client obituary:
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!
In my mod you get a +1 frag for gibbing someone.
I have this in client obituary:
- Code: Select all
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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: Select all
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: Select all
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.
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
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
- pfhorce1
- Posts: 1
- Joined: Sat Sep 15, 2007 3:11 am
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.ph ... ag-machine
Here you can find my monster pack mod, and they can swim and jump out of water. Source code included.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
66 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 1 guest
