share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
changeset 12981 4c7472d3d483
parent 12980 263d006c56a9
child 12982 ba577e0b8c27
equal deleted inserted replaced
12980:263d006c56a9 12981:4c7472d3d483
  1118       end
  1118       end
  1119     end
  1119     end
  1120 
  1120 
  1121     hpDiff = div(deathMaxHP * highEnemyKillHPBonus, 100)
  1121     hpDiff = div(deathMaxHP * highEnemyKillHPBonus, 100)
  1122     newHP = curHP + hpDiff
  1122     newHP = curHP + hpDiff
  1123     SetHealth(CurHog, newHP)
  1123     HealHog(CurHog, newHP)
  1124 
  1124   -- Friendly fire! Punish hog by removing weapons and helpers from pool
  1125     local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) - cratePickupGap, vgtHealthTag, hpDiff, false)
  1125   -- and reduce health
  1126     -- Set Tint
       
  1127     SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurHog)))
       
  1128   -- Friendly fire! Remove all weapons and helpers from pool
       
  1129   else
  1126   else
  1130     highWeapons[CurHog] = {}
  1127     highWeapons[CurHog] = {}
  1131     highHelpers[CurHog] = {}
  1128     highHelpers[CurHog] = {}
  1132 
  1129 
  1133     hpDiff = div(deathMaxHP * highFriendlyKillHPBonus, 100)
  1130     hpDiff = div(deathMaxHP * highFriendlyKillHPBonus, 100)
  1233   ##############################################################################
  1230   ##############################################################################
  1234   ### TURN BASED FUNCTIONS                                                   ###
  1231   ### TURN BASED FUNCTIONS                                                   ###
  1235   ##############################################################################
  1232   ##############################################################################
  1236 ]]--
  1233 ]]--
  1237 
  1234 
  1238 function calcKingHP()
  1235 function calcKingHP(doEffects)
       
  1236   if doEffects == nil then
       
  1237      doEffects = true
       
  1238   end
  1239   local teamKings = {}
  1239   local teamKings = {}
  1240   local teamHealth = {}
  1240   local teamHealth = {}
  1241 
  1241 
  1242   for hog, val in pairs(hogInfo) do
  1242   for hog, val in pairs(hogInfo) do
  1243     local hp = GetHealth(hog)
  1243     local hp = GetHealth(hog)
  1258   end
  1258   end
  1259 
  1259 
  1260   for team, hog in pairs(teamKings) do
  1260   for team, hog in pairs(teamKings) do
  1261     local hp = GetHealth(hog)
  1261     local hp = GetHealth(hog)
  1262     local newHP = div(teamHealth[team] * kingLinkPerc, 100)
  1262     local newHP = div(teamHealth[team] * kingLinkPerc, 100)
  1263     local diff = newHP - hp
       
  1264 
  1263 
  1265     -- Set hitpoints to 1 if no other hog is alive or only has 1 hitpoint
  1264     -- Set hitpoints to 1 if no other hog is alive or only has 1 hitpoint
  1266     if newHP <= 0 then
  1265     if newHP <= 0 then
  1267       newHP = 1
  1266       newHP = 1
  1268       diff = 0
  1267     end
  1269     end
  1268 
  1270 
  1269     local diff = math.abs(newHP - hp)
  1271     if diff < 0 then
  1270 
  1272       diff = -diff
  1271     -- Change HP and do some nice effects
  1273     end
  1272     if newHP ~= hp then
  1274 
  1273         if not doEffects then
  1275     if hp ~= newHP then
  1274             SetHealth(hog, newHP)
  1276       SetHealth(hog, newHP)
  1275         else
  1277       local effect = AddVisualGear(GetX(hog), GetY(hog) - cratePickupGap, vgtHealthTag, diff, false)
  1276             if newHP > hp then
  1278       -- Set Tint
  1277                 HealHog(hog, diff, false)
  1279       SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(hog)))
  1278             elseif newHP < hp then
       
  1279                 SetHealth(hog, newHP)
       
  1280                 if doEffects then
       
  1281                     local effect = AddVisualGear(GetX(hog), GetY(hog) - cratePickupGap, vgtHealthTag, diff, false)
       
  1282                     -- Set Tint
       
  1283                     SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(hog)))
       
  1284                 end
       
  1285             end
       
  1286         end
  1280     end
  1287     end
  1281   end
  1288   end
  1282 end
  1289 end
  1283 
  1290 
  1284 function setupHogTurn(hog)
  1291 function setupHogTurn(hog)
  1604       addTurnAmmo(teamHogs[key][1])
  1611       addTurnAmmo(teamHogs[key][1])
  1605     end
  1612     end
  1606   end
  1613   end
  1607 
  1614 
  1608   if mode == 'king' then
  1615   if mode == 'king' then
  1609     calcKingHP()
  1616     calcKingHP(false)
  1610   end
  1617   end
  1611 
  1618 
  1612   local txt = ''
  1619   local txt = ''
  1613   local icon = 0
  1620   local icon = 0
  1614 
  1621