Forum

Tutorial Requests

Discuss anything not covered by any of the other categories.

Moderator: InsideQC Admins

Postby redrum » Sat Sep 08, 2007 7:37 pm

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

Postby Orion » Sat Sep 08, 2007 8:30 pm

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: 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;
}
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby redrum » Mon Sep 10, 2007 1:54 am

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: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Orion » Mon Sep 10, 2007 2:12 am

Sorry, now I remember that particle() and BecomeExplosion() aren't used in QW. :lol:

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...
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby redrum » Mon Sep 10, 2007 2:51 am

ok, thats working better.
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! :shock:
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
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Mon Sep 10, 2007 3:11 am

A lso, when I respawn I keep blowing up! :shock:
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Mon Sep 10, 2007 3:21 am

Keeps applying the damage over and over again.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Dr. Shadowborg » Mon Sep 10, 2007 3:25 am

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! :shock:


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.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby redrum » Tue Sep 11, 2007 12:05 am

Thanks.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby FrikaC » Tue Sep 11, 2007 3:02 am

As for overriding "Your nailgun jammed", you can only have 1 centerprint at a time. There are ways to combine them.....
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby scar3crow » Tue Sep 11, 2007 7:54 pm

Sajt had some real cool centerprint appending in one of his unreleased mods, it looked dj jazzy jeff.
User avatar
scar3crow
InsideQC Staff
 
Posts: 1054
Joined: Tue Jan 18, 2005 8:54 pm
Location: Alabama

Postby Sajt » Tue Sep 11, 2007 11:29 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

Postby FrikaC » Wed Sep 12, 2007 4:08 pm

Prydon method is overkill, you can just use the centerprint7 method - passing in more parameters to the centerprint builtin.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Re: Tutorial Requests

Postby pfhorce1 » Sat Sep 15, 2007 3:47 am

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

Postby frag.machine » Sat Sep 15, 2007 1:41 pm

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest