1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
18 {.$DEFINE D2F_DEBUG_MONS_MOVE}
26 g_basic
, e_graphics
, g_phys
, g_textures
, g_grid
,
27 g_saveload
, g_panel
, xprofiler
;
54 TMonster
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
58 FDirection
: TDirection
;
59 FStartDirection
: TDirection
;
60 FStartX
, FStartY
: Integer;
66 FAnim
: Array of Array [TDirection
.D_LEFT
..TDirection
.D_RIGHT
] of TAnimation
;
75 FWaitAttackAnim
: Boolean;
86 FFirePainTime
: Integer;
89 mProxyId
: Integer; // node in dyntree or -1
90 mArrIdx
: Integer; // in gMonsters
92 FDieTriggers
: Array of Integer;
93 FSpawnTrigger
: Integer;
95 mNeedSend
: Boolean; // for network
97 mEDamageType
: Integer;
100 function findNewPrey(): Boolean;
101 procedure ActivateTriggers();
103 procedure setGameX (v
: Integer); inline;
104 procedure setGameY (v
: Integer); inline;
106 procedure doDamage (v
: Integer);
111 trapCheckFrameId
: DWord
; // for `g_weapons.CheckTrap()`
112 mplatCheckFrameId
: LongWord;
114 constructor Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
115 destructor Destroy(); override;
116 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
117 function Collide(Panel
: TPanel
): Boolean; overload
;
118 function Collide(X
, Y
: Integer): Boolean; overload
;
119 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
120 function alive(): Boolean;
121 procedure SetHealth(aH
: Integer);
122 procedure Push(vx
, vy
: Integer);
123 function Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
124 function Heal(Value
: Word): Boolean;
127 procedure ClientUpdate();
128 procedure ClientAttack(wx
, wy
, atx
, aty
: Integer);
129 procedure SetDeadAnim
;
132 procedure WakeUpSound();
133 procedure DieSound();
134 procedure PainSound();
135 procedure ActionSound();
136 procedure AddTrigger(t
: Integer);
137 procedure ClearTriggers();
139 procedure SaveState (st
: TStream
);
140 procedure LoadState (st
: TStream
);
141 procedure SetState(State
: Byte; ForceAnim
: Byte = 255);
142 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
143 procedure MakeBloodSimple(Count
: Word);
144 procedure RevertAnim(R
: Boolean = True);
145 function AnimIsReverse
: Boolean;
146 function shoot(o
: PObj
; immediately
: Boolean): Boolean;
147 function kick(o
: PObj
): Boolean;
148 procedure CatchFire(Attacker
: Word);
149 procedure OnFireFlame(Times
: DWORD
= 1);
151 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
153 procedure setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline;
154 procedure moveBy (dx
, dy
: Integer); inline;
156 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
159 function gncNeedSend (): Boolean; inline;
160 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
163 property Obj
: TObj read FObj
;
165 property proxyId
: Integer read mProxyId
;
166 property arrIdx
: Integer read mArrIdx
;
168 property MonsterType
: Byte read FMonsterType
;
169 property MonsterHealth
: Integer read FHealth write FHealth
;
170 property MonsterAmmo
: Integer read FAmmo write FAmmo
;
171 property MonsterTargetUID
: Word read FTargetUID write FTargetUID
;
172 property MonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
173 property MonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
174 property MonsterSleep
: Integer read FSleep write FSleep
;
175 property MonsterState
: Byte read FState write FState
;
176 property MonsterRemoved
: Boolean read FRemoved write FRemoved
;
177 property MonsterPain
: Integer read FPain write FPain
;
178 property MonsterAnim
: Byte read FCurAnim write FCurAnim
;
180 property UID
: Word read FUID write FUID
;
181 property SpawnTrigger
: Integer read FSpawnTrigger write FSpawnTrigger
;
183 property GameX
: Integer read FObj
.X write setGameX
;
184 property GameY
: Integer read FObj
.Y write setGameY
;
185 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
186 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
187 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
188 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
189 property GameDirection
: TDirection read FDirection write FDirection
;
191 property StartID
: Integer read FStartID
;
194 property eMonsterType
: Byte read FMonsterType
;
195 property eMonsterHealth
: Integer read FHealth write FHealth
;
196 property eMonsterAmmo
: Integer read FAmmo write FAmmo
;
197 property eMonsterTargetUID
: Word read FTargetUID write FTargetUID
;
198 property eMonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
199 property eMonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
200 property eMonsterSleep
: Integer read FSleep write FSleep
;
201 property eMonsterState
: Byte read FState write FState
;
202 property eMonsterRemoved
: Boolean read FRemoved
;
203 property eMonsterPain
: Integer read FPain write FPain
;
204 property eMonsterAnim
: Byte read FCurAnim
;
206 property eUID
: Word read FUID
;
207 property eSpawnTrigger
: Integer read FSpawnTrigger
;
209 property eGameX
: Integer read FObj
.X write setGameX
;
210 property eGameY
: Integer read FObj
.Y write setGameY
;
211 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
212 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
213 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
214 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
215 property eGameDirection
: TDirection read FDirection write FDirection
;
217 property eStartID
: Integer read FStartID
;
219 // set this before assigning something to `eDamage`
220 property eDamageType
: Integer read mEDamageType write mEDamageType
;
221 property eDamage
: Integer write doDamage
;
225 // will be called from map loader
226 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
228 procedure g_Monsters_LoadData ();
229 procedure g_Monsters_FreeData ();
230 procedure g_Monsters_Init ();
231 procedure g_Monsters_Free (clearGrid
: Boolean=true);
232 function g_Monsters_Create (MonsterType
: Byte; X
, Y
: Integer; Direction
: TDirection
;
233 AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
234 procedure g_Monsters_Update ();
235 procedure g_Monsters_Draw ();
236 procedure g_Monsters_DrawHealth ();
237 function g_Monsters_ByUID (UID
: Word): TMonster
;
238 procedure g_Monsters_killedp ();
239 procedure g_Monsters_SaveState (st
: TStream
);
240 procedure g_Monsters_LoadState (st
: TStream
);
242 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
243 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
245 function g_Mons_TypeLo (): Integer; inline;
246 function g_Mons_TypeHi (): Integer; inline;
248 function g_Mons_TypeIdByName (const name
: AnsiString): Integer;
249 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
250 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
254 TEachMonsterCB
= function (mon
: TMonster
): Boolean is nested
; // return `true` to stop
256 // throws on invalid uid
257 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
260 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
262 function g_Mons_TotalCount (): Integer; inline;
264 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
266 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
267 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
269 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
270 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
272 function g_Mons_getNewTrapFrameId (): DWord
; inline;
273 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
278 TMonsAlongLineCB = function (mon: TMonster; tag: Integer): Boolean is nested;
280 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
285 gmon_debug_use_sqaccel
: Boolean = true;
289 procedure g_Mons_ProfilersBegin ();
290 procedure g_Mons_ProfilersEnd ();
292 procedure g_Mons_LOS_Start (); inline;
293 procedure g_Mons_LOS_End (); inline;
296 profMonsLOS
: TProfiler
= nil; //WARNING: FOR DEBUGGING ONLY!
300 TMonsterGrid
= specialize TBodyGridBase
<TMonster
>;
303 monsGrid
: TMonsterGrid
= nil; // DO NOT USE! public for debugging only!
307 gmon_debug_think
: Boolean = true;
308 gmon_debug_one_think_step
: Boolean = false;
314 e_log
, e_texture
, g_main
, g_sound
, g_gfx
, g_player
, g_game
,
315 g_weapons
, g_triggers
, MAPDEF
, g_items
, g_options
,
316 g_console
, g_map
, Math
, g_menu
, wadreader
,
317 g_language
, g_netmsg
, idpool
, utils
, xstreams
;
321 // ////////////////////////////////////////////////////////////////////////// //
322 procedure g_Mons_ProfilersBegin ();
324 if (profMonsLOS
= nil) then profMonsLOS
:= TProfiler
.Create('LOS CALC', g_profile_history_size
);
325 if (profMonsLOS
<> nil) then profMonsLOS
.mainBegin(g_profile_los
);
326 if g_profile_los
and (profMonsLOS
<> nil) then
328 profMonsLOS
.sectionBegin('loscalc');
329 profMonsLOS
.sectionEnd();
333 procedure g_Mons_ProfilersEnd ();
335 if (profMonsLOS
<> nil) and (g_profile_los
) then profMonsLOS
.mainEnd();
338 procedure g_Mons_LOS_Start (); inline;
340 if (profMonsLOS
<> nil) then profMonsLOS
.sectionBeginAccum('loscalc');
343 procedure g_Mons_LOS_End (); inline;
345 if (profMonsLOS
<> nil) then profMonsLOS
.sectionEnd();
349 // ////////////////////////////////////////////////////////////////////////// //
351 monCheckTrapLastFrameId
: DWord
= 0;
352 monCheckMPlatLastFrameId
: LongWord = 0;
355 procedure TMonster
.getMapBox (out x
, y
, w
, h
: Integer); inline;
357 x
:= FObj
.X
+FObj
.Rect
.X
;
358 y
:= FObj
.Y
+FObj
.Rect
.Y
;
359 w
:= FObj
.Rect
.Width
;
360 h
:= FObj
.Rect
.Height
;
363 function TMonster
.gncNeedSend (): Boolean; inline; begin result
:= mNeedSend
; mNeedSend
:= false; end;
365 procedure TMonster
.setDirty (); inline; begin mNeedSend
:= true; end;
368 // ////////////////////////////////////////////////////////////////////////// //
370 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
372 if not assigned(cb) then begin result := nil; exit; end;
373 result := monsGrid.forEachAlongLine(x0, y0, x1, y1, cb, -1, log);
378 //WARNING! call this after monster position was changed, or coldet will not work right!
379 procedure TMonster
.positionChanged ();
382 nx
, ny
, nw
, nh
: Integer;
384 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
385 //e_WriteLog(Format('monster #%d(%u): pos=(%d,%d); rpos=(%d,%d)', [mArrIdx, UID, FObj.X, FObj.Y, FObj.Rect.X, FObj.Rect.Y]), MSG_NOTIFY);
387 if (mProxyId
= -1) then
390 mProxyId
:= monsGrid
.insertBody(self
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
391 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
392 monsGrid
.getBodyXY(mProxyId
, x
, y
);
393 e_WriteLog(Format('monster #%d:(%u): inserted into the grid; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
398 monsGrid
.getBodyDims(mProxyId
, x
, y
, w
, h
);
399 getMapBox(nx
, ny
, nw
, nh
);
401 if (w
<> nw
) or (h
<> nh
) then
404 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
405 e_WriteLog(Format('monster #%d:(%u): resized; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
407 monsGrid
.moveResizeBody(mProxyId
, nx
, ny
, nw
, nh
);
409 else if (x
<> nx
) or (y
<> ny
) then
412 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
413 e_WriteLog(Format('monster #%d:(%u): updating grid; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
415 monsGrid
.moveBody(mProxyId
, nx
, ny
);
419 exit
; // nothing to do
421 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
422 monsGrid
.getBodyXY(mProxyId
, x
, y
);
423 e_WriteLog(Format('monster #%d:(%u): updated grid; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
429 // ////////////////////////////////////////////////////////////////////////// //
439 MONSTER_SIGNATURE
= $534E4F4D; // 'MONS'
441 // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ:
442 ANIMTABLE
: Array [ANIM_SLEEP
..ANIM_PAIN
] of
446 end = ((name
: 'SLEEP'; loop
: True),
447 (name
: 'GO'; loop
: True),
448 (name
: 'DIE'; loop
: False),
449 (name
: 'MESS'; loop
: False),
450 (name
: 'ATTACK'; loop
: False),
451 (name
: 'ATTACK2'; loop
: False),
452 (name
: 'PAIN'; loop
: False));
454 // Òàáëèöà õàðàêòåðèñòèê ìîíñòðîâ:
455 MONSTERTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
465 ((Name
:'DEMON'; Rect
:(X
:7; Y
:8; Width
:50; Height
:52); Health
:60;
466 RunVel
: 7; MinPain
: 10; Pain
: 20; Jump
: 10),
468 (Name
:'IMP'; Rect
:(X
:15; Y
:10; Width
:34; Height
:50); Health
:25;
469 RunVel
: 3; MinPain
: 0; Pain
: 15; Jump
: 10),
471 (Name
:'ZOMBY'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:15;
472 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
474 (Name
:'SERG'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:20;
475 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
477 (Name
:'CYBER'; Rect
:(X
:24; Y
:9; Width
:80; Height
:110); Health
:500;
478 RunVel
: 5; MinPain
: 50; Pain
: 70; Jump
: 10),
480 (Name
:'CGUN'; Rect
:(X
:15; Y
:4; Width
:34; Height
:56); Health
:60;
481 RunVel
: 3; MinPain
: 10; Pain
: 20; Jump
: 10),
483 (Name
:'BARON'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:150;
484 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
486 (Name
:'KNIGHT'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:75;
487 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
489 (Name
:'CACO'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
490 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
492 (Name
:'SOUL'; Rect
:(X
:16; Y
:14; Width
:32; Height
:36); Health
:60;
493 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
495 (Name
:'PAIN'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
496 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
498 (Name
:'SPIDER'; Rect
:(X
:23; Y
:14; Width
:210; Height
:100); Health
:500;
499 RunVel
: 4; MinPain
: 50; Pain
: 70; Jump
: 10),
501 (Name
:'BSP'; Rect
:(X
:14; Y
:17; Width
:100; Height
:42); Health
:150;
502 RunVel
: 4; MinPain
: 0; Pain
: 20; Jump
: 10),
504 (Name
:'MANCUB'; Rect
:(X
:28; Y
:34; Width
:72; Height
:60); Health
:200;
505 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 7),
507 (Name
:'SKEL'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:200;
508 RunVel
: 6; MinPain
: 20; Pain
: 40; Jump
: 11),
510 (Name
:'VILE'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:150;
511 RunVel
: 7; MinPain
: 10; Pain
: 30; Jump
: 12),
513 (Name
:'FISH'; Rect
:(X
:6; Y
:11; Width
:20; Height
:10); Health
:35;
514 RunVel
: 14; MinPain
: 10; Pain
: 20; Jump
: 6),
516 (Name
:'BARREL'; Rect
:(X
:20; Y
:13; Width
:24; Height
:36); Health
:20;
517 RunVel
: 0; MinPain
: 0; Pain
: 0; Jump
: 0),
519 (Name
:'ROBO'; Rect
:(X
:30; Y
:26; Width
:68; Height
:76); Health
:20;
520 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 6),
522 (Name
:'MAN'; Rect
:(X
:15; Y
:6; Width
:34; Height
:52); Health
:400;
523 RunVel
: 8; MinPain
: 50; Pain
: 70; Jump
: 10));
525 // Òàáëèöà ïàðàìåòðîâ àíèìàöèè ìîíñòðîâ:
526 MONSTER_ANIMTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
529 wX
, wY
: Integer; // Îòêóäà âûëåòèò ïóëÿ
530 AnimSpeed
: Array [ANIM_SLEEP
..ANIM_PAIN
] of Byte;
531 AnimDeltaRight
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
532 AnimDeltaLeft
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
533 end = // SLEEP GO DIE MESS ATTACK ATTACK2 PAIN
534 ((LeftAnim
: False; wX
: 54; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //DEMON
535 AnimDeltaRight
: ((X
: 1; Y
: 4), (X
: 1; Y
: 4), (X
: 0; Y
: 4), (X
: 0; Y
: 4), (X
: 2; Y
: 6), (X
: 2; Y
: 6), (X
: 2; Y
: 5));
536 AnimDeltaLeft
: ((X
: 1; Y
: 4), (X
: 1; Y
: 4), (X
: 0; Y
: 4), (X
: 0; Y
: 4), (X
: 2; Y
: 6), (X
: 2; Y
: 6), (X
: 2; Y
: 5))),
538 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //IMP
539 AnimDeltaRight
: ((X
: 8; Y
: -4), (X
: 8; Y
: -4), (X
: -2; Y
: -1), (X
: 3; Y
: -2), (X
: 14; Y
: -4), (X
: 14; Y
: -4), (X
: -5; Y
: -4));
540 AnimDeltaLeft
: ((X
: 8; Y
: -4), (X
: 8; Y
: -4), (X
: -2; Y
: -1), (X
: 3; Y
: -2), (X
: 14; Y
: -4), (X
: 14; Y
: -4), (X
: -5; Y
: -4))),
542 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //ZOMBY
543 AnimDeltaRight
: ((X
: 1; Y
: -4), (X
: 1; Y
: -4), (X
: 3; Y
: -1), (X
: 2; Y
: -1), (X
: 2; Y
: -4), (X
: 2; Y
: -4), (X
: 1; Y
: -4));
544 AnimDeltaLeft
: ((X
: 1; Y
: -4), (X
: 1; Y
: -4), (X
: 3; Y
: -1), (X
: 2; Y
: -1), (X
: 2; Y
: -4), (X
: 2; Y
: -4), (X
: 1; Y
: -4))),
546 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //SERG
547 AnimDeltaRight
: ((X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: -3; Y
: -1), (X
: -4; Y
: -1), (X
: 1; Y
: -4), (X
: 1; Y
: -4), (X
: 0; Y
: -4));
548 AnimDeltaLeft
: ((X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: -3; Y
: -1), (X
: -4; Y
: -1), (X
: 1; Y
: -4), (X
: 1; Y
: -4), (X
: 0; Y
: -4))),
550 (LeftAnim
: True; wX
: 70; wY
: 73; AnimSpeed
:(3, 3, 3, 3, 3, 4, 3); //CYBER
551 AnimDeltaRight
: ((X
: 2; Y
: -6), (X
: 2; Y
: -6), (X
: -3; Y
: -4), (X
: -3; Y
: -4), (X
: 25; Y
: -6), (X
: 0; Y
: -6), (X
: -2; Y
: -6));
552 AnimDeltaLeft
: ((X
: 3; Y
: -3), (X
: 3; Y
: -3), (X
: -3; Y
: -4), (X
: -3; Y
: -4), (X
:-26; Y
: -3), (X
:-1; Y
: -3), (X
: 1; Y
: -3))),
554 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 1, 0, 4); //CGUN
555 AnimDeltaRight
: ((X
: -1; Y
: -2), (X
: -1; Y
: -2), (X
: -2; Y
: 0), (X
: -2; Y
: 0), (X
: 0; Y
: -3), (X
: 0; Y
: -3), (X
: -1; Y
: -2));
556 AnimDeltaLeft
: ((X
: -1; Y
: -2), (X
: -1; Y
: -2), (X
: -2; Y
: 0), (X
: -2; Y
: 0), (X
: -1; Y
: -4), (X
: -1; Y
: -4), (X
: 2; Y
: -4))),
558 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //BARON
559 AnimDeltaRight
: ((X
: 4; Y
: 0), (X
: 2; Y
: 0), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: 1; Y
: 0), (X
: 1; Y
: 0), (X
: -1; Y
: 0));
560 AnimDeltaLeft
: ((X
: 0; Y
: 0), (X
: 2; Y
: 0), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: -2; Y
: 0), (X
: -2; Y
: 0), (X
: 1; Y
: 0))),
562 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //KNIGHT
563 AnimDeltaRight
: ((X
: 4; Y
: 0), (X
: 2; Y
: 0), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: 1; Y
: 0), (X
: 1; Y
: 0), (X
: -1; Y
: 0));
564 AnimDeltaLeft
: ((X
: 0; Y
: 0), (X
: 2; Y
: 0), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: -2; Y
: 0), (X
: -2; Y
: 0), (X
: 1; Y
: 0))),
566 (LeftAnim
: False; wX
: 88; wY
: 69; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //CACO
567 AnimDeltaRight
: ((X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: 0; Y
: -5), (X
: 0; Y
: -5), (X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: 0; Y
: -4));
568 AnimDeltaLeft
: ((X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: 0; Y
: -5), (X
: 0; Y
: -5), (X
: 0; Y
: -4), (X
: 0; Y
: -4), (X
: 0; Y
: -4))),
570 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //SOUL
571 AnimDeltaRight
: ((X
: 1; Y
:-10), (X
: 1; Y
:-10), (X
:-33; Y
:-34), (X
:-33; Y
:-34), (X
:-16; Y
:-10), (X
:-16; Y
:-10), (X
: -1; Y
: -7));
572 AnimDeltaLeft
: ((X
: 1; Y
:-10), (X
: 1; Y
:-10), (X
:-33; Y
:-34), (X
:-33; Y
:-34), (X
:-16; Y
:-10), (X
:-16; Y
:-10), (X
: -1; Y
: -7))),
574 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //PAIN
575 AnimDeltaRight
: ((X
: -1; Y
: -3), (X
: -1; Y
: -3), (X
: -3; Y
: 0), (X
: -3; Y
: 0), (X
: -1; Y
: -3), (X
: -1; Y
: -3), (X
: -1; Y
: -4));
576 AnimDeltaLeft
: ((X
: -1; Y
: -3), (X
: -1; Y
: -3), (X
: -3; Y
: 0), (X
: -3; Y
: 0), (X
: -1; Y
: -3), (X
: -1; Y
: -3), (X
: -1; Y
: -4))),
578 (LeftAnim
: True; wX
: 128; wY
: 64; AnimSpeed
:(3, 2, 4, 4, 1, 0, 4); //SPIDER
579 AnimDeltaRight
: ((X
: -4; Y
: -4), (X
: -4; Y
: -4), (X
: -2; Y
: 8), (X
: -2; Y
: 8), (X
: -3; Y
: -3), (X
: -3; Y
: -3), (X
: -3; Y
: -4));
580 AnimDeltaLeft
: ((X
: -4; Y
: -4), (X
: -4; Y
: -4), (X
: -2; Y
: 8), (X
: -2; Y
: 8), (X
: -3; Y
: -3), (X
: -3; Y
: -3), (X
: 18; Y
: -5))),
582 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //BSP
583 AnimDeltaRight
: ((X
: 0; Y
: -1), (X
: 0; Y
: -1), (X
: -3; Y
: 5), (X
: -3; Y
: 5), (X
: 7; Y
: -1), (X
: 7; Y
: -1), (X
: 1; Y
: -3));
584 AnimDeltaLeft
: ((X
: 0; Y
: -1), (X
: 0; Y
: -1), (X
: -3; Y
: 5), (X
: -3; Y
: 5), (X
: 7; Y
: -1), (X
: 7; Y
: -1), (X
: 6; Y
: -3))),
586 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 2, 4, 2, 0, 4); //MANCUB
587 AnimDeltaRight
: ((X
: -2; Y
: -7), (X
: -2; Y
: -7), (X
: -4; Y
: -2), (X
: -4; Y
: -2), (X
: -4; Y
: -7), (X
: -4; Y
: -7), (X
:-14; Y
: -7));
588 AnimDeltaLeft
: ((X
: -2; Y
: -7), (X
: -2; Y
: -7), (X
: -4; Y
: -2), (X
: -4; Y
: -2), (X
: -4; Y
: -7), (X
: -4; Y
: -7), (X
:-14; Y
: -7))),
590 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //SKEL
591 AnimDeltaRight
: ((X
: -1; Y
: 4), (X
: -1; Y
: 4), (X
: -2; Y
: 4), (X
: -2; Y
: 4), (X
: -1; Y
: 4), (X
: 6; Y
: 2), (X
:-24; Y
: 4));
592 AnimDeltaLeft
: ((X
: 1; Y
: 4), (X
: -1; Y
: 4), (X
: -2; Y
: 4), (X
: -2; Y
: 4), (X
: -2; Y
: 2), (X
: -5; Y
: 4), (X
: 26; Y
: 4))),
594 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //VILE
595 AnimDeltaRight
: ((X
: 5; Y
:-21), (X
: 5; Y
:-21), (X
: 1; Y
:-21), (X
: 1; Y
:-21), (X
: 8; Y
:-23), (X
: -1; Y
:-23), (X
: 4; Y
:-20));
596 AnimDeltaLeft
: ((X
: -8; Y
:-21), (X
: 5; Y
:-21), (X
: 1; Y
:-21), (X
: 1; Y
:-21), (X
:-10; Y
:-24), (X
: 3; Y
:-23), (X
: -4; Y
:-22))),
598 (LeftAnim
: False; wX
: 8; wY
: 8; AnimSpeed
:(2, 2, 2, 2, 3, 0, 1); //FISH
599 AnimDeltaRight
: ((X
: -1; Y
: 0), (X
: -1; Y
: 0), (X
: -2; Y
: -1), (X
: -2; Y
: -1), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: -1; Y
: -1));
600 AnimDeltaLeft
: ((X
: -1; Y
: 0), (X
: -1; Y
: 0), (X
: -2; Y
: -1), (X
: -2; Y
: -1), (X
: -1; Y
: -1), (X
: -1; Y
: -1), (X
: -1; Y
: -1 ))),
602 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 0, 3, 0, 0, 0, 5); //BARREL
603 AnimDeltaRight
: ((X
: 0; Y
:-15), (X
: 0; Y
:-15), (X
: -1; Y
:-15), (X
: -1; Y
:-15), (X
: 0; Y
:-15), (X
: 0; Y
:-15), (X
: 0; Y
:-15));
604 AnimDeltaLeft
: ((X
: 0; Y
:-15), (X
: 0; Y
:-15), (X
: -1; Y
:-15), (X
: -1; Y
:-15), (X
: 0; Y
:-15), (X
: 0; Y
:-15), (X
: 0; Y
:-15))),
606 (LeftAnim
: False; wX
: 95; wY
: 57; AnimSpeed
:(1, 2, 1, 0, 1, 1, 0); //ROBO
607 AnimDeltaRight
: ((X
: -2; Y
:-26), (X
: -2; Y
:-26), (X
: 0; Y
:-26), (X
: 0; Y
:-26), (X
: 2; Y
:-26), (X
: 15; Y
:-26), (X
: -2; Y
:-26));
608 AnimDeltaLeft
: ((X
: -2; Y
:-26), (X
: -2; Y
:-26), (X
: 0; Y
:-26), (X
: 0; Y
:-26), (X
: 2; Y
:-26), (X
: 15; Y
:-26), (X
: -2; Y
:-26))),
610 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 2, 0, 5); //MAN
611 AnimDeltaRight
: ((X
: 0; Y
: -6), (X
: 0; Y
: -6), (X
: -2; Y
: 0), (X
: 2; Y
: 0), (X
: 1; Y
: -6), (X
: 1; Y
: -6), (X
: 0; Y
: -6));
612 AnimDeltaLeft
: ((X
: 0; Y
: -6), (X
: 0; Y
: -6), (X
: -2; Y
: 0), (X
: 2; Y
: 0), (X
: 1; Y
: -6), (X
: 1; Y
: -6), (X
: 0; Y
: -6))) );
614 MAX_ATM
= 89; // Âðåìÿ îæèäàíèÿ ïîñëå ïîòåðè öåëè
615 MAX_SOUL
= 512; // Îãðàíè÷åíèå Lost_Soul'îâ
618 // ////////////////////////////////////////////////////////////////////////// //
620 gMonsters
: array of TMonster
;
621 uidMap
: array [0..65535] of TMonster
; // monster knows it's index
622 freeInds
: TIdPool
= nil;
625 procedure clearUidMap ();
629 for idx
:= 0 to High(uidMap
) do uidMap
[idx
] := nil;
634 function g_Mons_getNewTrapFrameId (): DWord
; inline;
638 Inc(monCheckTrapLastFrameId
);
639 if (monCheckTrapLastFrameId
= 0) then
642 monCheckTrapLastFrameId
:= 1;
643 for f
:= 0 to High(gMonsters
) do
645 if (gMonsters
[f
] <> nil) then gMonsters
[f
].trapCheckFrameId
:= 0;
648 result
:= monCheckTrapLastFrameId
;
652 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
656 Inc(monCheckMPlatLastFrameId
);
657 if (monCheckMPlatLastFrameId
= 0) then
660 monCheckMPlatLastFrameId
:= 1;
661 for f
:= 0 to High(gMonsters
) do
663 if (gMonsters
[f
] <> nil) then gMonsters
[f
].mplatCheckFrameId
:= 0;
666 result
:= monCheckMPlatLastFrameId
;
675 soulcount
: Integer = 0;
678 function allocMonster (): DWORD
;
682 result
:= freeInds
.alloc();
683 if (result
> High(gMonsters
)) then
685 olen
:= Length(gMonsters
);
686 SetLength(gMonsters
, result
+64);
687 for f
:= olen
to High(gMonsters
) do gMonsters
[f
] := nil;
692 function IsFriend(a
, b
: Byte): Boolean;
696 // Áî÷êà - âñåì äðóã:
697 if (a
= MONSTER_BARREL
) or (b
= MONSTER_BARREL
) then
700 // Ìîíñòðû îäíîãî âèäà:
703 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
704 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
705 Exit
; // Ýòè íå áüþò ñâîèõ
708 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
709 if (a
= MONSTER_SOUL
) and (b
= MONSTER_PAIN
) then
711 // Pain_Elemental íå ìîæåò ðàíèòü Lost_Soul'à:
712 if (b
= MONSTER_SOUL
) and (a
= MONSTER_PAIN
) then
715 //  îñòàëüíûõ ñëó÷àÿõ - áóäóò áèòü äðóã äðóãà:
720 function BehaviourDamage(SpawnerUID
: Word; BH
, SelfType
: Byte): Boolean;
723 UIDType
, MonsterType
: Byte;
728 UIDType
:= g_GetUIDType(SpawnerUID
);
729 if UIDType
= UID_MONSTER
then
731 m
:= g_Monsters_ByUID(SpawnerUID
);
732 if m
= nil then Exit
;
733 MonsterType
:= m
.FMonsterType
;
737 BH_NORMAL
: Result
:= (UIDType
= UID_PLAYER
) or
738 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
740 BH_KILLER
: Result
:= UIDType
= UID_PLAYER
;
741 BH_MANIAC
: Result
:= (UIDType
= UID_PLAYER
) or
742 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
744 BH_INSANE
: Result
:= (UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
));
745 BH_CANNIBAL
: Result
:= (UIDType
= UID_MONSTER
) and (MonsterType
= SelfType
);
750 function canShoot(m
: Byte): Boolean;
755 MONSTER_DEMON
, MONSTER_FISH
, MONSTER_BARREL
:
763 function isCorpse (o
: PObj
; immediately
: Boolean): Integer;
766 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
768 atag := atag; // shut up, fpc!
769 result := false; // don't stop
770 if (mon.FState = MONSTATE_DEAD) and g_Obj_Collide(o, @mon.FObj) then
772 case mon.FMonsterType of // Íå âîñêðåñèòü:
773 MONSTER_SOUL, MONSTER_PAIN, MONSTER_CYBER, MONSTER_SPIDER,
774 MONSTER_VILE, MONSTER_BARREL, MONSTER_ROBO: exit;
776 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
785 mres
: TMonster
= nil;
786 it
: TMonsterGrid
.Iter
;
790 // Åñëè íóæíà âåðîÿòíîñòü
791 if not immediately
and (Random(8) <> 0) then exit
;
793 // Èùåì ìåðòâûõ ìîíñòðîâ ïîáëèçîñòè
794 if gmon_debug_use_sqaccel
then
796 //mon := monsGrid.forEachInAABB(o.X+o.Rect.X, o.Y+o.Rect.Y, o.Rect.Width, o.Rect.Height, monsCollCheck);
797 //if (mon <> nil) then result := mon.mArrIdx;
798 it
:= monsGrid
.forEachInAABB(o
.X
+o
.Rect
.X
, o
.Y
+o
.Rect
.Y
, o
.Rect
.Width
, o
.Rect
.Height
);
801 case mon
.FMonsterType
of // Íå âîñêðåñèòü:
802 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
803 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: begin end;
804 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
807 if (mres
<> nil) then break
;
810 if (mres
<> nil) then result
:= mres
.mArrIdx
;
814 for a
:= 0 to High(gMonsters
) do
816 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @gMonsters
[a
].FObj
) then
818 case gMonsters
[a
].FMonsterType
of // Íå âîñêðåñèòü:
819 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
820 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: Continue
;
821 else // Îñòàëüíûõ ìîæíî âîñêðåñèòü
832 procedure g_Monsters_LoadData();
834 e_WriteLog('Loading monsters data...', TMsgType
.Notify
);
836 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
], 133, False);
837 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD
+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
838 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD
+':MTEXTURES\BARREL_DIE', 64, 64, 4);
839 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD
+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
840 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD
+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
841 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD
+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
842 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD
+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
843 g_Game_StepLoading(6);
844 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD
+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
845 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD
+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
846 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK_L', GameWAD
+':MTEXTURES\ZOMBY_ATTACK_L', 64, 64, 2);
847 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD
+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
848 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD
+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
849 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD
+':MTEXTURES\SERG_GO', 64, 64, 4);
850 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD
+':MTEXTURES\SERG_DIE', 64, 64, 5);
851 g_Game_StepLoading(13);
852 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD
+':MTEXTURES\SERG_MESS', 64, 64, 9);
853 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD
+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
854 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK_L', GameWAD
+':MTEXTURES\SERG_ATTACK_L', 64, 64, 2);
855 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD
+':MTEXTURES\SERG_PAIN', 64, 64, 1);
856 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD
+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
857 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD
+':MTEXTURES\MAN_GO', 64, 64, 4);
858 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD
+':MTEXTURES\MAN_DIE', 64, 64, 7);
859 g_Game_StepLoading(20);
860 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD
+':MTEXTURES\MAN_MESS', 64, 64, 9);
861 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD
+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
862 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD
+':MTEXTURES\MAN_PAIN', 64, 64, 1);
863 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD
+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
864 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD
+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
865 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD
+':MTEXTURES\CGUN_GO', 64, 64, 4);
866 g_Game_StepLoading(26);
867 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD
+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
868 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD
+':MTEXTURES\CGUN_DIE', 64, 64, 7);
869 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD
+':MTEXTURES\CGUN_MESS', 64, 64, 6);
870 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD
+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
871 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD
+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
872 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD
+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
873 g_Game_StepLoading(32);
874 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD
+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
875 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD
+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
876 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD
+':MTEXTURES\IMP_GO', 64, 64, 4);
877 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD
+':MTEXTURES\IMP_DIE', 64, 64, 5);
878 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD
+':MTEXTURES\IMP_MESS', 64, 64, 8);
879 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD
+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
880 g_Game_StepLoading(38);
881 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD
+':MTEXTURES\IMP_PAIN', 64, 64, 1);
882 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD
+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
883 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD
+':MTEXTURES\DEMON_GO', 64, 64, 4);
884 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD
+':MTEXTURES\DEMON_DIE', 64, 64, 6);
885 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD
+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
886 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD
+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
887 g_Game_StepLoading(44);
888 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD
+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
889 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD
+':MTEXTURES\SOUL_GO', 64, 64, 2);
890 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD
+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
891 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD
+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
892 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD
+':MTEXTURES\SOUL_DIE', 128, 128, 7);
893 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD
+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
894 g_Game_StepLoading(50);
895 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD
+':MTEXTURES\FISH_GO', 32, 32, 4);
896 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD
+':MTEXTURES\FISH_PAIN', 32, 32, 3);
897 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD
+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
898 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD
+':MTEXTURES\FISH_DIE', 32, 32, 1);
899 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD
+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
900 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD
+':MTEXTURES\SPIDER_GO', 256, 128, 6);
901 g_Game_StepLoading(56);
902 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD
+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
903 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD
+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
904 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD
+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
905 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD
+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
906 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD
+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
907 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD
+':MTEXTURES\BSP_GO', 128, 64, 6);
908 g_Game_StepLoading(62);
909 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD
+':MTEXTURES\BSP_PAIN', 128, 64, 1);
910 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD
+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
911 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD
+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
912 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD
+':MTEXTURES\BSP_DIE', 128, 64, 7);
913 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD
+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
914 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD
+':MTEXTURES\CACO_GO', 128, 128, 1);
915 g_Game_StepLoading(68);
916 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD
+':MTEXTURES\CACO_PAIN', 128, 128, 1);
917 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD
+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
918 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD
+':MTEXTURES\CACO_DIE', 128, 128, 7);
919 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD
+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
920 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD
+':MTEXTURES\PAIN_GO', 128, 128, 4);
921 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD
+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
922 g_Game_StepLoading(74);
923 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD
+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
924 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD
+':MTEXTURES\PAIN_DIE', 128, 128, 7);
925 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD
+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
926 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD
+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
927 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD
+':MTEXTURES\BARON_GO', 128, 128, 4);
928 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD
+':MTEXTURES\BARON_PAIN', 128, 128, 1);
929 g_Game_StepLoading(80);
930 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD
+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
931 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD
+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
932 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD
+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
933 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD
+':MTEXTURES\BARON_DIE', 128, 128, 7);
934 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD
+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
935 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD
+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
936 g_Game_StepLoading(86);
937 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD
+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
938 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD
+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
939 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD
+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
940 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD
+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
941 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD
+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
942 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD
+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
943 g_Game_StepLoading(92);
944 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD
+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
945 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD
+':MTEXTURES\MANCUB_GO', 128, 128, 6);
946 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD
+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
947 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD
+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
948 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD
+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
949 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD
+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
950 g_Game_StepLoading(98);
951 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD
+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
952 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD
+':MTEXTURES\SKEL_GO', 128, 128, 6);
953 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD
+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
954 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD
+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
955 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD
+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
956 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD
+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
957 g_Game_StepLoading(104);
958 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD
+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
959 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD
+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
960 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD
+':MTEXTURES\SKEL_DIE', 128, 128, 5);
961 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD
+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
962 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD
+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD
+':MTEXTURES\VILE_GO', 128, 128, 6);
964 g_Game_StepLoading(110);
965 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD
+':MTEXTURES\VILE_PAIN', 128, 128, 1);
966 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD
+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
967 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD
+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
968 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD
+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
969 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD
+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
970 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD
+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
971 g_Game_StepLoading(116);
972 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD
+':MTEXTURES\VILE_DIE', 128, 128, 9);
973 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD
+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
974 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD
+':MTEXTURES\ROBO_GO', 128, 128, 12);
975 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD
+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
976 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD
+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
977 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD
+':MTEXTURES\ROBO_DIE', 128, 128, 1);
978 g_Game_StepLoading(122);
979 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD
+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
980 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD
+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
981 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD
+':MTEXTURES\CYBER_GO', 128, 128, 4);
982 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD
+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
983 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD
+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
984 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD
+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
985 g_Game_StepLoading(128);
986 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD
+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
987 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD
+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
988 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD
+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
989 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD
+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
990 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD
+':MTEXTURES\CYBER_DIE', 128, 128, 9);
991 g_Game_StepLoading(133);
993 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_SOUNDS
], 0, False);
995 g_Sound_CreateWADEx('SOUND_MONSTER_BARREL_DIE', GameWAD
+':MSOUNDS\BARREL_DIE');
997 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN', GameWAD
+':MSOUNDS\PAIN');
998 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN2', GameWAD
+':MSOUNDS\PAIN2');
999 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION', GameWAD
+':MSOUNDS\ACTION');
1000 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION2', GameWAD
+':MSOUNDS\ACTION2');
1001 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_1', GameWAD
+':MSOUNDS\ALERT_1');
1002 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_2', GameWAD
+':MSOUNDS\ALERT_2');
1003 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_3', GameWAD
+':MSOUNDS\ALERT_3');
1004 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_1', GameWAD
+':MSOUNDS\DIE_1');
1005 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_2', GameWAD
+':MSOUNDS\DIE_2');
1006 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_3', GameWAD
+':MSOUNDS\DIE_3');
1007 g_Sound_CreateWADEx('SOUND_MONSTER_SLOP', GameWAD
+':MSOUNDS\SLOP');
1009 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ATTACK', GameWAD
+':MSOUNDS\DEMON_ATTACK');
1010 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ALERT', GameWAD
+':MSOUNDS\DEMON_ALERT');
1011 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_DIE', GameWAD
+':MSOUNDS\DEMON_DIE');
1013 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_1', GameWAD
+':MSOUNDS\IMP_ALERT_1');
1014 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_2', GameWAD
+':MSOUNDS\IMP_ALERT_2');
1015 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_1', GameWAD
+':MSOUNDS\IMP_DIE_1');
1016 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_2', GameWAD
+':MSOUNDS\IMP_DIE_2');
1017 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ACTION', GameWAD
+':MSOUNDS\IMP_ACTION');
1018 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ATTACK', GameWAD
+':MSOUNDS\IMP_ATTACK');
1020 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_PAIN', GameWAD
+':MSOUNDS\MAN_PAIN');
1021 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_ALERT', GameWAD
+':MSOUNDS\MAN_ALERT');
1022 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_DIE', GameWAD
+':MSOUNDS\MAN_DIE');
1023 g_Sound_CreateWADEx('SOUND_MONSTER_HAHA', GameWAD
+':MSOUNDS\HAHA');
1024 g_Sound_CreateWADEx('SOUND_MONSTER_TRUP', GameWAD
+':MSOUNDS\TRUP');
1026 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_ATTACK', GameWAD
+':MSOUNDS\SOUL_ATTACK');
1027 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_DIE', GameWAD
+':MSOUNDS\SOUL_DIE');
1029 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ACTION', GameWAD
+':MSOUNDS\BSP_ACTION');
1030 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_DIE', GameWAD
+':MSOUNDS\BSP_DIE');
1031 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ALERT', GameWAD
+':MSOUNDS\BSP_ALERT');
1032 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_WALK', GameWAD
+':MSOUNDS\BSP_WALK');
1034 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ACTION', GameWAD
+':MSOUNDS\VILE_ACTION');
1035 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_PAIN', GameWAD
+':MSOUNDS\VILE_PAIN');
1036 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_DIE', GameWAD
+':MSOUNDS\VILE_DIE');
1037 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ALERT', GameWAD
+':MSOUNDS\VILE_ALERT');
1038 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ATTACK', GameWAD
+':MSOUNDS\VILE_ATTACK');
1040 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ACTION', GameWAD
+':MSOUNDS\SKEL_ACTION');
1041 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_DIE', GameWAD
+':MSOUNDS\SKEL_DIE');
1042 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ALERT', GameWAD
+':MSOUNDS\SKEL_ALERT');
1043 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ATTACK', GameWAD
+':MSOUNDS\SKEL_ATTACK');
1044 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_HIT', GameWAD
+':MSOUNDS\SKEL_HIT');
1046 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_PAIN', GameWAD
+':MSOUNDS\MANCUB_PAIN');
1047 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_DIE', GameWAD
+':MSOUNDS\MANCUB_DIE');
1048 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ALERT', GameWAD
+':MSOUNDS\MANCUB_ALERT');
1049 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ATTACK', GameWAD
+':MSOUNDS\MANCUB_ATTACK');
1051 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_PAIN', GameWAD
+':MSOUNDS\PAIN_PAIN');
1052 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_DIE', GameWAD
+':MSOUNDS\PAIN_DIE');
1053 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_ALERT', GameWAD
+':MSOUNDS\PAIN_ALERT');
1055 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_DIE', GameWAD
+':MSOUNDS\BARON_DIE');
1056 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_ALERT', GameWAD
+':MSOUNDS\BARON_ALERT');
1058 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_DIE', GameWAD
+':MSOUNDS\CACO_DIE');
1059 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_ALERT', GameWAD
+':MSOUNDS\CACO_ALERT');
1061 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_DIE', GameWAD
+':MSOUNDS\CYBER_DIE');
1062 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_ALERT', GameWAD
+':MSOUNDS\CYBER_ALERT');
1063 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_WALK', GameWAD
+':MSOUNDS\CYBER_WALK');
1065 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_DIE', GameWAD
+':MSOUNDS\KNIGHT_DIE');
1066 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_ALERT', GameWAD
+':MSOUNDS\KNIGHT_ALERT');
1068 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_DIE', GameWAD
+':MSOUNDS\SPIDER_DIE');
1069 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_ALERT', GameWAD
+':MSOUNDS\SPIDER_ALERT');
1070 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_WALK', GameWAD
+':MSOUNDS\SPIDER_WALK');
1072 g_Sound_CreateWADEx('SOUND_MONSTER_FISH_ATTACK', GameWAD
+':MSOUNDS\FISH_ATTACK');
1074 freeInds
:= TIdPool
.Create();
1076 monCheckTrapLastFrameId
:= 0;
1077 monCheckMPlatLastFrameId
:= 0;
1080 procedure g_Monsters_FreeData();
1082 e_WriteLog('Releasing monsters data...', TMsgType
.Notify
);
1084 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
1085 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
1086 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
1087 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
1088 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
1089 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
1090 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
1091 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
1092 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK_L');
1093 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
1094 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
1095 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
1096 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
1097 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
1098 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
1099 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK_L');
1100 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
1101 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
1102 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
1103 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
1104 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
1105 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
1106 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
1107 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
1108 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
1109 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
1110 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
1111 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
1112 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
1113 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
1114 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
1115 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
1116 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
1117 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
1118 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
1119 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
1120 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
1121 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
1122 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
1123 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
1124 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
1125 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
1126 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
1127 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
1128 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
1129 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
1130 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
1131 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
1132 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
1133 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
1134 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
1135 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
1136 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
1137 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
1138 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
1139 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
1140 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
1141 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
1142 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
1143 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
1144 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
1145 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
1146 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
1147 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
1148 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
1149 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
1150 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
1151 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
1152 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
1153 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
1154 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
1155 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
1156 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
1157 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
1158 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
1159 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
1160 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
1161 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
1162 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
1163 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
1164 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
1165 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
1166 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
1167 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
1168 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
1169 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
1170 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
1171 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
1172 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
1173 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
1174 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
1175 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
1176 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
1177 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
1178 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
1179 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
1180 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
1181 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
1182 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
1183 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
1184 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
1185 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
1186 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
1187 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
1188 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
1189 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
1190 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
1191 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
1192 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
1193 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
1194 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
1195 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
1196 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
1197 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
1198 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
1199 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
1200 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
1201 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
1202 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
1203 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
1204 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
1205 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
1206 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
1207 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
1208 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
1209 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
1210 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
1211 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
1212 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
1213 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
1214 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
1215 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
1216 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
1218 g_Sound_Delete('SOUND_MONSTER_BARREL_DIE');
1220 g_Sound_Delete('SOUND_MONSTER_PAIN');
1221 g_Sound_Delete('SOUND_MONSTER_PAIN2');
1222 g_Sound_Delete('SOUND_MONSTER_ACTION');
1223 g_Sound_Delete('SOUND_MONSTER_ACTION2');
1224 g_Sound_Delete('SOUND_MONSTER_ALERT_1');
1225 g_Sound_Delete('SOUND_MONSTER_ALERT_2');
1226 g_Sound_Delete('SOUND_MONSTER_ALERT_3');
1227 g_Sound_Delete('SOUND_MONSTER_DIE_1');
1228 g_Sound_Delete('SOUND_MONSTER_DIE_2');
1229 g_Sound_Delete('SOUND_MONSTER_DIE_3');
1230 g_Sound_Delete('SOUND_MONSTER_SLOP');
1232 g_Sound_Delete('SOUND_MONSTER_DEMON_ATTACK');
1233 g_Sound_Delete('SOUND_MONSTER_DEMON_ALERT');
1234 g_Sound_Delete('SOUND_MONSTER_DEMON_DIE');
1236 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_1');
1237 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_2');
1238 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_1');
1239 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_2');
1240 g_Sound_Delete('SOUND_MONSTER_IMP_ACTION');
1241 g_Sound_Delete('SOUND_MONSTER_IMP_ATTACK');
1243 g_Sound_Delete('SOUND_MONSTER_MAN_PAIN');
1244 g_Sound_Delete('SOUND_MONSTER_MAN_ALERT');
1245 g_Sound_Delete('SOUND_MONSTER_MAN_DIE');
1246 g_Sound_Delete('SOUND_MONSTER_HAHA');
1247 g_Sound_Delete('SOUND_MONSTER_TRUP');
1249 g_Sound_Delete('SOUND_MONSTER_SOUL_ATTACK');
1250 g_Sound_Delete('SOUND_MONSTER_SOUL_DIE');
1252 g_Sound_Delete('SOUND_MONSTER_BSP_ACTION');
1253 g_Sound_Delete('SOUND_MONSTER_BSP_DIE');
1254 g_Sound_Delete('SOUND_MONSTER_BSP_ALERT');
1255 g_Sound_Delete('SOUND_MONSTER_BSP_WALK');
1257 g_Sound_Delete('SOUND_MONSTER_VILE_ACTION');
1258 g_Sound_Delete('SOUND_MONSTER_VILE_PAIN');
1259 g_Sound_Delete('SOUND_MONSTER_VILE_DIE');
1260 g_Sound_Delete('SOUND_MONSTER_VILE_ALERT');
1261 g_Sound_Delete('SOUND_MONSTER_VILE_ATTACK');
1263 g_Sound_Delete('SOUND_MONSTER_SKEL_ACTION');
1264 g_Sound_Delete('SOUND_MONSTER_SKEL_DIE');
1265 g_Sound_Delete('SOUND_MONSTER_SKEL_ALERT');
1266 g_Sound_Delete('SOUND_MONSTER_SKEL_ATTACK');
1267 g_Sound_Delete('SOUND_MONSTER_SKEL_HIT');
1269 g_Sound_Delete('SOUND_MONSTER_MANCUB_PAIN');
1270 g_Sound_Delete('SOUND_MONSTER_MANCUB_DIE');
1271 g_Sound_Delete('SOUND_MONSTER_MANCUB_ALERT');
1272 g_Sound_Delete('SOUND_MONSTER_MANCUB_ATTACK');
1274 g_Sound_Delete('SOUND_MONSTER_PAIN_PAIN');
1275 g_Sound_Delete('SOUND_MONSTER_PAIN_DIE');
1276 g_Sound_Delete('SOUND_MONSTER_PAIN_ALERT');
1278 g_Sound_Delete('SOUND_MONSTER_BARON_DIE');
1279 g_Sound_Delete('SOUND_MONSTER_BARON_ALERT');
1281 g_Sound_Delete('SOUND_MONSTER_CACO_DIE');
1282 g_Sound_Delete('SOUND_MONSTER_CACO_ALERT');
1284 g_Sound_Delete('SOUND_MONSTER_CYBER_DIE');
1285 g_Sound_Delete('SOUND_MONSTER_CYBER_ALERT');
1286 g_Sound_Delete('SOUND_MONSTER_CYBER_WALK');
1288 g_Sound_Delete('SOUND_MONSTER_KNIGHT_DIE');
1289 g_Sound_Delete('SOUND_MONSTER_KNIGHT_ALERT');
1291 g_Sound_Delete('SOUND_MONSTER_SPIDER_DIE');
1292 g_Sound_Delete('SOUND_MONSTER_SPIDER_ALERT');
1293 g_Sound_Delete('SOUND_MONSTER_SPIDER_WALK');
1295 g_Sound_Delete('SOUND_MONSTER_FISH_ATTACK');
1301 procedure g_Monsters_Init();
1306 procedure g_Monsters_Free (clearGrid
: Boolean=true);
1310 e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid
]);
1316 for a
:= 0 to High(gMonsters
) do gMonsters
[a
].Free();
1319 monCheckTrapLastFrameId
:= 0;
1320 monCheckMPlatLastFrameId
:= 0;
1324 // will be called from map loader
1325 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
1328 monsGrid
:= TMonsterGrid
.Create(x
, y
, w
, h
);
1329 //clearUidMap(); // why not?
1330 e_LogWritefln('%s', ['Recreated monster tree']);
1334 function g_Monsters_Create(MonsterType
: Byte; X
, Y
: Integer;
1335 Direction
: TDirection
; AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
1342 // Íåò òàêîãî ìîíñòðà
1343 if (MonsterType
> MONSTER_MAN
) or (MonsterType
= 0) then exit
;
1345 // Ñîáëþäàåì îãðàíè÷åíèå Lost_Soul'îâ
1346 if MonsterType
= MONSTER_SOUL
then
1348 if soulcount
> MAX_SOUL
then exit
;
1349 soulcount
:= soulcount
+ 1;
1352 find_id
:= allocMonster();
1354 mon
:= TMonster
.Create(MonsterType
, find_id
, ForcedUID
);
1355 gMonsters
[find_id
] := mon
;
1356 mon
.mArrIdx
:= find_id
;
1359 uidMap
[mon
.FUID
] := mon
;
1361 // Íàñòðàèâàåì ïîëîæåíèå
1366 FObj
.X
:= X
-FObj
.Rect
.X
- (FObj
.Rect
.Width
div 2);
1367 FObj
.Y
:= Y
-FObj
.Rect
.Y
- FObj
.Rect
.Height
;
1371 FObj
.X
:= X
-FObj
.Rect
.X
;
1372 FObj
.Y
:= Y
-FObj
.Rect
.Y
;
1375 FDirection
:= Direction
;
1376 FStartDirection
:= Direction
;
1381 mon
.positionChanged();
1386 procedure g_Monsters_killedp();
1390 if gMonsters
= nil then
1393 // Ïðèêîëèñò ñìååòñÿ íàä ñìåðòüþ èãðîêà:
1394 h
:= High(gMonsters
);
1397 if (gMonsters
[a
] <> nil) then
1399 with gMonsters
[a
] do
1401 if (FMonsterType
= MONSTER_MAN
) and
1402 (FState
<> MONSTATE_DEAD
) and
1403 (FState
<> MONSTATE_SLEEP
) and
1404 (FState
<> MONSTATE_DIE
) then
1406 g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj
.X
, FObj
.Y
);
1414 procedure g_Monsters_Update();
1419 if gTime
mod (GAME_TICK
*2) = 0 then
1423 if abs(pt_x
) > 246 then pt_xs
:= -pt_xs
;
1424 if abs(pt_y
) > 100 then pt_ys
:= -pt_ys
;
1427 gMon
:= True; // Äëÿ ðàáîòû BlockMon'à
1429 if gmon_debug_think
or gmon_debug_one_think_step
then
1431 gmon_debug_one_think_step
:= false;
1432 for a
:= 0 to High(gMonsters
) do
1434 if (gMonsters
[a
] = nil) then continue
;
1435 if not gMonsters
[a
].FRemoved
then
1437 if g_Game_IsClient
then
1438 gMonsters
[a
].ClientUpdate()
1440 gMonsters
[a
].Update();
1444 gMonsters
[a
].Free();
1445 gMonsters
[a
] := nil;
1453 procedure g_Monsters_Draw();
1457 if gMonsters
<> nil then
1459 for a
:= 0 to High(gMonsters
) do
1461 if (gMonsters
[a
] <> nil) then gMonsters
[a
].Draw();
1466 procedure g_Monsters_DrawHealth();
1471 if gMonsters
= nil then Exit
;
1472 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1474 for a
:= 0 to High(gMonsters
) do
1476 if gMonsters
[a
] <> nil then
1478 e_TextureFontPrint(gMonsters
[a
].FObj
.X
+ gMonsters
[a
].FObj
.Rect
.X
,
1479 gMonsters
[a
].FObj
.Y
+ gMonsters
[a
].FObj
.Rect
.Y
+ gMonsters
[a
].FObj
.Rect
.Height
- fH
,
1480 IntToStr(gMonsters
[a
].FHealth
), gStdFont
);
1485 function g_Monsters_ByUID (UID
: Word): TMonster
;
1487 result
:= uidMap
[UID
];
1490 procedure g_Monsters_SaveState (st
: TStream
);
1494 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ìîíñòðîâ
1496 for i
:= 0 to High(gMonsters
) do
1498 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then count
+= 1;
1501 // Ñîõðàíÿåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1502 utils
.writeInt(st
, LongInt(pt_x
));
1503 utils
.writeInt(st
, LongInt(pt_xs
));
1504 utils
.writeInt(st
, LongInt(pt_y
));
1505 utils
.writeInt(st
, LongInt(pt_ys
));
1507 // Êîëè÷åñòâî ìîíñòðîâ
1508 utils
.writeInt(st
, LongInt(count
));
1510 if (count
= 0) then exit
;
1512 // Ñîõðàíÿåì ìîíñòðîâ
1513 for i
:= 0 to High(gMonsters
) do
1515 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then
1518 utils
.writeInt(st
, Byte(gMonsters
[i
].MonsterType
));
1519 // Ñîõðàíÿåì äàííûå ìîíñòðà:
1520 gMonsters
[i
].SaveState(st
);
1526 procedure g_Monsters_LoadState (st
: TStream
);
1534 g_Monsters_Free(false);
1536 // Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1537 pt_x
:= utils
.readLongInt(st
);
1538 pt_xs
:= utils
.readLongInt(st
);
1539 pt_y
:= utils
.readLongInt(st
);
1540 pt_ys
:= utils
.readLongInt(st
);
1542 // Êîëè÷åñòâî ìîíñòðîâ
1543 count
:= utils
.readLongInt(st
);
1545 if (count
= 0) then exit
;
1546 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid monster count');
1548 // Çàãðóæàåì ìîíñòðîâ
1549 for a
:= 0 to count
-1 do
1552 b
:= utils
.readByte(st
);
1554 mon
:= g_Monsters_Create(b
, 0, 0, TDirection
.D_LEFT
);
1555 if (mon
= nil) then raise XStreamError
.Create('g_Monsters_LoadState: ID = -1 (can''t create)');
1556 // Çàãðóæàåì äàííûå ìîíñòðà
1562 // ////////////////////////////////////////////////////////////////////////// //
1563 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1566 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1568 result
:= g_Monsters_Create(monType
, x
, y
, dir
);
1573 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1575 result
:= g_Mons_SpawnAt(g_Mons_TypeIdByName(typeName
), x
, y
, dir
);
1580 // ////////////////////////////////////////////////////////////////////////// //
1581 function g_Mons_TypeLo (): Integer; inline; begin result
:= Low(MONSTERTABLE
); end;
1582 function g_Mons_TypeHi (): Integer; inline; begin result
:= High(MONSTERTABLE
); end;
1585 function g_Mons_TypeIdByName (const name
: String): Integer;
1590 while (i
<= MONSTER_MAN
) do
1592 if (CompareText(name
, MONSTERTABLE
[i
].Name
) = 0) then
1601 if (CompareText(name
, 'zombie') = 0) then result
:= MONSTER_ZOMBY
;
1605 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
1607 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1608 result
:= MONSTERTABLE
[monType
].Name
1614 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
1616 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1617 Result
:= KilledByMonster
[monType
]
1623 // ////////////////////////////////////////////////////////////////////////// //
1624 { T M o n s t e r : }
1626 procedure TMonster
.setGameX (v
: Integer); inline; begin FObj
.X
:= v
; positionChanged(); end;
1627 procedure TMonster
.setGameY (v
: Integer); inline; begin FObj
.Y
:= v
; positionChanged(); end;
1629 procedure TMonster
.setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline; begin FObj
.X
:= ax
; FObj
.Y
:= ay
; if callPosChanged
then positionChanged(); end;
1631 procedure TMonster
.moveBy (dx
, dy
: Integer); inline;
1633 if (dx
<> 0) or (dy
<> 0) then
1641 procedure TMonster
.doDamage (v
: Integer);
1643 if (v
<= 0) then exit
;
1644 if (v
> 32767) then v
:= 32767;
1645 Damage(v
, 0, 0, 0, mEDamageType
);
1648 procedure TMonster
.ActionSound();
1650 case FMonsterType
of
1652 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ACTION', FObj
.X
, FObj
.Y
);
1653 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
,
1655 g_Sound_PlayExAt('SOUND_MONSTER_ACTION', FObj
.X
, FObj
.Y
);
1656 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1657 MONSTER_KNIGHT
, MONSTER_PAIN
, MONSTER_DEMON
,
1659 g_Sound_PlayExAt('SOUND_MONSTER_ACTION2', FObj
.X
, FObj
.Y
);
1661 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ACTION', FObj
.X
, FObj
.Y
);
1663 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ACTION', FObj
.X
, FObj
.Y
);
1665 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ACTION', FObj
.X
, FObj
.Y
);
1669 g_Sound_PlayExAt('SOUND_MONSTER_HAHA', FObj
.X
, FObj
.Y
);
1673 procedure TMonster
.PainSound();
1681 case FMonsterType
of
1682 MONSTER_IMP
, MONSTER_ZOMBY
, MONSTER_SERG
,
1683 MONSTER_SKEL
, MONSTER_CGUN
:
1684 g_Sound_PlayExAt('SOUND_MONSTER_PAIN', FObj
.X
, FObj
.Y
);
1685 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1686 MONSTER_KNIGHT
, MONSTER_DEMON
, MONSTER_SPIDER
,
1687 MONSTER_BSP
, MONSTER_CYBER
:
1688 g_Sound_PlayExAt('SOUND_MONSTER_PAIN2', FObj
.X
, FObj
.Y
);
1690 g_Sound_PlayExAt('SOUND_MONSTER_VILE_PAIN', FObj
.X
, FObj
.Y
);
1692 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_PAIN', FObj
.X
, FObj
.Y
);
1694 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_PAIN', FObj
.X
, FObj
.Y
);
1696 g_Sound_PlayExAt('SOUND_MONSTER_MAN_PAIN', FObj
.X
, FObj
.Y
);
1700 procedure TMonster
.DieSound();
1702 case FMonsterType
of
1705 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_1', FObj
.X
, FObj
.Y
);
1706 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_2', FObj
.X
, FObj
.Y
);
1708 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1710 0: g_Sound_PlayExAt('SOUND_MONSTER_DIE_1', FObj
.X
, FObj
.Y
);
1711 1: g_Sound_PlayExAt('SOUND_MONSTER_DIE_2', FObj
.X
, FObj
.Y
);
1712 2: g_Sound_PlayExAt('SOUND_MONSTER_DIE_3', FObj
.X
, FObj
.Y
);
1715 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_DIE', FObj
.X
, FObj
.Y
);
1717 g_Sound_PlayExAt('SOUND_MONSTER_BARREL_DIE', FObj
.X
, FObj
.Y
);
1719 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_DIE', FObj
.X
, FObj
.Y
);
1721 g_Sound_PlayExAt('SOUND_MONSTER_BSP_DIE', FObj
.X
, FObj
.Y
);
1723 g_Sound_PlayExAt('SOUND_MONSTER_VILE_DIE', FObj
.X
, FObj
.Y
);
1725 g_Sound_PlayExAt('SOUND_MONSTER_BARON_DIE', FObj
.X
, FObj
.Y
);
1727 g_Sound_PlayExAt('SOUND_MONSTER_CACO_DIE', FObj
.X
, FObj
.Y
);
1729 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_DIE', FObj
.X
, FObj
.Y
);
1731 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_DIE', FObj
.X
, FObj
.Y
);
1733 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_DIE', FObj
.X
, FObj
.Y
);
1735 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_DIE', FObj
.X
, FObj
.Y
);
1737 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_DIE', FObj
.X
, FObj
.Y
);
1739 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_DIE', FObj
.X
, FObj
.Y
);
1741 g_Sound_PlayExAt('SOUND_MONSTER_MAN_DIE', FObj
.X
, FObj
.Y
);
1745 procedure TMonster
.WakeUpSound();
1747 case FMonsterType
of
1750 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_1', FObj
.X
, FObj
.Y
);
1751 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_2', FObj
.X
, FObj
.Y
);
1753 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1755 0: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_1', FObj
.X
, FObj
.Y
);
1756 1: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_2', FObj
.X
, FObj
.Y
);
1757 2: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_3', FObj
.X
, FObj
.Y
);
1760 g_Sound_PlayExAt('SOUND_MONSTER_MAN_ALERT', FObj
.X
, FObj
.Y
);
1762 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ALERT', FObj
.X
, FObj
.Y
);
1764 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ALERT', FObj
.X
, FObj
.Y
);
1766 g_Sound_PlayExAt('SOUND_MONSTER_BARON_ALERT', FObj
.X
, FObj
.Y
);
1768 g_Sound_PlayExAt('SOUND_MONSTER_CACO_ALERT', FObj
.X
, FObj
.Y
);
1770 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_ALERT', FObj
.X
, FObj
.Y
);
1772 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_ALERT', FObj
.X
, FObj
.Y
);
1774 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ALERT', FObj
.X
, FObj
.Y
);
1776 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_ALERT', FObj
.X
, FObj
.Y
);
1778 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ALERT', FObj
.X
, FObj
.Y
);
1780 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ALERT', FObj
.X
, FObj
.Y
);
1782 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_ALERT', FObj
.X
, FObj
.Y
);
1788 procedure TMonster
.BFGHit();
1790 if FMonsterType
= MONSTER_FISH
then
1793 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1794 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1795 {if g_Game_IsServer and g_Game_IsNet then
1796 MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
1797 FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
1801 function TMonster
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
1803 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1811 function TMonster
.Collide(Panel
: TPanel
): Boolean;
1813 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1818 Panel
.Width
, Panel
.Height
);
1821 function TMonster
.Collide(X
, Y
: Integer): Boolean;
1823 X
:= X
- FObj
.X
- FObj
.Rect
.X
;
1824 Y
:= Y
- FObj
.Y
- FObj
.Rect
.Y
;
1825 Result
:= (x
>= 0) and (x
<= FObj
.Rect
.Width
) and
1826 (y
>= 0) and (y
<= FObj
.Rect
.Height
);
1829 procedure TMonster
.Respawn
;
1835 FDirection
:= FStartDirection
;
1836 {GameX}FObj
.X
:= FStartX
;
1837 {GameY}FObj
.Y
:= FStartY
;
1838 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
1839 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
1844 FDieTriggers
:= nil;
1845 FWaitAttackAnim
:= False;
1846 FChainFire
:= False;
1849 FState
:= MONSTATE_SLEEP
;
1850 FCurAnim
:= ANIM_SLEEP
;
1852 positionChanged(); // this updates spatial accelerators
1854 if g_Game_IsNet
and g_Game_IsServer
then
1856 MH_SEND_MonsterPos(FUID
);
1857 MH_SEND_MonsterState(FUID
);
1861 constructor TMonster
.Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
1864 FramesID
: DWORD
= 0;
1868 if ForcedUID
< 0 then
1869 FUID
:= g_CreateUID(UID_MONSTER
)
1873 FMonsterType
:= MonsterType
;
1877 FState
:= MONSTATE_SLEEP
;
1878 FCurAnim
:= ANIM_SLEEP
;
1879 FHealth
:= MONSTERTABLE
[MonsterType
].Health
;
1880 FMaxHealth
:= FHealth
;
1881 FObj
.Rect
:= MONSTERTABLE
[MonsterType
].Rect
;
1882 FDieTriggers
:= nil;
1883 FSpawnTrigger
:= -1;
1884 FWaitAttackAnim
:= False;
1885 FChainFire
:= False;
1887 FNoRespawn
:= False;
1889 FBehaviour
:= BH_NORMAL
;
1893 mEDamageType
:= HIT_SOME
;
1897 trapCheckFrameId
:= 0;
1898 mplatCheckFrameId
:= 0;
1901 if FMonsterType
in [MONSTER_ROBO
, MONSTER_BARREL
] then
1902 FBloodKind
:= BLOOD_SPARKS
1904 FBloodKind
:= BLOOD_NORMAL
;
1905 if FMonsterType
= MONSTER_CACO
then
1911 else if FMonsterType
in [MONSTER_BARON
, MONSTER_KNIGHT
] then
1924 SetLength(FAnim
, Length(ANIMTABLE
));
1926 for a
:= 0 to High(FAnim
) do
1928 FAnim
[a
, TDirection
.D_LEFT
] := nil;
1929 FAnim
[a
, TDirection
.D_RIGHT
] := nil;
1932 for a
:= ANIM_SLEEP
to ANIM_PAIN
do
1933 if (ANIMTABLE
[a
].name
<> '') and
1934 (MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
] <> 0) then
1936 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1937 '_'+ANIMTABLE
[a
].name
;
1939 res
:= g_Frames_Exists(s
);
1942 res
:= g_Frames_Get(FramesID
, s
);
1944 // Åñëè íåò òàêîé àíèìàöèè, òî ïðîáóåì çàìåíèòü åå íà àíèìàöèþ ñìåðòè:
1947 // Çàìåíÿåì òîëüêî ANIM_MESS íà ANIM_DIE:
1948 if a
<> ANIM_MESS
then
1951 if g_Frames_Get(FramesID
, 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1952 '_'+ANIMTABLE
[ANIM_DIE
].name
) then
1954 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1955 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1956 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1957 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1962 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1963 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1965 // Åñëè åñòü îòäåëüíàÿ ëåâàÿ àíèìàöèÿ - çàãðóæàåì:
1966 if MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
then
1968 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1969 '_'+ANIMTABLE
[a
].name
+'_L';
1970 if g_Frames_Exists(s
) then
1971 g_Frames_Get(FramesID
, s
);
1974 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1975 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1978 // Äëÿ êîëäóíà çàãðóæàåì òàêæå àíèìàöèþ îãíÿ:
1979 if MonsterType
= MONSTER_VILE
then
1981 g_Frames_Get(FramesID
, 'FRAMES_FIRE');
1982 vilefire
:= TAnimation
.Create(FramesID
, True, 2);
1988 function TMonster
.Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
1995 // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
1996 if (FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_REVIVE
) then
1999 // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà:
2000 if (t
= HIT_ELECTRO
) and (FMonsterType
= MONSTER_FISH
) and g_Game_IsServer
then
2003 if Random(2) = 0 then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
2005 SetState(MONSTATE_RUN
);
2009 // Ëîâóøêà óáèâàåò ñðàçó:
2010 if t
= HIT_TRAP
then
2013 // Ðîáîòó óðîíà íåò:
2014 if FMonsterType
= MONSTER_ROBO
then
2018 if g_Game_IsServer
then Dec(FHealth
, aDamage
);
2020 // Óñèëèâàåì áîëü ìîíñòðà îò óðîíà:
2023 FPain
:= FPain
+aDamage
;
2025 // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå:
2026 if FState
<> MONSTATE_PAIN
then
2027 if (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) and
2028 (FMonsterType
<> MONSTER_BARREL
) then
2029 SetState(MONSTATE_PAIN
);
2031 // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè:
2032 if (gBloodCount
> 0) then
2034 c
:= Min(aDamage
, 200);
2035 c
:= c
*gBloodCount
- (aDamage
div 4) + Random(c
div 2);
2037 if (VelX
= 0) and (VelY
= 0) then
2041 HIT_TRAP
, HIT_ACID
, HIT_ELECTRO
, HIT_FLAME
: MakeBloodSimple(c
);
2042 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, VelX
, VelY
);
2046 // Òåïåðü öåëü - óäàðèâøèé, åñëè òîëüêî íå ñàì ñåáÿ:
2047 if (SpawnerUID
<> FUID
) and (BehaviourDamage(SpawnerUID
, FBehaviour
, FMonsterType
)) then
2049 FTargetUID
:= SpawnerUID
;
2053 // Çäîðîâüå çàêîí÷èëîñü:
2054 if FHealth
<= 0 then
2056 // Åñëè ýòî íå áî÷êà è óáèë èãðîê, òî åìó +1:
2057 if (FMonsterType
<> MONSTER_BARREL
) then
2059 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2061 p
:= g_Player_Get(SpawnerUID
);
2062 if (p
<> nil) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2064 p
.MonsterKills
:= p
.MonsterKills
+1;
2065 if gGameSettings
.GameMode
= GM_COOP
then
2066 p
.Frags
:= p
.Frags
+ 1;
2067 // Uncomment this if you want to double-kill monsters
2071 if gLMSRespawn
= LMS_RESPAWN_NONE
then
2073 Inc(gCoopMonstersKilled
);
2074 if g_Game_IsNet
then
2080 case FMonsterType
of
2081 MONSTER_ZOMBY
: c
:= ITEM_AMMO_BULLETS
;
2082 MONSTER_SERG
: c
:= ITEM_WEAPON_SHOTGUN1
;
2083 MONSTER_CGUN
: c
:= ITEM_WEAPON_CHAINGUN
;
2084 MONSTER_MAN
: c
:= ITEM_KEY_RED
;
2091 it
:= g_Items_Create(FObj
.X
+ (FObj
.Rect
.Width
div 2),
2092 FObj
.Y
+ (FObj
.Rect
.Height
div 2),
2094 g_Items_SetDrop(it
); // mark it as monster drop
2095 g_Obj_Push(g_Items_ObjByIdx(it
), (FObj
.Vel
.X
div 2)-3+Random(7),
2096 (FObj
.Vel
.Y
div 2)-Random(4));
2097 //positionChanged(); // this updates spatial accelerators
2098 if g_Game_IsServer
and g_Game_IsNet
then
2099 MH_SEND_ItemSpawn(True, it
);
2102 // Òðóï äàëüøå íå èäåò:
2105 // Ó òðóïà ðàçìåðû ìåíüøå:
2106 if (FMonsterType
<> MONSTER_FISH
) and (FMonsterType
<> MONSTER_PAIN
) then
2108 FObj
.Rect
.Y
:= FObj
.Rect
.Y
+ FObj
.Rect
.Height
-12;
2109 FObj
.Rect
.Height
:= 12;
2113 // Óðîí áûë ñèëüíûì => ñëàáûå - â êàøó:
2114 if (FHealth
<= -30) and
2115 ((FMonsterType
= MONSTER_IMP
) or (FMonsterType
= MONSTER_ZOMBY
) or
2116 (FMonsterType
= MONSTER_SERG
) or (FMonsterType
= MONSTER_CGUN
) or
2117 (FMonsterType
= MONSTER_MAN
)) then
2119 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
2120 SetState(MONSTATE_DIE
, ANIM_MESS
);
2125 SetState(MONSTATE_DIE
);
2128 // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà:
2129 if g_Game_IsServer
then ActivateTriggers();
2134 if FState
= MONSTATE_SLEEP
then
2135 begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì:
2136 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2137 SetState(MONSTATE_GO
);
2140 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2144 function TMonster
.Heal(Value
: Word): Boolean;
2147 if g_Game_IsClient
then
2152 if FHealth
< FMaxHealth
then
2154 IncMax(FHealth
, Value
, FMaxHealth
);
2155 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2160 destructor TMonster
.Destroy();
2164 for a
:= 0 to High(FAnim
) do
2166 FAnim
[a
, TDirection
.D_LEFT
].Free();
2167 FAnim
[a
, TDirection
.D_RIGHT
].Free();
2172 if (mProxyId
<> -1) then
2174 if (monsGrid
<> nil) then
2176 monsGrid
.removeBody(mProxyId
);
2177 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
2178 e_WriteLog(Format('monster #%d:(%u): removed from grid; mProxyid=%d', [mArrIdx
, UID
, mProxyId
]), MSG_NOTIFY
);
2184 if (mArrIdx
<> -1) and (mArrIdx
< Length(gMonsters
)) then
2186 freeInds
.release(mArrIdx
);
2187 gMonsters
[mArrIdx
] := nil;
2191 uidMap
[FUID
] := nil;
2193 inherited Destroy();
2196 procedure TMonster
.Draw();
2202 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType));
2203 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState));
2205 // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
2206 if FMonsterType
= MONSTER_VILE
then
2207 if FState
= MONSTATE_SHOOT
then
2208 if GetPos(FTargetUID
, @o
) then
2209 vilefire
.Draw(o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-32,
2210 o
.Y
+o
.Rect
.Y
+o
.Rect
.Height
-128, TMirrorType
.None
);
2212 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
2214 if (g_dbg_scale
= 1.0) then
2216 if not g_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
,
2217 sX
-128, sY
-128, sWidth
+256, sHeight
+256) then
2221 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
2222 if FState
= MONSTATE_DEAD
then
2223 case FMonsterType
of
2224 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
2227 // Åñòü ÷òî ðèñîâàòü ïðè òåêóùåì ïîâåäåíèè:
2228 if FAnim
[FCurAnim
, FDirection
] <> nil then
2230 // Åñëè íåò ëåâîé àíèìàöèè èëè îíà ñîâïàäàåò ñ ïðàâîé => îòðàæàåì ïðàâóþ:
2231 if (FDirection
= TDirection
.D_LEFT
) and
2232 ((not MONSTER_ANIMTABLE
[FMonsterType
].LeftAnim
) or
2233 (FAnim
[FCurAnim
, TDirection
.D_LEFT
].FramesID
= FAnim
[FCurAnim
, TDirection
.D_RIGHT
].FramesID
)) and
2234 (FMonsterType
<> MONSTER_BARREL
) then
2235 m
:= TMirrorType
.Horizontal
2237 m
:= TMirrorType
.None
;
2239 // Ëåâàÿ àíèìàöèÿ => ìåíÿåì ñìåùåíèå îòíîñèòåëüíî öåíòðà:
2240 if (FDirection
= TDirection
.D_LEFT
) and
2241 (FMonsterType
<> MONSTER_BARREL
) then
2243 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].X
;
2244 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].Y
;
2246 if m
= TMirrorType
.Horizontal
then
2247 begin // Íåò îòäåëüíîé ëåâîé àíèìàöèè
2248 // Ðàññòîÿíèå îò êðàÿ òåêñòóðû äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2249 c
:= (MONSTERTABLE
[FMonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[FMonsterType
].Rect
.Width
;
2250 // Ðàññòîÿíèå îò êðàÿ õèò áîêñà äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2251 dx
:= FAnim
[FCurAnim
, FDirection
].Width
- c
- MONSTERTABLE
[FMonsterType
].Rect
.X
;
2252 // Ò.ê. äâèãàòü òåêñòóðó íóæíî áóäåò â ïðîòèâîïîëîæíîì íàïðàâëåíèè:
2254 // Ýòî çíà÷èò: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
2257 else // Ïðàâàÿ àíèìàöèÿ
2259 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].X
;
2260 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].Y
;
2264 FAnim
[FCurAnim
, FDirection
].Draw(Obj
.X
+dx
, Obj
.Y
+dy
, m
);
2267 if g_debug_Frames
then
2269 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2271 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2272 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2277 procedure TMonster
.MakeBloodSimple(Count
: Word);
2279 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+8,
2280 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2281 Count
div 2, 3, -1, 16, (FObj
.Rect
.Height
*2 div 3),
2282 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2283 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-8,
2284 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2285 Count
div 2, -3, -1, 16, (FObj
.Rect
.Height
*2) div 3,
2286 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2289 procedure TMonster
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
2291 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2292 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2293 Count
, VelX
, VelY
, 16, (FObj
.Rect
.Height
*2) div 3,
2294 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2297 procedure TMonster
.Push(vx
, vy
: Integer);
2299 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
2300 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
2301 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2304 procedure TMonster
.SetState(State
: Byte; ForceAnim
: Byte = 255);
2308 // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul,
2309 // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ:
2310 if (State
= MONSTATE_DIE
) and (MonsterType
= MONSTER_SOUL
) then
2311 soulcount
:= soulcount
-1;
2313 // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü:
2315 MONSTATE_DIE
, MONSTATE_DEAD
, MONSTATE_REVIVE
:
2316 if (State
<> MONSTATE_DEAD
) and (State
<> MONSTATE_REVIVE
) and
2317 (State
<> MONSTATE_GO
) then
2324 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
, ForceAnim
);
2326 // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè:
2328 MONSTATE_SLEEP
: Anim
:= ANIM_SLEEP
;
2329 MONSTATE_PAIN
: Anim
:= ANIM_PAIN
;
2330 MONSTATE_WAIT
: Anim
:= ANIM_SLEEP
;
2331 MONSTATE_CLIMB
, MONSTATE_RUN
, MONSTATE_RUNOUT
, MONSTATE_GO
: Anim
:= ANIM_GO
;
2332 MONSTATE_SHOOT
: Anim
:= ANIM_ATTACK
;
2333 MONSTATE_ATTACK
: Anim
:= ANIM_ATTACK
;
2334 MONSTATE_DIE
: Anim
:= ANIM_DIE
;
2336 begin // íà÷àëè âîñðåøàòüñÿ
2338 FAnim
[Anim
, FDirection
].Revert(True);
2340 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
2341 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
2348 // Íàäî ñìåíèòü àíèìàöèþ íà íåñòàíäàðòíóþ:
2349 if ForceAnim
<> 255 then
2352 // Åñëè àíèìàöèÿ íîâàÿ - ïåðåçàïóñêàåì å¸:
2353 if FCurAnim
<> Anim
then
2354 if FAnim
[Anim
, FDirection
] <> nil then
2356 FAnim
[Anim
, FDirection
].Reset();
2361 function TMonster
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
2368 //  òî÷êå íàçíà÷åíèÿ ñòåíà:
2369 if g_CollideLevel(X
, Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
) then
2371 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
2372 if g_Game_IsServer
and g_Game_IsNet
then
2373 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
2379 // Ýôôåêò òåëåïîðòà â ïîçèöèè ìîíñòðà:
2382 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
2383 TA
:= TAnimation
.Create(FramesID
, False, 6);
2384 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj
.X
, Obj
.Y
);
2385 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2386 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2388 if g_Game_IsServer
and g_Game_IsNet
then
2389 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2390 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 1,
2394 FObj
.X
:= X
- FObj
.Rect
.X
;
2395 FObj
.Y
:= Y
- FObj
.Rect
.Y
;
2399 FDirection
:= TDirection
.D_LEFT
2402 FDirection
:= TDirection
.D_RIGHT
2406 if FDirection
= TDirection
.D_RIGHT
then
2407 FDirection
:= TDirection
.D_LEFT
2409 FDirection
:= TDirection
.D_RIGHT
;
2412 // Ýôôåêò òåëåïîðòà â òî÷êå íàçíà÷åíèÿ:
2413 if not silent
and (TA
<> nil) then
2415 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2416 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2419 if g_Game_IsServer
and g_Game_IsNet
then
2420 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2421 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 0,
2425 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2429 procedure TMonster
.Update();
2431 a
, b
, sx
, sy
, wx
, wy
, oldvelx
: Integer;
2441 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
2442 if FMonsterType
= MONSTER_FISH
then
2443 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
2444 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2447 // Ëåòàþùèå ìîíòñðû:
2448 if ((FMonsterType
= MONSTER_SOUL
) or
2449 (FMonsterType
= MONSTER_PAIN
) or
2450 (FMonsterType
= MONSTER_CACO
)) and
2451 (FState
<> MONSTATE_DIE
) and
2452 (FState
<> MONSTATE_DEAD
) then
2455 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
2456 if gTime
mod (GAME_TICK
*2) <> 0 then
2458 g_Obj_Move(@FObj
, fall
, True, True);
2459 positionChanged(); // this updates spatial accelerators
2463 if FPainTicks
> 0 then
2466 FPainSound
:= False;
2469 st
:= g_Obj_Move(@FObj
, fall
, True, True);
2470 positionChanged(); // this updates spatial accelerators
2472 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
2473 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
2474 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
2477 if alive
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2479 Inc(gCoopMonstersKilled
);
2480 if g_Game_IsNet
then
2487 oldvelx
:= FObj
.Vel
.X
;
2489 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
2490 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
2491 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2493 if FFireTime
> 0 then
2495 if WordBool(st
and MOVE_INWATER
) then
2500 FFireTime
:= FFireTime
- 1;
2501 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2502 if FFirePainTime
= 0 then
2504 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
2505 FFirePainTime
:= 18;
2508 FFirePainTime
:= FFirePainTime
- 1;
2512 // Ìåðòâûé íè÷åãî íå äåëàåò:
2513 if (FState
= MONSTATE_DEAD
) then
2516 // AI ìîíñòðîâ âûêëþ÷åí:
2517 if g_debug_MonsterOff
then
2520 if FState
<> MONSTATE_SLEEP
then
2521 SetState(MONSTATE_SLEEP
);
2524 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
2525 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
2526 case FMonsterType
of
2528 if Random(4) = 0 then
2529 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2530 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2531 MONSTER_ROBO
, MONSTER_BARREL
:
2532 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2533 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2535 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
2536 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
2537 if Random(2) = 0 then
2538 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
2540 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
2544 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
2545 if FMonsterType
= MONSTER_BARREL
then
2547 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
2548 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
2549 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2550 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
2554 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
2555 if FMonsterType
= MONSTER_SOUL
then
2556 if WordBool(st
and MOVE_HITAIR
) then
2557 g_Obj_SetSpeed(@FObj
, 16);
2562 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
2563 if FObj
.Vel
.Y
< 0 then
2564 if WordBool(st
and MOVE_INWATER
) then
2567 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
2568 FTargetTime
:= FTargetTime
+ 1;
2571 if FShellTimer
> -1 then
2572 if FShellTimer
= 0 then
2574 if FShellType
= SHELL_SHELL
then
2575 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2576 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2577 GameVelX
, GameVelY
-2, SHELL_SHELL
)
2578 else if FShellType
= SHELL_DBLSHELL
then
2580 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2581 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2582 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
2583 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2584 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2585 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
2588 end else Dec(FShellTimer
);
2590 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
2592 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
2593 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
2594 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2595 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
2596 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2597 (FObj
.Accel
.Y
= 0) then
2598 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2601 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
2603 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
2604 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
2606 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2607 if gSoundEffectsDF
then PainSound();
2609 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
2612 // Ñíèæàåì áîëü ñî âðåìåíåì:
2615 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
2616 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
2620 SetState(MONSTATE_GO
);
2624 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
2627 FSleep
:= FSleep
+ 1;
2629 // Ïðîñïàëè äîñòàòî÷íî:
2630 if FSleep
>= 18 then
2635 // Íà èãðîêîâ èäóò òîëüêî îáû÷íûå ìîíñòðû, êèëëåðû è ìàíüÿêè
2636 if (FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_KILLER
) or (FBehaviour
= BH_MANIAC
) then
2637 // Åñëè åñòü èãðîê ðÿäîì, ïðîñûïàåìñÿ è èäåì ê íåìó:
2638 if (gPlayers
<> nil) then
2639 for a
:= 0 to High(gPlayers
) do
2640 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
2641 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
2643 if g_Look(@FObj
, @Obj
, FDirection
) then
2645 FTargetUID
:= gPlayers
[a
].UID
;
2648 SetState(MONSTATE_GO
);
2652 // Íà ìîíñòðîâ òÿíåò ìàíüÿêîâ, ïîåõàâøèõ è êàííèáàëîâ
2653 if (FTargetUID
= 0) and ((FBehaviour
= BH_MANIAC
)
2654 or (FBehaviour
= BH_INSANE
) or (FBehaviour
= BH_CANNIBAL
)) then
2655 // Åñëè åñòü ïîäõîäÿùèé ìîíñòð ðÿäîì:
2656 if gMonsters
<> nil then
2657 for a
:= 0 to High(gMonsters
) do
2658 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
2659 (gMonsters
[a
].FUID
<> FUID
) then
2661 // Ìàíüÿêè íàïàäàþò íà âñåõ ìîíñòðîâ, êðîìå äðóçåé
2662 if (FBehaviour
= BH_MANIAC
) and
2663 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2665 // Ïîåõàâøèå òàêæå, íî ìîãóò îáîçëèòüñÿ íà áî÷êó
2666 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
) and
2667 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2669 // Êàííèáàëû íàïàäàþò íà ñåáå ïîäîáíûõ
2670 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
2672 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
2674 FTargetUID
:= gMonsters
[a
].UID
;
2677 SetState(MONSTATE_GO
);
2683 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
2686 FSleep
:= FSleep
- 1;
2688 // Âûæäàëè äîñòàòî÷íî - èäåì:
2690 SetState(MONSTATE_GO
);
2693 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
2695 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2696 if WordBool(st
and MOVE_BLOCK
) then
2700 SetState(MONSTATE_RUNOUT
);
2705 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
2706 if (FMonsterType
= MONSTER_VILE
) then
2707 if isCorpse(@FObj
, False) <> -1 then
2710 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
2715 // Öåëü ïîãèáëà èëè äàâíî æäåì:
2716 if (not GetPos(FTargetUID
, @o
)) or (FTargetTime
> MAX_ATM
) then
2717 if not findNewPrey() then
2718 begin // Íîâûõ öåëåé íåò
2726 o
.Rect
:= _Rect(0, 0, 0, 1);
2728 else // Íîâàÿ öåëü åñòü - áåðåì åå êîîðäèíàòû
2729 GetPos(FTargetUID
, @o
);
2731 // Öåëü î÷åíü áëèçêî - ïèíàåì:
2732 if g_Obj_Collide(@FObj
, @o
) and (FTargetUID
<> 0) then
2735 if (FMonsterType
<> MONSTER_CYBER
) or (Random(2) = 0) then
2742 // Ðàññòîÿíèå äî öåëè:
2743 sx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
2744 sy
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2746 // Ïîâîðà÷èâàåìñÿ â ñòîðîíó öåëè:
2748 FDirection
:= TDirection
.D_RIGHT
2750 FDirection
:= TDirection
.D_LEFT
;
2752 // Åñëè ìîíñòð óìååò ñòðåëÿòü è åñòü ïî êîìó - ñòðåëÿåì:
2753 if canShoot(FMonsterType
) and (FTargetUID
<> 0) then
2754 if Abs(sx
) > Abs(sy
) then // óãîë âûñòðåëà óäîáíûé
2755 if shoot(@o
, False) then
2758 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
2759 if Abs(sx
) < 40 then
2760 if FMonsterType
<> MONSTER_FISH
then
2763 SetState(MONSTATE_RUN
);
2764 if Random(2) = 0 then
2765 FDirection
:= TDirection
.D_LEFT
2767 FDirection
:= TDirection
.D_RIGHT
;
2772 // Óïåðëèñü â ñòåíó:
2773 if WordBool(st
and MOVE_HITWALL
) then
2775 if g_Triggers_PressR(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
,
2776 FObj
.Rect
.Height
, FUID
, ACTIVATE_MONSTERPRESS
) <> nil then
2777 begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå
2779 SetState(MONSTATE_WAIT
);
2784 case FMonsterType
of
2785 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
2787 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2788 (FObj
.Accel
.Y
= 0) then
2789 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
2790 // Ïðûæîê ÷åðåç ñòåíó:
2791 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2792 SetState(MONSTATE_CLIMB
);
2799 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
2800 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
2801 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
2803 if FMonsterType
= MONSTER_FISH
then
2805 if not WordBool(st
and MOVE_INWATER
) then
2806 begin // Ðûáà âíå âîäû:
2807 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2808 begin // "Ñòîèò" òâåðäî
2809 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
2810 if FObj
.Accel
.Y
= 0 then FObj
.Vel
.Y
:= -6;
2811 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
2815 SetState(MONSTATE_PAIN
);
2816 FPain
:= FPain
+ 50;
2820 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2822 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2826 // Ðûáà ïëûâåò ââåðõ:
2827 if FObj
.Vel
.Y
< 0 then
2828 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
2830 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
2832 // Ïëàâàåì òóäà-ñþäà:
2833 if Random(2) = 0 then
2834 FDirection
:= TDirection
.D_LEFT
2836 FDirection
:= TDirection
.D_RIGHT
;
2838 SetState(MONSTATE_RUN
);
2842 else // Ëåòàþùèå ìîíñòðû
2844 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2846 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2851 else // "Íàçåìíûå" ìîíñòðû
2853 // Âîçìîæíî, ïèíàåì êóñêè:
2854 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
2856 b
:= Abs(FObj
.Vel
.X
);
2857 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2858 for a
:= 0 to High(gGibs
) do
2860 if gGibs
[a
].alive
and
2861 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2862 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
2865 if FObj
.Vel
.X
< 0 then
2867 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
2871 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
2876 // Áîññû ìîãóò ïèíàòü òðóïû:
2877 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
2878 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
2880 b
:= Abs(FObj
.Vel
.X
);
2881 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2882 for a
:= 0 to High(gCorpses
) do
2883 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
2885 co
:= gCorpses
[a
].Obj
;
2886 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2887 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
2889 if FObj
.Vel
.X
< 0 then
2890 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
2892 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
2895 // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
2897 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2899 if (Random(4) = 0) and (FObj
.Accel
.Y
= 0) then
2900 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2903 FSleep
:= FSleep
+ 1;
2909 if Random(8) = 0 then
2913 // Áåæèì â âûáðàííóþ ñòîðîíó:
2914 if FDirection
= TDirection
.D_RIGHT
then
2915 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2917 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2919 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2920 if WordBool(st
and MOVE_INWATER
) then
2921 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2922 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2923 if FMonsterType
= MONSTER_FISH
then
2927 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
2929 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2930 if WordBool(st
and MOVE_BLOCK
) then
2934 SetState(MONSTATE_RUNOUT
);
2939 FSleep
:= FSleep
- 1;
2941 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
2942 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
2945 SetState(MONSTATE_GO
);
2946 // Ñòåíà - èäåì îáðàòíî:
2947 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2950 if Random(8) = 0 then
2954 // Áåæèì â âûáðàííóþ ñòîðîíó:
2955 if FDirection
= TDirection
.D_RIGHT
then
2956 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2958 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2960 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2961 if WordBool(st
and MOVE_INWATER
) then
2962 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2963 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2964 if FMonsterType
= MONSTER_FISH
then
2968 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
2970 // Âûøëè èç ÁëîêÌîíà:
2971 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
2974 FSleep
:= FSleep
- 1;
2976 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
2977 if FSleep
<= -18 then
2980 SetState(MONSTATE_GO
);
2981 // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî:
2982 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2985 if Random(8) = 0 then
2989 // Áåæèì â âûáðàííóþ ñòîðîíó:
2990 if FDirection
= TDirection
.D_RIGHT
then
2991 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2993 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2995 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2996 if WordBool(st
and MOVE_INWATER
) then
2997 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2998 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2999 if FMonsterType
= MONSTER_FISH
then
3003 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3005 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3006 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3007 (not WordBool(st
and MOVE_HITWALL
)) then
3010 SetState(MONSTATE_GO
);
3012 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3013 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3017 SetState(MONSTATE_RUN
);
3021 // Áåæèì â âûáðàííóþ ñòîðîíó:
3022 if FDirection
= TDirection
.D_RIGHT
then
3023 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3025 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3027 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3028 if WordBool(st
and MOVE_INWATER
) then
3029 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3030 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3031 if FMonsterType
= MONSTER_FISH
then
3035 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3036 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3038 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3039 if FMonsterType
= MONSTER_SOUL
then
3041 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3042 SetState(MONSTATE_GO
);
3047 // Çàìåäëÿåìñÿ ïðè àòàêå:
3048 if FMonsterType
<> MONSTER_FISH
then
3049 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3051 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3052 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3054 // Öåëü ïîãèáëà => èäåì äàëüøå:
3055 if not GetPos(FTargetUID
, @o
) then
3057 SetState(MONSTATE_GO
);
3062 // Öåëü íå âèäíî => èäåì äàëüøå:
3063 if not g_Look(@FObj
, @o
, FDirection
) then
3065 SetState(MONSTATE_GO
);
3070 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3071 if g_Obj_CollideWater(@o
, 0, 0) then
3073 SetState(MONSTATE_GO
);
3079 tx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2);
3080 ty
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2);
3081 g_Weapon_HitUID(FTargetUID
, 2, FUID
, HIT_SOME
);
3084 end; // case FState of ...
3088 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3089 if FState
= MONSTATE_REVIVE
then
3090 if FAnim
[FCurAnim
, FDirection
].Played
then
3091 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3092 FAnim
[FCurAnim
, FDirection
].Revert(False);
3093 SetState(MONSTATE_GO
);
3096 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3097 if vilefire
<> nil then
3100 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3101 if (FState
= MONSTATE_DIE
) and
3102 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3103 (FAnim
[FCurAnim
, FDirection
].Played
) then
3106 SetState(MONSTATE_DEAD
);
3108 // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à:
3109 if (FMonsterType
= MONSTER_PAIN
) then
3111 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-30,
3112 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_LEFT
);
3115 mon
.SetState(MONSTATE_GO
);
3116 mon
.FNoRespawn
:= True;
3117 Inc(gTotalMonsters
);
3118 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3121 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3122 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_RIGHT
);
3125 mon
.SetState(MONSTATE_GO
);
3126 mon
.FNoRespawn
:= True;
3127 Inc(gTotalMonsters
);
3128 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3131 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-15,
3132 FObj
.Y
+FObj
.Rect
.Y
, TDirection
.D_RIGHT
);
3135 mon
.SetState(MONSTATE_GO
);
3136 mon
.FNoRespawn
:= True;
3137 Inc(gTotalMonsters
);
3138 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3141 if g_Game_IsNet
then MH_SEND_CoopStats();
3144 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3145 if (FMonsterType
= MONSTER_PAIN
) or
3146 (FMonsterType
= MONSTER_SOUL
) or
3147 (FMonsterType
= MONSTER_BARREL
) then
3151 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3152 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3153 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3154 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3155 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3156 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3157 if FState
= MONSTATE_ATTACK
then
3158 begin // Ñîñòîÿíèå - Àòàêà
3159 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3160 if FMonsterType
<> MONSTER_SOUL
then
3161 SetState(MONSTATE_GO
);
3163 else // Ñîñòîÿíèå - Ñòðåëüáà
3165 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3166 if not FChainFire
then
3167 SetState(MONSTATE_GO
)
3169 begin // Íàäî ñòðåëÿòü åùå
3170 FChainFire
:= False;
3171 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3172 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3173 FAnim
[FCurAnim
, FDirection
].Reset();
3177 FWaitAttackAnim
:= False;
3180 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3181 if (FMonsterType
= MONSTER_SOUL
) or
3182 ( (not FWaitAttackAnim
) and
3183 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3184 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3186 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3187 if FState
= MONSTATE_ATTACK
then
3188 begin // Ñîñòîÿíèå - Àòàêà
3189 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3190 if FMonsterType
= MONSTER_SOUL
then
3191 FAnim
[FCurAnim
, FDirection
].Reset();
3193 case FMonsterType
of
3194 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3195 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3196 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3197 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3198 if FMonsterType
= MONSTER_SOUL
then
3199 SetState(MONSTATE_GO
);
3202 // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì:
3203 if g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
) <> 0 then
3204 g_Sound_PlayExAt('SOUND_MONSTER_FISH_ATTACK', FObj
.X
, FObj
.Y
);
3206 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3207 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3208 if FCurAnim
= ANIM_ATTACK2
then
3211 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3212 if g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
) <> 0 then
3213 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_HIT', FObj
.X
, FObj
.Y
);
3217 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3218 if FCurAnim
= ANIM_ATTACK2
then
3220 sx
:= isCorpse(@FObj
, True);
3222 begin // Íàøëè, êîãî âîñêðåñèòü
3223 gMonsters
[sx
].SetState(MONSTATE_REVIVE
);
3224 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3225 // Âîñêðåøàòü - ñåáå âðåäèòü:
3226 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3232 else // Ñîñòîÿíèå - Ñòðåëüáà
3234 // Âû÷èñëÿåì êîîðäèíàòû, îòêóäà âûëåòèò ïóëÿ:
3235 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
;
3237 if FDirection
= TDirection
.D_LEFT
then
3239 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
-(MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2));
3240 wx
:= MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2)-wx
;
3241 end; // Ýòî çíà÷èò: wx := hitX + (hitWidth / 2) - (wx - (hitX + (hitWidth / 2)))
3244 wy
:= FObj
.Y
+ MONSTER_ANIMTABLE
[FMonsterType
].wY
;
3246 // Ìîíñòð íå ìîæåò öåëèòüñÿ â îáúåêò çà ñïèíîé, ñòðåëÿÿ âëåâî:
3247 if (FDirection
= TDirection
.D_LEFT
) and (tx
> wx
) then
3250 ty
:= wy
+ Random(11) - 5;
3252 // È àíàëîãè÷íî, ñòðåëÿÿ âïðàâî:
3253 if (FDirection
= TDirection
.D_RIGHT
) and (tx
< wx
) then
3256 ty
:= wy
+ Random(11) - 5;
3259 // Äåëàåì âûñòðåë íóæíûì îðóæèåì:
3260 case FMonsterType
of
3262 g_Weapon_ball1(wx
, wy
, tx
, ty
, FUID
);
3265 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3266 g_Weapon_gun(wx
, wy
, tx
, ty
, 1, 3, FUID
, True);
3267 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3271 g_Weapon_shotgun(wx
, wy
, tx
, ty
, FUID
);
3272 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3274 FShellType
:= SHELL_SHELL
;
3278 g_Weapon_dshotgun(wx
, wy
, tx
, ty
, FUID
);
3280 FShellType
:= SHELL_DBLSHELL
;
3285 g_Weapon_rocket(wx
, wy
, tx
, ty
, FUID
);
3286 // MH_SEND_MonsterAttack(FUID, wx, wy, tx, ty);
3289 g_Weapon_revf(wx
, wy
, tx
, ty
, FUID
, FTargetUID
);
3292 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3293 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3294 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3298 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3299 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3300 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
3303 g_Weapon_aplasma(wx
, wy
, tx
, ty
, FUID
);
3305 g_Weapon_plasma(wx
, wy
, tx
, ty
, FUID
);
3307 g_Weapon_manfire(wx
, wy
, tx
, ty
, FUID
);
3308 MONSTER_BARON
, MONSTER_KNIGHT
:
3309 g_Weapon_ball7(wx
, wy
, tx
, ty
, FUID
);
3311 g_Weapon_ball2(wx
, wy
, tx
, ty
, FUID
);
3313 begin // Ñîçäàåì Lost_Soul:
3314 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+(FObj
.Rect
.Width
div 2),
3315 FObj
.Y
+FObj
.Rect
.Y
, FDirection
);
3318 begin // Öåëü - öåëü Pain_Elemental'à. Ëåòèì ê íåé:
3319 mon
.FTargetUID
:= FTargetUID
;
3320 GetPos(FTargetUID
, @o
);
3321 mon
.FTargetTime
:= 0;
3322 mon
.FNoRespawn
:= True;
3323 mon
.SetState(MONSTATE_GO
);
3324 mon
.shoot(@o
, True);
3325 Inc(gTotalMonsters
);
3327 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3332 if FMonsterType
<> MONSTER_PAIN
then
3333 if g_Game_IsNet
then
3334 MH_SEND_MonsterShot(FUID
, wx
, wy
, tx
, ty
);
3336 // Ñêîðîñòðåëüíûå ìîíñòðû:
3337 if (FMonsterType
= MONSTER_CGUN
) or
3338 (FMonsterType
= MONSTER_SPIDER
) or
3339 (FMonsterType
= MONSTER_BSP
) or
3340 (FMonsterType
= MONSTER_MANCUB
) or
3341 (FMonsterType
= MONSTER_ROBO
) then
3342 if not GetPos(FTargetUID
, @o
) then
3343 // Öåëü ìåðòâà - èùåì íîâóþ:
3345 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3346 if shoot(@o
, False) then
3350 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3351 FWaitAttackAnim
:= True;
3354 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3355 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3357 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3358 // Çâóêè ïðè ïåðåäâèæåíèè:
3359 case FMonsterType
of
3361 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3362 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3363 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3365 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3366 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3367 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3369 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3370 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3371 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3373 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3374 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3375 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3379 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3380 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3381 FObj
.Vel
.X
:= oldvelx
;
3383 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3384 if FAnim
[FCurAnim
, FDirection
] <> nil then
3385 FAnim
[FCurAnim
, FDirection
].Update();
3388 procedure TMonster
.SetDeadAnim
;
3390 if FAnim
<> nil then
3391 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3394 procedure TMonster
.RevertAnim(R
: Boolean = True);
3396 if FAnim
<> nil then
3397 if FAnim
[FCurAnim
, FDirection
].IsReverse
<> R
then
3398 FAnim
[FCurAnim
, FDirection
].Revert(R
);
3401 function TMonster
.AnimIsReverse
: Boolean;
3403 if FAnim
<> nil then
3404 Result
:= FAnim
[FCurAnim
, FDirection
].IsReverse
3409 procedure TMonster
.ClientUpdate();
3411 a
, b
, sx
, sy
, oldvelx
: Integer;
3418 sx
:= 0; // SHUT UP COMPILER
3421 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
3422 if FMonsterType
= MONSTER_FISH
then
3423 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3424 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
3427 // Ëåòàþùèå ìîíòñðû:
3428 if ((FMonsterType
= MONSTER_SOUL
) or
3429 (FMonsterType
= MONSTER_PAIN
) or
3430 (FMonsterType
= MONSTER_CACO
)) and
3431 (FState
<> MONSTATE_DIE
) and
3432 (FState
<> MONSTATE_DEAD
) then
3435 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
3436 if gTime
mod (GAME_TICK
*2) <> 0 then
3438 g_Obj_Move(@FObj
, fall
, True, True);
3439 positionChanged(); // this updates spatial accelerators
3443 if FPainTicks
> 0 then
3446 FPainSound
:= False;
3449 st
:= g_Obj_Move(@FObj
, fall
, True, True);
3450 positionChanged(); // this updates spatial accelerators
3452 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
3453 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
3454 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
3460 oldvelx
:= FObj
.Vel
.X
;
3462 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
3463 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
3464 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3466 if FFireTime
> 0 then
3468 if WordBool(st
and MOVE_INWATER
) then
3473 FFireTime
:= FFireTime
- 1;
3477 // Ìåðòâûé íè÷åãî íå äåëàåò:
3478 if (FState
= MONSTATE_DEAD
) then
3481 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
3482 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
3483 case FMonsterType
of
3485 if Random(4) = 0 then
3486 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3487 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3488 MONSTER_ROBO
, MONSTER_BARREL
:
3489 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3490 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3492 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
3493 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
3494 if Random(2) = 0 then
3495 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
3497 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
3501 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
3502 if FMonsterType
= MONSTER_BARREL
then
3504 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
3505 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3506 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3507 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
3511 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
3512 if FMonsterType
= MONSTER_SOUL
then
3513 if WordBool(st
and MOVE_HITAIR
) then
3514 g_Obj_SetSpeed(@FObj
, 16);
3519 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
3520 if FObj
.Vel
.Y
< 0 then
3521 if WordBool(st
and MOVE_INWATER
) then
3524 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
3525 FTargetTime
:= FTargetTime
+ 1;
3527 if FShellTimer
> -1 then
3528 if FShellTimer
= 0 then
3530 if FShellType
= SHELL_SHELL
then
3531 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3532 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3533 GameVelX
, GameVelY
-2, SHELL_SHELL
)
3534 else if FShellType
= SHELL_DBLSHELL
then
3536 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3537 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3538 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
3539 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3540 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3541 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
3544 end else Dec(FShellTimer
);
3546 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
3548 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
3549 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
3550 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3551 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
3552 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3553 (FObj
.Accel
.Y
= 0) then
3554 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3557 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
3559 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
3560 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
3562 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
3563 if gSoundEffectsDF
then PainSound();
3565 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
3568 // Ñíèæàåì áîëü ñî âðåìåíåì:
3571 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
3572 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
3574 SetState(MONSTATE_GO
);
3579 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
3582 FSleep
:= FSleep
+ 1;
3584 // Ïðîñïàëè äîñòàòî÷íî:
3585 if FSleep
>= 18 then
3591 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
3594 FSleep
:= FSleep
- 1;
3597 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
3599 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3600 if WordBool(st
and MOVE_BLOCK
) then
3604 SetState(MONSTATE_RUNOUT
);
3609 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
3610 if (FMonsterType
= MONSTER_VILE
) then
3611 if isCorpse(@FObj
, False) <> -1 then
3613 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
3619 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
3620 if Abs(sx
) < 40 then
3621 if FMonsterType
<> MONSTER_FISH
then
3623 SetState(MONSTATE_RUN
);
3629 // Óïåðëèñü â ñòåíó:
3630 if WordBool(st
and MOVE_HITWALL
) then
3632 case FMonsterType
of
3633 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
3635 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3636 (FObj
.Accel
.Y
= 0) then
3637 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
3638 // Ïðûæîê ÷åðåç ñòåíó:
3639 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3640 SetState(MONSTATE_CLIMB
);
3647 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
3648 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
3649 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
3651 if FMonsterType
= MONSTER_FISH
then
3653 if not WordBool(st
and MOVE_INWATER
) then
3654 begin // Ðûáà âíå âîäû:
3655 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
3656 begin // "Ñòîèò" òâåðäî
3657 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
3658 if FObj
.Accel
.Y
= 0 then
3660 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
3664 SetState(MONSTATE_PAIN
);
3665 FPain
:= FPain
+ 50;
3669 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3671 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3675 // Ðûáà ïëûâåò ââåðõ:
3676 if FObj
.Vel
.Y
< 0 then
3677 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
3679 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
3681 // Ïëàâàåì òóäà-ñþäà:
3682 SetState(MONSTATE_RUN
);
3687 else // Ëåòàþùèå ìîíñòðû
3689 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3691 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3696 else // "Íàçåìíûå" ìîíñòðû
3698 // Âîçìîæíî, ïèíàåì êóñêè:
3699 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
3701 b
:= Abs(FObj
.Vel
.X
);
3702 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3703 for a
:= 0 to High(gGibs
) do
3705 if gGibs
[a
].alive
and
3706 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3707 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
3710 if FObj
.Vel
.X
< 0 then
3712 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
3716 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
3718 positionChanged(); // this updates spatial accelerators
3722 // Áîññû ìîãóò ïèíàòü òðóïû:
3723 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
3724 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
3726 b
:= Abs(FObj
.Vel
.X
);
3727 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3728 for a
:= 0 to High(gCorpses
) do
3729 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
3731 co
:= gCorpses
[a
].Obj
;
3732 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3733 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
3735 if FObj
.Vel
.X
< 0 then
3736 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
3738 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
3743 FSleep
:= FSleep
+ 1;
3749 if Random(8) = 0 then
3753 // Áåæèì â âûáðàííóþ ñòîðîíó:
3754 if FDirection
= TDirection
.D_RIGHT
then
3755 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3757 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3759 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3760 if WordBool(st
and MOVE_INWATER
) then
3761 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3762 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3763 if FMonsterType
= MONSTER_FISH
then
3767 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
3769 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3770 if WordBool(st
and MOVE_BLOCK
) then
3772 SetState(MONSTATE_RUNOUT
);
3778 FSleep
:= FSleep
- 1;
3780 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
3781 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
3783 SetState(MONSTATE_GO
);
3787 if Random(8) = 0 then
3791 // Áåæèì â âûáðàííóþ ñòîðîíó:
3792 if FDirection
= TDirection
.D_RIGHT
then
3793 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3795 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3797 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3798 if WordBool(st
and MOVE_INWATER
) then
3799 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3800 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3801 if FMonsterType
= MONSTER_FISH
then
3805 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3807 // Âûøëè èç ÁëîêÌîíà:
3808 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3811 FSleep
:= FSleep
- 1;
3813 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3814 if FSleep
<= -18 then
3816 SetState(MONSTATE_GO
);
3820 if Random(8) = 0 then
3824 // Áåæèì â âûáðàííóþ ñòîðîíó:
3825 if FDirection
= TDirection
.D_RIGHT
then
3826 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3828 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3830 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3831 if WordBool(st
and MOVE_INWATER
) then
3832 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3833 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3834 if FMonsterType
= MONSTER_FISH
then
3838 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3840 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3841 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3842 (not WordBool(st
and MOVE_HITWALL
)) then
3844 SetState(MONSTATE_GO
);
3847 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3848 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3850 SetState(MONSTATE_RUN
);
3855 // Áåæèì â âûáðàííóþ ñòîðîíó:
3856 if FDirection
= TDirection
.D_RIGHT
then
3857 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3859 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3861 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3862 if WordBool(st
and MOVE_INWATER
) then
3863 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3864 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3865 if FMonsterType
= MONSTER_FISH
then
3869 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3870 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3872 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3873 if FMonsterType
= MONSTER_SOUL
then
3875 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3876 SetState(MONSTATE_GO
);
3881 // Çàìåäëÿåìñÿ ïðè àòàêå:
3882 if FMonsterType
<> MONSTER_FISH
then
3883 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3885 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3886 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3888 // Öåëü ïîãèáëà => èäåì äàëüøå:
3889 if not GetPos(FTargetUID
, @o
) then
3891 SetState(MONSTATE_GO
);
3896 // Öåëü íå âèäíî => èäåì äàëüøå:
3897 if not g_Look(@FObj
, @o
, FDirection
) then
3899 SetState(MONSTATE_GO
);
3904 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3905 if g_Obj_CollideWater(@o
, 0, 0) then
3907 SetState(MONSTATE_GO
);
3913 end; // case FState of ...
3917 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3918 if FState
= MONSTATE_REVIVE
then
3919 if FAnim
[FCurAnim
, FDirection
].Played
then
3920 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3921 FAnim
[FCurAnim
, FDirection
].Revert(False);
3922 SetState(MONSTATE_GO
);
3925 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3926 if vilefire
<> nil then
3929 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3930 if (FState
= MONSTATE_DIE
) and
3931 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3932 (FAnim
[FCurAnim
, FDirection
].Played
) then
3935 SetState(MONSTATE_DEAD
);
3937 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3938 if (FMonsterType
= MONSTER_PAIN
) or
3939 (FMonsterType
= MONSTER_SOUL
) or
3940 (FMonsterType
= MONSTER_BARREL
) then
3943 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3946 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3947 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3948 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3949 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3950 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3951 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3952 if FState
= MONSTATE_ATTACK
then
3953 begin // Ñîñòîÿíèå - Àòàêà
3954 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3955 if FMonsterType
<> MONSTER_SOUL
then
3956 SetState(MONSTATE_GO
);
3958 else // Ñîñòîÿíèå - Ñòðåëüáà
3960 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3961 if not FChainFire
then
3962 SetState(MONSTATE_GO
)
3964 begin // Íàäî ñòðåëÿòü åùå
3965 FChainFire
:= False;
3966 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3967 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3968 FAnim
[FCurAnim
, FDirection
].Reset();
3972 FWaitAttackAnim
:= False;
3975 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3976 if (FMonsterType
= MONSTER_SOUL
) or
3977 ( (not FWaitAttackAnim
) and
3978 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3979 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3981 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3982 if FState
= MONSTATE_ATTACK
then
3983 begin // Ñîñòîÿíèå - Àòàêà
3984 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3985 if FMonsterType
= MONSTER_SOUL
then
3986 FAnim
[FCurAnim
, FDirection
].Reset();
3988 case FMonsterType
of
3989 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3990 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3991 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3992 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3993 if FMonsterType
= MONSTER_SOUL
then
3994 SetState(MONSTATE_GO
);
3997 g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
);
3999 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4000 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
4001 if FCurAnim
= ANIM_ATTACK2
then
4004 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
4005 g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
);
4009 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
4010 if FCurAnim
= ANIM_ATTACK2
then
4012 sx
:= isCorpse(@FObj
, True);
4014 begin // Íàøëè, êîãî âîñêðåñèòü
4015 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
4016 // Âîñêðåøàòü - ñåáå âðåäèòü:
4017 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
4023 else // Ñîñòîÿíèå - Ñòðåëüáà
4025 // Ñêîðîñòðåëüíûå ìîíñòðû:
4026 if (FMonsterType
= MONSTER_CGUN
) or
4027 (FMonsterType
= MONSTER_SPIDER
) or
4028 (FMonsterType
= MONSTER_BSP
) or
4029 (FMonsterType
= MONSTER_MANCUB
) or
4030 (FMonsterType
= MONSTER_ROBO
) then
4031 if not GetPos(FTargetUID
, @o
) then
4032 // Öåëü ìåðòâà - èùåì íîâóþ:
4034 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
4035 if shoot(@o
, False) then
4039 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
4040 FWaitAttackAnim
:= True;
4043 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
4044 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
4046 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
4047 // Çâóêè ïðè ïåðåäâèæåíèè:
4048 case FMonsterType
of
4050 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4051 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4052 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
4054 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4055 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4056 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
4058 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4059 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4060 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4062 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4063 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
4064 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4068 // Êîñòûëü äëÿ ïîòîêîâ
4069 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
4070 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
4071 FObj
.Vel
.X
:= oldvelx
;
4073 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
4074 if FAnim
[FCurAnim
, FDirection
] <> nil then
4075 FAnim
[FCurAnim
, FDirection
].Update();
4078 procedure TMonster
.ClientAttack(wx
, wy
, atx
, aty
: Integer);
4080 case FMonsterType
of
4083 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
4084 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4088 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
4090 FShellType
:= SHELL_SHELL
;
4094 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', wx
, wy
);
4096 FShellType
:= SHELL_DBLSHELL
;
4098 MONSTER_CGUN
, MONSTER_SPIDER
:
4100 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
4101 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4104 g_Weapon_ball1(wx
, wy
, atx
, aty
, FUID
);
4106 g_Weapon_rocket(wx
, wy
, atx
, aty
, FUID
);
4108 g_Weapon_revf(wx
, wy
, atx
, aty
, FUID
, FTargetUID
);
4110 g_Weapon_aplasma(wx
, wy
, atx
, aty
, FUID
);
4112 g_Weapon_plasma(wx
, wy
, atx
, aty
, FUID
);
4114 g_Weapon_manfire(wx
, wy
, atx
, aty
, FUID
);
4115 MONSTER_BARON
, MONSTER_KNIGHT
:
4116 g_Weapon_ball7(wx
, wy
, atx
, aty
, FUID
);
4118 g_Weapon_ball2(wx
, wy
, atx
, aty
, FUID
);
4122 procedure TMonster
.Turn();
4125 if FDirection
= TDirection
.D_LEFT
then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
4127 // Áåæèì â âûáðàííóþ ñòîðîíó:
4128 if FDirection
= TDirection
.D_RIGHT
then
4129 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
4131 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
4134 function TMonster
.findNewPrey(): Boolean;
4138 PlayersSee
, MonstersSee
: Array of DWORD
;
4139 PlayerNear
, MonsterNear
: Integer;
4142 SetLength(MonstersSee
, 0);
4143 SetLength(PlayersSee
, 0);
4150 // Ïîåõàâøèå, êàííèáàëû, è äîáðûå èãðîêîâ íå òðîãàþò
4151 if (gPlayers
<> nil) and (FBehaviour
<> BH_INSANE
) and
4152 (FBehaviour
<> BH_CANNIBAL
) and (FBehaviour
<> BH_GOOD
) then
4153 for a
:= 0 to High(gPlayers
) do
4154 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
4155 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
4157 if g_Look(@FObj
, @gPlayers
[a
].Obj
, FDirection
) then
4159 SetLength(PlayersSee
, Length(PlayersSee
) + 1);
4160 PlayersSee
[High(PlayersSee
)] := a
;
4162 l2
:= Abs(gPlayers
[a
].GameX
-FObj
.X
)+
4163 Abs(gPlayers
[a
].GameY
-FObj
.Y
);
4167 PlayerNear
:= Integer(a
);
4171 // Êèëëåðû è äîáðûå íå òðîãàþò ìîíñòðîâ
4172 if (gMonsters
<> nil) and (FBehaviour
<> BH_KILLER
) and (FBehaviour
<> BH_GOOD
) then
4173 for a
:= 0 to High(gMonsters
) do
4174 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
4175 (gMonsters
[a
].FUID
<> FUID
) then
4177 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
4178 Continue
; // Êàííèáàëû àòàêóþò òîëüêî ñîðîäè÷åé
4179 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
)
4180 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4181 Continue
; // Ïîåõàâøèå íå òðîãàþò äðóçåé, íî èì íå íðàâÿòñÿ áî÷êè
4182 if ((FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_MANIAC
))
4183 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4184 Continue
; // Îñòàâøèåñÿ òèïû, êðîìå êàííèáàëîâ, íå òðîãàþò ñâîèõ äðóçåé
4186 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
4188 SetLength(MonstersSee
, Length(MonstersSee
) + 1);
4189 MonstersSee
[High(MonstersSee
)] := a
;
4191 l2
:= Abs(gMonsters
[a
].FObj
.X
-FObj
.X
)+
4192 Abs(gMonsters
[a
].FObj
.Y
-FObj
.Y
);
4196 MonsterNear
:= Integer(a
);
4201 BH_NORMAL
, BH_KILLER
:
4203 // Îáû÷íûé è êèëëåð ñíà÷àëà èùóò èãðîêîâ â ïîëå çðåíèÿ
4204 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4206 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4207 FTargetUID
:= gPlayers
[a
].UID
;
4210 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4213 FTargetUID
:= gPlayers
[a
].UID
;
4215 // Ïîòîì îáû÷íûå èùóò ìîíñòðîâ â ïîëå çðåíèÿ
4216 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4218 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4219 FTargetUID
:= gMonsters
[a
].UID
;
4222 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4225 FTargetUID
:= gMonsters
[a
].UID
;
4228 BH_MANIAC
, BH_INSANE
, BH_CANNIBAL
:
4230 // Ìàíüÿêè, ïîåõàâøèå è êàííèáàëû ñíà÷àëà èñòðåáëÿþò âñ¸ â ïîëå çðåíèÿ
4231 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4233 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4234 FTargetUID
:= gPlayers
[a
].UID
;
4236 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4238 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4239 FTargetUID
:= gMonsters
[a
].UID
;
4241 // Çàòåì èùóò êîãî-òî ïîáëèçîñòè
4242 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4245 FTargetUID
:= gPlayers
[a
].UID
;
4247 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4250 FTargetUID
:= gMonsters
[a
].UID
;
4255 // Åñëè è ìîíñòðîâ íåò - íà÷èíàåì æäàòü öåëü:
4256 if FTargetUID
= 0 then
4258 // Ïîåõàâøèé ïûòàåòñÿ ñàìîóáèòüñÿ
4259 if FBehaviour
= BH_INSANE
then
4262 FTargetTime
:= MAX_ATM
;
4271 function TMonster
.kick(o
: PObj
): Boolean;
4275 case FMonsterType
of
4278 SetState(MONSTATE_ATTACK
);
4283 SetState(MONSTATE_ATTACK
);
4284 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj
.X
, FObj
.Y
);
4289 SetState(MONSTATE_ATTACK
);
4290 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj
.X
, FObj
.Y
);
4293 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4295 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
4296 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj
.X
, FObj
.Y
);
4299 MONSTER_BARON
, MONSTER_KNIGHT
,
4300 MONSTER_CACO
, MONSTER_MANCUB
:
4301 // Ýòè ìîíñòðû íå ïèíàþò - îíè ñòðåëÿþò â óïîð:
4302 if not g_Game_IsClient
then Result
:= shoot(o
, True);
4306 function TMonster
.shoot(o
: PObj
; immediately
: Boolean): Boolean;
4316 // Æäàòü âðåìåíè ãîòîâíîñòè ê âûñòðåëó:
4317 if not immediately
then
4318 case FMonsterType
of
4319 MONSTER_FISH
, MONSTER_BARREL
, MONSTER_DEMON
:
4320 Exit
; // íå ñòðåëÿþò
4321 MONSTER_CGUN
, MONSTER_BSP
, MONSTER_ROBO
:
4324 // Âðåìÿ âûñòðåëà óïóùåíî:
4326 FAmmo
:= IfThen(FMonsterType
= MONSTER_ROBO
, -200, -50);
4332 // Âðåìÿ âûñòðåëà óïóùåíî:
4339 // Âðåìÿ âûñòðåëà óïóùåíî:
4340 if FAmmo
>= 100 then
4345 // Ñòðåëÿåò íå âñåãäà:
4346 if Random(2) = 0 then
4349 // Âðåìÿ âûñòðåëà óïóùåíî:
4353 MONSTER_BARON
, MONSTER_KNIGHT
: if Random(8) <> 0 then Exit
;
4354 MONSTER_SKEL
: if Random(32) <> 0 then Exit
;
4355 MONSTER_VILE
: if Random(8) <> 0 then Exit
;
4356 MONSTER_PAIN
: if Random(8) <> 0 then Exit
;
4357 else if Random(16) <> 0 then Exit
;
4361 if not g_Look(@FObj
, o
, FDirection
) then
4366 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2)+((o
^.Vel
.X
{+o^.Accel.X})*12);
4367 ty
:= o
^.Y
+o
^.Rect
.Y
+(o
^.Rect
.Height
div 2)+((o
^.Vel
.Y
{+o^.Accel.Y})*12);
4369 // Ðàçíèöà ïî âûñîòå áîëüøå ðàçíèöû ïî ãîðèçîíòàëè
4370 // (íå ìîæåò ñòðåëÿòü ïîä òàêèì áîëüøèì óãëîì):
4371 if Abs(tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2))) <
4372 Abs(ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2))) then
4375 case FMonsterType
of
4376 MONSTER_IMP
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
:
4378 SetState(MONSTATE_SHOOT
);
4383 SetState(MONSTATE_SHOOT
);
4387 begin // Çàæèãàåì îãîíü
4388 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2);
4389 ty
:= o
^.Y
+o
^.Rect
.Y
;
4390 SetState(MONSTATE_SHOOT
);
4394 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ATTACK', FObj
.X
, FObj
.Y
);
4395 g_Sound_PlayExAt('SOUND_FIRE', o
^.X
, o
^.Y
);
4398 begin // Ëåòèò â ñòîðîíó öåëè:
4399 SetState(MONSTATE_ATTACK
);
4400 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj
.X
, FObj
.Y
);
4402 xd
:= tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
4403 yd
:= ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
4404 m
:= Max(Abs(xd
), Abs(yd
));
4408 FObj
.Vel
.X
:= (xd
*16) div m
;
4409 FObj
.Vel
.Y
:= (yd
*16) div m
;
4411 MONSTER_MANCUB
, MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_BSP
, MONSTER_ROBO
,
4412 MONSTER_CYBER
, MONSTER_CGUN
, MONSTER_SPIDER
, MONSTER_PAIN
, MONSTER_MAN
:
4414 // Ìàíêóáóñ ðÿâêàåò ïåðåä ïåðâîé àòàêîé:
4415 if FMonsterType
= MONSTER_MANCUB
then
4417 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj
.X
, FObj
.Y
);
4419 SetState(MONSTATE_SHOOT
);
4427 function TMonster
.alive(): Boolean;
4429 Result
:= (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) and (FHealth
> 0);
4432 procedure TMonster
.SetHealth(aH
: Integer);
4434 if (aH
> 0) and (aH
< 1000000) then
4437 if FHealth
> FMaxHealth
then
4438 FMaxHealth
:= FHealth
;
4442 procedure TMonster
.WakeUp();
4444 if g_Game_IsClient
then Exit
;
4445 SetState(MONSTATE_GO
);
4446 FTargetTime
:= MAX_ATM
;
4450 procedure TMonster
.SaveState (st
: TStream
);
4458 // Ñèãíàòóðà ìîíñòðà:
4459 utils
.writeSign(st
, 'MONS');
4460 utils
.writeInt(st
, Byte(0)); // version
4462 utils
.writeInt(st
, Word(FUID
));
4464 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
4465 utils
.writeInt(st
, Byte(b
));
4466 // Íàäî ëè óäàëèòü åãî
4467 utils
.writeBool(st
, FRemoved
);
4468 // Îñòàëîñü çäîðîâüÿ
4469 utils
.writeInt(st
, LongInt(FHealth
));
4471 utils
.writeInt(st
, Byte(FState
));
4473 utils
.writeInt(st
, Byte(FCurAnim
));
4475 utils
.writeInt(st
, Word(FTargetUID
));
4476 // Âðåìÿ ïîñëå ïîòåðè öåëè
4477 utils
.writeInt(st
, LongInt(FTargetTime
));
4478 // Ïîâåäåíèå ìîíñòðà
4479 utils
.writeInt(st
, Byte(FBehaviour
));
4480 // Ãîòîâíîñòü ê âûñòðåëó
4481 utils
.writeInt(st
, LongInt(FAmmo
));
4483 utils
.writeInt(st
, LongInt(FPain
));
4485 utils
.writeInt(st
, LongInt(FSleep
));
4486 // Îçâó÷èâàòü ëè áîëü
4487 utils
.writeBool(st
, FPainSound
);
4488 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4489 utils
.writeBool(st
, FWaitAttackAnim
);
4490 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4491 utils
.writeBool(st
, FChainFire
);
4492 // Ïîäëåæèò ëè ðåñïàâíó
4493 utils
.writeBool(st
, FNoRespawn
);
4495 utils
.writeInt(st
, LongInt(tx
));
4496 utils
.writeInt(st
, LongInt(ty
));
4497 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4498 utils
.writeInt(st
, LongInt(FStartID
));
4499 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4500 utils
.writeInt(st
, LongInt(FSpawnTrigger
));
4502 Obj_SaveState(st
, @FObj
);
4503 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4504 anim
:= (vilefire
<> nil);
4505 utils
.writeBool(st
, anim
);
4506 // Åñëè åñòü - ñîõðàíÿåì:
4507 if anim
then vilefire
.SaveState(st
);
4509 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4511 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4512 anim
:= (FAnim
[i
, TDirection
.D_LEFT
] <> nil);
4513 utils
.writeBool(st
, anim
);
4514 // Åñëè åñòü - ñîõðàíÿåì
4515 if anim
then FAnim
[i
, TDirection
.D_LEFT
].SaveState(st
);
4516 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4517 anim
:= (FAnim
[i
, TDirection
.D_RIGHT
] <> nil);
4518 utils
.writeBool(st
, anim
);
4519 // Åñëè åñòü - ñîõðàíÿåì
4520 if anim
then FAnim
[i
, TDirection
.D_RIGHT
].SaveState(st
);
4525 procedure TMonster
.LoadState (st
: TStream
);
4533 // Ñèãíàòóðà ìîíñòðà:
4534 if not utils
.checkSign(st
, 'MONS') then raise XStreamError
.Create('invalid monster signature');
4535 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid monster version');
4536 if (uidMap
[FUID
] <> nil) and (uidMap
[FUID
] <> self
) then raise Exception
.Create('internal error in monster loader (0)');
4537 uidMap
[FUID
] := nil;
4539 FUID
:= utils
.readWord(st
);
4540 //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
4541 if (uidMap
[FUID
] <> nil) then raise Exception
.Create('internal error in monster loader (1)');
4542 uidMap
[FUID
] := self
;
4544 b
:= utils
.readByte(st
);
4545 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
4546 // Íàäî ëè óäàëèòü åãî
4547 FRemoved
:= utils
.readBool(st
);
4548 // Îñòàëîñü çäîðîâüÿ
4549 FHealth
:= utils
.readLongInt(st
);
4551 FState
:= utils
.readByte(st
);
4553 FCurAnim
:= utils
.readByte(st
);
4555 FTargetUID
:= utils
.readWord(st
);
4556 // Âðåìÿ ïîñëå ïîòåðè öåëè
4557 FTargetTime
:= utils
.readLongInt(st
);
4558 // Ïîâåäåíèå ìîíñòðà
4559 FBehaviour
:= utils
.readByte(st
);
4560 // Ãîòîâíîñòü ê âûñòðåëó
4561 FAmmo
:= utils
.readLongInt(st
);
4563 FPain
:= utils
.readLongInt(st
);
4565 FSleep
:= utils
.readLongInt(st
);
4566 // Îçâó÷èâàòü ëè áîëü
4567 FPainSound
:= utils
.readBool(st
);
4568 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4569 FWaitAttackAnim
:= utils
.readBool(st
);
4570 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4571 FChainFire
:= utils
.readBool(st
);
4572 // Ïîäëåæèò ëè ðåñïàâíó
4573 FNoRespawn
:= utils
.readBool(st
);
4575 tx
:= utils
.readLongInt(st
);
4576 ty
:= utils
.readLongInt(st
);
4577 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4578 FStartID
:= utils
.readLongInt(st
);
4579 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4580 FSpawnTrigger
:= utils
.readLongInt(st
);
4582 Obj_LoadState(@FObj
, st
);
4583 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4584 anim
:= utils
.readBool(st
);
4585 // Åñëè åñòü - çàãðóæàåì:
4588 Assert(vilefire
<> nil, 'TMonster.LoadState: no vilefire anim');
4589 vilefire
.LoadState(st
);
4592 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4594 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4595 anim
:= utils
.readBool(st
);
4596 // Åñëè åñòü - çàãðóæàåì
4599 Assert(FAnim
[i
, TDirection
.D_LEFT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_left anim');
4600 FAnim
[i
, TDirection
.D_LEFT
].LoadState(st
);
4602 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4603 anim
:= utils
.readBool(st
);
4604 // Åñëè åñòü - çàãðóæàåì
4607 Assert(FAnim
[i
, TDirection
.D_RIGHT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_right anim');
4608 FAnim
[i
, TDirection
.D_RIGHT
].LoadState(st
);
4614 procedure TMonster
.ActivateTriggers();
4618 if FDieTriggers
<> nil then
4619 for a
:= 0 to High(FDieTriggers
) do
4620 g_Triggers_Press(FDieTriggers
[a
], ACTIVATE_MONSTERPRESS
);
4621 if FSpawnTrigger
> -1 then
4623 g_Triggers_DecreaseSpawner(FSpawnTrigger
);
4624 FSpawnTrigger
:= -1;
4628 procedure TMonster
.AddTrigger(t
: Integer);
4630 SetLength(FDieTriggers
, Length(FDieTriggers
)+1);
4631 FDieTriggers
[High(FDieTriggers
)] := t
;
4634 procedure TMonster
.ClearTriggers();
4636 SetLength(FDieTriggers
, 0);
4639 procedure TMonster
.CatchFire(Attacker
: Word);
4642 FFireAttacker
:= Attacker
;
4643 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_MonsterState(FUID
);
4646 procedure TMonster
.OnFireFlame(Times
: DWORD
= 1);
4651 if (Random(10) = 1) and (Times
= 1) then
4654 if g_Frames_Get(id
, 'FRAMES_FLAME') then
4656 for i
:= 1 to Times
do
4658 Anim
:= TAnimation
.Create(id
, False, 3);
4660 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
4661 Obj
.Y
+8+Random(8+Times
*2)+IfThen(FState
= MONSTATE_DEAD
, 16, 0), Anim
, ONCEANIM_SMOKE
);
4668 // ////////////////////////////////////////////////////////////////////////// //
4669 // throws on invalid uid
4670 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
4672 result
:= g_Mons_ByIdx_NC(uid
);
4673 if (result
= nil) then raise Exception
.Create('g_Mons_ByIdx: invalid monster id');
4677 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
4679 if (uid
< 0) or (uid
> High(gMonsters
)) then begin result
:= nil; exit
; end;
4680 result
:= gMonsters
[uid
];
4683 function g_Mons_TotalCount (): Integer; inline;
4685 result
:= Length(gMonsters
);
4689 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
4695 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4696 for idx
:= 0 to High(gMonsters
) do
4698 mon
:= gMonsters
[idx
];
4699 if (mon
<> nil) then
4702 if result
then exit
;
4708 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
4714 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4715 for idx
:= 0 to High(gMonsters
) do
4717 mon
:= gMonsters
[idx
];
4718 if (mon
<> nil) and mon
.alive
then
4721 if result
then exit
;
4727 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
4729 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4731 result := mon.alive;// and g_Obj_Collide(x, y, width, height, @mon.Obj));
4738 it
: TMonsterGrid
.Iter
;
4741 if (width
< 1) or (height
< 1) then exit
;
4742 if gmon_debug_use_sqaccel
then
4744 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4745 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4746 for mit
in it
do if (mit
.alive
) then begin result
:= true; break
; end;
4751 for idx
:= 0 to High(gMonsters
) do
4753 mon
:= gMonsters
[idx
];
4754 if (mon
<> nil) and mon
.alive
then
4756 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4767 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4769 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4778 it
: TMonsterGrid
.Iter
;
4781 if (width
< 1) or (height
< 1) then exit
;
4782 if gmon_debug_use_sqaccel
then
4784 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4785 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4786 for mit
in it
do if (cb(mit
^)) then begin result
:= true; break
; end;
4791 for idx
:= 0 to High(gMonsters
) do
4793 mon
:= gMonsters
[idx
];
4794 if (mon
<> nil) and mon
.alive
then
4796 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4799 if result
then exit
;
4807 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4809 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4812 //if mon.alive and g_Obj_Collide(x, y, width, height, @mon.Obj) then result := cb(mon);
4813 if mon.alive then result := cb(mon) else result := false;
4820 it
: TMonsterGrid
.Iter
;
4823 if (width
< 1) or (height
< 1) then exit
;
4824 if gmon_debug_use_sqaccel
then
4827 if (width = 1) and (height = 1) then
4829 result := (monsGrid.forEachAtPoint(x, y, monsCollCheck) <> nil);
4833 result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4836 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4839 if (mit
^.alive
) then
4841 if (cb(mit
^)) then begin result
:= true; break
; end;
4848 for idx
:= 0 to High(gMonsters
) do
4850 mon
:= gMonsters
[idx
];
4851 if (mon
<> nil) and mon
.alive
then
4853 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4856 if result
then exit
;