Skip to content

Commit 6823e24

Browse files
committed
fix weapon detonation
Add some extra logic implied by the `Begun_detonation` flag. Missiles that are homing can have their targets, headings, speeds, and lifetimes changed for various reasons. If a missile has begun detonation, particularly if it is in "detonation limbo" because it is flying across a bowl-shaped turret, we don't want to change any of that. The "detonation limbo" weapon lifetime is only accurate if all of those values remain constant. Follow up to #4006.
1 parent 305a7f6 commit 6823e24

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

code/weapon/weapons.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,6 +5018,10 @@ void weapon_home(object *obj, int num, float frame_time)
50185018
wip = &Weapon_info[wp->weapon_info_index];
50195019
hobjp = Weapons[num].homing_object;
50205020

5021+
// don't home if we're detonating; we don't want to change target, lifetime, heading, or speed
5022+
if (wp->weapon_flags[Weapon::Weapon_Flags::Begun_detonation])
5023+
return;
5024+
50215025
//local ssms home only in stages 1 and 5
50225026
if ( (wp->lssm_stage==2) || (wp->lssm_stage==3) || (wp->lssm_stage==4))
50235027
return;
@@ -5370,6 +5374,9 @@ void weapon_home(object *obj, int num, float frame_time)
53705374

53715375
// this flag is needed so we don't prolong the missile's life by repeatedly detonating it
53725376
wp->weapon_flags.set(Weapon::Weapon_Flags::Begun_detonation);
5377+
5378+
// return so we don't change target, lifetime, heading, or speed
5379+
return;
53735380
}
53745381

53755382
// Only lead target if more than one second away. Otherwise can miss target. I think this

0 commit comments

Comments
 (0)