Help redirecting damage?
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
Help redirecting damage?
- 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.
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
can't you just change targ at the start of the function?
if (targ.occupant && targ.occupant.health > 0)
targ = targ.occupant;
if (targ.occupant && targ.occupant.health > 0)
targ = targ.occupant;
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest