View previous topic :: View next topic |
Author |
Message |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Wed Jun 16, 2010 2:46 pm Post subject: Grenade help |
|
|
Hey guys, I've been away for awhile but still have my server up. I've been having this one problem that keeps crashing the server though. I have given the grenades health so that if it takes a hit it will explode as well as exploding when the timer expires. I think it's kinda cool. Anyway, I'll throw a bunch of grenades in the same area as a test. When the first one explodes it triggers all the rest to explode. Ther server doesn't crash. I'll do this test 10 times in a row trying to get the server to crash to no avail.
Then I'll come home one day and the server will be down.
I'm at work so I don't have the actual code right now, but what would be the correct way to achieve what I'm looking for?
I believe I added this to FireGrenade():
Code: |
newmis.takedamage = DAMAGE_AIM;
newmis.health = 50;
newmis.th_die = GrenadeExplode;
|
_________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Wed Jun 16, 2010 5:17 pm Post subject: |
|
|
Hey redrum, nice to see ya back!
Why do you think is your mod the root cause of the server crashes ?
Try to put the server running the vanilla progs.dat for some time to check if the crash persists. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
Dr. Shadowborg Inside3D Staff

Joined: 16 Oct 2004 Posts: 726
|
Posted: Wed Jun 16, 2010 6:42 pm Post subject: |
|
|
Couple of things that I thought of off the top of my head: (I've had to deal with stuff like this before with wallmines / dynamite)
When your grenade die function gets called, do something like:
self.takedamage = DAMAGE_NO;
This prevents grenades dying and setting other grenades off again causing overflow insanity.
Another thought is that you need to set a slight delay between grenades dying, thereby preventing massive amounts of explosion particles. (This can cause a crash too.) _________________ "Roboto suggests Plasma Bazooka." |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Wed Jun 16, 2010 10:08 pm Post subject: |
|
|
Hmmmm.
Wouldn't self.takedamage = DAMAGE_NO; prevent the grenade from actually "dying"?
I've exploded about 12 grenades all at once and the server didn't crash, so the delay thing won't help.
This function is def the reason for the crashes b/c when I remove it the server never crashes. _________________ 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: Wed Jun 16, 2010 10:13 pm Post subject: |
|
|
Here's the actual portion of code from FireGrenade();
Code: |
newmis.touch = GrenadeTouch;
newmis.nextthink = time + (2 + r);
newmis.health = 50;
newmis.takedamage = DAMAGE_AIM;
newmis.th_die = GrenadeExplode;
newmis.think = GrenadeExplode;
|
Maybe it's when the newmis.think and newmis.th_die happens at the exact same time??? _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Wed Jun 16, 2010 11:41 pm Post subject: |
|
|
If you look at T_Damage/T_RadiusDamage in combat.qc, you'll see that they ignore targets with takedamage set to zero (DAMAGE_NO). When an entity "dies", T_Damage() calls Killed(), which is where th_die gets called. You'll notice that it sets takedamage to DAMAGE_NO before calling th_die.
But since the think function isn't going through that function, takedamage is not being set to DAMAGE_NO when the grenade explodes after its timer expires (but it is when it is "killed").
If the grenade is still damageable when it explodes, you get this fun result: it explodes, looking for nearby entities to damage. One of those "nearby" entities turns out to be the exploding grenade itself. (Normally it would ignore it because it shouldn't be damageable). It therefore damages that grenade (itself), which causes it to explode again, which causes it damage itself again, exploding again... forever (stack overflow/runaway loop).
So, if you were to set takedamage to DAMAGE_NO in GrenadeExplode *before* the call to T_RadiusDamage, everything would be good. (Note: this crash probably also wouldn't happen if the T_RadiusDamage call passed "self" as the "ignore" parameter, which for some reason it doesn't. You could do this, but to be safe you should also clear takedamage as I've described.) _________________ 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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Thu Jun 17, 2010 2:35 am Post subject: |
|
|
Aha!
That makes total sense, wise man atop the mountain. Thanks. _________________ 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: Thu Jun 17, 2010 2:33 pm Post subject: |
|
|
It's working, so far so good! _________________ 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 Jun 28, 2010 8:03 pm Post subject: |
|
|
OK, another issue.
I was playing around with the smoking grenade code that I found in another thread. I didn't quite care for that "old school" effect. I decided to create a smoke effect from scratch. So I decided to use the puff cloud effect when you use the the shotgun. Here what I tried first:
Code: | void() GrenadeExplode =
{
local vector dir; //added this
if (self.voided)
return;
self.voided = 1;
dir = aim (self, 100000); //added this
FireBullets (256, dir, '0.25 0.25 0' ,0); //added this
T_RadiusDamage (self, self.owner, 120, world, "grenade");
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);
puff_count = puff_count + 1; //added this
remove (self);
}; |
That didn't work, the puff was not appearing. I knew it was something to do with the origin, this part of the code.
Code: | dir = aim (self, 100000); //added this |
So I tinkered with it, I changed the self to self.owner and it worked! Doesn't make sense to me because wouldn't that be the player? The player owns the grenade right?
Annnnnyway, I didn't care anymore of why it worked as long as it was working. Then it started crashing the server.
Any helpful hints? _________________ 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: Wed Jun 30, 2010 11:49 pm Post subject: |
|
|
Anyone? _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Thu Jul 01, 2010 12:43 am Post subject: |
|
|
Why is the grenade shooting a shotgun blast when it explodes? D: _________________ 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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Thu Jul 01, 2010 6:01 pm Post subject: |
|
|
for the smoke effect _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Thu Jul 01, 2010 10:29 pm Post subject: |
|
|
You have the grenade shooting bullets, too. In a pretty arbitrary direction, I might add. Remove the "dir = aim..." line and the FireBullets call. You can go in the shotgun code and find the the WriteByte/TE_GUNSHOT code and copy that over (and only that). But that will make a very poor smoke grenade, mind you. You don't have a lot of options for making a smoke grenade in software engines.
The only reasonable way to do smoke screens is big alpha-blended billboards, whose alpha ramps to zero when they come close to the screen (to avoid "popping" your head through a billboarded particle), and with some depth-buffer fudging to get soft intersections with geometry (I think I saw this recently on a thread here somewhere). Anyway it's pretty advanced stuff. There's a reason you don't see smoke grenades in old games. _________________ 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 |
|
 |
ceriux

Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA
|
Posted: Fri Jul 02, 2010 5:20 pm Post subject: |
|
|
the player would not be the owner of the smoke plume even if he is the owner of the grenade. the grenade is an entitie owned by the player and since the grenade is its own entitie it can own its own entities ( i think right? at least thats how i look at it. ) _________________ QuakeDB - Quake ModDB Group |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Jul 02, 2010 5:28 pm Post subject: |
|
|
aim(foo,bar);
is basically makevectors(self.angles); return v_forward;
except that it doesn't actually change v_forward, and the pitch can be autocorrected vertically in order to try hitting something (bar is meant to be the projectile speed, for moving stuff).
Better to replace with randomized direction vectors instead.
But yeah, as Sajt said your code shoots bullets, its not just a graphical effect (either that or you broke the shotgun!). _________________ What's a signature? |
|
Back to top |
|
 |
|