Skip to content

Commit

Permalink
human mission 10: Convert attacker type with wrapped CreateUnit
Browse files Browse the repository at this point in the history
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.

Closes: Wargus#458
  • Loading branch information
zzam committed Apr 9, 2024
1 parent 970f948 commit 334df1b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions campaigns/human/level10h_c.sms
Expand Up @@ -15,10 +15,10 @@ AddTrigger(
function() return IfRescuedNearUnit("this", ">=", 4, "unit-attack-peasant", "unit-circle-of-power") end,
function() return ActionVictory() end)

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

AddTrigger(
Expand Down Expand Up @@ -166,11 +166,11 @@ DefineAi("hum-10", "*", "hum-10", AiHuman10)

-- Map

Load("campaigns/human/level10h.sms")

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

0 comments on commit 334df1b

Please sign in to comment.