From b7e21d3dec1695a7a6f43d073b8b8ce3f0e159ff Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:23:10 +0800 Subject: [PATCH 1/5] update --- src/Ext/Rules/Body.cpp | 5 +++++ src/Ext/Rules/Body.h | 8 +++++++- src/Ext/Techno/Hooks.cpp | 33 +++++++++++++++++++++++++++++++++ src/Ext/TechnoType/Body.cpp | 4 ++++ src/Ext/TechnoType/Body.h | 4 ++++ src/Ext/WeaponType/Body.cpp | 2 ++ src/Ext/WeaponType/Body.h | 2 ++ 7 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 048086a786..30d36b9f3b 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -320,6 +320,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->AdjacentWallDamage.Read(exINI, GameStrings::CombatDamage, "AdjacentWallDamage"); + this->AutoTarget_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTarget.NoThreatBuildings"); + this->AutoTargetAI_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTargetAI.NoThreatBuildings"); + // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); for (int i = 0; i < itemsCount; ++i) @@ -589,6 +592,8 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->Parasite_GrappleAnim) .Process(this->InfantryAutoDeploy) .Process(this->AdjacentWallDamage) + .Process(this->AutoTarget_NoThreatBuildings) + .Process(this->AutoTargetAI_NoThreatBuildings) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index e082c5d42f..b9bff24067 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -270,7 +270,10 @@ class RulesExt Valueable InfantryAutoDeploy; Valueable AdjacentWallDamage; - + + Valueable AutoTarget_NoThreatBuildings; + Valueable AutoTargetAI_NoThreatBuildings; + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , HarvesterDumpAmount { 0.0f } @@ -480,6 +483,9 @@ class RulesExt , Parasite_GrappleAnim {} , InfantryAutoDeploy { false } , AdjacentWallDamage { 200 } + + , AutoTarget_NoThreatBuildings { false } + , AutoTargetAI_NoThreatBuildings { true } { } virtual ~ExtData() = default; diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index fb5669c234..931c5a5454 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -1459,3 +1459,36 @@ DEFINE_HOOK(0x6F7E1E, TechnoClass_CanAutoTargetObject_AU, 0x6) } #pragma endregion + +#pragma region AutoTargetExtension + +namespace CanAutoTargetTemp +{ + TechnoTypeExt::ExtData* TypeExtData; + WeaponTypeExt::ExtData* WeaponExt; +} + +DEFINE_HOOK(0x6F7E30, TechnoClass_CanAutoTarget_SetContent, 0x6) +{ + GET(TechnoClass*, pThis, EDI); + GET(WeaponTypeClass*, pWeapon, EBP); + + CanAutoTargetTemp::TypeExtData = TechnoExt::ExtMap.Find(pThis)->TypeExtData; + CanAutoTargetTemp::WeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon); + + return 0; +} + +DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTarget_AttackFriendlies_Building, 0x6) +{ + GET(TechnoClass*, pThis, EDI); + enum { CanAttack = 0x6F8604, Continue = 0x6F85BA }; + + const bool canAttack = CanAutoTargetTemp::WeaponExt->AttackNoThreatBuildings.Get( + CanAutoTargetTemp::TypeExtData->AutoTarget_NoThreatBuildings.Get(pThis->Owner->IsControlledByHuman() + ? RulesExt::Global()->AutoTarget_NoThreatBuildings : RulesExt::Global()->AutoTargetAI_NoThreatBuildings)); + + return canAttack ? CanAttack : Continue; +} + +#pragma endregion diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index d8bf5ebdb1..d85cad9fbc 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -1198,6 +1198,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) // VoiceIFVRepair from Ares 0.2 this->VoiceIFVRepair.Read(exINI, pSection, "VoiceIFVRepair"); this->ParseVoiceWeaponAttacks(exINI, pSection, this->VoiceWeaponAttacks, this->VoiceEliteWeaponAttacks); + + this->AutoTarget_NoThreatBuildings.Read(exINI, pSection, "AutoTarget.NoThreatBuildings"); } void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exINI, const char* pSection, INI_EX& exArtINI, const char* pArtSection) @@ -1609,6 +1611,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->InfantryAutoDeploy) .Process(this->TurretResponse) + + .Process(this->AutoTarget_NoThreatBuildings) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 277021f05d..445f3a7726 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -431,6 +431,8 @@ class TechnoTypeExt Nullable TurretResponse; + Nullable AutoTarget_NoThreatBuildings; + ExtData(TechnoTypeClass* OwnerObject) : Extension(OwnerObject) , HealthBar_Hide { false } , HealthBar_HidePips { false } @@ -812,6 +814,8 @@ class TechnoTypeExt , InfantryAutoDeploy {} , TurretResponse {} + + , AutoTarget_NoThreatBuildings {} { } virtual ~ExtData() = default; diff --git a/src/Ext/WeaponType/Body.cpp b/src/Ext/WeaponType/Body.cpp index be24ebc24f..c88b337102 100644 --- a/src/Ext/WeaponType/Body.cpp +++ b/src/Ext/WeaponType/Body.cpp @@ -153,6 +153,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->DelayedFire_OnlyOnInitialBurst.Read(exINI, pSection, "DelayedFire.OnlyOnInitialBurst"); this->DelayedFire_AnimOffset.Read(exINI, pSection, "DelayedFire.AnimOffset"); this->DelayedFire_AnimOnTurret.Read(exINI, pSection, "DelayedFire.AnimOnTurret"); + this->AttackNoThreatBuildings.Read(exINI, pSection, "AttackNoThreatBuildings"); // handle SkipWeaponPicking if (this->CanTarget != AffectedTarget::All || this->CanTargetHouses != AffectedHouse::All @@ -237,6 +238,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm) .Process(this->DelayedFire_OnlyOnInitialBurst) .Process(this->DelayedFire_AnimOffset) .Process(this->DelayedFire_AnimOnTurret) + .Process(this->AttackNoThreatBuildings) ; }; diff --git a/src/Ext/WeaponType/Body.h b/src/Ext/WeaponType/Body.h index 03d6fe37e0..438f085f29 100644 --- a/src/Ext/WeaponType/Body.h +++ b/src/Ext/WeaponType/Body.h @@ -91,6 +91,7 @@ class WeaponTypeExt Valueable DelayedFire_OnlyOnInitialBurst; Nullable DelayedFire_AnimOffset; Valueable DelayedFire_AnimOnTurret; + Nullable AttackNoThreatBuildings; bool SkipWeaponPicking; @@ -164,6 +165,7 @@ class WeaponTypeExt , DelayedFire_OnlyOnInitialBurst { false } , DelayedFire_AnimOffset {} , DelayedFire_AnimOnTurret { true } + , AttackNoThreatBuildings {} { } int GetBurstDelay(int burstIndex) const; From 2a95556a09ae8121e6fdbaff7a44e812295e225b Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:29:50 +0800 Subject: [PATCH 2/5] Update Hooks.cpp --- src/Ext/Techno/Hooks.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 931c5a5454..5edde65ff3 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -1481,9 +1481,10 @@ DEFINE_HOOK(0x6F7E30, TechnoClass_CanAutoTarget_SetContent, 0x6) DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTarget_AttackFriendlies_Building, 0x6) { - GET(TechnoClass*, pThis, EDI); enum { CanAttack = 0x6F8604, Continue = 0x6F85BA }; + GET(TechnoClass*, pThis, EDI); + const bool canAttack = CanAutoTargetTemp::WeaponExt->AttackNoThreatBuildings.Get( CanAutoTargetTemp::TypeExtData->AutoTarget_NoThreatBuildings.Get(pThis->Owner->IsControlledByHuman() ? RulesExt::Global()->AutoTarget_NoThreatBuildings : RulesExt::Global()->AutoTargetAI_NoThreatBuildings)); From 35d83fdb7b891517261c85d0bacdb27bbcd15010 Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sun, 12 Oct 2025 15:15:15 +0800 Subject: [PATCH 3/5] update doc --- CREDITS.md | 1 + docs/New-or-Enhanced-Logics.md | 25 +++++++++++++++++++++++++ docs/Whats-New.md | 1 + 3 files changed, 27 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index a89619a151..b50d1b6a5b 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -394,6 +394,7 @@ This page lists all the individual contributions to the project by their author. - Health bar permanently displayed - Unlimbo Detonate warhead - Fast access structure + - Attack non-threatening structures extensions - **NetsuNegi**: - Forbidding parallel AI queues by type - Jumpjet crash speed fix when crashing onto building diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index f634bc3d76..da62cc4c44 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1312,6 +1312,21 @@ In `rulesmd.ini`: AttackMove.IgnoreWeaponCheck=false ; boolean ``` +### Attack non-threatening structures + +- You can now freely configure whether units can automatically target non-threatening structures. + - `AutoTarget.NoThreatBuildings` affects player-controlled units, `AutoTargetAI.NoThreatBuildings` affects other units.. + +In `rulesmd.ini`: +```ini +[General] +AutoTarget.NoThreatBuildings=false ; boolean +AutoTargetAI.NoThreatBuildings=true ; boolean + +[SOMETECHNO] ; TechnoType +AttackNoThreatBuildings= ; boolean, default to [General] -> AutoTarget.NoThreatBuildings/AutoTargetAI.NoThreatBuildings. +``` + ### Aircraft spawner customizations ![image](_static/images/spawnrange-01.gif) @@ -2561,6 +2576,16 @@ In `rulesmd.ini`: AreaFire.Target=base ; AreaFire Target Enumeration (base|self|random) ``` +### Attack non-threatening structures + +- `AttackNoThreatBuildings` permits shooters to attack non-threatening structures. This setting overrides other configurations. + +In `rulesmd.ini`: +```ini +[SOMEWEAPON] ; WeaponType +AttackNoThreatBuildings= ; boolean +``` + ### Burst delay customizations - `Burst.Delays` allows specifying weapon-specific burst shot delays. Takes precedence over the old `BurstDelayX` logic available on VehicleTypes, functions with Infantry & BuildingType weapons (AircraftTypes are not supported due to their weapon firing system being completely different) and allows every shot of `Burst` to have a separate delay instead of only first four shots. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 104bb1ede6..d7c69881d6 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -452,6 +452,7 @@ New: - [Unlimbo Detonate warhead](New-or-Enhanced-Logics.md#unlimbo-detonate-warhead) (by FlyStar) - Attack and damage technos underground (by TaranDahl) - Fast access structure (by FlyStar) +- Attack non-threatening structures extensions (by FlyStar) Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) From 9c12cd66b47bbd517067446e9414f176a7e7d531 Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sun, 12 Oct 2025 15:18:41 +0800 Subject: [PATCH 4/5] Merge HOOK --- src/Ext/Techno/Hooks.TargetEvaluation.cpp | 17 ----------------- src/Ext/Techno/Hooks.cpp | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Ext/Techno/Hooks.TargetEvaluation.cpp b/src/Ext/Techno/Hooks.TargetEvaluation.cpp index 10daf28aac..91379ab69e 100644 --- a/src/Ext/Techno/Hooks.TargetEvaluation.cpp +++ b/src/Ext/Techno/Hooks.TargetEvaluation.cpp @@ -197,23 +197,6 @@ DEFINE_HOOK(0x4DF3A0, FootClass_UpdateAttackMove_SelectNewTarget, 0x6) return 0; } -DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6) -{ - enum { ContinueCheck = 0x6F85BA, CanTarget = 0x6F8604 }; - - GET(TechnoClass* const, pThis, EDI); - - if (!pThis->Owner->IsControlledByHuman()) - return CanTarget; - - if (!pThis->MegaMissionIsAttackMove()) - return ContinueCheck; - - const auto pExt = TechnoExt::ExtMap.Find(pThis); - - return pExt->TypeExtData->AttackMove_Aggressive.Get(RulesExt::Global()->AttackMove_Aggressive) ? CanTarget : ContinueCheck; -} - #pragma endregion #pragma region HealingWeapons diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 5edde65ff3..21049f6d2c 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -1479,17 +1479,25 @@ DEFINE_HOOK(0x6F7E30, TechnoClass_CanAutoTarget_SetContent, 0x6) return 0; } -DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTarget_AttackFriendlies_Building, 0x6) +DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6) { - enum { CanAttack = 0x6F8604, Continue = 0x6F85BA }; + enum { ContinueCheck = 0x6F85BA, CanTarget = 0x6F8604 }; - GET(TechnoClass*, pThis, EDI); + GET(TechnoClass* const, pThis, EDI); + + if (!pThis->MegaMissionIsAttackMove()) + return ContinueCheck; const bool canAttack = CanAutoTargetTemp::WeaponExt->AttackNoThreatBuildings.Get( CanAutoTargetTemp::TypeExtData->AutoTarget_NoThreatBuildings.Get(pThis->Owner->IsControlledByHuman() ? RulesExt::Global()->AutoTarget_NoThreatBuildings : RulesExt::Global()->AutoTargetAI_NoThreatBuildings)); - return canAttack ? CanAttack : Continue; + if (!canAttack) + return ContinueCheck; + + const auto pExt = TechnoExt::ExtMap.Find(pThis); + + return pExt->TypeExtData->AttackMove_Aggressive.Get(RulesExt::Global()->AttackMove_Aggressive) ? CanTarget : ContinueCheck; } #pragma endregion From c5bceebe00f6cf6249a7100d99d729d3250a0e8f Mon Sep 17 00:00:00 2001 From: Fly-Star <100747645+a851903106@users.noreply.github.com> Date: Sun, 12 Oct 2025 15:33:09 +0800 Subject: [PATCH 5/5] Update New-or-Enhanced-Logics.md --- docs/New-or-Enhanced-Logics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index da62cc4c44..6767ce137c 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -1315,7 +1315,7 @@ AttackMove.IgnoreWeaponCheck=false ; boolean ### Attack non-threatening structures - You can now freely configure whether units can automatically target non-threatening structures. - - `AutoTarget.NoThreatBuildings` affects player-controlled units, `AutoTargetAI.NoThreatBuildings` affects other units.. + - `AutoTarget.NoThreatBuildings` affects player-controlled units, `AutoTargetAI.NoThreatBuildings` affects other units. In `rulesmd.ini`: ```ini