Allow one leader to die with > 3 players

~ Part 1 ~

That by itself is not yet useful, as the unit will be dead,
and have no recruits in the next level.

As of string freeze. add only an image and no message.
This commit is contained in:
Severin Glöckner 2021-10-22 22:13:19 +02:00
parent 2183cd5b8f
commit 7609071a0f

View file

@ -6,7 +6,7 @@ local strings = {
promotion = _ "Dont lose heart comrades, we can still win this battle."
}
-- when a leader dies, take a commonder and make him the leader.
-- when a leader dies, take a commander and make him the leader.
on_event("die", function(cx)
local u = wesnoth.units.get(cx.x1, cx.y1)
if (not u) or (not u:matches({ canrecruit = true })) then
@ -25,8 +25,18 @@ on_event("die", function(cx)
id = commander.id,
message = strings.promotion
}
else
if u.side < 4 then
elseif u.side <= wml.variables.wc2_player_count or 3 then
if wml.variables.wc2_player_count or 3 > 3 and not wml.variables.wc2_defeated_side then
-- For 4p, one player is allowed to be defeated, without all players losing the scenario.
wml.variables.wc2_defeated_side = u.side
wml.variables.wc2_player_count = wml.variables.wc2_player_count - 1
wesnoth.wml_actions.item {
x = u.x,
y = u.y,
image = "items/bones.png",
z_order = 15,
}
else
wesnoth.wml_actions.message {
side = "1,2,3",
message = strings.defeat