From b9ea97fac227f13d5e769bff0170f08d811a2982 Mon Sep 17 00:00:00 2001 From: Victor Luchits Date: Sat, 26 Mar 2016 16:18:00 +0300 Subject: [PATCH] Fix instagib shot stopping on the first victim --- source/game/g_weapon.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source/game/g_weapon.cpp b/source/game/g_weapon.cpp index c1b8db9b9b..1bb233d4be 100644 --- a/source/game/g_weapon.cpp +++ b/source/game/g_weapon.cpp @@ -1289,7 +1289,8 @@ void W_Fire_Instagun( edict_t *self, vec3_t start, vec3_t angles, float damage, { vec3_t from, end, dir; trace_t tr; - edict_t *ignore, *event; + edict_t *ignore, *event, *hit; + int hit_movetype; int mask; bool missed = true; int dmgflags = 0; @@ -1314,24 +1315,27 @@ void W_Fire_Instagun( edict_t *self, vec3_t start, vec3_t angles, float damage, break; // allow trail to go through SOLID_BBOX entities (players, gibs, etc) - if( !ISBRUSHMODEL( game.edicts[tr.ent].s.modelindex ) ) - ignore = &game.edicts[tr.ent]; + hit = &game.edicts[tr.ent]; + hit_movetype = hit->movetype; // backup the original movetype as the entity may "die" - if( ( &game.edicts[tr.ent] != self ) && ( game.edicts[tr.ent].takedamage ) ) + if( !ISBRUSHMODEL( hit->s.modelindex ) ) + ignore = hit; + + if( ( hit != self ) && ( hit->takedamage ) ) { - G_Damage( &game.edicts[tr.ent], self, self, dir, dir, tr.endpos, damage, knockback, stun, dmgflags, mod ); + G_Damage( hit, self, self, dir, dir, tr.endpos, damage, knockback, stun, dmgflags, mod ); // spawn a impact event on each damaged ent event = G_SpawnEvent( EV_INSTA_EXPLOSION, DirToByte( tr.plane.normal ), tr.endpos ); event->s.ownerNum = ENTNUM( self ); event->s.firemode = FIRE_MODE_STRONG; - if( game.edicts[tr.ent].r.client ) + if( hit->r.client ) missed = false; } // some entity was touched - if( tr.ent == world->s.number - || game.edicts[tr.ent].movetype == MOVETYPE_NONE - || game.edicts[tr.ent].movetype == MOVETYPE_PUSH ) + if( hit == world + || hit_movetype == MOVETYPE_NONE + || hit_movetype == MOVETYPE_PUSH ) { if( g_instajump->integer && self && self->r.client ) {