Report spawning visual gear in onGearResurrect
authorWuzzy <Wuzzy2@mail.ru>
Tue, 07 Aug 2018 12:15:59 +0200
changeset 13629 c9a49d06f1a2
parent 13628 d5e029b84e16
child 13630 fe7d2bbf5f3f
Report spawning visual gear in onGearResurrect
ChangeLog.txt
hedgewars/uGearsUtils.pas
--- a/ChangeLog.txt	Tue Aug 07 11:37:37 2018 +0200
+++ b/ChangeLog.txt	Tue Aug 07 12:15:59 2018 +0200
@@ -84,6 +84,7 @@
  + New call: GetLaserSight(): Returns true if laser sight (as utility) is currenctly active (ignoring sniper rifle)
  + New call: IsHogHidden(gear): Returns true if hog is hidden
  + Changed call: AddTeam: 2nd param. color: Accepts negative value to use a default clan color from player settings
+ + Change callback: onGearResurrect: 2nd parameter for visual gear spawned at resurrect position (might be nil)
  + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available”
  + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player
  + New Lua library: Achievements
--- a/hedgewars/uGearsUtils.pas	Tue Aug 07 11:37:37 2018 +0200
+++ b/hedgewars/uGearsUtils.pas	Tue Aug 07 12:15:59 2018 +0200
@@ -797,13 +797,14 @@
 
 procedure ResurrectHedgehog(var gear: PGear);
 var tempTeam : PTeam;
-    sparkles: PVisualGear;
+    sparkles, expl: PVisualGear;
     gX, gY: LongInt;
 begin
     if (Gear^.LastDamage <> nil) then
         uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
     else
         uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
+    // Reset gear state
     AttackBar:= 0;
     gear^.dX := _0;
     gear^.dY := _0;
@@ -822,20 +823,25 @@
     DeleteCI(gear);
     gX := hwRound(gear^.X);
     gY := hwRound(gear^.Y);
-    // might need more sparkles for a column
+    // Spawn a few sparkles at death position.
+    // Might need more sparkles for a column.
     sparkles:= AddVisualGear(gX, gY, vgtDust, 1);
     if sparkles <> nil then
         begin
         sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF;
-        //sparkles^.Angle:= random(360);
         end;
+    // Set new position of gear (might fail)
     FindPlace(gear, false, 0, LAND_WIDTH, true);
     if gear <> nil then
         begin
-        AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion);
+        // Visual effect at position of resurrection
+        expl:= AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion);
         PlaySound(sndWarp);
         RenderHealth(gear^.Hedgehog^);
-        ScriptCall('onGearResurrect', gear^.uid);
+        if expl <> nil then
+            ScriptCall('onGearResurrect', gear^.uid, expl^.uid)
+        else
+            ScriptCall('onGearResurrect', gear^.uid);
         gear^.State := gstWait;
         end;
     RecountTeamHealth(tempTeam);