Skip to content

Commit

Permalink
set owner for teleport and droppod anims
Browse files Browse the repository at this point in the history
  • Loading branch information
Coronia committed Jan 21, 2025
1 parent e9a0e72 commit 2b201e1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
17 changes: 13 additions & 4 deletions src/Ext/TechnoType/Hooks.Teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <LocomotionClass.h>
#include <TeleportLocomotionClass.h>

#include <Ext/Anim/Body.h>
#include <Ext/Techno/Body.h>
#include <Ext/WeaponType/Body.h>
#include <TacticalClass.h>
Expand All @@ -19,7 +20,10 @@ DEFINE_HOOK(0x7193F6, TeleportLocomotionClass_ILocomotion_Process_WarpoutAnim, 0
GET_LOCO(ESI);

if (auto pWarpOut = pExt->WarpOut.Get(RulesClass::Instance->WarpOut))
GameCreate<AnimClass>(pWarpOut, pLinked->Location)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(pWarpOut, pLinked->Location);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}

if (pExt->WarpOutWeapon)
WeaponTypeExt::DetonateAt(pExt->WarpOutWeapon, pLinked, pLinked);
Expand Down Expand Up @@ -71,8 +75,10 @@ DEFINE_HOOK(0x719742, TeleportLocomotionClass_ILocomotion_Process_WarpInAnim, 0x
GET_LOCO(ESI);

if (auto pWarpIn = pExt->WarpIn.Get(RulesClass::Instance->WarpIn))
GameCreate<AnimClass>(pWarpIn, pLinked->Location)->Owner
= pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(pWarpIn, pLinked->Location);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}

auto const lastWarpDistance = TechnoExt::ExtMap.Find(pLinked)->LastWarpDistance;
bool isInMinRange = lastWarpDistance < pExt->ChronoRangeMinimum.Get(RulesClass::Instance->ChronoRangeMinimum);
Expand All @@ -91,7 +97,10 @@ DEFINE_HOOK(0x719827, TeleportLocomotionClass_ILocomotion_Process_WarpAway, 0x5)
GET_LOCO(ESI);

if (auto pWarpAway = pExt->WarpAway.Get(RulesClass::Instance->WarpOut))
GameCreate<AnimClass>(pWarpAway, pLinked->Location)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(pWarpAway, pLinked->Location);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}

return 0x719878;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Ext/WarheadType/Detonate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ void WarheadTypeExt::ExtData::Detonate(TechnoClass* pOwner, HouseClass* pHouse,
if (this->Crit_ActiveChanceAnims.size() > 0 && this->Crit_CurrentChance > 0.0)
{
int idx = ScenarioClass::Instance->Random.RandomRanged(0, this->Crit_ActiveChanceAnims.size() - 1);
GameCreate<AnimClass>(this->Crit_ActiveChanceAnims[idx], coords);
auto const pAnim = GameCreate<AnimClass>(this->Crit_ActiveChanceAnims[idx], coords);
AnimExt::SetAnimOwnerHouseKind(pAnim, pHouse, nullptr, false, true);
AnimExt::ExtMap.Find(pAnim)->SetInvoker(pOwner, pHouse);
}

bool bulletWasIntercepted = pBulletExt && pBulletExt->InterceptedStatus == InterceptedStatus::Intercepted;
Expand Down
2 changes: 1 addition & 1 deletion src/New/Entity/ShieldClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void ShieldClass::WeaponNullifyAnim(AnimTypeClass* pHitAnim)

if (pAnimType)
{
const auto pAnim = GameCreate<AnimClass>(pAnimType, this->Techno->GetCoords());
auto const pAnim = GameCreate<AnimClass>(pAnimType, this->Techno->GetCoords());
AnimExt::SetAnimOwnerHouseKind(pAnim, this->Techno->Owner, nullptr, false, true);
AnimExt::ExtMap.Find(pAnim)->SetInvoker(this->Techno);
}
Expand Down
25 changes: 20 additions & 5 deletions src/New/Type/Affiliated/DroppodTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ DEFINE_HOOK(0x4B5B70, DroppodLocomotionClass_ILoco_Process, 0x5)
VocClass::PlayAt(dWpn->Report[Randomizer::Global->Random() % count], coords);
MapClass::DamageArea(locnear, 2 * dWpn->Damage, pLinked, dWpn->Warhead, true, pLinked->Owner);
if (auto dmgAnim = MapClass::SelectDamageAnimation(2 * dWpn->Damage, dWpn->Warhead, LandType::Clear, locnear))
GameCreate<AnimClass>(dmgAnim, locnear, 0, 1, 0x2600, -15, 0)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(dmgAnim, locnear, 0, 1, 0x2600, -15, 0);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}
}
}
}
Expand All @@ -133,10 +136,16 @@ DEFINE_HOOK(0x4B5B70, DroppodLocomotionClass_ILoco_Process, 0x5)
if (pLinked->Unlimbo(pLinked->Location, DirType::North))
{
if (auto puff = podType->Puff.Get(RulesClass::Instance->DropPodPuff))
GameCreate<AnimClass>(puff, pLinked->Location)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(puff, pLinked->Location);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}

if (auto podAnim = podType->GroundAnim[lThis->OutOfMap].Get(RulesClass::Instance->DropPod[lThis->OutOfMap]))
GameCreate<AnimClass>(podAnim, pLinked->Location)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(podAnim, pLinked->Location);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}

if (dWpn && podType->Weapon_HitLandOnly)
WeaponTypeExt::DetonateAt(dWpn, pLinked->Location, pLinked, pLinked->Owner);
Expand All @@ -155,7 +164,10 @@ DEFINE_HOOK(0x4B5B70, DroppodLocomotionClass_ILoco_Process, 0x5)
{
MapClass::DamageArea(coords, 100, pLinked, RulesClass::Instance->C4Warhead, true, pLinked->Owner);
if (auto dmgAnim = MapClass::SelectDamageAnimation(100, RulesClass::Instance->C4Warhead, LandType::Clear, coords))
GameCreate<AnimClass>(dmgAnim, coords, 0, 1, 0x2600, -15, 0)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(dmgAnim, coords, 0, 1, 0x2600, -15, 0);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}
}
lThis->Release();
}
Expand Down Expand Up @@ -194,7 +206,10 @@ DEFINE_HOOK(0x4B607D, DroppodLocomotionClass_ILoco_MoveTo, 0x8)
{
pLinked->PrimaryFacing.SetCurrent(DirStruct { DirType::South });
if (auto entryAnim = podType->AtmosphereEntry.Get(RulesClass::Instance->AtmosphereEntry))
GameCreate<AnimClass>(entryAnim, to)->Owner = pLinked->Owner;
{
auto const pAnim = GameCreate<AnimClass>(entryAnim, to);
AnimExt::SetAnimOwnerHouseKind(pAnim, pLinked->Owner, nullptr, false, true);
}
}

return 0x4B61F0;
Expand Down

0 comments on commit 2b201e1

Please sign in to comment.