DEADSOFTWARE

mapdef cleanup; renamed some fields; mapdef.txt is RC0 now
[d2df-sdl.git] / src / game / g_player.pas
index afd5b7af33fbbf7a596800a70fa1e721ee957c3d..300979a87de4011a595a4d59af4704d9132f74a3 100644 (file)
@@ -321,6 +321,7 @@ type
     procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
 
     procedure getMapBox (out x, y, w, h: Integer); inline;
+    procedure moveBy (dx, dy: Integer); inline;
 
   public
     property    Vel: TPoint2i read FObj.Vel;
@@ -423,6 +424,7 @@ type
     Obj:      TObj;
 
     procedure getMapBox (out x, y, w, h: Integer); inline;
+    procedure moveBy (dx, dy: Integer); inline;
 
     procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
   end;
@@ -439,6 +441,7 @@ type
     Obj:      TObj;
 
     procedure getMapBox (out x, y, w, h: Integer); inline;
+    procedure moveBy (dx, dy: Integer); inline;
 
     procedure positionChanged ();  inline; //WARNING! call this after entity position was changed, or coldet will not work right!
   end;
@@ -464,12 +467,13 @@ type
     procedure   LoadState(var Mem: TBinMemoryReader);
 
     procedure getMapBox (out x, y, w, h: Integer); inline;
-
     procedure moveBy (dx, dy: Integer); inline;
 
     procedure positionChanged ();  inline; //WARNING! call this after entity position was changed, or coldet will not work right!
 
-    property    Obj: TObj read FObj;
+    function ObjPtr (): PObj; inline;
+
+    property    Obj: TObj read FObj; // copies object
     property    State: Byte read FState;
     property    Mess: Boolean read FMess;
   end;
@@ -1727,6 +1731,17 @@ begin
   h := Obj.Rect.Height;
 end;
 
+procedure TGib.moveBy (dx, dy: Integer); inline;
+begin
+  if (dx <> 0) or (dy <> 0) then
+  begin
+    Obj.X += dx;
+    Obj.Y += dy;
+    positionChanged();
+  end;
+end;
+
+
 procedure TShell.getMapBox (out x, y, w, h: Integer); inline;
 begin
   x := Obj.X;
@@ -1735,10 +1750,21 @@ begin
   h := Obj.Rect.Height;
 end;
 
+procedure TShell.moveBy (dx, dy: Integer); inline;
+begin
+  if (dx <> 0) or (dy <> 0) then
+  begin
+    Obj.X += dx;
+    Obj.Y += dy;
+    positionChanged();
+  end;
+end;
+
 
 procedure TGib.positionChanged (); inline; begin end;
 procedure TShell.positionChanged (); inline; begin end;
 
+
 procedure g_Player_DrawCorpses();
 var
   i: Integer;
@@ -3196,7 +3222,7 @@ begin
         if mon = nil then
           s := '?'
         else
-          s := g_Monsters_GetKilledBy(mon.MonsterType);
+          s := g_Mons_GetKilledByTypeId(mon.MonsterType);
 
         case KillType of
           K_HARDKILL:
@@ -3954,15 +3980,17 @@ begin
         if not (R_BERSERK in FRulez) then
         begin
           Include(FRulez, R_BERSERK);
-          if FBFGFireCounter = -1 then
+          if gBerserkAutoswitch and (FBFGFireCounter = -1) then
           begin
             FCurrWeap := WEAPON_KASTET;
             resetWeaponQueue();
             FModel.SetWeapon(WEAPON_KASTET);
           end;
           if gFlash <> 0 then
+          begin
             Inc(FPain, 100);
             if gFlash = 2 then Inc(FPickup, 5);
+          end;
           FBerserk := gTime+30000;
           Result := True;
           remove := True;
@@ -5069,6 +5097,7 @@ begin
     if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
 end;
 
+
 procedure TPlayer.getMapBox (out x, y, w, h: Integer); inline;
 begin
   x := FObj.X+PLAYER_RECT.X;
@@ -5077,6 +5106,18 @@ begin
   h := PLAYER_RECT.Height;
 end;
 
+
+procedure TPlayer.moveBy (dx, dy: Integer); inline;
+begin
+  if (dx <> 0) or (dy <> 0) then
+  begin
+    FObj.X += dx;
+    FObj.Y += dy;
+    positionChanged();
+  end;
+end;
+
+
 function TPlayer.Collide(X, Y: Integer; Width, Height: Word): Boolean;
 begin
   Result := g_Collide(FObj.X+PLAYER_RECT.X,
@@ -6122,6 +6163,8 @@ begin
   inherited;
 end;
 
+function TCorpse.ObjPtr (): PObj; inline; begin result := @FObj; end;
+
 procedure TCorpse.positionChanged (); inline; begin end;
 
 procedure TCorpse.moveBy (dx, dy: Integer); inline;
@@ -6143,6 +6186,7 @@ begin
   h := PLAYER_CORPSERECT.Height;
 end;
 
+
 procedure TCorpse.Damage(Value: Word; vx, vy: Integer);
 var
   pm: TPlayerModel;