Skip to content

Commit

Permalink
RemoveDisguise applicable to mirages
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Jun 30, 2024
1 parent e459ba3 commit d7f7f05
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ LaunchSW.DisplayMoney.Offset=0,0 ; X,Y, pixels relative to default

### Remove disguise on impact

- Warheads can now remove disguise from disguised infantry such as spies. This will work even if the disguised was acquired by default through `PermaDisguise`.
- Warheads can now remove disguise from disguised spies or mirage tanks. This will work even if the disguised was acquired by default through `PermaDisguise`.

In `rulesmd.ini`:
```ini
Expand Down
14 changes: 14 additions & 0 deletions src/Ext/Techno/Hooks.Disguise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,17 @@ DEFINE_HOOK(0x7060A9, TechnoClass_TechnoClass_DrawObject_DisguisePalette, 0x6)

return SkipGameCode;
}

DEFINE_HOOK(0x74691D, UnitClass_UpdateDisguise_EMP, 0x6)
{
GET(UnitClass*, pThis, ESI);
// Remove mirage disguise if under emp or being flipped, approximately 15 deg
if (pThis->IsUnderEMP() || std::abs(pThis->AngleRotatedForwards) > 0.25 || std::abs(pThis->AngleRotatedSideways) > 0.25)
{
pThis->ClearDisguise();
R->EAX(pThis->MindControlRingAnim);
return 0x746AA5;
}

return 0x746931;
}
2 changes: 1 addition & 1 deletion src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class WarheadTypeExt
void InterceptBullets(TechnoClass* pOwner, WeaponTypeClass* pWeapon, CoordStruct coords);
private:
void DetonateOnOneUnit(HouseClass* pHouse, TechnoClass* pTarget, TechnoClass* pOwner = nullptr, bool bulletWasIntercepted = false);
void ApplyRemoveDisguiseToInf(HouseClass* pHouse, TechnoClass* pTarget);
void ApplyRemoveDisguise(HouseClass* pHouse, TechnoClass* pTarget);
void ApplyRemoveMindControl(HouseClass* pHouse, TechnoClass* pTarget);
void ApplyCrit(HouseClass* pHouse, TechnoClass* pTarget, TechnoClass* Owner, TechnoExt::ExtData* pTargetExt);
void ApplyShieldModifiers(TechnoClass* pTarget, TechnoExt::ExtData* pTargetExt);
Expand Down
11 changes: 6 additions & 5 deletions src/Ext/WarheadType/Detonate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void WarheadTypeExt::ExtData::DetonateOnOneUnit(HouseClass* pHouse, TechnoClass*
this->ApplyShieldModifiers(pTarget, pTargetExt);

if (this->RemoveDisguise)
this->ApplyRemoveDisguiseToInf(pHouse, pTarget);
this->ApplyRemoveDisguise(pHouse, pTarget);

if (this->RemoveMindControl)
this->ApplyRemoveMindControl(pHouse, pTarget);
Expand Down Expand Up @@ -263,12 +263,13 @@ void WarheadTypeExt::ExtData::ApplyRemoveMindControl(HouseClass* pHouse, TechnoC
pTarget->MindControlledBy->CaptureManager->FreeUnit(pTarget);
}

void WarheadTypeExt::ExtData::ApplyRemoveDisguiseToInf(HouseClass* pHouse, TechnoClass* pTarget)
void WarheadTypeExt::ExtData::ApplyRemoveDisguise(HouseClass* pHouse, TechnoClass* pTarget)
{
if (auto pInf = abstract_cast<InfantryClass*>(pTarget))
auto const rtti = pTarget->WhatAmI();
if (rtti == AbstractType::Infantry || rtti == AbstractType::Unit)
{
if (pInf->IsDisguised())
pInf->Disguised = false;
if (pTarget->IsDisguised())
pTarget->ClearDisguise();
}
}

Expand Down

0 comments on commit d7f7f05

Please sign in to comment.