Forum

Help redirecting damage?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Help redirecting damage?

Postby gnounc » Mon Aug 16, 2010 9:19 am

Code: Select all

void() W_damageSwap =
{
   local vector dir;
   
   dir = aim (self, 100);
   traceline (self.origin, self.origin + dir*200, FALSE, self);

   if (trace_ent.takedamage)
   {
      self.flags = self.flags + FL_HOST;
      self.occupant = trace_ent;
   }
};

and basically stuck this in T_Damage

Code: Select all

   if (targ.flags & FL_HOST)
   {
      targ.occupant.health = targ.occupant.health - take;
      // react to the damage
      oldself = self;
      self = targ;
   }



I'm trying to make a selected enemy take damage in my place.

[edited because I'm retarded and had the entities switched around]

almost working
Last edited by gnounc on Mon Aug 16, 2010 9:32 am, edited 1 time in total.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby Spike » Mon Aug 16, 2010 9:28 am

can't you just change targ at the start of the function?

if (targ.occupant && targ.occupant.health > 0)
targ = targ.occupant;
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby gnounc » Mon Aug 16, 2010 9:37 am

Apparently yes, yes I can.
Done and done, thank you.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest