# HG changeset patch # User Wuzzy # Date 1559901349 -7200 # Node ID 40537955de63195dbc1ab0d27fbc21c000e02751 # Parent f3f09c71ff6c312477eb00f5ff215e04a92c1a78 Battalion (King): At end of turn, re-kill all minions without king diff -r f3f09c71ff6c -r 40537955de63 share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua Fri Jun 07 11:35:13 2019 +0200 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua Fri Jun 07 11:55:49 2019 +0200 @@ -266,6 +266,8 @@ local kingLinkPerc = 50 -- Percentage of life to share from the team +local teamKingsAlive = {} -- whether the king of each team is still alive + local pointsWepBase = 5 -- Game start points weapons local pointsHlpBase = 2 -- Game start points helpers local pointsKeepPerc = 80 -- Percentage of points to take to next round @@ -717,6 +719,7 @@ if mode == 'king' then counter[team]['King'] = 1 table.insert(group[team], 'King') + teamKingsAlive[team] = true end end @@ -1185,6 +1188,7 @@ end end end + teamKingsAlive[team] = false -- We don't use DismissTeam, it causes a lot of problems and nasty side-effects. @@ -1323,6 +1327,20 @@ addTurnAmmo(hog) end +function checkKingAlive(gear) + -- This workaround works because in King Mode, we made + -- sure only kings can have the crown. + if GetHogHat(gear) == 'crown' then + teamKingsAlive[getHogInfo(gear, 'team')] = true + end +end + +function killLonelyMinion(gear) + if teamKingsAlive[getHogInfo(gear, 'team')] == false then + SetHealth(gear, 0) + end +end + function onEndTurn() if not firstTurnOver then firstTurnOver = true @@ -1350,6 +1368,12 @@ if mode == 'points' and GetHealth(CurHog) ~= nil then savePoints(CurHog) end + + -- In King Mode, kill all hogs without king in their team + if mode == 'king' then + runOnGears(checkKingAlive) + runOnGears(killLonelyMinion) + end end function savePoints(hog)