View previous topic :: View next topic |
Author |
Message |
Ghost_Fang
Joined: 12 Nov 2009 Posts: 162
|
Posted: Sat Mar 13, 2010 4:59 pm Post subject: Sticky Grenades |
|
|
Im using the sticky grenades from the tutorials page but i did a little editing to get rid of the random and stuff. But now when the grenades stick the dont explode they just disappear. But when i kill the enemy the grenade appears on the dead body THEN explodes....
Code: | void () GlueStick =
{
if ( ((self.enemy != world) && (self.enemy.health > 1)) )
{
self.origin = self.enemy.origin;
if ( (self.velocity == VEC_ORIGIN) ) {
self.avelocity = VEC_ORIGIN;
}
}
self.think = GrenadeExplode;
self.nextthink = time + 2;
}; |
Code: | void () GlueTouch =
{
if ( (other == self.owner) ) {
return ;
}
sound (self,CHAN_WEAPON,"misc/outwater.wav",TRUE,ATTN_NORM); // sound to make when it stick
self.touch = GlueStick; // go to GlueStick when touching something
self.velocity = (self.velocity * 0);
self.avelocity = VEC_ORIGIN;
self.enemy = other;
}; |
and my missile.touch = GlueTouch; in my grenade throwing function.
Also instead of sharing the enemies origin when it sticks, how would i make the origin on the spot of the enemy where it hits? |
|
Back to top |
|
 |
Downsider

Joined: 16 Sep 2008 Posts: 478
|
Posted: Sat Mar 13, 2010 6:30 pm Post subject: |
|
|
Subtract from the grenade's origin to the object that was hits origin, then move it to the entity's origin on it's nextthink, then add the subtracted amount. |
|
Back to top |
|
 |
|