Skip to content

Commit ab266fa

Browse files
authored
[Minor] Fix create building map trigger action (#1848)
Fixes an issue with map trigger action 125 causing buildups to play incorrectly sometimes. A separate issue remains where any building that is mid-buildup will interrupt buildup if it changes owner but this is not exclusive to buildings created through the trigger action. Also re-enabled use fo the third parameter but this time it turns buildups off even if otherwise available if set to != 0.
1 parent 5764059 commit ab266fa

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ This page lists all the individual contributions to the project by their author.
277277
- Restored parabombs
278278
- Delayed fire weapons
279279
- Changes / fixes to `Vertical` projectile logic and customizing projectile initial facing behavior
280+
- Bugfixes to map trigger action `125 Create Building At`
280281
- **Morton (MortonPL)**:
281282
- `XDrawOffset` for animations
282283
- Shield passthrough & absorption

docs/Whats-New.md

Lines changed: 4 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
@@ -478,6 +480,7 @@ Phobos fixes:
478480
- Fixed `AmbientDamage.Warhead` not working for waves (by Starkku)
479481
- Fixed `SkirmishUnlimitedColors` not being checked if Phobos runs without Ares active (by Starkku)
480482
- Fixed number of `*.ApplyFirepowerMult` options (f.ex anim damage, crit) ignoring veterancy firepower modifier (by Starkku)
483+
- Fixed map trigger action `125 Build At...` not always playing buildups correctly (by Starkku)
481484
482485
Fixes / interactions with other extensions:
483486
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)

src/Ext/TAction/Hooks.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,50 @@ 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);
36-
GET(BuildingTypeClass*, pBldType, ECX);
39+
GET(BuildingTypeClass*, pBuildingType, 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
42-
bool bCreated = false;
43-
if (auto pBld = static_cast<BuildingClass*>(pBldType->CreateObject(pHouse)))
43+
const bool playBuildup = pThis->Param3 == 0 && pBuildingType->LoadBuildup();
44+
bool created = false;
45+
46+
if (auto pBuilding = static_cast<BuildingClass*>(pBuildingType->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-
}
48+
// Set before unlimbo cause otherwise it will call BuildingClass::Place.
49+
pBuilding->QueueMission(Mission::Construction, false);
50+
pBuilding->NextMission();
5551

56-
if (!pBld->ForceCreate(coord))
52+
if (!pBuilding->ForceCreate(coord))
5753
{
58-
pBld->UnInit();
54+
pBuilding->UnInit();
5955
}
6056
else
6157
{
62-
if (!bPlayBuildUp)
63-
pBld->Place(false);
64-
65-
pBld->IsReadyToCommence = true;
58+
// Reset mission and build state if we're not going to play buildup afterwards.
59+
if (!playBuildup)
60+
{
61+
pBuilding->BeginMode(BStateType::Idle);
62+
pBuilding->QueueMission(Mission::Guard, false);
63+
pBuilding->NextMission();
64+
pBuilding->Place(false); // Manually call this now.
65+
}
6666

6767
if (SessionClass::IsCampaign() && !pHouse->IsControlledByHuman())
68-
pBld->ShouldRebuild = pThis->Param4 > 0;
68+
pBuilding->ShouldRebuild = pThis->Param4 > 0;
6969

70-
bCreated = true;
70+
created = true;
7171
}
7272
}
7373

74-
R->AL(bCreated);
74+
R->AL(created);
7575
return 0x6E42C1;
7676
}
7777

0 commit comments

Comments
 (0)