Forum

Sticky Grenades

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Sticky Grenades

Postby Ghost_Fang » Sat Mar 13, 2010 4:59 pm

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: Select all
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: Select all
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?
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby Downsider » Sat Mar 13, 2010 6:30 pm

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.
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest