# HG changeset patch
# User sheepluva
# Date 1432675793 -7200
# Node ID 7341e0c3f9662c2650f6a25d99d736acca98b676
# Parent  98cab7f366c38e736f7f5cf6e2a75fb80d671e04
LuaAPI: fix OnHogAttack the incorrect AmmoType (amNothing) under certain conditions. Thanks for CheezeMonkey for reporting this

diff -r 98cab7f366c3 -r 7341e0c3f966 hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Wed May 27 10:37:12 2015 -0400
+++ b/hedgewars/uGearsHedgehog.pas	Tue May 26 23:29:53 2015 +0200
@@ -213,6 +213,7 @@
     speech: PVisualGear;
     newGear:  PGear;
     CurWeapon: PAmmo;
+    usedAmmoType: TAmmoType;
     altUse: boolean;
     elastic: hwFloat;
 begin
@@ -222,6 +223,7 @@
 with Gear^,
     Gear^.Hedgehog^ do
         begin
+        usedAmmoType:= CurAmmoType;
         if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstChooseTarget)) = 0) and (((State and gstMoving) = 0)
         or (Power > 0)
         or (CurAmmoType = amTeleport)
@@ -509,7 +511,7 @@
         else
             Message:= Message and (not gmAttack);
 
-    ScriptCall('onHogAttack', ord(CurAmmoType));
+    ScriptCall('onHogAttack', ord(usedAmmoType));
     end; // of with Gear^, Gear^.Hedgehog^ do
 
     TargetPoint.X := NoPointX;