X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=932e081d6da0b56ef9dabac4c6e190b9ca2ceaa2;hb=31d174a428ef1235e1708b0738804b47e006cf5c;hp=afd5b7af33fbbf7a596800a70fa1e721ee957c3d;hpb=1f3c760a3beb696acb34781fa305b10942aee2b1;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index afd5b7a..932e081 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -20,6 +20,7 @@ unit g_player; interface uses + mempool, e_graphics, g_playermodel, g_basic, g_textures, g_weapons, g_phys, g_sound, g_saveload, MAPDEF, BinEditor, g_panel; @@ -133,7 +134,7 @@ type Time: Word; end; - TPlayer = class (TObject) + TPlayer = class(TPoolObject) private FIamBot: Boolean; FUID: Word; @@ -195,34 +196,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; @@ -321,12 +326,12 @@ 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; 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; @@ -357,6 +362,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 @@ -376,7 +416,7 @@ type Value: String; end; - TBot = class (TPlayer) + TBot = class(TPlayer) private FSelectedWeapon: Byte; FTargetUID: Word; @@ -423,6 +463,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,11 +480,12 @@ 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; - TCorpse = class (TObject) + TCorpse = class(TPoolObject) private FModelName: String; FMess: Boolean; @@ -464,12 +506,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 +1770,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 +1789,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; @@ -2030,6 +2095,7 @@ begin viewPortY := 0; viewPortW := 0; viewPortH := 0; + mEDamageType := HIT_SOME; FIamBot := False; FDummy := False; @@ -2077,6 +2143,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; @@ -3196,7 +3269,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: @@ -3612,6 +3685,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 @@ -3954,15 +4037,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; @@ -5069,6 +5154,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 +5163,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 +6220,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 +6243,7 @@ begin h := PLAYER_CORPSERECT.Height; end; + procedure TCorpse.Damage(Value: Word; vx, vy: Integer); var pm: TPlayerModel; @@ -7570,4 +7671,7 @@ begin FDifficult := TDifficult(p^); end; + +begin + conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '', true, true); end.