Add Lua callback onHogSwitch
authorWuzzy <Wuzzy2@mail.ru>
Thu, 16 May 2019 20:31:41 +0200
changeset 14997 8c1a8673843f
parent 14996 fdfe8bf91b8b
child 14998 1e21dfd7f9b5
Add Lua callback onHogSwitch
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Thu May 16 19:44:27 2019 +0200
+++ b/ChangeLog.txt	Thu May 16 20:31:41 2019 +0200
@@ -135,6 +135,7 @@
  + Utils library: New calls: getReadableChallengeRecord, updateChallengeRecord, integerSqrt, integerHypotenuse
  + New callback: onGameResult(winningClan): Called when the game ends normally. winningClan = index of winning clan or -1 on draw
  + New callback: onCaseDrop(gear): Called at the point where a crate MIGHT be dropped between turns. Gear is the crate gear or nil
+ + New callback: ooHogSwitch(oldHog): Called when hogs was switched with the “switch hedgehog” utility
  + New callback: onPreciseLocal(): Called when precise key is pressed client-side
  + SendStat extension: Option to use predefined modes with siPointType, like "!POINTS" or "!TIME"
  + SimpleMission: Add isMissionTeam attribute for teams
--- a/hedgewars/uGearsHandlersMess.pas	Thu May 16 19:44:27 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu May 16 20:31:41 2019 +0200
@@ -3338,6 +3338,7 @@
     hedgehog: PHedgehog;
     State: Longword;
     switchDir: Longword;
+    oldUid: Longword;
 begin
     AllInactive := false;
 
@@ -3355,6 +3356,7 @@
     if (Gear^.Message and gmSwitch) <> 0 then
         begin
         HHGear := CurrentHedgehog^.Gear;
+        oldUid:= HHGear^.uid;
         HHGear^.Message := HHGear^.Message and (not gmSwitch);
         Gear^.Message := Gear^.Message and (not gmSwitch);
 
@@ -3387,6 +3389,7 @@
         AmmoMenuInvalidated:= true;
 
         HHGear := CurrentHedgehog^.Gear;
+        ScriptCall('onHogSwitch', oldUid);
         HHGear^.State := State;
         HHGear^.Active := true;
         FollowGear := HHGear;