DEADSOFTWARE

some more exoma code
[d2df-sdl.git] / src / game / g_player.pas
index 06ae6e50340317cda52f96b1b34228d50c48f18c..9c20c904f520d41a9855248c2a9822ee95e46138 100644 (file)
@@ -195,34 +195,38 @@ type
     FNoReload:  Boolean;
     FJustTeleported: Boolean;
     FNetTime: LongWord;
-
-    function    CollideLevel(XInc, YInc: Integer): Boolean;
-    function    StayOnStep(XInc, YInc: Integer): Boolean;
-    function    HeadInLiquid(XInc, YInc: Integer): Boolean;
-    function    BodyInLiquid(XInc, YInc: Integer): Boolean;
-    function    BodyInAcid(XInc, YInc: Integer): Boolean;
-    function    FullInLift(XInc, YInc: Integer): Integer;
-    {procedure   CollideItem();}
-    procedure   FlySmoke(Times: DWORD = 1);
-    procedure   OnFireFlame(Times: DWORD = 1);
-    function    GetAmmoByWeapon(Weapon: Byte): Word;
-    procedure   SetAction(Action: Byte; Force: Boolean = False);
-    procedure   OnDamage(Angle: SmallInt); virtual;
-    function    firediry(): Integer;
-
-    procedure   Run(Direction: TDirection);
-    procedure   NextWeapon();
-    procedure   PrevWeapon();
-    procedure   SeeUp();
-    procedure   SeeDown();
-    procedure   Fire();
-    procedure   Jump();
-    procedure   Use();
+    mEDamageType: Integer;
+
+
+    function CollideLevel(XInc, YInc: Integer): Boolean;
+    function StayOnStep(XInc, YInc: Integer): Boolean;
+    function HeadInLiquid(XInc, YInc: Integer): Boolean;
+    function BodyInLiquid(XInc, YInc: Integer): Boolean;
+    function BodyInAcid(XInc, YInc: Integer): Boolean;
+    function FullInLift(XInc, YInc: Integer): Integer;
+    {procedure CollideItem();}
+    procedure FlySmoke(Times: DWORD = 1);
+    procedure OnFireFlame(Times: DWORD = 1);
+    function GetAmmoByWeapon(Weapon: Byte): Word;
+    procedure SetAction(Action: Byte; Force: Boolean = False);
+    procedure OnDamage(Angle: SmallInt); virtual;
+    function firediry(): Integer;
+
+    procedure Run(Direction: TDirection);
+    procedure NextWeapon();
+    procedure PrevWeapon();
+    procedure SeeUp();
+    procedure SeeDown();
+    procedure Fire();
+    procedure Jump();
+    procedure Use();
 
     function getNextWeaponIndex (): Byte; // return 255 for "no switch"
     procedure resetWeaponQueue ();
     function hasAmmoForWeapon (weapon: Byte): Boolean;
 
+    procedure doDamage (v: Integer);
+
   public
     FDamageBuffer:   Integer;
 
@@ -327,7 +331,6 @@ type
     property    Vel: TPoint2i read FObj.Vel;
     property    Obj: TObj read FObj;
 
-  published
     property    Name: String read FName write FName;
     property    Model: TPlayerModel read FModel;
     property    Health: Integer read FHealth write FHealth;
@@ -358,6 +361,41 @@ type
     property    UID: Word read FUID write FUID;
     property    JustTeleported: Boolean read FJustTeleported write FJustTeleported;
     property    NetTime: LongWord read FNetTime write FNetTime;
+
+  published
+    property eName: String read FName write FName;
+    property eHealth: Integer read FHealth write FHealth;
+    property eLives: Byte read FLives write FLives;
+    property eArmor: Integer read FArmor write FArmor;
+    property eAir:   Integer read FAir write FAir;
+    property eJetFuel: Integer read FJetFuel write FJetFuel;
+    property eFrags: Integer read FFrags write FFrags;
+    property eDeath: Integer read FDeath write FDeath;
+    property eKills: Integer read FKills write FKills;
+    property eCurrWeap: Byte read FCurrWeap write FCurrWeap;
+    property eMonsterKills: Integer read FMonsterKills write FMonsterKills;
+    property eSecrets: Integer read FSecrets write FSecrets;
+    property eGodMode: Boolean read FGodMode write FGodMode;
+    property eNoTarget: Boolean read FNoTarget write FNoTarget;
+    property eNoReload: Boolean read FNoReload write FNoReload;
+    property eAlive: Boolean read FAlive write FAlive;
+    property eFlag: Byte read FFlag;
+    property eTeam: Byte read FTeam write FTeam;
+    property eDirection: TDirection read FDirection;
+    property eGameX: Integer read FObj.X write FObj.X;
+    property eGameY: Integer read FObj.Y write FObj.Y;
+    property eGameVelX: Integer read FObj.Vel.X write FObj.Vel.X;
+    property eGameVelY: Integer read FObj.Vel.Y write FObj.Vel.Y;
+    property eGameAccelX: Integer read FObj.Accel.X write FObj.Accel.X;
+    property eGameAccelY: Integer read FObj.Accel.Y write FObj.Accel.Y;
+    property eIncCam: Integer read FIncCam write FIncCam;
+    property eUID: Word read FUID;
+    property eJustTeleported: Boolean read FJustTeleported;
+    property eNetTime: LongWord read FNetTime;
+
+    // set this before assigning something to `eDamage`
+    property eDamageType: Integer read mEDamageType write mEDamageType;
+    property eDamage: Integer write doDamage;
   end;
 
   TDifficult = record
@@ -471,7 +509,9 @@ type
 
     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;
@@ -2054,6 +2094,7 @@ begin
   viewPortY := 0;
   viewPortW := 0;
   viewPortH := 0;
+  mEDamageType := HIT_SOME;
 
   FIamBot := False;
   FDummy := False;
@@ -2101,6 +2142,13 @@ procedure TPlayer.positionChanged (); inline;
 begin
 end;
 
+procedure TPlayer.doDamage (v: Integer);
+begin
+  if (v <= 0) then exit;
+  if (v > 32767) then v := 32767;
+  Damage(v, 0, 0, 0, mEDamageType);
+end;
+
 procedure TPlayer.Damage(value: Word; SpawnerUID: Word; vx, vy: Integer; t: Byte);
 var
   c: Word;
@@ -3636,6 +3684,16 @@ begin
 end;
 
 function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean;
+
+  function allowBerserkSwitching (): Boolean;
+  begin
+    if (FBFGFireCounter <> -1) then begin result := false; exit; end;
+    result := true;
+    if gBerserkAutoswitch then exit;
+    if not (gDebugMode or gCheats) then exit;
+    result := false;
+  end;
+
 var
   a: Boolean;
 begin
@@ -3978,15 +4036,17 @@ begin
         if not (R_BERSERK in FRulez) then
         begin
           Include(FRulez, R_BERSERK);
-          if FBFGFireCounter = -1 then
+          if allowBerserkSwitching 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;
@@ -6159,6 +6219,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;
@@ -7608,4 +7670,7 @@ begin
   FDifficult := TDifficult(p^);
 end;
 
+
+begin
+  conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '',  true, true);
 end.