Gez
Why don't I have a custom title by now?!
Posts: 9138
Registered: 07-07 |
qoncept said:
Makes me wonder if there's an unknown stat that sets the chance a monster will switch targets.
Nothing in the Doom code is unknown.
There is an Arch-Vile-specific mechanism for that. In ZDoom is it generalized as the QUICKTORETALIATE flag.
For a more technical explanation of how this works in vanilla, the P_DamageMobj() function has this code:
code: if ( (!target->threshold || target->type == MT_VILE)
&& source && source != target
&& source->type != MT_VILE)
{
// if not intent on another player,
// chase after this one
target->target = source;
target->threshold = BASETHRESHOLD;
if (target->state == &states[target->info->spawnstate]
&& target->info->seestate != S_NULL)
P_SetMobjState (target, target->info->seestate);
}
BASETHRESHOLD is defined to be 100, and threshold is a countdown which is decremented (and possibly nulled) every time an actor calls A_Chase, thanks to this code:
code: // modify target threshold
if (actor->threshold)
{
if (!actor->target
|| actor->target->health <= 0)
{
actor->threshold = 0;
}
else
actor->threshold--;
}
As you can see, the damage code normally waits for threshold to be back to 0 before switching the hurt monster's target to its latest bully, but arch-viles don't wait for this. Also, if the monster's current target is dead, the threshold is reset to 0 at the next A_Chase call.
The great thing with the arch-vile is that it can lead to surprising behavior. Like, you get engulfed by the flames, and oh crap there's no cover but boom, it's another monster behind the vile that suddenly explodes. Or vice-versa, you're seeing an arch-vile infighting some other monster, shoot it in the back, and boom, you explode with no warning.
|