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, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
17 {.$DEFINE D2F_DEBUG_MONS_MOVE}
25 g_basic
, e_graphics
, g_phys
, g_textures
, g_grid
,
26 g_saveload
, g_panel
, xprofiler
;
55 TMonster
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
59 FDirection
: TDirection
;
60 FStartDirection
: TDirection
;
61 FStartX
, FStartY
: Integer;
67 FAnim
: Array of Array [TDirection
.D_LEFT
..TDirection
.D_RIGHT
] of TAnimation
;
76 FWaitAttackAnim
: Boolean;
87 FFirePainTime
: Integer;
90 mProxyId
: Integer; // node in dyntree or -1
91 mArrIdx
: Integer; // in gMonsters
93 FDieTriggers
: Array of Integer;
94 FSpawnTrigger
: Integer;
96 mNeedSend
: Boolean; // for network
98 mEDamageType
: Integer;
101 function findNewPrey(): Boolean;
102 procedure ActivateTriggers();
104 procedure setGameX (v
: Integer); inline;
105 procedure setGameY (v
: Integer); inline;
107 procedure doDamage (v
: Integer);
112 trapCheckFrameId
: DWord
; // for `g_weapons.CheckTrap()`
113 mplatCheckFrameId
: LongWord;
115 constructor Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
116 destructor Destroy(); override;
117 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
118 function Collide(Panel
: TPanel
): Boolean; overload
;
119 function Collide(X
, Y
: Integer): Boolean; overload
;
120 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
121 function alive(): Boolean;
122 procedure SetHealth(aH
: Integer);
123 procedure Push(vx
, vy
: Integer);
124 function Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
125 function Heal(Value
: Word): Boolean;
128 procedure ClientUpdate();
129 procedure ClientAttack(wx
, wy
, atx
, aty
: Integer);
130 procedure SetDeadAnim
;
133 procedure WakeUpSound();
134 procedure DieSound();
135 procedure PainSound();
136 procedure ActionSound();
137 procedure AddTrigger(t
: Integer);
138 procedure ClearTriggers();
140 procedure SaveState (st
: TStream
);
141 procedure LoadState (st
: TStream
);
142 procedure SetState(State
: Byte; ForceAnim
: Byte = 255);
143 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
144 procedure MakeBloodSimple(Count
: Word);
145 procedure RevertAnim(R
: Boolean = True);
146 function AnimIsReverse
: Boolean;
147 function shoot(o
: PObj
; immediately
: Boolean): Boolean;
148 function kick(o
: PObj
): Boolean;
149 procedure CatchFire(Attacker
: Word; Timeout
: Integer = MON_BURN_TIME
);
150 procedure OnFireFlame(Times
: DWORD
= 1);
152 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
154 procedure setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline;
155 procedure moveBy (dx
, dy
: Integer); inline;
157 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
160 function gncNeedSend (): Boolean; inline;
161 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
164 property Obj
: TObj read FObj
;
166 property proxyId
: Integer read mProxyId
;
167 property arrIdx
: Integer read mArrIdx
;
169 property MonsterType
: Byte read FMonsterType
;
170 property MonsterHealth
: Integer read FHealth write FHealth
;
171 property MonsterAmmo
: Integer read FAmmo write FAmmo
;
172 property MonsterTargetUID
: Word read FTargetUID write FTargetUID
;
173 property MonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
174 property MonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
175 property MonsterSleep
: Integer read FSleep write FSleep
;
176 property MonsterState
: Byte read FState write FState
;
177 property MonsterRemoved
: Boolean read FRemoved write FRemoved
;
178 property MonsterPain
: Integer read FPain write FPain
;
179 property MonsterAnim
: Byte read FCurAnim write FCurAnim
;
181 property UID
: Word read FUID write FUID
;
182 property SpawnTrigger
: Integer read FSpawnTrigger write FSpawnTrigger
;
184 property GameX
: Integer read FObj
.X write setGameX
;
185 property GameY
: Integer read FObj
.Y write setGameY
;
186 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
187 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
188 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
189 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
190 property GameDirection
: TDirection read FDirection write FDirection
;
192 property StartID
: Integer read FStartID
;
195 property eMonsterType
: Byte read FMonsterType
;
196 property eMonsterHealth
: Integer read FHealth write FHealth
;
197 property eMonsterAmmo
: Integer read FAmmo write FAmmo
;
198 property eMonsterTargetUID
: Word read FTargetUID write FTargetUID
;
199 property eMonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
200 property eMonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
201 property eMonsterSleep
: Integer read FSleep write FSleep
;
202 property eMonsterState
: Byte read FState write FState
;
203 property eMonsterRemoved
: Boolean read FRemoved
;
204 property eMonsterPain
: Integer read FPain write FPain
;
205 property eMonsterAnim
: Byte read FCurAnim
;
207 property eUID
: Word read FUID
;
208 property eSpawnTrigger
: Integer read FSpawnTrigger
;
210 property eGameX
: Integer read FObj
.X write setGameX
;
211 property eGameY
: Integer read FObj
.Y write setGameY
;
212 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
213 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
214 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
215 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
216 property eGameDirection
: TDirection read FDirection write FDirection
;
218 property eStartID
: Integer read FStartID
;
220 // set this before assigning something to `eDamage`
221 property eDamageType
: Integer read mEDamageType write mEDamageType
;
222 property eDamage
: Integer write doDamage
;
226 // will be called from map loader
227 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
229 procedure g_Monsters_LoadData ();
230 procedure g_Monsters_FreeData ();
231 procedure g_Monsters_Init ();
232 procedure g_Monsters_Free (clearGrid
: Boolean=true);
233 function g_Monsters_Create (MonsterType
: Byte; X
, Y
: Integer; Direction
: TDirection
;
234 AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
235 procedure g_Monsters_Update ();
236 procedure g_Monsters_Draw ();
237 procedure g_Monsters_DrawHealth ();
238 function g_Monsters_ByUID (UID
: Word): TMonster
;
239 procedure g_Monsters_killedp ();
240 procedure g_Monsters_SaveState (st
: TStream
);
241 procedure g_Monsters_LoadState (st
: TStream
);
243 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
244 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
246 function g_Mons_TypeLo (): Integer; inline;
247 function g_Mons_TypeHi (): Integer; inline;
249 function g_Mons_TypeIdByName (const name
: AnsiString): Integer;
250 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
251 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
255 TEachMonsterCB
= function (mon
: TMonster
): Boolean is nested
; // return `true` to stop
257 // throws on invalid uid
258 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
261 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
263 function g_Mons_TotalCount (): Integer; inline;
265 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
267 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
268 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
270 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
271 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
273 function g_Mons_getNewTrapFrameId (): DWord
; inline;
274 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
279 TMonsAlongLineCB = function (mon: TMonster; tag: Integer): Boolean is nested;
281 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
286 gmon_debug_use_sqaccel
: Boolean = true;
290 procedure g_Mons_ProfilersBegin ();
291 procedure g_Mons_ProfilersEnd ();
293 procedure g_Mons_LOS_Start (); inline;
294 procedure g_Mons_LOS_End (); inline;
297 profMonsLOS
: TProfiler
= nil; //WARNING: FOR DEBUGGING ONLY!
301 TMonsterGrid
= specialize TBodyGridBase
<TMonster
>;
304 monsGrid
: TMonsterGrid
= nil; // DO NOT USE! public for debugging only!
308 gmon_debug_think
: Boolean = true;
309 gmon_debug_one_think_step
: Boolean = false;
315 e_log
, e_texture
, g_main
, g_sound
, g_gfx
, g_player
, g_game
,
316 g_weapons
, g_triggers
, MAPDEF
, g_items
, g_options
,
317 g_console
, g_map
, Math
, g_menu
, wadreader
,
318 g_language
, g_netmsg
, idpool
, utils
, xstreams
;
322 // ////////////////////////////////////////////////////////////////////////// //
323 procedure g_Mons_ProfilersBegin ();
325 if (profMonsLOS
= nil) then profMonsLOS
:= TProfiler
.Create('LOS CALC', g_profile_history_size
);
326 if (profMonsLOS
<> nil) then profMonsLOS
.mainBegin(g_profile_los
);
327 if g_profile_los
and (profMonsLOS
<> nil) then
329 profMonsLOS
.sectionBegin('loscalc');
330 profMonsLOS
.sectionEnd();
334 procedure g_Mons_ProfilersEnd ();
336 if (profMonsLOS
<> nil) and (g_profile_los
) then profMonsLOS
.mainEnd();
339 procedure g_Mons_LOS_Start (); inline;
341 if (profMonsLOS
<> nil) then profMonsLOS
.sectionBeginAccum('loscalc');
344 procedure g_Mons_LOS_End (); inline;
346 if (profMonsLOS
<> nil) then profMonsLOS
.sectionEnd();
350 // ////////////////////////////////////////////////////////////////////////// //
352 monCheckTrapLastFrameId
: DWord
= 0;
353 monCheckMPlatLastFrameId
: LongWord = 0;
356 procedure TMonster
.getMapBox (out x
, y
, w
, h
: Integer); inline;
358 x
:= FObj
.X
+FObj
.Rect
.X
;
359 y
:= FObj
.Y
+FObj
.Rect
.Y
;
360 w
:= FObj
.Rect
.Width
;
361 h
:= FObj
.Rect
.Height
;
364 function TMonster
.gncNeedSend (): Boolean; inline; begin result
:= mNeedSend
; mNeedSend
:= false; end;
366 procedure TMonster
.setDirty (); inline; begin mNeedSend
:= true; end;
369 // ////////////////////////////////////////////////////////////////////////// //
371 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
373 if not assigned(cb) then begin result := nil; exit; end;
374 result := monsGrid.forEachAlongLine(x0, y0, x1, y1, cb, -1, log);
379 //WARNING! call this after monster position was changed, or coldet will not work right!
380 procedure TMonster
.positionChanged ();
383 nx
, ny
, nw
, nh
: Integer;
385 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
386 //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);
388 if (mProxyId
= -1) then
391 mProxyId
:= monsGrid
.insertBody(self
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
392 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
393 monsGrid
.getBodyXY(mProxyId
, x
, y
);
394 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
);
399 monsGrid
.getBodyDims(mProxyId
, x
, y
, w
, h
);
400 getMapBox(nx
, ny
, nw
, nh
);
402 if (w
<> nw
) or (h
<> nh
) then
405 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
406 e_WriteLog(Format('monster #%d:(%u): resized; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
408 monsGrid
.moveResizeBody(mProxyId
, nx
, ny
, nw
, nh
);
410 else if (x
<> nx
) or (y
<> ny
) then
413 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
414 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
);
416 monsGrid
.moveBody(mProxyId
, nx
, ny
);
420 exit
; // nothing to do
422 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
423 monsGrid
.getBodyXY(mProxyId
, x
, y
);
424 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
);
430 // ////////////////////////////////////////////////////////////////////////// //
440 MONSTER_SIGNATURE
= $534E4F4D; // 'MONS'
442 // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ:
443 ANIMTABLE
: Array [ANIM_SLEEP
..ANIM_PAIN
] of
447 end = ((name
: 'SLEEP'; loop
: True),
448 (name
: 'GO'; loop
: True),
449 (name
: 'DIE'; loop
: False),
450 (name
: 'MESS'; loop
: False),
451 (name
: 'ATTACK'; loop
: False),
452 (name
: 'ATTACK2'; loop
: False),
453 (name
: 'PAIN'; loop
: False));
455 // Òàáëèöà õàðàêòåðèñòèê ìîíñòðîâ:
456 MONSTERTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
466 ((Name
:'DEMON'; Rect
:(X
:7; Y
:8; Width
:50; Height
:52); Health
:60;
467 RunVel
: 7; MinPain
: 10; Pain
: 20; Jump
: 10),
469 (Name
:'IMP'; Rect
:(X
:15; Y
:10; Width
:34; Height
:50); Health
:25;
470 RunVel
: 3; MinPain
: 0; Pain
: 15; Jump
: 10),
472 (Name
:'ZOMBY'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:15;
473 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
475 (Name
:'SERG'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:20;
476 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
478 (Name
:'CYBER'; Rect
:(X
:24; Y
:9; Width
:80; Height
:110); Health
:500;
479 RunVel
: 5; MinPain
: 50; Pain
: 70; Jump
: 10),
481 (Name
:'CGUN'; Rect
:(X
:15; Y
:4; Width
:34; Height
:56); Health
:60;
482 RunVel
: 3; MinPain
: 10; Pain
: 20; Jump
: 10),
484 (Name
:'BARON'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:150;
485 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
487 (Name
:'KNIGHT'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:75;
488 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
490 (Name
:'CACO'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
491 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
493 (Name
:'SOUL'; Rect
:(X
:16; Y
:14; Width
:32; Height
:36); Health
:60;
494 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
496 (Name
:'PAIN'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
497 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
499 (Name
:'SPIDER'; Rect
:(X
:23; Y
:14; Width
:210; Height
:100); Health
:500;
500 RunVel
: 4; MinPain
: 50; Pain
: 70; Jump
: 10),
502 (Name
:'BSP'; Rect
:(X
:14; Y
:17; Width
:100; Height
:42); Health
:150;
503 RunVel
: 4; MinPain
: 0; Pain
: 20; Jump
: 10),
505 (Name
:'MANCUB'; Rect
:(X
:28; Y
:34; Width
:72; Height
:60); Health
:200;
506 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 7),
508 (Name
:'SKEL'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:200;
509 RunVel
: 6; MinPain
: 20; Pain
: 40; Jump
: 11),
511 (Name
:'VILE'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:150;
512 RunVel
: 7; MinPain
: 10; Pain
: 30; Jump
: 12),
514 (Name
:'FISH'; Rect
:(X
:6; Y
:11; Width
:20; Height
:10); Health
:35;
515 RunVel
: 14; MinPain
: 10; Pain
: 20; Jump
: 6),
517 (Name
:'BARREL'; Rect
:(X
:20; Y
:13; Width
:24; Height
:36); Health
:20;
518 RunVel
: 0; MinPain
: 0; Pain
: 0; Jump
: 0),
520 (Name
:'ROBO'; Rect
:(X
:30; Y
:26; Width
:68; Height
:76); Health
:20;
521 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 6),
523 (Name
:'MAN'; Rect
:(X
:15; Y
:6; Width
:34; Height
:52); Health
:400;
524 RunVel
: 8; MinPain
: 50; Pain
: 70; Jump
: 10));
526 // Òàáëèöà ïàðàìåòðîâ àíèìàöèè ìîíñòðîâ:
527 MONSTER_ANIMTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
530 wX
, wY
: Integer; // Îòêóäà âûëåòèò ïóëÿ
531 AnimSpeed
: Array [ANIM_SLEEP
..ANIM_PAIN
] of Byte;
532 AnimDeltaRight
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
533 AnimDeltaLeft
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
534 end = // SLEEP GO DIE MESS ATTACK ATTACK2 PAIN
535 ((LeftAnim
: False; wX
: 54; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //DEMON
536 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));
537 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))),
539 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //IMP
540 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));
541 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))),
543 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //ZOMBY
544 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));
545 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))),
547 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //SERG
548 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));
549 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))),
551 (LeftAnim
: True; wX
: 70; wY
: 73; AnimSpeed
:(3, 3, 3, 3, 3, 4, 3); //CYBER
552 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));
553 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))),
555 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 1, 0, 4); //CGUN
556 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));
557 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))),
559 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //BARON
560 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));
561 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))),
563 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //KNIGHT
564 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));
565 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))),
567 (LeftAnim
: False; wX
: 88; wY
: 69; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //CACO
568 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));
569 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))),
571 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //SOUL
572 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));
573 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))),
575 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //PAIN
576 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));
577 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))),
579 (LeftAnim
: True; wX
: 128; wY
: 64; AnimSpeed
:(3, 2, 4, 4, 1, 0, 4); //SPIDER
580 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));
581 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))),
583 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //BSP
584 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));
585 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))),
587 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 2, 4, 2, 0, 4); //MANCUB
588 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));
589 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))),
591 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //SKEL
592 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));
593 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))),
595 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //VILE
596 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));
597 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))),
599 (LeftAnim
: False; wX
: 8; wY
: 8; AnimSpeed
:(2, 2, 2, 2, 3, 0, 1); //FISH
600 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));
601 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 ))),
603 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 0, 3, 0, 0, 0, 5); //BARREL
604 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));
605 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))),
607 (LeftAnim
: False; wX
: 95; wY
: 57; AnimSpeed
:(1, 2, 1, 0, 1, 1, 0); //ROBO
608 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));
609 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))),
611 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 2, 0, 5); //MAN
612 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));
613 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))) );
615 MAX_ATM
= 89; // Âðåìÿ îæèäàíèÿ ïîñëå ïîòåðè öåëè
616 MAX_SOUL
= 512; // Îãðàíè÷åíèå Lost_Soul'îâ
619 // ////////////////////////////////////////////////////////////////////////// //
621 gMonsters
: array of TMonster
;
622 uidMap
: array [0..65535] of TMonster
; // monster knows it's index
623 freeInds
: TIdPool
= nil;
626 procedure clearUidMap ();
630 for idx
:= 0 to High(uidMap
) do uidMap
[idx
] := nil;
635 function g_Mons_getNewTrapFrameId (): DWord
; inline;
639 Inc(monCheckTrapLastFrameId
);
640 if (monCheckTrapLastFrameId
= 0) then
643 monCheckTrapLastFrameId
:= 1;
644 for f
:= 0 to High(gMonsters
) do
646 if (gMonsters
[f
] <> nil) then gMonsters
[f
].trapCheckFrameId
:= 0;
649 result
:= monCheckTrapLastFrameId
;
653 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
657 Inc(monCheckMPlatLastFrameId
);
658 if (monCheckMPlatLastFrameId
= 0) then
661 monCheckMPlatLastFrameId
:= 1;
662 for f
:= 0 to High(gMonsters
) do
664 if (gMonsters
[f
] <> nil) then gMonsters
[f
].mplatCheckFrameId
:= 0;
667 result
:= monCheckMPlatLastFrameId
;
676 soulcount
: Integer = 0;
679 function allocMonster (): DWORD
;
683 result
:= freeInds
.alloc();
684 if (result
> High(gMonsters
)) then
686 olen
:= Length(gMonsters
);
687 SetLength(gMonsters
, result
+64);
688 for f
:= olen
to High(gMonsters
) do gMonsters
[f
] := nil;
693 function IsFriend(a
, b
: Byte): Boolean;
697 // Áî÷êà - âñåì äðóã:
698 if (a
= MONSTER_BARREL
) or (b
= MONSTER_BARREL
) then
701 // Ìîíñòðû îäíîãî âèäà:
704 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
705 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
706 Exit
; // Ýòè íå áüþò ñâîèõ
709 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
710 if (a
= MONSTER_SOUL
) and (b
= MONSTER_PAIN
) then
712 // Pain_Elemental íå ìîæåò ðàíèòü Lost_Soul'à:
713 if (b
= MONSTER_SOUL
) and (a
= MONSTER_PAIN
) then
716 //  îñòàëüíûõ ñëó÷àÿõ - áóäóò áèòü äðóã äðóãà:
721 function BehaviourDamage(SpawnerUID
: Word; BH
, SelfType
: Byte): Boolean;
724 UIDType
, MonsterType
: Byte;
729 UIDType
:= g_GetUIDType(SpawnerUID
);
730 if UIDType
= UID_MONSTER
then
732 m
:= g_Monsters_ByUID(SpawnerUID
);
733 if m
= nil then Exit
;
734 MonsterType
:= m
.FMonsterType
;
738 BH_NORMAL
: Result
:= (UIDType
= UID_PLAYER
) or
739 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
741 BH_KILLER
: Result
:= UIDType
= UID_PLAYER
;
742 BH_MANIAC
: Result
:= (UIDType
= UID_PLAYER
) or
743 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
745 BH_INSANE
: Result
:= (UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
));
746 BH_CANNIBAL
: Result
:= (UIDType
= UID_MONSTER
) and (MonsterType
= SelfType
);
751 function canShoot(m
: Byte): Boolean;
756 MONSTER_DEMON
, MONSTER_FISH
, MONSTER_BARREL
:
764 function isCorpse (o
: PObj
; immediately
: Boolean): Integer;
767 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
769 atag := atag; // shut up, fpc!
770 result := false; // don't stop
771 if (mon.FState = MONSTATE_DEAD) and g_Obj_Collide(o, @mon.FObj) then
773 case mon.FMonsterType of // Íå âîñêðåñèòü:
774 MONSTER_SOUL, MONSTER_PAIN, MONSTER_CYBER, MONSTER_SPIDER,
775 MONSTER_VILE, MONSTER_BARREL, MONSTER_ROBO: exit;
777 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
786 mres
: TMonster
= nil;
787 it
: TMonsterGrid
.Iter
;
791 // Åñëè íóæíà âåðîÿòíîñòü
792 if not immediately
and (Random(8) <> 0) then exit
;
794 // Èùåì ìåðòâûõ ìîíñòðîâ ïîáëèçîñòè
795 if gmon_debug_use_sqaccel
then
797 //mon := monsGrid.forEachInAABB(o.X+o.Rect.X, o.Y+o.Rect.Y, o.Rect.Width, o.Rect.Height, monsCollCheck);
798 //if (mon <> nil) then result := mon.mArrIdx;
799 it
:= monsGrid
.forEachInAABB(o
.X
+o
.Rect
.X
, o
.Y
+o
.Rect
.Y
, o
.Rect
.Width
, o
.Rect
.Height
);
802 case mon
.FMonsterType
of // Íå âîñêðåñèòü:
803 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
804 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: begin end;
805 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
808 if (mres
<> nil) then break
;
811 if (mres
<> nil) then result
:= mres
.mArrIdx
;
815 for a
:= 0 to High(gMonsters
) do
817 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @gMonsters
[a
].FObj
) then
819 case gMonsters
[a
].FMonsterType
of // Íå âîñêðåñèòü:
820 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
821 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: Continue
;
822 else // Îñòàëüíûõ ìîæíî âîñêðåñèòü
833 procedure g_Monsters_LoadData();
835 e_WriteLog('Loading monsters data...', TMsgType
.Notify
);
837 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
], 133, False);
838 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD
+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
839 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD
+':MTEXTURES\BARREL_DIE', 64, 64, 4);
840 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD
+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
841 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD
+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
842 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD
+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
843 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD
+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
844 g_Game_StepLoading(6);
845 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD
+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
846 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD
+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
847 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK_L', GameWAD
+':MTEXTURES\ZOMBY_ATTACK_L', 64, 64, 2);
848 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD
+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
849 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD
+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
850 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD
+':MTEXTURES\SERG_GO', 64, 64, 4);
851 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD
+':MTEXTURES\SERG_DIE', 64, 64, 5);
852 g_Game_StepLoading(13);
853 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD
+':MTEXTURES\SERG_MESS', 64, 64, 9);
854 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD
+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
855 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK_L', GameWAD
+':MTEXTURES\SERG_ATTACK_L', 64, 64, 2);
856 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD
+':MTEXTURES\SERG_PAIN', 64, 64, 1);
857 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD
+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
858 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD
+':MTEXTURES\MAN_GO', 64, 64, 4);
859 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD
+':MTEXTURES\MAN_DIE', 64, 64, 7);
860 g_Game_StepLoading(20);
861 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD
+':MTEXTURES\MAN_MESS', 64, 64, 9);
862 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD
+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
863 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD
+':MTEXTURES\MAN_PAIN', 64, 64, 1);
864 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD
+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
865 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD
+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
866 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD
+':MTEXTURES\CGUN_GO', 64, 64, 4);
867 g_Game_StepLoading(26);
868 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD
+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
869 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD
+':MTEXTURES\CGUN_DIE', 64, 64, 7);
870 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD
+':MTEXTURES\CGUN_MESS', 64, 64, 6);
871 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD
+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
872 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD
+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
873 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD
+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
874 g_Game_StepLoading(32);
875 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD
+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
876 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD
+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
877 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD
+':MTEXTURES\IMP_GO', 64, 64, 4);
878 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD
+':MTEXTURES\IMP_DIE', 64, 64, 5);
879 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD
+':MTEXTURES\IMP_MESS', 64, 64, 8);
880 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD
+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
881 g_Game_StepLoading(38);
882 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD
+':MTEXTURES\IMP_PAIN', 64, 64, 1);
883 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD
+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
884 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD
+':MTEXTURES\DEMON_GO', 64, 64, 4);
885 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD
+':MTEXTURES\DEMON_DIE', 64, 64, 6);
886 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD
+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
887 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD
+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
888 g_Game_StepLoading(44);
889 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD
+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
890 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD
+':MTEXTURES\SOUL_GO', 64, 64, 2);
891 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD
+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
892 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD
+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
893 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD
+':MTEXTURES\SOUL_DIE', 128, 128, 7);
894 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD
+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
895 g_Game_StepLoading(50);
896 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD
+':MTEXTURES\FISH_GO', 32, 32, 4);
897 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD
+':MTEXTURES\FISH_PAIN', 32, 32, 3);
898 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD
+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
899 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD
+':MTEXTURES\FISH_DIE', 32, 32, 1);
900 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD
+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
901 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD
+':MTEXTURES\SPIDER_GO', 256, 128, 6);
902 g_Game_StepLoading(56);
903 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD
+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
904 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD
+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
905 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD
+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
906 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD
+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
907 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD
+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
908 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD
+':MTEXTURES\BSP_GO', 128, 64, 6);
909 g_Game_StepLoading(62);
910 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD
+':MTEXTURES\BSP_PAIN', 128, 64, 1);
911 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD
+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
912 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD
+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
913 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD
+':MTEXTURES\BSP_DIE', 128, 64, 7);
914 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD
+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
915 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD
+':MTEXTURES\CACO_GO', 128, 128, 1);
916 g_Game_StepLoading(68);
917 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD
+':MTEXTURES\CACO_PAIN', 128, 128, 1);
918 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD
+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
919 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD
+':MTEXTURES\CACO_DIE', 128, 128, 7);
920 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD
+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
921 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD
+':MTEXTURES\PAIN_GO', 128, 128, 4);
922 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD
+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
923 g_Game_StepLoading(74);
924 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD
+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
925 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD
+':MTEXTURES\PAIN_DIE', 128, 128, 7);
926 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD
+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
927 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD
+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
928 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD
+':MTEXTURES\BARON_GO', 128, 128, 4);
929 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD
+':MTEXTURES\BARON_PAIN', 128, 128, 1);
930 g_Game_StepLoading(80);
931 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD
+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
932 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD
+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
933 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD
+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
934 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD
+':MTEXTURES\BARON_DIE', 128, 128, 7);
935 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD
+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
936 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD
+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
937 g_Game_StepLoading(86);
938 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD
+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
939 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD
+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
940 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD
+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
941 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD
+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
942 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD
+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
943 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD
+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
944 g_Game_StepLoading(92);
945 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD
+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
946 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD
+':MTEXTURES\MANCUB_GO', 128, 128, 6);
947 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD
+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
948 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD
+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
949 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD
+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
950 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD
+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
951 g_Game_StepLoading(98);
952 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD
+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
953 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD
+':MTEXTURES\SKEL_GO', 128, 128, 6);
954 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD
+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
955 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD
+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
956 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD
+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
957 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD
+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
958 g_Game_StepLoading(104);
959 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD
+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
960 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD
+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
961 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD
+':MTEXTURES\SKEL_DIE', 128, 128, 5);
962 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD
+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD
+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
964 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD
+':MTEXTURES\VILE_GO', 128, 128, 6);
965 g_Game_StepLoading(110);
966 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD
+':MTEXTURES\VILE_PAIN', 128, 128, 1);
967 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD
+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
968 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD
+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
969 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD
+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
970 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD
+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
971 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD
+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
972 g_Game_StepLoading(116);
973 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD
+':MTEXTURES\VILE_DIE', 128, 128, 9);
974 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD
+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
975 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD
+':MTEXTURES\ROBO_GO', 128, 128, 12);
976 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD
+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
977 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD
+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
978 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD
+':MTEXTURES\ROBO_DIE', 128, 128, 1);
979 g_Game_StepLoading(122);
980 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD
+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
981 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD
+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
982 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD
+':MTEXTURES\CYBER_GO', 128, 128, 4);
983 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD
+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
984 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD
+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
985 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD
+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
986 g_Game_StepLoading(128);
987 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD
+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
988 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD
+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
989 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD
+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
990 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD
+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
991 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD
+':MTEXTURES\CYBER_DIE', 128, 128, 9);
992 g_Game_StepLoading(133);
994 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_SOUNDS
], 0, False);
996 g_Sound_CreateWADEx('SOUND_MONSTER_BARREL_DIE', GameWAD
+':MSOUNDS\BARREL_DIE');
998 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN', GameWAD
+':MSOUNDS\PAIN');
999 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN2', GameWAD
+':MSOUNDS\PAIN2');
1000 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION', GameWAD
+':MSOUNDS\ACTION');
1001 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION2', GameWAD
+':MSOUNDS\ACTION2');
1002 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_1', GameWAD
+':MSOUNDS\ALERT_1');
1003 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_2', GameWAD
+':MSOUNDS\ALERT_2');
1004 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_3', GameWAD
+':MSOUNDS\ALERT_3');
1005 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_1', GameWAD
+':MSOUNDS\DIE_1');
1006 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_2', GameWAD
+':MSOUNDS\DIE_2');
1007 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_3', GameWAD
+':MSOUNDS\DIE_3');
1008 g_Sound_CreateWADEx('SOUND_MONSTER_SLOP', GameWAD
+':MSOUNDS\SLOP');
1010 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ATTACK', GameWAD
+':MSOUNDS\DEMON_ATTACK');
1011 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ALERT', GameWAD
+':MSOUNDS\DEMON_ALERT');
1012 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_DIE', GameWAD
+':MSOUNDS\DEMON_DIE');
1014 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_1', GameWAD
+':MSOUNDS\IMP_ALERT_1');
1015 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_2', GameWAD
+':MSOUNDS\IMP_ALERT_2');
1016 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_1', GameWAD
+':MSOUNDS\IMP_DIE_1');
1017 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_2', GameWAD
+':MSOUNDS\IMP_DIE_2');
1018 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ACTION', GameWAD
+':MSOUNDS\IMP_ACTION');
1019 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ATTACK', GameWAD
+':MSOUNDS\IMP_ATTACK');
1021 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_PAIN', GameWAD
+':MSOUNDS\MAN_PAIN');
1022 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_ALERT', GameWAD
+':MSOUNDS\MAN_ALERT');
1023 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_DIE', GameWAD
+':MSOUNDS\MAN_DIE');
1024 g_Sound_CreateWADEx('SOUND_MONSTER_HAHA', GameWAD
+':MSOUNDS\HAHA');
1025 g_Sound_CreateWADEx('SOUND_MONSTER_TRUP', GameWAD
+':MSOUNDS\TRUP');
1027 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_ATTACK', GameWAD
+':MSOUNDS\SOUL_ATTACK');
1028 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_DIE', GameWAD
+':MSOUNDS\SOUL_DIE');
1030 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ACTION', GameWAD
+':MSOUNDS\BSP_ACTION');
1031 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_DIE', GameWAD
+':MSOUNDS\BSP_DIE');
1032 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ALERT', GameWAD
+':MSOUNDS\BSP_ALERT');
1033 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_WALK', GameWAD
+':MSOUNDS\BSP_WALK');
1035 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ACTION', GameWAD
+':MSOUNDS\VILE_ACTION');
1036 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_PAIN', GameWAD
+':MSOUNDS\VILE_PAIN');
1037 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_DIE', GameWAD
+':MSOUNDS\VILE_DIE');
1038 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ALERT', GameWAD
+':MSOUNDS\VILE_ALERT');
1039 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ATTACK', GameWAD
+':MSOUNDS\VILE_ATTACK');
1041 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ACTION', GameWAD
+':MSOUNDS\SKEL_ACTION');
1042 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_DIE', GameWAD
+':MSOUNDS\SKEL_DIE');
1043 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ALERT', GameWAD
+':MSOUNDS\SKEL_ALERT');
1044 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ATTACK', GameWAD
+':MSOUNDS\SKEL_ATTACK');
1045 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_HIT', GameWAD
+':MSOUNDS\SKEL_HIT');
1047 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_PAIN', GameWAD
+':MSOUNDS\MANCUB_PAIN');
1048 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_DIE', GameWAD
+':MSOUNDS\MANCUB_DIE');
1049 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ALERT', GameWAD
+':MSOUNDS\MANCUB_ALERT');
1050 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ATTACK', GameWAD
+':MSOUNDS\MANCUB_ATTACK');
1052 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_PAIN', GameWAD
+':MSOUNDS\PAIN_PAIN');
1053 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_DIE', GameWAD
+':MSOUNDS\PAIN_DIE');
1054 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_ALERT', GameWAD
+':MSOUNDS\PAIN_ALERT');
1056 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_DIE', GameWAD
+':MSOUNDS\BARON_DIE');
1057 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_ALERT', GameWAD
+':MSOUNDS\BARON_ALERT');
1059 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_DIE', GameWAD
+':MSOUNDS\CACO_DIE');
1060 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_ALERT', GameWAD
+':MSOUNDS\CACO_ALERT');
1062 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_DIE', GameWAD
+':MSOUNDS\CYBER_DIE');
1063 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_ALERT', GameWAD
+':MSOUNDS\CYBER_ALERT');
1064 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_WALK', GameWAD
+':MSOUNDS\CYBER_WALK');
1066 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_DIE', GameWAD
+':MSOUNDS\KNIGHT_DIE');
1067 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_ALERT', GameWAD
+':MSOUNDS\KNIGHT_ALERT');
1069 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_DIE', GameWAD
+':MSOUNDS\SPIDER_DIE');
1070 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_ALERT', GameWAD
+':MSOUNDS\SPIDER_ALERT');
1071 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_WALK', GameWAD
+':MSOUNDS\SPIDER_WALK');
1073 g_Sound_CreateWADEx('SOUND_MONSTER_FISH_ATTACK', GameWAD
+':MSOUNDS\FISH_ATTACK');
1075 freeInds
:= TIdPool
.Create();
1077 monCheckTrapLastFrameId
:= 0;
1078 monCheckMPlatLastFrameId
:= 0;
1081 procedure g_Monsters_FreeData();
1083 e_WriteLog('Releasing monsters data...', TMsgType
.Notify
);
1085 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
1086 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
1087 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
1088 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
1089 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
1090 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
1091 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
1092 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
1093 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK_L');
1094 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
1095 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
1096 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
1097 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
1098 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
1099 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
1100 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK_L');
1101 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
1102 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
1103 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
1104 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
1105 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
1106 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
1107 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
1108 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
1109 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
1110 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
1111 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
1112 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
1113 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
1114 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
1115 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
1116 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
1117 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
1118 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
1119 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
1120 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
1121 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
1122 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
1123 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
1124 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
1125 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
1126 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
1127 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
1128 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
1129 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
1130 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
1131 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
1132 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
1133 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
1134 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
1135 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
1136 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
1137 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
1138 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
1139 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
1140 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
1141 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
1142 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
1143 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
1144 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
1145 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
1146 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
1147 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
1148 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
1149 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
1150 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
1151 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
1152 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
1153 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
1154 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
1155 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
1156 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
1157 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
1158 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
1159 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
1160 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
1161 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
1162 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
1163 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
1164 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
1165 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
1166 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
1167 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
1168 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
1169 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
1170 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
1171 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
1172 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
1173 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
1174 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
1175 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
1176 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
1177 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
1178 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
1179 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
1180 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
1181 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
1182 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
1183 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
1184 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
1185 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
1186 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
1187 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
1188 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
1189 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
1190 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
1191 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
1192 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
1193 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
1194 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
1195 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
1196 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
1197 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
1198 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
1199 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
1200 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
1201 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
1202 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
1203 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
1204 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
1205 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
1206 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
1207 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
1208 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
1209 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
1210 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
1211 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
1212 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
1213 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
1214 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
1215 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
1216 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
1217 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
1219 g_Sound_Delete('SOUND_MONSTER_BARREL_DIE');
1221 g_Sound_Delete('SOUND_MONSTER_PAIN');
1222 g_Sound_Delete('SOUND_MONSTER_PAIN2');
1223 g_Sound_Delete('SOUND_MONSTER_ACTION');
1224 g_Sound_Delete('SOUND_MONSTER_ACTION2');
1225 g_Sound_Delete('SOUND_MONSTER_ALERT_1');
1226 g_Sound_Delete('SOUND_MONSTER_ALERT_2');
1227 g_Sound_Delete('SOUND_MONSTER_ALERT_3');
1228 g_Sound_Delete('SOUND_MONSTER_DIE_1');
1229 g_Sound_Delete('SOUND_MONSTER_DIE_2');
1230 g_Sound_Delete('SOUND_MONSTER_DIE_3');
1231 g_Sound_Delete('SOUND_MONSTER_SLOP');
1233 g_Sound_Delete('SOUND_MONSTER_DEMON_ATTACK');
1234 g_Sound_Delete('SOUND_MONSTER_DEMON_ALERT');
1235 g_Sound_Delete('SOUND_MONSTER_DEMON_DIE');
1237 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_1');
1238 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_2');
1239 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_1');
1240 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_2');
1241 g_Sound_Delete('SOUND_MONSTER_IMP_ACTION');
1242 g_Sound_Delete('SOUND_MONSTER_IMP_ATTACK');
1244 g_Sound_Delete('SOUND_MONSTER_MAN_PAIN');
1245 g_Sound_Delete('SOUND_MONSTER_MAN_ALERT');
1246 g_Sound_Delete('SOUND_MONSTER_MAN_DIE');
1247 g_Sound_Delete('SOUND_MONSTER_HAHA');
1248 g_Sound_Delete('SOUND_MONSTER_TRUP');
1250 g_Sound_Delete('SOUND_MONSTER_SOUL_ATTACK');
1251 g_Sound_Delete('SOUND_MONSTER_SOUL_DIE');
1253 g_Sound_Delete('SOUND_MONSTER_BSP_ACTION');
1254 g_Sound_Delete('SOUND_MONSTER_BSP_DIE');
1255 g_Sound_Delete('SOUND_MONSTER_BSP_ALERT');
1256 g_Sound_Delete('SOUND_MONSTER_BSP_WALK');
1258 g_Sound_Delete('SOUND_MONSTER_VILE_ACTION');
1259 g_Sound_Delete('SOUND_MONSTER_VILE_PAIN');
1260 g_Sound_Delete('SOUND_MONSTER_VILE_DIE');
1261 g_Sound_Delete('SOUND_MONSTER_VILE_ALERT');
1262 g_Sound_Delete('SOUND_MONSTER_VILE_ATTACK');
1264 g_Sound_Delete('SOUND_MONSTER_SKEL_ACTION');
1265 g_Sound_Delete('SOUND_MONSTER_SKEL_DIE');
1266 g_Sound_Delete('SOUND_MONSTER_SKEL_ALERT');
1267 g_Sound_Delete('SOUND_MONSTER_SKEL_ATTACK');
1268 g_Sound_Delete('SOUND_MONSTER_SKEL_HIT');
1270 g_Sound_Delete('SOUND_MONSTER_MANCUB_PAIN');
1271 g_Sound_Delete('SOUND_MONSTER_MANCUB_DIE');
1272 g_Sound_Delete('SOUND_MONSTER_MANCUB_ALERT');
1273 g_Sound_Delete('SOUND_MONSTER_MANCUB_ATTACK');
1275 g_Sound_Delete('SOUND_MONSTER_PAIN_PAIN');
1276 g_Sound_Delete('SOUND_MONSTER_PAIN_DIE');
1277 g_Sound_Delete('SOUND_MONSTER_PAIN_ALERT');
1279 g_Sound_Delete('SOUND_MONSTER_BARON_DIE');
1280 g_Sound_Delete('SOUND_MONSTER_BARON_ALERT');
1282 g_Sound_Delete('SOUND_MONSTER_CACO_DIE');
1283 g_Sound_Delete('SOUND_MONSTER_CACO_ALERT');
1285 g_Sound_Delete('SOUND_MONSTER_CYBER_DIE');
1286 g_Sound_Delete('SOUND_MONSTER_CYBER_ALERT');
1287 g_Sound_Delete('SOUND_MONSTER_CYBER_WALK');
1289 g_Sound_Delete('SOUND_MONSTER_KNIGHT_DIE');
1290 g_Sound_Delete('SOUND_MONSTER_KNIGHT_ALERT');
1292 g_Sound_Delete('SOUND_MONSTER_SPIDER_DIE');
1293 g_Sound_Delete('SOUND_MONSTER_SPIDER_ALERT');
1294 g_Sound_Delete('SOUND_MONSTER_SPIDER_WALK');
1296 g_Sound_Delete('SOUND_MONSTER_FISH_ATTACK');
1302 procedure g_Monsters_Init();
1307 procedure g_Monsters_Free (clearGrid
: Boolean=true);
1311 e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid
]);
1317 for a
:= 0 to High(gMonsters
) do gMonsters
[a
].Free();
1320 monCheckTrapLastFrameId
:= 0;
1321 monCheckMPlatLastFrameId
:= 0;
1325 // will be called from map loader
1326 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
1329 monsGrid
:= TMonsterGrid
.Create(x
, y
, w
, h
);
1330 //clearUidMap(); // why not?
1331 e_LogWritefln('%s', ['Recreated monster tree']);
1335 function g_Monsters_Create(MonsterType
: Byte; X
, Y
: Integer;
1336 Direction
: TDirection
; AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
1343 // Íåò òàêîãî ìîíñòðà
1344 if (MonsterType
> MONSTER_MAN
) or (MonsterType
= 0) then exit
;
1346 // Ñîáëþäàåì îãðàíè÷åíèå Lost_Soul'îâ
1347 if MonsterType
= MONSTER_SOUL
then
1349 if soulcount
> MAX_SOUL
then exit
;
1350 soulcount
:= soulcount
+ 1;
1353 find_id
:= allocMonster();
1355 mon
:= TMonster
.Create(MonsterType
, find_id
, ForcedUID
);
1356 gMonsters
[find_id
] := mon
;
1357 mon
.mArrIdx
:= find_id
;
1360 uidMap
[mon
.FUID
] := mon
;
1362 // Íàñòðàèâàåì ïîëîæåíèå
1367 FObj
.X
:= X
-FObj
.Rect
.X
- (FObj
.Rect
.Width
div 2);
1368 FObj
.Y
:= Y
-FObj
.Rect
.Y
- FObj
.Rect
.Height
;
1372 FObj
.X
:= X
-FObj
.Rect
.X
;
1373 FObj
.Y
:= Y
-FObj
.Rect
.Y
;
1376 FDirection
:= Direction
;
1377 FStartDirection
:= Direction
;
1382 mon
.positionChanged();
1387 procedure g_Monsters_killedp();
1391 if gMonsters
= nil then
1394 // Ïðèêîëèñò ñìååòñÿ íàä ñìåðòüþ èãðîêà:
1395 h
:= High(gMonsters
);
1398 if (gMonsters
[a
] <> nil) then
1400 with gMonsters
[a
] do
1402 if (FMonsterType
= MONSTER_MAN
) and
1403 (FState
<> MONSTATE_DEAD
) and
1404 (FState
<> MONSTATE_SLEEP
) and
1405 (FState
<> MONSTATE_DIE
) then
1407 g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj
.X
, FObj
.Y
);
1415 procedure g_Monsters_Update();
1420 if gTime
mod (GAME_TICK
*2) = 0 then
1424 if abs(pt_x
) > 246 then pt_xs
:= -pt_xs
;
1425 if abs(pt_y
) > 100 then pt_ys
:= -pt_ys
;
1428 gMon
:= True; // Äëÿ ðàáîòû BlockMon'à
1430 if gmon_debug_think
or gmon_debug_one_think_step
then
1432 gmon_debug_one_think_step
:= false;
1433 for a
:= 0 to High(gMonsters
) do
1435 if (gMonsters
[a
] = nil) then continue
;
1436 if not gMonsters
[a
].FRemoved
then
1438 if g_Game_IsClient
then
1439 gMonsters
[a
].ClientUpdate()
1441 gMonsters
[a
].Update();
1445 gMonsters
[a
].Free();
1446 gMonsters
[a
] := nil;
1454 procedure g_Monsters_Draw();
1458 if gMonsters
<> nil then
1460 for a
:= 0 to High(gMonsters
) do
1462 if (gMonsters
[a
] <> nil) then gMonsters
[a
].Draw();
1467 procedure g_Monsters_DrawHealth();
1472 if gMonsters
= nil then Exit
;
1473 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1475 for a
:= 0 to High(gMonsters
) do
1477 if gMonsters
[a
] <> nil then
1479 e_TextureFontPrint(gMonsters
[a
].FObj
.X
+ gMonsters
[a
].FObj
.Rect
.X
,
1480 gMonsters
[a
].FObj
.Y
+ gMonsters
[a
].FObj
.Rect
.Y
+ gMonsters
[a
].FObj
.Rect
.Height
- fH
,
1481 IntToStr(gMonsters
[a
].FHealth
), gStdFont
);
1486 function g_Monsters_ByUID (UID
: Word): TMonster
;
1488 result
:= uidMap
[UID
];
1491 procedure g_Monsters_SaveState (st
: TStream
);
1495 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ìîíñòðîâ
1497 for i
:= 0 to High(gMonsters
) do
1499 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then count
+= 1;
1502 // Ñîõðàíÿåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1503 utils
.writeInt(st
, LongInt(pt_x
));
1504 utils
.writeInt(st
, LongInt(pt_xs
));
1505 utils
.writeInt(st
, LongInt(pt_y
));
1506 utils
.writeInt(st
, LongInt(pt_ys
));
1508 // Êîëè÷åñòâî ìîíñòðîâ
1509 utils
.writeInt(st
, LongInt(count
));
1511 if (count
= 0) then exit
;
1513 // Ñîõðàíÿåì ìîíñòðîâ
1514 for i
:= 0 to High(gMonsters
) do
1516 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then
1519 utils
.writeInt(st
, Byte(gMonsters
[i
].MonsterType
));
1520 // Ñîõðàíÿåì äàííûå ìîíñòðà:
1521 gMonsters
[i
].SaveState(st
);
1527 procedure g_Monsters_LoadState (st
: TStream
);
1535 g_Monsters_Free(false);
1537 // Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1538 pt_x
:= utils
.readLongInt(st
);
1539 pt_xs
:= utils
.readLongInt(st
);
1540 pt_y
:= utils
.readLongInt(st
);
1541 pt_ys
:= utils
.readLongInt(st
);
1543 // Êîëè÷åñòâî ìîíñòðîâ
1544 count
:= utils
.readLongInt(st
);
1546 if (count
= 0) then exit
;
1547 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid monster count');
1549 // Çàãðóæàåì ìîíñòðîâ
1550 for a
:= 0 to count
-1 do
1553 b
:= utils
.readByte(st
);
1555 mon
:= g_Monsters_Create(b
, 0, 0, TDirection
.D_LEFT
);
1556 if (mon
= nil) then raise XStreamError
.Create('g_Monsters_LoadState: ID = -1 (can''t create)');
1557 // Çàãðóæàåì äàííûå ìîíñòðà
1563 // ////////////////////////////////////////////////////////////////////////// //
1564 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1567 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1569 result
:= g_Monsters_Create(monType
, x
, y
, dir
);
1574 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1576 result
:= g_Mons_SpawnAt(g_Mons_TypeIdByName(typeName
), x
, y
, dir
);
1581 // ////////////////////////////////////////////////////////////////////////// //
1582 function g_Mons_TypeLo (): Integer; inline; begin result
:= Low(MONSTERTABLE
); end;
1583 function g_Mons_TypeHi (): Integer; inline; begin result
:= High(MONSTERTABLE
); end;
1586 function g_Mons_TypeIdByName (const name
: String): Integer;
1591 while (i
<= MONSTER_MAN
) do
1593 if (CompareText(name
, MONSTERTABLE
[i
].Name
) = 0) then
1602 if (CompareText(name
, 'zombie') = 0) then result
:= MONSTER_ZOMBY
;
1606 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
1608 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1609 result
:= MONSTERTABLE
[monType
].Name
1615 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
1617 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1618 Result
:= KilledByMonster
[monType
]
1624 // ////////////////////////////////////////////////////////////////////////// //
1625 { T M o n s t e r : }
1627 procedure TMonster
.setGameX (v
: Integer); inline; begin FObj
.X
:= v
; positionChanged(); end;
1628 procedure TMonster
.setGameY (v
: Integer); inline; begin FObj
.Y
:= v
; positionChanged(); end;
1630 procedure TMonster
.setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline; begin FObj
.X
:= ax
; FObj
.Y
:= ay
; if callPosChanged
then positionChanged(); end;
1632 procedure TMonster
.moveBy (dx
, dy
: Integer); inline;
1634 if (dx
<> 0) or (dy
<> 0) then
1642 procedure TMonster
.doDamage (v
: Integer);
1644 if (v
<= 0) then exit
;
1645 if (v
> 32767) then v
:= 32767;
1646 Damage(v
, 0, 0, 0, mEDamageType
);
1649 procedure TMonster
.ActionSound();
1651 case FMonsterType
of
1653 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ACTION', FObj
.X
, FObj
.Y
);
1654 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
,
1656 g_Sound_PlayExAt('SOUND_MONSTER_ACTION', FObj
.X
, FObj
.Y
);
1657 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1658 MONSTER_KNIGHT
, MONSTER_PAIN
, MONSTER_DEMON
,
1660 g_Sound_PlayExAt('SOUND_MONSTER_ACTION2', FObj
.X
, FObj
.Y
);
1662 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ACTION', FObj
.X
, FObj
.Y
);
1664 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ACTION', FObj
.X
, FObj
.Y
);
1666 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ACTION', FObj
.X
, FObj
.Y
);
1670 g_Sound_PlayExAt('SOUND_MONSTER_HAHA', FObj
.X
, FObj
.Y
);
1674 procedure TMonster
.PainSound();
1682 case FMonsterType
of
1683 MONSTER_IMP
, MONSTER_ZOMBY
, MONSTER_SERG
,
1684 MONSTER_SKEL
, MONSTER_CGUN
:
1685 g_Sound_PlayExAt('SOUND_MONSTER_PAIN', FObj
.X
, FObj
.Y
);
1686 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1687 MONSTER_KNIGHT
, MONSTER_DEMON
, MONSTER_SPIDER
,
1688 MONSTER_BSP
, MONSTER_CYBER
:
1689 g_Sound_PlayExAt('SOUND_MONSTER_PAIN2', FObj
.X
, FObj
.Y
);
1691 g_Sound_PlayExAt('SOUND_MONSTER_VILE_PAIN', FObj
.X
, FObj
.Y
);
1693 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_PAIN', FObj
.X
, FObj
.Y
);
1695 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_PAIN', FObj
.X
, FObj
.Y
);
1697 g_Sound_PlayExAt('SOUND_MONSTER_MAN_PAIN', FObj
.X
, FObj
.Y
);
1701 procedure TMonster
.DieSound();
1703 case FMonsterType
of
1706 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_1', FObj
.X
, FObj
.Y
);
1707 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_2', FObj
.X
, FObj
.Y
);
1709 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1711 0: g_Sound_PlayExAt('SOUND_MONSTER_DIE_1', FObj
.X
, FObj
.Y
);
1712 1: g_Sound_PlayExAt('SOUND_MONSTER_DIE_2', FObj
.X
, FObj
.Y
);
1713 2: g_Sound_PlayExAt('SOUND_MONSTER_DIE_3', FObj
.X
, FObj
.Y
);
1716 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_DIE', FObj
.X
, FObj
.Y
);
1718 g_Sound_PlayExAt('SOUND_MONSTER_BARREL_DIE', FObj
.X
, FObj
.Y
);
1720 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_DIE', FObj
.X
, FObj
.Y
);
1722 g_Sound_PlayExAt('SOUND_MONSTER_BSP_DIE', FObj
.X
, FObj
.Y
);
1724 g_Sound_PlayExAt('SOUND_MONSTER_VILE_DIE', FObj
.X
, FObj
.Y
);
1726 g_Sound_PlayExAt('SOUND_MONSTER_BARON_DIE', FObj
.X
, FObj
.Y
);
1728 g_Sound_PlayExAt('SOUND_MONSTER_CACO_DIE', FObj
.X
, FObj
.Y
);
1730 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_DIE', FObj
.X
, FObj
.Y
);
1732 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_DIE', FObj
.X
, FObj
.Y
);
1734 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_DIE', FObj
.X
, FObj
.Y
);
1736 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_DIE', FObj
.X
, FObj
.Y
);
1738 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_DIE', FObj
.X
, FObj
.Y
);
1740 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_DIE', FObj
.X
, FObj
.Y
);
1742 g_Sound_PlayExAt('SOUND_MONSTER_MAN_DIE', FObj
.X
, FObj
.Y
);
1746 procedure TMonster
.WakeUpSound();
1748 case FMonsterType
of
1751 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_1', FObj
.X
, FObj
.Y
);
1752 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_2', FObj
.X
, FObj
.Y
);
1754 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1756 0: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_1', FObj
.X
, FObj
.Y
);
1757 1: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_2', FObj
.X
, FObj
.Y
);
1758 2: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_3', FObj
.X
, FObj
.Y
);
1761 g_Sound_PlayExAt('SOUND_MONSTER_MAN_ALERT', FObj
.X
, FObj
.Y
);
1763 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ALERT', FObj
.X
, FObj
.Y
);
1765 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ALERT', FObj
.X
, FObj
.Y
);
1767 g_Sound_PlayExAt('SOUND_MONSTER_BARON_ALERT', FObj
.X
, FObj
.Y
);
1769 g_Sound_PlayExAt('SOUND_MONSTER_CACO_ALERT', FObj
.X
, FObj
.Y
);
1771 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_ALERT', FObj
.X
, FObj
.Y
);
1773 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_ALERT', FObj
.X
, FObj
.Y
);
1775 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ALERT', FObj
.X
, FObj
.Y
);
1777 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_ALERT', FObj
.X
, FObj
.Y
);
1779 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ALERT', FObj
.X
, FObj
.Y
);
1781 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ALERT', FObj
.X
, FObj
.Y
);
1783 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_ALERT', FObj
.X
, FObj
.Y
);
1789 procedure TMonster
.BFGHit();
1791 if FMonsterType
= MONSTER_FISH
then
1794 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1795 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1796 {if g_Game_IsServer and g_Game_IsNet then
1797 MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
1798 FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
1802 function TMonster
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
1804 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1812 function TMonster
.Collide(Panel
: TPanel
): Boolean;
1814 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1819 Panel
.Width
, Panel
.Height
);
1822 function TMonster
.Collide(X
, Y
: Integer): Boolean;
1824 X
:= X
- FObj
.X
- FObj
.Rect
.X
;
1825 Y
:= Y
- FObj
.Y
- FObj
.Rect
.Y
;
1826 Result
:= (x
>= 0) and (x
<= FObj
.Rect
.Width
) and
1827 (y
>= 0) and (y
<= FObj
.Rect
.Height
);
1830 procedure TMonster
.Respawn
;
1836 FDirection
:= FStartDirection
;
1837 {GameX}FObj
.X
:= FStartX
;
1838 {GameY}FObj
.Y
:= FStartY
;
1839 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
1840 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
1845 FDieTriggers
:= nil;
1846 FWaitAttackAnim
:= False;
1847 FChainFire
:= False;
1850 FState
:= MONSTATE_SLEEP
;
1851 FCurAnim
:= ANIM_SLEEP
;
1853 positionChanged(); // this updates spatial accelerators
1855 if g_Game_IsNet
and g_Game_IsServer
then
1857 MH_SEND_MonsterPos(FUID
);
1858 MH_SEND_MonsterState(FUID
);
1862 constructor TMonster
.Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
1865 FramesID
: DWORD
= 0;
1869 if ForcedUID
< 0 then
1870 FUID
:= g_CreateUID(UID_MONSTER
)
1874 FMonsterType
:= MonsterType
;
1878 FState
:= MONSTATE_SLEEP
;
1879 FCurAnim
:= ANIM_SLEEP
;
1880 FHealth
:= MONSTERTABLE
[MonsterType
].Health
;
1881 FMaxHealth
:= FHealth
;
1882 FObj
.Rect
:= MONSTERTABLE
[MonsterType
].Rect
;
1883 FDieTriggers
:= nil;
1884 FSpawnTrigger
:= -1;
1885 FWaitAttackAnim
:= False;
1886 FChainFire
:= False;
1888 FNoRespawn
:= False;
1890 FBehaviour
:= BH_NORMAL
;
1894 mEDamageType
:= HIT_SOME
;
1898 trapCheckFrameId
:= 0;
1899 mplatCheckFrameId
:= 0;
1902 if FMonsterType
in [MONSTER_ROBO
, MONSTER_BARREL
] then
1903 FBloodKind
:= BLOOD_SPARKS
1905 FBloodKind
:= BLOOD_NORMAL
;
1906 if FMonsterType
= MONSTER_CACO
then
1912 else if FMonsterType
in [MONSTER_BARON
, MONSTER_KNIGHT
] then
1925 SetLength(FAnim
, Length(ANIMTABLE
));
1927 for a
:= 0 to High(FAnim
) do
1929 FAnim
[a
, TDirection
.D_LEFT
] := nil;
1930 FAnim
[a
, TDirection
.D_RIGHT
] := nil;
1933 for a
:= ANIM_SLEEP
to ANIM_PAIN
do
1934 if (ANIMTABLE
[a
].name
<> '') and
1935 (MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
] <> 0) then
1937 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1938 '_'+ANIMTABLE
[a
].name
;
1940 res
:= g_Frames_Exists(s
);
1943 res
:= g_Frames_Get(FramesID
, s
);
1945 // Åñëè íåò òàêîé àíèìàöèè, òî ïðîáóåì çàìåíèòü åå íà àíèìàöèþ ñìåðòè:
1948 // Çàìåíÿåì òîëüêî ANIM_MESS íà ANIM_DIE:
1949 if a
<> ANIM_MESS
then
1952 if g_Frames_Get(FramesID
, 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1953 '_'+ANIMTABLE
[ANIM_DIE
].name
) then
1955 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1956 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1957 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1958 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1963 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1964 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1966 // Åñëè åñòü îòäåëüíàÿ ëåâàÿ àíèìàöèÿ - çàãðóæàåì:
1967 if MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
then
1969 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1970 '_'+ANIMTABLE
[a
].name
+'_L';
1971 if g_Frames_Exists(s
) then
1972 g_Frames_Get(FramesID
, s
);
1975 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1976 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1979 // Äëÿ êîëäóíà çàãðóæàåì òàêæå àíèìàöèþ îãíÿ:
1980 if MonsterType
= MONSTER_VILE
then
1982 g_Frames_Get(FramesID
, 'FRAMES_FIRE');
1983 vilefire
:= TAnimation
.Create(FramesID
, True, 2);
1989 function TMonster
.Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
1996 // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
1997 if (FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_REVIVE
) then
2000 // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà:
2001 if (t
= HIT_ELECTRO
) and (FMonsterType
= MONSTER_FISH
) and g_Game_IsServer
then
2004 if Random(2) = 0 then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
2006 SetState(MONSTATE_RUN
);
2010 // Àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
2011 if (t
= HIT_FLAME
) and (FMonsterType
in [MONSTER_VILE
, MONSTER_SOUL
]) then
2013 // Ïðîñíóòüñÿ âñå-òàêè ñòîèò
2014 if FState
= MONSTATE_SLEEP
then
2015 SetState(MONSTATE_GO
);
2019 // Ëîâóøêà óáèâàåò ñðàçó:
2020 if t
= HIT_TRAP
then
2023 // Ðîáîòó óðîíà íåò:
2024 if FMonsterType
= MONSTER_ROBO
then
2028 if g_Game_IsServer
then Dec(FHealth
, aDamage
);
2030 // Óñèëèâàåì áîëü ìîíñòðà îò óðîíà:
2033 FPain
:= FPain
+aDamage
;
2035 // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå:
2036 if FState
<> MONSTATE_PAIN
then
2037 if (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) and
2038 (FMonsterType
<> MONSTER_BARREL
) then
2039 SetState(MONSTATE_PAIN
);
2041 // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè:
2042 if (gBloodCount
> 0) then
2044 c
:= Min(aDamage
, 200);
2045 c
:= c
*gBloodCount
- (aDamage
div 4) + Random(c
div 2);
2047 if (VelX
= 0) and (VelY
= 0) then
2051 HIT_TRAP
, HIT_ACID
, HIT_ELECTRO
, HIT_FLAME
: MakeBloodSimple(c
);
2052 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, VelX
, VelY
);
2056 // Òåïåðü öåëü - óäàðèâøèé, åñëè òîëüêî íå ñàì ñåáÿ:
2057 if (SpawnerUID
<> FUID
) and (BehaviourDamage(SpawnerUID
, FBehaviour
, FMonsterType
)) then
2059 FTargetUID
:= SpawnerUID
;
2063 // Çäîðîâüå çàêîí÷èëîñü:
2064 if FHealth
<= 0 then
2066 // Åñëè ýòî íå áî÷êà è óáèë èãðîê, òî åìó +1:
2067 if (FMonsterType
<> MONSTER_BARREL
) then
2069 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2071 p
:= g_Player_Get(SpawnerUID
);
2072 if (p
<> nil) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2074 p
.MonsterKills
:= p
.MonsterKills
+1;
2075 if gGameSettings
.GameMode
= GM_COOP
then
2076 p
.Frags
:= p
.Frags
+ 1;
2077 // Uncomment this if you want to double-kill monsters
2081 if gLMSRespawn
= LMS_RESPAWN_NONE
then
2083 Inc(gCoopMonstersKilled
);
2084 if g_Game_IsNet
then
2090 case FMonsterType
of
2091 MONSTER_ZOMBY
: c
:= ITEM_AMMO_BULLETS
;
2092 MONSTER_SERG
: c
:= ITEM_WEAPON_SHOTGUN1
;
2093 MONSTER_CGUN
: c
:= ITEM_WEAPON_CHAINGUN
;
2094 MONSTER_MAN
: c
:= ITEM_KEY_RED
;
2101 it
:= g_Items_Create(FObj
.X
+ (FObj
.Rect
.Width
div 2),
2102 FObj
.Y
+ (FObj
.Rect
.Height
div 2),
2104 g_Items_SetDrop(it
); // mark it as monster drop
2105 g_Obj_Push(g_Items_ObjByIdx(it
), (FObj
.Vel
.X
div 2)-3+Random(7),
2106 (FObj
.Vel
.Y
div 2)-Random(4));
2107 //positionChanged(); // this updates spatial accelerators
2108 if g_Game_IsServer
and g_Game_IsNet
then
2109 MH_SEND_ItemSpawn(True, it
);
2112 // Òðóï äàëüøå íå èäåò:
2115 // Ó òðóïà ðàçìåðû ìåíüøå:
2116 if (FMonsterType
<> MONSTER_FISH
) and (FMonsterType
<> MONSTER_PAIN
) then
2118 FObj
.Rect
.Y
:= FObj
.Rect
.Y
+ FObj
.Rect
.Height
-12;
2119 FObj
.Rect
.Height
:= 12;
2123 // Óðîí áûë ñèëüíûì => ñëàáûå - â êàøó:
2124 if (FHealth
<= -30) and
2125 ((FMonsterType
= MONSTER_IMP
) or (FMonsterType
= MONSTER_ZOMBY
) or
2126 (FMonsterType
= MONSTER_SERG
) or (FMonsterType
= MONSTER_CGUN
) or
2127 (FMonsterType
= MONSTER_MAN
)) then
2129 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
2130 SetState(MONSTATE_DIE
, ANIM_MESS
);
2135 SetState(MONSTATE_DIE
);
2138 // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà:
2139 if g_Game_IsServer
then ActivateTriggers();
2144 if FState
= MONSTATE_SLEEP
then
2145 begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì:
2146 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2147 SetState(MONSTATE_GO
);
2150 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2154 function TMonster
.Heal(Value
: Word): Boolean;
2157 if g_Game_IsClient
then
2162 if FHealth
< FMaxHealth
then
2164 IncMax(FHealth
, Value
, FMaxHealth
);
2165 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2170 destructor TMonster
.Destroy();
2174 for a
:= 0 to High(FAnim
) do
2176 FAnim
[a
, TDirection
.D_LEFT
].Free();
2177 FAnim
[a
, TDirection
.D_RIGHT
].Free();
2182 if (mProxyId
<> -1) then
2184 if (monsGrid
<> nil) then
2186 monsGrid
.removeBody(mProxyId
);
2187 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
2188 e_WriteLog(Format('monster #%d:(%u): removed from grid; mProxyid=%d', [mArrIdx
, UID
, mProxyId
]), MSG_NOTIFY
);
2194 if (mArrIdx
<> -1) and (mArrIdx
< Length(gMonsters
)) then
2196 freeInds
.release(mArrIdx
);
2197 gMonsters
[mArrIdx
] := nil;
2201 uidMap
[FUID
] := nil;
2203 inherited Destroy();
2206 procedure TMonster
.Draw();
2212 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType));
2213 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState));
2215 // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
2216 if FMonsterType
= MONSTER_VILE
then
2217 if FState
= MONSTATE_SHOOT
then
2218 if GetPos(FTargetUID
, @o
) then
2219 vilefire
.Draw(o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-32,
2220 o
.Y
+o
.Rect
.Y
+o
.Rect
.Height
-128, TMirrorType
.None
);
2222 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
2224 if (g_dbg_scale
= 1.0) then
2226 if not g_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
,
2227 sX
-128, sY
-128, sWidth
+256, sHeight
+256) then
2231 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
2232 if FState
= MONSTATE_DEAD
then
2233 case FMonsterType
of
2234 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
2237 // Åñòü ÷òî ðèñîâàòü ïðè òåêóùåì ïîâåäåíèè:
2238 if FAnim
[FCurAnim
, FDirection
] <> nil then
2240 // Åñëè íåò ëåâîé àíèìàöèè èëè îíà ñîâïàäàåò ñ ïðàâîé => îòðàæàåì ïðàâóþ:
2241 if (FDirection
= TDirection
.D_LEFT
) and
2242 ((not MONSTER_ANIMTABLE
[FMonsterType
].LeftAnim
) or
2243 (FAnim
[FCurAnim
, TDirection
.D_LEFT
].FramesID
= FAnim
[FCurAnim
, TDirection
.D_RIGHT
].FramesID
)) and
2244 (FMonsterType
<> MONSTER_BARREL
) then
2245 m
:= TMirrorType
.Horizontal
2247 m
:= TMirrorType
.None
;
2249 // Ëåâàÿ àíèìàöèÿ => ìåíÿåì ñìåùåíèå îòíîñèòåëüíî öåíòðà:
2250 if (FDirection
= TDirection
.D_LEFT
) and
2251 (FMonsterType
<> MONSTER_BARREL
) then
2253 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].X
;
2254 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].Y
;
2256 if m
= TMirrorType
.Horizontal
then
2257 begin // Íåò îòäåëüíîé ëåâîé àíèìàöèè
2258 // Ðàññòîÿíèå îò êðàÿ òåêñòóðû äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2259 c
:= (MONSTERTABLE
[FMonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[FMonsterType
].Rect
.Width
;
2260 // Ðàññòîÿíèå îò êðàÿ õèò áîêñà äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2261 dx
:= FAnim
[FCurAnim
, FDirection
].Width
- c
- MONSTERTABLE
[FMonsterType
].Rect
.X
;
2262 // Ò.ê. äâèãàòü òåêñòóðó íóæíî áóäåò â ïðîòèâîïîëîæíîì íàïðàâëåíèè:
2264 // Ýòî çíà÷èò: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
2267 else // Ïðàâàÿ àíèìàöèÿ
2269 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].X
;
2270 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].Y
;
2274 FAnim
[FCurAnim
, FDirection
].Draw(Obj
.X
+dx
, Obj
.Y
+dy
, m
);
2277 if g_debug_Frames
then
2279 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2281 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2282 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2287 procedure TMonster
.MakeBloodSimple(Count
: Word);
2289 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+8,
2290 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2291 Count
div 2, 3, -1, 16, (FObj
.Rect
.Height
*2 div 3),
2292 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2293 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-8,
2294 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2295 Count
div 2, -3, -1, 16, (FObj
.Rect
.Height
*2) div 3,
2296 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2299 procedure TMonster
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
2301 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2302 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2303 Count
, VelX
, VelY
, 16, (FObj
.Rect
.Height
*2) div 3,
2304 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2307 procedure TMonster
.Push(vx
, vy
: Integer);
2309 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
2310 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
2311 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2314 procedure TMonster
.SetState(State
: Byte; ForceAnim
: Byte = 255);
2318 // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul,
2319 // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ:
2320 if (State
= MONSTATE_DIE
) and (MonsterType
= MONSTER_SOUL
) then
2321 soulcount
:= soulcount
-1;
2323 // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü:
2325 MONSTATE_DIE
, MONSTATE_DEAD
, MONSTATE_REVIVE
:
2326 if (State
<> MONSTATE_DEAD
) and (State
<> MONSTATE_REVIVE
) and
2327 (State
<> MONSTATE_GO
) then
2334 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
, ForceAnim
);
2336 // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè:
2338 MONSTATE_SLEEP
: Anim
:= ANIM_SLEEP
;
2339 MONSTATE_PAIN
: Anim
:= ANIM_PAIN
;
2340 MONSTATE_WAIT
: Anim
:= ANIM_SLEEP
;
2341 MONSTATE_CLIMB
, MONSTATE_RUN
, MONSTATE_RUNOUT
, MONSTATE_GO
: Anim
:= ANIM_GO
;
2342 MONSTATE_SHOOT
: Anim
:= ANIM_ATTACK
;
2343 MONSTATE_ATTACK
: Anim
:= ANIM_ATTACK
;
2344 MONSTATE_DIE
: Anim
:= ANIM_DIE
;
2346 begin // íà÷àëè âîñðåøàòüñÿ
2348 FAnim
[Anim
, FDirection
].Revert(True);
2350 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
2351 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
2358 // Íàäî ñìåíèòü àíèìàöèþ íà íåñòàíäàðòíóþ:
2359 if ForceAnim
<> 255 then
2362 // Åñëè àíèìàöèÿ íîâàÿ - ïåðåçàïóñêàåì å¸:
2363 if FCurAnim
<> Anim
then
2364 if FAnim
[Anim
, FDirection
] <> nil then
2366 FAnim
[Anim
, FDirection
].Reset();
2371 function TMonster
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
2378 //  òî÷êå íàçíà÷åíèÿ ñòåíà:
2379 if g_CollideLevel(X
, Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
) then
2381 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
2382 if g_Game_IsServer
and g_Game_IsNet
then
2383 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
2389 // Ýôôåêò òåëåïîðòà â ïîçèöèè ìîíñòðà:
2392 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
2393 TA
:= TAnimation
.Create(FramesID
, False, 6);
2394 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj
.X
, Obj
.Y
);
2395 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2396 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2398 if g_Game_IsServer
and g_Game_IsNet
then
2399 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2400 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 1,
2404 FObj
.X
:= X
- FObj
.Rect
.X
;
2405 FObj
.Y
:= Y
- FObj
.Rect
.Y
;
2409 FDirection
:= TDirection
.D_LEFT
2412 FDirection
:= TDirection
.D_RIGHT
2416 if FDirection
= TDirection
.D_RIGHT
then
2417 FDirection
:= TDirection
.D_LEFT
2419 FDirection
:= TDirection
.D_RIGHT
;
2422 // Ýôôåêò òåëåïîðòà â òî÷êå íàçíà÷åíèÿ:
2423 if not silent
and (TA
<> nil) then
2425 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2426 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2429 if g_Game_IsServer
and g_Game_IsNet
then
2430 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2431 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 0,
2435 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2439 procedure TMonster
.Update();
2441 a
, b
, sx
, sy
, wx
, wy
, oldvelx
: Integer;
2447 it
: TMonsterGrid
.Iter
;
2453 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
2454 if FMonsterType
= MONSTER_FISH
then
2455 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
2456 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2459 // Ëåòàþùèå ìîíòñðû:
2460 if ((FMonsterType
= MONSTER_SOUL
) or
2461 (FMonsterType
= MONSTER_PAIN
) or
2462 (FMonsterType
= MONSTER_CACO
)) and
2463 (FState
<> MONSTATE_DIE
) and
2464 (FState
<> MONSTATE_DEAD
) then
2467 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
2468 if gTime
mod (GAME_TICK
*2) <> 0 then
2470 g_Obj_Move(@FObj
, fall
, True, True);
2471 positionChanged(); // this updates spatial accelerators
2475 if FPainTicks
> 0 then
2478 FPainSound
:= False;
2481 st
:= g_Obj_Move(@FObj
, fall
, True, True);
2482 positionChanged(); // this updates spatial accelerators
2484 // Åñëè ãîðèì - ïîäæèãàåì äðóãèõ ìîíñòðîâ, íî íå íà 100 òèêîâ êàæäûé ðàç:
2485 if FFireTime
> 0 then
2487 it
:= monsGrid
.forEachInAABB(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
2489 if mit
.UID
<> FUID
then
2490 mit
.CatchFire(FFireAttacker
, FFireTime
);
2493 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
2494 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
2495 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
2498 if alive
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2500 Inc(gCoopMonstersKilled
);
2501 if g_Game_IsNet
then
2508 oldvelx
:= FObj
.Vel
.X
;
2510 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
2511 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
2512 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2514 if FFireTime
> 0 then
2516 if WordBool(st
and MOVE_INWATER
) then
2521 FFireTime
:= FFireTime
- 1;
2522 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2523 if FFirePainTime
= 0 then
2525 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
2526 FFirePainTime
:= 18;
2529 FFirePainTime
:= FFirePainTime
- 1;
2533 // Ìåðòâûé íè÷åãî íå äåëàåò:
2534 if (FState
= MONSTATE_DEAD
) then
2537 // AI ìîíñòðîâ âûêëþ÷åí:
2538 if g_debug_MonsterOff
then
2541 if FState
<> MONSTATE_SLEEP
then
2542 SetState(MONSTATE_SLEEP
);
2545 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
2546 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
2547 case FMonsterType
of
2549 if Random(4) = 0 then
2550 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2551 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2552 MONSTER_ROBO
, MONSTER_BARREL
:
2553 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2554 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2556 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
2557 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
2558 if Random(2) = 0 then
2559 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
2561 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
2565 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
2566 if FMonsterType
= MONSTER_BARREL
then
2568 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
2569 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
2570 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2571 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
2575 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
2576 if FMonsterType
= MONSTER_SOUL
then
2577 if WordBool(st
and MOVE_HITAIR
) then
2578 g_Obj_SetSpeed(@FObj
, 16);
2583 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
2584 if FObj
.Vel
.Y
< 0 then
2585 if WordBool(st
and MOVE_INWATER
) then
2588 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
2589 FTargetTime
:= FTargetTime
+ 1;
2592 if FShellTimer
> -1 then
2593 if FShellTimer
= 0 then
2595 if FShellType
= SHELL_SHELL
then
2596 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2597 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2598 GameVelX
, GameVelY
-2, SHELL_SHELL
)
2599 else if FShellType
= SHELL_DBLSHELL
then
2601 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2602 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2603 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
2604 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2605 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2606 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
2609 end else Dec(FShellTimer
);
2611 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
2613 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
2614 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
2615 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2616 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
2617 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2618 (FObj
.Accel
.Y
= 0) then
2619 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2622 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
2624 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
2625 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
2627 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2628 if gSoundEffectsDF
then PainSound();
2630 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
2633 // Ñíèæàåì áîëü ñî âðåìåíåì:
2636 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
2637 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
2641 SetState(MONSTATE_GO
);
2645 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
2648 FSleep
:= FSleep
+ 1;
2650 // Ïðîñïàëè äîñòàòî÷íî:
2651 if FSleep
>= 18 then
2656 // Íà èãðîêîâ èäóò òîëüêî îáû÷íûå ìîíñòðû, êèëëåðû è ìàíüÿêè
2657 if (FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_KILLER
) or (FBehaviour
= BH_MANIAC
) then
2658 // Åñëè åñòü èãðîê ðÿäîì, ïðîñûïàåìñÿ è èäåì ê íåìó:
2659 if (gPlayers
<> nil) then
2660 for a
:= 0 to High(gPlayers
) do
2661 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
2662 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
2664 if g_Look(@FObj
, @Obj
, FDirection
) then
2666 FTargetUID
:= gPlayers
[a
].UID
;
2669 SetState(MONSTATE_GO
);
2673 // Íà ìîíñòðîâ òÿíåò ìàíüÿêîâ, ïîåõàâøèõ è êàííèáàëîâ
2674 if (FTargetUID
= 0) and ((FBehaviour
= BH_MANIAC
)
2675 or (FBehaviour
= BH_INSANE
) or (FBehaviour
= BH_CANNIBAL
)) then
2676 // Åñëè åñòü ïîäõîäÿùèé ìîíñòð ðÿäîì:
2677 if gMonsters
<> nil then
2678 for a
:= 0 to High(gMonsters
) do
2679 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
2680 (gMonsters
[a
].FUID
<> FUID
) then
2682 // Ìàíüÿêè íàïàäàþò íà âñåõ ìîíñòðîâ, êðîìå äðóçåé
2683 if (FBehaviour
= BH_MANIAC
) and
2684 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2686 // Ïîåõàâøèå òàêæå, íî ìîãóò îáîçëèòüñÿ íà áî÷êó
2687 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
) and
2688 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2690 // Êàííèáàëû íàïàäàþò íà ñåáå ïîäîáíûõ
2691 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
2693 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
2695 FTargetUID
:= gMonsters
[a
].UID
;
2698 SetState(MONSTATE_GO
);
2704 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
2707 FSleep
:= FSleep
- 1;
2709 // Âûæäàëè äîñòàòî÷íî - èäåì:
2711 SetState(MONSTATE_GO
);
2714 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
2716 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2717 if WordBool(st
and MOVE_BLOCK
) then
2721 SetState(MONSTATE_RUNOUT
);
2726 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
2727 if (FMonsterType
= MONSTER_VILE
) then
2728 if isCorpse(@FObj
, False) <> -1 then
2731 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
2736 // Öåëü ïîãèáëà èëè äàâíî æäåì:
2737 if (not GetPos(FTargetUID
, @o
)) or (FTargetTime
> MAX_ATM
) then
2738 if not findNewPrey() then
2739 begin // Íîâûõ öåëåé íåò
2747 o
.Rect
:= _Rect(0, 0, 0, 1);
2749 else // Íîâàÿ öåëü åñòü - áåðåì åå êîîðäèíàòû
2750 GetPos(FTargetUID
, @o
);
2752 // Öåëü î÷åíü áëèçêî - ïèíàåì:
2753 if g_Obj_Collide(@FObj
, @o
) and (FTargetUID
<> 0) then
2756 if (FMonsterType
<> MONSTER_CYBER
) or (Random(2) = 0) then
2763 // Ðàññòîÿíèå äî öåëè:
2764 sx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
2765 sy
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2767 // Ïîâîðà÷èâàåìñÿ â ñòîðîíó öåëè:
2769 FDirection
:= TDirection
.D_RIGHT
2771 FDirection
:= TDirection
.D_LEFT
;
2773 // Åñëè ìîíñòð óìååò ñòðåëÿòü è åñòü ïî êîìó - ñòðåëÿåì:
2774 if canShoot(FMonsterType
) and (FTargetUID
<> 0) then
2775 if Abs(sx
) > Abs(sy
) then // óãîë âûñòðåëà óäîáíûé
2776 if shoot(@o
, False) then
2779 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
2780 if Abs(sx
) < 40 then
2781 if FMonsterType
<> MONSTER_FISH
then
2784 SetState(MONSTATE_RUN
);
2785 if Random(2) = 0 then
2786 FDirection
:= TDirection
.D_LEFT
2788 FDirection
:= TDirection
.D_RIGHT
;
2793 // Óïåðëèñü â ñòåíó:
2794 if WordBool(st
and MOVE_HITWALL
) then
2796 if g_Triggers_PressR(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
,
2797 FObj
.Rect
.Height
, FUID
, ACTIVATE_MONSTERPRESS
) <> nil then
2798 begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå
2800 SetState(MONSTATE_WAIT
);
2805 case FMonsterType
of
2806 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
2808 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2809 (FObj
.Accel
.Y
= 0) then
2810 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
2811 // Ïðûæîê ÷åðåç ñòåíó:
2812 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2813 SetState(MONSTATE_CLIMB
);
2820 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
2821 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
2822 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
2824 if FMonsterType
= MONSTER_FISH
then
2826 if not WordBool(st
and MOVE_INWATER
) then
2827 begin // Ðûáà âíå âîäû:
2828 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2829 begin // "Ñòîèò" òâåðäî
2830 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
2831 if FObj
.Accel
.Y
= 0 then FObj
.Vel
.Y
:= -6;
2832 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
2836 SetState(MONSTATE_PAIN
);
2837 FPain
:= FPain
+ 50;
2841 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2843 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2847 // Ðûáà ïëûâåò ââåðõ:
2848 if FObj
.Vel
.Y
< 0 then
2849 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
2851 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
2853 // Ïëàâàåì òóäà-ñþäà:
2854 if Random(2) = 0 then
2855 FDirection
:= TDirection
.D_LEFT
2857 FDirection
:= TDirection
.D_RIGHT
;
2859 SetState(MONSTATE_RUN
);
2863 else // Ëåòàþùèå ìîíñòðû
2865 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2867 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2872 else // "Íàçåìíûå" ìîíñòðû
2874 // Âîçìîæíî, ïèíàåì êóñêè:
2875 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
2877 b
:= Abs(FObj
.Vel
.X
);
2878 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2879 for a
:= 0 to High(gGibs
) do
2881 if gGibs
[a
].alive
and
2882 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2883 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
2886 if FObj
.Vel
.X
< 0 then
2888 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
2892 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
2897 // Áîññû ìîãóò ïèíàòü òðóïû:
2898 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
2899 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
2901 b
:= Abs(FObj
.Vel
.X
);
2902 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2903 for a
:= 0 to High(gCorpses
) do
2904 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
2906 co
:= gCorpses
[a
].Obj
;
2907 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2908 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
2910 if FObj
.Vel
.X
< 0 then
2911 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
2913 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
2916 // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
2918 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2920 if (Random(4) = 0) and (FObj
.Accel
.Y
= 0) then
2921 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2924 FSleep
:= FSleep
+ 1;
2930 if Random(8) = 0 then
2934 // Áåæèì â âûáðàííóþ ñòîðîíó:
2935 if FDirection
= TDirection
.D_RIGHT
then
2936 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2938 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2940 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2941 if WordBool(st
and MOVE_INWATER
) then
2942 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2943 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2944 if FMonsterType
= MONSTER_FISH
then
2948 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
2950 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2951 if WordBool(st
and MOVE_BLOCK
) then
2955 SetState(MONSTATE_RUNOUT
);
2960 FSleep
:= FSleep
- 1;
2962 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
2963 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
2966 SetState(MONSTATE_GO
);
2967 // Ñòåíà - èäåì îáðàòíî:
2968 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2971 if Random(8) = 0 then
2975 // Áåæèì â âûáðàííóþ ñòîðîíó:
2976 if FDirection
= TDirection
.D_RIGHT
then
2977 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2979 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2981 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2982 if WordBool(st
and MOVE_INWATER
) then
2983 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2984 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2985 if FMonsterType
= MONSTER_FISH
then
2989 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
2991 // Âûøëè èç ÁëîêÌîíà:
2992 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
2995 FSleep
:= FSleep
- 1;
2997 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
2998 if FSleep
<= -18 then
3001 SetState(MONSTATE_GO
);
3002 // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî:
3003 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3006 if Random(8) = 0 then
3010 // Áåæèì â âûáðàííóþ ñòîðîíó:
3011 if FDirection
= TDirection
.D_RIGHT
then
3012 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3014 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3016 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3017 if WordBool(st
and MOVE_INWATER
) then
3018 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3019 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3020 if FMonsterType
= MONSTER_FISH
then
3024 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3026 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3027 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3028 (not WordBool(st
and MOVE_HITWALL
)) then
3031 SetState(MONSTATE_GO
);
3033 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3034 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3038 SetState(MONSTATE_RUN
);
3042 // Áåæèì â âûáðàííóþ ñòîðîíó:
3043 if FDirection
= TDirection
.D_RIGHT
then
3044 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3046 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3048 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3049 if WordBool(st
and MOVE_INWATER
) then
3050 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3051 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3052 if FMonsterType
= MONSTER_FISH
then
3056 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3057 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3059 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3060 if FMonsterType
= MONSTER_SOUL
then
3062 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3063 SetState(MONSTATE_GO
);
3068 // Çàìåäëÿåìñÿ ïðè àòàêå:
3069 if FMonsterType
<> MONSTER_FISH
then
3070 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3072 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3073 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3075 // Öåëü ïîãèáëà => èäåì äàëüøå:
3076 if not GetPos(FTargetUID
, @o
) then
3078 SetState(MONSTATE_GO
);
3083 // Öåëü íå âèäíî => èäåì äàëüøå:
3084 if not g_Look(@FObj
, @o
, FDirection
) then
3086 SetState(MONSTATE_GO
);
3091 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3092 if g_Obj_CollideWater(@o
, 0, 0) then
3094 SetState(MONSTATE_GO
);
3100 tx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2);
3101 ty
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2);
3102 g_Weapon_HitUID(FTargetUID
, 2, FUID
, HIT_SOME
);
3105 end; // case FState of ...
3109 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3110 if FState
= MONSTATE_REVIVE
then
3111 if FAnim
[FCurAnim
, FDirection
].Played
then
3112 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3113 FAnim
[FCurAnim
, FDirection
].Revert(False);
3114 SetState(MONSTATE_GO
);
3117 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3118 if vilefire
<> nil then
3121 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3122 if (FState
= MONSTATE_DIE
) and
3123 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3124 (FAnim
[FCurAnim
, FDirection
].Played
) then
3127 SetState(MONSTATE_DEAD
);
3129 // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à:
3130 if (FMonsterType
= MONSTER_PAIN
) then
3132 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-30,
3133 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_LEFT
);
3136 mon
.SetState(MONSTATE_GO
);
3137 mon
.FNoRespawn
:= True;
3138 Inc(gTotalMonsters
);
3139 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3142 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3143 FObj
.Y
+FObj
.Rect
.Y
+20, TDirection
.D_RIGHT
);
3146 mon
.SetState(MONSTATE_GO
);
3147 mon
.FNoRespawn
:= True;
3148 Inc(gTotalMonsters
);
3149 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3152 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-15,
3153 FObj
.Y
+FObj
.Rect
.Y
, TDirection
.D_RIGHT
);
3156 mon
.SetState(MONSTATE_GO
);
3157 mon
.FNoRespawn
:= True;
3158 Inc(gTotalMonsters
);
3159 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3162 if g_Game_IsNet
then MH_SEND_CoopStats();
3165 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3166 if (FMonsterType
= MONSTER_PAIN
) or
3167 (FMonsterType
= MONSTER_SOUL
) or
3168 (FMonsterType
= MONSTER_BARREL
) then
3172 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3173 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3174 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3175 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3176 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3177 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3178 if FState
= MONSTATE_ATTACK
then
3179 begin // Ñîñòîÿíèå - Àòàêà
3180 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3181 if FMonsterType
<> MONSTER_SOUL
then
3182 SetState(MONSTATE_GO
);
3184 else // Ñîñòîÿíèå - Ñòðåëüáà
3186 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3187 if not FChainFire
then
3188 SetState(MONSTATE_GO
)
3190 begin // Íàäî ñòðåëÿòü åùå
3191 FChainFire
:= False;
3192 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3193 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3194 FAnim
[FCurAnim
, FDirection
].Reset();
3198 FWaitAttackAnim
:= False;
3201 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3202 if (FMonsterType
= MONSTER_SOUL
) or
3203 ( (not FWaitAttackAnim
) and
3204 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3205 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3207 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3208 if FState
= MONSTATE_ATTACK
then
3209 begin // Ñîñòîÿíèå - Àòàêà
3210 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3211 if FMonsterType
= MONSTER_SOUL
then
3212 FAnim
[FCurAnim
, FDirection
].Reset();
3214 case FMonsterType
of
3215 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3216 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3217 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3218 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3219 if FMonsterType
= MONSTER_SOUL
then
3220 SetState(MONSTATE_GO
);
3223 // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì:
3224 if g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
) <> 0 then
3225 g_Sound_PlayExAt('SOUND_MONSTER_FISH_ATTACK', FObj
.X
, FObj
.Y
);
3227 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3228 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3229 if FCurAnim
= ANIM_ATTACK2
then
3232 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3233 if g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
) <> 0 then
3234 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_HIT', FObj
.X
, FObj
.Y
);
3238 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3239 if FCurAnim
= ANIM_ATTACK2
then
3241 sx
:= isCorpse(@FObj
, True);
3243 begin // Íàøëè, êîãî âîñêðåñèòü
3244 gMonsters
[sx
].SetState(MONSTATE_REVIVE
);
3245 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3246 // Âîñêðåøàòü - ñåáå âðåäèòü:
3247 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3253 else // Ñîñòîÿíèå - Ñòðåëüáà
3255 // Âû÷èñëÿåì êîîðäèíàòû, îòêóäà âûëåòèò ïóëÿ:
3256 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
;
3258 if FDirection
= TDirection
.D_LEFT
then
3260 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
-(MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2));
3261 wx
:= MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2)-wx
;
3262 end; // Ýòî çíà÷èò: wx := hitX + (hitWidth / 2) - (wx - (hitX + (hitWidth / 2)))
3265 wy
:= FObj
.Y
+ MONSTER_ANIMTABLE
[FMonsterType
].wY
;
3267 // Ìîíñòð íå ìîæåò öåëèòüñÿ â îáúåêò çà ñïèíîé, ñòðåëÿÿ âëåâî:
3268 if (FDirection
= TDirection
.D_LEFT
) and (tx
> wx
) then
3271 ty
:= wy
+ Random(11) - 5;
3273 // È àíàëîãè÷íî, ñòðåëÿÿ âïðàâî:
3274 if (FDirection
= TDirection
.D_RIGHT
) and (tx
< wx
) then
3277 ty
:= wy
+ Random(11) - 5;
3280 // Äåëàåì âûñòðåë íóæíûì îðóæèåì:
3281 case FMonsterType
of
3283 g_Weapon_ball1(wx
, wy
, tx
, ty
, FUID
);
3286 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3287 g_Weapon_gun(wx
, wy
, tx
, ty
, 1, 3, FUID
, True);
3288 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3292 g_Weapon_shotgun(wx
, wy
, tx
, ty
, FUID
);
3293 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3295 FShellType
:= SHELL_SHELL
;
3299 g_Weapon_dshotgun(wx
, wy
, tx
, ty
, FUID
);
3301 FShellType
:= SHELL_DBLSHELL
;
3306 g_Weapon_rocket(wx
, wy
, tx
, ty
, FUID
);
3307 // MH_SEND_MonsterAttack(FUID, wx, wy, tx, ty);
3310 g_Weapon_revf(wx
, wy
, tx
, ty
, FUID
, FTargetUID
);
3313 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3314 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3315 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3319 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3320 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3321 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
3324 g_Weapon_aplasma(wx
, wy
, tx
, ty
, FUID
);
3326 g_Weapon_plasma(wx
, wy
, tx
, ty
, FUID
);
3328 g_Weapon_manfire(wx
, wy
, tx
, ty
, FUID
);
3329 MONSTER_BARON
, MONSTER_KNIGHT
:
3330 g_Weapon_ball7(wx
, wy
, tx
, ty
, FUID
);
3332 g_Weapon_ball2(wx
, wy
, tx
, ty
, FUID
);
3334 begin // Ñîçäàåì Lost_Soul:
3335 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+(FObj
.Rect
.Width
div 2),
3336 FObj
.Y
+FObj
.Rect
.Y
, FDirection
);
3339 begin // Öåëü - öåëü Pain_Elemental'à. Ëåòèì ê íåé:
3340 mon
.FTargetUID
:= FTargetUID
;
3341 GetPos(FTargetUID
, @o
);
3342 mon
.FTargetTime
:= 0;
3343 mon
.FNoRespawn
:= True;
3344 mon
.SetState(MONSTATE_GO
);
3345 mon
.shoot(@o
, True);
3346 Inc(gTotalMonsters
);
3348 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3353 if FMonsterType
<> MONSTER_PAIN
then
3354 if g_Game_IsNet
then
3355 MH_SEND_MonsterShot(FUID
, wx
, wy
, tx
, ty
);
3357 // Ñêîðîñòðåëüíûå ìîíñòðû:
3358 if (FMonsterType
= MONSTER_CGUN
) or
3359 (FMonsterType
= MONSTER_SPIDER
) or
3360 (FMonsterType
= MONSTER_BSP
) or
3361 (FMonsterType
= MONSTER_MANCUB
) or
3362 (FMonsterType
= MONSTER_ROBO
) then
3363 if not GetPos(FTargetUID
, @o
) then
3364 // Öåëü ìåðòâà - èùåì íîâóþ:
3366 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3367 if shoot(@o
, False) then
3371 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3372 FWaitAttackAnim
:= True;
3375 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3376 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3378 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3379 // Çâóêè ïðè ïåðåäâèæåíèè:
3380 case FMonsterType
of
3382 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3383 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3384 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3386 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3387 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3388 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3390 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3391 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3392 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3394 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3395 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3396 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3400 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3401 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3402 FObj
.Vel
.X
:= oldvelx
;
3404 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3405 if FAnim
[FCurAnim
, FDirection
] <> nil then
3406 FAnim
[FCurAnim
, FDirection
].Update();
3409 procedure TMonster
.SetDeadAnim
;
3411 if FAnim
<> nil then
3412 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3415 procedure TMonster
.RevertAnim(R
: Boolean = True);
3417 if FAnim
<> nil then
3418 if FAnim
[FCurAnim
, FDirection
].IsReverse
<> R
then
3419 FAnim
[FCurAnim
, FDirection
].Revert(R
);
3422 function TMonster
.AnimIsReverse
: Boolean;
3424 if FAnim
<> nil then
3425 Result
:= FAnim
[FCurAnim
, FDirection
].IsReverse
3430 procedure TMonster
.ClientUpdate();
3432 a
, b
, sx
, sy
, oldvelx
: Integer;
3439 sx
:= 0; // SHUT UP COMPILER
3442 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
3443 if FMonsterType
= MONSTER_FISH
then
3444 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3445 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
3448 // Ëåòàþùèå ìîíòñðû:
3449 if ((FMonsterType
= MONSTER_SOUL
) or
3450 (FMonsterType
= MONSTER_PAIN
) or
3451 (FMonsterType
= MONSTER_CACO
)) and
3452 (FState
<> MONSTATE_DIE
) and
3453 (FState
<> MONSTATE_DEAD
) then
3456 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
3457 if gTime
mod (GAME_TICK
*2) <> 0 then
3459 g_Obj_Move(@FObj
, fall
, True, True);
3460 positionChanged(); // this updates spatial accelerators
3464 if FPainTicks
> 0 then
3467 FPainSound
:= False;
3470 st
:= g_Obj_Move(@FObj
, fall
, True, True);
3471 positionChanged(); // this updates spatial accelerators
3473 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
3474 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
3475 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
3481 oldvelx
:= FObj
.Vel
.X
;
3483 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
3484 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
3485 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3487 if FFireTime
> 0 then
3489 if WordBool(st
and MOVE_INWATER
) then
3494 FFireTime
:= FFireTime
- 1;
3498 // Ìåðòâûé íè÷åãî íå äåëàåò:
3499 if (FState
= MONSTATE_DEAD
) then
3502 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
3503 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
3504 case FMonsterType
of
3506 if Random(4) = 0 then
3507 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3508 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3509 MONSTER_ROBO
, MONSTER_BARREL
:
3510 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3511 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3513 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
3514 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
3515 if Random(2) = 0 then
3516 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
3518 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
3522 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
3523 if FMonsterType
= MONSTER_BARREL
then
3525 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
3526 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3527 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3528 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
3532 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
3533 if FMonsterType
= MONSTER_SOUL
then
3534 if WordBool(st
and MOVE_HITAIR
) then
3535 g_Obj_SetSpeed(@FObj
, 16);
3540 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
3541 if FObj
.Vel
.Y
< 0 then
3542 if WordBool(st
and MOVE_INWATER
) then
3545 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
3546 FTargetTime
:= FTargetTime
+ 1;
3548 if FShellTimer
> -1 then
3549 if FShellTimer
= 0 then
3551 if FShellType
= SHELL_SHELL
then
3552 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3553 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3554 GameVelX
, GameVelY
-2, SHELL_SHELL
)
3555 else if FShellType
= SHELL_DBLSHELL
then
3557 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3558 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3559 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
3560 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3561 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3562 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
3565 end else Dec(FShellTimer
);
3567 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
3569 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
3570 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
3571 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3572 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
3573 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3574 (FObj
.Accel
.Y
= 0) then
3575 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3578 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
3580 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
3581 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
3583 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
3584 if gSoundEffectsDF
then PainSound();
3586 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
3589 // Ñíèæàåì áîëü ñî âðåìåíåì:
3592 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
3593 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
3595 SetState(MONSTATE_GO
);
3600 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
3603 FSleep
:= FSleep
+ 1;
3605 // Ïðîñïàëè äîñòàòî÷íî:
3606 if FSleep
>= 18 then
3612 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
3615 FSleep
:= FSleep
- 1;
3618 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
3620 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3621 if WordBool(st
and MOVE_BLOCK
) then
3625 SetState(MONSTATE_RUNOUT
);
3630 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
3631 if (FMonsterType
= MONSTER_VILE
) then
3632 if isCorpse(@FObj
, False) <> -1 then
3634 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
3640 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
3641 if Abs(sx
) < 40 then
3642 if FMonsterType
<> MONSTER_FISH
then
3644 SetState(MONSTATE_RUN
);
3650 // Óïåðëèñü â ñòåíó:
3651 if WordBool(st
and MOVE_HITWALL
) then
3653 case FMonsterType
of
3654 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
3656 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3657 (FObj
.Accel
.Y
= 0) then
3658 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
3659 // Ïðûæîê ÷åðåç ñòåíó:
3660 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3661 SetState(MONSTATE_CLIMB
);
3668 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
3669 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
3670 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
3672 if FMonsterType
= MONSTER_FISH
then
3674 if not WordBool(st
and MOVE_INWATER
) then
3675 begin // Ðûáà âíå âîäû:
3676 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
3677 begin // "Ñòîèò" òâåðäî
3678 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
3679 if FObj
.Accel
.Y
= 0 then
3681 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
3685 SetState(MONSTATE_PAIN
);
3686 FPain
:= FPain
+ 50;
3690 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3692 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3696 // Ðûáà ïëûâåò ââåðõ:
3697 if FObj
.Vel
.Y
< 0 then
3698 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
3700 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
3702 // Ïëàâàåì òóäà-ñþäà:
3703 SetState(MONSTATE_RUN
);
3708 else // Ëåòàþùèå ìîíñòðû
3710 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3712 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3717 else // "Íàçåìíûå" ìîíñòðû
3719 // Âîçìîæíî, ïèíàåì êóñêè:
3720 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
3722 b
:= Abs(FObj
.Vel
.X
);
3723 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3724 for a
:= 0 to High(gGibs
) do
3726 if gGibs
[a
].alive
and
3727 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3728 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
3731 if FObj
.Vel
.X
< 0 then
3733 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
3737 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
3739 positionChanged(); // this updates spatial accelerators
3743 // Áîññû ìîãóò ïèíàòü òðóïû:
3744 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
3745 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
3747 b
:= Abs(FObj
.Vel
.X
);
3748 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3749 for a
:= 0 to High(gCorpses
) do
3750 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
3752 co
:= gCorpses
[a
].Obj
;
3753 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3754 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
3756 if FObj
.Vel
.X
< 0 then
3757 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
3759 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
3764 FSleep
:= FSleep
+ 1;
3770 if Random(8) = 0 then
3774 // Áåæèì â âûáðàííóþ ñòîðîíó:
3775 if FDirection
= TDirection
.D_RIGHT
then
3776 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3778 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3780 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3781 if WordBool(st
and MOVE_INWATER
) then
3782 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3783 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3784 if FMonsterType
= MONSTER_FISH
then
3788 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
3790 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3791 if WordBool(st
and MOVE_BLOCK
) then
3793 SetState(MONSTATE_RUNOUT
);
3799 FSleep
:= FSleep
- 1;
3801 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
3802 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
3804 SetState(MONSTATE_GO
);
3808 if Random(8) = 0 then
3812 // Áåæèì â âûáðàííóþ ñòîðîíó:
3813 if FDirection
= TDirection
.D_RIGHT
then
3814 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3816 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3818 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3819 if WordBool(st
and MOVE_INWATER
) then
3820 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3821 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3822 if FMonsterType
= MONSTER_FISH
then
3826 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3828 // Âûøëè èç ÁëîêÌîíà:
3829 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3832 FSleep
:= FSleep
- 1;
3834 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3835 if FSleep
<= -18 then
3837 SetState(MONSTATE_GO
);
3841 if Random(8) = 0 then
3845 // Áåæèì â âûáðàííóþ ñòîðîíó:
3846 if FDirection
= TDirection
.D_RIGHT
then
3847 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3849 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3851 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3852 if WordBool(st
and MOVE_INWATER
) then
3853 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3854 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3855 if FMonsterType
= MONSTER_FISH
then
3859 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3861 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3862 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3863 (not WordBool(st
and MOVE_HITWALL
)) then
3865 SetState(MONSTATE_GO
);
3868 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3869 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3871 SetState(MONSTATE_RUN
);
3876 // Áåæèì â âûáðàííóþ ñòîðîíó:
3877 if FDirection
= TDirection
.D_RIGHT
then
3878 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3880 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3882 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3883 if WordBool(st
and MOVE_INWATER
) then
3884 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3885 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3886 if FMonsterType
= MONSTER_FISH
then
3890 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3891 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3893 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3894 if FMonsterType
= MONSTER_SOUL
then
3896 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3897 SetState(MONSTATE_GO
);
3902 // Çàìåäëÿåìñÿ ïðè àòàêå:
3903 if FMonsterType
<> MONSTER_FISH
then
3904 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3906 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3907 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3909 // Öåëü ïîãèáëà => èäåì äàëüøå:
3910 if not GetPos(FTargetUID
, @o
) then
3912 SetState(MONSTATE_GO
);
3917 // Öåëü íå âèäíî => èäåì äàëüøå:
3918 if not g_Look(@FObj
, @o
, FDirection
) then
3920 SetState(MONSTATE_GO
);
3925 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3926 if g_Obj_CollideWater(@o
, 0, 0) then
3928 SetState(MONSTATE_GO
);
3934 end; // case FState of ...
3938 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3939 if FState
= MONSTATE_REVIVE
then
3940 if FAnim
[FCurAnim
, FDirection
].Played
then
3941 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3942 FAnim
[FCurAnim
, FDirection
].Revert(False);
3943 SetState(MONSTATE_GO
);
3946 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3947 if vilefire
<> nil then
3950 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3951 if (FState
= MONSTATE_DIE
) and
3952 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3953 (FAnim
[FCurAnim
, FDirection
].Played
) then
3956 SetState(MONSTATE_DEAD
);
3958 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3959 if (FMonsterType
= MONSTER_PAIN
) or
3960 (FMonsterType
= MONSTER_SOUL
) or
3961 (FMonsterType
= MONSTER_BARREL
) then
3964 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3967 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3968 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3969 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3970 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3971 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3972 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3973 if FState
= MONSTATE_ATTACK
then
3974 begin // Ñîñòîÿíèå - Àòàêà
3975 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3976 if FMonsterType
<> MONSTER_SOUL
then
3977 SetState(MONSTATE_GO
);
3979 else // Ñîñòîÿíèå - Ñòðåëüáà
3981 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3982 if not FChainFire
then
3983 SetState(MONSTATE_GO
)
3985 begin // Íàäî ñòðåëÿòü åùå
3986 FChainFire
:= False;
3987 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3988 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3989 FAnim
[FCurAnim
, FDirection
].Reset();
3993 FWaitAttackAnim
:= False;
3996 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3997 if (FMonsterType
= MONSTER_SOUL
) or
3998 ( (not FWaitAttackAnim
) and
3999 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
4000 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
4002 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
4003 if FState
= MONSTATE_ATTACK
then
4004 begin // Ñîñòîÿíèå - Àòàêà
4005 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
4006 if FMonsterType
= MONSTER_SOUL
then
4007 FAnim
[FCurAnim
, FDirection
].Reset();
4009 case FMonsterType
of
4010 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
4011 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
4012 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
4013 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
4014 if FMonsterType
= MONSTER_SOUL
then
4015 SetState(MONSTATE_GO
);
4018 g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
);
4020 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4021 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
4022 if FCurAnim
= ANIM_ATTACK2
then
4025 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
4026 g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
);
4030 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
4031 if FCurAnim
= ANIM_ATTACK2
then
4033 sx
:= isCorpse(@FObj
, True);
4035 begin // Íàøëè, êîãî âîñêðåñèòü
4036 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
4037 // Âîñêðåøàòü - ñåáå âðåäèòü:
4038 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
4044 else // Ñîñòîÿíèå - Ñòðåëüáà
4046 // Ñêîðîñòðåëüíûå ìîíñòðû:
4047 if (FMonsterType
= MONSTER_CGUN
) or
4048 (FMonsterType
= MONSTER_SPIDER
) or
4049 (FMonsterType
= MONSTER_BSP
) or
4050 (FMonsterType
= MONSTER_MANCUB
) or
4051 (FMonsterType
= MONSTER_ROBO
) then
4052 if not GetPos(FTargetUID
, @o
) then
4053 // Öåëü ìåðòâà - èùåì íîâóþ:
4055 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
4056 if shoot(@o
, False) then
4060 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
4061 FWaitAttackAnim
:= True;
4064 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
4065 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
4067 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
4068 // Çâóêè ïðè ïåðåäâèæåíèè:
4069 case FMonsterType
of
4071 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4072 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4073 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
4075 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4076 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4077 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
4079 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4080 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4081 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4083 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4084 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
4085 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4089 // Êîñòûëü äëÿ ïîòîêîâ
4090 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
4091 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
4092 FObj
.Vel
.X
:= oldvelx
;
4094 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
4095 if FAnim
[FCurAnim
, FDirection
] <> nil then
4096 FAnim
[FCurAnim
, FDirection
].Update();
4099 procedure TMonster
.ClientAttack(wx
, wy
, atx
, aty
: Integer);
4101 case FMonsterType
of
4104 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
4105 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4109 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
4111 FShellType
:= SHELL_SHELL
;
4115 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', wx
, wy
);
4117 FShellType
:= SHELL_DBLSHELL
;
4119 MONSTER_CGUN
, MONSTER_SPIDER
:
4121 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
4122 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4125 g_Weapon_ball1(wx
, wy
, atx
, aty
, FUID
);
4127 g_Weapon_rocket(wx
, wy
, atx
, aty
, FUID
);
4129 g_Weapon_revf(wx
, wy
, atx
, aty
, FUID
, FTargetUID
);
4131 g_Weapon_aplasma(wx
, wy
, atx
, aty
, FUID
);
4133 g_Weapon_plasma(wx
, wy
, atx
, aty
, FUID
);
4135 g_Weapon_manfire(wx
, wy
, atx
, aty
, FUID
);
4136 MONSTER_BARON
, MONSTER_KNIGHT
:
4137 g_Weapon_ball7(wx
, wy
, atx
, aty
, FUID
);
4139 g_Weapon_ball2(wx
, wy
, atx
, aty
, FUID
);
4143 procedure TMonster
.Turn();
4146 if FDirection
= TDirection
.D_LEFT
then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
4148 // Áåæèì â âûáðàííóþ ñòîðîíó:
4149 if FDirection
= TDirection
.D_RIGHT
then
4150 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
4152 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
4155 function TMonster
.findNewPrey(): Boolean;
4159 PlayersSee
, MonstersSee
: Array of DWORD
;
4160 PlayerNear
, MonsterNear
: Integer;
4163 SetLength(MonstersSee
, 0);
4164 SetLength(PlayersSee
, 0);
4171 // Ïîåõàâøèå, êàííèáàëû, è äîáðûå èãðîêîâ íå òðîãàþò
4172 if (gPlayers
<> nil) and (FBehaviour
<> BH_INSANE
) and
4173 (FBehaviour
<> BH_CANNIBAL
) and (FBehaviour
<> BH_GOOD
) then
4174 for a
:= 0 to High(gPlayers
) do
4175 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
4176 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
4178 if g_Look(@FObj
, @gPlayers
[a
].Obj
, FDirection
) then
4180 SetLength(PlayersSee
, Length(PlayersSee
) + 1);
4181 PlayersSee
[High(PlayersSee
)] := a
;
4183 l2
:= Abs(gPlayers
[a
].GameX
-FObj
.X
)+
4184 Abs(gPlayers
[a
].GameY
-FObj
.Y
);
4188 PlayerNear
:= Integer(a
);
4192 // Êèëëåðû è äîáðûå íå òðîãàþò ìîíñòðîâ
4193 if (gMonsters
<> nil) and (FBehaviour
<> BH_KILLER
) and (FBehaviour
<> BH_GOOD
) then
4194 for a
:= 0 to High(gMonsters
) do
4195 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
4196 (gMonsters
[a
].FUID
<> FUID
) then
4198 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
4199 Continue
; // Êàííèáàëû àòàêóþò òîëüêî ñîðîäè÷åé
4200 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
)
4201 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4202 Continue
; // Ïîåõàâøèå íå òðîãàþò äðóçåé, íî èì íå íðàâÿòñÿ áî÷êè
4203 if ((FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_MANIAC
))
4204 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4205 Continue
; // Îñòàâøèåñÿ òèïû, êðîìå êàííèáàëîâ, íå òðîãàþò ñâîèõ äðóçåé
4207 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
4209 SetLength(MonstersSee
, Length(MonstersSee
) + 1);
4210 MonstersSee
[High(MonstersSee
)] := a
;
4212 l2
:= Abs(gMonsters
[a
].FObj
.X
-FObj
.X
)+
4213 Abs(gMonsters
[a
].FObj
.Y
-FObj
.Y
);
4217 MonsterNear
:= Integer(a
);
4222 BH_NORMAL
, BH_KILLER
:
4224 // Îáû÷íûé è êèëëåð ñíà÷àëà èùóò èãðîêîâ â ïîëå çðåíèÿ
4225 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4227 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4228 FTargetUID
:= gPlayers
[a
].UID
;
4231 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4234 FTargetUID
:= gPlayers
[a
].UID
;
4236 // Ïîòîì îáû÷íûå èùóò ìîíñòðîâ â ïîëå çðåíèÿ
4237 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4239 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4240 FTargetUID
:= gMonsters
[a
].UID
;
4243 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4246 FTargetUID
:= gMonsters
[a
].UID
;
4249 BH_MANIAC
, BH_INSANE
, BH_CANNIBAL
:
4251 // Ìàíüÿêè, ïîåõàâøèå è êàííèáàëû ñíà÷àëà èñòðåáëÿþò âñ¸ â ïîëå çðåíèÿ
4252 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4254 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4255 FTargetUID
:= gPlayers
[a
].UID
;
4257 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4259 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4260 FTargetUID
:= gMonsters
[a
].UID
;
4262 // Çàòåì èùóò êîãî-òî ïîáëèçîñòè
4263 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4266 FTargetUID
:= gPlayers
[a
].UID
;
4268 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4271 FTargetUID
:= gMonsters
[a
].UID
;
4276 // Åñëè è ìîíñòðîâ íåò - íà÷èíàåì æäàòü öåëü:
4277 if FTargetUID
= 0 then
4279 // Ïîåõàâøèé ïûòàåòñÿ ñàìîóáèòüñÿ
4280 if FBehaviour
= BH_INSANE
then
4283 FTargetTime
:= MAX_ATM
;
4292 function TMonster
.kick(o
: PObj
): Boolean;
4296 case FMonsterType
of
4299 SetState(MONSTATE_ATTACK
);
4304 SetState(MONSTATE_ATTACK
);
4305 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj
.X
, FObj
.Y
);
4310 SetState(MONSTATE_ATTACK
);
4311 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj
.X
, FObj
.Y
);
4314 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4316 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
4317 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj
.X
, FObj
.Y
);
4320 MONSTER_BARON
, MONSTER_KNIGHT
,
4321 MONSTER_CACO
, MONSTER_MANCUB
:
4322 // Ýòè ìîíñòðû íå ïèíàþò - îíè ñòðåëÿþò â óïîð:
4323 if not g_Game_IsClient
then Result
:= shoot(o
, True);
4327 function TMonster
.shoot(o
: PObj
; immediately
: Boolean): Boolean;
4337 // Æäàòü âðåìåíè ãîòîâíîñòè ê âûñòðåëó:
4338 if not immediately
then
4339 case FMonsterType
of
4340 MONSTER_FISH
, MONSTER_BARREL
, MONSTER_DEMON
:
4341 Exit
; // íå ñòðåëÿþò
4342 MONSTER_CGUN
, MONSTER_BSP
, MONSTER_ROBO
:
4345 // Âðåìÿ âûñòðåëà óïóùåíî:
4347 FAmmo
:= IfThen(FMonsterType
= MONSTER_ROBO
, -200, -50);
4353 // Âðåìÿ âûñòðåëà óïóùåíî:
4360 // Âðåìÿ âûñòðåëà óïóùåíî:
4361 if FAmmo
>= 100 then
4366 // Ñòðåëÿåò íå âñåãäà:
4367 if Random(2) = 0 then
4370 // Âðåìÿ âûñòðåëà óïóùåíî:
4374 MONSTER_BARON
, MONSTER_KNIGHT
: if Random(8) <> 0 then Exit
;
4375 MONSTER_SKEL
: if Random(32) <> 0 then Exit
;
4376 MONSTER_VILE
: if Random(8) <> 0 then Exit
;
4377 MONSTER_PAIN
: if Random(8) <> 0 then Exit
;
4378 else if Random(16) <> 0 then Exit
;
4382 if not g_Look(@FObj
, o
, FDirection
) then
4387 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2)+((o
^.Vel
.X
{+o^.Accel.X})*12);
4388 ty
:= o
^.Y
+o
^.Rect
.Y
+(o
^.Rect
.Height
div 2)+((o
^.Vel
.Y
{+o^.Accel.Y})*12);
4390 // Ðàçíèöà ïî âûñîòå áîëüøå ðàçíèöû ïî ãîðèçîíòàëè
4391 // (íå ìîæåò ñòðåëÿòü ïîä òàêèì áîëüøèì óãëîì):
4392 if Abs(tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2))) <
4393 Abs(ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2))) then
4396 case FMonsterType
of
4397 MONSTER_IMP
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
:
4399 SetState(MONSTATE_SHOOT
);
4404 SetState(MONSTATE_SHOOT
);
4408 begin // Çàæèãàåì îãîíü
4409 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2);
4410 ty
:= o
^.Y
+o
^.Rect
.Y
;
4411 SetState(MONSTATE_SHOOT
);
4415 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ATTACK', FObj
.X
, FObj
.Y
);
4416 g_Sound_PlayExAt('SOUND_FIRE', o
^.X
, o
^.Y
);
4419 begin // Ëåòèò â ñòîðîíó öåëè:
4420 SetState(MONSTATE_ATTACK
);
4421 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj
.X
, FObj
.Y
);
4423 xd
:= tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
4424 yd
:= ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
4425 m
:= Max(Abs(xd
), Abs(yd
));
4429 FObj
.Vel
.X
:= (xd
*16) div m
;
4430 FObj
.Vel
.Y
:= (yd
*16) div m
;
4432 MONSTER_MANCUB
, MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_BSP
, MONSTER_ROBO
,
4433 MONSTER_CYBER
, MONSTER_CGUN
, MONSTER_SPIDER
, MONSTER_PAIN
, MONSTER_MAN
:
4435 // Ìàíêóáóñ ðÿâêàåò ïåðåä ïåðâîé àòàêîé:
4436 if FMonsterType
= MONSTER_MANCUB
then
4438 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj
.X
, FObj
.Y
);
4440 SetState(MONSTATE_SHOOT
);
4448 function TMonster
.alive(): Boolean;
4450 Result
:= (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) and (FHealth
> 0);
4453 procedure TMonster
.SetHealth(aH
: Integer);
4455 if (aH
> 0) and (aH
< 1000000) then
4458 if FHealth
> FMaxHealth
then
4459 FMaxHealth
:= FHealth
;
4463 procedure TMonster
.WakeUp();
4465 if g_Game_IsClient
then Exit
;
4466 SetState(MONSTATE_GO
);
4467 FTargetTime
:= MAX_ATM
;
4471 procedure TMonster
.SaveState (st
: TStream
);
4479 // Ñèãíàòóðà ìîíñòðà:
4480 utils
.writeSign(st
, 'MONS');
4481 utils
.writeInt(st
, Byte(0)); // version
4483 utils
.writeInt(st
, Word(FUID
));
4485 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
4486 utils
.writeInt(st
, Byte(b
));
4487 // Íàäî ëè óäàëèòü åãî
4488 utils
.writeBool(st
, FRemoved
);
4489 // Îñòàëîñü çäîðîâüÿ
4490 utils
.writeInt(st
, LongInt(FHealth
));
4492 utils
.writeInt(st
, Byte(FState
));
4494 utils
.writeInt(st
, Byte(FCurAnim
));
4496 utils
.writeInt(st
, Word(FTargetUID
));
4497 // Âðåìÿ ïîñëå ïîòåðè öåëè
4498 utils
.writeInt(st
, LongInt(FTargetTime
));
4499 // Ïîâåäåíèå ìîíñòðà
4500 utils
.writeInt(st
, Byte(FBehaviour
));
4501 // Ãîòîâíîñòü ê âûñòðåëó
4502 utils
.writeInt(st
, LongInt(FAmmo
));
4504 utils
.writeInt(st
, LongInt(FPain
));
4506 utils
.writeInt(st
, LongInt(FSleep
));
4507 // Îçâó÷èâàòü ëè áîëü
4508 utils
.writeBool(st
, FPainSound
);
4509 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4510 utils
.writeBool(st
, FWaitAttackAnim
);
4511 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4512 utils
.writeBool(st
, FChainFire
);
4513 // Ïîäëåæèò ëè ðåñïàâíó
4514 utils
.writeBool(st
, FNoRespawn
);
4516 utils
.writeInt(st
, LongInt(tx
));
4517 utils
.writeInt(st
, LongInt(ty
));
4518 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4519 utils
.writeInt(st
, LongInt(FStartID
));
4520 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4521 utils
.writeInt(st
, LongInt(FSpawnTrigger
));
4523 Obj_SaveState(st
, @FObj
);
4524 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4525 anim
:= (vilefire
<> nil);
4526 utils
.writeBool(st
, anim
);
4527 // Åñëè åñòü - ñîõðàíÿåì:
4528 if anim
then vilefire
.SaveState(st
);
4530 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4532 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4533 anim
:= (FAnim
[i
, TDirection
.D_LEFT
] <> nil);
4534 utils
.writeBool(st
, anim
);
4535 // Åñëè åñòü - ñîõðàíÿåì
4536 if anim
then FAnim
[i
, TDirection
.D_LEFT
].SaveState(st
);
4537 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4538 anim
:= (FAnim
[i
, TDirection
.D_RIGHT
] <> nil);
4539 utils
.writeBool(st
, anim
);
4540 // Åñëè åñòü - ñîõðàíÿåì
4541 if anim
then FAnim
[i
, TDirection
.D_RIGHT
].SaveState(st
);
4546 procedure TMonster
.LoadState (st
: TStream
);
4554 // Ñèãíàòóðà ìîíñòðà:
4555 if not utils
.checkSign(st
, 'MONS') then raise XStreamError
.Create('invalid monster signature');
4556 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid monster version');
4557 if (uidMap
[FUID
] <> nil) and (uidMap
[FUID
] <> self
) then raise Exception
.Create('internal error in monster loader (0)');
4558 uidMap
[FUID
] := nil;
4560 FUID
:= utils
.readWord(st
);
4561 //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
4562 if (uidMap
[FUID
] <> nil) then raise Exception
.Create('internal error in monster loader (1)');
4563 uidMap
[FUID
] := self
;
4565 b
:= utils
.readByte(st
);
4566 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
4567 // Íàäî ëè óäàëèòü åãî
4568 FRemoved
:= utils
.readBool(st
);
4569 // Îñòàëîñü çäîðîâüÿ
4570 FHealth
:= utils
.readLongInt(st
);
4572 FState
:= utils
.readByte(st
);
4574 FCurAnim
:= utils
.readByte(st
);
4576 FTargetUID
:= utils
.readWord(st
);
4577 // Âðåìÿ ïîñëå ïîòåðè öåëè
4578 FTargetTime
:= utils
.readLongInt(st
);
4579 // Ïîâåäåíèå ìîíñòðà
4580 FBehaviour
:= utils
.readByte(st
);
4581 // Ãîòîâíîñòü ê âûñòðåëó
4582 FAmmo
:= utils
.readLongInt(st
);
4584 FPain
:= utils
.readLongInt(st
);
4586 FSleep
:= utils
.readLongInt(st
);
4587 // Îçâó÷èâàòü ëè áîëü
4588 FPainSound
:= utils
.readBool(st
);
4589 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4590 FWaitAttackAnim
:= utils
.readBool(st
);
4591 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4592 FChainFire
:= utils
.readBool(st
);
4593 // Ïîäëåæèò ëè ðåñïàâíó
4594 FNoRespawn
:= utils
.readBool(st
);
4596 tx
:= utils
.readLongInt(st
);
4597 ty
:= utils
.readLongInt(st
);
4598 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4599 FStartID
:= utils
.readLongInt(st
);
4600 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4601 FSpawnTrigger
:= utils
.readLongInt(st
);
4603 Obj_LoadState(@FObj
, st
);
4604 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4605 anim
:= utils
.readBool(st
);
4606 // Åñëè åñòü - çàãðóæàåì:
4609 Assert(vilefire
<> nil, 'TMonster.LoadState: no vilefire anim');
4610 vilefire
.LoadState(st
);
4613 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4615 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4616 anim
:= utils
.readBool(st
);
4617 // Åñëè åñòü - çàãðóæàåì
4620 Assert(FAnim
[i
, TDirection
.D_LEFT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_left anim');
4621 FAnim
[i
, TDirection
.D_LEFT
].LoadState(st
);
4623 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4624 anim
:= utils
.readBool(st
);
4625 // Åñëè åñòü - çàãðóæàåì
4628 Assert(FAnim
[i
, TDirection
.D_RIGHT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_right anim');
4629 FAnim
[i
, TDirection
.D_RIGHT
].LoadState(st
);
4635 procedure TMonster
.ActivateTriggers();
4639 if FDieTriggers
<> nil then
4640 for a
:= 0 to High(FDieTriggers
) do
4641 g_Triggers_Press(FDieTriggers
[a
], ACTIVATE_MONSTERPRESS
);
4642 if FSpawnTrigger
> -1 then
4644 g_Triggers_DecreaseSpawner(FSpawnTrigger
);
4645 FSpawnTrigger
:= -1;
4649 procedure TMonster
.AddTrigger(t
: Integer);
4651 SetLength(FDieTriggers
, Length(FDieTriggers
)+1);
4652 FDieTriggers
[High(FDieTriggers
)] := t
;
4655 procedure TMonster
.ClearTriggers();
4657 SetLength(FDieTriggers
, 0);
4660 procedure TMonster
.CatchFire(Attacker
: Word; Timeout
: Integer = MON_BURN_TIME
);
4662 if FMonsterType
in [MONSTER_SOUL
, MONSTER_VILE
] then
4663 exit
; // àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
4664 if Timeout
<= 0 then exit
;
4665 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
4666 exit
; // íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
4667 if FFireTime
<= 0 then
4668 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
4669 FFireTime
:= Timeout
;
4670 FFireAttacker
:= Attacker
;
4671 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_MonsterState(FUID
);
4674 procedure TMonster
.OnFireFlame(Times
: DWORD
= 1);
4679 if (Random(10) = 1) and (Times
= 1) then
4682 if g_Frames_Get(id
, 'FRAMES_FLAME') then
4684 for i
:= 1 to Times
do
4686 Anim
:= TAnimation
.Create(id
, False, 3);
4688 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
4689 Obj
.Y
+8+Random(8+Times
*2)+IfThen(FState
= MONSTATE_DEAD
, 16, 0), Anim
, ONCEANIM_SMOKE
);
4696 // ////////////////////////////////////////////////////////////////////////// //
4697 // throws on invalid uid
4698 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
4700 result
:= g_Mons_ByIdx_NC(uid
);
4701 if (result
= nil) then raise Exception
.Create('g_Mons_ByIdx: invalid monster id');
4705 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
4707 if (uid
< 0) or (uid
> High(gMonsters
)) then begin result
:= nil; exit
; end;
4708 result
:= gMonsters
[uid
];
4711 function g_Mons_TotalCount (): Integer; inline;
4713 result
:= Length(gMonsters
);
4717 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
4723 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4724 for idx
:= 0 to High(gMonsters
) do
4726 mon
:= gMonsters
[idx
];
4727 if (mon
<> nil) then
4730 if result
then exit
;
4736 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
4742 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4743 for idx
:= 0 to High(gMonsters
) do
4745 mon
:= gMonsters
[idx
];
4746 if (mon
<> nil) and mon
.alive
then
4749 if result
then exit
;
4755 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
4757 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4759 result := mon.alive;// and g_Obj_Collide(x, y, width, height, @mon.Obj));
4766 it
: TMonsterGrid
.Iter
;
4769 if (width
< 1) or (height
< 1) then exit
;
4770 if gmon_debug_use_sqaccel
then
4772 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4773 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4774 for mit
in it
do if (mit
.alive
) then begin result
:= true; break
; end;
4779 for idx
:= 0 to High(gMonsters
) do
4781 mon
:= gMonsters
[idx
];
4782 if (mon
<> nil) and mon
.alive
then
4784 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4795 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4797 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4806 it
: TMonsterGrid
.Iter
;
4809 if (width
< 1) or (height
< 1) then exit
;
4810 if gmon_debug_use_sqaccel
then
4812 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4813 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4814 for mit
in it
do if (cb(mit
^)) then begin result
:= true; break
; end;
4819 for idx
:= 0 to High(gMonsters
) do
4821 mon
:= gMonsters
[idx
];
4822 if (mon
<> nil) and mon
.alive
then
4824 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4827 if result
then exit
;
4835 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4837 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4840 //if mon.alive and g_Obj_Collide(x, y, width, height, @mon.Obj) then result := cb(mon);
4841 if mon.alive then result := cb(mon) else result := false;
4848 it
: TMonsterGrid
.Iter
;
4851 if (width
< 1) or (height
< 1) then exit
;
4852 if gmon_debug_use_sqaccel
then
4855 if (width = 1) and (height = 1) then
4857 result := (monsGrid.forEachAtPoint(x, y, monsCollCheck) <> nil);
4861 result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4864 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4867 if (mit
^.alive
) then
4869 if (cb(mit
^)) then begin result
:= true; break
; end;
4876 for idx
:= 0 to High(gMonsters
) do
4878 mon
:= gMonsters
[idx
];
4879 if (mon
<> nil) and mon
.alive
then
4881 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4884 if result
then exit
;