Skip to content

Commit 65c1457

Browse files
zzamJarod42
authored andcommitted
human mission 10: Convert attacker units with wrapped CreateUnit
With the original TransformUnit the unit-peasant become unit-attack-peasant only in GameCycle=2. But the Defeat-Trigger that counts them is already executed in in GameCycle=1. This trigger then counts 0 units of type 'unit-attack-peasant' and the mission is lost. This happens since Wargus/stratagus#626 was merged: b5e5bb0c6a18ccbf ("Merge pull request #626 from zzam/trigger-each-cycle") Before the code was fragile but it worked due to the ordering of triggers. Closes: #458
1 parent 970f948 commit 65c1457

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

campaigns/human/level10h_c.sms

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ AddTrigger(
1515
function() return IfRescuedNearUnit("this", ">=", 4, "unit-attack-peasant", "unit-circle-of-power") end,
1616
function() return ActionVictory() end)
1717

18-
-- If we one of the attack peasants we should rescue dies, we're done
18+
-- If too many of the attack peasants we should rescue die, we're done.
1919
AddTrigger(
2020
function() return (GetPlayerData(4, "UnitTypesCount", "unit-attack-peasant") +
21-
GetPlayerData(GetThisPlayer(), "UnitTypesCount", "unit-attack-peasant")) <= 3 end,
21+
GetPlayerData(GetThisPlayer(), "UnitTypesCount", "unit-attack-peasant")) < 4 end,
2222
function() return ActionDefeat() end)
2323

2424
AddTrigger(
@@ -166,11 +166,11 @@ DefineAi("hum-10", "*", "hum-10", AiHuman10)
166166

167167
-- Map
168168

169-
Load("campaigns/human/level10h.sms")
170-
171-
-- Make the player 4 units attack peasants
172-
for i,unit in ipairs(GetUnits(4)) do
173-
if GetUnitVariable(unit, "Ident") == "unit-peasant" then
174-
TransformUnit(unit, "unit-attack-peasant")
175-
end
169+
local origCreateUnit = CreateUnit
170+
function CreateUnit(type, player, pos)
171+
-- Make the player 4 units attack peasants
172+
if player == 4 and type == "unit-peasant" then type = "unit-attack-peasant" end
173+
return origCreateUnit(type, player, pos)
176174
end
175+
Load("campaigns/human/level10h.sms")
176+
CreateUnit = origCreateUnit

0 commit comments

Comments
 (0)