diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index c2605a092509cd28d1f5bbf36c64a5e7fb7a1014..5478180bf23ed93ddf84d425087edbd16e20f605 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
{$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
g_base, g_playermodel, g_basic, g_textures,
g_weapons, g_phys, g_sound, g_saveload, MAPDEF,
- g_panel;
+ g_panel, r_playermodel;
const
KEY_LEFT = 1;
FSavedStateNum: Integer;
FModel: TPlayerModel;
- FPunchAnim: TAnimation;
+ FPunchAnim: TAnimationState;
FActionPrior: Byte;
FActionAnim: Byte;
FActionForce: Boolean;
property Berserk: Integer read FBerserk;
property Pain: Integer read FPain;
property Pickup: Integer read FPickup;
- property PunchAnim: TAnimation read FPunchAnim write FPunchAnim;
+ property PunchAnim: TAnimationState read FPunchAnim write FPunchAnim;
property SpawnInvul: Integer read FSpawnInvul;
property Ghost: Boolean read FGhost;
PGib = ^TGib;
TGib = record
alive: Boolean;
- ID: DWORD;
- MaskID: DWORD;
RAngle: Integer;
Color: TRGB;
Obj: TObj;
+ ModelID: Integer;
+ GibID: Integer;
+
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: string; fColor: TRGB);
var
- a: Integer;
+ a, mid: Integer;
GibsArray: TGibsArray;
Blood: TModelBlood;
begin
if (gGibs = nil) or (Length(gGibs) = 0) then
Exit;
- if not g_PlayerModel_GetGibs(ModelName, GibsArray) then
+ mid := g_PlayerModel_GetIndex(ModelName);
+ if mid = -1 then
+ Exit;
+ if not g_PlayerModel_GetGibs(mid, GibsArray) then
Exit;
- Blood := g_PlayerModel_GetBlood(ModelName);
+ Blood := PlayerModelsArray[mid].Blood;
for a := 0 to High(GibsArray) do
with gGibs[CurrentGib] do
begin
+ ModelID := mid;
+ GibID := GibsArray[a];
Color := fColor;
- ID := GibsArray[a].ID;
- MaskID := GibsArray[a].MaskID;
alive := True;
g_Obj_Init(@Obj);
- Obj.Rect := GibsArray[a].Rect;
- Obj.X := fX-GibsArray[a].Rect.X-(GibsArray[a].Rect.Width div 2);
- Obj.Y := fY-GibsArray[a].Rect.Y-(GibsArray[a].Rect.Height div 2);
+ Obj.Rect := r_PlayerModel_GetGibRect(ModelID, GibID);
+ Obj.X := fX - Obj.Rect.X - (Obj.Rect.Width div 2);
+ Obj.Y := fY - Obj.Rect.Y - (Obj.Rect.Height div 2);
g_Obj_PushA(@Obj, 25 + Random(10), Random(361));
positionChanged(); // this updates spatial accelerators
RAngle := Random(360);
FNetTime := 0;
FWaitForFirstSpawn := false;
+ FPunchAnim := TAnimationState.Create(False, 1, 4);
+ FPunchAnim.Disable;
resetWeaponQueue();
end;
FJetSoundOn.Free();
FJetSoundOff.Free();
FModel.Free();
- if FPunchAnim <> nil then
- FPunchAnim.Free();
+ FPunchAnim.Free();
inherited;
end;
procedure TPlayer.DoPunch();
-var
- id: DWORD;
- st: String;
begin
- if FPunchAnim <> nil then begin
- FPunchAnim.reset();
- FPunchAnim.Free;
- FPunchAnim := nil;
- end;
- st := 'FRAMES_PUNCH';
- if R_BERSERK in FRulez then
- st := st + '_BERSERK';
- if FKeys[KEY_UP].Pressed then
- st := st + '_UP'
- else if FKeys[KEY_DOWN].Pressed then
- st := st + '_DN';
- g_Frames_Get(id, st);
- FPunchAnim := TAnimation.Create(id, False, 1);
+ FPunchAnim.Reset;
+ FPunchAnim.Enable;
end;
procedure TPlayer.Fire();
FLoss := 0;
end;
- if FAlive and (FPunchAnim <> nil) then
- FPunchAnim.Update();
+ if FAlive then
+ FPunchAnim.Update;
+ if FPunchAnim.played then
+ FPunchAnim.Disable;
if FAlive and (gFly or FJetpack) then
FlySmoke();
if (FModel.AnimState.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
then SetAction(A_STAND, True);
- if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.Fire) then FModel.Update;
+ if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.GetFire()) then FModel.Update;
for b := Low(FKeys) to High(FKeys) do
if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);