mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
fix(model): ModelScene spell animations do not play over a death
A unit without health plays only death animations: CGUnit_C:: PlayAnimation (0x005FE2F0) returns unless IsDeathAnimation (0x005FDA90, __stdcall) holds for the animation. An actor had no such gate, so a missile already in flight when the target died still played its wound (and its impact kit's animation) on arrival and replaced the death animation; StopSpellVisual only drops the casts still preparing. An actor whose own animation is a death animation now takes no kit animation over it, and setting a death drops the kit animation that plays. The missiles still land and show their impact effects.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -461,9 +461,26 @@ void Actor::ClearModel() {
|
||||
RunScript(S_ONMODELCLEARED, 0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsDeathAnimation(int anim) {
|
||||
return reinterpret_cast<int(__stdcall *)(int)>(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<int>(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
|
||||
|
||||
Reference in New Issue
Block a user