hedgewars/uGearsUtils.pas
changeset 13629 c9a49d06f1a2
parent 13627 605767bbd022
child 13642 3d14950641a4
equal deleted inserted replaced
13628:d5e029b84e16 13629:c9a49d06f1a2
   795 end;
   795 end;
   796 
   796 
   797 
   797 
   798 procedure ResurrectHedgehog(var gear: PGear);
   798 procedure ResurrectHedgehog(var gear: PGear);
   799 var tempTeam : PTeam;
   799 var tempTeam : PTeam;
   800     sparkles: PVisualGear;
   800     sparkles, expl: PVisualGear;
   801     gX, gY: LongInt;
   801     gX, gY: LongInt;
   802 begin
   802 begin
   803     if (Gear^.LastDamage <> nil) then
   803     if (Gear^.LastDamage <> nil) then
   804         uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
   804         uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
   805     else
   805     else
   806         uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
   806         uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
       
   807     // Reset gear state
   807     AttackBar:= 0;
   808     AttackBar:= 0;
   808     gear^.dX := _0;
   809     gear^.dX := _0;
   809     gear^.dY := _0;
   810     gear^.dY := _0;
   810     gear^.Damage := 0;
   811     gear^.Damage := 0;
   811     gear^.Health := gear^.Hedgehog^.InitialHealth;
   812     gear^.Health := gear^.Hedgehog^.InitialHealth;
   820             end;
   821             end;
   821     tempTeam := gear^.Hedgehog^.Team;
   822     tempTeam := gear^.Hedgehog^.Team;
   822     DeleteCI(gear);
   823     DeleteCI(gear);
   823     gX := hwRound(gear^.X);
   824     gX := hwRound(gear^.X);
   824     gY := hwRound(gear^.Y);
   825     gY := hwRound(gear^.Y);
   825     // might need more sparkles for a column
   826     // Spawn a few sparkles at death position.
       
   827     // Might need more sparkles for a column.
   826     sparkles:= AddVisualGear(gX, gY, vgtDust, 1);
   828     sparkles:= AddVisualGear(gX, gY, vgtDust, 1);
   827     if sparkles <> nil then
   829     if sparkles <> nil then
   828         begin
   830         begin
   829         sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF;
   831         sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF;
   830         //sparkles^.Angle:= random(360);
   832         end;
   831         end;
   833     // Set new position of gear (might fail)
   832     FindPlace(gear, false, 0, LAND_WIDTH, true);
   834     FindPlace(gear, false, 0, LAND_WIDTH, true);
   833     if gear <> nil then
   835     if gear <> nil then
   834         begin
   836         begin
   835         AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion);
   837         // Visual effect at position of resurrection
       
   838         expl:= AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion);
   836         PlaySound(sndWarp);
   839         PlaySound(sndWarp);
   837         RenderHealth(gear^.Hedgehog^);
   840         RenderHealth(gear^.Hedgehog^);
   838         ScriptCall('onGearResurrect', gear^.uid);
   841         if expl <> nil then
       
   842             ScriptCall('onGearResurrect', gear^.uid, expl^.uid)
       
   843         else
       
   844             ScriptCall('onGearResurrect', gear^.uid);
   839         gear^.State := gstWait;
   845         gear^.State := gstWait;
   840         end;
   846         end;
   841     RecountTeamHealth(tempTeam);
   847     RecountTeamHealth(tempTeam);
   842 end;
   848 end;
   843 
   849