Battalion: Only show collected ammo to local player
authorWuzzy <almikes@aol.com>
Sun, 01 Oct 2017 03:12:56 +0200
changeset 12633 96e30c42c318
parent 12632 32fe36654299
child 12634 be1ee010e30d
Battalion: Only show collected ammo to local player
share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua	Sun Oct 01 02:10:34 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua	Sun Oct 01 03:12:56 2017 +0200
@@ -818,7 +818,9 @@
   PlaySound(sndShotgunReload)
 
   if GetRandom(100) < emptyCrateChance then
-    AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
+    if IsHogLocal(CurHog) then
+      AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
+    end
     return
   elseif GetRandom(100) < bonusCrateChance then
     factor = 2 * strength
@@ -844,12 +846,12 @@
     randAmmo = possibleWeapons[randIndex]
   end
 
-  AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
-
   AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor)
-  local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
-  -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
-  SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor)
+  if IsHogLocal(CurHog) then
+    AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
+    local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
+    SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor)
+  end
 end
 --[[
  : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant.
@@ -862,7 +864,9 @@
   PlaySound(sndShotgunReload)
 
   if GetRandom(100) < emptyCrateChance then
-    AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
+    if IsHogLocal(CurHog) then
+      AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
+    end
     return
   elseif GetRandom(100) < bonusCrateChance then
     factor = 2 * strength
@@ -885,12 +889,12 @@
     randUtility = possibleHelpers[randIndex]
   end
   
-  AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
-
   AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor)
-  local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
-  -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
-  SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor)
+  if IsHogLocal(CurHog) then
+    AddCaption(string.format(loc("+%d ammo"), factor), msgColor, capgrpMessage)
+    local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true)
+    SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor)
+  end
 end
 
 function onPickupCrate(crate)
@@ -1112,9 +1116,10 @@
 
         AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1)
 
-        local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true)
-        -- (vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
-        SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil)
+        if IsHogLocal(CurHog) then
+           local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true)
+           SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil)
+        end
 
         i = i +1
       end