index 1d1fca781779cccd2b76e08cc34ab2af6a458046..7a55bf758b8b9744c5a7883c43fbcb0659d23351 100644 (file)
interface
interface
- uses MAPDEF, g_textures, g_base, g_basic, g_weapons, utils, g_gfx;
+ uses MAPDEF, g_animations, g_base, g_basic, g_weapons, utils;
const
A_STAND = 0;
const
A_STAND = 0;
W_POS_NORMAL = 0;
W_POS_UP = 1;
W_POS_DOWN = 2;
W_POS_NORMAL = 0;
W_POS_UP = 1;
W_POS_DOWN = 2;
+ W_POS_LAST = W_POS_DOWN;
W_ACT_NORMAL = 0;
W_ACT_FIRE = 1;
W_ACT_NORMAL = 0;
W_ACT_FIRE = 1;
+ W_ACT_LAST = W_ACT_FIRE;
FLAG_BASEPOINT: TDFPoint = (X:16; Y:43);
type
TWeaponPoints = Array [WP_FIRST + 1..WP_LAST, A_STAND..A_LAST, TDirection.D_LEFT..TDirection.D_RIGHT] of Array of TDFPoint;
FLAG_BASEPOINT: TDFPoint = (X:16; Y:43);
type
TWeaponPoints = Array [WP_FIRST + 1..WP_LAST, A_STAND..A_LAST, TDirection.D_LEFT..TDirection.D_RIGHT] of Array of TDFPoint;
- TModelMatrix = Array [TDirection.D_LEFT..TDirection.D_RIGHT, A_STAND..A_LAST] of TAnimationState;
-
TModelTextures = Array [TDirection.D_LEFT..TDirection.D_RIGHT, A_STAND..A_LAST] of record
Resource: String;
Mask: String;
TModelTextures = Array [TDirection.D_LEFT..TDirection.D_RIGHT, A_STAND..A_LAST] of record
Resource: String;
Mask: String;
Back: Boolean;
end;
Back: Boolean;
end;
+{$IFDEF ENABLE_GFX}
TModelBlood = record
R, G, B, Kind: Byte;
end;
TModelBlood = record
R, G, B, Kind: Byte;
end;
+{$ENDIF}
TModelSound = record
ID: DWORD;
TModelSound = record
ID: DWORD;
TModelSoundArray = Array of TModelSound;
TModelSoundArray = Array of TModelSound;
- TGibsArray = Array of Integer;
-
TPlayerModel = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
private
FDirection: TDirection;
FColor: TRGB;
FCurrentAnimation: Byte;
TPlayerModel = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
private
FDirection: TDirection;
FColor: TRGB;
FCurrentAnimation: Byte;
- FAnimState: TAnimationState;
+ FAnimState: TAnimState;
FCurrentWeapon: Byte;
FFlag: Byte;
FFireCounter: Byte;
FCurrentWeapon: Byte;
FFlag: Byte;
FFireCounter: Byte;
function PlaySound(SoundType, Level: Byte; X, Y: Integer): Boolean;
procedure Update();
function PlaySound(SoundType, Level: Byte; X, Y: Integer): Boolean;
procedure Update();
- function GetBlood (): TModelBlood;
+ {$IFDEF ENABLE_GFX}
+ function GetBlood (): TModelBlood;
+ {$ENDIF}
+
function GetName (): String;
published
function GetName (): String;
published
public
property Color: TRGB read FColor write FColor;
public
property Color: TRGB read FColor write FColor;
- property AnimState: TAnimationState read FAnimState;
+ property AnimState: TAnimState read FAnimState;
property CurrentAnimation: Byte read FCurrentAnimation;
property CurrentWeapon: Byte read FCurrentWeapon;
property Flag: Byte read FFlag;
property CurrentAnimation: Byte read FCurrentAnimation;
property CurrentWeapon: Byte read FCurrentWeapon;
property Flag: Byte read FFlag;
procedure g_PlayerModel_FreeData();
function g_PlayerModel_Load(FileName: String): Boolean;
function g_PlayerModel_GetNames(): SSArray;
procedure g_PlayerModel_FreeData();
function g_PlayerModel_Load(FileName: String): Boolean;
function g_PlayerModel_GetNames(): SSArray;
-function g_PlayerModel_GetBlood(ModelName: String): TModelBlood;
function g_PlayerModel_Get(ModelName: String): TPlayerModel;
function g_PlayerModel_Get(ModelName: String): TPlayerModel;
-function g_PlayerModel_GetGibs (ModelID: Integer; var Gibs: TGibsArray): Boolean;
function g_PlayerModel_GetIndex (ModelName: String): Integer;
function g_PlayerModel_GetIndex (ModelName: String): Integer;
+{$IFDEF ENABLE_GFX}
+ function g_PlayerModel_GetBlood(ModelName: String): TModelBlood;
+{$ENDIF}
+
procedure g_PlayerModel_LoadFake (ModelName, FileName: String);
(* --- private data --- *)
procedure g_PlayerModel_LoadFake (ModelName, FileName: String);
(* --- private data --- *)
PainSounds: TModelSoundArray;
DieSounds: TModelSoundArray;
SlopSound: Byte;
PainSounds: TModelSoundArray;
DieSounds: TModelSoundArray;
SlopSound: Byte;
- Blood: TModelBlood;
+ {$IFDEF ENABLE_GFX}
+ Blood: TModelBlood;
+ {$ENDIF}
// =======================
FileName: String;
Anim: TModelTextures;
// =======================
FileName: String;
Anim: TModelTextures;
- GibsCount: Integer;
- GibsResource:String;
- GibsMask: String;
- GibsOnce: Integer;
+ {$IFDEF ENABLE_GIBS}
+ GibsCount: Integer;
+ GibsResource:String;
+ GibsMask: String;
+ GibsOnce: Integer;
+ {$ENDIF}
end;
var
end;
var
implementation
implementation
-uses
- g_sound, g_console, SysUtils, g_player, CONFIG,
- e_sound, g_options, g_map, Math, e_log, wadreader;
+ uses
+ {$IFDEF ENABLE_GFX}
+ g_gfx,
+ {$ENDIF}
+ g_sound, g_console, SysUtils, g_player, CONFIG,
+ e_sound, g_options, g_map, Math, e_log, wadreader
+ ;
const
FLAG_DEFPOINT: TDFPoint = (X:32; Y:16);
const
FLAG_DEFPOINT: TDFPoint = (X:32; Y:16);
PlayerModelsArray[ID].Author := config.ReadStr('Model', 'author', '');
PlayerModelsArray[ID].Description := config.ReadStr('Model', 'description', '');
PlayerModelsArray[ID].FileName := FileName;
PlayerModelsArray[ID].Author := config.ReadStr('Model', 'author', '');
PlayerModelsArray[ID].Description := config.ReadStr('Model', 'description', '');
PlayerModelsArray[ID].FileName := FileName;
- with PlayerModelsArray[ID] do
- begin
- Blood.R := MAX(0, MIN(255, config.ReadInt('Blood', 'R', 150)));
- Blood.G := MAX(0, MIN(255, config.ReadInt('Blood', 'G', 0)));
- Blood.B := MAX(0, MIN(255, config.ReadInt('Blood', 'B', 0)));
- case config.ReadStr('Blood', 'Kind', 'NORMAL') of
- 'NORMAL': Blood.Kind := BLOOD_NORMAL;
- 'SPARKS': Blood.Kind := BLOOD_CSPARKS;
- 'COMBINE': Blood.Kind := BLOOD_COMBINE;
- else
- Blood.Kind := BLOOD_NORMAL
- end
- end;
+
+ {$IFDEF ENABLE_GFX}
+ with PlayerModelsArray[ID] do
+ begin
+ Blood.R := MAX(0, MIN(255, config.ReadInt('Blood', 'R', 150)));
+ Blood.G := MAX(0, MIN(255, config.ReadInt('Blood', 'G', 0)));
+ Blood.B := MAX(0, MIN(255, config.ReadInt('Blood', 'B', 0)));
+ case config.ReadStr('Blood', 'Kind', 'NORMAL') of
+ 'NORMAL': Blood.Kind := BLOOD_NORMAL;
+ 'SPARKS': Blood.Kind := BLOOD_CSPARKS;
+ 'COMBINE': Blood.Kind := BLOOD_COMBINE;
+ else
+ Blood.Kind := BLOOD_NORMAL
+ end
+ end;
+ {$ENDIF}
for b := A_STAND to A_LAST do
begin
for b := A_STAND to A_LAST do
begin
SlopSound := Min(Max(config.ReadInt('Sound', 'slop', 0), 0), 2);
SlopSound := Min(Max(config.ReadInt('Sound', 'slop', 0), 0), 2);
- GibsCount := config.ReadInt('Gibs', 'count', 0);
- GibsResource := config.ReadStr('Gibs', 'resource', 'GIBS');
- GibsMask := config.ReadStr('Gibs', 'mask', 'GIBSMASK');
- GibsOnce := config.ReadInt('Gibs', 'once', -1);
+ {$IFDEF ENABLE_GIBS}
+ GibsCount := config.ReadInt('Gibs', 'count', 0);
+ GibsResource := config.ReadStr('Gibs', 'resource', 'GIBS');
+ GibsMask := config.ReadStr('Gibs', 'mask', 'GIBSMASK');
+ GibsOnce := config.ReadInt('Gibs', 'once', -1);
+ {$ENDIF}
ok := True;
for aa := WP_FIRST + 1 to WP_LAST do
ok := True;
for aa := WP_FIRST + 1 to WP_LAST do
end;
end;
end;
end;
- function g_PlayerModel_GetGibs (ModelID: Integer; var Gibs: TGibsArray): Boolean;
- var i, b: Integer; c: Boolean;
- begin
- Gibs := nil;
- Result := False;
- if (PlayerModelsArray = nil) or (gGibsCount = 0) then
- Exit;
-
- c := False;
- SetLength(Gibs, gGibsCount);
- for i := 0 to High(Gibs) do
- begin
- if c and (PlayerModelsArray[ModelID].GibsCount = 1) then
- begin
- SetLength(Gibs, i);
- Break;
- end;
-
- repeat
- b := Random(PlayerModelsArray[ModelID].GibsCount);
- until not ((PlayerModelsArray[ModelID].GibsOnce = b + 1) and c);
-
- Gibs[i] := b;
-
- c := PlayerModelsArray[ModelID].GibsOnce = b + 1;
- end;
- Result := True;
- end;
-
function g_PlayerModel_GetNames(): SSArray;
var
i: DWORD;
function g_PlayerModel_GetNames(): SSArray;
var
i: DWORD;
end;
end;
end;
end;
+{$IFDEF ENABLE_GFX}
function g_PlayerModel_GetBlood(ModelName: string): TModelBlood;
var
a: Integer;
function g_PlayerModel_GetBlood(ModelName: string): TModelBlood;
var
a: Integer;
Break;
end;
end;
Break;
end;
end;
+{$ENDIF}
procedure g_PlayerModel_FreeData();
var i, b: Integer;
procedure g_PlayerModel_FreeData();
var i, b: Integer;
{ TPlayerModel }
procedure TPlayerModel.ChangeAnimation (Animation: Byte; Force: Boolean = False);
{ TPlayerModel }
procedure TPlayerModel.ChangeAnimation (Animation: Byte; Force: Boolean = False);
- var once: Boolean; speed, count: Integer;
+ var loop: Boolean; speed, count: Integer;
begin
if not Force then
if FCurrentAnimation = Animation then
Exit;
FCurrentAnimation := Animation;
begin
if not Force then
if FCurrentAnimation = Animation then
Exit;
FCurrentAnimation := Animation;
- once := FCurrentAnimation in [A_STAND, A_WALK];
+ loop := FCurrentAnimation in [A_STAND, A_WALK];
speed := PlayerModelsArray[FID].ModelSpeed[FCurrentAnimation];
count := PlayerModelsArray[FID].Anim[FDirection, FCurrentAnimation].Frames;
speed := PlayerModelsArray[FID].ModelSpeed[FCurrentAnimation];
count := PlayerModelsArray[FID].Anim[FDirection, FCurrentAnimation].Frames;
- FAnimState := TAnimationState.Create(once, speed, count);
+ FAnimState := TAnimState.Create(loop, speed, count);
end;
destructor TPlayerModel.Destroy();
begin
end;
destructor TPlayerModel.Destroy();
begin
- FAnimState.Free;
+ FAnimState.Invalidate;
inherited;
end;
inherited;
end;
procedure TPlayerModel.SetFire (Fire: Boolean);
begin
if Fire then
procedure TPlayerModel.SetFire (Fire: Boolean);
begin
if Fire then
- FFireCounter := PlayerModelsArray[FID].ModelSpeed[A_ATTACK] * PlayerModelsArray[FID].Anim[TDirection.D_RIGHT, A_ATTACK].Frames
+ FFireCounter := PlayerModelsArray[FID].ModelSpeed[A_ATTACK] * PlayerModelsArray[FID].Anim[TDirection.D_RIGHT, A_ATTACK].Frames + 1
else
FFireCounter := 0
end;
else
FFireCounter := 0
end;
FCurrentWeapon := Weapon
end;
FCurrentWeapon := Weapon
end;
+{$IFDEF ENABLE_GFX}
function TPlayerModel.GetBlood (): TModelBlood;
begin
Result := PlayerModelsArray[FID].Blood
end;
function TPlayerModel.GetBlood (): TModelBlood;
begin
Result := PlayerModelsArray[FID].Blood
end;
+{$ENDIF}
function TPlayerModel.GetName (): String;
begin
function TPlayerModel.GetName (): String;
begin
procedure TPlayerModel.Update;
begin
procedure TPlayerModel.Update;
begin
- if FAnimState <> nil then
+ if FAnimState.IsValid() then
FAnimState.Update;
if FFireCounter > 0 then
Dec(FFireCounter)
FAnimState.Update;
if FFireCounter > 0 then
Dec(FFireCounter)