From 43bf0fac338b9bcbcb7d1500efc085509587839b Mon Sep 17 00:00:00 2001 From: Starkku Date: Tue, 9 Sep 2025 14:38:09 +0300 Subject: [PATCH 1/3] Fix create building map trigger action --- docs/Whats-New.md | 4 +++- src/Ext/TAction/Hooks.cpp | 31 ++++++++++++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 432a86fe92..87eb995f71 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -10,6 +10,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo] ### From vanilla +- Map trigger action `125 Build At...` now plays buildup by default if available, this can be toggled off using the third parameter (values other than 0). See [required changes for `fadata.ini`](#for-map-editor-final-alert-2) on how to enable the parameter in map editor. - `IsSimpleDeployer` units now obey deploying facing constraint even without deploying animation. To disable this, set `DeployDir` (defaults to `[AudioVisual] -> DeployDir`) to -1. - `Vertical=true` projectiles now default to completely downwards initial trajectory/facing regardless of if their projectile image has `Voxel=true` or not. This behavior can be reverted by setting `VerticalInitialFacing=false` on projectile in `rulesmd.ini`. - `Vertical=true` projectiles no longer move horizontally if fired by aircraft by default. To re-enable this behaviour set `Vertical.AircraftFix=false` on the projectile. @@ -129,6 +130,7 @@ HideLightFlashEffects=false ; boolean 102=Horizontal position,0 103=Vertical position,0 104=Banner ID,0 + 105=No buildup,0 [EventsRA2] 500=Local variable is greater than,48,6,0,0,[LONG DESC],0,1,500,1 @@ -176,7 +178,7 @@ HideLightFlashEffects=false ; boolean [ActionsRA2] 41=Play animation at a waypoint...,0,25,69,0,0,0,1,0,0,[LONG DESC].,0,1,41 - 125=Build at...,-10,47,0,65,0,0,1,0,0,[LONG DESC],0,1,125 + 125=Build at...,-10,47,105,65,0,0,1,0,0,[LONG DESC],0,1,125 500=Save game,-4,13,0,0,0,0,0,0,0,[LONG DESC],0,1,500,1 501=Edit variable,0,56,55,6,54,0,0,0,0,[LONG DESC],0,1,501,1 502=Generate random number,0,56,57,58,54,0,0,0,0,[LONG DESC],0,1,502,1 diff --git a/src/Ext/TAction/Hooks.cpp b/src/Ext/TAction/Hooks.cpp index bbfd31748f..a00e75d2d3 100644 --- a/src/Ext/TAction/Hooks.cpp +++ b/src/Ext/TAction/Hooks.cpp @@ -28,8 +28,11 @@ DEFINE_HOOK(0x6DD8B0, TActionClass_Execute, 0x6) return handled ? 0x6DD910 : 0; } -// TODO: Sometimes Buildup anims plays while the building image is already there in faster gamespeed. // Bugfix: TAction 125 Build At could neither display the buildups nor be AI-repairable in singleplayer mode +// Sep 9, 2025 - Starkku: Fixed issues with buildups potentially ending up in infinite loops etc. +// A separate issue remains where buildup sequence will interrupt if building's house changes mid-buildup, +// but this applies to all buildings and not just ones created through the trigger. +// Also restored Param3 to control the buildup display, only this time it is inverted (set to >0 to disable buildups). DEFINE_HOOK(0x6E427D, TActionClass_CreateBuildingAt, 0x9) { GET(TActionClass*, pThis, ESI); @@ -37,32 +40,26 @@ DEFINE_HOOK(0x6E427D, TActionClass_CreateBuildingAt, 0x9) GET(HouseClass*, pHouse, EDI); REF_STACK(CoordStruct, coord, STACK_OFFSET(0x24, -0x18)); - const bool bPlayBuildUp = pBldType->LoadBuildup(); - //Param3 can be used for other purposes in the future + const bool bPlayBuildUp = pThis->Param3 == 0 && pBldType->LoadBuildup(); bool bCreated = false; + if (auto pBld = static_cast(pBldType->CreateObject(pHouse))) { - if (bPlayBuildUp) - { - pBld->BeginMode(BStateType::Construction); - pBld->QueueMission(Mission::Construction, false); - } - else - { - pBld->BeginMode(BStateType::Idle); - pBld->QueueMission(Mission::Guard, false); - } - if (!pBld->ForceCreate(coord)) { pBld->UnInit(); } else { - if (!bPlayBuildUp) + if (bPlayBuildUp) + { + pBld->ForceMission(Mission::Construction); + } + else + { + pBld->EnterIdleMode(false, false); pBld->Place(false); - - pBld->IsReadyToCommence = true; + } if (SessionClass::IsCampaign() && !pHouse->IsControlledByHuman()) pBld->ShouldRebuild = pThis->Param4 > 0; From 638d6a39f11ed8f390340a025d6cbf06c39d5819 Mon Sep 17 00:00:00 2001 From: Starkku Date: Tue, 9 Sep 2025 16:40:28 +0300 Subject: [PATCH 2/3] Fix some residual problems --- src/Ext/TAction/Hooks.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Ext/TAction/Hooks.cpp b/src/Ext/TAction/Hooks.cpp index a00e75d2d3..48e4136248 100644 --- a/src/Ext/TAction/Hooks.cpp +++ b/src/Ext/TAction/Hooks.cpp @@ -36,39 +36,42 @@ DEFINE_HOOK(0x6DD8B0, TActionClass_Execute, 0x6) DEFINE_HOOK(0x6E427D, TActionClass_CreateBuildingAt, 0x9) { GET(TActionClass*, pThis, ESI); - GET(BuildingTypeClass*, pBldType, ECX); + GET(BuildingTypeClass*, pBuildingType, ECX); GET(HouseClass*, pHouse, EDI); REF_STACK(CoordStruct, coord, STACK_OFFSET(0x24, -0x18)); - const bool bPlayBuildUp = pThis->Param3 == 0 && pBldType->LoadBuildup(); - bool bCreated = false; + const bool playBuildup = pThis->Param3 == 0 && pBuildingType->LoadBuildup(); + bool created = false; - if (auto pBld = static_cast(pBldType->CreateObject(pHouse))) + if (auto pBuilding = static_cast(pBuildingType->CreateObject(pHouse))) { - if (!pBld->ForceCreate(coord)) + // Set before unlimbo cause otherwise it will call BuildingClass::Place. + pBuilding->QueueMission(Mission::Construction, false); + pBuilding->NextMission(); + + if (!pBuilding->ForceCreate(coord)) { - pBld->UnInit(); + pBuilding->UnInit(); } else { - if (bPlayBuildUp) - { - pBld->ForceMission(Mission::Construction); - } - else + // Reset mission and build state if we're not going to play buildup afterwards. + if (!playBuildup) { - pBld->EnterIdleMode(false, false); - pBld->Place(false); + pBuilding->BeginMode(BStateType::Idle); + pBuilding->QueueMission(Mission::Guard, false); + pBuilding->NextMission(); + pBuilding->Place(false); // Manually call this now. } if (SessionClass::IsCampaign() && !pHouse->IsControlledByHuman()) - pBld->ShouldRebuild = pThis->Param4 > 0; + pBuilding->ShouldRebuild = pThis->Param4 > 0; - bCreated = true; + created = true; } } - R->AL(bCreated); + R->AL(created); return 0x6E42C1; } From 9444c7657c8708edd613d06b11611e1b281dbd4e Mon Sep 17 00:00:00 2001 From: Starkku Date: Thu, 11 Sep 2025 13:49:55 +0300 Subject: [PATCH 3/3] Add credits and changelog --- CREDITS.md | 1 + docs/Whats-New.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 599ca1b29a..ce1028f046 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -277,6 +277,7 @@ This page lists all the individual contributions to the project by their author. - Restored parabombs - Delayed fire weapons - Changes / fixes to `Vertical` projectile logic and customizing projectile initial facing behavior + - Bugfixes to map trigger action `125 Create Building At` - **Morton (MortonPL)**: - `XDrawOffset` for animations - Shield passthrough & absorption diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 87eb995f71..0da0a637ee 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -480,6 +480,7 @@ Phobos fixes: - Fixed `AmbientDamage.Warhead` not working for waves (by Starkku) - Fixed `SkirmishUnlimitedColors` not being checked if Phobos runs without Ares active (by Starkku) - Fixed number of `*.ApplyFirepowerMult` options (f.ex anim damage, crit) ignoring veterancy firepower modifier (by Starkku) +- Fixed map trigger action `125 Build At...` not always playing buildups correctly (by Starkku) Fixes / interactions with other extensions: - `Convert.Deploy` displays 'NoDeploy' cursor if the new type is not allowed to move to the cell due to `SpeedType` etc. (by Starkku)