diff --git a/CREDITS.md b/CREDITS.md index e29cc7ea90..2eded00650 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -739,6 +739,7 @@ This page lists all the individual contributions to the project by their author. - Remove the restriction that prohibits InfantryTypes from using the InitialPayload logic - Add `ammo`, `health`, `mission`, `landtype` and `sequence` conditions to `DiscardOn` - Disable AlphaImage during Buildup + - Allow customizing the default value of `[Warhead] -> PreventScatter` via `[CombatDamage] -> Warhead.PreventScatter` - **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 f3044a53d2..4c24525455 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -382,6 +382,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed the issue of Ares' EMP not suspending the production of AI factories. - Removed the restriction that prohibits InfantryTypes from using the InitialPayload logic. - `ProjectileRange` now has weapon range modifiers applied to it if greater than 0 and unless `ProjectileRange.ApplyModifiers` is set to false on the WeaponType. +- Allowed customizing the default value of `[Warhead] -> PreventScatter` via `[CombatDamage] -> Warhead.PreventScatter`. ## Newly added global settings @@ -525,22 +526,25 @@ In `rulesmd.ini`: AdjacentWallDamage=200 ; integer ``` -### Customize the global default values of some vanilla flags +### Customize the global default values of some vanilla/Ares flags -- The following flags supplement definitions for flags that do not have global default values in vanilla. +- The following flags supplement definitions for flags that do not have global default values in vanilla/Ares. ```{hint} -Unless otherwise specified, the definition is the same as the name of the micro-level definition flag. +Unless otherwise specified, after removing the last dot and everything before it, the definition is the same as the name of the micro-level definition flag. ``` In `rulesmd.ini`: ```ini [General] -DefaultToGuardArea=false ; boolean +DefaultToGuardArea=false ; boolean + +[CombatDamage] +Warhead.PreventScatter=false ; boolean [AudioVisual] -LeptonMindControlOffset=70 ; integer, in leptons -MindControlRingOffset=140 ; integer, in leptons +LeptonMindControlOffset=70 ; integer, in leptons +MindControlRingOffset=140 ; integer, in leptons ``` ### Customizing effect of level lighting on air units diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 33d36a170a..1244b7256d 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -665,6 +665,7 @@ HideShakeEffects=false ; boolean - [Customize whether warhead can prevent crew escape from techno](New-or-Enhanced-Logics.md#customize-whether-warhead-can-prevent-crew-escape-from-techno) (by NetsuNegi) - [Disable AlphaImage during Buildup](Fixed-or-Improved-Logics.md#disable-alphaimage-during-buildup) (by Noble_Fish) - [Reload speed adjustment on promotion](New-or-Enhanced-Logics.md#reload-speed-adjustment-on-promotion) (by Nuke) +- Allowed customizing the default value of `[Warhead] -> PreventScatter` via `[CombatDamage] -> Warhead.PreventScatter` (by Noble_Fish) #### Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) diff --git a/docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po b/docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po index b87fd5060a..1acc98e0ae 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po +++ b/docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po @@ -2168,18 +2168,18 @@ msgstr "" msgid "Now you can customize that damage by using the following flag." msgstr "现在你可以使用下面的标签自定义这个杀伤值。" -msgid "Customize the global default values of some vanilla flags" -msgstr "自定义部分原版语句的全局默认值" +msgid "Customize the global default values of some vanilla/Ares flags" +msgstr "自定义部分原版/Ares 语句的全局默认值" msgid "" "The following flags supplement definitions for flags that do not have " -"global default values in vanilla." -msgstr "以下语句为原版中没有全局默认值的语句补充了默认值定义。" +"global default values in vanilla/Ares." +msgstr "以下语句为原版/Ares 中没有全局默认值的语句补充了默认值定义。" msgid "" -"Unless otherwise specified, the definition is the same as the name of the" +"Unless otherwise specified, after removing the last dot and everything before it, the definition is the same as the name of the" " micro-level definition flag." -msgstr "除非特别说明,默认与微观定义语句名称相同。" +msgstr "除非特别说明,去掉最后一个 `.` 及之前的内容后,默认与微观定义语句名称相同。" msgid "Customizing effect of level lighting on air units" msgstr "自定义光照等级对空中单位的影响" diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 66e0d35ed4..e0d7f53ac5 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -609,6 +609,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->NoAlphaImageOnBuildup.Read(exINI, GameStrings::AudioVisual, "NoAlphaImageOnBuildup"); this->ReadyToNextMission_MovingCheck.Read(exINI, GameStrings::General, "ReadyToNextMission.MovingCheck"); + this->Warhead_PreventScatter.Read(exINI, GameStrings::CombatDamage, "Warhead.PreventScatter"); + // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); for (int i = 0; i < itemsCount; ++i) @@ -1084,6 +1086,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->ApproachTarget_StopWhenInRange) .Process(this->NoAlphaImageOnBuildup) .Process(this->ReadyToNextMission_MovingCheck) + .Process(this->Warhead_PreventScatter) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 58db82c07f..076d0d2ee6 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -533,6 +533,8 @@ class RulesExt Valueable NoAlphaImageOnBuildup; + Valueable Warhead_PreventScatter; + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , HarvesterDumpAmount { 0.0f } @@ -1000,6 +1002,7 @@ class RulesExt , NoAlphaImageOnBuildup { false } , ReadyToNextMission_MovingCheck { false } + , Warhead_PreventScatter { false } { } virtual ~ExtData() = default; diff --git a/src/Ext/WarheadType/Body.cpp b/src/Ext/WarheadType/Body.cpp index 676af1014b..a279347c60 100644 --- a/src/Ext/WarheadType/Body.cpp +++ b/src/Ext/WarheadType/Body.cpp @@ -486,6 +486,7 @@ void WarheadTypeExt::LoadFromINIFile(CCINIClass* const pINI) this->Malicious.Read(exINI, pSection, "Malicious"); this->Flash_Duration.Read(exINI, pSection, "Flash.Duration"); this->Damage_Deployed.Read(exINI, pSection, "Damage.Deployed"); + this->PreventScatter.Read(exINI, pSection, "PreventScatter"); // List all Warheads here that respect CellSpread // Used in WarheadTypeExt::Detonate @@ -808,6 +809,7 @@ void WarheadTypeExt::Serialize(T& Stm) .Process(this->Malicious) .Process(this->Flash_Duration) .Process(this->Damage_Deployed) + .Process(this->PreventScatter) .Process(this->WasDetonatedOnAllMapObjects) .Process(this->RemainingAnimCreationInterval) diff --git a/src/Ext/WarheadType/Body.h b/src/Ext/WarheadType/Body.h index 89939ca3d9..880101e6e5 100644 --- a/src/Ext/WarheadType/Body.h +++ b/src/Ext/WarheadType/Body.h @@ -278,6 +278,7 @@ class WarheadTypeExt final : public AbstractTypeExt Valueable Malicious; Nullable Flash_Duration; Valueable Damage_Deployed; + Nullable PreventScatter; double Crit_RandomBuffer; double Crit_CurrentChance; @@ -514,6 +515,7 @@ class WarheadTypeExt final : public AbstractTypeExt , Malicious { true } , Flash_Duration {} , Damage_Deployed { 1.0 } + , PreventScatter {} , Crit_RandomBuffer { 0.0 } , Crit_CurrentChance { 0.0 } diff --git a/src/Misc/Hooks.Ares.cpp b/src/Misc/Hooks.Ares.cpp index 1e9d201176..1bed9df103 100644 --- a/src/Misc/Hooks.Ares.cpp +++ b/src/Misc/Hooks.Ares.cpp @@ -4,11 +4,13 @@ #include #include +#include #include #include #include #include #include +#include #include @@ -185,6 +187,17 @@ DEFINE_HOOK(0x440580, BuildingClass_Unlimbo_UnitDeliveryFix, 0x5) _GET_FUNCTION_ADDRESS(RadarJammerClass::Update, AresRadarJammerClass_Update_GetAddr) +static DWORD _cdecl AresPreventScatter_Override(REGISTERS* R) +{ + GET(FootClass* const, pThis, ESI); + GET_STACK(WarheadTypeClass*, pWarhead, 0xD0); + + if (!WarheadTypeExt::Fetch(pWarhead)->PreventScatter.Get(RulesExt::Global()->Warhead_PreventScatter)) + pThis->Scatter(CoordStruct::Empty, true, false); + + return 0x702D11; +} + void Apply_Ares3_0_Patches() { // Abductor fix: @@ -292,6 +305,8 @@ void Apply_Ares3_0_Patches() Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x13FA7, &BuildingExt::UpdateFactoryQueues); Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x4CD9E, &BuildingExt::UpdateFactoryQueues); Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x4CE84, &BuildingExt::UpdateFactoryQueues); + + Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x4ADE0, GET_OFFSET(AresPreventScatter_Override)); } void Apply_Ares3_0p1_Patches() @@ -403,4 +418,6 @@ void Apply_Ares3_0p1_Patches() Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x14537, &BuildingExt::UpdateFactoryQueues); Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x4DA0E, &BuildingExt::UpdateFactoryQueues); Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x4DAF4, &BuildingExt::UpdateFactoryQueues); + + Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x4BA40, GET_OFFSET(AresPreventScatter_Override)); }