diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 75775079fc244b3060310b2d9618bf7577716d35..db455725d2ca1b4f83c662584a279953acad455f 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
FSavedStateNum: Integer;
FModel: TPlayerModel;
FSavedStateNum: Integer;
FModel: TPlayerModel;
- FPunchAnim: TAnimation;
+ FPunchAnim: TAnimationState;
FActionPrior: Byte;
FActionAnim: Byte;
FActionForce: Boolean;
FActionPrior: Byte;
FActionAnim: Byte;
FActionForce: Boolean;
property Berserk: Integer read FBerserk;
property Pain: Integer read FPain;
property Pickup: Integer read FPickup;
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;
property SpawnInvul: Integer read FSpawnInvul;
property Ghost: Boolean read FGhost;
PGib = ^TGib;
TGib = record
alive: Boolean;
PGib = ^TGib;
TGib = record
alive: Boolean;
- ID: DWORD;
- MaskID: DWORD;
RAngle: Integer;
Color: TRGB;
Obj: TObj;
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 getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
PShell = ^TShell;
TShell = record
PShell = ^TShell;
TShell = record
- SpriteID: DWORD;
- alive: Boolean;
+ alive: Boolean;
SType: Byte;
RAngle: Integer;
Timeout: Cardinal;
SType: Byte;
RAngle: Integer;
Timeout: Cardinal;
- CX, CY: Integer;
Obj: TObj;
procedure getMapBox (out x, y, w, h: Integer); inline;
Obj: TObj;
procedure getMapBox (out x, y, w, h: Integer); inline;
TCorpse = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
private
TCorpse = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
private
- FModelName: String;
FMess: Boolean;
FState: Byte;
FDamage: Byte;
FMess: Boolean;
FState: Byte;
FDamage: Byte;
- FColor: TRGB;
FObj: TObj;
FPlayerUID: Word;
FObj: TObj;
FPlayerUID: Word;
- FAnimation: TAnimation;
- FAnimationMask: TAnimation;
+ FModel: TPlayerModel;
public
constructor Create(X, Y: Integer; ModelName: String; aMess: Boolean);
public
constructor Create(X, Y: Integer; ModelName: String; aMess: Boolean);
property Obj: TObj read FObj; // copies object
property State: Byte read FState;
property Mess: Boolean read FMess;
property Obj: TObj read FObj; // copies object
property State: Byte read FState;
property Mess: Boolean read FMess;
-
- (* internal state *)
- property Color: TRGB read FColor;
- property Animation: TAnimation read FAnimation;
- property AnimationMask: TAnimation read FAnimationMask;
+ property Model: TPlayerModel read FModel;
end;
TTeamStat = Array [TEAM_RED..TEAM_BLUE] of
end;
TTeamStat = Array [TEAM_RED..TEAM_BLUE] of
function g_Player_GetStats(): TPlayerStatArray;
function g_Player_ValidName(Name: String): Boolean;
function g_Player_CreateCorpse(Player: TPlayer): Integer;
function g_Player_GetStats(): TPlayerStatArray;
function g_Player_ValidName(Name: String): Boolean;
function g_Player_CreateCorpse(Player: TPlayer): Integer;
-procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: String; fColor: TRGB);
+procedure g_Player_CreateGibs (fX, fY, mid: Integer; fColor: TRGB);
procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
procedure g_Player_UpdatePhysicalObjects();
procedure g_Player_RemoveAllCorpses();
procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
procedure g_Player_UpdatePhysicalObjects();
procedure g_Player_RemoveAllCorpses();
implementation
uses
implementation
uses
-{$IFDEF ENABLE_HOLMES}
- g_holmes,
-{$ENDIF}
+ {$IFDEF ENABLE_HOLMES}
+ g_holmes,
+ {$ENDIF}
+ {$IFDEF ENABLE_MENU}
+ g_menu,
+ {$ENDIF}
+ {$IFNDEF HEADLESS}
+ r_render,
+ {$ENDIF}
e_log, g_map, g_items, g_console, g_gfx, Math,
e_log, g_map, g_items, g_console, g_gfx, Math,
- g_options, g_triggers, g_menu, g_game, g_grid, e_res,
+ g_options, g_triggers, g_game, g_grid, e_res,
wadreader, g_monsters, CONFIG, g_language,
g_net, g_netmsg,
utils, xstreams;
wadreader, g_monsters, CONFIG, g_language,
g_net, g_netmsg,
utils, xstreams;
if not ok then
find_id := Random(Length(gCorpses));
if not ok then
find_id := Random(Length(gCorpses));
- gCorpses[find_id] := TCorpse.Create(FObj.X, FObj.Y, FModel.Name, FHealth < -20);
- gCorpses[find_id].FColor := FModel.Color;
+ gCorpses[find_id] := TCorpse.Create(FObj.X, FObj.Y, FModel.GetName(), FHealth < -20);
+ gCorpses[find_id].FModel.Color := FModel.Color;
gCorpses[find_id].FObj.Vel := FObj.Vel;
gCorpses[find_id].FObj.Accel := FObj.Accel;
gCorpses[find_id].FPlayerUID := FUID;
gCorpses[find_id].FObj.Vel := FObj.Vel;
gCorpses[find_id].FObj.Accel := FObj.Accel;
gCorpses[find_id].FPlayerUID := FUID;
Result := find_id;
end
else
Result := find_id;
end
else
- g_Player_CreateGibs(FObj.X + PLAYER_RECT_CX,
- FObj.Y + PLAYER_RECT_CY,
- FModel.Name, FModel.Color);
+ g_Player_CreateGibs(FObj.X + PLAYER_RECT_CX, FObj.Y + PLAYER_RECT_CY, FModel.id, FModel.Color);
end;
end;
procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
end;
end;
procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
-var
- SID: DWORD;
begin
if (gShells = nil) or (Length(gShells) = 0) then
Exit;
with gShells[CurrentShell] do
begin
begin
if (gShells = nil) or (Length(gShells) = 0) then
Exit;
with gShells[CurrentShell] do
begin
- SpriteID := 0;
g_Obj_Init(@Obj);
Obj.Rect.X := 0;
Obj.Rect.Y := 0;
if T = SHELL_BULLET then
begin
g_Obj_Init(@Obj);
Obj.Rect.X := 0;
Obj.Rect.Y := 0;
if T = SHELL_BULLET then
begin
- if g_Texture_Get('TEXTURE_SHELL_BULLET', SID) then
- SpriteID := SID;
- CX := 2;
- CY := 1;
Obj.Rect.Width := 4;
Obj.Rect.Height := 2;
end
else
begin
Obj.Rect.Width := 4;
Obj.Rect.Height := 2;
end
else
begin
- if g_Texture_Get('TEXTURE_SHELL_SHELL', SID) then
- SpriteID := SID;
- CX := 4;
- CY := 2;
Obj.Rect.Width := 7;
Obj.Rect.Height := 3;
end;
Obj.Rect.Width := 7;
Obj.Rect.Height := 3;
end;
end;
end;
end;
end;
-procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: string; fColor: TRGB);
+procedure g_Player_CreateGibs (fX, fY, mid: Integer; fColor: TRGB);
var
a: Integer;
GibsArray: TGibsArray;
Blood: TModelBlood;
begin
var
a: Integer;
GibsArray: TGibsArray;
Blood: TModelBlood;
begin
+ if mid = -1 then
+ Exit;
if (gGibs = nil) or (Length(gGibs) = 0) then
Exit;
if (gGibs = nil) or (Length(gGibs) = 0) then
Exit;
- if not g_PlayerModel_GetGibs(ModelName, GibsArray) then
+ if not g_PlayerModel_GetGibs(mid, GibsArray) then
Exit;
Exit;
- Blood := g_PlayerModel_GetBlood(ModelName);
+ Blood := PlayerModelsArray[mid].Blood;
for a := 0 to High(GibsArray) do
with gGibs[CurrentGib] do
begin
for a := 0 to High(GibsArray) do
with gGibs[CurrentGib] do
begin
+ ModelID := mid;
+ GibID := GibsArray[a];
Color := fColor;
Color := fColor;
- ID := GibsArray[a].ID;
- MaskID := GibsArray[a].MaskID;
alive := True;
g_Obj_Init(@Obj);
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);
+ {$IFNDEF HEADLESS}
+ Obj.Rect := r_Render_GetGibRect(ModelID, GibID);
+ {$ELSE}
+ Obj.Rect.X := 16;
+ Obj.Rect.Y := 16;
+ Obj.Rect.Width := 16;
+ Obj.Rect.Height := 16;
+ {$ENDIF}
+ 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);
g_Obj_PushA(@Obj, 25 + Random(10), Random(361));
positionChanged(); // this updates spatial accelerators
RAngle := Random(360);
if gCorpses[i] <> nil then
begin
// Название модели
if gCorpses[i] <> nil then
begin
// Название модели
- utils.writeStr(st, gCorpses[i].FModelName);
+ utils.writeStr(st, gCorpses[i].FModel.GetName());
// Тип смерти
utils.writeBool(st, gCorpses[i].Mess);
// Сохраняем данные трупа:
// Тип смерти
utils.writeBool(st, gCorpses[i].Mess);
// Сохраняем данные трупа:
FNetTime := 0;
FWaitForFirstSpawn := false;
FNetTime := 0;
FWaitForFirstSpawn := false;
+ FPunchAnim := TAnimationState.Create(False, 1, 4);
+ FPunchAnim.Disable;
resetWeaponQueue();
end;
resetWeaponQueue();
end;
FJetSoundOn.Free();
FJetSoundOff.Free();
FModel.Free();
FJetSoundOn.Free();
FJetSoundOff.Free();
FModel.Free();
- if FPunchAnim <> nil then
- FPunchAnim.Free();
+ FPunchAnim.Free();
inherited;
end;
procedure TPlayer.DoPunch();
inherited;
end;
procedure TPlayer.DoPunch();
-var
- id: DWORD;
- st: String;
begin
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();
end;
procedure TPlayer.Fire();
end;
procedure TPlayer.MakeBloodSimple(Count: Word);
end;
procedure TPlayer.MakeBloodSimple(Count: Word);
+ var Blood: TModelBlood;
begin
begin
+ Blood := SELF.FModel.GetBlood();
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)+8,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count div 2, 3, -1, 16, (PLAYER_RECT.Height*2 div 3),
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)+8,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count div 2, 3, -1, 16, (PLAYER_RECT.Height*2 div 3),
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-8,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count div 2, -3, -1, 16, (PLAYER_RECT.Height*2) div 3,
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-8,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count div 2, -3, -1, 16, (PLAYER_RECT.Height*2) div 3,
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
end;
procedure TPlayer.MakeBloodVector(Count: Word; VelX, VelY: Integer);
end;
procedure TPlayer.MakeBloodVector(Count: Word; VelX, VelY: Integer);
+ var Blood: TModelBlood;
begin
begin
+ Blood := SELF.FModel.GetBlood();
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count, VelX, VelY, 16, (PLAYER_RECT.Height*2) div 3,
g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
Count, VelX, VelY, 16, (PLAYER_RECT.Height*2) div 3,
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
end;
procedure TPlayer.ProcessWeaponAction(Action: Byte);
end;
procedure TPlayer.ProcessWeaponAction(Action: Byte);
var
RespawnPoint: TRespawnPoint;
a, b, c: Byte;
var
RespawnPoint: TRespawnPoint;
a, b, c: Byte;
- Anim: TAnimation;
- ID: DWORD;
begin
FSlopeOld := 0;
FIncCamOld := 0;
begin
FSlopeOld := 0;
FIncCamOld := 0;
// Анимация возрождения:
if (not gLoadGameMode) and (not Silent) then
// Анимация возрождения:
if (not gLoadGameMode) and (not Silent) then
- if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
- begin
- Anim := TAnimation.Create(ID, False, 3);
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+ );
FSpectator := False;
FGhost := False;
FSpectator := False;
FGhost := False;
end;
function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
end;
function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
-var
- Anim: TAnimation;
- ID: DWORD;
begin
Result := False;
begin
Result := False;
FJustTeleported := True;
FJustTeleported := True;
- Anim := nil;
if not silent then
begin
if not silent then
begin
- if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
- begin
- Anim := TAnimation.Create(ID, False, 3);
- end;
-
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj.X, FObj.Y);
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj.X, FObj.Y);
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+ );
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 1,
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 1,
end;
end;
end;
end;
- if not silent and (Anim <> nil) then
+ if not silent then
begin
begin
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
- Anim.Free();
-
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+ );
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 0,
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 0,
FLoss := 0;
end;
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 FAlive and (gFly or FJetpack) then
FlySmoke();
if (FActionAnim = A_PAIN) and (FModel.Animation <> A_PAIN) then
begin
FModel.ChangeAnimation(FActionAnim, FActionForce);
if (FActionAnim = A_PAIN) and (FModel.Animation <> A_PAIN) then
begin
FModel.ChangeAnimation(FActionAnim, FActionForce);
- FModel.GetCurrentAnimation.MinLength := i;
- FModel.GetCurrentAnimationMask.MinLength := i;
+ FModel.AnimState.MinLength := i;
end else FModel.ChangeAnimation(FActionAnim, FActionForce and (FModel.Animation <> A_STAND));
end else FModel.ChangeAnimation(FActionAnim, FActionForce and (FModel.Animation <> A_STAND));
- if (FModel.GetCurrentAnimation.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
+ if (FModel.AnimState.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
then SetAction(A_STAND, True);
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);
for b := Low(FKeys) to High(FKeys) do
if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
// Время до повторного респауна, смены оружия, исользования, захвата флага
for i := T_RESPAWN to T_FLAGCAP do utils.writeInt(st, LongWord(FTime[i]));
// Название модели
// Время до повторного респауна, смены оружия, исользования, захвата флага
for i := T_RESPAWN to T_FLAGCAP do utils.writeInt(st, LongWord(FTime[i]));
// Название модели
- utils.writeStr(st, FModel.Name);
+ utils.writeStr(st, FModel.GetName());
// Цвет модели
utils.writeInt(st, Byte(FColor.R));
utils.writeInt(st, Byte(FColor.G));
// Цвет модели
utils.writeInt(st, Byte(FColor.R));
utils.writeInt(st, Byte(FColor.G));
end;
procedure TPlayer.FlySmoke(Times: DWORD = 1);
end;
procedure TPlayer.FlySmoke(Times: DWORD = 1);
-var
- id, i: DWORD;
- Anim: TAnimation;
+ var i: DWORD;
begin
if (Random(5) = 1) and (Times = 1) then
Exit;
begin
if (Random(5) = 1) and (Times = 1) then
Exit;
Exit;
end;
Exit;
end;
- if g_Frames_Get(id, 'FRAMES_SMOKE') then
+ for i := 1 to Times do
begin
begin
- for i := 1 to Times do
- begin
- Anim := TAnimation.Create(id, False, 3);
- Anim.Alpha := 150;
- g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
- Obj.Y+Obj.Rect.Height-4+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(
+ R_GFX_SMOKE_TRANS,
+ Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_SMOKE_WIDTH div 2),
+ Obj.Y+Obj.Rect.Height-4+Random(8+Times*2)
+ );
end;
end;
procedure TPlayer.OnFireFlame(Times: DWORD = 1);
end;
end;
procedure TPlayer.OnFireFlame(Times: DWORD = 1);
-var
- id, i: DWORD;
- Anim: TAnimation;
+ var i: DWORD;
begin
if (Random(10) = 1) and (Times = 1) then
Exit;
begin
if (Random(10) = 1) and (Times = 1) then
Exit;
- if g_Frames_Get(id, 'FRAMES_FLAME') then
+ for i := 1 to Times do
begin
begin
- for i := 1 to Times do
- begin
- Anim := TAnimation.Create(id, False, 3);
- Anim.Alpha := 0;
- g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
- Obj.Y+8+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(
+ R_GFX_FLAME,
+ Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_FLAME_WIDTH div 2),
+ Obj.Y+8+Random(8+Times*2)
+ );
end;
end;
end;
end;
FObj.X := X;
FObj.Y := Y;
FObj.Rect := PLAYER_CORPSERECT;
FObj.X := X;
FObj.Y := Y;
FObj.Rect := PLAYER_CORPSERECT;
- FModelName := ModelName;
FMess := aMess;
FMess := aMess;
+ FModel := g_PlayerModel_Get(ModelName);
if FMess then
if FMess then
- begin
- FState := CORPSE_STATE_MESS;
- g_PlayerModel_GetAnim(ModelName, A_DIE2, FAnimation, FAnimationMask);
- end
+ begin
+ FState := CORPSE_STATE_MESS;
+ FModel.ChangeAnimation(A_DIE2);
+ end
else
else
- begin
- FState := CORPSE_STATE_NORMAL;
- g_PlayerModel_GetAnim(ModelName, A_DIE1, FAnimation, FAnimationMask);
- end;
+ begin
+ FState := CORPSE_STATE_NORMAL;
+ FModel.ChangeAnimation(A_DIE1);
+ end;
end;
destructor TCorpse.Destroy();
begin
end;
destructor TCorpse.Destroy();
begin
- FAnimation.Free();
-
+ FModel.Free;
inherited;
end;
inherited;
end;
procedure TCorpse.Damage(Value: Word; SpawnerUID: Word; vx, vy: Integer);
procedure TCorpse.Damage(Value: Word; SpawnerUID: Word; vx, vy: Integer);
-var
- pm: TPlayerModel;
- Blood: TModelBlood;
+ var Blood: TModelBlood;
begin
if FState = CORPSE_STATE_REMOVEME then
Exit;
begin
if FState = CORPSE_STATE_REMOVEME then
Exit;
FDamage := FDamage + Value;
if FDamage > 150 then
FDamage := FDamage + Value;
if FDamage > 150 then
+ begin
+ if FModel <> nil then
begin
begin
- if FAnimation <> nil then
- begin
- FAnimation.Free();
- FAnimation := nil;
-
- FState := CORPSE_STATE_REMOVEME;
-
- g_Player_CreateGibs(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
- FModelName, FColor);
- // Звук мяса от трупа:
- pm := g_PlayerModel_Get(FModelName);
- pm.PlaySound(MODELSOUND_DIE, 5, FObj.X, FObj.Y);
- pm.Free;
-
- // Зловещий смех:
- if (gBodyKillEvent <> -1)
- and gDelayedEvents[gBodyKillEvent].Pending then
- gDelayedEvents[gBodyKillEvent].Pending := False;
- gBodyKillEvent := g_Game_DelayEvent(DE_BODYKILL, 1050, SpawnerUID);
- end;
+ FState := CORPSE_STATE_REMOVEME;
+
+ g_Player_CreateGibs(
+ FObj.X + FObj.Rect.X + (FObj.Rect.Width div 2),
+ FObj.Y + FObj.Rect.Y + (FObj.Rect.Height div 2),
+ FModel.id,
+ FModel.Color
+ );
+
+ // Звук мяса от трупа:
+ FModel.PlaySound(MODELSOUND_DIE, 5, FObj.X, FObj.Y);
+
+ // Зловещий смех:
+ if (gBodyKillEvent <> -1) and gDelayedEvents[gBodyKillEvent].Pending then
+ gDelayedEvents[gBodyKillEvent].Pending := False;
+ gBodyKillEvent := g_Game_DelayEvent(DE_BODYKILL, 1050, SpawnerUID);
+
+ FModel.Free;
+ FModel := nil;
end
end
+ end
else
begin
else
begin
- Blood := g_PlayerModel_GetBlood(FModelName);
+ Blood := FModel.GetBlood();
FObj.Vel.X := FObj.Vel.X + vx;
FObj.Vel.Y := FObj.Vel.Y + vy;
g_GFX_Blood(FObj.X+PLAYER_CORPSERECT.X+(PLAYER_CORPSERECT.Width div 2),
FObj.Vel.X := FObj.Vel.X + vx;
FObj.Vel.Y := FObj.Vel.Y + vy;
g_GFX_Blood(FObj.X+PLAYER_CORPSERECT.X+(PLAYER_CORPSERECT.Width div 2),
Exit;
end;
Exit;
end;
- if FAnimation <> nil then
- FAnimation.Update();
- if FAnimationMask <> nil then
- FAnimationMask.Update();
+ if FModel <> nil then
+ FModel.Update;
end;
procedure TCorpse.SaveState (st: TStream);
end;
procedure TCorpse.SaveState (st: TStream);
-var
- anim: Boolean;
+ var anim: Boolean;
begin
assert(st <> nil);
begin
assert(st <> nil);
// Накопленный урон
utils.writeInt(st, Byte(FDamage));
// Цвет
// Накопленный урон
utils.writeInt(st, Byte(FDamage));
// Цвет
- utils.writeInt(st, Byte(FColor.R));
- utils.writeInt(st, Byte(FColor.G));
- utils.writeInt(st, Byte(FColor.B));
+ utils.writeInt(st, Byte(FModel.Color.R));
+ utils.writeInt(st, Byte(FModel.Color.G));
+ utils.writeInt(st, Byte(FModel.Color.B));
// Объект трупа
Obj_SaveState(st, @FObj);
utils.writeInt(st, Word(FPlayerUID));
// Объект трупа
Obj_SaveState(st, @FObj);
utils.writeInt(st, Word(FPlayerUID));
- // Есть ли анимация
- anim := (FAnimation <> nil);
+ // animation
+ anim := (FModel <> nil);
utils.writeBool(st, anim);
utils.writeBool(st, anim);
- // Если есть - сохраняем
- if anim then FAnimation.SaveState(st);
- // Есть ли маска анимации
- anim := (FAnimationMask <> nil);
+ if anim then FModel.AnimState.SaveState(st, 0, False);
+ // animation for mask (same as animation, compat with older saves)
+ anim := (FModel <> nil);
utils.writeBool(st, anim);
utils.writeBool(st, anim);
- // Если есть - сохраняем
- if anim then FAnimationMask.SaveState(st);
+ if anim then FModel.AnimState.SaveState(st, 0, False);
end;
procedure TCorpse.LoadState (st: TStream);
end;
procedure TCorpse.LoadState (st: TStream);
-var
- anim: Boolean;
+ var anim, blending: Boolean; r, g, b, alpha: Byte; stub: TAnimationState;
begin
assert(st <> nil);
begin
assert(st <> nil);
// Накопленный урон
FDamage := utils.readByte(st);
// Цвет
// Накопленный урон
FDamage := utils.readByte(st);
// Цвет
- FColor.R := utils.readByte(st);
- FColor.G := utils.readByte(st);
- FColor.B := utils.readByte(st);
+ r := utils.readByte(st);
+ g := utils.readByte(st);
+ b := utils.readByte(st);
+ FModel.SetColor(r, g, b);
// Объект трупа
Obj_LoadState(@FObj, st);
FPlayerUID := utils.readWord(st);
// Объект трупа
Obj_LoadState(@FObj, st);
FPlayerUID := utils.readWord(st);
- // Есть ли анимация
+ // animation
+ stub := TAnimationState.Create(False, 0, 0);
anim := utils.readBool(st);
anim := utils.readBool(st);
- // Если есть - загружаем
if anim then
begin
if anim then
begin
- Assert(FAnimation <> nil, 'TCorpse.LoadState: no FAnimation');
- FAnimation.LoadState(st);
- end;
- // Есть ли маска анимации
- anim := utils.readBool(st);
- // Если есть - загружаем
- if anim then
+ stub.LoadState(st, alpha, blending);
+ FModel.AnimState.CurrentFrame := Min(stub.CurrentFrame, FModel.AnimState.Length);
+ end
+ else
begin
begin
- Assert(FAnimationMask <> nil, 'TCorpse.LoadState: no FAnimationMask');
- FAnimationMask.LoadState(st);
+ FModel.Free;
+ FModel := nil
end;
end;
+ // animation for mask (same as animation, compat with older saves)
+ anim := utils.readBool(st);
+ if anim then stub.LoadState(st, alpha, blending);
+ stub.Free;
end;
{ T B o t : }
end;
{ T B o t : }