Skip to content

Commit

Permalink
Merge pull request #4 from TaranDahl/SpyEffect_RadarJam
Browse files Browse the repository at this point in the history
SpyEffect.RadarJamDuration
  • Loading branch information
CrimRecya authored Jan 10, 2025
2 parents 8cb640b + 97f3664 commit c717d66
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Ext/Building/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Body.h"
#include "Ext/House/Body.h"

#include <BitFont.h>

Expand Down Expand Up @@ -339,6 +340,19 @@ bool BuildingExt::ExtData::HandleInfiltrate(HouseClass* pInfiltratorHouse, int m
idx = this->TypeExtData->SpyEffect_InfiltratorSuperWeapon;
if (idx >= 0)
launchTheSWHere(pInfiltratorHouse->Supers.Items[idx], pInfiltratorHouse);

auto jamTime = this->TypeExtData->SpyEffect_RadarJamDuration;

if (jamTime > 0)
{
pVictimHouse->RecheckRadar = true;
auto pVictimExt = HouseExt::ExtMap.Find(pVictimHouse);
if (pVictimExt->SpyEffect_RadarJamTimer.TimeLeft < jamTime)
{
pVictimExt->SpyEffect_RadarJamTimer.Stop();
pVictimExt->SpyEffect_RadarJamTimer.Start(jamTime);
}
}
}

return true;
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->SpyEffect_VictimSuperWeapon.Read(exINI, pSection, "SpyEffect.VictimSuperWeapon");
this->SpyEffect_InfiltratorSuperWeapon.Read(exINI, pSection, "SpyEffect.InfiltratorSuperWeapon");
}
this->SpyEffect_RadarJamDuration.Read(exINI, pSection, "SpyEffect.RadarJamDuration");

if (pThis->MaxNumberOccupants > 10)
{
Expand Down Expand Up @@ -993,6 +994,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->SpyEffect_Custom)
.Process(this->SpyEffect_VictimSuperWeapon)
.Process(this->SpyEffect_InfiltratorSuperWeapon)
.Process(this->SpyEffect_RadarJamDuration)
.Process(this->ConsideredVehicle)
.Process(this->ZShapePointMove_OnBuildup)
.Process(this->SellBuildupLength)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class BuildingTypeExt
Valueable<bool> SpyEffect_Custom;
ValueableIdx<SuperWeaponTypeClass> SpyEffect_VictimSuperWeapon;
ValueableIdx<SuperWeaponTypeClass> SpyEffect_InfiltratorSuperWeapon;
Valueable<int> SpyEffect_RadarJamDuration;

Nullable<bool> ConsideredVehicle;
Valueable<bool> ZShapePointMove_OnBuildup;
Expand Down Expand Up @@ -124,6 +125,7 @@ class BuildingTypeExt
, SpyEffect_Custom { false }
, SpyEffect_VictimSuperWeapon {}
, SpyEffect_InfiltratorSuperWeapon {}
, SpyEffect_RadarJamDuration { 0 }
, ConsideredVehicle {}
, ZShapePointMove_OnBuildup { false }
, SellBuildupLength { 23 }
Expand Down
1 change: 1 addition & 0 deletions src/Ext/House/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ void HouseExt::ExtData::Serialize(T& Stm)
.Process(this->AIFireSaleDelayTimer)
.Process(this->SuspendedEMPulseSWs)
.Process(this->SuperExts)
.Process(this->SpyEffect_RadarJamTimer)
;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/House/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class HouseExt
};
std::vector<SWExt> SuperExts;

CDTimerClass SpyEffect_RadarJamTimer;

ExtData(HouseClass* OwnerObject) : Extension<HouseClass>(OwnerObject)
, PowerPlantEnhancers {}
, OwnedLimboDeliveredBuildings {}
Expand Down Expand Up @@ -102,6 +104,7 @@ class HouseExt
, AIFireSaleDelayTimer {}
, SuspendedEMPulseSWs {}
, SuperExts(SuperWeaponTypeClass::Array->Count)
, SpyEffect_RadarJamTimer {}
{ }

bool OwnsLimboDeliveredBuilding(BuildingClass* pBuilding);
Expand Down
37 changes: 37 additions & 0 deletions src/Ext/House/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,43 @@ DEFINE_HOOK(0x4FD8F7, HouseClass_UpdateAI_OnLastLegs, 0x10)
return ret;
}

namespace SpyEffectRadarJamContext
{
HouseClass* pThis;
}

DEFINE_HOOK(0x4F8440, HouseCLass_Update_SpyEffectRadarJam, 0x5)
{
GET(HouseClass*, pThis, ECX);

auto pExt = HouseExt::ExtMap.Find(pThis);

int StartTime = pExt->SpyEffect_RadarJamTimer.StartTime;
int TimeLeft = pExt->SpyEffect_RadarJamTimer.TimeLeft;

if (StartTime != -1 && Unsorted::CurrentFrame - StartTime == TimeLeft)
{
pExt->SpyEffect_RadarJamTimer.Stop();
pThis->RecheckRadar = true;
}

return 0;
}

DEFINE_HOOK(0x508DF0, HouseClass_UpdateRadar_SetContext, 0x7)
{
GET(HouseClass*, pThis, ECX);
SpyEffectRadarJamContext::pThis = pThis;
return 0;
}

DEFINE_HOOK(0x508F2A, HouseClass_UpdateRadar_CheckSpyEffectRadarJam, 0x5)
{
enum { RadarUnavailable = 0x508F2F };
auto const pExt = HouseExt::ExtMap.Find(SpyEffectRadarJamContext::pThis);
return pExt->SpyEffect_RadarJamTimer.IsTicking() ? RadarUnavailable : 0;
}

// WW's code set anger on every houses, even on the allies.
DEFINE_HOOK(0x4FD616, HouseClass_sub4FD500_DontAngerOnAlly, 0x9)
{
Expand Down

0 comments on commit c717d66

Please sign in to comment.