Some survival mode changes by burp
authortiyuri@gmail.com
Wed, 25 Aug 2010 21:06:34 +0100
changeset 3768 39947624dabb
parent 3767 2416a3f51c77
child 3769 bb9ecd0346d8
Some survival mode changes by burp
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Wed Aug 25 12:28:37 2010 +0200
+++ b/hedgewars/GSHandlers.inc	Wed Aug 25 21:06:34 2010 +0100
@@ -125,13 +125,17 @@
             Gear^.State := gstDrowning;
             Gear^.RenderTimer := false;
             if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then
-                Gear^.doStep := @doStepDrowningGear;
-            if Gear^.Kind = gtHedgehog then
-            begin
-                Gear^.State := Gear^.State and (not gstHHDriven);
-                AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name),
-                cWhiteColor, capgrpMessage);
-            end;
+                if Gear^.Kind = gtHedgehog then begin
+                    if PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] then begin
+                        ResurrectHedgehog(Gear); 
+                    end else begin
+                        Gear^.doStep := @doStepDrowningGear;
+                        Gear^.State := Gear^.State and (not gstHHDriven);
+                        AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
+                    end;
+                end else begin
+                    Gear^.doStep := @doStepDrowningGear;
+                end;
             if hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius then
                 // don't play splash if they are already way past the surface
                 PlaySound(sndSplash)
--- a/hedgewars/HHHandlers.inc	Wed Aug 25 12:28:37 2010 +0200
+++ b/hedgewars/HHHandlers.inc	Wed Aug 25 21:06:34 2010 +0100
@@ -851,10 +851,14 @@
 
         if not PHedgehog(Gear^.Hedgehog)^.Team^.hasGone then
             begin
-            Gear^.State:= Gear^.State or gstHHDeath;
-            Gear^.doStep:= @doStepHedgehogDead;
-            // Death message
-            AddCaption(Format(GetEventString(eidDied), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
+            if PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] then begin
+                ResurrectHedgehog(Gear);
+            end else begin
+                Gear^.State:= Gear^.State or gstHHDeath;
+                Gear^.doStep:= @doStepHedgehogDead;
+                // Death message
+                AddCaption(Format(GetEventString(eidDied), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
+            end;
             end
         else
             begin
--- a/hedgewars/uConsts.pas	Wed Aug 25 12:28:37 2010 +0200
+++ b/hedgewars/uConsts.pas	Wed Aug 25 21:06:34 2010 +0100
@@ -184,7 +184,7 @@
             PrevTexture, NextTexture: PTexture;
             end;
 
-    THogEffect = (heInvulnerable, hePoisoned);
+    THogEffect = (heInvulnerable, heResurrectable, hePoisoned);
 
     TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite);
 const
--- a/hedgewars/uGears.pas	Wed Aug 25 12:28:37 2010 +0200
+++ b/hedgewars/uGears.pas	Wed Aug 25 21:06:34 2010 +0100
@@ -82,6 +82,7 @@
 procedure freeModule;
 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
+procedure ResurrectHedgehog(gear: PGear);
 procedure ProcessGears;
 procedure EndTurnCleanup;
 procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource);
@@ -318,6 +319,9 @@
                 gear^.Friction:= _0_999;
                 gear^.Angle:= cMaxAngle div 2;
                 gear^.Z:= cHHZ;
+                if (GameFlags and gfAISurvival) <> 0 then
+                    if PHedgehog(gear^.Hedgehog)^.BotLevel > 0 then
+                        PHedgehog(gear^.Hedgehog)^.Effects[heResurrectable] := true;
                 end;
 gtAmmo_Grenade: begin // bazooka
                 gear^.Radius:= 4;
@@ -1539,6 +1543,18 @@
 CountGears:= count;
 end;
 
+procedure ResurrectHedgehog(gear: PGear);
+begin
+    gear^.Health := 100;
+    gear^.dX := _0;
+    gear^.dY := _0;
+    gear^.State := gstWait;
+    FindPlace(Gear, false, 0, LAND_WIDTH); 
+    RenderHealth(PHedgehog(gear^.Hedgehog)^);
+    RecountTeamHealth(PHedgehog(gear^.Hedgehog)^.Team);
+    ScriptCall('onResurrect', gear^.uid);
+end;
+
 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear;
 begin
     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);