share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
changeset 12628 96e30c42c318
parent 12422 959d1f4dff25
child 12812 59cb9bd8331c
equal deleted inserted replaced
12627:32fe36654299 12628:96e30c42c318
   816   local factor = 1 * strength
   816   local factor = 1 * strength
   817   local msgColor = GetClanColor(GetHogClan(CurHog))
   817   local msgColor = GetClanColor(GetHogClan(CurHog))
   818   PlaySound(sndShotgunReload)
   818   PlaySound(sndShotgunReload)
   819 
   819 
   820   if GetRandom(100) < emptyCrateChance then
   820   if GetRandom(100) < emptyCrateChance then
   821     AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
   821     if IsHogLocal(CurHog) then
       
   822       AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
       
   823     end
   822     return
   824     return
   823   elseif GetRandom(100) < bonusCrateChance then
   825   elseif GetRandom(100) < bonusCrateChance then
   824     factor = 2 * strength
   826     factor = 2 * strength
   825   end
   827   end
   826 
   828 
   842 
   844 
   843     randIndex = GetRandom(table.getn(possibleWeapons)) +1
   845     randIndex = GetRandom(table.getn(possibleWeapons)) +1
   844     randAmmo = possibleWeapons[randIndex]
   846     randAmmo = possibleWeapons[randIndex]
   845   end
   847   end
   846 
   848 
   847   AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
       
   848 
       
   849   AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor)
   849   AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor)
   850   local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
   850   if IsHogLocal(CurHog) then
   851   -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
   851     AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
   852   SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor)
   852     local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
       
   853     SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor)
       
   854   end
   853 end
   855 end
   854 --[[
   856 --[[
   855  : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant.
   857  : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant.
   856  :
   858  :
   857  : Has a 7% chance to be empty.
   859  : Has a 7% chance to be empty.
   860   local factor = 1 * strength
   862   local factor = 1 * strength
   861   local msgColor = GetClanColor(GetHogClan(CurHog))
   863   local msgColor = GetClanColor(GetHogClan(CurHog))
   862   PlaySound(sndShotgunReload)
   864   PlaySound(sndShotgunReload)
   863 
   865 
   864   if GetRandom(100) < emptyCrateChance then
   866   if GetRandom(100) < emptyCrateChance then
   865     AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
   867     if IsHogLocal(CurHog) then
       
   868       AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
       
   869     end
   866     return
   870     return
   867   elseif GetRandom(100) < bonusCrateChance then
   871   elseif GetRandom(100) < bonusCrateChance then
   868     factor = 2 * strength
   872     factor = 2 * strength
   869   end
   873   end
   870 
   874 
   883 
   887 
   884     randIndex = GetRandom(table.getn(possibleHelpers)) +1
   888     randIndex = GetRandom(table.getn(possibleHelpers)) +1
   885     randUtility = possibleHelpers[randIndex]
   889     randUtility = possibleHelpers[randIndex]
   886   end
   890   end
   887   
   891   
   888   AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
       
   889 
       
   890   AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor)
   892   AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor)
   891   local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
   893   if IsHogLocal(CurHog) then
   892   -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
   894     AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
   893   SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor)
   895     local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
       
   896     SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor)
       
   897   end
   894 end
   898 end
   895 
   899 
   896 function onPickupCrate(crate)
   900 function onPickupCrate(crate)
   897   local pos = GetGearPos(crate)
   901   local pos = GetGearPos(crate)
   898 
   902 
  1110         -- Remove the randomized weapon so it cannot be picked up twice
  1114         -- Remove the randomized weapon so it cannot be picked up twice
  1111         table.remove(bonAmmo, randAmmo)
  1115         table.remove(bonAmmo, randAmmo)
  1112 
  1116 
  1113         AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1)
  1117         AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1)
  1114 
  1118 
  1115         local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true)
  1119         if IsHogLocal(CurHog) then
  1116         -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
  1120            local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true)
  1117         SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil)
  1121            SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil)
       
  1122         end
  1118 
  1123 
  1119         i = i +1
  1124         i = i +1
  1120       end
  1125       end
  1121     end
  1126     end
  1122 
  1127