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}
25 {$IFDEF USE_MEMPOOL}mempool
,{$ENDIF}
26 g_basic
, e_graphics
, g_phys
, g_textures
, g_grid
,
27 g_saveload
, g_panel
, xprofiler
;
53 TMonster
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
57 FDirection
: TDirection
;
58 FStartDirection
: TDirection
;
59 FStartX
, FStartY
: Integer;
65 FAnim
: Array of Array [TDirection
.D_LEFT
..TDirection
.D_RIGHT
] of TAnimation
;
74 FWaitAttackAnim
: Boolean;
85 FFirePainTime
: Integer;
88 mProxyId
: Integer; // node in dyntree or -1
89 mArrIdx
: Integer; // in gMonsters
91 FDieTriggers
: Array of Integer;
92 FSpawnTrigger
: Integer;
94 mNeedSend
: Boolean; // for network
96 mEDamageType
: Integer;
99 function findNewPrey(): Boolean;
100 procedure ActivateTriggers();
102 procedure setGameX (v
: Integer); inline;
103 procedure setGameY (v
: Integer); inline;
105 procedure doDamage (v
: Integer);
110 trapCheckFrameId
: DWord
; // for `g_weapons.CheckTrap()`
111 mplatCheckFrameId
: LongWord;
113 constructor Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
114 destructor Destroy(); override;
115 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
116 function Collide(Panel
: TPanel
): Boolean; overload
;
117 function Collide(X
, Y
: Integer): Boolean; overload
;
118 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
119 function alive(): Boolean;
120 procedure SetHealth(aH
: Integer);
121 procedure Push(vx
, vy
: Integer);
122 function Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
123 function Heal(Value
: Word): Boolean;
126 procedure ClientUpdate();
127 procedure ClientAttack(wx
, wy
, atx
, aty
: Integer);
128 procedure SetDeadAnim
;
131 procedure WakeUpSound();
132 procedure DieSound();
133 procedure PainSound();
134 procedure ActionSound();
135 procedure AddTrigger(t
: Integer);
136 procedure ClearTriggers();
138 procedure SaveState (st
: TStream
);
139 procedure LoadState (st
: TStream
);
140 procedure SetState(State
: Byte; ForceAnim
: Byte = 255);
141 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
142 procedure MakeBloodSimple(Count
: Word);
143 procedure RevertAnim(R
: Boolean = True);
144 function AnimIsReverse
: Boolean;
145 function shoot(o
: PObj
; immediately
: Boolean): Boolean;
146 function kick(o
: PObj
): Boolean;
147 procedure CatchFire(Attacker
: Word);
148 procedure OnFireFlame(Times
: DWORD
= 1);
150 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
152 procedure setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline;
153 procedure moveBy (dx
, dy
: Integer); inline;
155 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
158 function gncNeedSend (): Boolean; inline;
159 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
162 property Obj
: TObj read FObj
;
164 property proxyId
: Integer read mProxyId
;
165 property arrIdx
: Integer read mArrIdx
;
167 property MonsterType
: Byte read FMonsterType
;
168 property MonsterHealth
: Integer read FHealth write FHealth
;
169 property MonsterAmmo
: Integer read FAmmo write FAmmo
;
170 property MonsterTargetUID
: Word read FTargetUID write FTargetUID
;
171 property MonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
172 property MonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
173 property MonsterSleep
: Integer read FSleep write FSleep
;
174 property MonsterState
: Byte read FState write FState
;
175 property MonsterRemoved
: Boolean read FRemoved write FRemoved
;
176 property MonsterPain
: Integer read FPain write FPain
;
177 property MonsterAnim
: Byte read FCurAnim write FCurAnim
;
179 property UID
: Word read FUID write FUID
;
180 property SpawnTrigger
: Integer read FSpawnTrigger write FSpawnTrigger
;
182 property GameX
: Integer read FObj
.X write setGameX
;
183 property GameY
: Integer read FObj
.Y write setGameY
;
184 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
185 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
186 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
187 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
188 property GameDirection
: TDirection read FDirection write FDirection
;
190 property StartID
: Integer read FStartID
;
193 property eMonsterType
: Byte read FMonsterType
;
194 property eMonsterHealth
: Integer read FHealth write FHealth
;
195 property eMonsterAmmo
: Integer read FAmmo write FAmmo
;
196 property eMonsterTargetUID
: Word read FTargetUID write FTargetUID
;
197 property eMonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
198 property eMonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
199 property eMonsterSleep
: Integer read FSleep write FSleep
;
200 property eMonsterState
: Byte read FState write FState
;
201 property eMonsterRemoved
: Boolean read FRemoved
;
202 property eMonsterPain
: Integer read FPain write FPain
;
203 property eMonsterAnim
: Byte read FCurAnim
;
205 property eUID
: Word read FUID
;
206 property eSpawnTrigger
: Integer read FSpawnTrigger
;
208 property eGameX
: Integer read FObj
.X write setGameX
;
209 property eGameY
: Integer read FObj
.Y write setGameY
;
210 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
211 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
212 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
213 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
214 property eGameDirection
: TDirection read FDirection write FDirection
;
216 property eStartID
: Integer read FStartID
;
218 // set this before assigning something to `eDamage`
219 property eDamageType
: Integer read mEDamageType write mEDamageType
;
220 property eDamage
: Integer write doDamage
;
224 // will be called from map loader
225 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
227 procedure g_Monsters_LoadData ();
228 procedure g_Monsters_FreeData ();
229 procedure g_Monsters_Init ();
230 procedure g_Monsters_Free (clearGrid
: Boolean=true);
231 function g_Monsters_Create (MonsterType
: Byte; X
, Y
: Integer; Direction
: TDirection
;
232 AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
233 procedure g_Monsters_Update ();
234 procedure g_Monsters_Draw ();
235 procedure g_Monsters_DrawHealth ();
236 function g_Monsters_ByUID (UID
: Word): TMonster
;
237 procedure g_Monsters_killedp ();
238 procedure g_Monsters_SaveState (st
: TStream
);
239 procedure g_Monsters_LoadState (st
: TStream
);
241 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
242 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
244 function g_Mons_TypeLo (): Integer; inline;
245 function g_Mons_TypeHi (): Integer; inline;
247 function g_Mons_TypeIdByName (const name
: AnsiString): Integer;
248 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
249 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
253 TEachMonsterCB
= function (mon
: TMonster
): Boolean is nested
; // return `true` to stop
255 // throws on invalid uid
256 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
259 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
261 function g_Mons_TotalCount (): Integer; inline;
263 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
265 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
266 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
268 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
269 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
271 function g_Mons_getNewTrapFrameId (): DWord
; inline;
272 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
276 TMonsAlongLineCB
= function (mon
: TMonster
; tag
: Integer): Boolean is nested
;
278 function g_Mons_AlongLine (x0
, y0
, x1
, y1
: Integer; cb
: TMonsAlongLineCB
; log
: Boolean=false): TMonster
;
282 gmon_debug_use_sqaccel
: Boolean = true;
286 procedure g_Mons_ProfilersBegin ();
287 procedure g_Mons_ProfilersEnd ();
289 procedure g_Mons_LOS_Start (); inline;
290 procedure g_Mons_LOS_End (); inline;
293 profMonsLOS
: TProfiler
= nil; //WARNING: FOR DEBUGGING ONLY!
297 TMonsterGrid
= specialize TBodyGridBase
<TMonster
>;
300 monsGrid
: TMonsterGrid
= nil; // DO NOT USE! public for debugging only!
304 gmon_debug_think
: Boolean = true;
305 gmon_debug_one_think_step
: Boolean = false;
311 e_log
, e_texture
, g_main
, g_sound
, g_gfx
, g_player
, g_game
,
312 g_weapons
, g_triggers
, MAPDEF
, g_items
, g_options
,
313 g_console
, g_map
, Math
, g_menu
, wadreader
,
314 g_language
, g_netmsg
, idpool
, utils
, xstreams
;
318 // ////////////////////////////////////////////////////////////////////////// //
319 procedure g_Mons_ProfilersBegin ();
321 if (profMonsLOS
= nil) then profMonsLOS
:= TProfiler
.Create('LOS CALC', g_profile_history_size
);
322 profMonsLOS
.mainBegin(g_profile_los
);
323 if g_profile_los
then
325 profMonsLOS
.sectionBegin('loscalc');
326 profMonsLOS
.sectionEnd();
330 procedure g_Mons_ProfilersEnd ();
332 if (profMonsLOS
<> nil) and (g_profile_los
) then profMapCollision
.mainEnd();
335 procedure g_Mons_LOS_Start (); inline;
337 profMonsLOS
.sectionBeginAccum('loscalc');
340 procedure g_Mons_LOS_End (); inline;
342 profMonsLOS
.sectionEnd();
346 // ////////////////////////////////////////////////////////////////////////// //
348 monCheckTrapLastFrameId
: DWord
= 0;
349 monCheckMPlatLastFrameId
: LongWord = 0;
352 procedure TMonster
.getMapBox (out x
, y
, w
, h
: Integer); inline;
354 x
:= FObj
.X
+FObj
.Rect
.X
;
355 y
:= FObj
.Y
+FObj
.Rect
.Y
;
356 w
:= FObj
.Rect
.Width
;
357 h
:= FObj
.Rect
.Height
;
360 function TMonster
.gncNeedSend (): Boolean; inline; begin result
:= mNeedSend
; mNeedSend
:= false; end;
362 procedure TMonster
.setDirty (); inline; begin mNeedSend
:= true; end;
365 // ////////////////////////////////////////////////////////////////////////// //
366 function g_Mons_AlongLine (x0
, y0
, x1
, y1
: Integer; cb
: TMonsAlongLineCB
; log
: Boolean=false): TMonster
;
368 if not assigned(cb
) then begin result
:= nil; exit
; end;
369 result
:= monsGrid
.forEachAlongLine(x0
, y0
, x1
, y1
, cb
, -1, log
);
373 //WARNING! call this after monster position was changed, or coldet will not work right!
374 procedure TMonster
.positionChanged ();
377 nx
, ny
, nw
, nh
: Integer;
379 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
380 //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);
382 if (mProxyId
= -1) then
385 mProxyId
:= monsGrid
.insertBody(self
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
386 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
387 monsGrid
.getBodyXY(mProxyId
, x
, y
);
388 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
);
393 monsGrid
.getBodyDims(mProxyId
, x
, y
, w
, h
);
394 getMapBox(nx
, ny
, nw
, nh
);
396 if (w
<> nw
) or (h
<> nh
) then
399 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
400 e_WriteLog(Format('monster #%d:(%u): resized; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
402 monsGrid
.moveResizeBody(mProxyId
, nx
, ny
, nw
, nh
);
404 else if (x
<> nx
) or (y
<> ny
) then
407 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
408 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
);
410 monsGrid
.moveBody(mProxyId
, nx
, ny
);
414 exit
; // nothing to do
416 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
417 monsGrid
.getBodyXY(mProxyId
, x
, y
);
418 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
);
424 // ////////////////////////////////////////////////////////////////////////// //
434 MONSTER_SIGNATURE
= $534E4F4D; // 'MONS'
436 // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ:
437 ANIMTABLE
: Array [ANIM_SLEEP
..ANIM_PAIN
] of
441 end = ((name
: 'SLEEP'; loop
: True),
442 (name
: 'GO'; loop
: True),
443 (name
: 'DIE'; loop
: False),
444 (name
: 'MESS'; loop
: False),
445 (name
: 'ATTACK'; loop
: False),
446 (name
: 'ATTACK2'; loop
: False),
447 (name
: 'PAIN'; loop
: False));
449 // Òàáëèöà õàðàêòåðèñòèê ìîíñòðîâ:
450 MONSTERTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
460 ((Name
:'DEMON'; Rect
:(X
:7; Y
:8; Width
:50; Height
:52); Health
:60;
461 RunVel
: 7; MinPain
: 10; Pain
: 20; Jump
: 10),
463 (Name
:'IMP'; Rect
:(X
:15; Y
:10; Width
:34; Height
:50); Health
:25;
464 RunVel
: 3; MinPain
: 0; Pain
: 15; Jump
: 10),
466 (Name
:'ZOMBY'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:15;
467 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
469 (Name
:'SERG'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:20;
470 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
472 (Name
:'CYBER'; Rect
:(X
:24; Y
:9; Width
:80; Height
:110); Health
:500;
473 RunVel
: 5; MinPain
: 50; Pain
: 70; Jump
: 10),
475 (Name
:'CGUN'; Rect
:(X
:15; Y
:4; Width
:34; Height
:56); Health
:60;
476 RunVel
: 3; MinPain
: 10; Pain
: 20; Jump
: 10),
478 (Name
:'BARON'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:150;
479 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
481 (Name
:'KNIGHT'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:75;
482 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
484 (Name
:'CACO'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
485 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
487 (Name
:'SOUL'; Rect
:(X
:16; Y
:14; Width
:32; Height
:36); Health
:60;
488 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
490 (Name
:'PAIN'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
491 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
493 (Name
:'SPIDER'; Rect
:(X
:23; Y
:14; Width
:210; Height
:100); Health
:500;
494 RunVel
: 4; MinPain
: 50; Pain
: 70; Jump
: 10),
496 (Name
:'BSP'; Rect
:(X
:14; Y
:17; Width
:100; Height
:42); Health
:150;
497 RunVel
: 4; MinPain
: 0; Pain
: 20; Jump
: 10),
499 (Name
:'MANCUB'; Rect
:(X
:28; Y
:34; Width
:72; Height
:60); Health
:200;
500 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 7),
502 (Name
:'SKEL'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:200;
503 RunVel
: 6; MinPain
: 20; Pain
: 40; Jump
: 11),
505 (Name
:'VILE'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:150;
506 RunVel
: 7; MinPain
: 10; Pain
: 30; Jump
: 12),
508 (Name
:'FISH'; Rect
:(X
:6; Y
:11; Width
:20; Height
:10); Health
:35;
509 RunVel
: 14; MinPain
: 10; Pain
: 20; Jump
: 6),
511 (Name
:'BARREL'; Rect
:(X
:20; Y
:13; Width
:24; Height
:36); Health
:20;
512 RunVel
: 0; MinPain
: 0; Pain
: 0; Jump
: 0),
514 (Name
:'ROBO'; Rect
:(X
:30; Y
:26; Width
:68; Height
:76); Health
:20;
515 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 6),
517 (Name
:'MAN'; Rect
:(X
:15; Y
:6; Width
:34; Height
:52); Health
:400;
518 RunVel
: 8; MinPain
: 50; Pain
: 70; Jump
: 10));
520 // Òàáëèöà ïàðàìåòðîâ àíèìàöèè ìîíñòðîâ:
521 MONSTER_ANIMTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
524 wX
, wY
: Integer; // Îòêóäà âûëåòèò ïóëÿ
525 AnimSpeed
: Array [ANIM_SLEEP
..ANIM_PAIN
] of Byte;
526 AnimDeltaRight
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
527 AnimDeltaLeft
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
528 end = // SLEEP GO DIE MESS ATTACK ATTACK2 PAIN
529 ((LeftAnim
: False; wX
: 54; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //DEMON
530 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));
531 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))),
533 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //IMP
534 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));
535 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))),
537 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //ZOMBY
538 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));
539 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))),
541 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //SERG
542 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));
543 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))),
545 (LeftAnim
: True; wX
: 70; wY
: 73; AnimSpeed
:(3, 3, 3, 3, 3, 4, 3); //CYBER
546 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));
547 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))),
549 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 1, 0, 4); //CGUN
550 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));
551 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))),
553 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //BARON
554 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));
555 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))),
557 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //KNIGHT
558 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));
559 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))),
561 (LeftAnim
: False; wX
: 88; wY
: 69; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //CACO
562 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));
563 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))),
565 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //SOUL
566 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));
567 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))),
569 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //PAIN
570 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));
571 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))),
573 (LeftAnim
: True; wX
: 128; wY
: 64; AnimSpeed
:(3, 2, 4, 4, 1, 0, 4); //SPIDER
574 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));
575 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))),
577 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //BSP
578 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));
579 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))),
581 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 2, 4, 2, 0, 4); //MANCUB
582 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));
583 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))),
585 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //SKEL
586 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));
587 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))),
589 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //VILE
590 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));
591 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))),
593 (LeftAnim
: False; wX
: 8; wY
: 8; AnimSpeed
:(2, 2, 2, 2, 3, 0, 1); //FISH
594 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));
595 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 ))),
597 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 0, 3, 0, 0, 0, 5); //BARREL
598 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));
599 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))),
601 (LeftAnim
: False; wX
: 95; wY
: 57; AnimSpeed
:(1, 2, 1, 0, 1, 1, 0); //ROBO
602 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));
603 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))),
605 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 2, 0, 5); //MAN
606 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));
607 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))) );
609 MAX_ATM
= 89; // Âðåìÿ îæèäàíèÿ ïîñëå ïîòåðè öåëè
610 MAX_SOUL
= 512; // Îãðàíè÷åíèå Lost_Soul'îâ
613 // ////////////////////////////////////////////////////////////////////////// //
615 gMonsters
: array of TMonster
;
616 uidMap
: array [0..65535] of TMonster
; // monster knows it's index
617 freeInds
: TIdPool
= nil;
620 procedure clearUidMap ();
624 for idx
:= 0 to High(uidMap
) do uidMap
[idx
] := nil;
629 function g_Mons_getNewTrapFrameId (): DWord
; inline;
633 Inc(monCheckTrapLastFrameId
);
634 if (monCheckTrapLastFrameId
= 0) then
637 monCheckTrapLastFrameId
:= 1;
638 for f
:= 0 to High(gMonsters
) do
640 if (gMonsters
[f
] <> nil) then gMonsters
[f
].trapCheckFrameId
:= 0;
643 result
:= monCheckTrapLastFrameId
;
647 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
651 Inc(monCheckMPlatLastFrameId
);
652 if (monCheckMPlatLastFrameId
= 0) then
655 monCheckMPlatLastFrameId
:= 1;
656 for f
:= 0 to High(gMonsters
) do
658 if (gMonsters
[f
] <> nil) then gMonsters
[f
].mplatCheckFrameId
:= 0;
661 result
:= monCheckMPlatLastFrameId
;
670 soulcount
: Integer = 0;
673 function allocMonster (): DWORD
;
677 result
:= freeInds
.alloc();
678 if (result
> High(gMonsters
)) then
680 olen
:= Length(gMonsters
);
681 SetLength(gMonsters
, result
+64);
682 for f
:= olen
to High(gMonsters
) do gMonsters
[f
] := nil;
687 function IsFriend(a
, b
: Byte): Boolean;
691 // Áî÷êà - âñåì äðóã:
692 if (a
= MONSTER_BARREL
) or (b
= MONSTER_BARREL
) then
695 // Ìîíñòðû îäíîãî âèäà:
698 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
699 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
700 Exit
; // Ýòè íå áüþò ñâîèõ
703 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
704 if (a
= MONSTER_SOUL
) and (b
= MONSTER_PAIN
) then
706 // Pain_Elemental íå ìîæåò ðàíèòü Lost_Soul'à:
707 if (b
= MONSTER_SOUL
) and (a
= MONSTER_PAIN
) then
710 //  îñòàëüíûõ ñëó÷àÿõ - áóäóò áèòü äðóã äðóãà:
715 function BehaviourDamage(SpawnerUID
: Word; BH
, SelfType
: Byte): Boolean;
718 UIDType
, MonsterType
: Byte;
723 UIDType
:= g_GetUIDType(SpawnerUID
);
724 if UIDType
= UID_MONSTER
then
726 m
:= g_Monsters_ByUID(SpawnerUID
);
727 if m
= nil then Exit
;
728 MonsterType
:= m
.FMonsterType
;
732 BH_NORMAL
: Result
:= (UIDType
= UID_PLAYER
) or
733 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
735 BH_KILLER
: Result
:= UIDType
= UID_PLAYER
;
736 BH_MANIAC
: Result
:= (UIDType
= UID_PLAYER
) or
737 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
739 BH_INSANE
: Result
:= (UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
));
740 BH_CANNIBAL
: Result
:= (UIDType
= UID_MONSTER
) and (MonsterType
= SelfType
);
745 function canShoot(m
: Byte): Boolean;
750 MONSTER_DEMON
, MONSTER_FISH
, MONSTER_BARREL
:
758 function isCorpse (o
: PObj
; immediately
: Boolean): Integer;
760 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
762 atag
:= atag
; // shut up, fpc!
763 result
:= false; // don't stop
764 if (mon
.FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @mon
.FObj
) then
766 case mon
.FMonsterType
of // Íå âîñêðåñèòü:
767 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
768 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: exit
;
770 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
781 // Åñëè íóæíà âåðîÿòíîñòü
782 if not immediately
and (Random(8) <> 0) then exit
;
784 // Èùåì ìåðòâûõ ìîíñòðîâ ïîáëèçîñòè
785 if gmon_debug_use_sqaccel
then
787 mon
:= monsGrid
.forEachInAABB(o
.X
+o
.Rect
.X
, o
.Y
+o
.Rect
.Y
, o
.Rect
.Width
, o
.Rect
.Height
, monsCollCheck
);
788 if (mon
<> nil) then result
:= mon
.mArrIdx
;
792 for a
:= 0 to High(gMonsters
) do
794 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @gMonsters
[a
].FObj
) then
796 case gMonsters
[a
].FMonsterType
of // Íå âîñêðåñèòü:
797 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
798 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: Continue
;
799 else // Îñòàëüíûõ ìîæíî âîñêðåñèòü
810 procedure g_Monsters_LoadData();
812 e_WriteLog('Loading monsters data...', TMsgType
.Notify
);
814 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 0%', 0, False);
815 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD
+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
816 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD
+':MTEXTURES\BARREL_DIE', 64, 64, 4);
817 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD
+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
818 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD
+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
819 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD
+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
820 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD
+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
821 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 5%', 0, True);
822 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD
+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
823 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD
+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
824 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD
+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
825 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD
+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
826 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD
+':MTEXTURES\SERG_GO', 64, 64, 4);
827 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD
+':MTEXTURES\SERG_DIE', 64, 64, 5);
828 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 10%', 0, True);
829 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD
+':MTEXTURES\SERG_MESS', 64, 64, 9);
830 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD
+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
831 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD
+':MTEXTURES\SERG_PAIN', 64, 64, 1);
832 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD
+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
833 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD
+':MTEXTURES\MAN_GO', 64, 64, 4);
834 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD
+':MTEXTURES\MAN_DIE', 64, 64, 7);
835 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 15%', 0, True);
836 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD
+':MTEXTURES\MAN_MESS', 64, 64, 9);
837 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD
+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
838 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD
+':MTEXTURES\MAN_PAIN', 64, 64, 1);
839 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD
+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
840 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD
+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
841 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD
+':MTEXTURES\CGUN_GO', 64, 64, 4);
842 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 20%', 0, True);
843 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD
+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
844 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD
+':MTEXTURES\CGUN_DIE', 64, 64, 7);
845 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD
+':MTEXTURES\CGUN_MESS', 64, 64, 6);
846 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD
+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
847 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD
+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
848 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD
+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
849 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 25%', 0, True);
850 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD
+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
851 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD
+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
852 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD
+':MTEXTURES\IMP_GO', 64, 64, 4);
853 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD
+':MTEXTURES\IMP_DIE', 64, 64, 5);
854 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD
+':MTEXTURES\IMP_MESS', 64, 64, 8);
855 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD
+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
856 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 30%', 0, True);
857 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD
+':MTEXTURES\IMP_PAIN', 64, 64, 1);
858 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD
+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
859 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD
+':MTEXTURES\DEMON_GO', 64, 64, 4);
860 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD
+':MTEXTURES\DEMON_DIE', 64, 64, 6);
861 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD
+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
862 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD
+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
863 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 35%', 0, True);
864 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD
+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
865 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD
+':MTEXTURES\SOUL_GO', 64, 64, 2);
866 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD
+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
867 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD
+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
868 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD
+':MTEXTURES\SOUL_DIE', 128, 128, 7);
869 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD
+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
870 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 40%', 0, True);
871 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD
+':MTEXTURES\FISH_GO', 32, 32, 4);
872 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD
+':MTEXTURES\FISH_PAIN', 32, 32, 3);
873 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD
+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
874 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD
+':MTEXTURES\FISH_DIE', 32, 32, 1);
875 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD
+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
876 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD
+':MTEXTURES\SPIDER_GO', 256, 128, 6);
877 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 45%', 0, True);
878 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD
+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
879 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD
+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
880 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD
+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
881 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD
+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
882 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD
+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
883 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD
+':MTEXTURES\BSP_GO', 128, 64, 6);
884 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 50%', 0, True);
885 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD
+':MTEXTURES\BSP_PAIN', 128, 64, 1);
886 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD
+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
887 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD
+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
888 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD
+':MTEXTURES\BSP_DIE', 128, 64, 7);
889 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD
+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
890 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD
+':MTEXTURES\CACO_GO', 128, 128, 1);
891 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 55%', 0, True);
892 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD
+':MTEXTURES\CACO_PAIN', 128, 128, 1);
893 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD
+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
894 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD
+':MTEXTURES\CACO_DIE', 128, 128, 7);
895 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD
+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
896 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD
+':MTEXTURES\PAIN_GO', 128, 128, 4);
897 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD
+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
898 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 60%', 0, True);
899 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD
+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
900 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD
+':MTEXTURES\PAIN_DIE', 128, 128, 7);
901 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD
+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
902 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD
+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
903 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD
+':MTEXTURES\BARON_GO', 128, 128, 4);
904 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD
+':MTEXTURES\BARON_PAIN', 128, 128, 1);
905 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 65%', 0, True);
906 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD
+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
907 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD
+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
908 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD
+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
909 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD
+':MTEXTURES\BARON_DIE', 128, 128, 7);
910 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD
+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
911 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD
+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
912 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 70%', 0, True);
913 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD
+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
914 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD
+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
915 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD
+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
916 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD
+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
917 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD
+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
918 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD
+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
919 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 75%', 0, True);
920 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD
+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
921 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD
+':MTEXTURES\MANCUB_GO', 128, 128, 6);
922 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD
+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
923 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD
+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
924 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD
+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
925 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD
+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
926 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 80%', 0, True);
927 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD
+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
928 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD
+':MTEXTURES\SKEL_GO', 128, 128, 6);
929 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD
+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
930 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD
+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
931 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD
+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
932 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD
+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
933 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 85%', 0, True);
934 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD
+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
935 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD
+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
936 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD
+':MTEXTURES\SKEL_DIE', 128, 128, 5);
937 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD
+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
938 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD
+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
939 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD
+':MTEXTURES\VILE_GO', 128, 128, 6);
940 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 90%', 0, True);
941 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD
+':MTEXTURES\VILE_PAIN', 128, 128, 1);
942 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD
+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
943 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD
+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
944 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD
+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
945 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD
+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
946 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD
+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
947 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 95%', 0, True);
948 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD
+':MTEXTURES\VILE_DIE', 128, 128, 9);
949 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD
+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
950 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD
+':MTEXTURES\ROBO_GO', 128, 128, 12);
951 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD
+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
952 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD
+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
953 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD
+':MTEXTURES\ROBO_DIE', 128, 128, 1);
954 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 100%', 0, True);
955 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD
+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
956 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD
+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
957 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD
+':MTEXTURES\CYBER_GO', 128, 128, 4);
958 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD
+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
959 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD
+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
960 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD
+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
961 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD
+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
962 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD
+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD
+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
964 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD
+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
965 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD
+':MTEXTURES\CYBER_DIE', 128, 128, 9);
967 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_SOUNDS
], 0, False);
969 g_Sound_CreateWADEx('SOUND_MONSTER_BARREL_DIE', GameWAD
+':MSOUNDS\BARREL_DIE');
971 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN', GameWAD
+':MSOUNDS\PAIN');
972 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN2', GameWAD
+':MSOUNDS\PAIN2');
973 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION', GameWAD
+':MSOUNDS\ACTION');
974 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION2', GameWAD
+':MSOUNDS\ACTION2');
975 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_1', GameWAD
+':MSOUNDS\ALERT_1');
976 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_2', GameWAD
+':MSOUNDS\ALERT_2');
977 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_3', GameWAD
+':MSOUNDS\ALERT_3');
978 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_1', GameWAD
+':MSOUNDS\DIE_1');
979 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_2', GameWAD
+':MSOUNDS\DIE_2');
980 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_3', GameWAD
+':MSOUNDS\DIE_3');
981 g_Sound_CreateWADEx('SOUND_MONSTER_SLOP', GameWAD
+':MSOUNDS\SLOP');
983 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ATTACK', GameWAD
+':MSOUNDS\DEMON_ATTACK');
984 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ALERT', GameWAD
+':MSOUNDS\DEMON_ALERT');
985 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_DIE', GameWAD
+':MSOUNDS\DEMON_DIE');
987 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_1', GameWAD
+':MSOUNDS\IMP_ALERT_1');
988 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_2', GameWAD
+':MSOUNDS\IMP_ALERT_2');
989 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_1', GameWAD
+':MSOUNDS\IMP_DIE_1');
990 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_2', GameWAD
+':MSOUNDS\IMP_DIE_2');
991 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ACTION', GameWAD
+':MSOUNDS\IMP_ACTION');
992 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ATTACK', GameWAD
+':MSOUNDS\IMP_ATTACK');
994 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_PAIN', GameWAD
+':MSOUNDS\MAN_PAIN');
995 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_ALERT', GameWAD
+':MSOUNDS\MAN_ALERT');
996 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_DIE', GameWAD
+':MSOUNDS\MAN_DIE');
997 g_Sound_CreateWADEx('SOUND_MONSTER_HAHA', GameWAD
+':MSOUNDS\HAHA');
998 g_Sound_CreateWADEx('SOUND_MONSTER_TRUP', GameWAD
+':MSOUNDS\TRUP');
1000 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_ATTACK', GameWAD
+':MSOUNDS\SOUL_ATTACK');
1001 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_DIE', GameWAD
+':MSOUNDS\SOUL_DIE');
1003 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ACTION', GameWAD
+':MSOUNDS\BSP_ACTION');
1004 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_DIE', GameWAD
+':MSOUNDS\BSP_DIE');
1005 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ALERT', GameWAD
+':MSOUNDS\BSP_ALERT');
1006 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_WALK', GameWAD
+':MSOUNDS\BSP_WALK');
1008 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ACTION', GameWAD
+':MSOUNDS\VILE_ACTION');
1009 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_PAIN', GameWAD
+':MSOUNDS\VILE_PAIN');
1010 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_DIE', GameWAD
+':MSOUNDS\VILE_DIE');
1011 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ALERT', GameWAD
+':MSOUNDS\VILE_ALERT');
1012 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ATTACK', GameWAD
+':MSOUNDS\VILE_ATTACK');
1014 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ACTION', GameWAD
+':MSOUNDS\SKEL_ACTION');
1015 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_DIE', GameWAD
+':MSOUNDS\SKEL_DIE');
1016 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ALERT', GameWAD
+':MSOUNDS\SKEL_ALERT');
1017 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ATTACK', GameWAD
+':MSOUNDS\SKEL_ATTACK');
1018 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_HIT', GameWAD
+':MSOUNDS\SKEL_HIT');
1020 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_PAIN', GameWAD
+':MSOUNDS\MANCUB_PAIN');
1021 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_DIE', GameWAD
+':MSOUNDS\MANCUB_DIE');
1022 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ALERT', GameWAD
+':MSOUNDS\MANCUB_ALERT');
1023 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ATTACK', GameWAD
+':MSOUNDS\MANCUB_ATTACK');
1025 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_PAIN', GameWAD
+':MSOUNDS\PAIN_PAIN');
1026 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_DIE', GameWAD
+':MSOUNDS\PAIN_DIE');
1027 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_ALERT', GameWAD
+':MSOUNDS\PAIN_ALERT');
1029 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_DIE', GameWAD
+':MSOUNDS\BARON_DIE');
1030 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_ALERT', GameWAD
+':MSOUNDS\BARON_ALERT');
1032 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_DIE', GameWAD
+':MSOUNDS\CACO_DIE');
1033 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_ALERT', GameWAD
+':MSOUNDS\CACO_ALERT');
1035 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_DIE', GameWAD
+':MSOUNDS\CYBER_DIE');
1036 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_ALERT', GameWAD
+':MSOUNDS\CYBER_ALERT');
1037 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_WALK', GameWAD
+':MSOUNDS\CYBER_WALK');
1039 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_DIE', GameWAD
+':MSOUNDS\KNIGHT_DIE');
1040 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_ALERT', GameWAD
+':MSOUNDS\KNIGHT_ALERT');
1042 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_DIE', GameWAD
+':MSOUNDS\SPIDER_DIE');
1043 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_ALERT', GameWAD
+':MSOUNDS\SPIDER_ALERT');
1044 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_WALK', GameWAD
+':MSOUNDS\SPIDER_WALK');
1046 g_Sound_CreateWADEx('SOUND_MONSTER_FISH_ATTACK', GameWAD
+':MSOUNDS\FISH_ATTACK');
1048 freeInds
:= TIdPool
.Create();
1050 monCheckTrapLastFrameId
:= 0;
1051 monCheckMPlatLastFrameId
:= 0;
1054 procedure g_Monsters_FreeData();
1056 e_WriteLog('Releasing monsters data...', TMsgType
.Notify
);
1058 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
1059 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
1060 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
1061 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
1062 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
1063 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
1064 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
1065 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
1066 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
1067 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
1068 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
1069 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
1070 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
1071 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
1072 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
1073 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
1074 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
1075 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
1076 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
1077 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
1078 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
1079 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
1080 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
1081 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
1082 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
1083 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
1084 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
1085 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
1086 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
1087 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
1088 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
1089 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
1090 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
1091 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
1092 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
1093 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
1094 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
1095 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
1096 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
1097 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
1098 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
1099 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
1100 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
1101 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
1102 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
1103 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
1104 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
1105 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
1106 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
1107 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
1108 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
1109 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
1110 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
1111 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
1112 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
1113 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
1114 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
1115 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
1116 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
1117 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
1118 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
1119 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
1120 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
1121 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
1122 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
1123 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
1124 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
1125 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
1126 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
1127 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
1128 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
1129 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
1130 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
1131 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
1132 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
1133 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
1134 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
1135 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
1136 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
1137 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
1138 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
1139 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
1140 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
1141 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
1142 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
1143 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
1144 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
1145 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
1146 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
1147 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
1148 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
1149 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
1150 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
1151 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
1152 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
1153 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
1154 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
1155 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
1156 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
1157 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
1158 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
1159 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
1160 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
1161 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
1162 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
1163 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
1164 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
1165 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
1166 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
1167 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
1168 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
1169 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
1170 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
1171 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
1172 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
1173 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
1174 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
1175 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
1176 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
1177 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
1178 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
1179 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
1180 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
1181 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
1182 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
1183 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
1184 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
1185 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
1186 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
1187 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
1188 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
1190 g_Sound_Delete('SOUND_MONSTER_BARREL_DIE');
1192 g_Sound_Delete('SOUND_MONSTER_PAIN');
1193 g_Sound_Delete('SOUND_MONSTER_PAIN2');
1194 g_Sound_Delete('SOUND_MONSTER_ACTION');
1195 g_Sound_Delete('SOUND_MONSTER_ACTION2');
1196 g_Sound_Delete('SOUND_MONSTER_ALERT_1');
1197 g_Sound_Delete('SOUND_MONSTER_ALERT_2');
1198 g_Sound_Delete('SOUND_MONSTER_ALERT_3');
1199 g_Sound_Delete('SOUND_MONSTER_DIE_1');
1200 g_Sound_Delete('SOUND_MONSTER_DIE_2');
1201 g_Sound_Delete('SOUND_MONSTER_DIE_3');
1202 g_Sound_Delete('SOUND_MONSTER_SLOP');
1204 g_Sound_Delete('SOUND_MONSTER_DEMON_ATTACK');
1205 g_Sound_Delete('SOUND_MONSTER_DEMON_ALERT');
1206 g_Sound_Delete('SOUND_MONSTER_DEMON_DIE');
1208 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_1');
1209 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_2');
1210 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_1');
1211 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_2');
1212 g_Sound_Delete('SOUND_MONSTER_IMP_ACTION');
1213 g_Sound_Delete('SOUND_MONSTER_IMP_ATTACK');
1215 g_Sound_Delete('SOUND_MONSTER_MAN_PAIN');
1216 g_Sound_Delete('SOUND_MONSTER_MAN_ALERT');
1217 g_Sound_Delete('SOUND_MONSTER_MAN_DIE');
1218 g_Sound_Delete('SOUND_MONSTER_HAHA');
1219 g_Sound_Delete('SOUND_MONSTER_TRUP');
1221 g_Sound_Delete('SOUND_MONSTER_SOUL_ATTACK');
1222 g_Sound_Delete('SOUND_MONSTER_SOUL_DIE');
1224 g_Sound_Delete('SOUND_MONSTER_BSP_ACTION');
1225 g_Sound_Delete('SOUND_MONSTER_BSP_DIE');
1226 g_Sound_Delete('SOUND_MONSTER_BSP_ALERT');
1227 g_Sound_Delete('SOUND_MONSTER_BSP_WALK');
1229 g_Sound_Delete('SOUND_MONSTER_VILE_ACTION');
1230 g_Sound_Delete('SOUND_MONSTER_VILE_PAIN');
1231 g_Sound_Delete('SOUND_MONSTER_VILE_DIE');
1232 g_Sound_Delete('SOUND_MONSTER_VILE_ALERT');
1233 g_Sound_Delete('SOUND_MONSTER_VILE_ATTACK');
1235 g_Sound_Delete('SOUND_MONSTER_SKEL_ACTION');
1236 g_Sound_Delete('SOUND_MONSTER_SKEL_DIE');
1237 g_Sound_Delete('SOUND_MONSTER_SKEL_ALERT');
1238 g_Sound_Delete('SOUND_MONSTER_SKEL_ATTACK');
1239 g_Sound_Delete('SOUND_MONSTER_SKEL_HIT');
1241 g_Sound_Delete('SOUND_MONSTER_MANCUB_PAIN');
1242 g_Sound_Delete('SOUND_MONSTER_MANCUB_DIE');
1243 g_Sound_Delete('SOUND_MONSTER_MANCUB_ALERT');
1244 g_Sound_Delete('SOUND_MONSTER_MANCUB_ATTACK');
1246 g_Sound_Delete('SOUND_MONSTER_PAIN_PAIN');
1247 g_Sound_Delete('SOUND_MONSTER_PAIN_DIE');
1248 g_Sound_Delete('SOUND_MONSTER_PAIN_ALERT');
1250 g_Sound_Delete('SOUND_MONSTER_BARON_DIE');
1251 g_Sound_Delete('SOUND_MONSTER_BARON_ALERT');
1253 g_Sound_Delete('SOUND_MONSTER_CACO_DIE');
1254 g_Sound_Delete('SOUND_MONSTER_CACO_ALERT');
1256 g_Sound_Delete('SOUND_MONSTER_CYBER_DIE');
1257 g_Sound_Delete('SOUND_MONSTER_CYBER_ALERT');
1258 g_Sound_Delete('SOUND_MONSTER_CYBER_WALK');
1260 g_Sound_Delete('SOUND_MONSTER_KNIGHT_DIE');
1261 g_Sound_Delete('SOUND_MONSTER_KNIGHT_ALERT');
1263 g_Sound_Delete('SOUND_MONSTER_SPIDER_DIE');
1264 g_Sound_Delete('SOUND_MONSTER_SPIDER_ALERT');
1265 g_Sound_Delete('SOUND_MONSTER_SPIDER_WALK');
1267 g_Sound_Delete('SOUND_MONSTER_FISH_ATTACK');
1273 procedure g_Monsters_Init();
1278 procedure g_Monsters_Free (clearGrid
: Boolean=true);
1282 e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid
]);
1288 for a
:= 0 to High(gMonsters
) do gMonsters
[a
].Free();
1291 monCheckTrapLastFrameId
:= 0;
1292 monCheckMPlatLastFrameId
:= 0;
1296 // will be called from map loader
1297 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
1300 monsGrid
:= TMonsterGrid
.Create(x
, y
, w
, h
);
1301 //clearUidMap(); // why not?
1302 e_LogWritefln('%s', ['Recreated monster tree']);
1306 function g_Monsters_Create(MonsterType
: Byte; X
, Y
: Integer;
1307 Direction
: TDirection
; AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
1314 // Íåò òàêîãî ìîíñòðà
1315 if (MonsterType
> MONSTER_MAN
) or (MonsterType
= 0) then exit
;
1317 // Ñîáëþäàåì îãðàíè÷åíèå Lost_Soul'îâ
1318 if MonsterType
= MONSTER_SOUL
then
1320 if soulcount
> MAX_SOUL
then exit
;
1321 soulcount
:= soulcount
+ 1;
1324 find_id
:= allocMonster();
1326 mon
:= TMonster
.Create(MonsterType
, find_id
, ForcedUID
);
1327 gMonsters
[find_id
] := mon
;
1328 mon
.mArrIdx
:= find_id
;
1331 uidMap
[mon
.FUID
] := mon
;
1333 // Íàñòðàèâàåì ïîëîæåíèå
1338 FObj
.X
:= X
-FObj
.Rect
.X
- (FObj
.Rect
.Width
div 2);
1339 FObj
.Y
:= Y
-FObj
.Rect
.Y
- FObj
.Rect
.Height
;
1343 FObj
.X
:= X
-FObj
.Rect
.X
;
1344 FObj
.Y
:= Y
-FObj
.Rect
.Y
;
1347 FDirection
:= Direction
;
1348 FStartDirection
:= Direction
;
1353 mon
.positionChanged();
1358 procedure g_Monsters_killedp();
1362 if gMonsters
= nil then
1365 // Ïðèêîëèñò ñìååòñÿ íàä ñìåðòüþ èãðîêà:
1366 h
:= High(gMonsters
);
1369 if (gMonsters
[a
] <> nil) then
1371 with gMonsters
[a
] do
1373 if (FMonsterType
= MONSTER_MAN
) and
1374 (FState
<> MONSTATE_DEAD
) and
1375 (FState
<> MONSTATE_SLEEP
) and
1376 (FState
<> MONSTATE_DIE
) then
1378 g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj
.X
, FObj
.Y
);
1386 procedure g_Monsters_Update();
1391 if gTime
mod (GAME_TICK
*2) = 0 then
1395 if abs(pt_x
) > 246 then pt_xs
:= -pt_xs
;
1396 if abs(pt_y
) > 100 then pt_ys
:= -pt_ys
;
1399 gMon
:= True; // Äëÿ ðàáîòû BlockMon'à
1401 if gmon_debug_think
or gmon_debug_one_think_step
then
1403 gmon_debug_one_think_step
:= false;
1404 for a
:= 0 to High(gMonsters
) do
1406 if (gMonsters
[a
] = nil) then continue
;
1407 if not gMonsters
[a
].FRemoved
then
1409 if g_Game_IsClient
then
1410 gMonsters
[a
].ClientUpdate()
1412 gMonsters
[a
].Update();
1416 gMonsters
[a
].Free();
1417 gMonsters
[a
] := nil;
1425 procedure g_Monsters_Draw();
1429 if gMonsters
<> nil then
1431 for a
:= 0 to High(gMonsters
) do
1433 if (gMonsters
[a
] <> nil) then gMonsters
[a
].Draw();
1438 procedure g_Monsters_DrawHealth();
1443 if gMonsters
= nil then Exit
;
1444 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1446 for a
:= 0 to High(gMonsters
) do
1448 if gMonsters
[a
] <> nil then
1450 e_TextureFontPrint(gMonsters
[a
].FObj
.X
+ gMonsters
[a
].FObj
.Rect
.X
,
1451 gMonsters
[a
].FObj
.Y
+ gMonsters
[a
].FObj
.Rect
.Y
+ gMonsters
[a
].FObj
.Rect
.Height
- fH
,
1452 IntToStr(gMonsters
[a
].FHealth
), gStdFont
);
1457 function g_Monsters_ByUID (UID
: Word): TMonster
;
1459 result
:= uidMap
[UID
];
1462 procedure g_Monsters_SaveState (st
: TStream
);
1466 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ìîíñòðîâ
1468 for i
:= 0 to High(gMonsters
) do
1470 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then count
+= 1;
1473 // Ñîõðàíÿåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1474 utils
.writeInt(st
, LongInt(pt_x
));
1475 utils
.writeInt(st
, LongInt(pt_xs
));
1476 utils
.writeInt(st
, LongInt(pt_y
));
1477 utils
.writeInt(st
, LongInt(pt_ys
));
1479 // Êîëè÷åñòâî ìîíñòðîâ
1480 utils
.writeInt(st
, LongInt(count
));
1482 if (count
= 0) then exit
;
1484 // Ñîõðàíÿåì ìîíñòðîâ
1485 for i
:= 0 to High(gMonsters
) do
1487 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then
1490 utils
.writeInt(st
, Byte(gMonsters
[i
].MonsterType
));
1491 // Ñîõðàíÿåì äàííûå ìîíñòðà:
1492 gMonsters
[i
].SaveState(st
);
1498 procedure g_Monsters_LoadState (st
: TStream
);
1506 g_Monsters_Free(false);
1508 // Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1509 pt_x
:= utils
.readLongInt(st
);
1510 pt_xs
:= utils
.readLongInt(st
);
1511 pt_y
:= utils
.readLongInt(st
);
1512 pt_ys
:= utils
.readLongInt(st
);
1514 // Êîëè÷åñòâî ìîíñòðîâ
1515 count
:= utils
.readLongInt(st
);
1517 if (count
= 0) then exit
;
1518 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid monster count');
1520 // Çàãðóæàåì ìîíñòðîâ
1521 for a
:= 0 to count
-1 do
1524 b
:= utils
.readByte(st
);
1526 mon
:= g_Monsters_Create(b
, 0, 0, TDirection
.D_LEFT
);
1527 if (mon
= nil) then raise XStreamError
.Create('g_Monsters_LoadState: ID = -1 (can''t create)');
1528 // Çàãðóæàåì äàííûå ìîíñòðà
1534 // ////////////////////////////////////////////////////////////////////////// //
1535 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1538 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1540 result
:= g_Monsters_Create(monType
, x
, y
, dir
);
1545 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1547 result
:= g_Mons_SpawnAt(g_Mons_TypeIdByName(typeName
), x
, y
, dir
);
1552 // ////////////////////////////////////////////////////////////////////////// //
1553 function g_Mons_TypeLo (): Integer; inline; begin result
:= Low(MONSTERTABLE
); end;
1554 function g_Mons_TypeHi (): Integer; inline; begin result
:= High(MONSTERTABLE
); end;
1557 function g_Mons_TypeIdByName (const name
: String): Integer;
1562 while (i
<= MONSTER_MAN
) do
1564 if (CompareText(name
, MONSTERTABLE
[i
].Name
) = 0) then
1573 if (CompareText(name
, 'zombie') = 0) then result
:= MONSTER_ZOMBY
;
1577 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
1579 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1580 result
:= MONSTERTABLE
[monType
].Name
1586 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
1588 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1589 Result
:= KilledByMonster
[monType
]
1595 // ////////////////////////////////////////////////////////////////////////// //
1596 { T M o n s t e r : }
1598 procedure TMonster
.setGameX (v
: Integer); inline; begin FObj
.X
:= v
; positionChanged(); end;
1599 procedure TMonster
.setGameY (v
: Integer); inline; begin FObj
.Y
:= v
; positionChanged(); end;
1601 procedure TMonster
.setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline; begin FObj
.X
:= ax
; FObj
.Y
:= ay
; if callPosChanged
then positionChanged(); end;
1603 procedure TMonster
.moveBy (dx
, dy
: Integer); inline;
1605 if (dx
<> 0) or (dy
<> 0) then
1613 procedure TMonster
.doDamage (v
: Integer);
1615 if (v
<= 0) then exit
;
1616 if (v
> 32767) then v
:= 32767;
1617 Damage(v
, 0, 0, 0, mEDamageType
);
1620 procedure TMonster
.ActionSound();
1622 case FMonsterType
of
1624 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ACTION', FObj
.X
, FObj
.Y
);
1625 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
,
1627 g_Sound_PlayExAt('SOUND_MONSTER_ACTION', FObj
.X
, FObj
.Y
);
1628 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1629 MONSTER_KNIGHT
, MONSTER_PAIN
, MONSTER_DEMON
,
1631 g_Sound_PlayExAt('SOUND_MONSTER_ACTION2', FObj
.X
, FObj
.Y
);
1633 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ACTION', FObj
.X
, FObj
.Y
);
1635 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ACTION', FObj
.X
, FObj
.Y
);
1637 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ACTION', FObj
.X
, FObj
.Y
);
1641 g_Sound_PlayExAt('SOUND_MONSTER_HAHA', FObj
.X
, FObj
.Y
);
1645 procedure TMonster
.PainSound();
1653 case FMonsterType
of
1654 MONSTER_IMP
, MONSTER_ZOMBY
, MONSTER_SERG
,
1655 MONSTER_SKEL
, MONSTER_CGUN
:
1656 g_Sound_PlayExAt('SOUND_MONSTER_PAIN', FObj
.X
, FObj
.Y
);
1657 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1658 MONSTER_KNIGHT
, MONSTER_DEMON
, MONSTER_SPIDER
,
1659 MONSTER_BSP
, MONSTER_CYBER
:
1660 g_Sound_PlayExAt('SOUND_MONSTER_PAIN2', FObj
.X
, FObj
.Y
);
1662 g_Sound_PlayExAt('SOUND_MONSTER_VILE_PAIN', FObj
.X
, FObj
.Y
);
1664 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_PAIN', FObj
.X
, FObj
.Y
);
1666 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_PAIN', FObj
.X
, FObj
.Y
);
1668 g_Sound_PlayExAt('SOUND_MONSTER_MAN_PAIN', FObj
.X
, FObj
.Y
);
1672 procedure TMonster
.DieSound();
1674 case FMonsterType
of
1677 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_1', FObj
.X
, FObj
.Y
);
1678 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_2', FObj
.X
, FObj
.Y
);
1680 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1682 0: g_Sound_PlayExAt('SOUND_MONSTER_DIE_1', FObj
.X
, FObj
.Y
);
1683 1: g_Sound_PlayExAt('SOUND_MONSTER_DIE_2', FObj
.X
, FObj
.Y
);
1684 2: g_Sound_PlayExAt('SOUND_MONSTER_DIE_3', FObj
.X
, FObj
.Y
);
1687 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_DIE', FObj
.X
, FObj
.Y
);
1689 g_Sound_PlayExAt('SOUND_MONSTER_BARREL_DIE', FObj
.X
, FObj
.Y
);
1691 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_DIE', FObj
.X
, FObj
.Y
);
1693 g_Sound_PlayExAt('SOUND_MONSTER_BSP_DIE', FObj
.X
, FObj
.Y
);
1695 g_Sound_PlayExAt('SOUND_MONSTER_VILE_DIE', FObj
.X
, FObj
.Y
);
1697 g_Sound_PlayExAt('SOUND_MONSTER_BARON_DIE', FObj
.X
, FObj
.Y
);
1699 g_Sound_PlayExAt('SOUND_MONSTER_CACO_DIE', FObj
.X
, FObj
.Y
);
1701 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_DIE', FObj
.X
, FObj
.Y
);
1703 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_DIE', FObj
.X
, FObj
.Y
);
1705 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_DIE', FObj
.X
, FObj
.Y
);
1707 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_DIE', FObj
.X
, FObj
.Y
);
1709 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_DIE', FObj
.X
, FObj
.Y
);
1711 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_DIE', FObj
.X
, FObj
.Y
);
1713 g_Sound_PlayExAt('SOUND_MONSTER_MAN_DIE', FObj
.X
, FObj
.Y
);
1717 procedure TMonster
.WakeUpSound();
1719 case FMonsterType
of
1722 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_1', FObj
.X
, FObj
.Y
);
1723 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_2', FObj
.X
, FObj
.Y
);
1725 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1727 0: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_1', FObj
.X
, FObj
.Y
);
1728 1: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_2', FObj
.X
, FObj
.Y
);
1729 2: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_3', FObj
.X
, FObj
.Y
);
1732 g_Sound_PlayExAt('SOUND_MONSTER_MAN_ALERT', FObj
.X
, FObj
.Y
);
1734 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ALERT', FObj
.X
, FObj
.Y
);
1736 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ALERT', FObj
.X
, FObj
.Y
);
1738 g_Sound_PlayExAt('SOUND_MONSTER_BARON_ALERT', FObj
.X
, FObj
.Y
);
1740 g_Sound_PlayExAt('SOUND_MONSTER_CACO_ALERT', FObj
.X
, FObj
.Y
);
1742 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_ALERT', FObj
.X
, FObj
.Y
);
1744 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_ALERT', FObj
.X
, FObj
.Y
);
1746 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ALERT', FObj
.X
, FObj
.Y
);
1748 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_ALERT', FObj
.X
, FObj
.Y
);
1750 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ALERT', FObj
.X
, FObj
.Y
);
1752 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ALERT', FObj
.X
, FObj
.Y
);
1754 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_ALERT', FObj
.X
, FObj
.Y
);
1760 procedure TMonster
.BFGHit();
1762 if FMonsterType
= MONSTER_FISH
then
1765 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1766 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1767 {if g_Game_IsServer and g_Game_IsNet then
1768 MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
1769 FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
1773 function TMonster
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
1775 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1783 function TMonster
.Collide(Panel
: TPanel
): Boolean;
1785 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1790 Panel
.Width
, Panel
.Height
);
1793 function TMonster
.Collide(X
, Y
: Integer): Boolean;
1795 X
:= X
- FObj
.X
- FObj
.Rect
.X
;
1796 Y
:= Y
- FObj
.Y
- FObj
.Rect
.Y
;
1797 Result
:= (x
>= 0) and (x
<= FObj
.Rect
.Width
) and
1798 (y
>= 0) and (y
<= FObj
.Rect
.Height
);
1801 procedure TMonster
.Respawn
;
1807 FDirection
:= FStartDirection
;
1808 {GameX}FObj
.X
:= FStartX
;
1809 {GameY}FObj
.Y
:= FStartY
;
1810 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
1811 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
1816 FDieTriggers
:= nil;
1817 FWaitAttackAnim
:= False;
1818 FChainFire
:= False;
1821 FState
:= MONSTATE_SLEEP
;
1822 FCurAnim
:= ANIM_SLEEP
;
1824 positionChanged(); // this updates spatial accelerators
1826 if g_Game_IsNet
and g_Game_IsServer
then
1828 MH_SEND_MonsterPos(FUID
);
1829 MH_SEND_MonsterState(FUID
);
1833 constructor TMonster
.Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
1836 FramesID
: DWORD
= 0;
1840 if ForcedUID
< 0 then
1841 FUID
:= g_CreateUID(UID_MONSTER
)
1845 FMonsterType
:= MonsterType
;
1849 FState
:= MONSTATE_SLEEP
;
1850 FCurAnim
:= ANIM_SLEEP
;
1851 FHealth
:= MONSTERTABLE
[MonsterType
].Health
;
1852 FMaxHealth
:= FHealth
;
1853 FObj
.Rect
:= MONSTERTABLE
[MonsterType
].Rect
;
1854 FDieTriggers
:= nil;
1855 FSpawnTrigger
:= -1;
1856 FWaitAttackAnim
:= False;
1857 FChainFire
:= False;
1859 FNoRespawn
:= False;
1861 FBehaviour
:= BH_NORMAL
;
1865 mEDamageType
:= HIT_SOME
;
1869 trapCheckFrameId
:= 0;
1870 mplatCheckFrameId
:= 0;
1873 if FMonsterType
in [MONSTER_ROBO
, MONSTER_BARREL
] then
1874 FBloodKind
:= BLOOD_SPARKS
1876 FBloodKind
:= BLOOD_NORMAL
;
1877 if FMonsterType
= MONSTER_CACO
then
1883 else if FMonsterType
in [MONSTER_BARON
, MONSTER_KNIGHT
] then
1896 SetLength(FAnim
, Length(ANIMTABLE
));
1898 for a
:= 0 to High(FAnim
) do
1900 FAnim
[a
, TDirection
.D_LEFT
] := nil;
1901 FAnim
[a
, TDirection
.D_RIGHT
] := nil;
1904 for a
:= ANIM_SLEEP
to ANIM_PAIN
do
1905 if (ANIMTABLE
[a
].name
<> '') and
1906 (MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
] <> 0) then
1908 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1909 '_'+ANIMTABLE
[a
].name
;
1911 res
:= g_Frames_Exists(s
);
1914 res
:= g_Frames_Get(FramesID
, s
);
1916 // Åñëè íåò òàêîé àíèìàöèè, òî ïðîáóåì çàìåíèòü åå íà àíèìàöèþ ñìåðòè:
1919 // Çàìåíÿåì òîëüêî ANIM_MESS íà ANIM_DIE:
1920 if a
<> ANIM_MESS
then
1923 if g_Frames_Get(FramesID
, 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1924 '_'+ANIMTABLE
[ANIM_DIE
].name
) then
1926 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1927 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1928 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1929 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1934 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1935 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1937 // Åñëè åñòü îòäåëüíàÿ ëåâàÿ àíèìàöèÿ - çàãðóæàåì:
1938 if MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
then
1940 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1941 '_'+ANIMTABLE
[a
].name
+'_L';
1942 if g_Frames_Exists(s
) then
1943 g_Frames_Get(FramesID
, s
);
1946 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1947 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1950 // Äëÿ êîëäóíà çàãðóæàåì òàêæå àíèìàöèþ îãíÿ:
1951 if MonsterType
= MONSTER_VILE
then
1953 g_Frames_Get(FramesID
, 'FRAMES_FIRE');
1954 vilefire
:= TAnimation
.Create(FramesID
, True, 2);
1960 function TMonster
.Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
1967 // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
1968 if (FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_REVIVE
) then
1971 // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà:
1972 if (t
= HIT_ELECTRO
) and (FMonsterType
= MONSTER_FISH
) and g_Game_IsServer
then
1975 if Random(2) = 0 then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
1977 SetState(MONSTATE_RUN
);
1981 // Ëîâóøêà óáèâàåò ñðàçó:
1982 if t
= HIT_TRAP
then
1985 // Ðîáîòó óðîíà íåò:
1986 if FMonsterType
= MONSTER_ROBO
then
1990 if g_Game_IsServer
then Dec(FHealth
, aDamage
);
1992 // Óñèëèâàåì áîëü ìîíñòðà îò óðîíà:
1995 FPain
:= FPain
+aDamage
;
1997 // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå:
1998 if FState
<> MONSTATE_PAIN
then
1999 if (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) and
2000 (FMonsterType
<> MONSTER_BARREL
) then
2001 SetState(MONSTATE_PAIN
);
2003 // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè:
2004 if (gBloodCount
> 0) then
2006 c
:= Min(aDamage
, 200);
2007 c
:= c
*gBloodCount
- (aDamage
div 4) + Random(c
div 2);
2009 if (VelX
= 0) and (VelY
= 0) then
2013 HIT_TRAP
, HIT_ACID
, HIT_ELECTRO
, HIT_FLAME
: MakeBloodSimple(c
);
2014 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, VelX
, VelY
);
2018 // Òåïåðü öåëü - óäàðèâøèé, åñëè òîëüêî íå ñàì ñåáÿ:
2019 if (SpawnerUID
<> FUID
) and (BehaviourDamage(SpawnerUID
, FBehaviour
, FMonsterType
)) then
2021 FTargetUID
:= SpawnerUID
;
2025 // Çäîðîâüå çàêîí÷èëîñü:
2026 if FHealth
<= 0 then
2028 // Åñëè ýòî íå áî÷êà è óáèë èãðîê, òî åìó +1:
2029 if (FMonsterType
<> MONSTER_BARREL
) then
2031 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2033 p
:= g_Player_Get(SpawnerUID
);
2034 if (p
<> nil) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2036 p
.MonsterKills
:= p
.MonsterKills
+1;
2037 if gGameSettings
.GameMode
= GM_COOP
then
2038 p
.Frags
:= p
.Frags
+ 1;
2039 // Uncomment this if you want to double-kill monsters
2043 if gLMSRespawn
= LMS_RESPAWN_NONE
then
2045 Inc(gCoopMonstersKilled
);
2046 if g_Game_IsNet
then
2052 case FMonsterType
of
2053 MONSTER_ZOMBY
: c
:= ITEM_AMMO_BULLETS
;
2054 MONSTER_SERG
: c
:= ITEM_WEAPON_SHOTGUN1
;
2055 MONSTER_CGUN
: c
:= ITEM_WEAPON_CHAINGUN
;
2056 MONSTER_MAN
: c
:= ITEM_KEY_RED
;
2063 it
:= g_Items_Create(FObj
.X
+ (FObj
.Rect
.Width
div 2),
2064 FObj
.Y
+ (FObj
.Rect
.Height
div 2),
2066 g_Items_SetDrop(it
); // mark it as monster drop
2067 g_Obj_Push(g_Items_ObjByIdx(it
), (FObj
.Vel
.X
div 2)-3+Random(7),
2068 (FObj
.Vel
.Y
div 2)-Random(4));
2069 //positionChanged(); // this updates spatial accelerators
2070 if g_Game_IsServer
and g_Game_IsNet
then
2071 MH_SEND_ItemSpawn(True, it
);
2074 // Òðóï äàëüøå íå èäåò:
2077 // Ó òðóïà ðàçìåðû ìåíüøå:
2078 if (FMonsterType
<> MONSTER_FISH
) and (FMonsterType
<> MONSTER_PAIN
) then
2080 FObj
.Rect
.Y
:= FObj
.Rect
.Y
+ FObj
.Rect
.Height
-12;
2081 FObj
.Rect
.Height
:= 12;
2085 // Óðîí áûë ñèëüíûì => ñëàáûå - â êàøó:
2086 if (FHealth
<= -30) and
2087 ((FMonsterType
= MONSTER_IMP
) or (FMonsterType
= MONSTER_ZOMBY
) or
2088 (FMonsterType
= MONSTER_SERG
) or (FMonsterType
= MONSTER_CGUN
) or
2089 (FMonsterType
= MONSTER_MAN
)) then
2091 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
2092 SetState(MONSTATE_DIE
, ANIM_MESS
);
2097 SetState(MONSTATE_DIE
);
2100 // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà:
2101 if g_Game_IsServer
then ActivateTriggers();
2106 if FState
= MONSTATE_SLEEP
then
2107 begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì:
2108 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2109 SetState(MONSTATE_GO
);
2112 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2116 function TMonster
.Heal(Value
: Word): Boolean;
2119 if g_Game_IsClient
then
2124 if FHealth
< FMaxHealth
then
2126 IncMax(FHealth
, Value
, FMaxHealth
);
2127 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2132 destructor TMonster
.Destroy();
2136 for a
:= 0 to High(FAnim
) do
2138 FAnim
[a
, TDirection
.D_LEFT
].Free();
2139 FAnim
[a
, TDirection
.D_RIGHT
].Free();
2144 if (mProxyId
<> -1) then
2146 if (monsGrid
<> nil) then
2148 monsGrid
.removeBody(mProxyId
);
2149 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
2150 e_WriteLog(Format('monster #%d:(%u): removed from grid; mProxyid=%d', [mArrIdx
, UID
, mProxyId
]), MSG_NOTIFY
);
2156 if (mArrIdx
<> -1) and (mArrIdx
< Length(gMonsters
)) then
2158 freeInds
.release(mArrIdx
);
2159 gMonsters
[mArrIdx
] := nil;
2163 uidMap
[FUID
] := nil;
2165 inherited Destroy();
2168 procedure TMonster
.Draw();
2174 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType));
2175 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState));
2177 // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
2178 if FMonsterType
= MONSTER_VILE
then
2179 if FState
= MONSTATE_SHOOT
then
2180 if GetPos(FTargetUID
, @o
) then
2181 vilefire
.Draw(o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-32,
2182 o
.Y
+o
.Rect
.Y
+o
.Rect
.Height
-128, TMirrorType
.None
);
2184 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
2186 if (g_dbg_scale
= 1.0) then
2188 if not g_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
,
2189 sX
-128, sY
-128, sWidth
+256, sHeight
+256) then
2193 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
2194 if FState
= MONSTATE_DEAD
then
2195 case FMonsterType
of
2196 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
2199 // Åñòü ÷òî ðèñîâàòü ïðè òåêóùåì ïîâåäåíèè:
2200 if FAnim
[FCurAnim
, FDirection
] <> nil then
2202 // Åñëè íåò ëåâîé àíèìàöèè èëè îíà ñîâïàäàåò ñ ïðàâîé => îòðàæàåì ïðàâóþ:
2203 if (FDirection
= TDirection
.D_LEFT
) and
2204 ((not MONSTER_ANIMTABLE
[FMonsterType
].LeftAnim
) or
2205 (FAnim
[FCurAnim
, TDirection
.D_LEFT
].FramesID
= FAnim
[FCurAnim
, TDirection
.D_RIGHT
].FramesID
)) and
2206 (FMonsterType
<> MONSTER_BARREL
) then
2207 m
:= TMirrorType
.Horizontal
2209 m
:= TMirrorType
.None
;
2211 // Ëåâàÿ àíèìàöèÿ => ìåíÿåì ñìåùåíèå îòíîñèòåëüíî öåíòðà:
2212 if (FDirection
= TDirection
.D_LEFT
) and
2213 (FMonsterType
<> MONSTER_BARREL
) then
2215 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].X
;
2216 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].Y
;
2218 if m
= TMirrorType
.Horizontal
then
2219 begin // Íåò îòäåëüíîé ëåâîé àíèìàöèè
2220 // Ðàññòîÿíèå îò êðàÿ òåêñòóðû äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2221 c
:= (MONSTERTABLE
[FMonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[FMonsterType
].Rect
.Width
;
2222 // Ðàññòîÿíèå îò êðàÿ õèò áîêñà äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2223 dx
:= FAnim
[FCurAnim
, FDirection
].Width
- c
- MONSTERTABLE
[FMonsterType
].Rect
.X
;
2224 // Ò.ê. äâèãàòü òåêñòóðó íóæíî áóäåò â ïðîòèâîïîëîæíîì íàïðàâëåíèè:
2226 // Ýòî çíà÷èò: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
2229 else // Ïðàâàÿ àíèìàöèÿ
2231 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].X
;
2232 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].Y
;
2236 FAnim
[FCurAnim
, FDirection
].Draw(Obj
.X
+dx
, Obj
.Y
+dy
, m
);
2239 if g_debug_Frames
then
2241 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2243 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2244 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2249 procedure TMonster
.MakeBloodSimple(Count
: Word);
2251 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+8,
2252 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2253 Count
div 2, 3, -1, 16, (FObj
.Rect
.Height
*2 div 3),
2254 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2255 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-8,
2256 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2257 Count
div 2, -3, -1, 16, (FObj
.Rect
.Height
*2) div 3,
2258 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2261 procedure TMonster
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
2263 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2264 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2265 Count
, VelX
, VelY
, 16, (FObj
.Rect
.Height
*2) div 3,
2266 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2269 procedure TMonster
.Push(vx
, vy
: Integer);
2271 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
2272 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
2273 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2276 procedure TMonster
.SetState(State
: Byte; ForceAnim
: Byte = 255);
2280 // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul,
2281 // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ:
2282 if (State
= MONSTATE_DIE
) and (MonsterType
= MONSTER_SOUL
) then
2283 soulcount
:= soulcount
-1;
2285 // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü:
2287 MONSTATE_DIE
, MONSTATE_DEAD
, MONSTATE_REVIVE
:
2288 if (State
<> MONSTATE_DEAD
) and (State
<> MONSTATE_REVIVE
) and
2289 (State
<> MONSTATE_GO
) then
2296 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
, ForceAnim
);
2298 // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè:
2300 MONSTATE_SLEEP
: Anim
:= ANIM_SLEEP
;
2301 MONSTATE_PAIN
: Anim
:= ANIM_PAIN
;
2302 MONSTATE_WAIT
: Anim
:= ANIM_SLEEP
;
2303 MONSTATE_CLIMB
, MONSTATE_RUN
, MONSTATE_RUNOUT
, MONSTATE_GO
: Anim
:= ANIM_GO
;
2304 MONSTATE_SHOOT
: Anim
:= ANIM_ATTACK
;
2305 MONSTATE_ATTACK
: Anim
:= ANIM_ATTACK
;
2306 MONSTATE_DIE
: Anim
:= ANIM_DIE
;
2308 begin // íà÷àëè âîñðåøàòüñÿ
2310 FAnim
[Anim
, FDirection
].Revert(True);
2312 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
2313 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
2320 // Íàäî ñìåíèòü àíèìàöèþ íà íåñòàíäàðòíóþ:
2321 if ForceAnim
<> 255 then
2324 // Åñëè àíèìàöèÿ íîâàÿ - ïåðåçàïóñêàåì å¸:
2325 if FCurAnim
<> Anim
then
2326 if FAnim
[Anim
, FDirection
] <> nil then
2328 FAnim
[Anim
, FDirection
].Reset();
2333 function TMonster
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
2340 //  òî÷êå íàçíà÷åíèÿ ñòåíà:
2341 if g_CollideLevel(X
, Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
) then
2343 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
2344 if g_Game_IsServer
and g_Game_IsNet
then
2345 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
2351 // Ýôôåêò òåëåïîðòà â ïîçèöèè ìîíñòðà:
2354 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
2355 TA
:= TAnimation
.Create(FramesID
, False, 6);
2356 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj
.X
, Obj
.Y
);
2357 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2358 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2360 if g_Game_IsServer
and g_Game_IsNet
then
2361 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2362 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 1,
2366 FObj
.X
:= X
- FObj
.Rect
.X
;
2367 FObj
.Y
:= Y
- FObj
.Rect
.Y
;
2371 FDirection
:= TDirection
.D_LEFT
2374 FDirection
:= TDirection
.D_RIGHT
2378 if FDirection
= TDirection
.D_RIGHT
then
2379 FDirection
:= TDirection
.D_LEFT
2381 FDirection
:= TDirection
.D_RIGHT
;
2384 // Ýôôåêò òåëåïîðòà â òî÷êå íàçíà÷åíèÿ:
2385 if not silent
and (TA
<> nil) then
2387 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2388 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2391 if g_Game_IsServer
and g_Game_IsNet
then
2392 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2393 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 0,
2397 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2401 procedure TMonster
.Update();
2403 a
, b
, sx
, sy
, wx
, wy
, oldvelx
: Integer;
2413 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
2414 if FMonsterType
= MONSTER_FISH
then
2415 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
2416 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2419 // Ëåòàþùèå ìîíòñðû:
2420 if ((FMonsterType
= MONSTER_SOUL
) or
2421 (FMonsterType
= MONSTER_PAIN
) or
2422 (FMonsterType
= MONSTER_CACO
)) and
2423 (FState
<> MONSTATE_DIE
) and
2424 (FState
<> MONSTATE_DEAD
) then
2427 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
2428 if gTime
mod (GAME_TICK
*2) <> 0 then
2430 g_Obj_Move(@FObj
, fall
, True, True);
2431 positionChanged(); // this updates spatial accelerators
2435 if FPainTicks
> 0 then
2438 FPainSound
:= False;
2441 st
:= g_Obj_Move(@FObj
, fall
, True, True);
2442 positionChanged(); // this updates spatial accelerators
2444 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
2445 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
2446 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
2449 if alive
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2451 Inc(gCoopMonstersKilled
);
2452 if g_Game_IsNet
then
2459 oldvelx
:= FObj
.Vel
.X
;
2461 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
2462 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
2463 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2465 if FFireTime
> 0 then
2467 if WordBool(st
and MOVE_INWATER
) then
2472 FFireTime
:= FFireTime
- 1;
2473 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2474 if FFirePainTime
= 0 then
2476 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
2477 FFirePainTime
:= 18;
2480 FFirePainTime
:= FFirePainTime
- 1;
2484 // Ìåðòâûé íè÷åãî íå äåëàåò:
2485 if (FState
= MONSTATE_DEAD
) then
2488 // AI ìîíñòðîâ âûêëþ÷åí:
2489 if g_debug_MonsterOff
then
2492 if FState
<> MONSTATE_SLEEP
then
2493 SetState(MONSTATE_SLEEP
);
2496 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
2497 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
2498 case FMonsterType
of
2500 if Random(4) = 0 then
2501 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2502 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2503 MONSTER_ROBO
, MONSTER_BARREL
:
2504 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2505 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2507 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
2508 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
2509 if Random(2) = 0 then
2510 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
2512 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
2516 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
2517 if FMonsterType
= MONSTER_BARREL
then
2519 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
2520 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
2521 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2522 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
2526 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
2527 if FMonsterType
= MONSTER_SOUL
then
2528 if WordBool(st
and MOVE_HITAIR
) then
2529 g_Obj_SetSpeed(@FObj
, 16);
2534 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
2535 if FObj
.Vel
.Y
< 0 then
2536 if WordBool(st
and MOVE_INWATER
) then
2539 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
2540 FTargetTime
:= FTargetTime
+ 1;
2543 if FShellTimer
> -1 then
2544 if FShellTimer
= 0 then
2546 if FShellType
= SHELL_SHELL
then
2547 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2548 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2549 GameVelX
, GameVelY
-2, SHELL_SHELL
)
2550 else if FShellType
= SHELL_DBLSHELL
then
2552 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2553 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2554 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
2555 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2556 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2557 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
2560 end else Dec(FShellTimer
);
2562 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
2564 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
2565 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
2566 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2567 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
2568 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2569 (FObj
.Accel
.Y
= 0) then
2570 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2573 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
2575 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
2576 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
2578 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2579 if gSoundEffectsDF
then PainSound();
2581 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
2584 // Ñíèæàåì áîëü ñî âðåìåíåì:
2587 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
2588 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
2592 SetState(MONSTATE_GO
);
2596 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
2599 FSleep
:= FSleep
+ 1;
2601 // Ïðîñïàëè äîñòàòî÷íî:
2602 if FSleep
>= 18 then
2607 // Íà èãðîêîâ èäóò òîëüêî îáû÷íûå ìîíñòðû, êèëëåðû è ìàíüÿêè
2608 if (FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_KILLER
) or (FBehaviour
= BH_MANIAC
) then
2609 // Åñëè åñòü èãðîê ðÿäîì, ïðîñûïàåìñÿ è èäåì ê íåìó:
2610 if (gPlayers
<> nil) then
2611 for a
:= 0 to High(gPlayers
) do
2612 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
2613 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
2615 if g_Look(@FObj
, @Obj
, FDirection
) then
2617 FTargetUID
:= gPlayers
[a
].UID
;
2620 SetState(MONSTATE_GO
);
2624 // Íà ìîíñòðîâ òÿíåò ìàíüÿêîâ, ïîåõàâøèõ è êàííèáàëîâ
2625 if (FTargetUID
= 0) and ((FBehaviour
= BH_MANIAC
)
2626 or (FBehaviour
= BH_INSANE
) or (FBehaviour
= BH_CANNIBAL
)) then
2627 // Åñëè åñòü ïîäõîäÿùèé ìîíñòð ðÿäîì:
2628 if gMonsters
<> nil then
2629 for a
:= 0 to High(gMonsters
) do
2630 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
2631 (gMonsters
[a
].FUID
<> FUID
) then
2633 // Ìàíüÿêè íàïàäàþò íà âñåõ ìîíñòðîâ, êðîìå äðóçåé
2634 if (FBehaviour
= BH_MANIAC
) and
2635 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2637 // Ïîåõàâøèå òàêæå, íî ìîãóò îáîçëèòüñÿ íà áî÷êó
2638 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
) and
2639 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2641 // Êàííèáàëû íàïàäàþò íà ñåáå ïîäîáíûõ
2642 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
2644 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
2646 FTargetUID
:= gMonsters
[a
].UID
;
2649 SetState(MONSTATE_GO
);
2655 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
2658 FSleep
:= FSleep
- 1;
2660 // Âûæäàëè äîñòàòî÷íî - èäåì:
2662 SetState(MONSTATE_GO
);
2665 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
2667 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2668 if WordBool(st
and MOVE_BLOCK
) then
2672 SetState(MONSTATE_RUNOUT
);
2677 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
2678 if (FMonsterType
= MONSTER_VILE
) then
2679 if isCorpse(@FObj
, False) <> -1 then
2682 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
2687 // Öåëü ïîãèáëà èëè äàâíî æäåì:
2688 if (not GetPos(FTargetUID
, @o
)) or (FTargetTime
> MAX_ATM
) then
2689 if not findNewPrey() then
2690 begin // Íîâûõ öåëåé íåò
2698 o
.Rect
:= _Rect(0, 0, 0, 1);
2700 else // Íîâàÿ öåëü åñòü - áåðåì åå êîîðäèíàòû
2701 GetPos(FTargetUID
, @o
);
2703 // Öåëü î÷åíü áëèçêî - ïèíàåì:
2704 if g_Obj_Collide(@FObj
, @o
) and (FTargetUID
<> 0) then
2707 if (FMonsterType
<> MONSTER_CYBER
) or (Random(2) = 0) then
2714 // Ðàññòîÿíèå äî öåëè:
2715 sx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
2716 sy
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2718 // Ïîâîðà÷èâàåìñÿ â ñòîðîíó öåëè:
2720 FDirection
:= TDirection
.D_RIGHT
2722 FDirection
:= TDirection
.D_LEFT
;
2724 // Åñëè ìîíñòð óìååò ñòðåëÿòü è åñòü ïî êîìó - ñòðåëÿåì:
2725 if canShoot(FMonsterType
) and (FTargetUID
<> 0) then
2726 if Abs(sx
) > Abs(sy
) then // óãîë âûñòðåëà óäîáíûé
2727 if shoot(@o
, False) then
2730 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
2731 if Abs(sx
) < 40 then
2732 if FMonsterType
<> MONSTER_FISH
then
2735 SetState(MONSTATE_RUN
);
2736 if Random(2) = 0 then
2737 FDirection
:= TDirection
.D_LEFT
2739 FDirection
:= TDirection
.D_RIGHT
;
2744 // Óïåðëèñü â ñòåíó:
2745 if WordBool(st
and MOVE_HITWALL
) then
2747 if g_Triggers_PressR(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
,
2748 FObj
.Rect
.Height
, FUID
, ACTIVATE_MONSTERPRESS
) <> nil then
2749 begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå
2751 SetState(MONSTATE_WAIT
);
2756 case FMonsterType
of
2757 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
2759 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2760 (FObj
.Accel
.Y
= 0) then
2761 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
2762 // Ïðûæîê ÷åðåç ñòåíó:
2763 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2764 SetState(MONSTATE_CLIMB
);
2771 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
2772 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
2773 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
2775 if FMonsterType
= MONSTER_FISH
then
2777 if not WordBool(st
and MOVE_INWATER
) then
2778 begin // Ðûáà âíå âîäû:
2779 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2780 begin // "Ñòîèò" òâåðäî
2781 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
2782 if FObj
.Accel
.Y
= 0 then FObj
.Vel
.Y
:= -6;
2783 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
2787 SetState(MONSTATE_PAIN
);
2788 FPain
:= FPain
+ 50;
2792 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2794 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2798 // Ðûáà ïëûâåò ââåðõ:
2799 if FObj
.Vel
.Y
< 0 then
2800 if not g_Obj_CollideWater(@FObj
, 0, -16) then
2802 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
2804 // Ïëàâàåì òóäà-ñþäà:
2805 if Random(2) = 0 then
2806 FDirection
:= TDirection
.D_LEFT
2808 FDirection
:= TDirection
.D_RIGHT
;
2810 SetState(MONSTATE_RUN
);
2814 else // Ëåòàþùèå ìîíñòðû
2816 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2818 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2823 else // "Íàçåìíûå" ìîíñòðû
2825 // Âîçìîæíî, ïèíàåì êóñêè:
2826 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
2828 b
:= Abs(FObj
.Vel
.X
);
2829 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2830 for a
:= 0 to High(gGibs
) do
2832 if gGibs
[a
].alive
and
2833 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2834 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
2837 if FObj
.Vel
.X
< 0 then
2839 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
2843 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
2848 // Áîññû ìîãóò ïèíàòü òðóïû:
2849 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
2850 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
2852 b
:= Abs(FObj
.Vel
.X
);
2853 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2854 for a
:= 0 to High(gCorpses
) do
2855 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
2857 co
:= gCorpses
[a
].Obj
;
2858 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2859 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
2861 if FObj
.Vel
.X
< 0 then
2862 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
2864 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
2867 // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
2869 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2871 if (Random(4) = 0) and (FObj
.Accel
.Y
= 0) then
2872 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2875 FSleep
:= FSleep
+ 1;
2881 if Random(8) = 0 then
2885 // Áåæèì â âûáðàííóþ ñòîðîíó:
2886 if FDirection
= TDirection
.D_RIGHT
then
2887 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2889 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2891 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2892 if WordBool(st
and MOVE_INWATER
) then
2893 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2894 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2895 if FMonsterType
= MONSTER_FISH
then
2899 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
2901 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2902 if WordBool(st
and MOVE_BLOCK
) then
2906 SetState(MONSTATE_RUNOUT
);
2911 FSleep
:= FSleep
- 1;
2913 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
2914 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
2917 SetState(MONSTATE_GO
);
2918 // Ñòåíà - èäåì îáðàòíî:
2919 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2922 if Random(8) = 0 then
2926 // Áåæèì â âûáðàííóþ ñòîðîíó:
2927 if FDirection
= TDirection
.D_RIGHT
then
2928 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2930 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2932 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2933 if WordBool(st
and MOVE_INWATER
) then
2934 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2935 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2936 if FMonsterType
= MONSTER_FISH
then
2940 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
2942 // Âûøëè èç ÁëîêÌîíà:
2943 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
2946 FSleep
:= FSleep
- 1;
2948 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
2949 if FSleep
<= -18 then
2952 SetState(MONSTATE_GO
);
2953 // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî:
2954 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2957 if Random(8) = 0 then
2961 // Áåæèì â âûáðàííóþ ñòîðîíó:
2962 if FDirection
= TDirection
.D_RIGHT
then
2963 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2965 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2967 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2968 if WordBool(st
and MOVE_INWATER
) then
2969 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2970 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2971 if FMonsterType
= MONSTER_FISH
then
2975 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
2977 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
2978 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
2979 (not WordBool(st
and MOVE_HITWALL
)) then
2982 SetState(MONSTATE_GO
);
2984 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
2985 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2989 SetState(MONSTATE_RUN
);
2993 // Áåæèì â âûáðàííóþ ñòîðîíó:
2994 if FDirection
= TDirection
.D_RIGHT
then
2995 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2997 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2999 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3000 if WordBool(st
and MOVE_INWATER
) then
3001 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3002 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3003 if FMonsterType
= MONSTER_FISH
then
3007 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3008 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3010 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3011 if FMonsterType
= MONSTER_SOUL
then
3013 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3014 SetState(MONSTATE_GO
);
3019 // Çàìåäëÿåìñÿ ïðè àòàêå:
3020 if FMonsterType
<> MONSTER_FISH
then
3021 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3023 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3024 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3026 // Öåëü ïîãèáëà => èäåì äàëüøå:
3027 if not GetPos(FTargetUID
, @o
) then
3029 SetState(MONSTATE_GO
);
3034 // Öåëü íå âèäíî => èäåì äàëüøå:
3035 if not g_Look(@FObj
, @o
, FDirection
) then
3037 SetState(MONSTATE_GO
);
3042 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3043 if g_Obj_CollideWater(@o
, 0, 0) then
3045 SetState(MONSTATE_GO
);
3051 tx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2);
3052 ty
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2);
3053 g_Weapon_HitUID(FTargetUID
, 2, FUID
, HIT_SOME
);
3056 end; // case FState of ...
3060 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3061 if FState
= MONSTATE_REVIVE
then
3062 if FAnim
[FCurAnim
, FDirection
].Played
then
3063 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3064 FAnim
[FCurAnim
, FDirection
].Revert(False);
3065 SetState(MONSTATE_GO
);
3068 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3069 if vilefire
<> nil then
3072 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3073 if (FState
= MONSTATE_DIE
) and
3074 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3075 (FAnim
[FCurAnim
, FDirection
].Played
) then
3078 SetState(MONSTATE_DEAD
);
3080 // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à:
3081 if (FMonsterType
= MONSTER_PAIN
) then
3083 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-30,
3084 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_LEFT
);
3087 mon
.SetState(MONSTATE_GO
);
3088 mon
.FNoRespawn
:= True;
3089 Inc(gTotalMonsters
);
3090 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3093 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3094 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_RIGHT
);
3097 mon
.SetState(MONSTATE_GO
);
3098 mon
.FNoRespawn
:= True;
3099 Inc(gTotalMonsters
);
3100 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3103 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-15,
3104 FObj
.Y
+FObj
.Rect
.Y
, TDirection
.D_RIGHT
);
3107 mon
.SetState(MONSTATE_GO
);
3108 mon
.FNoRespawn
:= True;
3109 Inc(gTotalMonsters
);
3110 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3113 if g_Game_IsNet
then MH_SEND_CoopStats();
3116 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3117 if (FMonsterType
= MONSTER_PAIN
) or
3118 (FMonsterType
= MONSTER_SOUL
) or
3119 (FMonsterType
= MONSTER_BARREL
) then
3123 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3124 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3125 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3126 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3127 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3128 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3129 if FState
= MONSTATE_ATTACK
then
3130 begin // Ñîñòîÿíèå - Àòàêà
3131 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3132 if FMonsterType
<> MONSTER_SOUL
then
3133 SetState(MONSTATE_GO
);
3135 else // Ñîñòîÿíèå - Ñòðåëüáà
3137 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3138 if not FChainFire
then
3139 SetState(MONSTATE_GO
)
3141 begin // Íàäî ñòðåëÿòü åùå
3142 FChainFire
:= False;
3143 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3144 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3145 FAnim
[FCurAnim
, FDirection
].Reset();
3149 FWaitAttackAnim
:= False;
3152 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3153 if (FMonsterType
= MONSTER_SOUL
) or
3154 ( (not FWaitAttackAnim
) and
3155 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3156 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3158 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3159 if FState
= MONSTATE_ATTACK
then
3160 begin // Ñîñòîÿíèå - Àòàêà
3161 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3162 if FMonsterType
= MONSTER_SOUL
then
3163 FAnim
[FCurAnim
, FDirection
].Reset();
3165 case FMonsterType
of
3166 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3167 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3168 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3169 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3170 if FMonsterType
= MONSTER_SOUL
then
3171 SetState(MONSTATE_GO
);
3174 // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì:
3175 if g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
) <> 0 then
3176 g_Sound_PlayExAt('SOUND_MONSTER_FISH_ATTACK', FObj
.X
, FObj
.Y
);
3178 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3179 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3180 if FCurAnim
= ANIM_ATTACK2
then
3183 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3184 if g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
) <> 0 then
3185 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_HIT', FObj
.X
, FObj
.Y
);
3189 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3190 if FCurAnim
= ANIM_ATTACK2
then
3192 sx
:= isCorpse(@FObj
, True);
3194 begin // Íàøëè, êîãî âîñêðåñèòü
3195 gMonsters
[sx
].SetState(MONSTATE_REVIVE
);
3196 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3197 // Âîñêðåøàòü - ñåáå âðåäèòü:
3198 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3204 else // Ñîñòîÿíèå - Ñòðåëüáà
3206 // Âû÷èñëÿåì êîîðäèíàòû, îòêóäà âûëåòèò ïóëÿ:
3207 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
;
3209 if FDirection
= TDirection
.D_LEFT
then
3211 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
-(MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2));
3212 wx
:= MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2)-wx
;
3213 end; // Ýòî çíà÷èò: wx := hitX + (hitWidth / 2) - (wx - (hitX + (hitWidth / 2)))
3216 wy
:= FObj
.Y
+ MONSTER_ANIMTABLE
[FMonsterType
].wY
;
3218 // Äåëàåì âûñòðåë íóæíûì îðóæèåì:
3219 case FMonsterType
of
3221 g_Weapon_ball1(wx
, wy
, tx
, ty
, FUID
);
3224 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3225 g_Weapon_gun(wx
, wy
, tx
, ty
, 1, 3, FUID
, True);
3226 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3230 g_Weapon_shotgun(wx
, wy
, tx
, ty
, FUID
);
3231 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3233 FShellType
:= SHELL_SHELL
;
3237 g_Weapon_dshotgun(wx
, wy
, tx
, ty
, FUID
);
3239 FShellType
:= SHELL_DBLSHELL
;
3244 g_Weapon_rocket(wx
, wy
, tx
, ty
, FUID
);
3245 // MH_SEND_MonsterAttack(FUID, wx, wy, tx, ty);
3248 g_Weapon_revf(wx
, wy
, tx
, ty
, FUID
, FTargetUID
);
3251 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3252 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3253 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3257 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3258 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3259 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
3262 g_Weapon_aplasma(wx
, wy
, tx
, ty
, FUID
);
3264 g_Weapon_plasma(wx
, wy
, tx
, ty
, FUID
);
3266 g_Weapon_manfire(wx
, wy
, tx
, ty
, FUID
);
3267 MONSTER_BARON
, MONSTER_KNIGHT
:
3268 g_Weapon_ball7(wx
, wy
, tx
, ty
, FUID
);
3270 g_Weapon_ball2(wx
, wy
, tx
, ty
, FUID
);
3272 begin // Ñîçäàåì Lost_Soul:
3273 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+(FObj
.Rect
.Width
div 2),
3274 FObj
.Y
+FObj
.Rect
.Y
, FDirection
);
3277 begin // Öåëü - öåëü Pain_Elemental'à. Ëåòèì ê íåé:
3278 mon
.FTargetUID
:= FTargetUID
;
3279 GetPos(FTargetUID
, @o
);
3280 mon
.FTargetTime
:= 0;
3281 mon
.FNoRespawn
:= True;
3282 mon
.SetState(MONSTATE_GO
);
3283 mon
.shoot(@o
, True);
3284 Inc(gTotalMonsters
);
3286 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3291 if FMonsterType
<> MONSTER_PAIN
then
3292 if g_Game_IsNet
then
3293 MH_SEND_MonsterShot(FUID
, wx
, wy
, tx
, ty
);
3295 // Ñêîðîñòðåëüíûå ìîíñòðû:
3296 if (FMonsterType
= MONSTER_CGUN
) or
3297 (FMonsterType
= MONSTER_SPIDER
) or
3298 (FMonsterType
= MONSTER_BSP
) or
3299 (FMonsterType
= MONSTER_MANCUB
) or
3300 (FMonsterType
= MONSTER_ROBO
) then
3301 if not GetPos(FTargetUID
, @o
) then
3302 // Öåëü ìåðòâà - èùåì íîâóþ:
3304 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3305 if shoot(@o
, False) then
3309 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3310 FWaitAttackAnim
:= True;
3313 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3314 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3316 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3317 // Çâóêè ïðè ïåðåäâèæåíèè:
3318 case FMonsterType
of
3320 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3321 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3322 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3324 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3325 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3326 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3328 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3329 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3330 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3332 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3333 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3334 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3338 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3339 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3340 FObj
.Vel
.X
:= oldvelx
;
3342 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3343 if FAnim
[FCurAnim
, FDirection
] <> nil then
3344 FAnim
[FCurAnim
, FDirection
].Update();
3347 procedure TMonster
.SetDeadAnim
;
3349 if FAnim
<> nil then
3350 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3353 procedure TMonster
.RevertAnim(R
: Boolean = True);
3355 if FAnim
<> nil then
3356 if FAnim
[FCurAnim
, FDirection
].IsReverse
<> R
then
3357 FAnim
[FCurAnim
, FDirection
].Revert(R
);
3360 function TMonster
.AnimIsReverse
: Boolean;
3362 if FAnim
<> nil then
3363 Result
:= FAnim
[FCurAnim
, FDirection
].IsReverse
3368 procedure TMonster
.ClientUpdate();
3370 a
, b
, sx
, sy
, oldvelx
: Integer;
3377 sx
:= 0; // SHUT UP COMPILER
3380 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
3381 if FMonsterType
= MONSTER_FISH
then
3382 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3383 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
3386 // Ëåòàþùèå ìîíòñðû:
3387 if ((FMonsterType
= MONSTER_SOUL
) or
3388 (FMonsterType
= MONSTER_PAIN
) or
3389 (FMonsterType
= MONSTER_CACO
)) and
3390 (FState
<> MONSTATE_DIE
) and
3391 (FState
<> MONSTATE_DEAD
) then
3394 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
3395 if gTime
mod (GAME_TICK
*2) <> 0 then
3397 g_Obj_Move(@FObj
, fall
, True, True);
3398 positionChanged(); // this updates spatial accelerators
3402 if FPainTicks
> 0 then
3405 FPainSound
:= False;
3408 st
:= g_Obj_Move(@FObj
, fall
, True, True);
3409 positionChanged(); // this updates spatial accelerators
3411 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
3412 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
3413 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
3419 oldvelx
:= FObj
.Vel
.X
;
3421 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
3422 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
3423 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3425 if FFireTime
> 0 then
3427 if WordBool(st
and MOVE_INWATER
) then
3432 FFireTime
:= FFireTime
- 1;
3436 // Ìåðòâûé íè÷åãî íå äåëàåò:
3437 if (FState
= MONSTATE_DEAD
) then
3440 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
3441 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
3442 case FMonsterType
of
3444 if Random(4) = 0 then
3445 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3446 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3447 MONSTER_ROBO
, MONSTER_BARREL
:
3448 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3449 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3451 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
3452 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
3453 if Random(2) = 0 then
3454 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
3456 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
3460 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
3461 if FMonsterType
= MONSTER_BARREL
then
3463 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
3464 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3465 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3466 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
3470 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
3471 if FMonsterType
= MONSTER_SOUL
then
3472 if WordBool(st
and MOVE_HITAIR
) then
3473 g_Obj_SetSpeed(@FObj
, 16);
3478 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
3479 if FObj
.Vel
.Y
< 0 then
3480 if WordBool(st
and MOVE_INWATER
) then
3483 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
3484 FTargetTime
:= FTargetTime
+ 1;
3486 if FShellTimer
> -1 then
3487 if FShellTimer
= 0 then
3489 if FShellType
= SHELL_SHELL
then
3490 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3491 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3492 GameVelX
, GameVelY
-2, SHELL_SHELL
)
3493 else if FShellType
= SHELL_DBLSHELL
then
3495 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3496 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3497 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
3498 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3499 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3500 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
3503 end else Dec(FShellTimer
);
3505 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
3507 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
3508 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
3509 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3510 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
3511 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3512 (FObj
.Accel
.Y
= 0) then
3513 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3516 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
3518 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
3519 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
3521 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
3522 if gSoundEffectsDF
then PainSound();
3524 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
3527 // Ñíèæàåì áîëü ñî âðåìåíåì:
3530 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
3531 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
3533 SetState(MONSTATE_GO
);
3538 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
3541 FSleep
:= FSleep
+ 1;
3543 // Ïðîñïàëè äîñòàòî÷íî:
3544 if FSleep
>= 18 then
3550 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
3553 FSleep
:= FSleep
- 1;
3556 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
3558 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3559 if WordBool(st
and MOVE_BLOCK
) then
3563 SetState(MONSTATE_RUNOUT
);
3568 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
3569 if (FMonsterType
= MONSTER_VILE
) then
3570 if isCorpse(@FObj
, False) <> -1 then
3572 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
3578 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
3579 if Abs(sx
) < 40 then
3580 if FMonsterType
<> MONSTER_FISH
then
3582 SetState(MONSTATE_RUN
);
3588 // Óïåðëèñü â ñòåíó:
3589 if WordBool(st
and MOVE_HITWALL
) then
3591 case FMonsterType
of
3592 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
3594 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3595 (FObj
.Accel
.Y
= 0) then
3596 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
3597 // Ïðûæîê ÷åðåç ñòåíó:
3598 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3599 SetState(MONSTATE_CLIMB
);
3606 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
3607 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
3608 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
3610 if FMonsterType
= MONSTER_FISH
then
3612 if not WordBool(st
and MOVE_INWATER
) then
3613 begin // Ðûáà âíå âîäû:
3614 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
3615 begin // "Ñòîèò" òâåðäî
3616 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
3617 if FObj
.Accel
.Y
= 0 then
3619 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
3623 SetState(MONSTATE_PAIN
);
3624 FPain
:= FPain
+ 50;
3628 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3630 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3634 // Ðûáà ïëûâåò ââåðõ:
3635 if FObj
.Vel
.Y
< 0 then
3636 if not g_Obj_CollideWater(@FObj
, 0, -16) then
3638 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
3640 // Ïëàâàåì òóäà-ñþäà:
3641 SetState(MONSTATE_RUN
);
3646 else // Ëåòàþùèå ìîíñòðû
3648 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3650 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3655 else // "Íàçåìíûå" ìîíñòðû
3657 // Âîçìîæíî, ïèíàåì êóñêè:
3658 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
3660 b
:= Abs(FObj
.Vel
.X
);
3661 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3662 for a
:= 0 to High(gGibs
) do
3664 if gGibs
[a
].alive
and
3665 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3666 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
3669 if FObj
.Vel
.X
< 0 then
3671 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
3675 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
3677 positionChanged(); // this updates spatial accelerators
3681 // Áîññû ìîãóò ïèíàòü òðóïû:
3682 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
3683 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
3685 b
:= Abs(FObj
.Vel
.X
);
3686 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3687 for a
:= 0 to High(gCorpses
) do
3688 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
3690 co
:= gCorpses
[a
].Obj
;
3691 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3692 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
3694 if FObj
.Vel
.X
< 0 then
3695 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
3697 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
3702 FSleep
:= FSleep
+ 1;
3708 if Random(8) = 0 then
3712 // Áåæèì â âûáðàííóþ ñòîðîíó:
3713 if FDirection
= TDirection
.D_RIGHT
then
3714 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3716 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3718 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3719 if WordBool(st
and MOVE_INWATER
) then
3720 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3721 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3722 if FMonsterType
= MONSTER_FISH
then
3726 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
3728 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3729 if WordBool(st
and MOVE_BLOCK
) then
3731 SetState(MONSTATE_RUNOUT
);
3737 FSleep
:= FSleep
- 1;
3739 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
3740 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
3742 SetState(MONSTATE_GO
);
3746 if Random(8) = 0 then
3750 // Áåæèì â âûáðàííóþ ñòîðîíó:
3751 if FDirection
= TDirection
.D_RIGHT
then
3752 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3754 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3756 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3757 if WordBool(st
and MOVE_INWATER
) then
3758 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3759 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3760 if FMonsterType
= MONSTER_FISH
then
3764 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3766 // Âûøëè èç ÁëîêÌîíà:
3767 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3770 FSleep
:= FSleep
- 1;
3772 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3773 if FSleep
<= -18 then
3775 SetState(MONSTATE_GO
);
3779 if Random(8) = 0 then
3783 // Áåæèì â âûáðàííóþ ñòîðîíó:
3784 if FDirection
= TDirection
.D_RIGHT
then
3785 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3787 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3789 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3790 if WordBool(st
and MOVE_INWATER
) then
3791 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3792 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3793 if FMonsterType
= MONSTER_FISH
then
3797 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3799 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3800 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3801 (not WordBool(st
and MOVE_HITWALL
)) then
3803 SetState(MONSTATE_GO
);
3806 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3807 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3809 SetState(MONSTATE_RUN
);
3814 // Áåæèì â âûáðàííóþ ñòîðîíó:
3815 if FDirection
= TDirection
.D_RIGHT
then
3816 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3818 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3820 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3821 if WordBool(st
and MOVE_INWATER
) then
3822 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3823 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3824 if FMonsterType
= MONSTER_FISH
then
3828 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3829 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3831 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3832 if FMonsterType
= MONSTER_SOUL
then
3834 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3835 SetState(MONSTATE_GO
);
3840 // Çàìåäëÿåìñÿ ïðè àòàêå:
3841 if FMonsterType
<> MONSTER_FISH
then
3842 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3844 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3845 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3847 // Öåëü ïîãèáëà => èäåì äàëüøå:
3848 if not GetPos(FTargetUID
, @o
) then
3850 SetState(MONSTATE_GO
);
3855 // Öåëü íå âèäíî => èäåì äàëüøå:
3856 if not g_Look(@FObj
, @o
, FDirection
) then
3858 SetState(MONSTATE_GO
);
3863 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3864 if g_Obj_CollideWater(@o
, 0, 0) then
3866 SetState(MONSTATE_GO
);
3872 end; // case FState of ...
3876 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3877 if FState
= MONSTATE_REVIVE
then
3878 if FAnim
[FCurAnim
, FDirection
].Played
then
3879 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3880 FAnim
[FCurAnim
, FDirection
].Revert(False);
3881 SetState(MONSTATE_GO
);
3884 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3885 if vilefire
<> nil then
3888 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3889 if (FState
= MONSTATE_DIE
) and
3890 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3891 (FAnim
[FCurAnim
, FDirection
].Played
) then
3894 SetState(MONSTATE_DEAD
);
3896 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3897 if (FMonsterType
= MONSTER_PAIN
) or
3898 (FMonsterType
= MONSTER_SOUL
) or
3899 (FMonsterType
= MONSTER_BARREL
) then
3902 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3905 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3906 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3907 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3908 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3909 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3910 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3911 if FState
= MONSTATE_ATTACK
then
3912 begin // Ñîñòîÿíèå - Àòàêà
3913 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3914 if FMonsterType
<> MONSTER_SOUL
then
3915 SetState(MONSTATE_GO
);
3917 else // Ñîñòîÿíèå - Ñòðåëüáà
3919 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3920 if not FChainFire
then
3921 SetState(MONSTATE_GO
)
3923 begin // Íàäî ñòðåëÿòü åùå
3924 FChainFire
:= False;
3925 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3926 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3927 FAnim
[FCurAnim
, FDirection
].Reset();
3931 FWaitAttackAnim
:= False;
3934 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3935 if (FMonsterType
= MONSTER_SOUL
) or
3936 ( (not FWaitAttackAnim
) and
3937 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3938 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3940 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3941 if FState
= MONSTATE_ATTACK
then
3942 begin // Ñîñòîÿíèå - Àòàêà
3943 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3944 if FMonsterType
= MONSTER_SOUL
then
3945 FAnim
[FCurAnim
, FDirection
].Reset();
3947 case FMonsterType
of
3948 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3949 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3950 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3951 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3952 if FMonsterType
= MONSTER_SOUL
then
3953 SetState(MONSTATE_GO
);
3956 g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
);
3958 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3959 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3960 if FCurAnim
= ANIM_ATTACK2
then
3963 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3964 g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
);
3968 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3969 if FCurAnim
= ANIM_ATTACK2
then
3971 sx
:= isCorpse(@FObj
, True);
3973 begin // Íàøëè, êîãî âîñêðåñèòü
3974 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3975 // Âîñêðåøàòü - ñåáå âðåäèòü:
3976 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3982 else // Ñîñòîÿíèå - Ñòðåëüáà
3984 // Ñêîðîñòðåëüíûå ìîíñòðû:
3985 if (FMonsterType
= MONSTER_CGUN
) or
3986 (FMonsterType
= MONSTER_SPIDER
) or
3987 (FMonsterType
= MONSTER_BSP
) or
3988 (FMonsterType
= MONSTER_MANCUB
) or
3989 (FMonsterType
= MONSTER_ROBO
) then
3990 if not GetPos(FTargetUID
, @o
) then
3991 // Öåëü ìåðòâà - èùåì íîâóþ:
3993 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3994 if shoot(@o
, False) then
3998 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3999 FWaitAttackAnim
:= True;
4002 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
4003 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
4005 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
4006 // Çâóêè ïðè ïåðåäâèæåíèè:
4007 case FMonsterType
of
4009 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4010 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4011 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
4013 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4014 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4015 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
4017 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4018 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4019 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4021 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4022 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
4023 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4027 // Êîñòûëü äëÿ ïîòîêîâ
4028 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
4029 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
4030 FObj
.Vel
.X
:= oldvelx
;
4032 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
4033 if FAnim
[FCurAnim
, FDirection
] <> nil then
4034 FAnim
[FCurAnim
, FDirection
].Update();
4037 procedure TMonster
.ClientAttack(wx
, wy
, atx
, aty
: Integer);
4039 case FMonsterType
of
4042 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
4043 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4047 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
4049 FShellType
:= SHELL_SHELL
;
4053 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', wx
, wy
);
4055 FShellType
:= SHELL_DBLSHELL
;
4057 MONSTER_CGUN
, MONSTER_SPIDER
:
4059 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
4060 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4063 g_Weapon_ball1(wx
, wy
, atx
, aty
, FUID
);
4065 g_Weapon_rocket(wx
, wy
, atx
, aty
, FUID
);
4067 g_Weapon_revf(wx
, wy
, atx
, aty
, FUID
, FTargetUID
);
4069 g_Weapon_aplasma(wx
, wy
, atx
, aty
, FUID
);
4071 g_Weapon_plasma(wx
, wy
, atx
, aty
, FUID
);
4073 g_Weapon_manfire(wx
, wy
, atx
, aty
, FUID
);
4074 MONSTER_BARON
, MONSTER_KNIGHT
:
4075 g_Weapon_ball7(wx
, wy
, atx
, aty
, FUID
);
4077 g_Weapon_ball2(wx
, wy
, atx
, aty
, FUID
);
4081 procedure TMonster
.Turn();
4084 if FDirection
= TDirection
.D_LEFT
then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
4086 // Áåæèì â âûáðàííóþ ñòîðîíó:
4087 if FDirection
= TDirection
.D_RIGHT
then
4088 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
4090 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
4093 function TMonster
.findNewPrey(): Boolean;
4097 PlayersSee
, MonstersSee
: Array of DWORD
;
4098 PlayerNear
, MonsterNear
: Integer;
4101 SetLength(MonstersSee
, 0);
4102 SetLength(PlayersSee
, 0);
4109 // Ïîåõàâøèå, êàííèáàëû, è äîáðûå èãðîêîâ íå òðîãàþò
4110 if (gPlayers
<> nil) and (FBehaviour
<> BH_INSANE
) and
4111 (FBehaviour
<> BH_CANNIBAL
) and (FBehaviour
<> BH_GOOD
) then
4112 for a
:= 0 to High(gPlayers
) do
4113 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
4114 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
4116 if g_Look(@FObj
, @gPlayers
[a
].Obj
, FDirection
) then
4118 SetLength(PlayersSee
, Length(PlayersSee
) + 1);
4119 PlayersSee
[High(PlayersSee
)] := a
;
4121 l2
:= Abs(gPlayers
[a
].GameX
-FObj
.X
)+
4122 Abs(gPlayers
[a
].GameY
-FObj
.Y
);
4126 PlayerNear
:= Integer(a
);
4130 // Êèëëåðû è äîáðûå íå òðîãàþò ìîíñòðîâ
4131 if (gMonsters
<> nil) and (FBehaviour
<> BH_KILLER
) and (FBehaviour
<> BH_GOOD
) then
4132 for a
:= 0 to High(gMonsters
) do
4133 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
4134 (gMonsters
[a
].FUID
<> FUID
) then
4136 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
4137 Continue
; // Êàííèáàëû àòàêóþò òîëüêî ñîðîäè÷åé
4138 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
)
4139 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4140 Continue
; // Ïîåõàâøèå íå òðîãàþò äðóçåé, íî èì íå íðàâÿòñÿ áî÷êè
4141 if ((FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_MANIAC
))
4142 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4143 Continue
; // Îñòàâøèåñÿ òèïû, êðîìå êàííèáàëîâ, íå òðîãàþò ñâîèõ äðóçåé
4145 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
4147 SetLength(MonstersSee
, Length(MonstersSee
) + 1);
4148 MonstersSee
[High(MonstersSee
)] := a
;
4150 l2
:= Abs(gMonsters
[a
].FObj
.X
-FObj
.X
)+
4151 Abs(gMonsters
[a
].FObj
.Y
-FObj
.Y
);
4155 MonsterNear
:= Integer(a
);
4160 BH_NORMAL
, BH_KILLER
:
4162 // Îáû÷íûé è êèëëåð ñíà÷àëà èùóò èãðîêîâ â ïîëå çðåíèÿ
4163 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4165 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4166 FTargetUID
:= gPlayers
[a
].UID
;
4169 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4172 FTargetUID
:= gPlayers
[a
].UID
;
4174 // Ïîòîì îáû÷íûå èùóò ìîíñòðîâ â ïîëå çðåíèÿ
4175 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4177 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4178 FTargetUID
:= gMonsters
[a
].UID
;
4181 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4184 FTargetUID
:= gMonsters
[a
].UID
;
4187 BH_MANIAC
, BH_INSANE
, BH_CANNIBAL
:
4189 // Ìàíüÿêè, ïîåõàâøèå è êàííèáàëû ñíà÷àëà èñòðåáëÿþò âñ¸ â ïîëå çðåíèÿ
4190 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4192 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4193 FTargetUID
:= gPlayers
[a
].UID
;
4195 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4197 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4198 FTargetUID
:= gMonsters
[a
].UID
;
4200 // Çàòåì èùóò êîãî-òî ïîáëèçîñòè
4201 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4204 FTargetUID
:= gPlayers
[a
].UID
;
4206 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4209 FTargetUID
:= gMonsters
[a
].UID
;
4214 // Åñëè è ìîíñòðîâ íåò - íà÷èíàåì æäàòü öåëü:
4215 if FTargetUID
= 0 then
4217 // Ïîåõàâøèé ïûòàåòñÿ ñàìîóáèòüñÿ
4218 if FBehaviour
= BH_INSANE
then
4221 FTargetTime
:= MAX_ATM
;
4230 function TMonster
.kick(o
: PObj
): Boolean;
4234 case FMonsterType
of
4237 SetState(MONSTATE_ATTACK
);
4242 SetState(MONSTATE_ATTACK
);
4243 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj
.X
, FObj
.Y
);
4248 SetState(MONSTATE_ATTACK
);
4249 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj
.X
, FObj
.Y
);
4252 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4254 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
4255 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj
.X
, FObj
.Y
);
4258 MONSTER_BARON
, MONSTER_KNIGHT
,
4259 MONSTER_CACO
, MONSTER_MANCUB
:
4260 // Ýòè ìîíñòðû íå ïèíàþò - îíè ñòðåëÿþò â óïîð:
4261 if not g_Game_IsClient
then Result
:= shoot(o
, True);
4265 function TMonster
.shoot(o
: PObj
; immediately
: Boolean): Boolean;
4275 // Æäàòü âðåìåíè ãîòîâíîñòè ê âûñòðåëó:
4276 if not immediately
then
4277 case FMonsterType
of
4278 MONSTER_FISH
, MONSTER_BARREL
, MONSTER_DEMON
:
4279 Exit
; // íå ñòðåëÿþò
4280 MONSTER_CGUN
, MONSTER_BSP
, MONSTER_ROBO
:
4283 // Âðåìÿ âûñòðåëà óïóùåíî:
4285 FAmmo
:= IfThen(FMonsterType
= MONSTER_ROBO
, -200, -50);
4291 // Âðåìÿ âûñòðåëà óïóùåíî:
4298 // Âðåìÿ âûñòðåëà óïóùåíî:
4299 if FAmmo
>= 100 then
4304 // Ñòðåëÿåò íå âñåãäà:
4305 if Random(2) = 0 then
4308 // Âðåìÿ âûñòðåëà óïóùåíî:
4312 MONSTER_BARON
, MONSTER_KNIGHT
: if Random(8) <> 0 then Exit
;
4313 MONSTER_SKEL
: if Random(32) <> 0 then Exit
;
4314 MONSTER_VILE
: if Random(8) <> 0 then Exit
;
4315 MONSTER_PAIN
: if Random(8) <> 0 then Exit
;
4316 else if Random(16) <> 0 then Exit
;
4320 if not g_Look(@FObj
, o
, FDirection
) then
4325 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2)+((o
^.Vel
.X
{+o^.Accel.X})*12);
4326 ty
:= o
^.Y
+o
^.Rect
.Y
+(o
^.Rect
.Height
div 2)+((o
^.Vel
.Y
{+o^.Accel.Y})*12);
4328 // Ðàçíèöà ïî âûñîòå áîëüøå ðàçíèöû ïî ãîðèçîíòàëè
4329 // (íå ìîæåò ñòðåëÿòü ïîä òàêèì áîëüøèì óãëîì):
4330 if Abs(tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2))) <
4331 Abs(ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2))) then
4334 case FMonsterType
of
4335 MONSTER_IMP
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
:
4337 SetState(MONSTATE_SHOOT
);
4342 SetState(MONSTATE_SHOOT
);
4346 begin // Çàæèãàåì îãîíü
4347 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2);
4348 ty
:= o
^.Y
+o
^.Rect
.Y
;
4349 SetState(MONSTATE_SHOOT
);
4353 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ATTACK', FObj
.X
, FObj
.Y
);
4354 g_Sound_PlayExAt('SOUND_FIRE', o
^.X
, o
^.Y
);
4357 begin // Ëåòèò â ñòîðîíó öåëè:
4358 SetState(MONSTATE_ATTACK
);
4359 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj
.X
, FObj
.Y
);
4361 xd
:= tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
4362 yd
:= ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
4363 m
:= Max(Abs(xd
), Abs(yd
));
4367 FObj
.Vel
.X
:= (xd
*16) div m
;
4368 FObj
.Vel
.Y
:= (yd
*16) div m
;
4370 MONSTER_MANCUB
, MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_BSP
, MONSTER_ROBO
,
4371 MONSTER_CYBER
, MONSTER_CGUN
, MONSTER_SPIDER
, MONSTER_PAIN
, MONSTER_MAN
:
4373 // Ìàíêóáóñ ðÿâêàåò ïåðåä ïåðâîé àòàêîé:
4374 if FMonsterType
= MONSTER_MANCUB
then
4376 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj
.X
, FObj
.Y
);
4378 SetState(MONSTATE_SHOOT
);
4386 function TMonster
.alive(): Boolean;
4388 Result
:= (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) and (FHealth
> 0);
4391 procedure TMonster
.SetHealth(aH
: Integer);
4393 if (aH
> 0) and (aH
< 1000000) then
4396 if FHealth
> FMaxHealth
then
4397 FMaxHealth
:= FHealth
;
4401 procedure TMonster
.WakeUp();
4403 if g_Game_IsClient
then Exit
;
4404 SetState(MONSTATE_GO
);
4405 FTargetTime
:= MAX_ATM
;
4409 procedure TMonster
.SaveState (st
: TStream
);
4417 // Ñèãíàòóðà ìîíñòðà:
4418 utils
.writeSign(st
, 'MONS');
4419 utils
.writeInt(st
, Byte(0)); // version
4421 utils
.writeInt(st
, Word(FUID
));
4423 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
4424 utils
.writeInt(st
, Byte(b
));
4425 // Íàäî ëè óäàëèòü åãî
4426 utils
.writeBool(st
, FRemoved
);
4427 // Îñòàëîñü çäîðîâüÿ
4428 utils
.writeInt(st
, LongInt(FHealth
));
4430 utils
.writeInt(st
, Byte(FState
));
4432 utils
.writeInt(st
, Byte(FCurAnim
));
4434 utils
.writeInt(st
, Word(FTargetUID
));
4435 // Âðåìÿ ïîñëå ïîòåðè öåëè
4436 utils
.writeInt(st
, LongInt(FTargetTime
));
4437 // Ïîâåäåíèå ìîíñòðà
4438 utils
.writeInt(st
, Byte(FBehaviour
));
4439 // Ãîòîâíîñòü ê âûñòðåëó
4440 utils
.writeInt(st
, LongInt(FAmmo
));
4442 utils
.writeInt(st
, LongInt(FPain
));
4444 utils
.writeInt(st
, LongInt(FSleep
));
4445 // Îçâó÷èâàòü ëè áîëü
4446 utils
.writeBool(st
, FPainSound
);
4447 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4448 utils
.writeBool(st
, FWaitAttackAnim
);
4449 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4450 utils
.writeBool(st
, FChainFire
);
4451 // Ïîäëåæèò ëè ðåñïàâíó
4452 utils
.writeBool(st
, FNoRespawn
);
4454 utils
.writeInt(st
, LongInt(tx
));
4455 utils
.writeInt(st
, LongInt(ty
));
4456 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4457 utils
.writeInt(st
, LongInt(FStartID
));
4458 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4459 utils
.writeInt(st
, LongInt(FSpawnTrigger
));
4461 Obj_SaveState(st
, @FObj
);
4462 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4463 anim
:= (vilefire
<> nil);
4464 utils
.writeBool(st
, anim
);
4465 // Åñëè åñòü - ñîõðàíÿåì:
4466 if anim
then vilefire
.SaveState(st
);
4468 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4470 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4471 anim
:= (FAnim
[i
, TDirection
.D_LEFT
] <> nil);
4472 utils
.writeBool(st
, anim
);
4473 // Åñëè åñòü - ñîõðàíÿåì
4474 if anim
then FAnim
[i
, TDirection
.D_LEFT
].SaveState(st
);
4475 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4476 anim
:= (FAnim
[i
, TDirection
.D_RIGHT
] <> nil);
4477 utils
.writeBool(st
, anim
);
4478 // Åñëè åñòü - ñîõðàíÿåì
4479 if anim
then FAnim
[i
, TDirection
.D_RIGHT
].SaveState(st
);
4484 procedure TMonster
.LoadState (st
: TStream
);
4492 // Ñèãíàòóðà ìîíñòðà:
4493 if not utils
.checkSign(st
, 'MONS') then raise XStreamError
.Create('invalid monster signature');
4494 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid monster version');
4495 if (uidMap
[FUID
] <> nil) and (uidMap
[FUID
] <> self
) then raise Exception
.Create('internal error in monster loader (0)');
4496 uidMap
[FUID
] := nil;
4498 FUID
:= utils
.readWord(st
);
4499 //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
4500 if (uidMap
[FUID
] <> nil) then raise Exception
.Create('internal error in monster loader (1)');
4501 uidMap
[FUID
] := self
;
4503 b
:= utils
.readByte(st
);
4504 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
4505 // Íàäî ëè óäàëèòü åãî
4506 FRemoved
:= utils
.readBool(st
);
4507 // Îñòàëîñü çäîðîâüÿ
4508 FHealth
:= utils
.readLongInt(st
);
4510 FState
:= utils
.readByte(st
);
4512 FCurAnim
:= utils
.readByte(st
);
4514 FTargetUID
:= utils
.readWord(st
);
4515 // Âðåìÿ ïîñëå ïîòåðè öåëè
4516 FTargetTime
:= utils
.readLongInt(st
);
4517 // Ïîâåäåíèå ìîíñòðà
4518 FBehaviour
:= utils
.readByte(st
);
4519 // Ãîòîâíîñòü ê âûñòðåëó
4520 FAmmo
:= utils
.readLongInt(st
);
4522 FPain
:= utils
.readLongInt(st
);
4524 FSleep
:= utils
.readLongInt(st
);
4525 // Îçâó÷èâàòü ëè áîëü
4526 FPainSound
:= utils
.readBool(st
);
4527 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4528 FWaitAttackAnim
:= utils
.readBool(st
);
4529 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4530 FChainFire
:= utils
.readBool(st
);
4531 // Ïîäëåæèò ëè ðåñïàâíó
4532 FNoRespawn
:= utils
.readBool(st
);
4534 tx
:= utils
.readLongInt(st
);
4535 ty
:= utils
.readLongInt(st
);
4536 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4537 FStartID
:= utils
.readLongInt(st
);
4538 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4539 FSpawnTrigger
:= utils
.readLongInt(st
);
4541 Obj_LoadState(@FObj
, st
);
4542 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4543 anim
:= utils
.readBool(st
);
4544 // Åñëè åñòü - çàãðóæàåì:
4547 Assert(vilefire
<> nil, 'TMonster.LoadState: no vilefire anim');
4548 vilefire
.LoadState(st
);
4551 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4553 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4554 anim
:= utils
.readBool(st
);
4555 // Åñëè åñòü - çàãðóæàåì
4558 Assert(FAnim
[i
, TDirection
.D_LEFT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_left anim');
4559 FAnim
[i
, TDirection
.D_LEFT
].LoadState(st
);
4561 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4562 anim
:= utils
.readBool(st
);
4563 // Åñëè åñòü - çàãðóæàåì
4566 Assert(FAnim
[i
, TDirection
.D_RIGHT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_right anim');
4567 FAnim
[i
, TDirection
.D_RIGHT
].LoadState(st
);
4573 procedure TMonster
.ActivateTriggers();
4577 if FDieTriggers
<> nil then
4578 for a
:= 0 to High(FDieTriggers
) do
4579 g_Triggers_Press(FDieTriggers
[a
], ACTIVATE_MONSTERPRESS
);
4580 if FSpawnTrigger
> -1 then
4582 g_Triggers_DecreaseSpawner(FSpawnTrigger
);
4583 FSpawnTrigger
:= -1;
4587 procedure TMonster
.AddTrigger(t
: Integer);
4589 SetLength(FDieTriggers
, Length(FDieTriggers
)+1);
4590 FDieTriggers
[High(FDieTriggers
)] := t
;
4593 procedure TMonster
.ClearTriggers();
4595 SetLength(FDieTriggers
, 0);
4598 procedure TMonster
.CatchFire(Attacker
: Word);
4601 FFireAttacker
:= Attacker
;
4602 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_MonsterState(FUID
);
4605 procedure TMonster
.OnFireFlame(Times
: DWORD
= 1);
4610 if (Random(10) = 1) and (Times
= 1) then
4613 if g_Frames_Get(id
, 'FRAMES_FLAME') then
4615 for i
:= 1 to Times
do
4617 Anim
:= TAnimation
.Create(id
, False, 3);
4619 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
4620 Obj
.Y
+8+Random(8+Times
*2)+IfThen(FState
= MONSTATE_DEAD
, 16, 0), Anim
, ONCEANIM_SMOKE
);
4627 // ////////////////////////////////////////////////////////////////////////// //
4628 // throws on invalid uid
4629 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
4631 result
:= g_Mons_ByIdx_NC(uid
);
4632 if (result
= nil) then raise Exception
.Create('g_Mons_ByIdx: invalid monster id');
4636 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
4638 if (uid
< 0) or (uid
> High(gMonsters
)) then begin result
:= nil; exit
; end;
4639 result
:= gMonsters
[uid
];
4642 function g_Mons_TotalCount (): Integer; inline;
4644 result
:= Length(gMonsters
);
4648 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
4654 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4655 for idx
:= 0 to High(gMonsters
) do
4657 mon
:= gMonsters
[idx
];
4658 if (mon
<> nil) then
4661 if result
then exit
;
4667 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
4673 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4674 for idx
:= 0 to High(gMonsters
) do
4676 mon
:= gMonsters
[idx
];
4677 if (mon
<> nil) and mon
.alive
then
4680 if result
then exit
;
4686 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
4688 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4690 result
:= mon
.alive
;// and g_Obj_Collide(x, y, width, height, @mon.Obj));
4698 if (width
< 1) or (height
< 1) then exit
;
4699 if gmon_debug_use_sqaccel
then
4701 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4705 for idx
:= 0 to High(gMonsters
) do
4707 mon
:= gMonsters
[idx
];
4708 if (mon
<> nil) and mon
.alive
then
4710 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4721 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4723 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4733 if (width
< 1) or (height
< 1) then exit
;
4734 if gmon_debug_use_sqaccel
then
4736 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4740 for idx
:= 0 to High(gMonsters
) do
4742 mon
:= gMonsters
[idx
];
4743 if (mon
<> nil) and mon
.alive
then
4745 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4748 if result
then exit
;
4756 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4758 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4761 //if mon.alive and g_Obj_Collide(x, y, width, height, @mon.Obj) then result := cb(mon);
4762 if mon
.alive
then result
:= cb(mon
) else result
:= false;
4770 if (width
< 1) or (height
< 1) then exit
;
4771 if gmon_debug_use_sqaccel
then
4773 if (width
= 1) and (height
= 1) then
4775 result
:= (monsGrid
.forEachAtPoint(x
, y
, monsCollCheck
) <> nil);
4779 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4784 for idx
:= 0 to High(gMonsters
) do
4786 mon
:= gMonsters
[idx
];
4787 if (mon
<> nil) and mon
.alive
then
4789 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4792 if result
then exit
;