share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
changeset 14788 458a8c4e65ca
parent 13643 690cc84e9fd6
child 14790 dd4daa216398
equal deleted inserted replaced
14787:cbdfc5b1d5b8 14788:458a8c4e65ca
   942   ### SUDDEN DEATH FUNCTIONS                                                 ###
   942   ### SUDDEN DEATH FUNCTIONS                                                 ###
   943   ##############################################################################
   943   ##############################################################################
   944 ]]--
   944 ]]--
   945 
   945 
   946 function onSuddenDeathDamage(hog)
   946 function onSuddenDeathDamage(hog)
       
   947   if GetEffect(hog, heInvulnerable) ~= 0 then
       
   948     return
       
   949   end
   947   local hp = GetHealth(hog)
   950   local hp = GetHealth(hog)
   948   local maxHp = getHogInfo(hog, 'maxHp')
   951   local maxHp = getHogInfo(hog, 'maxHp')
   949   local newHp = 0
   952   local newHp = 0
   950   local hpDec = 0
   953   local hpDec = 0
   951   local hpPer = div(hp * 100, maxHp)
   954   local hpPer = div(hp * 100, maxHp)
   973     end
   976     end
   974 
   977 
   975     hpDec = hp - newHp
   978     hpDec = hp - newHp
   976 
   979 
   977     SetHealth(hog, newHp)
   980     SetHealth(hog, newHp)
   978     local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false)
   981     if hpDec > 0 then
   979     SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor)
   982       local r = math.random(1, 2)
       
   983       if r == 1 then
       
   984          PlaySound(sndPoisonCough, hog, true)
       
   985       else
       
   986          PlaySound(sndPoisonMoan, hog, true)
       
   987       end
       
   988       local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false)
       
   989       SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor)
       
   990     end
   980   end
   991   end
   981 end
   992 end
   982 
   993 
   983 function onSuddenDeathTurn()
   994 function onSuddenDeathTurn()
   984   runOnGears(onSuddenDeathDamage)
   995   runOnGears(onSuddenDeathDamage)
  1442   CurHog = CurrentHedgehog
  1453   CurHog = CurrentHedgehog
  1443   CurTeam = getHogInfo(CurHog, 'team')
  1454   CurTeam = getHogInfo(CurHog, 'team')
  1444 
  1455 
  1445   if suddenDeath == true then
  1456   if suddenDeath == true then
  1446     onSuddenDeathTurn()
  1457     onSuddenDeathTurn()
  1447   else
       
  1448     local RoundsTillSD = (SuddenDeathTurns+2) - (TotalRounds+1)
       
  1449     -- Show SD reminder every couple of turns, and in the first turn
       
  1450     if (not firstTurnOver) or (RoundsTillSD <= 6) or (RoundsTillSD <= 25 and RoundsTillSD % 5 == 0) or (RoundsTillSD % 10 == 0) then
       
  1451         AddCaption(string.format(loc("Rounds until Sudden Death: %d"), RoundsTillSD), capcolDefault, capgrpGameState)
       
  1452     end
       
  1453   end
  1458   end
  1454 
  1459 
  1455   -- Generate new weapons for last hog if it's still alive
  1460   -- Generate new weapons for last hog if it's still alive
  1456   if LastHog ~= nil and LastHog ~= CurHog then
  1461   if LastHog ~= nil and LastHog ~= CurHog then
  1457     if mode == 'points' then
  1462     if mode == 'points' then