diff --git a/src/Offsets.h b/src/Offsets.h index 683a80f9..aadf0850 100644 --- a/src/Offsets.h +++ b/src/Offsets.h @@ -6376,6 +6376,10 @@ enum Offsets { // right hand (attachment 1) for the main-hand lane and the left (2) for // the off hand (AttachItemModel 0x0047A0C0). FUN_M2MODEL_HAS_ANIMATION = 0x00711960, + // IsDeathAnimation `int __stdcall(int anim)`, ret 4 (a jump table). A + // dead unit plays only death animations: CGUnit_C::PlayAnimation + // (0x005FE2F0) returns for health below 1 unless the animation is one. + FUN_IS_DEATH_ANIMATION = 0x005FDA90, ANIM_STAND = 0, ANIM_BOW_PULL = 160, ANIM_BOW_RELEASE = 161, diff --git a/src/model/SceneActor.cpp b/src/model/SceneActor.cpp index 48741005..c9ef4da4 100644 --- a/src/model/SceneActor.cpp +++ b/src/model/SceneActor.cpp @@ -461,9 +461,26 @@ void Actor::ClearModel() { RunScript(S_ONMODELCLEARED, 0); } +namespace { + +bool IsDeathAnimation(int anim) { + return reinterpret_cast(Offsets::FUN_IS_DEATH_ANIMATION)(anim) != 0; +} + +} // namespace + +// An actor whose own animation is a death animation is dead to its spells, as +// a unit without health is to its PlayAnimation (0x005FE2F0): a kit's +// animation (a cast, an impact, a wound) does not play over the death, and a +// death drops the one that plays. void Actor::PlayAnimation() { if (model == nullptr) return; + if (kitAnimation >= 0 && IsDeathAnimation(static_cast(animation)) && !IsDeathAnimation(kitAnimation)) { + kitAnimation = -1; + kitAnimationLoops = false; + kitAnimationEnded = true; + } heldPositionMs = -1; // a paused actor holds the new animation's first frame // An end the scene's advance reported for the animation this replaces is // not this one's: the engine reports a replaced play as reason 1, which