From c93235bd84fc8686b9d01085e762d7e1512c4fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E7=BA=A2=E7=83=AD=E8=8C=B6?= <335958461@qq.com> Date: Mon, 24 Feb 2025 21:52:04 +0800 Subject: [PATCH] [Vanilla Improvement] No turret unit turn to the target when rearming (#1465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Now vehicles (exclude jumpjets) without turret will attempt to turn to the target while the weapon is cooling down, rather than after the weapon has cooled down, by setting to `NoTurret.TrackTarget` true. In `rulesmd.ini`: ```ini [General] NoTurret.TrackTarget=false ; boolean [SOMEUNIT] ; UnitType NoTurret.TrackTarget= ; boolean, defaults to [General]->NoTurret.TrackTarget ``` --------- Co-authored-by: 航味麻酱 <93972760+TaranDahl@users.noreply.github.com> --- CREDITS.md | 2 ++ docs/Fixed-or-Improved-Logics.md | 15 +++++++++++++++ docs/Whats-New.md | 1 + src/Ext/Rules/Body.cpp | 3 +++ src/Ext/Rules/Body.h | 3 +++ src/Ext/Techno/Hooks.Misc.cpp | 23 +++++++++++++++++++++++ src/Ext/TechnoType/Body.cpp | 5 +++++ src/Ext/TechnoType/Body.h | 4 ++++ 8 files changed, 56 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 20fd5b1985..cb70d9e728 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -388,6 +388,7 @@ This page lists all the individual contributions to the project by their author. - Fix for sidebar not updating queued unit numbers when on hold - New Parabola trajectory - Enhanced Bombard trajectory + - No turret unit turn to the target - **Ollerus** - Build limit group enhancement - Customizable rocker amplitude @@ -407,6 +408,7 @@ This page lists all the individual contributions to the project by their author. - Parasite returning bug fix - Bunkerable checks dehardcode - Prevent the units with locomotors that cause problems from entering the tank bunker + - No turret unit turn to the target - **tyuah8** - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix - **Aephiex** - initial fix for Ares academy not working on the initial payloads of vehicles built from a war factory - **Multfinite** - Allow to toggle main exception handler via command line argument `-ExceptionHandler=boolean` diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index dbda0f5086..0b54915330 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -1339,6 +1339,21 @@ Ammo.AddOnDeploy=0 ; integer Due to technical constraints, units that use `Convert.Deploy` from [Ares’ Type Conversion](https://ares-developers.github.io/Ares-docs/new/typeconversion.html) to change type with `Ammo.AddOnDeploy` will add or substract ammo despite of convertion success. This will also happen when unit exits tank bunker. ``` +### Unit Without Turret Always Turn To Target + +- Now vehicles (exclude jumpjets) without turret will attempt to turn to the target while the weapon is cooling down, rather than after the weapon has cooled down, by setting to `NoTurret.TrackTarget` true. + +In `rulesmd.ini`: +```ini +[General] +NoTurret.TrackTarget=false ; boolean + +[SOMEUNIT] ; UnitType +NoTurret.TrackTarget= ; boolean, defaults to [General]->NoTurret.TrackTarget +```{warning} +Due to technical constraints, units that use `Convert.Deploy` from [Ares’ Type Conversion](https://ares-developers.github.io/Ares-docs/new/typeconversion.html) to change type with `Ammo.AddOnDeploy` will add or substract ammo despite of convertion success. This will also happen when unit exits tank bunker. +``` + ## Veinholes & Weeds ### Veinholes diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 4fe0ac86f4..de27221e80 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -498,6 +498,7 @@ New: - Allow infantry to use land sequences in water (by Starkku) - `` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku) - Allow customizing charge turret delays per burst on a weapon (by Starkku) +- No turret unit turn to the target (by CrimRecya & TaranDahl) - Unit `Speed` setting now accepts floating point values (by Starkku) - Extending `Power` to all TechnoTypes (by Morton) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 38c5130c0c..2d44c88b75 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -215,6 +215,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->UseFixedVoxelLighting.Read(exINI, GameStrings::AudioVisual, "UseFixedVoxelLighting"); + this->NoTurret_TrackTarget.Read(exINI, GameStrings::General, "NoTurret.TrackTarget"); + this->GatherWhenMCVDeploy.Read(exINI, GameStrings::General, "GatherWhenMCVDeploy"); this->AIFireSale.Read(exINI, GameStrings::General, "AIFireSale"); this->AIFireSaleDelay.Read(exINI, GameStrings::General, "AIFireSaleDelay"); @@ -415,6 +417,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->CombatAlert_UseAttackVoice) .Process(this->CombatAlert_UseEVA) .Process(this->UseFixedVoxelLighting) + .Process(this->NoTurret_TrackTarget) .Process(this->GatherWhenMCVDeploy) .Process(this->AIFireSale) .Process(this->AIFireSaleDelay) diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 7f5fc6f240..2cb06e5f33 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -172,6 +172,8 @@ class RulesExt // Nullable> VoxelShadowLightSource; Valueable UseFixedVoxelLighting; + Valueable NoTurret_TrackTarget; + Valueable GatherWhenMCVDeploy; Valueable AIFireSale; Valueable AIFireSaleDelay; @@ -312,6 +314,7 @@ class RulesExt , CombatAlert_UseAttackVoice { true } , CombatAlert_UseEVA { true } , UseFixedVoxelLighting { false } + , NoTurret_TrackTarget { false } , GatherWhenMCVDeploy { true } , AIFireSale { true } , AIFireSaleDelay { 0 } diff --git a/src/Ext/Techno/Hooks.Misc.cpp b/src/Ext/Techno/Hooks.Misc.cpp index 4150eb2b1a..6149d956af 100644 --- a/src/Ext/Techno/Hooks.Misc.cpp +++ b/src/Ext/Techno/Hooks.Misc.cpp @@ -338,6 +338,29 @@ DEFINE_HOOK(0x74691D, UnitClass_UpdateDisguise_EMP, 0x6) #pragma endregion +#pragma region NoTurretUnitAlwaysTurnToTarget + +DEFINE_HOOK(0x7410BB, UnitClass_GetFireError_CheckFacingError, 0x8) +{ + enum { NoNeedToCheck = 0x74132B, ContinueCheck = 0x7410C3 }; + + GET(const FireError, fireError, EAX); + + if (fireError == FireError::OK) + return ContinueCheck; + + GET(UnitClass* const, pThis, ESI); + + const auto pType = pThis->Type; + + if (!TechnoTypeExt::ExtMap.Find(pType)->NoTurret_TrackTarget.Get(RulesExt::Global()->NoTurret_TrackTarget)) + return NoNeedToCheck; + + return (fireError == FireError::REARM && !pType->Turret && !pThis->IsWarpingIn()) ? ContinueCheck : NoNeedToCheck; +} + +#pragma endregion + #pragma region Misc // I must not regroup my forces. diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 345be5f9ff..63b5651ddb 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -461,6 +461,9 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->BuildLimitGroup_ExtraLimit_Nums.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.Nums"); this->BuildLimitGroup_ExtraLimit_MaxCount.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.MaxCount"); this->BuildLimitGroup_ExtraLimit_MaxNum.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.MaxNum"); + + this->NoTurret_TrackTarget.Read(exINI, pSection, "NoTurret.TrackTarget"); + this->Wake.Read(exINI, pSection, "Wake"); this->Wake_Grapple.Read(exINI, pSection, "Wake.Grapple"); this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking"); @@ -844,6 +847,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->BuildLimitGroup_ExtraLimit_MaxCount) .Process(this->BuildLimitGroup_ExtraLimit_MaxNum) + .Process(this->NoTurret_TrackTarget) + .Process(this->Wake) .Process(this->Wake_Grapple) .Process(this->Wake_Sinking) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index f36bbf39b1..cf325654c8 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -233,6 +233,8 @@ class TechnoTypeExt ValueableVector BuildLimitGroup_ExtraLimit_MaxCount; Valueable BuildLimitGroup_ExtraLimit_MaxNum; + Nullable NoTurret_TrackTarget; + Nullable Wake; Nullable Wake_Grapple; Nullable Wake_Sinking; @@ -469,6 +471,8 @@ class TechnoTypeExt , BuildLimitGroup_ExtraLimit_MaxCount {} , BuildLimitGroup_ExtraLimit_MaxNum { 0 } + , NoTurret_TrackTarget {} + , Wake { } , Wake_Grapple { } , Wake_Sinking { }