diff --git a/CREDITS.md b/CREDITS.md index e1f85a5f48..5d9ea011ce 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -737,6 +737,7 @@ This page lists all the individual contributions to the project by their author. - Separately define the global default values of TerrainTypes' `IsPassable` and `CanBeBuiltOn` based on `SpawnsTiberium` - 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 - **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 99cd132375..96f1fb60ab 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -1361,6 +1361,19 @@ In `rulesmd.ini`: DeployFireDelay= ; integer, default value ranges from 14 to 16 ``` +### Disable AlphaImage during Buildup + +- Now you can disable AlphaImage before the building is completed. + +In `rulesmd.ini`: +```ini +[AudioVisual] +NoAlphaImageOnBuildup=false ; boolean + +[SOMEBUILDING] ; BuildingType +NoAlphaImageOnBuildup= ; boolean, defaults to [AudioVisual] -> NoAlphaImageOnBuildup +``` + ### Disable `DamageSound` - Now you can disable `DamageSound` of a building. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 5ed4613f13..3f918553c5 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -663,6 +663,7 @@ HideShakeEffects=false ; boolean - [Allow the unit to stop immediately if the target enters the range during ApproachTarget](Fixed-or-Improved-Logics.md#stop-immediately-if-the-target-enters-the-range-during-approachtarget) (by TaranDahl) - [Allow the unit to keep pursuing the target during ApproachTarget](Fixed-or-Improved-Logics.md#keep-pursuing-the-target-during-approachtarget) (by TaranDahl) - [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) #### 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/src/Ext/BuildingType/Body.cpp b/src/Ext/BuildingType/Body.cpp index 8db74c6279..a4fbc51d69 100644 --- a/src/Ext/BuildingType/Body.cpp +++ b/src/Ext/BuildingType/Body.cpp @@ -217,6 +217,7 @@ void BuildingTypeExt::LoadFromINIFile(CCINIClass* const pINI) this->Units_UseRepairCost.Read(exINI, pSection, "Units.UseRepairCost"); this->NoBuildAreaOnBuildup.Read(exINI, pSection, "NoBuildAreaOnBuildup"); + this->NoAlphaImageOnBuildup.Read(exINI, pSection, "NoAlphaImageOnBuildup"); this->Adjacent_Allowed.Read(exINI, pSection, "Adjacent.Allowed"); this->Adjacent_Disallowed.Read(exINI, pSection, "Adjacent.Disallowed"); this->Adjacent_Disallowed_Prohibit.Read(exINI, pSection, "Adjacent.Disallowed.Prohibit"); @@ -410,6 +411,7 @@ void BuildingTypeExt::Serialize(T& Stm) .Process(this->Units_RepairPercent) .Process(this->Units_UseRepairCost) .Process(this->NoBuildAreaOnBuildup) + .Process(this->NoAlphaImageOnBuildup) .Process(this->Adjacent_Allowed) .Process(this->Adjacent_Disallowed) .Process(this->Adjacent_Disallowed_Prohibit) diff --git a/src/Ext/BuildingType/Body.h b/src/Ext/BuildingType/Body.h index 79aa55352c..83bf64d7f1 100644 --- a/src/Ext/BuildingType/Body.h +++ b/src/Ext/BuildingType/Body.h @@ -81,6 +81,7 @@ class BuildingTypeExt final : public TechnoTypeExt Nullable Units_UseRepairCost; Valueable NoBuildAreaOnBuildup; + Nullable NoAlphaImageOnBuildup; ValueableVector Adjacent_Allowed; ValueableVector Adjacent_Disallowed; Valueable Adjacent_Disallowed_Prohibit; @@ -190,6 +191,7 @@ class BuildingTypeExt final : public TechnoTypeExt , Units_RepairPercent {} , Units_UseRepairCost {} , NoBuildAreaOnBuildup { false } + , NoAlphaImageOnBuildup {} , Adjacent_Allowed {} , Adjacent_Disallowed {} , Adjacent_Disallowed_Prohibit { false } diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 642cd2561a..271a06fe00 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -599,6 +599,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->ApproachTarget_StopWhenInRange.Read(exINI, GameStrings::General, "AttackMove.StopWhenTargetAcquired"); this->ApproachTarget_StopWhenInRange.Read(exINI, GameStrings::General, "ApproachTarget.StopWhenInRange"); + this->NoAlphaImageOnBuildup.Read(exINI, GameStrings::AudioVisual, "NoAlphaImageOnBuildup"); + // Section AITargetTypes int itemsCount = pINI->GetKeyCount("AITargetTypes"); for (int i = 0; i < itemsCount; ++i) @@ -1069,6 +1071,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->PoseDir_Production) .Process(this->PoseDir_Field) .Process(this->ApproachTarget_StopWhenInRange) + .Process(this->NoAlphaImageOnBuildup) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 066223dc2c..5f295408eb 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -527,6 +527,8 @@ class RulesExt Valueable ApproachTarget_StopWhenInRange; + Valueable NoAlphaImageOnBuildup; + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , HarvesterDumpAmount { 0.0f } @@ -988,6 +990,8 @@ class RulesExt , PoseDir_Field{} , ApproachTarget_StopWhenInRange { false } + + , NoAlphaImageOnBuildup { false } { } virtual ~ExtData() = default; diff --git a/src/Misc/Hooks.AlphaImage.cpp b/src/Misc/Hooks.AlphaImage.cpp index bd7252fc0a..ff8b6795e2 100644 --- a/src/Misc/Hooks.AlphaImage.cpp +++ b/src/Misc/Hooks.AlphaImage.cpp @@ -72,8 +72,13 @@ static void __fastcall UpdateAlphaShape(ObjectClass* pSource) const auto pBuilding = abstract_cast(pSource); - if (pBuilding && !inactive && pBuilding->GetCurrentMission() != Mission::Construction) - inactive |= !pBuilding->IsPowerOnline() || BuildingExt::Fetch(pBuilding)->LimboID != -1; + if (pBuilding && !inactive) + { + if (pBuilding->GetCurrentMission() != Mission::Construction) + inactive |= !pBuilding->IsPowerOnline() || BuildingExt::Fetch(pBuilding)->LimboID != -1; + else if (BuildingTypeExt::Fetch(pBuilding->Type)->NoAlphaImageOnBuildup.Get(RulesExt::Global()->NoAlphaImageOnBuildup)) + inactive = true; + } auto& alphaExt = *AresFunctions::AlphaExtMap; @@ -115,3 +120,18 @@ DEFINE_HOOK(0x5F3E78, ObjectClass_AI_UpdateAlphaShape, 0x6) return 0; } + +DEFINE_HOOK(0x5F5045, ObjectClass_Place_NoAlphaImageOnBuildup, 0x6) +{ + GET(ObjectTypeClass* const, pType, EBX); + + if (const auto pBuildingType = abstract_cast(pType)) + { + if (BuildingTypeExt::Fetch(pBuildingType)->NoAlphaImageOnBuildup.Get(RulesExt::Global()->NoAlphaImageOnBuildup)) + return 0x5F514B; // jump past the AlphaShape creation block (the `jz` skip target) + } + + R->EAX(pType ? pType->AlphaImage : nullptr); + + return 0; +}