DEADSOFTWARE

Player: Code formatting only
[d2df-sdl.git] / src / game / g_player.pas
index a0496da85e63e8314c938bcea0aa18bd7a957495..ef8b1af0da19cfd20e0ea61faa118bc8474f298f 100644 (file)
@@ -168,6 +168,7 @@ type
     FXTo, FYTo: Integer;
     FSpectatePlayer: Integer;
     FFirePainTime:   Integer;
+    FFireAttacker:   Word;
 
     FSavedState: TPlayerSavedState;
 
@@ -308,7 +309,7 @@ type
     procedure   RealizeCurrentWeapon();
     procedure   JetpackOn;
     procedure   JetpackOff;
-    procedure   CatchFire();
+    procedure   CatchFire(Attacker: Word);
 
     property    Name: String read FName write FName;
     property    Model: TPlayerModel read FModel;
@@ -575,7 +576,7 @@ const
   //                               WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
   //                               WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
   WEAPON_RELOAD: Array [WP_FIRST..WP_LAST] of Byte =
-                                (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 0);
+                                (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
 
   PLAYER_SIGNATURE = $52594C50; // 'PLYR'
   CORPSE_SIGNATURE = $50524F43; // 'CORP'
@@ -1993,6 +1994,7 @@ begin
   FShellTimer := -1;
   FFireTime := 0;
   FFirePainTime := 0;
+  FFireAttacker := 0;
 
   FActualModelName := 'doomer';
 
@@ -2880,9 +2882,10 @@ begin
   FJetSoundOff.PlayAt(FObj.X, FObj.Y);
 end;
 
-procedure TPlayer.CatchFire();
+procedure TPlayer.CatchFire(Attacker: Word);
 begin
-  FFireTime := 360;
+  FFireTime := 100;
+  FFireAttacker := Attacker;
   if g_Game_IsNet and g_Game_IsServer then
     MH_SEND_PlayerStats(FUID);
 end;
@@ -3353,13 +3356,21 @@ var
 begin
   result := 255; // default result: "no switch"
   // had weapon cycling on previous frame? remove that flag
-  if (FNextWeap and $2000) <> 0 then begin FNextWeap := FNextWeap and $1FFF; FNextWeapDelay := 0; end;
+  if (FNextWeap and $2000) <> 0 then
+  begin
+    FNextWeap := FNextWeap and $1FFF;
+    FNextWeapDelay := 0;
+  end;
   // cycling has priority
   if (FNextWeap and $C000) <> 0 then
   begin
-    if (FNextWeap and $8000) <> 0 then dir := 1 else dir := -1;
+    if (FNextWeap and $8000) <> 0 then
+      dir := 1
+    else
+      dir := -1;
     FNextWeap := FNextWeap or $2000; // we need this
-    if FNextWeapDelay > 0 then exit; // cooldown time
+    if FNextWeapDelay > 0 then
+      exit; // cooldown time
     cwi := FCurrWeap;
     for i := 0 to High(FWeapon) do
     begin
@@ -3376,8 +3387,14 @@ begin
     exit;
   end;
   // no cycling
-  for i := 0 to High(wantThisWeapon) do wantThisWeapon[i] := false;
-  for i := 0 to High(FWeapon) do if (FNextWeap and (1 shl i)) <> 0 then begin wantThisWeapon[i] := true; Inc(wwc); end;
+  for i := 0 to High(wantThisWeapon) do
+    wantThisWeapon[i] := false;
+  for i := 0 to High(FWeapon) do
+    if (FNextWeap and (1 shl i)) <> 0 then
+    begin
+      wantThisWeapon[i] := true;
+      Inc(wwc);
+    end;
   // exclude currently selected weapon from the set
   wantThisWeapon[FCurrWeap] := false;
   // slow down alterations a little
@@ -3385,11 +3402,19 @@ begin
   begin
     //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
     // more than one weapon requested, assume "alteration" and check alteration delay
-    if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah
+    if FNextWeapDelay > 0 then
+    begin
+      FNextWeap := 0;
+      exit;
+    end; // yeah
   end;
   // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
   // but clear all counters if no weapon should be switched
-  if wwc < 1 then begin resetWeaponQueue(); exit; end;
+  if wwc < 1 then
+  begin
+    resetWeaponQueue();
+    exit;
+  end;
   //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
   // try weapons in descending order
   for i := High(FWeapon) downto 0 do
@@ -3498,6 +3523,7 @@ begin
         IncMax(FHealth, 10, PLAYER_HP_SOFT);
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -3507,6 +3533,7 @@ begin
         IncMax(FHealth, 25, PLAYER_HP_SOFT);
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -3534,6 +3561,7 @@ begin
         IncMax(FHealth, 100, PLAYER_HP_LIMIT);
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -3546,6 +3574,7 @@ begin
           FArmor := PLAYER_AP_LIMIT;
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -3801,6 +3830,7 @@ begin
         FMegaRulez[MR_SUIT] := gTime+PLAYER_SUIT_TIME;
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -3830,6 +3860,7 @@ begin
           FBerserk := gTime+30000;
           Result := True;
           remove := True;
+          FFireTime := 0;
         end;
         if FHealth < PLAYER_HP_SOFT then
         begin
@@ -3837,6 +3868,7 @@ begin
           FBerserk := gTime+30000;
           Result := True;
           remove := True;
+          FFireTime := 0;
         end;
       end;
 
@@ -3855,6 +3887,7 @@ begin
         IncMax(FHealth, 4, PLAYER_HP_LIMIT);
         Result := True;
         remove := True;
+        FFireTime := 0;
         if gFlash = 2 then Inc(FPickup, 5);
       end;
 
@@ -4236,6 +4269,9 @@ begin
   FDamageBuffer := 0;
   FJetpack := False;
   FCanJetpack := False;
+  FFireTime := 0;
+  FFirePainTime := 0;
+  FFireAttacker := 0;
 
 // Àíèìàöèÿ âîçðîæäåíèÿ:
   if (not gLoadGameMode) and (not Silent) then
@@ -4834,13 +4870,19 @@ begin
         FFireTime := 0;
         FFirePainTime := 0;
       end
+      else if FMegaRulez[MR_SUIT] >= gTime then
+      begin
+        if FMegaRulez[MR_SUIT] = gTime then
+          FFireTime := 1;
+        FFirePainTime := 0;
+      end
       else
       begin
         OnFireFlame(1);
         if FFirePainTime <= 0 then
         begin
           if g_Game_IsServer then
-            Damage(5, 0, 0, 0, HIT_FLAME);
+            Damage(5, FFireAttacker, 0, 0, HIT_FLAME);
           FFirePainTime := 18;
         end;
         FFirePainTime := FFirePainTime - 1;
@@ -6204,7 +6246,7 @@ var
   firew, fireh: Integer;
   angle: SmallInt;
   mon: TMonster;
-  pla: TPlayer;
+  pla, tpla: TPlayer;
   vsPlayer, vsMonster, ok: Boolean;
 begin
   vsPlayer := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER);
@@ -6238,14 +6280,16 @@ begin
       if (g_GetUIDType(Target.UID) = UID_PLAYER) and
           vsPlayer then
         begin // Èãðîê
-          with g_Player_Get(Target.UID) do
-            begin
-              if (@FObj) <> nil then
+          tpla := g_Player_Get(Target.UID);
+          if tpla <> nil then
+            with tpla do
               begin
-                Target.X := FObj.X;
-                Target.Y := FObj.Y;
+                if (@FObj) <> nil then
+                begin
+                  Target.X := FObj.X;
+                  Target.Y := FObj.Y;
+                end;
               end;
-            end;
 
           Target.cX := Target.X + PLAYER_RECT_CX;
           Target.cY := Target.Y + PLAYER_RECT_CY;