Skip to content

Commit 43bf0fa

Browse files
committed
Fix create building map trigger action
1 parent 8c9dcff commit 43bf0fa

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

docs/Whats-New.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
1010

1111
### From vanilla
1212

13+
- 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.
1314
- `IsSimpleDeployer` units now obey deploying facing constraint even without deploying animation. To disable this, set `DeployDir` (defaults to `[AudioVisual] -> DeployDir`) to -1.
1415
- `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`.
1516
- `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
129130
102=Horizontal position,0
130131
103=Vertical position,0
131132
104=Banner ID,0
133+
105=No buildup,0
132134
133135
[EventsRA2]
134136
500=Local variable is greater than,48,6,0,0,[LONG DESC],0,1,500,1
@@ -176,7 +178,7 @@ HideLightFlashEffects=false ; boolean
176178
177179
[ActionsRA2]
178180
41=Play animation at a waypoint...,0,25,69,0,0,0,1,0,0,[LONG DESC].,0,1,41
179-
125=Build at...,-10,47,0,65,0,0,1,0,0,[LONG DESC],0,1,125
181+
125=Build at...,-10,47,105,65,0,0,1,0,0,[LONG DESC],0,1,125
180182
500=Save game,-4,13,0,0,0,0,0,0,0,[LONG DESC],0,1,500,1
181183
501=Edit variable,0,56,55,6,54,0,0,0,0,[LONG DESC],0,1,501,1
182184
502=Generate random number,0,56,57,58,54,0,0,0,0,[LONG DESC],0,1,502,1

src/Ext/TAction/Hooks.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,38 @@ DEFINE_HOOK(0x6DD8B0, TActionClass_Execute, 0x6)
2828
return handled ? 0x6DD910 : 0;
2929
}
3030

31-
// TODO: Sometimes Buildup anims plays while the building image is already there in faster gamespeed.
3231
// Bugfix: TAction 125 Build At could neither display the buildups nor be AI-repairable in singleplayer mode
32+
// Sep 9, 2025 - Starkku: Fixed issues with buildups potentially ending up in infinite loops etc.
33+
// A separate issue remains where buildup sequence will interrupt if building's house changes mid-buildup,
34+
// but this applies to all buildings and not just ones created through the trigger.
35+
// Also restored Param3 to control the buildup display, only this time it is inverted (set to >0 to disable buildups).
3336
DEFINE_HOOK(0x6E427D, TActionClass_CreateBuildingAt, 0x9)
3437
{
3538
GET(TActionClass*, pThis, ESI);
3639
GET(BuildingTypeClass*, pBldType, ECX);
3740
GET(HouseClass*, pHouse, EDI);
3841
REF_STACK(CoordStruct, coord, STACK_OFFSET(0x24, -0x18));
3942

40-
const bool bPlayBuildUp = pBldType->LoadBuildup();
41-
//Param3 can be used for other purposes in the future
43+
const bool bPlayBuildUp = pThis->Param3 == 0 && pBldType->LoadBuildup();
4244
bool bCreated = false;
45+
4346
if (auto pBld = static_cast<BuildingClass*>(pBldType->CreateObject(pHouse)))
4447
{
45-
if (bPlayBuildUp)
46-
{
47-
pBld->BeginMode(BStateType::Construction);
48-
pBld->QueueMission(Mission::Construction, false);
49-
}
50-
else
51-
{
52-
pBld->BeginMode(BStateType::Idle);
53-
pBld->QueueMission(Mission::Guard, false);
54-
}
55-
5648
if (!pBld->ForceCreate(coord))
5749
{
5850
pBld->UnInit();
5951
}
6052
else
6153
{
62-
if (!bPlayBuildUp)
54+
if (bPlayBuildUp)
55+
{
56+
pBld->ForceMission(Mission::Construction);
57+
}
58+
else
59+
{
60+
pBld->EnterIdleMode(false, false);
6361
pBld->Place(false);
64-
65-
pBld->IsReadyToCommence = true;
62+
}
6663

6764
if (SessionClass::IsCampaign() && !pHouse->IsControlledByHuman())
6865
pBld->ShouldRebuild = pThis->Param4 > 0;

0 commit comments

Comments
 (0)