share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
changeset 15128 40537955de63
parent 15126 ab21cbb0e3a0
child 15428 c95efbab66e6
equal deleted inserted replaced
15127:f3f09c71ff6c 15128:40537955de63
   263 local highHelpers = {} -- Saves the helpers from kills
   263 local highHelpers = {} -- Saves the helpers from kills
   264 local highSpecialBonus = {amTeleport, amJetpack}
   264 local highSpecialBonus = {amTeleport, amJetpack}
   265 local highSpecialPool = {amExtraDamage, amVampiric}
   265 local highSpecialPool = {amExtraDamage, amVampiric}
   266 
   266 
   267 local kingLinkPerc = 50 -- Percentage of life to share from the team
   267 local kingLinkPerc = 50 -- Percentage of life to share from the team
       
   268 
       
   269 local teamKingsAlive = {} -- whether the king of each team is still alive
   268 
   270 
   269 local pointsWepBase = 5 -- Game start points weapons
   271 local pointsWepBase = 5 -- Game start points weapons
   270 local pointsHlpBase = 2 -- Game start points helpers
   272 local pointsHlpBase = 2 -- Game start points helpers
   271 local pointsKeepPerc = 80 -- Percentage of points to take to next round
   273 local pointsKeepPerc = 80 -- Percentage of points to take to next round
   272 local pointsWepTurn = 5 -- Round bonus points weapons
   274 local pointsWepTurn = 5 -- Round bonus points weapons
   715   end
   717   end
   716 
   718 
   717   if mode == 'king' then
   719   if mode == 'king' then
   718     counter[team]['King'] = 1
   720     counter[team]['King'] = 1
   719     table.insert(group[team], 'King')
   721     table.insert(group[team], 'King')
       
   722     teamKingsAlive[team] = true
   720   end
   723   end
   721 end
   724 end
   722 
   725 
   723 function countTeamHogs(hog)
   726 function countTeamHogs(hog)
   724   local team = GetHogTeamName(hog)
   727   local team = GetHogTeamName(hog)
  1183       if hp ~= nil and hp > 0 then
  1186       if hp ~= nil and hp > 0 then
  1184         SetHealth(hog, 0)
  1187         SetHealth(hog, 0)
  1185       end
  1188       end
  1186     end
  1189     end
  1187   end
  1190   end
       
  1191   teamKingsAlive[team] = false
  1188 
  1192 
  1189   -- We don't use DismissTeam, it causes a lot of problems and nasty side-effects.
  1193   -- We don't use DismissTeam, it causes a lot of problems and nasty side-effects.
  1190 
  1194 
  1191 end
  1195 end
  1192 
  1196 
  1321 function setupHogTurn(hog)
  1325 function setupHogTurn(hog)
  1322   clearHogAmmo(hog)
  1326   clearHogAmmo(hog)
  1323   addTurnAmmo(hog)
  1327   addTurnAmmo(hog)
  1324 end
  1328 end
  1325 
  1329 
       
  1330 function checkKingAlive(gear)
       
  1331   -- This workaround works because in King Mode, we made
       
  1332   -- sure only kings can have the crown.
       
  1333   if GetHogHat(gear) == 'crown' then
       
  1334     teamKingsAlive[getHogInfo(gear, 'team')] = true
       
  1335   end
       
  1336 end
       
  1337 
       
  1338 function killLonelyMinion(gear)
       
  1339   if teamKingsAlive[getHogInfo(gear, 'team')] == false then
       
  1340     SetHealth(gear, 0)
       
  1341   end
       
  1342 end
       
  1343 
  1326 function onEndTurn()
  1344 function onEndTurn()
  1327   if not firstTurnOver then
  1345   if not firstTurnOver then
  1328     firstTurnOver = true
  1346     firstTurnOver = true
  1329   end
  1347   end
  1330   local anyHog = nil
  1348   local anyHog = nil
  1347   end
  1365   end
  1348 
  1366 
  1349   -- When we are on points mode count remaining weapon/helper points
  1367   -- When we are on points mode count remaining weapon/helper points
  1350   if mode == 'points' and GetHealth(CurHog) ~= nil then
  1368   if mode == 'points' and GetHealth(CurHog) ~= nil then
  1351     savePoints(CurHog)
  1369     savePoints(CurHog)
       
  1370   end
       
  1371 
       
  1372   -- In King Mode, kill all hogs without king in their team
       
  1373   if mode == 'king' then
       
  1374     runOnGears(checkKingAlive)
       
  1375     runOnGears(killLonelyMinion)
  1352   end
  1376   end
  1353 end
  1377 end
  1354 
  1378 
  1355 function savePoints(hog)
  1379 function savePoints(hog)
  1356   local team = getHogInfo(hog, 'team')
  1380   local team = getHogInfo(hog, 'team')