Skip to content

Commit b429215

Browse files
committed
Fix some idiosyncracies with animation damage
- Always use invoker's owner house as house dealing damage if available and Damage.DealtByInvoker is set to true - Restore fallback for house dealing damage to use owner objects (attachee) or parent building's owning house if available, separately from invoker logic - Clarify some of the behaviour in docs
1 parent 71d1329 commit b429215

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ LandingDir= ; Direction type (integers from 0-255). Accepts negative values
328328

329329
- `Weapon` can be set to a WeaponType, to create a projectile and immediately detonate it instead of simply dealing `Damage` by `Warhead`. This allows weapon effects to be applied.
330330
- `Damage.Delay` determines delay between two applications of `Damage`. Requires `Damage` to be set to 1.0 or above. Value of 0 disables the delay. Keep in mind that this is measured in animation frames, not game frames. Depending on `Rate`, animation may or may not advance animation frames on every game frame.
331-
- `Damage.DealtByInvoker`, if set to true, makes any `Damage` dealt to be considered as coming from the animation's invoker (f.ex, firer of the weapon if it is Warhead `AnimList/SplashList` animation, the destroyed vehicle if it is `DestroyAnim` animation or the object the animation is attached to). If invoker has died or does not exist, the house the invoker belonged to is still used to deal damage and apply Phobos-introduced Warhead effects. Does not affect which house the `Damage` dealt by `Warhead` is dealt by.
331+
- `Damage.DealtByInvoker`, if set to true, makes any `Damage` dealt to be considered as coming from the animation's invoker (f.ex, firer of the weapon if it is Warhead `AnimList/SplashList` animation, the destroyed vehicle if it is `DestroyAnim` animation or the object the animation is attached to). If invoker has died or does not exist, the house the invoker belonged to is still used to deal damage and apply Phobos-introduced Warhead effects etc. If not set, the animation's owner house, or failing that, owning house of object it is attached to or the building it belongs to is used to deal the damage.
332332
- `Damage.ApplyFirepowerMult` determines whether or not firepower modifiers from the animation's invoker are applied on the damage dealt from this animation, if exists.
333333
- `Damage.ApplyOncePerLoop`, if set to true, makes `Damage` be dealt only once per animation loop (on single loop animations, only once, period) instead of on every frame or intervals defined by `Damage.Delay`. The frame on which it is dealt is determined by `Damage.Delay`, defaulting to after the first animation frame.
334334

src/Ext/Anim/Hooks.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ DEFINE_HOOK(0x42453E, AnimClass_AI_Damage, 0x6)
9999
{
100100
const auto pExt = AnimExt::ExtMap.Find(pThis);
101101
pInvoker = pExt->Invoker;
102-
103-
if (pExt->InvokerHouse)
104-
pOwner = pExt->InvokerHouse;
102+
pOwner = pExt->InvokerHouse;
105103

106104
if (!pInvoker)
107105
{
@@ -111,6 +109,7 @@ DEFINE_HOOK(0x42453E, AnimClass_AI_Damage, 0x6)
111109
pInvoker = pExt->ParentBuilding;
112110
}
113111

112+
114113
if (pInvoker)
115114
{
116115
if (!pOwner)
@@ -121,6 +120,16 @@ DEFINE_HOOK(0x42453E, AnimClass_AI_Damage, 0x6)
121120
}
122121
}
123122

123+
// Jun 29, 2025 - Starkku: Owner != Invoker. Previously OwnerObject / ParentBuilding fallback only existed for Warheads
124+
// but if we are unifying the approaches it needs to be available even without and separately from invoker.
125+
if (!pOwner)
126+
{
127+
if (pThis->OwnerObject)
128+
pOwner = pThis->OwnerObject->GetOwningHouse();
129+
else if (pThis->IsBuildingAnim)
130+
pOwner = AnimExt::ExtMap.Find(pThis)->ParentBuilding->Owner;
131+
}
132+
124133
if (pTypeExt->Weapon)
125134
{
126135
WeaponTypeExt::DetonateAt(pTypeExt->Weapon, pThis->GetCoords(), pInvoker, appliedDamage, pOwner);

0 commit comments

Comments
 (0)