DEADSOFTWARE

Game: Don't catch fire underwater in any circumstances
[d2df-sdl.git] / src / game / g_player.pas
index 81825dfe7bce4b108fbf20570dcdf17a0f8200f4..d4b6bdd3691f03593806e6ec41f59dde424813bb 100644 (file)
@@ -97,6 +97,8 @@ const
   SUICIDE_DAMAGE  = 112;
   WEAPON_DELAY    = 5;
 
+  PLAYER_BURN_TIME = 110;
+
   PLAYER1_DEF_COLOR: TRGB = (R:64; G:175; B:48);
   PLAYER2_DEF_COLOR: TRGB = (R:96; G:96; B:96);
 
@@ -336,7 +338,7 @@ type
     procedure   FlamerOff;
     procedure   JetpackOn;
     procedure   JetpackOff;
-    procedure   CatchFire(Attacker: Word);
+    procedure   CatchFire(Attacker: Word; Timeout: Integer = PLAYER_BURN_TIME);
 
     //WARNING! this does nothing for now, but still call it!
     procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
@@ -2328,12 +2330,12 @@ var
 begin
   if FAlive then
     begin
-      indX := FObj.X+FObj.Rect.X;
-      indY := FObj.Y;
       if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
         begin
           e_GetTextureSize(ID, @indW, @indH);
-          e_Draw(ID, indX + indW div 2, indY - indH, 0, True, False);
+          indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
+          indY := FObj.Y;
+          e_Draw(ID, indX, indY - indH, 0, True, False);
         end;
     end;
   //e_TextureFontPrint(indX, indY, FName, gStdFont); // Shows player name overhead
@@ -3189,13 +3191,17 @@ begin
   FJetSoundOff.PlayAt(FObj.X, FObj.Y);
 end;
 
-procedure TPlayer.CatchFire(Attacker: Word);
+procedure TPlayer.CatchFire(Attacker: Word; Timeout: Integer = PLAYER_BURN_TIME);
 begin
+  if Timeout <= 0 then
+    exit;
   if (FMegaRulez[MR_SUIT] > gTime) or (FMegaRulez[MR_INVUL] > gTime) then
     exit; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
+  if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then
+    exit; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
   if FFireTime <= 0 then
     g_Sound_PlayExAt('SOUND_IGNITE', FObj.X, FObj.Y);
-  FFireTime := 100;
+  FFireTime := Timeout;
   FFireAttacker := Attacker;
   if g_Game_IsNet and g_Game_IsServer then
     MH_SEND_PlayerStats(FUID);
@@ -3851,9 +3857,9 @@ begin
 
   case ItemType of
     ITEM_MEDKIT_SMALL:
-      if FHealth < PLAYER_HP_SOFT then
+      if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
       begin
-        IncMax(FHealth, 10, PLAYER_HP_SOFT);
+        if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 10, PLAYER_HP_SOFT);
         Result := True;
         remove := True;
         FFireTime := 0;
@@ -3861,9 +3867,9 @@ begin
       end;
 
     ITEM_MEDKIT_LARGE:
-      if FHealth < PLAYER_HP_SOFT then
+      if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
       begin
-        IncMax(FHealth, 25, PLAYER_HP_SOFT);
+        if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 25, PLAYER_HP_SOFT);
         Result := True;
         remove := True;
         FFireTime := 0;
@@ -3889,9 +3895,9 @@ begin
       end;
 
     ITEM_SPHERE_BLUE:
-      if FHealth < PLAYER_HP_LIMIT then
+      if (FHealth < PLAYER_HP_LIMIT) or (FFireTime > 0) then
       begin
-        IncMax(FHealth, 100, PLAYER_HP_LIMIT);
+        if FHealth < PLAYER_HP_LIMIT then IncMax(FHealth, 100, PLAYER_HP_LIMIT);
         Result := True;
         remove := True;
         FFireTime := 0;
@@ -3899,7 +3905,7 @@ begin
       end;
 
     ITEM_SPHERE_WHITE:
-      if (FHealth < PLAYER_HP_LIMIT) or (FArmor < PLAYER_AP_LIMIT) then
+      if (FHealth < PLAYER_HP_LIMIT) or (FArmor < PLAYER_AP_LIMIT) or (FFireTime > 0) then
       begin
         if FHealth < PLAYER_HP_LIMIT then
           FHealth := PLAYER_HP_LIMIT;
@@ -4104,7 +4110,7 @@ begin
             (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or
             (FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or
             (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or
-            (FMaxAmmo[A_FUEL] < AmmoLimits[1, A_FUEL]) then
+            (FAmmo[A_FUEL] < FMaxAmmo[A_FUEL]) then
       begin
         FMaxAmmo[A_BULLETS] := AmmoLimits[1, A_BULLETS];
         FMaxAmmo[A_SHELLS] := AmmoLimits[1, A_SHELLS];
@@ -4120,6 +4126,8 @@ begin
           IncMax(FAmmo[A_ROCKETS], 1, FMaxAmmo[A_ROCKETS]);
         if FAmmo[A_CELLS] < FMaxAmmo[A_CELLS] then
           IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
+        if FAmmo[A_FUEL] < FMaxAmmo[A_FUEL] then
+          IncMax(FAmmo[A_FUEL], 50, FMaxAmmo[A_FUEL]);
 
         FRulez := FRulez + [R_ITEM_BACKPACK];
         Result := True;
@@ -4197,9 +4205,9 @@ begin
           remove := True;
           FFireTime := 0;
         end;
-        if FHealth < PLAYER_HP_SOFT then
+        if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
         begin
-          FHealth := PLAYER_HP_SOFT;
+          if FHealth < PLAYER_HP_SOFT then FHealth := PLAYER_HP_SOFT;
           FBerserk := gTime+30000;
           Result := True;
           remove := True;
@@ -4217,9 +4225,9 @@ begin
       end;
 
     ITEM_BOTTLE:
-      if FHealth < PLAYER_HP_LIMIT then
+      if (FHealth < PLAYER_HP_LIMIT) or (FFireTime > 0) then
       begin
-        IncMax(FHealth, 4, PLAYER_HP_LIMIT);
+        if FHealth < PLAYER_HP_LIMIT then IncMax(FHealth, 4, PLAYER_HP_LIMIT);
         Result := True;
         remove := True;
         FFireTime := 0;
@@ -5276,8 +5284,8 @@ begin
         if FFirePainTime <= 0 then
         begin
           if g_Game_IsServer then
-            Damage(6, FFireAttacker, 0, 0, HIT_FLAME);
-          FFirePainTime := 18;
+            Damage(2, FFireAttacker, 0, 0, HIT_FLAME);
+          FFirePainTime := 12 - FFireTime div 12;
         end;
         FFirePainTime := FFirePainTime - 1;
         FFireTime := FFireTime - 1;