diff --git a/CREDITS.md b/CREDITS.md index d486713e9d..36ad961727 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -749,6 +749,7 @@ This page lists all the individual contributions to the project by their author. - Fix the bug where a building with `Factory=BuildingType` owned by the AI did not play `ProductionAnim` when placing a produced building - Fix the bug that buildings with passengers cannot unload via the Deploy hotkey or command bar button - Fix the bug that Ares tunnel-type buildings cannot unload via the Deploy hotkey or command bar button + - Customize whether mind-controlled Insignificant technos can be auto-targeted - **Ollerus**: - Build limit group enhancement - Customizable rocker amplitude diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index f62adf507d..7115f1696b 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -566,6 +566,16 @@ LeptonMindControlOffset=70 ; integer, in leptons MindControlRingOffset=140 ; integer, in leptons ``` +### Customize whether mind-controlled Insignificant technos can be auto-targeted + +- In vanilla Red Alert 2, non-building technos with `Insignificant=yes` can never be acquired as auto targets, even when mind-controlled. In vanilla Yuri's Revenge, such technos become targetable once they are mind-controlled. Now you can customize it. + +In `rulesmd.ini`: +```ini +[CombatDamage] +AutoTarget.InsignificantWhenMindControlled=true ; boolean +``` + ### Customizing effect of level lighting on air units - It is now possible to customize how air units are affected by level lighting, separately for AircraftTypes and infantry/vehicles with Jumpjet `Locomotor`. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 8225c1eaa0..0cb4b0ff89 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -421,6 +421,7 @@ HideShakeEffects=false ; boolean #### New: - [Customized transport plane for teams](AI-Scripting-and-Mapping.md#customized-transport-plane-for-teams) (by FlyStar) - [Modify ammo on impact](New-or-Enhanced-Logics.md#modify-ammo-on-impact) (by FS-21) +- [Customize whether mind-controlled Insignificant technos can be auto-targeted](Fixed-or-Improved-Logics.md#customize-whether-mind-controlled-Insignificant-technos-can-be-auto-targeted) (by Noble_Fish) #### Vanilla fixes: - Fixed the bug where a building with `Factory=BuildingType` owned by the AI did not play `ProductionAnim` when placing a produced building (by Noble_Fish) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index d54228d3b8..856b0991a0 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -613,7 +613,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->ReadyToNextMission_MovingCheck.Read(exINI, GameStrings::General, "ReadyToNextMission.MovingCheck"); this->Warhead_PreventScatter.Read(exINI, GameStrings::CombatDamage, "Warhead.PreventScatter"); - + this->ProjectileRange_ApplyModifiers.Read(exINI, GameStrings::CombatDamage, "ProjectileRange.ApplyModifiers"); this->KeepAlive_Infantry.Read(exINI, GameStrings::General, "KeepAlive.Infantry"); @@ -622,6 +622,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->KeepAlive_Buildings.Read(exINI, GameStrings::General, "KeepAlive.Buildings"); this->KeepAlive_Defenses.Read(exINI, GameStrings::General, "KeepAlive.Defenses"); + this->AutoTarget_InsignificantWhenMindControlled.Read(exINI, GameStrings::CombatDamage, "AutoTarget.InsignificantWhenMindControlled"); + // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); for (int i = 0; i < itemsCount; ++i) @@ -1106,6 +1108,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->KeepAlive_Aircraft) .Process(this->KeepAlive_Buildings) .Process(this->KeepAlive_Defenses) + .Process(this->AutoTarget_InsignificantWhenMindControlled) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 2de689e591..707de53c9b 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -544,6 +544,7 @@ class RulesExt Valueable KeepAlive_Aircraft; Valueable KeepAlive_Buildings; Valueable KeepAlive_Defenses; + Valueable AutoTarget_InsignificantWhenMindControlled; ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } @@ -1025,6 +1026,8 @@ class RulesExt , KeepAlive_Aircraft { false } , KeepAlive_Buildings { true } , KeepAlive_Defenses { true } + + , AutoTarget_InsignificantWhenMindControlled { true } { } virtual ~ExtData() = default; diff --git a/src/Ext/Techno/Hooks.Targeting.cpp b/src/Ext/Techno/Hooks.Targeting.cpp index 2550a55622..4ee468e1c6 100644 --- a/src/Ext/Techno/Hooks.Targeting.cpp +++ b/src/Ext/Techno/Hooks.Targeting.cpp @@ -70,6 +70,21 @@ DEFINE_HOOK(0x6F7CE2, TechnoClass_CanAutoTargetObject_IronCurtain, 0x6) return 0; } +DEFINE_HOOK(0x6F8364, TechnoClass_CanAutoTargetObject_InsignificantWhenMindControlled, 0x6) +{ + enum { SkipMindControlChecks = 0x6F838E }; + + GET(TechnoClass*, pTarget, ESI); + + if (!RulesExt::Global()->AutoTarget_InsignificantWhenMindControlled + && pTarget->GetTechnoType()->Insignificant) + { + return SkipMindControlChecks; + } + + return 0; +} + // WW adds an optimization that: If the techno get a target in 1/4 or 1/2 of their targeting range, then it will not checking other targets. DEFINE_HOOK(0x6F9AF4, TechnoClass_SelectAutoTarget_DisableStupid, 0x6) {