diff --git a/src/Ext/Building/Body.cpp b/src/Ext/Building/Body.cpp index feeeb6ba71..2d4df2e4fe 100644 --- a/src/Ext/Building/Body.cpp +++ b/src/Ext/Building/Body.cpp @@ -1,4 +1,5 @@ #include "Body.h" +#include "Ext/House/Body.h" #include @@ -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; diff --git a/src/Ext/BuildingType/Body.cpp b/src/Ext/BuildingType/Body.cpp index 46b6673df7..6adaf10005 100644 --- a/src/Ext/BuildingType/Body.cpp +++ b/src/Ext/BuildingType/Body.cpp @@ -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) { @@ -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) diff --git a/src/Ext/BuildingType/Body.h b/src/Ext/BuildingType/Body.h index 977cd53023..1e1a8604d5 100644 --- a/src/Ext/BuildingType/Body.h +++ b/src/Ext/BuildingType/Body.h @@ -59,6 +59,7 @@ class BuildingTypeExt Valueable SpyEffect_Custom; ValueableIdx SpyEffect_VictimSuperWeapon; ValueableIdx SpyEffect_InfiltratorSuperWeapon; + Valueable SpyEffect_RadarJamDuration; Nullable ConsideredVehicle; Valueable ZShapePointMove_OnBuildup; @@ -124,6 +125,7 @@ class BuildingTypeExt , SpyEffect_Custom { false } , SpyEffect_VictimSuperWeapon {} , SpyEffect_InfiltratorSuperWeapon {} + , SpyEffect_RadarJamDuration { 0 } , ConsideredVehicle {} , ZShapePointMove_OnBuildup { false } , SellBuildupLength { 23 } diff --git a/src/Ext/House/Body.cpp b/src/Ext/House/Body.cpp index 8f928902a0..a39d710c8a 100644 --- a/src/Ext/House/Body.cpp +++ b/src/Ext/House/Body.cpp @@ -636,6 +636,7 @@ void HouseExt::ExtData::Serialize(T& Stm) .Process(this->AIFireSaleDelayTimer) .Process(this->SuspendedEMPulseSWs) .Process(this->SuperExts) + .Process(this->SpyEffect_RadarJamTimer) ; } diff --git a/src/Ext/House/Body.h b/src/Ext/House/Body.h index b6c0f21c2d..f72e98a744 100644 --- a/src/Ext/House/Body.h +++ b/src/Ext/House/Body.h @@ -70,6 +70,8 @@ class HouseExt }; std::vector SuperExts; + CDTimerClass SpyEffect_RadarJamTimer; + ExtData(HouseClass* OwnerObject) : Extension(OwnerObject) , PowerPlantEnhancers {} , OwnedLimboDeliveredBuildings {} @@ -102,6 +104,7 @@ class HouseExt , AIFireSaleDelayTimer {} , SuspendedEMPulseSWs {} , SuperExts(SuperWeaponTypeClass::Array->Count) + , SpyEffect_RadarJamTimer {} { } bool OwnsLimboDeliveredBuilding(BuildingClass* pBuilding); diff --git a/src/Ext/House/Hooks.cpp b/src/Ext/House/Hooks.cpp index 4c5dbdb9fb..6f37b05754 100644 --- a/src/Ext/House/Hooks.cpp +++ b/src/Ext/House/Hooks.cpp @@ -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) {