6 g_textures
, g_basic
, e_graphics
, WADEDITOR
,
44 TModelSoundArray
= Array of TModelSound
;
45 TGibsArray
= Array of TGibSprite
;
46 TWeaponPoints
= Array [WEAPON_SAW
..WEAPON_SUPERPULEMET
] of
47 Array [A_STAND
..A_PAIN
] of
48 Array [D_LEFT
..D_RIGHT
] of Array of TPoint
;
50 TPlayerModel
= class (TObject
)
53 FDirection
: TDirection
;
55 FCurrentAnimation
: Byte;
56 FAnim
: Array [D_LEFT
..D_RIGHT
] of Array [A_STAND
..A_PAIN
] of TAnimation
;
57 FMaskAnim
: Array [D_LEFT
..D_RIGHT
] of Array [A_STAND
..A_PAIN
] of TAnimation
;
58 FWeaponPoints
: TWeaponPoints
;
59 FPainSounds
: TModelSoundArray
;
60 FDieSounds
: TModelSoundArray
;
67 FFlagAnim
: TAnimation
;
72 destructor Destroy(); override;
73 procedure ChangeAnimation(Animation
: Byte; Force
: Boolean = False);
74 function GetCurrentAnimation
: TAnimation
;
75 function GetCurrentAnimationMask
: TAnimation
;
76 procedure SetColor(Red
, Green
, Blue
: Byte);
77 procedure SetWeapon(Weapon
: Byte);
78 procedure SetFlag(Flag
: Byte);
79 procedure SetFire(Fire
: Boolean);
80 function PlaySound(SoundType
, Level
: Byte; X
, Y
: Integer): Boolean;
82 procedure Draw(X
, Y
: Integer; Alpha
: Byte = 0);
84 property Fire
: Boolean read FFire
;
85 property Direction
: TDirection read FDirection write FDirection
;
86 property Animation
: Byte read FCurrentAnimation
;
87 property Weapon
: Byte read FCurrentWeapon
;
88 property Name
: String read FName
;
89 property Color
: TRGB read FColor write FColor
;
92 procedure g_PlayerModel_LoadData();
93 procedure g_PlayerModel_FreeData();
94 function g_PlayerModel_Load(FileName
: String): Boolean;
95 function g_PlayerModel_GetNames(): SArray
;
96 function g_PlayerModel_GetInfo(ModelName
: String): TModelInfo
;
97 function g_PlayerModel_Get(ModelName
: String): TPlayerModel
;
98 function g_PlayerModel_GetAnim(ModelName
: String; Anim
: Byte; var _Anim
, _Mask
: TAnimation
): Boolean;
99 function g_PlayerModel_GetGibs(ModelName
: String; var Gibs
: TGibsArray
): Boolean;
104 g_main
, g_sound
, g_console
, SysUtils
, g_player
, CONFIG
,
105 GL
, GLExt
, e_sound
, g_options
, g_map
, Math
, e_log
;
108 TPlayerModelInfo
= record
110 ModelSpeed
: Array [A_STAND
..A_PAIN
] of Byte;
113 WeaponPoints
: TWeaponPoints
;
115 PainSounds
: TModelSoundArray
;
116 DieSounds
: TModelSoundArray
;
128 FLAG_BASEPOINT
: TPoint
= (X
:16; Y
:43);
129 FLAG_DEFPOINT
: TPoint
= (X
:32; Y
:16);
131 WEAPONBASE
: Array [WEAPON_SAW
..WEAPON_SUPERPULEMET
] of TPoint
=
132 ((X
:8; Y
:4), (X
:8; Y
:8), (X
:16; Y
:16), (X
:16; Y
:24),
133 (X
:16; Y
:16), (X
:24; Y
:24), (X
:16; Y
:16), (X
:24; Y
:24), (X
:16; Y
:16));
135 AnimNames
: Array [A_STAND
..A_PAIN
] of String =
136 ('StandAnim','WalkAnim','Die1Anim','Die2Anim','AttackAnim',
137 'SeeUpAnim','SeeDownAnim','AttackUpAnim','AttackDownAnim','PainAnim');
138 WeapNames
: Array [WEAPON_SAW
..WEAPON_SUPERPULEMET
] of String =
139 ('csaw', 'hgun', 'sg', 'ssg', 'mgun', 'rkt', 'plz', 'bfg', 'spl');
142 WeaponID
: Array [WEAPON_SAW
..WEAPON_SUPERPULEMET
] of
143 Array [W_POS_NORMAL
..W_POS_DOWN
] of
144 Array [W_ACT_NORMAL
..W_ACT_FIRE
] of DWORD
;
145 PlayerModelsArray
: Array of TPlayerModelInfo
;
147 procedure g_PlayerModel_LoadData();
151 for a
:= WEAPON_SAW
to WEAPON_SUPERPULEMET
do
153 g_Texture_CreateWAD(WeaponID
[a
][W_POS_NORMAL
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
]));
154 g_Texture_CreateWAD(WeaponID
[a
][W_POS_NORMAL
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_FIRE');
155 g_Texture_CreateWAD(WeaponID
[a
][W_POS_UP
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_UP');
156 g_Texture_CreateWAD(WeaponID
[a
][W_POS_UP
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_UP_FIRE');
157 g_Texture_CreateWAD(WeaponID
[a
][W_POS_DOWN
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_DN');
158 g_Texture_CreateWAD(WeaponID
[a
][W_POS_DOWN
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_DN_FIRE');
162 function GetPoint(var str
: String; var point
: TPoint
): Boolean;
170 if Length(str
) < 3 then
173 for a
:= 1 to Length(str
) do
174 if (str
[a
] = ',') or (a
= Length(str
)) then
176 s
:= Copy(str
, 1, a
);
177 if s
[Length(s
)] = ',' then
178 SetLength(s
, Length(s
)-1);
181 if (Sscanf(s
, '%d:%d', [@x
, @y
]) < 2) or
182 (x
< -64) or (x
> 128) or
183 (y
< -64) or (y
> 128) then
195 function GetWeapPoints(str
: String; weapon
: Byte; anim
: Byte; dir
: TDirection
;
196 frames
: Word; backanim
: Boolean; var wpoints
: TWeaponPoints
): Boolean;
205 backanim
:= backanim
and (frames
> 2);
207 for a
:= 1 to frames
do
209 if not GetPoint(str
, wpoints
[weapon
, anim
, dir
, a
-1]) then
212 with wpoints
[weapon
, anim
, dir
, a
-1] do
214 X
:= X
- WEAPONBASE
[weapon
].X
;
215 Y
:= Y
- WEAPONBASE
[weapon
].Y
;
221 h
:= High(wpoints
[weapon
, anim
, dir
]);
223 for b
:= h
downto frames
do
224 wpoints
[weapon
, anim
, dir
, b
] := wpoints
[weapon
, anim
, dir
, h
-b
+1];
229 function g_PlayerModel_Load(FileName
: string): Boolean;
232 a
, b
, len
, aa
, bb
, f
: Integer;
235 pData
, pData2
: Pointer;
241 e_WriteLog(Format('Loading player model: %s', [ExtractFileName(FileName
)]), MSG_NOTIFY
);
245 WAD
:= TWADEditor_1
.Create
;
246 WAD
.ReadFile(FileName
);
248 if WAD
.GetLastError
<> DFWAD_NOERROR
then
254 if not WAD
.GetResource('TEXT', 'MODEL', pData
, len
) then
260 config
:= TConfig
.CreateMem(pData
, len
);
263 s
:= config
.ReadStr('Model', 'name', '');
271 SetLength(PlayerModelsArray
, Length(PlayerModelsArray
)+1);
272 ID
:= High(PlayerModelsArray
);
274 prefix
:= FileName
+':TEXTURES\';
276 with PlayerModelsArray
[ID
].Info
do
279 Author
:= config
.ReadStr('Model', 'author', '');
280 Description
:= config
.ReadStr('Model', 'description', '');
283 for b
:= A_STAND
to A_PAIN
do
285 if not (g_Frames_CreateWAD(nil, s
+'_RIGHTANIM'+IntToStr(b
),
286 prefix
+config
.ReadStr(AnimNames
[b
], 'resource', ''),
287 64, 64, config
.ReadInt(AnimNames
[b
], 'frames', 1),
288 config
.ReadBool(AnimNames
[b
], 'backanim', False)) and
289 g_Frames_CreateWAD(nil, s
+'_RIGHTANIM'+IntToStr(b
)+'_MASK',
290 prefix
+config
.ReadStr(AnimNames
[b
], 'mask', ''),
291 64, 64, config
.ReadInt(AnimNames
[b
], 'frames', 1),
292 config
.ReadBool(AnimNames
[b
], 'backanim', False))) then
299 for aa
:= WEAPON_SAW
to WEAPON_SUPERPULEMET
do
300 for bb
:= A_STAND
to A_PAIN
do
301 for cc
:= D_LEFT
to D_RIGHT
do
303 f
:= config
.ReadInt(AnimNames
[bb
], 'frames', 1);
304 if config
.ReadBool(AnimNames
[bb
], 'backanim', False) then
305 if f
> 2 then f
:= 2*f
-2;
306 SetLength(PlayerModelsArray
[ID
].WeaponPoints
[aa
, bb
, cc
], f
);
309 if (config
.ReadStr(AnimNames
[b
], 'resource2', '') <> '') and
310 (config
.ReadStr(AnimNames
[b
], 'mask2', '') <> '') then
312 g_Frames_CreateWAD(nil, s
+'_LEFTANIM'+IntToStr(b
),
313 prefix
+config
.ReadStr(AnimNames
[b
], 'resource2', ''),
314 64, 64, config
.ReadInt(AnimNames
[b
], 'frames', 1),
315 config
.ReadBool(AnimNames
[b
], 'backanim', False));
317 g_Frames_CreateWAD(nil, s
+'_LEFTANIM'+IntToStr(b
)+'_MASK',
318 prefix
+config
.ReadStr(AnimNames
[b
], 'mask2', ''),
319 64, 64, config
.ReadInt(AnimNames
[b
], 'frames', 1),
320 config
.ReadBool(AnimNames
[b
], 'backanim', False));
323 PlayerModelsArray
[ID
].ModelSpeed
[b
] := Max(1, config
.ReadInt(AnimNames
[b
], 'waitcount', 1) div 3);
326 with PlayerModelsArray
[ID
], config
do
328 prefix
:= FileName
+':SOUNDS\';
332 s
:= config
.ReadStr('Sound', 'pain'+IntToStr(a
), '');
335 SetLength(PainSounds
, Length(PainSounds
)+1);
336 g_Sound_CreateWAD(PainSounds
[High(PainSounds
)].ID
, prefix
+s
);
337 PainSounds
[High(PainSounds
)].Level
:= config
.ReadInt('Sound', 'painlevel'+IntToStr(a
), 1);
344 s
:= config
.ReadStr('Sound', 'die'+IntToStr(a
), '');
347 SetLength(DieSounds
, Length(DieSounds
)+1);
348 g_Sound_CreateWAD(DieSounds
[High(DieSounds
)].ID
, prefix
+s
);
349 DieSounds
[High(DieSounds
)].Level
:= config
.ReadInt('Sound', 'dielevel'+IntToStr(a
), 1);
354 SlopSound
:= Min(Max(config
.ReadInt('Sound', 'slop', 0), 0), 2);
356 SetLength(Gibs
, ReadInt('Gibs', 'count', 0));
359 (WAD
.GetResource('TEXTURES', config
.ReadStr('Gibs', 'resource', 'GIBS'), pData
, len
)) and
360 (WAD
.GetResource('TEXTURES', config
.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2
, len
)) then
362 for a
:= 0 to High(Gibs
) do
363 if e_CreateTextureMemEx(pData
, Gibs
[a
].ID
, a
*32, 0, 32, 32) and
364 e_CreateTextureMemEx(pData2
, Gibs
[a
].MaskID
, a
*32, 0, 32, 32) then
366 Gibs
[a
].Rect
:= e_GetTextureSize2(Gibs
[a
].ID
);
368 if Height
> 3 then Height
:= Height
-1-Random(2);
369 Gibs
[a
].OnlyOne
:= config
.ReadInt('Gibs', 'once', -1) = a
+1;
377 for aa
:= WEAPON_SAW
to WEAPON_SUPERPULEMET
do
378 for bb
:= A_STAND
to A_PAIN
do
379 if not (bb
in [A_DIE1
, A_DIE2
, A_PAIN
]) then
381 ok
:= ok
and GetWeapPoints(config
.ReadStr(AnimNames
[bb
], WeapNames
[aa
]+'_points', ''), aa
, bb
, D_RIGHT
,
382 config
.ReadInt(AnimNames
[bb
], 'frames', 0),
383 config
.ReadBool(AnimNames
[bb
], 'backanim', False),
386 if not GetWeapPoints(config
.ReadStr(AnimNames
[bb
], WeapNames
[aa
]+'2_points', ''), aa
, bb
, D_LEFT
,
387 config
.ReadInt(AnimNames
[bb
], 'frames', 0),
388 config
.ReadBool(AnimNames
[bb
], 'backanim', False),
390 for f
:= 0 to High(WeaponPoints
[aa
, bb
, D_RIGHT
]) do
392 WeaponPoints
[aa
, bb
, D_LEFT
, f
].X
:= -WeaponPoints
[aa
, bb
, D_RIGHT
, f
].X
;
393 WeaponPoints
[aa
, bb
, D_LEFT
, f
].Y
:= WeaponPoints
[aa
, bb
, D_RIGHT
, f
].Y
;
396 if not ok
then Break
;
398 {if ok then g_Console_Add(Info.Name+' weapon points ok')
399 else g_Console_Add(Info.Name+' weapon points fail');}
400 Info
.HaveWeapon
:= ok
;
402 s
:= config
.ReadStr('Model', 'flag_point', '');
403 if not GetPoint(s
, FlagPoint
) then FlagPoint
:= FLAG_DEFPOINT
;
405 FlagAngle
:= config
.ReadInt('Model', 'flag_angle', FLAG_DEFANGLE
);
414 function g_PlayerModel_Get(ModelName
: String): TPlayerModel
;
422 if PlayerModelsArray
= nil then Exit
;
424 for a
:= 0 to High(PlayerModelsArray
) do
425 if AnsiLowerCase(PlayerModelsArray
[a
].Info
.Name
) = AnsiLowerCase(ModelName
) then
427 Result
:= TPlayerModel
.Create
;
429 with PlayerModelsArray
[a
] do
431 Result
.FName
:= Info
.Name
;
433 for b
:= A_STAND
to A_PAIN
do
435 if not (g_Frames_Get(ID
, Info
.Name
+'_RIGHTANIM'+IntToStr(b
)) and
436 g_Frames_Get(ID2
, Info
.Name
+'_RIGHTANIM'+IntToStr(b
)+'_MASK')) then
443 Result
.FAnim
[D_RIGHT
][b
] := TAnimation
.Create(ID
, b
in [A_STAND
, A_WALK
], ModelSpeed
[b
]);
445 Result
.FMaskAnim
[D_RIGHT
][b
] := TAnimation
.Create(ID2
, b
in [A_STAND
, A_WALK
], ModelSpeed
[b
]);
447 if g_Frames_Exists(Info
.Name
+'_LEFTANIM'+IntToStr(b
)) and
448 g_Frames_Exists(Info
.Name
+'_LEFTANIM'+IntToStr(b
)+'_MASK') then
449 if g_Frames_Get(ID
, Info
.Name
+'_LEFTANIM'+IntToStr(b
)) and
450 g_Frames_Get(ID2
, Info
.Name
+'_LEFTANIM'+IntToStr(b
)+'_MASK') then
452 Result
.FAnim
[D_LEFT
][b
] := TAnimation
.Create(ID
, b
in [A_STAND
, A_WALK
], ModelSpeed
[b
]);
454 Result
.FMaskAnim
[D_LEFT
][b
] := TAnimation
.Create(ID2
, b
in [A_STAND
, A_WALK
], ModelSpeed
[b
]);
457 Result
.FPainSounds
:= PainSounds
;
458 Result
.FDieSounds
:= DieSounds
;
459 Result
.FSlopSound
:= SlopSound
;
462 Result
.FDrawWeapon
:= Info
.HaveWeapon
;
463 Result
.FWeaponPoints
:= WeaponPoints
;
465 Result
.FFlagPoint
:= FlagPoint
;
466 Result
.FFlagAngle
:= FlagAngle
;
473 function g_PlayerModel_GetAnim(ModelName
: string; Anim
: Byte; var _Anim
, _Mask
: TAnimation
): Boolean;
481 if PlayerModelsArray
= nil then Exit
;
482 for a
:= 0 to High(PlayerModelsArray
) do
483 if PlayerModelsArray
[a
].Info
.Name
= ModelName
then
484 with PlayerModelsArray
[a
] do
486 if Anim
in [A_STAND
, A_WALK
] then c
:= True else c
:= False;
488 if not g_Frames_Get(ID
, Info
.Name
+'_RIGHTANIM'+IntToStr(Anim
)) then
489 if not g_Frames_Get(ID
, Info
.Name
+'_LEFTANIM'+IntToStr(Anim
)) then Exit
;
491 _Anim
:= TAnimation
.Create(ID
, c
, ModelSpeed
[Anim
]);
492 _Anim
.Speed
:= ModelSpeed
[Anim
];
494 if not g_Frames_Get(ID
, Info
.Name
+'_RIGHTANIM'+IntToStr(Anim
)+'_MASK') then
495 if not g_Frames_Get(ID
, Info
.Name
+'_LEFTANIM'+IntToStr(Anim
)+'_MASK') then Exit
;
497 _Mask
:= TAnimation
.Create(ID
, c
, ModelSpeed
[Anim
]);
498 _Mask
.Speed
:= ModelSpeed
[Anim
];
506 function g_PlayerModel_GetGibs(ModelName
: string; var Gibs
: TGibsArray
): Boolean;
513 if PlayerModelsArray
= nil then Exit
;
514 if gGibsCount
= 0 then Exit
;
518 SetLength(Gibs
, gGibsCount
);
520 for a
:= 0 to High(PlayerModelsArray
) do
521 if PlayerModelsArray
[a
].Info
.Name
= ModelName
then
523 for i
:= 0 to High(Gibs
) do
525 if c
and (Length(PlayerModelsArray
[a
].Gibs
) = 1) then
532 b
:= Random(Length(PlayerModelsArray
[a
].Gibs
));
533 until not (PlayerModelsArray
[a
].Gibs
[b
].OnlyOne
and c
);
535 Gibs
[i
] := PlayerModelsArray
[a
].Gibs
[b
];
537 if Gibs
[i
].OnlyOne
then c
:= True;
545 function g_PlayerModel_GetNames(): SArray
;
551 if PlayerModelsArray
= nil then Exit
;
553 for i
:= 0 to High(PlayerModelsArray
) do
555 SetLength(Result
, Length(Result
)+1);
556 Result
[High(Result
)] := PlayerModelsArray
[i
].Info
.Name
;
560 function g_PlayerModel_GetInfo(ModelName
: string): TModelInfo
;
564 if PlayerModelsArray
= nil then Exit
;
566 for a
:= 0 to High(PlayerModelsArray
) do
567 if PlayerModelsArray
[a
].Info
.Name
= ModelName
then
569 Result
:= PlayerModelsArray
[a
].Info
;
574 procedure g_PlayerModel_FreeData();
579 for a
:= WEAPON_SAW
to WEAPON_SUPERPULEMET
do
580 for b
:= W_POS_NORMAL
to W_POS_DOWN
do
581 for c
:= W_ACT_NORMAL
to W_ACT_FIRE
do
582 e_DeleteTexture(WeaponID
[a
][b
][c
]);
584 e_WriteLog('Releasing models...', MSG_NOTIFY
);
586 if PlayerModelsArray
= nil then Exit
;
588 for i
:= 0 to High(PlayerModelsArray
) do
589 with PlayerModelsArray
[i
] do
591 for a
:= A_STAND
to A_PAIN
do
593 g_Frames_DeleteByName(Info
.Name
+'_LEFTANIM'+IntToStr(a
));
594 g_Frames_DeleteByName(Info
.Name
+'_LEFTANIM'+IntToStr(a
)+'_MASK');
595 g_Frames_DeleteByName(Info
.Name
+'_RIGHTANIM'+IntToStr(a
));
596 g_Frames_DeleteByName(Info
.Name
+'_RIGHTANIM'+IntToStr(a
)+'_MASK');
599 if PainSounds
<> nil then
600 for b
:= 0 to High(PainSounds
) do
601 e_DeleteSound(PainSounds
[b
].ID
);
603 if DieSounds
<> nil then
604 for b
:= 0 to High(DieSounds
) do
605 e_DeleteSound(DieSounds
[b
].ID
);
608 for b
:= 0 to High(Gibs
) do
610 e_DeleteTexture(Gibs
[b
].ID
);
611 e_DeleteTexture(Gibs
[b
].MaskID
);
615 PlayerModelsArray
:= nil;
620 procedure TPlayerModel
.ChangeAnimation(Animation
: Byte; Force
: Boolean = False);
622 if not Force
then if FCurrentAnimation
= Animation
then Exit
;
624 FCurrentAnimation
:= Animation
;
626 if (FDirection
= D_LEFT
) and
627 (FAnim
[D_LEFT
][FCurrentAnimation
] <> nil) and
628 (FMaskAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
630 FAnim
[D_LEFT
][FCurrentAnimation
].Reset
;
631 FMaskAnim
[D_LEFT
][FCurrentAnimation
].Reset
;
635 FAnim
[D_RIGHT
][FCurrentAnimation
].Reset
;
636 FMaskAnim
[D_RIGHT
][FCurrentAnimation
].Reset
;
640 destructor TPlayerModel
.Destroy();
644 for a
:= A_STAND
to A_PAIN
do
646 FAnim
[D_LEFT
][a
].Free();
647 FMaskAnim
[D_LEFT
][a
].Free();
648 FAnim
[D_RIGHT
][a
].Free();
649 FMaskAnim
[D_RIGHT
][a
].Free();
655 procedure TPlayerModel
.Draw(X
, Y
: Integer; Alpha
: Byte = 0);
662 if Direction
= D_LEFT
then
665 Mirror
:= M_HORIZONTAL
;
667 if (FFlag
<> FLAG_NONE
) and (FFlagAnim
<> nil) and
668 (not (FCurrentAnimation
in [A_DIE1
, A_DIE2
])) then
670 p
.X
:= IfThen(Direction
= D_LEFT
,
672 64-FLAG_BASEPOINT
.X
);
673 p
.Y
:= FLAG_BASEPOINT
.Y
;
675 FFlagAnim
.DrawEx(X
+IfThen(Direction
= D_LEFT
, FFlagPoint
.X
-1, 2*FLAG_BASEPOINT
.X
-FFlagPoint
.X
+1)-FLAG_BASEPOINT
.X
,
676 Y
+FFlagPoint
.Y
-FLAG_BASEPOINT
.Y
+1, Mirror
, p
,
677 IfThen(FDirection
= D_RIGHT
, FFlagAngle
, -FFlagAngle
));
681 if Direction
= D_RIGHT
then
684 Mirror
:= M_HORIZONTAL
;
687 (not (FCurrentAnimation
in [A_DIE1
, A_DIE2
, A_PAIN
])) and
688 (FCurrentWeapon
in [WEAPON_SAW
..WEAPON_SUPERPULEMET
]) then
690 if FCurrentAnimation
in [A_SEEUP
, A_ATTACKUP
] then
693 if FCurrentAnimation
in [A_SEEDOWN
, A_ATTACKDOWN
] then
698 if (FCurrentAnimation
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
]) or
705 e_Draw(WeaponID
[FCurrentWeapon
][pos
][act
],
706 X
+FWeaponPoints
[FCurrentWeapon
, FCurrentAnimation
, FDirection
,
707 FAnim
[D_RIGHT
][FCurrentAnimation
].CurrentFrame
].X
,
708 Y
+FWeaponPoints
[FCurrentWeapon
, FCurrentAnimation
, FDirection
,
709 FAnim
[D_RIGHT
][FCurrentAnimation
].CurrentFrame
].Y
,
710 0, True, False, Mirror
);
714 if (FDirection
= D_LEFT
) and
715 (FAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
717 FAnim
[D_LEFT
][FCurrentAnimation
].Alpha
:= Alpha
;
718 FAnim
[D_LEFT
][FCurrentAnimation
].Draw(X
, Y
, M_NONE
);
722 FAnim
[D_RIGHT
][FCurrentAnimation
].Alpha
:= Alpha
;
723 FAnim
[D_RIGHT
][FCurrentAnimation
].Draw(X
, Y
, Mirror
);
729 if (FDirection
= D_LEFT
) and
730 (FMaskAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
732 FMaskAnim
[D_LEFT
][FCurrentAnimation
].Alpha
:= Alpha
;
733 FMaskAnim
[D_LEFT
][FCurrentAnimation
].Draw(X
, Y
, M_NONE
);
737 FMaskAnim
[D_RIGHT
][FCurrentAnimation
].Alpha
:= Alpha
;
738 FMaskAnim
[D_RIGHT
][FCurrentAnimation
].Draw(X
, Y
, Mirror
);
746 function TPlayerModel
.GetCurrentAnimation
: TAnimation
;
748 if (FDirection
= D_LEFT
) and (FAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
749 Result
:= FAnim
[D_LEFT
][FCurrentAnimation
]
751 Result
:= FAnim
[D_RIGHT
][FCurrentAnimation
];
754 function TPlayerModel
.GetCurrentAnimationMask
: TAnimation
;
756 if (FDirection
= D_LEFT
) and (FMaskAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
757 Result
:= FMaskAnim
[D_LEFT
][FCurrentAnimation
]
759 Result
:= FMaskAnim
[D_RIGHT
][FCurrentAnimation
];
762 function TPlayerModel
.PlaySound(SoundType
, Level
: Byte; X
, Y
: Integer): Boolean;
764 TempArray
: array of DWORD
;
768 SetLength(TempArray
, 0);
770 if SoundType
= MODELSOUND_PAIN
then
772 if FPainSounds
= nil then Exit
;
774 for a
:= 0 to High(FPainSounds
) do
775 if FPainSounds
[a
].Level
= Level
then
777 SetLength(TempArray
, Length(TempArray
)+1);
778 TempArray
[High(TempArray
)] := FPainSounds
[a
].ID
;
783 if (Level
in [2, 3]) and (FSlopSound
> 0) then
785 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', X
, Y
);
786 if FSlopSound
= 1 then
792 if FDieSounds
= nil then Exit
;
794 for a
:= 0 to High(FDieSounds
) do
795 if FDieSounds
[a
].Level
= Level
then
797 SetLength(TempArray
, Length(TempArray
)+1);
798 TempArray
[High(TempArray
)] := FDieSounds
[a
].ID
;
802 if TempArray
= nil then Exit
;
804 g_Sound_PlayAt(TempArray
[Random(Length(TempArray
))], X
, Y
);
809 procedure TPlayerModel
.SetColor(Red
, Green
, Blue
: Byte);
816 procedure TPlayerModel
.SetFire(Fire
: Boolean);
820 if FFire
then FFireCounter
:= FAnim
[D_RIGHT
, A_ATTACK
].Speed
*FAnim
[D_RIGHT
, A_ATTACK
].TotalFrames
821 else FFireCounter
:= 0;
824 procedure TPlayerModel
.SetFlag(Flag
: Byte);
834 FLAG_RED
: g_Frames_Get(id
, 'FRAMES_FLAG_RED');
835 FLAG_BLUE
: g_Frames_Get(id
, 'FRAMES_FLAG_BLUE');
839 FFlagAnim
:= TAnimation
.Create(id
, True, 8);
842 procedure TPlayerModel
.SetWeapon(Weapon
: Byte);
844 FCurrentWeapon
:= Weapon
;
847 procedure TPlayerModel
.Update();
849 if (FDirection
= D_LEFT
) and (FAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
850 FAnim
[D_LEFT
][FCurrentAnimation
].Update
else FAnim
[D_RIGHT
][FCurrentAnimation
].Update
;
852 if (FDirection
= D_LEFT
) and (FMaskAnim
[D_LEFT
][FCurrentAnimation
] <> nil) then
853 FMaskAnim
[D_LEFT
][FCurrentAnimation
].Update
else FMaskAnim
[D_RIGHT
][FCurrentAnimation
].Update
;
855 if FFlagAnim
<> nil then FFlagAnim
.Update
;
857 if FFireCounter
> 0 then Dec(FFireCounter
) else FFire
:= False;