From b75596f7e02fb6399a6d9dd035ec7e9ad58b7f79 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 13 Apr 2022 21:15:29 +0300 Subject: [PATCH] player: use TAnimState for punch --- src/game/g_player.pas | 8 ++++---- src/game/opengl/r_player.pas | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/g_player.pas b/src/game/g_player.pas index ea2aea5..312f186 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -185,7 +185,7 @@ type FSavedStateNum: Integer; FModel: TPlayerModel; - FPunchAnim: TAnimationState; + FPunchAnim: TAnimState; FActionPrior: Byte; FActionAnim: Byte; FActionForce: Boolean; @@ -414,7 +414,7 @@ type property Berserk: Integer read FBerserk; property Pain: Integer read FPain; property Pickup: Integer read FPickup; - property PunchAnim: TAnimationState read FPunchAnim write FPunchAnim; + property PunchAnim: TAnimState read FPunchAnim write FPunchAnim; property SpawnInvul: Integer read FSpawnInvul; property Ghost: Boolean read FGhost; @@ -1644,7 +1644,7 @@ begin FNetTime := 0; FWaitForFirstSpawn := false; - FPunchAnim := TAnimationState.Create(False, 1, 4); + FPunchAnim := TAnimState.Create(False, 1, 4); FPunchAnim.Disable; resetWeaponQueue(); @@ -1799,7 +1799,7 @@ begin FJetSoundOn.Free(); FJetSoundOff.Free(); FModel.Free(); - FPunchAnim.Free(); + FPunchAnim.Invalidate; inherited; end; diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index 6204da3..1beb1e4 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -452,12 +452,12 @@ begin else Mirror := TMirrorType.Horizontal; - if p.PunchAnim.enabled then + if p.PunchAnim.IsValid() and p.PunchAnim.enabled then begin if p.FKeys[KEY_DOWN].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 2] else if p.FKeys[KEY_UP].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 1] else ID := PunchFrames[R_BERSERK in p.FRulez, 0]; - r_AnimationState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, 0, Mirror, False); + r_AnimState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, 0, Mirror, False); end; if (p.FMegaRulez[MR_INVUL] > gTime) and ((gPlayerDrawn <> p) or (p.SpawnInvul >= gTime)) then -- 2.29.2