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;
127 procedure PreUpdate();
129 procedure ClientUpdate();
130 procedure ClientAttack(wx
, wy
, atx
, aty
: Integer);
131 procedure SetDeadAnim
;
134 procedure WakeUpSound();
135 procedure DieSound();
136 procedure PainSound();
137 procedure ActionSound();
138 procedure AddTrigger(t
: Integer);
139 procedure ClearTriggers();
141 procedure SaveState (st
: TStream
);
142 procedure LoadState (st
: TStream
);
143 procedure SetState(State
: Byte; ForceAnim
: Byte = 255);
144 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
145 procedure MakeBloodSimple(Count
: Word);
146 procedure RevertAnim(R
: Boolean = True);
147 function AnimIsReverse
: Boolean;
148 function shoot(o
: PObj
; immediately
: Boolean): Boolean;
149 function kick(o
: PObj
): Boolean;
150 procedure CatchFire(Attacker
: Word; Timeout
: Integer = MON_BURN_TIME
);
151 procedure OnFireFlame(Times
: DWORD
= 1);
153 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
155 procedure setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline;
156 procedure moveBy (dx
, dy
: Integer); inline;
158 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
161 function gncNeedSend (): Boolean; inline;
162 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
165 property Obj
: TObj read FObj
;
167 property proxyId
: Integer read mProxyId
;
168 property arrIdx
: Integer read mArrIdx
;
170 property MonsterType
: Byte read FMonsterType
;
171 property MonsterHealth
: Integer read FHealth write FHealth
;
172 property MonsterAmmo
: Integer read FAmmo write FAmmo
;
173 property MonsterTargetUID
: Word read FTargetUID write FTargetUID
;
174 property MonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
175 property MonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
176 property MonsterSleep
: Integer read FSleep write FSleep
;
177 property MonsterState
: Byte read FState write FState
;
178 property MonsterRemoved
: Boolean read FRemoved write FRemoved
;
179 property MonsterPain
: Integer read FPain write FPain
;
180 property MonsterAnim
: Byte read FCurAnim write FCurAnim
;
182 property UID
: Word read FUID write FUID
;
183 property SpawnTrigger
: Integer read FSpawnTrigger write FSpawnTrigger
;
185 property GameX
: Integer read FObj
.X write setGameX
;
186 property GameY
: Integer read FObj
.Y write setGameY
;
187 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
188 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
189 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
190 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
191 property GameDirection
: TDirection read FDirection write FDirection
;
193 property StartID
: Integer read FStartID
;
196 property eMonsterType
: Byte read FMonsterType
;
197 property eMonsterHealth
: Integer read FHealth write FHealth
;
198 property eMonsterAmmo
: Integer read FAmmo write FAmmo
;
199 property eMonsterTargetUID
: Word read FTargetUID write FTargetUID
;
200 property eMonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
201 property eMonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
202 property eMonsterSleep
: Integer read FSleep write FSleep
;
203 property eMonsterState
: Byte read FState write FState
;
204 property eMonsterRemoved
: Boolean read FRemoved
;
205 property eMonsterPain
: Integer read FPain write FPain
;
206 property eMonsterAnim
: Byte read FCurAnim
;
208 property eUID
: Word read FUID
;
209 property eSpawnTrigger
: Integer read FSpawnTrigger
;
211 property eGameX
: Integer read FObj
.X write setGameX
;
212 property eGameY
: Integer read FObj
.Y write setGameY
;
213 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
214 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
215 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
216 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
217 property eGameDirection
: TDirection read FDirection write FDirection
;
219 property eStartID
: Integer read FStartID
;
221 // set this before assigning something to `eDamage`
222 property eDamageType
: Integer read mEDamageType write mEDamageType
;
223 property eDamage
: Integer write doDamage
;
227 // will be called from map loader
228 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
230 procedure g_Monsters_LoadData ();
231 procedure g_Monsters_FreeData ();
232 procedure g_Monsters_Init ();
233 procedure g_Monsters_Free (clearGrid
: Boolean=true);
234 function g_Monsters_Create (MonsterType
: Byte; X
, Y
: Integer; Direction
: TDirection
;
235 AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
236 procedure g_Monsters_PreUpdate ();
237 procedure g_Monsters_Update ();
238 procedure g_Monsters_Draw ();
239 procedure g_Monsters_DrawHealth ();
240 function g_Monsters_ByUID (UID
: Word): TMonster
;
241 procedure g_Monsters_killedp ();
242 procedure g_Monsters_SaveState (st
: TStream
);
243 procedure g_Monsters_LoadState (st
: TStream
);
245 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
246 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
248 function g_Mons_TypeLo (): Integer; inline;
249 function g_Mons_TypeHi (): Integer; inline;
251 function g_Mons_TypeIdByName (const name
: AnsiString): Integer;
252 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
253 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
257 TEachMonsterCB
= function (mon
: TMonster
): Boolean is nested
; // return `true` to stop
259 // throws on invalid uid
260 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
263 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
265 function g_Mons_TotalCount (): Integer; inline;
267 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
269 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
270 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
272 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
273 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
275 function g_Mons_getNewTrapFrameId (): DWord
; inline;
276 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
281 TMonsAlongLineCB = function (mon: TMonster; tag: Integer): Boolean is nested;
283 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
288 gmon_debug_use_sqaccel
: Boolean = true;
292 procedure g_Mons_ProfilersBegin ();
293 procedure g_Mons_ProfilersEnd ();
295 procedure g_Mons_LOS_Start (); inline;
296 procedure g_Mons_LOS_End (); inline;
299 profMonsLOS
: TProfiler
= nil; //WARNING: FOR DEBUGGING ONLY!
303 TMonsterGrid
= specialize TBodyGridBase
<TMonster
>;
306 monsGrid
: TMonsterGrid
= nil; // DO NOT USE! public for debugging only!
310 gmon_debug_think
: Boolean = true;
311 gmon_debug_one_think_step
: Boolean = false;
317 e_log
, e_texture
, g_main
, g_sound
, g_gfx
, g_player
, g_game
,
318 g_weapons
, g_triggers
, MAPDEF
, g_items
, g_options
,
319 g_console
, g_map
, Math
, g_menu
, wadreader
,
320 g_language
, g_netmsg
, idpool
, utils
, xstreams
;
324 // ////////////////////////////////////////////////////////////////////////// //
325 procedure g_Mons_ProfilersBegin ();
327 if (profMonsLOS
= nil) then profMonsLOS
:= TProfiler
.Create('LOS CALC', g_profile_history_size
);
328 if (profMonsLOS
<> nil) then profMonsLOS
.mainBegin(g_profile_los
);
329 if g_profile_los
and (profMonsLOS
<> nil) then
331 profMonsLOS
.sectionBegin('loscalc');
332 profMonsLOS
.sectionEnd();
336 procedure g_Mons_ProfilersEnd ();
338 if (profMonsLOS
<> nil) and (g_profile_los
) then profMonsLOS
.mainEnd();
341 procedure g_Mons_LOS_Start (); inline;
343 if (profMonsLOS
<> nil) then profMonsLOS
.sectionBeginAccum('loscalc');
346 procedure g_Mons_LOS_End (); inline;
348 if (profMonsLOS
<> nil) then profMonsLOS
.sectionEnd();
352 // ////////////////////////////////////////////////////////////////////////// //
354 monCheckTrapLastFrameId
: DWord
= 0;
355 monCheckMPlatLastFrameId
: LongWord = 0;
358 procedure TMonster
.getMapBox (out x
, y
, w
, h
: Integer); inline;
360 x
:= FObj
.X
+FObj
.Rect
.X
;
361 y
:= FObj
.Y
+FObj
.Rect
.Y
;
362 w
:= FObj
.Rect
.Width
;
363 h
:= FObj
.Rect
.Height
;
366 function TMonster
.gncNeedSend (): Boolean; inline; begin result
:= mNeedSend
; mNeedSend
:= false; end;
368 procedure TMonster
.setDirty (); inline; begin mNeedSend
:= true; end;
371 // ////////////////////////////////////////////////////////////////////////// //
373 function g_Mons_AlongLine (x0, y0, x1, y1: Integer; cb: TMonsAlongLineCB; log: Boolean=false): TMonster;
375 if not assigned(cb) then begin result := nil; exit; end;
376 result := monsGrid.forEachAlongLine(x0, y0, x1, y1, cb, -1, log);
381 //WARNING! call this after monster position was changed, or coldet will not work right!
382 procedure TMonster
.positionChanged ();
385 nx
, ny
, nw
, nh
: Integer;
387 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
388 //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);
390 if (mProxyId
= -1) then
393 mProxyId
:= monsGrid
.insertBody(self
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
394 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
395 monsGrid
.getBodyXY(mProxyId
, x
, y
);
396 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
);
401 monsGrid
.getBodyDims(mProxyId
, x
, y
, w
, h
);
402 getMapBox(nx
, ny
, nw
, nh
);
404 if (w
<> nw
) or (h
<> nh
) then
407 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
408 e_WriteLog(Format('monster #%d:(%u): resized; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
410 monsGrid
.moveResizeBody(mProxyId
, nx
, ny
, nw
, nh
);
412 else if (x
<> nx
) or (y
<> ny
) then
415 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
416 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
);
418 monsGrid
.moveBody(mProxyId
, nx
, ny
);
422 exit
; // nothing to do
424 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
425 monsGrid
.getBodyXY(mProxyId
, x
, y
);
426 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
);
432 // ////////////////////////////////////////////////////////////////////////// //
442 MONSTER_SIGNATURE
= $534E4F4D; // 'MONS'
444 // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ:
445 ANIMTABLE
: Array [ANIM_SLEEP
..ANIM_PAIN
] of
449 end = ((name
: 'SLEEP'; loop
: True),
450 (name
: 'GO'; loop
: True),
451 (name
: 'DIE'; loop
: False),
452 (name
: 'MESS'; loop
: False),
453 (name
: 'ATTACK'; loop
: False),
454 (name
: 'ATTACK2'; loop
: False),
455 (name
: 'PAIN'; loop
: False));
457 // Òàáëèöà õàðàêòåðèñòèê ìîíñòðîâ:
458 MONSTERTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
468 ((Name
:'DEMON'; Rect
:(X
:7; Y
:8; Width
:50; Height
:52); Health
:60;
469 RunVel
: 7; MinPain
: 10; Pain
: 20; Jump
: 10),
471 (Name
:'IMP'; Rect
:(X
:15; Y
:10; Width
:34; Height
:50); Health
:25;
472 RunVel
: 3; MinPain
: 0; Pain
: 15; Jump
: 10),
474 (Name
:'ZOMBY'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:15;
475 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
477 (Name
:'SERG'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:20;
478 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
480 (Name
:'CYBER'; Rect
:(X
:24; Y
:9; Width
:80; Height
:110); Health
:500;
481 RunVel
: 5; MinPain
: 50; Pain
: 70; Jump
: 10),
483 (Name
:'CGUN'; Rect
:(X
:15; Y
:4; Width
:34; Height
:56); Health
:60;
484 RunVel
: 3; MinPain
: 10; Pain
: 20; Jump
: 10),
486 (Name
:'BARON'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:150;
487 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
489 (Name
:'KNIGHT'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:75;
490 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
492 (Name
:'CACO'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
493 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
495 (Name
:'SOUL'; Rect
:(X
:16; Y
:14; Width
:32; Height
:36); Health
:60;
496 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
498 (Name
:'PAIN'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
499 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
501 (Name
:'SPIDER'; Rect
:(X
:23; Y
:14; Width
:210; Height
:100); Health
:500;
502 RunVel
: 4; MinPain
: 50; Pain
: 70; Jump
: 10),
504 (Name
:'BSP'; Rect
:(X
:14; Y
:17; Width
:100; Height
:42); Health
:150;
505 RunVel
: 4; MinPain
: 0; Pain
: 20; Jump
: 10),
507 (Name
:'MANCUB'; Rect
:(X
:28; Y
:34; Width
:72; Height
:60); Health
:200;
508 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 7),
510 (Name
:'SKEL'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:200;
511 RunVel
: 6; MinPain
: 20; Pain
: 40; Jump
: 11),
513 (Name
:'VILE'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:150;
514 RunVel
: 7; MinPain
: 10; Pain
: 30; Jump
: 12),
516 (Name
:'FISH'; Rect
:(X
:6; Y
:11; Width
:20; Height
:10); Health
:35;
517 RunVel
: 14; MinPain
: 10; Pain
: 20; Jump
: 6),
519 (Name
:'BARREL'; Rect
:(X
:20; Y
:13; Width
:24; Height
:36); Health
:20;
520 RunVel
: 0; MinPain
: 0; Pain
: 0; Jump
: 0),
522 (Name
:'ROBO'; Rect
:(X
:30; Y
:26; Width
:68; Height
:76); Health
:20;
523 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 6),
525 (Name
:'MAN'; Rect
:(X
:15; Y
:6; Width
:34; Height
:52); Health
:400;
526 RunVel
: 8; MinPain
: 50; Pain
: 70; Jump
: 10));
528 // Òàáëèöà ïàðàìåòðîâ àíèìàöèè ìîíñòðîâ:
529 MONSTER_ANIMTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
532 wX
, wY
: Integer; // Îòêóäà âûëåòèò ïóëÿ
533 AnimSpeed
: Array [ANIM_SLEEP
..ANIM_PAIN
] of Byte;
534 AnimDeltaRight
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
535 AnimDeltaLeft
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
536 end = // SLEEP GO DIE MESS ATTACK ATTACK2 PAIN
537 ((LeftAnim
: False; wX
: 54; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //DEMON
538 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));
539 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))),
541 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //IMP
542 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));
543 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))),
545 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //ZOMBY
546 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));
547 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))),
549 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //SERG
550 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));
551 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))),
553 (LeftAnim
: True; wX
: 70; wY
: 73; AnimSpeed
:(3, 3, 3, 3, 3, 4, 3); //CYBER
554 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));
555 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))),
557 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 1, 0, 4); //CGUN
558 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));
559 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))),
561 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //BARON
562 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));
563 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))),
565 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //KNIGHT
566 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));
567 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))),
569 (LeftAnim
: False; wX
: 88; wY
: 69; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //CACO
570 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));
571 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))),
573 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //SOUL
574 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));
575 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))),
577 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //PAIN
578 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));
579 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))),
581 (LeftAnim
: True; wX
: 128; wY
: 64; AnimSpeed
:(3, 2, 4, 4, 1, 0, 4); //SPIDER
582 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));
583 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))),
585 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //BSP
586 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));
587 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))),
589 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 2, 4, 2, 0, 4); //MANCUB
590 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));
591 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))),
593 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //SKEL
594 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));
595 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))),
597 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //VILE
598 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));
599 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))),
601 (LeftAnim
: False; wX
: 8; wY
: 8; AnimSpeed
:(2, 2, 2, 2, 3, 0, 1); //FISH
602 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));
603 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 ))),
605 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 0, 3, 0, 0, 0, 5); //BARREL
606 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));
607 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))),
609 (LeftAnim
: False; wX
: 95; wY
: 57; AnimSpeed
:(1, 2, 1, 0, 1, 1, 0); //ROBO
610 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));
611 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))),
613 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 2, 0, 5); //MAN
614 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));
615 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))) );
617 MAX_ATM
= 89; // Âðåìÿ îæèäàíèÿ ïîñëå ïîòåðè öåëè
618 MAX_SOUL
= 512; // Îãðàíè÷åíèå Lost_Soul'îâ
621 // ////////////////////////////////////////////////////////////////////////// //
623 gMonsters
: array of TMonster
;
624 uidMap
: array [0..65535] of TMonster
; // monster knows it's index
625 freeInds
: TIdPool
= nil;
628 procedure clearUidMap ();
632 for idx
:= 0 to High(uidMap
) do uidMap
[idx
] := nil;
637 function g_Mons_getNewTrapFrameId (): DWord
; inline;
641 Inc(monCheckTrapLastFrameId
);
642 if (monCheckTrapLastFrameId
= 0) then
645 monCheckTrapLastFrameId
:= 1;
646 for f
:= 0 to High(gMonsters
) do
648 if (gMonsters
[f
] <> nil) then gMonsters
[f
].trapCheckFrameId
:= 0;
651 result
:= monCheckTrapLastFrameId
;
655 function g_Mons_getNewMPlatFrameId (): LongWord; inline;
659 Inc(monCheckMPlatLastFrameId
);
660 if (monCheckMPlatLastFrameId
= 0) then
663 monCheckMPlatLastFrameId
:= 1;
664 for f
:= 0 to High(gMonsters
) do
666 if (gMonsters
[f
] <> nil) then gMonsters
[f
].mplatCheckFrameId
:= 0;
669 result
:= monCheckMPlatLastFrameId
;
678 soulcount
: Integer = 0;
681 function allocMonster (): DWORD
;
685 result
:= freeInds
.alloc();
686 if (result
> High(gMonsters
)) then
688 olen
:= Length(gMonsters
);
689 SetLength(gMonsters
, result
+64);
690 for f
:= olen
to High(gMonsters
) do gMonsters
[f
] := nil;
695 function IsFriend(a
, b
: Byte): Boolean;
699 // Áî÷êà - âñåì äðóã:
700 if (a
= MONSTER_BARREL
) or (b
= MONSTER_BARREL
) then
703 // Ìîíñòðû îäíîãî âèäà:
706 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
707 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
708 Exit
; // Ýòè íå áüþò ñâîèõ
711 // Pain_Elemental è Lost_Soul íå âîþþò äðóã ñ äðóãîì:
712 if [a
, b
] = [MONSTER_PAIN
, MONSTER_SOUL
] then
715 //  îñòàëüíûõ ñëó÷àÿõ - áóäóò áèòü äðóã äðóãà:
720 function BehaviourDamage(SpawnerUID
: Word; BH
, SelfType
: Byte): Boolean;
723 UIDType
, MonsterType
: Byte;
728 UIDType
:= g_GetUIDType(SpawnerUID
);
729 if UIDType
= UID_MONSTER
then
731 m
:= g_Monsters_ByUID(SpawnerUID
);
732 if m
= nil then Exit
;
733 MonsterType
:= m
.FMonsterType
;
737 BH_NORMAL
: Result
:= (UIDType
= UID_PLAYER
) or
738 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
740 BH_KILLER
: Result
:= UIDType
= UID_PLAYER
;
741 BH_MANIAC
: Result
:= (UIDType
= UID_PLAYER
) or
742 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
744 BH_INSANE
: Result
:= (UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
));
745 BH_CANNIBAL
: Result
:= (UIDType
= UID_MONSTER
) and (MonsterType
= SelfType
);
750 function canShoot(m
: Byte): Boolean;
755 MONSTER_DEMON
, MONSTER_FISH
, MONSTER_BARREL
:
763 function isCorpse (o
: PObj
; immediately
: Boolean): Integer;
766 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
768 atag := atag; // shut up, fpc!
769 result := false; // don't stop
770 if (mon.FState = MONSTATE_DEAD) and g_Obj_Collide(o, @mon.FObj) then
772 case mon.FMonsterType of // Íå âîñêðåñèòü:
773 MONSTER_SOUL, MONSTER_PAIN, MONSTER_CYBER, MONSTER_SPIDER,
774 MONSTER_VILE, MONSTER_BARREL, MONSTER_ROBO: exit;
776 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
785 mres
: TMonster
= nil;
786 it
: TMonsterGrid
.Iter
;
790 // Åñëè íóæíà âåðîÿòíîñòü
791 if not immediately
and (Random(8) <> 0) then exit
;
793 // Èùåì ìåðòâûõ ìîíñòðîâ ïîáëèçîñòè
794 if gmon_debug_use_sqaccel
then
796 //mon := monsGrid.forEachInAABB(o.X+o.Rect.X, o.Y+o.Rect.Y, o.Rect.Width, o.Rect.Height, monsCollCheck);
797 //if (mon <> nil) then result := mon.mArrIdx;
798 it
:= monsGrid
.forEachInAABB(o
.X
+o
.Rect
.X
, o
.Y
+o
.Rect
.Y
, o
.Rect
.Width
, o
.Rect
.Height
);
801 case mon
.FMonsterType
of // Íå âîñêðåñèòü:
802 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
803 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: begin end;
804 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
807 if (mres
<> nil) then break
;
810 if (mres
<> nil) then result
:= mres
.mArrIdx
;
814 for a
:= 0 to High(gMonsters
) do
816 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @gMonsters
[a
].FObj
) then
818 case gMonsters
[a
].FMonsterType
of // Íå âîñêðåñèòü:
819 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
820 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: Continue
;
821 else // Îñòàëüíûõ ìîæíî âîñêðåñèòü
832 procedure g_Monsters_LoadData();
834 e_WriteLog('Loading monsters data...', TMsgType
.Notify
);
836 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
], 133, False);
837 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD
+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
838 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD
+':MTEXTURES\BARREL_DIE', 64, 64, 4);
839 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD
+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
840 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD
+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
841 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD
+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
842 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD
+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
843 g_Game_StepLoading(6);
844 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD
+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
845 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD
+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
846 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK_L', GameWAD
+':MTEXTURES\ZOMBY_ATTACK_L', 64, 64, 2);
847 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD
+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
848 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD
+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
849 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD
+':MTEXTURES\SERG_GO', 64, 64, 4);
850 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD
+':MTEXTURES\SERG_DIE', 64, 64, 5);
851 g_Game_StepLoading(13);
852 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD
+':MTEXTURES\SERG_MESS', 64, 64, 9);
853 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD
+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
854 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK_L', GameWAD
+':MTEXTURES\SERG_ATTACK_L', 64, 64, 2);
855 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD
+':MTEXTURES\SERG_PAIN', 64, 64, 1);
856 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD
+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
857 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD
+':MTEXTURES\MAN_GO', 64, 64, 4);
858 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD
+':MTEXTURES\MAN_DIE', 64, 64, 7);
859 g_Game_StepLoading(20);
860 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD
+':MTEXTURES\MAN_MESS', 64, 64, 9);
861 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD
+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
862 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD
+':MTEXTURES\MAN_PAIN', 64, 64, 1);
863 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD
+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
864 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD
+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
865 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD
+':MTEXTURES\CGUN_GO', 64, 64, 4);
866 g_Game_StepLoading(26);
867 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD
+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
868 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD
+':MTEXTURES\CGUN_DIE', 64, 64, 7);
869 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD
+':MTEXTURES\CGUN_MESS', 64, 64, 6);
870 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD
+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
871 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD
+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
872 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD
+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
873 g_Game_StepLoading(32);
874 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD
+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
875 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD
+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
876 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD
+':MTEXTURES\IMP_GO', 64, 64, 4);
877 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD
+':MTEXTURES\IMP_DIE', 64, 64, 5);
878 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD
+':MTEXTURES\IMP_MESS', 64, 64, 8);
879 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD
+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
880 g_Game_StepLoading(38);
881 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD
+':MTEXTURES\IMP_PAIN', 64, 64, 1);
882 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD
+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
883 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD
+':MTEXTURES\DEMON_GO', 64, 64, 4);
884 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD
+':MTEXTURES\DEMON_DIE', 64, 64, 6);
885 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD
+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
886 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD
+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
887 g_Game_StepLoading(44);
888 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD
+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
889 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD
+':MTEXTURES\SOUL_GO', 64, 64, 2);
890 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD
+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
891 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD
+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
892 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD
+':MTEXTURES\SOUL_DIE', 128, 128, 7);
893 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD
+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
894 g_Game_StepLoading(50);
895 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD
+':MTEXTURES\FISH_GO', 32, 32, 4);
896 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD
+':MTEXTURES\FISH_PAIN', 32, 32, 3);
897 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD
+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
898 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD
+':MTEXTURES\FISH_DIE', 32, 32, 1);
899 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD
+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
900 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD
+':MTEXTURES\SPIDER_GO', 256, 128, 6);
901 g_Game_StepLoading(56);
902 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD
+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
903 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD
+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
904 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD
+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
905 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD
+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
906 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD
+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
907 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD
+':MTEXTURES\BSP_GO', 128, 64, 6);
908 g_Game_StepLoading(62);
909 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD
+':MTEXTURES\BSP_PAIN', 128, 64, 1);
910 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD
+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
911 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD
+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
912 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD
+':MTEXTURES\BSP_DIE', 128, 64, 7);
913 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD
+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
914 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD
+':MTEXTURES\CACO_GO', 128, 128, 1);
915 g_Game_StepLoading(68);
916 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD
+':MTEXTURES\CACO_PAIN', 128, 128, 1);
917 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD
+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
918 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD
+':MTEXTURES\CACO_DIE', 128, 128, 7);
919 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD
+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
920 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD
+':MTEXTURES\PAIN_GO', 128, 128, 4);
921 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD
+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
922 g_Game_StepLoading(74);
923 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD
+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
924 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD
+':MTEXTURES\PAIN_DIE', 128, 128, 7);
925 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD
+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
926 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD
+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
927 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD
+':MTEXTURES\BARON_GO', 128, 128, 4);
928 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD
+':MTEXTURES\BARON_PAIN', 128, 128, 1);
929 g_Game_StepLoading(80);
930 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD
+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
931 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD
+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
932 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD
+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
933 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD
+':MTEXTURES\BARON_DIE', 128, 128, 7);
934 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD
+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
935 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD
+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
936 g_Game_StepLoading(86);
937 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD
+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
938 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD
+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
939 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD
+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
940 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD
+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
941 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD
+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
942 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD
+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
943 g_Game_StepLoading(92);
944 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD
+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
945 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD
+':MTEXTURES\MANCUB_GO', 128, 128, 6);
946 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD
+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
947 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD
+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
948 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD
+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
949 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD
+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
950 g_Game_StepLoading(98);
951 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD
+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
952 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD
+':MTEXTURES\SKEL_GO', 128, 128, 6);
953 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD
+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
954 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD
+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
955 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD
+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
956 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD
+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
957 g_Game_StepLoading(104);
958 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD
+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
959 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD
+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
960 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD
+':MTEXTURES\SKEL_DIE', 128, 128, 5);
961 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD
+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
962 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD
+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD
+':MTEXTURES\VILE_GO', 128, 128, 6);
964 g_Game_StepLoading(110);
965 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD
+':MTEXTURES\VILE_PAIN', 128, 128, 1);
966 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD
+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
967 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD
+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
968 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD
+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
969 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD
+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
970 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD
+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
971 g_Game_StepLoading(116);
972 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD
+':MTEXTURES\VILE_DIE', 128, 128, 9);
973 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD
+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
974 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD
+':MTEXTURES\ROBO_GO', 128, 128, 12);
975 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD
+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
976 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD
+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
977 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD
+':MTEXTURES\ROBO_DIE', 128, 128, 1);
978 g_Game_StepLoading(122);
979 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD
+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
980 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD
+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
981 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD
+':MTEXTURES\CYBER_GO', 128, 128, 4);
982 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD
+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
983 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD
+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
984 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD
+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
985 g_Game_StepLoading(128);
986 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD
+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
987 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD
+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
988 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD
+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
989 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD
+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
990 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD
+':MTEXTURES\CYBER_DIE', 128, 128, 9);
991 g_Game_StepLoading(133);
993 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_SOUNDS
], 0, False);
995 g_Sound_CreateWADEx('SOUND_MONSTER_BARREL_DIE', GameWAD
+':MSOUNDS\BARREL_DIE');
997 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN', GameWAD
+':MSOUNDS\PAIN');
998 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN2', GameWAD
+':MSOUNDS\PAIN2');
999 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION', GameWAD
+':MSOUNDS\ACTION');
1000 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION2', GameWAD
+':MSOUNDS\ACTION2');
1001 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_1', GameWAD
+':MSOUNDS\ALERT_1');
1002 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_2', GameWAD
+':MSOUNDS\ALERT_2');
1003 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_3', GameWAD
+':MSOUNDS\ALERT_3');
1004 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_1', GameWAD
+':MSOUNDS\DIE_1');
1005 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_2', GameWAD
+':MSOUNDS\DIE_2');
1006 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_3', GameWAD
+':MSOUNDS\DIE_3');
1007 g_Sound_CreateWADEx('SOUND_MONSTER_SLOP', GameWAD
+':MSOUNDS\SLOP');
1009 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ATTACK', GameWAD
+':MSOUNDS\DEMON_ATTACK');
1010 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ALERT', GameWAD
+':MSOUNDS\DEMON_ALERT');
1011 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_DIE', GameWAD
+':MSOUNDS\DEMON_DIE');
1013 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_1', GameWAD
+':MSOUNDS\IMP_ALERT_1');
1014 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_2', GameWAD
+':MSOUNDS\IMP_ALERT_2');
1015 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_1', GameWAD
+':MSOUNDS\IMP_DIE_1');
1016 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_2', GameWAD
+':MSOUNDS\IMP_DIE_2');
1017 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ACTION', GameWAD
+':MSOUNDS\IMP_ACTION');
1018 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ATTACK', GameWAD
+':MSOUNDS\IMP_ATTACK');
1020 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_PAIN', GameWAD
+':MSOUNDS\MAN_PAIN');
1021 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_ALERT', GameWAD
+':MSOUNDS\MAN_ALERT');
1022 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_DIE', GameWAD
+':MSOUNDS\MAN_DIE');
1023 g_Sound_CreateWADEx('SOUND_MONSTER_HAHA', GameWAD
+':MSOUNDS\HAHA');
1024 g_Sound_CreateWADEx('SOUND_MONSTER_TRUP', GameWAD
+':MSOUNDS\TRUP');
1026 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_ATTACK', GameWAD
+':MSOUNDS\SOUL_ATTACK');
1027 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_DIE', GameWAD
+':MSOUNDS\SOUL_DIE');
1029 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ACTION', GameWAD
+':MSOUNDS\BSP_ACTION');
1030 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_DIE', GameWAD
+':MSOUNDS\BSP_DIE');
1031 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ALERT', GameWAD
+':MSOUNDS\BSP_ALERT');
1032 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_WALK', GameWAD
+':MSOUNDS\BSP_WALK');
1034 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ACTION', GameWAD
+':MSOUNDS\VILE_ACTION');
1035 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_PAIN', GameWAD
+':MSOUNDS\VILE_PAIN');
1036 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_DIE', GameWAD
+':MSOUNDS\VILE_DIE');
1037 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ALERT', GameWAD
+':MSOUNDS\VILE_ALERT');
1038 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ATTACK', GameWAD
+':MSOUNDS\VILE_ATTACK');
1040 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ACTION', GameWAD
+':MSOUNDS\SKEL_ACTION');
1041 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_DIE', GameWAD
+':MSOUNDS\SKEL_DIE');
1042 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ALERT', GameWAD
+':MSOUNDS\SKEL_ALERT');
1043 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ATTACK', GameWAD
+':MSOUNDS\SKEL_ATTACK');
1044 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_HIT', GameWAD
+':MSOUNDS\SKEL_HIT');
1046 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_PAIN', GameWAD
+':MSOUNDS\MANCUB_PAIN');
1047 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_DIE', GameWAD
+':MSOUNDS\MANCUB_DIE');
1048 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ALERT', GameWAD
+':MSOUNDS\MANCUB_ALERT');
1049 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ATTACK', GameWAD
+':MSOUNDS\MANCUB_ATTACK');
1051 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_PAIN', GameWAD
+':MSOUNDS\PAIN_PAIN');
1052 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_DIE', GameWAD
+':MSOUNDS\PAIN_DIE');
1053 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_ALERT', GameWAD
+':MSOUNDS\PAIN_ALERT');
1055 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_DIE', GameWAD
+':MSOUNDS\BARON_DIE');
1056 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_ALERT', GameWAD
+':MSOUNDS\BARON_ALERT');
1058 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_DIE', GameWAD
+':MSOUNDS\CACO_DIE');
1059 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_ALERT', GameWAD
+':MSOUNDS\CACO_ALERT');
1061 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_DIE', GameWAD
+':MSOUNDS\CYBER_DIE');
1062 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_ALERT', GameWAD
+':MSOUNDS\CYBER_ALERT');
1063 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_WALK', GameWAD
+':MSOUNDS\CYBER_WALK');
1065 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_DIE', GameWAD
+':MSOUNDS\KNIGHT_DIE');
1066 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_ALERT', GameWAD
+':MSOUNDS\KNIGHT_ALERT');
1068 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_DIE', GameWAD
+':MSOUNDS\SPIDER_DIE');
1069 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_ALERT', GameWAD
+':MSOUNDS\SPIDER_ALERT');
1070 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_WALK', GameWAD
+':MSOUNDS\SPIDER_WALK');
1072 g_Sound_CreateWADEx('SOUND_MONSTER_FISH_ATTACK', GameWAD
+':MSOUNDS\FISH_ATTACK');
1074 freeInds
:= TIdPool
.Create();
1076 monCheckTrapLastFrameId
:= 0;
1077 monCheckMPlatLastFrameId
:= 0;
1080 procedure g_Monsters_FreeData();
1082 e_WriteLog('Releasing monsters data...', TMsgType
.Notify
);
1084 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
1085 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
1086 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
1087 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
1088 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
1089 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
1090 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
1091 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
1092 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK_L');
1093 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
1094 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
1095 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
1096 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
1097 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
1098 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
1099 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK_L');
1100 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
1101 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
1102 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
1103 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
1104 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
1105 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
1106 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
1107 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
1108 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
1109 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
1110 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
1111 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
1112 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
1113 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
1114 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
1115 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
1116 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
1117 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
1118 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
1119 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
1120 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
1121 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
1122 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
1123 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
1124 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
1125 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
1126 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
1127 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
1128 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
1129 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
1130 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
1131 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
1132 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
1133 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
1134 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
1135 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
1136 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
1137 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
1138 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
1139 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
1140 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
1141 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
1142 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
1143 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
1144 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
1145 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
1146 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
1147 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
1148 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
1149 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
1150 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
1151 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
1152 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
1153 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
1154 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
1155 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
1156 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
1157 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
1158 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
1159 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
1160 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
1161 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
1162 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
1163 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
1164 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
1165 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
1166 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
1167 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
1168 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
1169 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
1170 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
1171 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
1172 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
1173 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
1174 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
1175 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
1176 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
1177 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
1178 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
1179 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
1180 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
1181 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
1182 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
1183 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
1184 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
1185 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
1186 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
1187 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
1188 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
1189 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
1190 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
1191 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
1192 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
1193 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
1194 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
1195 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
1196 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
1197 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
1198 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
1199 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
1200 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
1201 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
1202 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
1203 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
1204 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
1205 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
1206 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
1207 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
1208 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
1209 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
1210 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
1211 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
1212 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
1213 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
1214 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
1215 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
1216 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
1218 g_Sound_Delete('SOUND_MONSTER_BARREL_DIE');
1220 g_Sound_Delete('SOUND_MONSTER_PAIN');
1221 g_Sound_Delete('SOUND_MONSTER_PAIN2');
1222 g_Sound_Delete('SOUND_MONSTER_ACTION');
1223 g_Sound_Delete('SOUND_MONSTER_ACTION2');
1224 g_Sound_Delete('SOUND_MONSTER_ALERT_1');
1225 g_Sound_Delete('SOUND_MONSTER_ALERT_2');
1226 g_Sound_Delete('SOUND_MONSTER_ALERT_3');
1227 g_Sound_Delete('SOUND_MONSTER_DIE_1');
1228 g_Sound_Delete('SOUND_MONSTER_DIE_2');
1229 g_Sound_Delete('SOUND_MONSTER_DIE_3');
1230 g_Sound_Delete('SOUND_MONSTER_SLOP');
1232 g_Sound_Delete('SOUND_MONSTER_DEMON_ATTACK');
1233 g_Sound_Delete('SOUND_MONSTER_DEMON_ALERT');
1234 g_Sound_Delete('SOUND_MONSTER_DEMON_DIE');
1236 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_1');
1237 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_2');
1238 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_1');
1239 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_2');
1240 g_Sound_Delete('SOUND_MONSTER_IMP_ACTION');
1241 g_Sound_Delete('SOUND_MONSTER_IMP_ATTACK');
1243 g_Sound_Delete('SOUND_MONSTER_MAN_PAIN');
1244 g_Sound_Delete('SOUND_MONSTER_MAN_ALERT');
1245 g_Sound_Delete('SOUND_MONSTER_MAN_DIE');
1246 g_Sound_Delete('SOUND_MONSTER_HAHA');
1247 g_Sound_Delete('SOUND_MONSTER_TRUP');
1249 g_Sound_Delete('SOUND_MONSTER_SOUL_ATTACK');
1250 g_Sound_Delete('SOUND_MONSTER_SOUL_DIE');
1252 g_Sound_Delete('SOUND_MONSTER_BSP_ACTION');
1253 g_Sound_Delete('SOUND_MONSTER_BSP_DIE');
1254 g_Sound_Delete('SOUND_MONSTER_BSP_ALERT');
1255 g_Sound_Delete('SOUND_MONSTER_BSP_WALK');
1257 g_Sound_Delete('SOUND_MONSTER_VILE_ACTION');
1258 g_Sound_Delete('SOUND_MONSTER_VILE_PAIN');
1259 g_Sound_Delete('SOUND_MONSTER_VILE_DIE');
1260 g_Sound_Delete('SOUND_MONSTER_VILE_ALERT');
1261 g_Sound_Delete('SOUND_MONSTER_VILE_ATTACK');
1263 g_Sound_Delete('SOUND_MONSTER_SKEL_ACTION');
1264 g_Sound_Delete('SOUND_MONSTER_SKEL_DIE');
1265 g_Sound_Delete('SOUND_MONSTER_SKEL_ALERT');
1266 g_Sound_Delete('SOUND_MONSTER_SKEL_ATTACK');
1267 g_Sound_Delete('SOUND_MONSTER_SKEL_HIT');
1269 g_Sound_Delete('SOUND_MONSTER_MANCUB_PAIN');
1270 g_Sound_Delete('SOUND_MONSTER_MANCUB_DIE');
1271 g_Sound_Delete('SOUND_MONSTER_MANCUB_ALERT');
1272 g_Sound_Delete('SOUND_MONSTER_MANCUB_ATTACK');
1274 g_Sound_Delete('SOUND_MONSTER_PAIN_PAIN');
1275 g_Sound_Delete('SOUND_MONSTER_PAIN_DIE');
1276 g_Sound_Delete('SOUND_MONSTER_PAIN_ALERT');
1278 g_Sound_Delete('SOUND_MONSTER_BARON_DIE');
1279 g_Sound_Delete('SOUND_MONSTER_BARON_ALERT');
1281 g_Sound_Delete('SOUND_MONSTER_CACO_DIE');
1282 g_Sound_Delete('SOUND_MONSTER_CACO_ALERT');
1284 g_Sound_Delete('SOUND_MONSTER_CYBER_DIE');
1285 g_Sound_Delete('SOUND_MONSTER_CYBER_ALERT');
1286 g_Sound_Delete('SOUND_MONSTER_CYBER_WALK');
1288 g_Sound_Delete('SOUND_MONSTER_KNIGHT_DIE');
1289 g_Sound_Delete('SOUND_MONSTER_KNIGHT_ALERT');
1291 g_Sound_Delete('SOUND_MONSTER_SPIDER_DIE');
1292 g_Sound_Delete('SOUND_MONSTER_SPIDER_ALERT');
1293 g_Sound_Delete('SOUND_MONSTER_SPIDER_WALK');
1295 g_Sound_Delete('SOUND_MONSTER_FISH_ATTACK');
1301 procedure g_Monsters_Init();
1306 procedure g_Monsters_Free (clearGrid
: Boolean=true);
1310 e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid
]);
1316 for a
:= 0 to High(gMonsters
) do gMonsters
[a
].Free();
1319 monCheckTrapLastFrameId
:= 0;
1320 monCheckMPlatLastFrameId
:= 0;
1324 // will be called from map loader
1325 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
1328 monsGrid
:= TMonsterGrid
.Create(x
, y
, w
, h
);
1329 //clearUidMap(); // why not?
1330 e_LogWritefln('%s', ['Recreated monster tree']);
1334 function g_Monsters_Create(MonsterType
: Byte; X
, Y
: Integer;
1335 Direction
: TDirection
; AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
1342 // Íåò òàêîãî ìîíñòðà
1343 if (MonsterType
> MONSTER_MAN
) or (MonsterType
= 0) then exit
;
1345 // Ñîáëþäàåì îãðàíè÷åíèå Lost_Soul'îâ
1346 if MonsterType
= MONSTER_SOUL
then
1348 if soulcount
> MAX_SOUL
then exit
;
1352 find_id
:= allocMonster();
1354 mon
:= TMonster
.Create(MonsterType
, find_id
, ForcedUID
);
1355 gMonsters
[find_id
] := mon
;
1356 mon
.mArrIdx
:= find_id
;
1359 uidMap
[mon
.FUID
] := mon
;
1361 // Íàñòðàèâàåì ïîëîæåíèå
1366 FObj
.X
:= X
-FObj
.Rect
.X
- (FObj
.Rect
.Width
div 2);
1367 FObj
.Y
:= Y
-FObj
.Rect
.Y
- FObj
.Rect
.Height
;
1371 FObj
.X
:= X
-FObj
.Rect
.X
;
1372 FObj
.Y
:= Y
-FObj
.Rect
.Y
;
1375 FDirection
:= Direction
;
1376 FStartDirection
:= Direction
;
1379 FObj
.oldX
:= FObj
.X
;
1380 FObj
.oldY
:= FObj
.Y
;
1383 mon
.positionChanged();
1388 procedure g_Monsters_killedp();
1392 if gMonsters
= nil then
1395 // Ïðèêîëèñò ñìååòñÿ íàä ñìåðòüþ èãðîêà:
1396 h
:= High(gMonsters
);
1399 if (gMonsters
[a
] <> nil) then
1401 with gMonsters
[a
] do
1403 if (FMonsterType
= MONSTER_MAN
) and
1404 (FState
<> MONSTATE_DEAD
) and
1405 (FState
<> MONSTATE_SLEEP
) and
1406 (FState
<> MONSTATE_DIE
) then
1408 g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj
.X
, FObj
.Y
);
1416 procedure g_Monsters_PreUpdate();
1420 if gMonsters
= nil then Exit
;
1421 for a
:= 0 to High(gMonsters
) do
1422 if (gMonsters
[a
] <> nil) and (not gMonsters
[a
].FRemoved
) then
1423 gMonsters
[a
].PreUpdate();
1426 procedure g_Monsters_Update();
1431 if gTime
mod (GAME_TICK
*2) = 0 then
1435 if abs(pt_x
) > 246 then pt_xs
:= -pt_xs
;
1436 if abs(pt_y
) > 100 then pt_ys
:= -pt_ys
;
1439 gMon
:= True; // Äëÿ ðàáîòû BlockMon'à
1441 if gmon_debug_think
or gmon_debug_one_think_step
then
1443 gmon_debug_one_think_step
:= false;
1444 for a
:= 0 to High(gMonsters
) do
1446 if (gMonsters
[a
] = nil) then continue
;
1447 if not gMonsters
[a
].FRemoved
then
1449 if g_Game_IsClient
then
1450 gMonsters
[a
].ClientUpdate()
1452 gMonsters
[a
].Update();
1456 gMonsters
[a
].Free();
1457 gMonsters
[a
] := nil;
1465 procedure g_Monsters_Draw();
1469 if gMonsters
<> nil then
1471 for a
:= 0 to High(gMonsters
) do
1473 if (gMonsters
[a
] <> nil) then gMonsters
[a
].Draw();
1478 procedure g_Monsters_DrawHealth();
1483 if gMonsters
= nil then Exit
;
1484 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1486 for a
:= 0 to High(gMonsters
) do
1488 if gMonsters
[a
] <> nil then
1490 e_TextureFontPrint(gMonsters
[a
].FObj
.X
+ gMonsters
[a
].FObj
.Rect
.X
,
1491 gMonsters
[a
].FObj
.Y
+ gMonsters
[a
].FObj
.Rect
.Y
+ gMonsters
[a
].FObj
.Rect
.Height
- fH
,
1492 IntToStr(gMonsters
[a
].FHealth
), gStdFont
);
1497 function g_Monsters_ByUID (UID
: Word): TMonster
;
1499 result
:= uidMap
[UID
];
1502 procedure g_Monsters_SaveState (st
: TStream
);
1506 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ìîíñòðîâ
1508 for i
:= 0 to High(gMonsters
) do
1510 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then count
+= 1;
1513 // Ñîõðàíÿåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1514 utils
.writeInt(st
, LongInt(pt_x
));
1515 utils
.writeInt(st
, LongInt(pt_xs
));
1516 utils
.writeInt(st
, LongInt(pt_y
));
1517 utils
.writeInt(st
, LongInt(pt_ys
));
1519 // Êîëè÷åñòâî ìîíñòðîâ
1520 utils
.writeInt(st
, LongInt(count
));
1522 if (count
= 0) then exit
;
1524 // Ñîõðàíÿåì ìîíñòðîâ
1525 for i
:= 0 to High(gMonsters
) do
1527 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then
1530 utils
.writeInt(st
, Byte(gMonsters
[i
].MonsterType
));
1531 // Ñîõðàíÿåì äàííûå ìîíñòðà:
1532 gMonsters
[i
].SaveState(st
);
1538 procedure g_Monsters_LoadState (st
: TStream
);
1546 g_Monsters_Free(false);
1548 // Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1549 pt_x
:= utils
.readLongInt(st
);
1550 pt_xs
:= utils
.readLongInt(st
);
1551 pt_y
:= utils
.readLongInt(st
);
1552 pt_ys
:= utils
.readLongInt(st
);
1554 // Êîëè÷åñòâî ìîíñòðîâ
1555 count
:= utils
.readLongInt(st
);
1557 if (count
= 0) then exit
;
1558 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid monster count');
1560 // Çàãðóæàåì ìîíñòðîâ
1561 for a
:= 0 to count
-1 do
1564 b
:= utils
.readByte(st
);
1566 mon
:= g_Monsters_Create(b
, 0, 0, TDirection
.D_LEFT
);
1567 if (mon
= nil) then raise XStreamError
.Create('g_Monsters_LoadState: ID = -1 (can''t create)');
1568 // Çàãðóæàåì äàííûå ìîíñòðà
1574 // ////////////////////////////////////////////////////////////////////////// //
1575 function g_Mons_SpawnAt (monType
: Integer; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1578 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1580 result
:= g_Monsters_Create(monType
, x
, y
, dir
);
1585 function g_Mons_SpawnAt (const typeName
: AnsiString; x
, y
: Integer; dir
: TDirection
=TDirection
.D_LEFT
): TMonster
; overload
;
1587 result
:= g_Mons_SpawnAt(g_Mons_TypeIdByName(typeName
), x
, y
, dir
);
1592 // ////////////////////////////////////////////////////////////////////////// //
1593 function g_Mons_TypeLo (): Integer; inline; begin result
:= Low(MONSTERTABLE
); end;
1594 function g_Mons_TypeHi (): Integer; inline; begin result
:= High(MONSTERTABLE
); end;
1597 function g_Mons_TypeIdByName (const name
: String): Integer;
1602 while (i
<= MONSTER_MAN
) do
1604 if (CompareText(name
, MONSTERTABLE
[i
].Name
) = 0) then
1613 if (CompareText(name
, 'zombie') = 0) then result
:= MONSTER_ZOMBY
;
1617 function g_Mons_NameByTypeId (monType
: Integer): AnsiString;
1619 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1620 result
:= MONSTERTABLE
[monType
].Name
1626 function g_Mons_GetKilledByTypeId (monType
: Integer): AnsiString;
1628 if (monType
>= MONSTER_DEMON
) and (monType
<= MONSTER_MAN
) then
1629 Result
:= KilledByMonster
[monType
]
1635 // ////////////////////////////////////////////////////////////////////////// //
1636 { T M o n s t e r : }
1638 procedure TMonster
.setGameX (v
: Integer); inline; begin FObj
.X
:= v
; positionChanged(); end;
1639 procedure TMonster
.setGameY (v
: Integer); inline; begin FObj
.Y
:= v
; positionChanged(); end;
1641 procedure TMonster
.setPosition (ax
, ay
: Integer; callPosChanged
: Boolean=true); inline; begin FObj
.X
:= ax
; FObj
.Y
:= ay
; if callPosChanged
then positionChanged(); end;
1643 procedure TMonster
.moveBy (dx
, dy
: Integer); inline;
1645 if (dx
<> 0) or (dy
<> 0) then
1653 procedure TMonster
.doDamage (v
: Integer);
1655 if (v
<= 0) then exit
;
1656 if (v
> 32767) then v
:= 32767;
1657 Damage(v
, 0, 0, 0, mEDamageType
);
1660 procedure TMonster
.ActionSound();
1662 case FMonsterType
of
1664 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ACTION', FObj
.X
, FObj
.Y
);
1665 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
,
1667 g_Sound_PlayExAt('SOUND_MONSTER_ACTION', FObj
.X
, FObj
.Y
);
1668 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1669 MONSTER_KNIGHT
, MONSTER_PAIN
, MONSTER_DEMON
,
1671 g_Sound_PlayExAt('SOUND_MONSTER_ACTION2', FObj
.X
, FObj
.Y
);
1673 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ACTION', FObj
.X
, FObj
.Y
);
1675 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ACTION', FObj
.X
, FObj
.Y
);
1677 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ACTION', FObj
.X
, FObj
.Y
);
1681 g_Sound_PlayExAt('SOUND_MONSTER_HAHA', FObj
.X
, FObj
.Y
);
1685 procedure TMonster
.PainSound();
1693 case FMonsterType
of
1694 MONSTER_IMP
, MONSTER_ZOMBY
, MONSTER_SERG
,
1695 MONSTER_SKEL
, MONSTER_CGUN
:
1696 g_Sound_PlayExAt('SOUND_MONSTER_PAIN', FObj
.X
, FObj
.Y
);
1697 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1698 MONSTER_KNIGHT
, MONSTER_DEMON
, MONSTER_SPIDER
,
1699 MONSTER_BSP
, MONSTER_CYBER
:
1700 g_Sound_PlayExAt('SOUND_MONSTER_PAIN2', FObj
.X
, FObj
.Y
);
1702 g_Sound_PlayExAt('SOUND_MONSTER_VILE_PAIN', FObj
.X
, FObj
.Y
);
1704 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_PAIN', FObj
.X
, FObj
.Y
);
1706 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_PAIN', FObj
.X
, FObj
.Y
);
1708 g_Sound_PlayExAt('SOUND_MONSTER_MAN_PAIN', FObj
.X
, FObj
.Y
);
1712 procedure TMonster
.DieSound();
1714 case FMonsterType
of
1717 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_1', FObj
.X
, FObj
.Y
);
1718 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_2', FObj
.X
, FObj
.Y
);
1720 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1722 0: g_Sound_PlayExAt('SOUND_MONSTER_DIE_1', FObj
.X
, FObj
.Y
);
1723 1: g_Sound_PlayExAt('SOUND_MONSTER_DIE_2', FObj
.X
, FObj
.Y
);
1724 2: g_Sound_PlayExAt('SOUND_MONSTER_DIE_3', FObj
.X
, FObj
.Y
);
1727 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_DIE', FObj
.X
, FObj
.Y
);
1729 g_Sound_PlayExAt('SOUND_MONSTER_BARREL_DIE', FObj
.X
, FObj
.Y
);
1731 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_DIE', FObj
.X
, FObj
.Y
);
1733 g_Sound_PlayExAt('SOUND_MONSTER_BSP_DIE', FObj
.X
, FObj
.Y
);
1735 g_Sound_PlayExAt('SOUND_MONSTER_VILE_DIE', FObj
.X
, FObj
.Y
);
1737 g_Sound_PlayExAt('SOUND_MONSTER_BARON_DIE', FObj
.X
, FObj
.Y
);
1739 g_Sound_PlayExAt('SOUND_MONSTER_CACO_DIE', FObj
.X
, FObj
.Y
);
1741 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_DIE', FObj
.X
, FObj
.Y
);
1743 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_DIE', FObj
.X
, FObj
.Y
);
1745 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_DIE', FObj
.X
, FObj
.Y
);
1747 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_DIE', FObj
.X
, FObj
.Y
);
1749 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_DIE', FObj
.X
, FObj
.Y
);
1751 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_DIE', FObj
.X
, FObj
.Y
);
1753 g_Sound_PlayExAt('SOUND_MONSTER_MAN_DIE', FObj
.X
, FObj
.Y
);
1757 procedure TMonster
.WakeUpSound();
1759 case FMonsterType
of
1762 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_1', FObj
.X
, FObj
.Y
);
1763 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_2', FObj
.X
, FObj
.Y
);
1765 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1767 0: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_1', FObj
.X
, FObj
.Y
);
1768 1: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_2', FObj
.X
, FObj
.Y
);
1769 2: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_3', FObj
.X
, FObj
.Y
);
1772 g_Sound_PlayExAt('SOUND_MONSTER_MAN_ALERT', FObj
.X
, FObj
.Y
);
1774 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ALERT', FObj
.X
, FObj
.Y
);
1776 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ALERT', FObj
.X
, FObj
.Y
);
1778 g_Sound_PlayExAt('SOUND_MONSTER_BARON_ALERT', FObj
.X
, FObj
.Y
);
1780 g_Sound_PlayExAt('SOUND_MONSTER_CACO_ALERT', FObj
.X
, FObj
.Y
);
1782 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_ALERT', FObj
.X
, FObj
.Y
);
1784 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_ALERT', FObj
.X
, FObj
.Y
);
1786 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ALERT', FObj
.X
, FObj
.Y
);
1788 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_ALERT', FObj
.X
, FObj
.Y
);
1790 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ALERT', FObj
.X
, FObj
.Y
);
1792 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ALERT', FObj
.X
, FObj
.Y
);
1794 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_ALERT', FObj
.X
, FObj
.Y
);
1800 procedure TMonster
.BFGHit();
1802 if FMonsterType
= MONSTER_FISH
then
1805 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1806 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1807 {if g_Game_IsServer and g_Game_IsNet then
1808 MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
1809 FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
1813 function TMonster
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
1815 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1823 function TMonster
.Collide(Panel
: TPanel
): Boolean;
1825 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1830 Panel
.Width
, Panel
.Height
);
1833 function TMonster
.Collide(X
, Y
: Integer): Boolean;
1835 X
:= X
- FObj
.X
- FObj
.Rect
.X
;
1836 Y
:= Y
- FObj
.Y
- FObj
.Rect
.Y
;
1837 Result
:= (x
>= 0) and (x
<= FObj
.Rect
.Width
) and
1838 (y
>= 0) and (y
<= FObj
.Rect
.Height
);
1841 procedure TMonster
.Respawn
;
1847 FDirection
:= FStartDirection
;
1848 {GameX}FObj
.X
:= FStartX
;
1849 {GameY}FObj
.Y
:= FStartY
;
1850 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
1851 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
1856 FDieTriggers
:= nil;
1857 FWaitAttackAnim
:= False;
1858 FChainFire
:= False;
1861 FState
:= MONSTATE_SLEEP
;
1862 FCurAnim
:= ANIM_SLEEP
;
1864 positionChanged(); // this updates spatial accelerators
1866 if g_Game_IsNet
and g_Game_IsServer
then
1868 MH_SEND_MonsterPos(FUID
);
1869 MH_SEND_MonsterState(FUID
);
1873 constructor TMonster
.Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
1876 FramesID
: DWORD
= 0;
1880 if ForcedUID
< 0 then
1881 FUID
:= g_CreateUID(UID_MONSTER
)
1885 FMonsterType
:= MonsterType
;
1889 FState
:= MONSTATE_SLEEP
;
1890 FCurAnim
:= ANIM_SLEEP
;
1891 FHealth
:= MONSTERTABLE
[MonsterType
].Health
;
1892 FMaxHealth
:= FHealth
;
1893 FObj
.Rect
:= MONSTERTABLE
[MonsterType
].Rect
;
1894 FDieTriggers
:= nil;
1895 FSpawnTrigger
:= -1;
1896 FWaitAttackAnim
:= False;
1897 FChainFire
:= False;
1899 FNoRespawn
:= False;
1901 FBehaviour
:= BH_NORMAL
;
1905 mEDamageType
:= HIT_SOME
;
1909 trapCheckFrameId
:= 0;
1910 mplatCheckFrameId
:= 0;
1913 if FMonsterType
in [MONSTER_ROBO
, MONSTER_BARREL
] then
1914 FBloodKind
:= BLOOD_SPARKS
1916 FBloodKind
:= BLOOD_NORMAL
;
1917 if FMonsterType
= MONSTER_CACO
then
1923 else if FMonsterType
in [MONSTER_BARON
, MONSTER_KNIGHT
] then
1936 SetLength(FAnim
, Length(ANIMTABLE
));
1938 for a
:= 0 to High(FAnim
) do
1940 FAnim
[a
, TDirection
.D_LEFT
] := nil;
1941 FAnim
[a
, TDirection
.D_RIGHT
] := nil;
1944 for a
:= ANIM_SLEEP
to ANIM_PAIN
do
1945 if (ANIMTABLE
[a
].name
<> '') and
1946 (MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
] <> 0) then
1948 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1949 '_'+ANIMTABLE
[a
].name
;
1951 res
:= g_Frames_Exists(s
);
1954 res
:= g_Frames_Get(FramesID
, s
);
1956 // Åñëè íåò òàêîé àíèìàöèè, òî ïðîáóåì çàìåíèòü åå íà àíèìàöèþ ñìåðòè:
1959 // Çàìåíÿåì òîëüêî ANIM_MESS íà ANIM_DIE:
1960 if a
<> ANIM_MESS
then
1963 if g_Frames_Get(FramesID
, 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1964 '_'+ANIMTABLE
[ANIM_DIE
].name
) then
1966 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1967 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1968 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1969 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1974 FAnim
[a
, TDirection
.D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1975 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1977 // Åñëè åñòü îòäåëüíàÿ ëåâàÿ àíèìàöèÿ - çàãðóæàåì:
1978 if MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
then
1980 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1981 '_'+ANIMTABLE
[a
].name
+'_L';
1982 if g_Frames_Exists(s
) then
1983 g_Frames_Get(FramesID
, s
);
1986 FAnim
[a
, TDirection
.D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1987 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1990 // Äëÿ êîëäóíà çàãðóæàåì òàêæå àíèìàöèþ îãíÿ:
1991 if MonsterType
= MONSTER_VILE
then
1993 g_Frames_Get(FramesID
, 'FRAMES_FIRE');
1994 vilefire
:= TAnimation
.Create(FramesID
, True, 2);
2000 function TMonster
.Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
2007 // Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup
2008 if (gLMSRespawn
> LMS_RESPAWN_NONE
) then exit
;
2010 // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
2011 if (FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_REVIVE
) then
2014 // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà:
2015 if (t
= HIT_ELECTRO
) and (FMonsterType
= MONSTER_FISH
) and g_Game_IsServer
then
2018 if Random(2) = 0 then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
2020 SetState(MONSTATE_RUN
);
2024 // Àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
2025 if (t
= HIT_FLAME
) and (FMonsterType
in [MONSTER_VILE
, MONSTER_SOUL
]) then
2027 // Ïðîñíóòüñÿ âñå-òàêè ñòîèò
2028 if FState
= MONSTATE_SLEEP
then
2029 SetState(MONSTATE_GO
);
2033 // Ëîâóøêà óáèâàåò ñðàçó:
2034 if t
= HIT_TRAP
then
2037 // Ðîáîòó óðîíà íåò:
2038 if FMonsterType
= MONSTER_ROBO
then
2042 if g_Game_IsServer
then Dec(FHealth
, aDamage
);
2044 // Óñèëèâàåì áîëü ìîíñòðà îò óðîíà:
2047 FPain
:= FPain
+aDamage
;
2049 // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå:
2050 if FState
<> MONSTATE_PAIN
then
2051 if (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) and
2052 (FMonsterType
<> MONSTER_BARREL
) then
2053 SetState(MONSTATE_PAIN
);
2055 // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè:
2056 if (gBloodCount
> 0) then
2058 c
:= Min(aDamage
, 200);
2059 c
:= c
*gBloodCount
- (aDamage
div 4) + Random(c
div 2);
2061 if (VelX
= 0) and (VelY
= 0) then
2065 HIT_TRAP
, HIT_ACID
, HIT_ELECTRO
, HIT_FLAME
: MakeBloodSimple(c
);
2066 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, VelX
, VelY
);
2070 // Òåïåðü öåëü - óäàðèâøèé, åñëè òîëüêî íå ñàì ñåáÿ:
2071 if (SpawnerUID
<> FUID
) and (BehaviourDamage(SpawnerUID
, FBehaviour
, FMonsterType
)) then
2073 FTargetUID
:= SpawnerUID
;
2077 // Çäîðîâüå çàêîí÷èëîñü:
2078 if FHealth
<= 0 then
2080 // Åñëè ýòî íå áî÷êà è óáèë èãðîê, òî åìó +1:
2081 if (FMonsterType
<> MONSTER_BARREL
) then
2083 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2085 p
:= g_Player_Get(SpawnerUID
);
2086 if (p
<> nil) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2088 p
.MonsterKills
:= p
.MonsterKills
+1;
2089 if gGameSettings
.GameMode
= GM_COOP
then
2090 p
.Frags
:= p
.Frags
+ 1;
2091 // Uncomment this if you want to double-kill monsters
2095 if gLMSRespawn
= LMS_RESPAWN_NONE
then
2097 Inc(gCoopMonstersKilled
);
2098 if g_Game_IsNet
then
2104 case FMonsterType
of
2105 MONSTER_ZOMBY
: c
:= ITEM_AMMO_BULLETS
;
2106 MONSTER_SERG
: c
:= ITEM_WEAPON_SHOTGUN1
;
2107 MONSTER_CGUN
: c
:= ITEM_WEAPON_CHAINGUN
;
2108 MONSTER_MAN
: c
:= ITEM_KEY_RED
;
2115 it
:= g_Items_Create(FObj
.X
+ (FObj
.Rect
.Width
div 2),
2116 FObj
.Y
+ (FObj
.Rect
.Height
div 2),
2118 g_Items_SetDrop(it
); // mark it as monster drop
2119 g_Obj_Push(g_Items_ObjByIdx(it
), (FObj
.Vel
.X
div 2)-3+Random(7),
2120 (FObj
.Vel
.Y
div 2)-Random(4));
2121 //positionChanged(); // this updates spatial accelerators
2122 if g_Game_IsServer
and g_Game_IsNet
then
2123 MH_SEND_ItemSpawn(True, it
);
2126 // Òðóï äàëüøå íå èäåò:
2129 // Ó òðóïà ðàçìåðû ìåíüøå:
2130 if (FMonsterType
<> MONSTER_FISH
) and (FMonsterType
<> MONSTER_PAIN
) then
2132 FObj
.Rect
.Y
:= FObj
.Rect
.Y
+ FObj
.Rect
.Height
-12;
2133 FObj
.Rect
.Height
:= 12;
2137 // Óðîí áûë ñèëüíûì => ñëàáûå - â êàøó:
2138 if (FHealth
<= -30) and
2139 ((FMonsterType
= MONSTER_IMP
) or (FMonsterType
= MONSTER_ZOMBY
) or
2140 (FMonsterType
= MONSTER_SERG
) or (FMonsterType
= MONSTER_CGUN
) or
2141 (FMonsterType
= MONSTER_MAN
)) then
2143 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
2144 SetState(MONSTATE_DIE
, ANIM_MESS
);
2149 SetState(MONSTATE_DIE
);
2152 // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà:
2153 if g_Game_IsServer
then ActivateTriggers();
2158 if FState
= MONSTATE_SLEEP
then
2159 begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì:
2160 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2161 SetState(MONSTATE_GO
);
2164 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2168 function TMonster
.Heal(Value
: Word): Boolean;
2171 if g_Game_IsClient
then
2176 if FHealth
< FMaxHealth
then
2178 IncMax(FHealth
, Value
, FMaxHealth
);
2179 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2184 destructor TMonster
.Destroy();
2188 for a
:= 0 to High(FAnim
) do
2190 FAnim
[a
, TDirection
.D_LEFT
].Free();
2191 FAnim
[a
, TDirection
.D_RIGHT
].Free();
2196 if (mProxyId
<> -1) then
2198 if (monsGrid
<> nil) then
2200 monsGrid
.removeBody(mProxyId
);
2201 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
2202 e_WriteLog(Format('monster #%d:(%u): removed from grid; mProxyid=%d', [mArrIdx
, UID
, mProxyId
]), MSG_NOTIFY
);
2208 if (mArrIdx
<> -1) and (mArrIdx
< Length(gMonsters
)) then
2210 freeInds
.release(mArrIdx
);
2211 gMonsters
[mArrIdx
] := nil;
2215 uidMap
[FUID
] := nil;
2217 inherited Destroy();
2220 procedure TMonster
.Draw();
2223 dx
, dy
, c
, fX
, fY
: Integer;
2226 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType));
2227 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState));
2229 FObj
.lerp(gLerpFactor
, fX
, fY
);
2231 // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
2232 if FMonsterType
= MONSTER_VILE
then
2233 if FState
= MONSTATE_SHOOT
then
2234 if GetPos(FTargetUID
, @o
) then
2235 vilefire
.Draw(o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-32,
2236 o
.Y
+o
.Rect
.Y
+o
.Rect
.Height
-128, TMirrorType
.None
);
2238 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
2240 if (g_dbg_scale
= 1.0) then
2242 if not g_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
,
2243 sX
-128, sY
-128, sWidth
+256, sHeight
+256) then
2247 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
2248 if FState
= MONSTATE_DEAD
then
2249 case FMonsterType
of
2250 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
2253 // Åñòü ÷òî ðèñîâàòü ïðè òåêóùåì ïîâåäåíèè:
2254 if FAnim
[FCurAnim
, FDirection
] <> nil then
2256 // Åñëè íåò ëåâîé àíèìàöèè èëè îíà ñîâïàäàåò ñ ïðàâîé => îòðàæàåì ïðàâóþ:
2257 if (FDirection
= TDirection
.D_LEFT
) and
2258 ((not MONSTER_ANIMTABLE
[FMonsterType
].LeftAnim
) or
2259 (FAnim
[FCurAnim
, TDirection
.D_LEFT
].FramesID
= FAnim
[FCurAnim
, TDirection
.D_RIGHT
].FramesID
)) and
2260 (FMonsterType
<> MONSTER_BARREL
) then
2261 m
:= TMirrorType
.Horizontal
2263 m
:= TMirrorType
.None
;
2265 // Ëåâàÿ àíèìàöèÿ => ìåíÿåì ñìåùåíèå îòíîñèòåëüíî öåíòðà:
2266 if (FDirection
= TDirection
.D_LEFT
) and
2267 (FMonsterType
<> MONSTER_BARREL
) then
2269 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].X
;
2270 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].Y
;
2272 if m
= TMirrorType
.Horizontal
then
2273 begin // Íåò îòäåëüíîé ëåâîé àíèìàöèè
2274 // Ðàññòîÿíèå îò êðàÿ òåêñòóðû äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2275 c
:= (MONSTERTABLE
[FMonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[FMonsterType
].Rect
.Width
;
2276 // Ðàññòîÿíèå îò êðàÿ õèò áîêñà äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2277 dx
:= FAnim
[FCurAnim
, FDirection
].Width
- c
- MONSTERTABLE
[FMonsterType
].Rect
.X
;
2278 // Ò.ê. äâèãàòü òåêñòóðó íóæíî áóäåò â ïðîòèâîïîëîæíîì íàïðàâëåíèè:
2280 // Ýòî çíà÷èò: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
2283 else // Ïðàâàÿ àíèìàöèÿ
2285 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].X
;
2286 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].Y
;
2290 FAnim
[FCurAnim
, FDirection
].Draw(fX
+dx
, fY
+dy
, m
);
2293 if g_debug_Frames
then
2295 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2297 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2298 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2303 procedure TMonster
.MakeBloodSimple(Count
: Word);
2305 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+8,
2306 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2307 Count
div 2, 3, -1, 16, (FObj
.Rect
.Height
*2 div 3),
2308 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2309 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-8,
2310 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2311 Count
div 2, -3, -1, 16, (FObj
.Rect
.Height
*2) div 3,
2312 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2315 procedure TMonster
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
2317 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2318 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2319 Count
, VelX
, VelY
, 16, (FObj
.Rect
.Height
*2) div 3,
2320 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2323 procedure TMonster
.Push(vx
, vy
: Integer);
2325 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
2326 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
2327 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2330 procedure TMonster
.SetState(State
: Byte; ForceAnim
: Byte = 255);
2334 // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul,
2335 // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ:
2336 if (State
= MONSTATE_DIE
) and (MonsterType
= MONSTER_SOUL
) then
2337 soulcount
:= soulcount
-1;
2339 // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü:
2341 MONSTATE_DIE
, MONSTATE_DEAD
, MONSTATE_REVIVE
:
2342 if (State
<> MONSTATE_DEAD
) and (State
<> MONSTATE_REVIVE
) and
2343 (State
<> MONSTATE_GO
) then
2350 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
, ForceAnim
);
2352 // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè:
2354 MONSTATE_SLEEP
: Anim
:= ANIM_SLEEP
;
2355 MONSTATE_PAIN
: Anim
:= ANIM_PAIN
;
2356 MONSTATE_WAIT
: Anim
:= ANIM_SLEEP
;
2357 MONSTATE_CLIMB
, MONSTATE_RUN
, MONSTATE_RUNOUT
, MONSTATE_GO
: Anim
:= ANIM_GO
;
2358 MONSTATE_SHOOT
: Anim
:= ANIM_ATTACK
;
2359 MONSTATE_ATTACK
: Anim
:= ANIM_ATTACK
;
2360 MONSTATE_DIE
: Anim
:= ANIM_DIE
;
2362 begin // íà÷àëè âîñêðåøàòüñÿ
2364 FAnim
[Anim
, FDirection
].Revert(True);
2366 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
2367 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
2374 // Íàäî ñìåíèòü àíèìàöèþ íà íåñòàíäàðòíóþ:
2375 if ForceAnim
<> 255 then
2378 // Åñëè àíèìàöèÿ íîâàÿ - ïåðåçàïóñêàåì å¸:
2379 if FCurAnim
<> Anim
then
2380 if FAnim
[Anim
, FDirection
] <> nil then
2382 FAnim
[Anim
, FDirection
].Reset();
2387 function TMonster
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
2394 //  òî÷êå íàçíà÷åíèÿ ñòåíà:
2395 if g_CollideLevel(X
, Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
) then
2397 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
2398 if g_Game_IsServer
and g_Game_IsNet
then
2399 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
2405 // Ýôôåêò òåëåïîðòà â ïîçèöèè ìîíñòðà:
2408 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
2409 TA
:= TAnimation
.Create(FramesID
, False, 6);
2410 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj
.X
, Obj
.Y
);
2411 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2412 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2414 if g_Game_IsServer
and g_Game_IsNet
then
2415 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2416 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 1,
2420 FObj
.X
:= X
- FObj
.Rect
.X
;
2421 FObj
.Y
:= Y
- FObj
.Rect
.Y
;
2422 FObj
.oldX
:= FObj
.X
; // don't interpolate after teleport
2423 FObj
.oldY
:= FObj
.Y
;
2427 FDirection
:= TDirection
.D_LEFT
2430 FDirection
:= TDirection
.D_RIGHT
2434 if FDirection
= TDirection
.D_RIGHT
then
2435 FDirection
:= TDirection
.D_LEFT
2437 FDirection
:= TDirection
.D_RIGHT
;
2440 // Ýôôåêò òåëåïîðòà â òî÷êå íàçíà÷åíèÿ:
2441 if not silent
and (TA
<> nil) then
2443 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2444 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2447 if g_Game_IsServer
and g_Game_IsNet
then
2448 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2449 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 0,
2453 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2457 procedure TMonster
.PreUpdate();
2459 FObj
.oldX
:= FObj
.X
;
2460 FObj
.oldY
:= FObj
.Y
;
2463 procedure TMonster
.Update();
2465 a
, b
, sx
, sy
, wx
, wy
, oldvelx
, i
: Integer;
2471 it
: TMonsterGrid
.Iter
;
2477 // Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup
2478 if (gLMSRespawn
> LMS_RESPAWN_NONE
) then exit
;
2480 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
2481 if FMonsterType
= MONSTER_FISH
then
2482 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
2483 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2486 // Ëåòàþùèå ìîíñòðû:
2487 if ((FMonsterType
= MONSTER_SOUL
) or
2488 (FMonsterType
= MONSTER_PAIN
) or
2489 (FMonsterType
= MONSTER_CACO
)) and
2490 (FState
<> MONSTATE_DIE
) and
2491 (FState
<> MONSTATE_DEAD
) then
2494 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
2495 if gTime
mod (GAME_TICK
*2) <> 0 then
2497 g_Obj_Move(@FObj
, fall
, True, True);
2498 positionChanged(); // this updates spatial accelerators
2502 if FPainTicks
> 0 then
2505 FPainSound
:= False;
2508 st
:= g_Obj_Move(@FObj
, fall
, True, True);
2509 positionChanged(); // this updates spatial accelerators
2511 // Åñëè ãîðèì - ïîäæèãàåì äðóãèõ ìîíñòðîâ, íî íå íà 100 òèêîâ êàæäûé ðàç:
2512 if FFireTime
> 0 then
2514 it
:= monsGrid
.forEachInAABB(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
2516 if mit
.UID
<> FUID
then
2517 mit
.CatchFire(FFireAttacker
, FFireTime
);
2520 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
2521 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
2522 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
2525 if alive
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2527 Inc(gCoopMonstersKilled
);
2528 if g_Game_IsNet
then
2535 oldvelx
:= FObj
.Vel
.X
;
2537 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
2538 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
2539 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2541 if FFireTime
> 0 then
2543 if WordBool(st
and MOVE_INWATER
) then
2548 FFireTime
:= FFireTime
- 1;
2549 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2550 if FFirePainTime
= 0 then
2552 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
2553 FFirePainTime
:= 18;
2556 FFirePainTime
:= FFirePainTime
- 1;
2560 // Ìåðòâûé íè÷åãî íå äåëàåò:
2561 if (FState
= MONSTATE_DEAD
) then
2564 // AI ìîíñòðîâ âûêëþ÷åí:
2565 if g_debug_MonsterOff
then
2568 if FState
<> MONSTATE_SLEEP
then
2569 SetState(MONSTATE_SLEEP
);
2572 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
2573 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
2574 case FMonsterType
of
2576 if Random(4) = 0 then
2577 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2578 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2579 MONSTER_ROBO
, MONSTER_BARREL
:
2580 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2581 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2583 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
2584 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
2587 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
2588 if FMonsterType
= MONSTER_BARREL
then
2590 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
2591 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
2592 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2593 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
2597 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
2598 if FMonsterType
= MONSTER_SOUL
then
2599 if WordBool(st
and MOVE_HITAIR
) then
2600 g_Obj_SetSpeed(@FObj
, 16);
2605 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
2606 if FObj
.Vel
.Y
< 0 then
2607 if WordBool(st
and MOVE_INWATER
) then
2610 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
2611 FTargetTime
:= FTargetTime
+ 1;
2614 if FShellTimer
> -1 then
2615 if FShellTimer
= 0 then
2617 if FShellType
= SHELL_SHELL
then
2618 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2619 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2620 GameVelX
, GameVelY
-2, SHELL_SHELL
)
2621 else if FShellType
= SHELL_DBLSHELL
then
2623 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2624 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2625 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
2626 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2627 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2628 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
2631 end else Dec(FShellTimer
);
2633 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
2635 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
2636 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
2637 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2638 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
2639 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2640 (FObj
.Accel
.Y
= 0) then
2641 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2644 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
2646 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
2647 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
2649 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2650 if gSoundEffectsDF
then PainSound();
2652 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
2655 // Ñíèæàåì áîëü ñî âðåìåíåì:
2658 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
2659 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
2663 SetState(MONSTATE_GO
);
2667 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
2670 FSleep
:= FSleep
+ 1;
2672 // Ïðîñïàëè äîñòàòî÷íî:
2673 if FSleep
>= 18 then
2678 // Íà èãðîêîâ èäóò òîëüêî îáû÷íûå ìîíñòðû, êèëëåðû è ìàíüÿêè
2679 if (FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_KILLER
) or (FBehaviour
= BH_MANIAC
) then
2680 // Åñëè åñòü èãðîê ðÿäîì, ïðîñûïàåìñÿ è èäåì ê íåìó:
2681 if (gPlayers
<> nil) then
2682 for a
:= 0 to High(gPlayers
) do
2683 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
2684 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FPowerups
[MR_INVIS
] < gTime
) then
2686 if g_Look(@FObj
, @Obj
, FDirection
) then
2688 FTargetUID
:= gPlayers
[a
].UID
;
2691 SetState(MONSTATE_GO
);
2695 // Íà ìîíñòðîâ òÿíåò ìàíüÿêîâ, ïîåõàâøèõ è êàííèáàëîâ
2696 if (FTargetUID
= 0) and ((FBehaviour
= BH_MANIAC
)
2697 or (FBehaviour
= BH_INSANE
) or (FBehaviour
= BH_CANNIBAL
)) then
2698 // Åñëè åñòü ïîäõîäÿùèé ìîíñòð ðÿäîì:
2699 if gMonsters
<> nil then
2700 for a
:= 0 to High(gMonsters
) do
2701 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
2702 (gMonsters
[a
].FUID
<> FUID
) then
2704 // Ìàíüÿêè íàïàäàþò íà âñåõ ìîíñòðîâ, êðîìå äðóçåé
2705 if (FBehaviour
= BH_MANIAC
) and
2706 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2708 // Ïîåõàâøèå òàêæå, íî ìîãóò îáîçëèòüñÿ íà áî÷êó
2709 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
) and
2710 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2712 // Êàííèáàëû íàïàäàþò íà ñåáå ïîäîáíûõ
2713 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
2715 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
2717 FTargetUID
:= gMonsters
[a
].UID
;
2720 SetState(MONSTATE_GO
);
2726 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
2729 FSleep
:= FSleep
- 1;
2731 // Âûæäàëè äîñòàòî÷íî - èäåì:
2733 SetState(MONSTATE_GO
);
2736 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
2738 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2739 if WordBool(st
and MOVE_BLOCK
) then
2743 SetState(MONSTATE_RUNOUT
);
2748 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
2749 if (FMonsterType
= MONSTER_VILE
) then
2750 if isCorpse(@FObj
, False) <> -1 then
2753 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
2758 // Öåëü ïîãèáëà èëè äàâíî æäåì:
2759 if (not GetPos(FTargetUID
, @o
)) or (FTargetTime
> MAX_ATM
) then
2760 if not findNewPrey() then
2761 begin // Íîâûõ öåëåé íåò
2769 o
.Rect
:= _Rect(0, 0, 0, 1);
2771 else // Íîâàÿ öåëü åñòü - áåðåì åå êîîðäèíàòû
2772 GetPos(FTargetUID
, @o
);
2774 // Öåëü î÷åíü áëèçêî - ïèíàåì:
2775 if g_Obj_Collide(@FObj
, @o
) and (FTargetUID
<> 0) then
2778 if (FMonsterType
<> MONSTER_CYBER
) or (Random(2) = 0) then
2785 // Ðàññòîÿíèå äî öåëè:
2786 sx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
2787 sy
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2789 // Ïîâîðà÷èâàåìñÿ â ñòîðîíó öåëè:
2791 FDirection
:= TDirection
.D_RIGHT
2793 FDirection
:= TDirection
.D_LEFT
;
2795 // Åñëè ìîíñòð óìååò ñòðåëÿòü è åñòü ïî êîìó - ñòðåëÿåì:
2796 if canShoot(FMonsterType
) and (FTargetUID
<> 0) then
2797 if Abs(sx
) > Abs(sy
) then // óãîë âûñòðåëà óäîáíûé
2798 if shoot(@o
, False) then
2801 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
2802 if Abs(sx
) < 40 then
2803 if FMonsterType
<> MONSTER_FISH
then
2806 SetState(MONSTATE_RUN
);
2807 if Random(2) = 0 then
2808 FDirection
:= TDirection
.D_LEFT
2810 FDirection
:= TDirection
.D_RIGHT
;
2815 // Óïåðëèñü â ñòåíó:
2816 if WordBool(st
and MOVE_HITWALL
) then
2818 if g_Triggers_PressR(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
,
2819 FObj
.Rect
.Height
, FUID
, ACTIVATE_MONSTERPRESS
) <> nil then
2820 begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå
2822 SetState(MONSTATE_WAIT
);
2827 case FMonsterType
of
2828 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
2830 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2831 (FObj
.Accel
.Y
= 0) then
2832 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
2833 // Ïðûæîê ÷åðåç ñòåíó:
2834 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2835 SetState(MONSTATE_CLIMB
);
2842 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
2843 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
2844 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
2846 if FMonsterType
= MONSTER_FISH
then
2848 if not WordBool(st
and MOVE_INWATER
) then
2849 begin // Ðûáà âíå âîäû:
2850 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2851 begin // "Ñòîèò" òâåðäî
2852 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
2853 if FObj
.Accel
.Y
= 0 then FObj
.Vel
.Y
:= -6;
2854 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
2858 SetState(MONSTATE_PAIN
);
2859 FPain
:= FPain
+ 50;
2863 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2865 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2869 // Ðûáà ïëûâåò ââåðõ:
2870 if FObj
.Vel
.Y
< 0 then
2871 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
2873 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
2875 // Ïëàâàåì òóäà-ñþäà:
2876 if Random(2) = 0 then
2877 FDirection
:= TDirection
.D_LEFT
2879 FDirection
:= TDirection
.D_RIGHT
;
2881 SetState(MONSTATE_RUN
);
2885 else // Ëåòàþùèå ìîíñòðû
2887 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2889 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2894 else // "Íàçåìíûå" ìîíñòðû
2896 // Âîçìîæíî, ïèíàåì êóñêè:
2897 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
2899 b
:= Abs(FObj
.Vel
.X
);
2900 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2901 for a
:= 0 to High(gGibs
) do
2903 if gGibs
[a
].alive
and
2904 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2905 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
2908 if FObj
.Vel
.X
< 0 then
2910 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
2914 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
2919 // Áîññû ìîãóò ïèíàòü òðóïû:
2920 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
2921 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
2923 b
:= Abs(FObj
.Vel
.X
);
2924 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2925 for a
:= 0 to High(gCorpses
) do
2926 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
2928 co
:= gCorpses
[a
].Obj
;
2929 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2930 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
2932 if FObj
.Vel
.X
< 0 then
2933 gCorpses
[a
].Damage(b
*2, FUID
, -b
, Random(7)) // íàëåâî
2935 gCorpses
[a
].Damage(b
*2, FUID
, b
, Random(7)); // íàïðàâî
2938 // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
2940 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2942 if (Random(4) = 0) and (FObj
.Accel
.Y
= 0) then
2943 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2946 FSleep
:= FSleep
+ 1;
2952 if Random(8) = 0 then
2956 // Áåæèì â âûáðàííóþ ñòîðîíó:
2957 if FDirection
= TDirection
.D_RIGHT
then
2958 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2960 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2962 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2963 if WordBool(st
and MOVE_INWATER
) then
2964 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2965 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2966 if FMonsterType
= MONSTER_FISH
then
2970 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
2972 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2973 if WordBool(st
and MOVE_BLOCK
) then
2977 SetState(MONSTATE_RUNOUT
);
2982 FSleep
:= FSleep
- 1;
2984 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
2985 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
2988 SetState(MONSTATE_GO
);
2989 // Ñòåíà - èäåì îáðàòíî:
2990 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2993 if Random(8) = 0 then
2997 // Áåæèì â âûáðàííóþ ñòîðîíó:
2998 if FDirection
= TDirection
.D_RIGHT
then
2999 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3001 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3003 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3004 if WordBool(st
and MOVE_INWATER
) then
3005 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3006 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3007 if FMonsterType
= MONSTER_FISH
then
3011 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3013 // Âûøëè èç ÁëîêÌîíà:
3014 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3017 FSleep
:= FSleep
- 1;
3019 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3020 if FSleep
<= -18 then
3023 SetState(MONSTATE_GO
);
3024 // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî:
3025 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3028 if Random(8) = 0 then
3032 // Áåæèì â âûáðàííóþ ñòîðîíó:
3033 if FDirection
= TDirection
.D_RIGHT
then
3034 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3036 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3038 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3039 if WordBool(st
and MOVE_INWATER
) then
3040 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3041 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3042 if FMonsterType
= MONSTER_FISH
then
3046 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3048 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3049 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3050 (not WordBool(st
and MOVE_HITWALL
)) then
3053 SetState(MONSTATE_GO
);
3055 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3056 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3060 SetState(MONSTATE_RUN
);
3064 // Áåæèì â âûáðàííóþ ñòîðîíó:
3065 if FDirection
= TDirection
.D_RIGHT
then
3066 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3068 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3070 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3071 if WordBool(st
and MOVE_INWATER
) then
3072 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3073 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3074 if FMonsterType
= MONSTER_FISH
then
3078 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3079 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3081 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3082 if FMonsterType
= MONSTER_SOUL
then
3084 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3085 SetState(MONSTATE_GO
);
3090 // Çàìåäëÿåìñÿ ïðè àòàêå:
3091 if FMonsterType
<> MONSTER_FISH
then
3092 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3094 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3095 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3097 // Öåëü ïîãèáëà => èäåì äàëüøå:
3098 if not GetPos(FTargetUID
, @o
) then
3100 SetState(MONSTATE_GO
);
3105 // Öåëü íå âèäíî => èäåì äàëüøå:
3106 if not g_Look(@FObj
, @o
, FDirection
) then
3108 SetState(MONSTATE_GO
);
3113 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3114 if g_Obj_CollideWater(@o
, 0, 0) then
3116 SetState(MONSTATE_GO
);
3122 tx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2);
3123 ty
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2);
3124 g_Weapon_HitUID(FTargetUID
, 2, FUID
, HIT_SOME
);
3127 end; // case FState of ...
3131 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3132 if FState
= MONSTATE_REVIVE
then
3133 if FAnim
[FCurAnim
, FDirection
].Played
then
3134 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3135 FAnim
[FCurAnim
, FDirection
].Revert(False);
3136 SetState(MONSTATE_GO
);
3139 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3140 if vilefire
<> nil then
3143 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3144 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
] <> nil) then
3146 if FAnim
[FCurAnim
, FDirection
].Played
then
3148 SetState(MONSTATE_DEAD
);
3149 if g_Game_IsNet
then MH_SEND_CoopStats();
3151 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3152 if FMonsterType
in [MONSTER_PAIN
, MONSTER_SOUL
, MONSTER_BARREL
] then
3155 else if (FMonsterType
= MONSTER_PAIN
) and
3156 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3157 FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2 + 1) and
3158 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3159 for i
:= 0 to 2 do // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à ïîñåðåäèíå àíèìàöèè:
3161 // FIXME: lostsouls may stuck in walls here
3162 mon
:= g_Monsters_Create(MONSTER_SOUL
,
3163 FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+RandomRange(-15,16),
3164 FObj
.Y
+FObj
.Rect
.Y
+RandomRange(-7,8), FDirection
);
3167 mon
.SetState(MONSTATE_GO
);
3168 mon
.FNoRespawn
:= True;
3169 gTotalMonsters
+= 1;
3170 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3175 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3176 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3177 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3178 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3179 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3180 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3181 if FState
= MONSTATE_ATTACK
then
3182 begin // Ñîñòîÿíèå - Àòàêà
3183 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3184 if FMonsterType
<> MONSTER_SOUL
then
3185 SetState(MONSTATE_GO
);
3187 else // Ñîñòîÿíèå - Ñòðåëüáà
3189 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3190 if not FChainFire
then
3191 SetState(MONSTATE_GO
)
3193 begin // Íàäî ñòðåëÿòü åùå
3194 FChainFire
:= False;
3195 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3196 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3197 FAnim
[FCurAnim
, FDirection
].Reset();
3201 FWaitAttackAnim
:= False;
3204 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3205 if (FMonsterType
= MONSTER_SOUL
) or
3206 ( (not FWaitAttackAnim
) and
3207 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3208 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3210 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3211 if FState
= MONSTATE_ATTACK
then
3212 begin // Ñîñòîÿíèå - Àòàêà
3213 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3214 if FMonsterType
= MONSTER_SOUL
then
3215 FAnim
[FCurAnim
, FDirection
].Reset();
3217 case FMonsterType
of
3218 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3219 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3220 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3221 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3222 if FMonsterType
= MONSTER_SOUL
then
3223 SetState(MONSTATE_GO
);
3226 // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì:
3227 if g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
) <> 0 then
3228 g_Sound_PlayExAt('SOUND_MONSTER_FISH_ATTACK', FObj
.X
, FObj
.Y
);
3230 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3231 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3232 if FCurAnim
= ANIM_ATTACK2
then
3235 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3236 if g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
) <> 0 then
3237 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_HIT', FObj
.X
, FObj
.Y
);
3241 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3242 if FCurAnim
= ANIM_ATTACK2
then
3244 sx
:= isCorpse(@FObj
, True);
3246 begin // Íàøëè, êîãî âîñêðåñèòü
3247 gMonsters
[sx
].SetState(MONSTATE_REVIVE
);
3248 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3249 // Âîñêðåøàòü - ñåáå âðåäèòü:
3250 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3256 else // Ñîñòîÿíèå - Ñòðåëüáà
3258 // Âû÷èñëÿåì êîîðäèíàòû, îòêóäà âûëåòèò ïóëÿ:
3259 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
;
3261 if FDirection
= TDirection
.D_LEFT
then
3263 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
-(MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2));
3264 wx
:= MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2)-wx
;
3265 end; // Ýòî çíà÷èò: wx := hitX + (hitWidth / 2) - (wx - (hitX + (hitWidth / 2)))
3268 wy
:= FObj
.Y
+ MONSTER_ANIMTABLE
[FMonsterType
].wY
;
3270 // Ìîíñòð íå ìîæåò öåëèòüñÿ â îáúåêò çà ñïèíîé, ñòðåëÿÿ âëåâî:
3271 if (FDirection
= TDirection
.D_LEFT
) and (tx
> wx
) then
3274 ty
:= wy
+ Random(11) - 5;
3276 // È àíàëîãè÷íî, ñòðåëÿÿ âïðàâî:
3277 if (FDirection
= TDirection
.D_RIGHT
) and (tx
< wx
) then
3280 ty
:= wy
+ Random(11) - 5;
3283 // Äåëàåì âûñòðåë íóæíûì îðóæèåì:
3284 case FMonsterType
of
3286 g_Weapon_ball1(wx
, wy
, tx
, ty
, FUID
);
3289 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3290 g_Weapon_gun(wx
, wy
, tx
, ty
, 1, 3, FUID
, True);
3291 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3295 g_Weapon_shotgun(wx
, wy
, tx
, ty
, FUID
);
3296 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3298 FShellType
:= SHELL_SHELL
;
3302 g_Weapon_dshotgun(wx
, wy
, tx
, ty
, FUID
);
3304 FShellType
:= SHELL_DBLSHELL
;
3309 g_Weapon_rocket(wx
, wy
, tx
, ty
, FUID
);
3310 // MH_SEND_MonsterAttack(FUID, wx, wy, tx, ty);
3313 g_Weapon_revf(wx
, wy
, tx
, ty
, FUID
, FTargetUID
);
3316 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3317 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3318 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3322 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3323 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3324 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
3327 g_Weapon_aplasma(wx
, wy
, tx
, ty
, FUID
);
3329 g_Weapon_plasma(wx
, wy
, tx
, ty
, FUID
);
3331 g_Weapon_manfire(wx
, wy
, tx
, ty
, FUID
);
3332 MONSTER_BARON
, MONSTER_KNIGHT
:
3333 g_Weapon_ball7(wx
, wy
, tx
, ty
, FUID
);
3335 g_Weapon_ball2(wx
, wy
, tx
, ty
, FUID
);
3337 begin // Ñîçäàåì Lost_Soul:
3338 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+(FObj
.Rect
.Width
div 2),
3339 FObj
.Y
+FObj
.Rect
.Y
, FDirection
);
3342 begin // Öåëü - öåëü Pain_Elemental'à. Ëåòèì ê íåé:
3343 mon
.FTargetUID
:= FTargetUID
;
3344 GetPos(FTargetUID
, @o
);
3345 mon
.FTargetTime
:= 0;
3346 mon
.FNoRespawn
:= True;
3347 mon
.SetState(MONSTATE_GO
);
3348 mon
.shoot(@o
, True);
3349 Inc(gTotalMonsters
);
3351 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3356 if FMonsterType
<> MONSTER_PAIN
then
3357 if g_Game_IsNet
then
3358 MH_SEND_MonsterShot(FUID
, wx
, wy
, tx
, ty
);
3360 // Ñêîðîñòðåëüíûå ìîíñòðû:
3361 if (FMonsterType
= MONSTER_CGUN
) or
3362 (FMonsterType
= MONSTER_SPIDER
) or
3363 (FMonsterType
= MONSTER_BSP
) or
3364 (FMonsterType
= MONSTER_MANCUB
) or
3365 (FMonsterType
= MONSTER_ROBO
) then
3366 if not GetPos(FTargetUID
, @o
) then
3367 // Öåëü ìåðòâà - èùåì íîâóþ:
3369 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3370 if shoot(@o
, False) then
3374 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3375 FWaitAttackAnim
:= True;
3378 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3379 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3381 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3382 // Çâóêè ïðè ïåðåäâèæåíèè:
3383 case FMonsterType
of
3385 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3386 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3387 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3389 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3390 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3391 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3393 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3394 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3395 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3397 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3398 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3399 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3403 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3404 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3405 FObj
.Vel
.X
:= oldvelx
;
3407 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3408 if FAnim
[FCurAnim
, FDirection
] <> nil then
3409 FAnim
[FCurAnim
, FDirection
].Update();
3412 procedure TMonster
.SetDeadAnim
;
3414 if FAnim
<> nil then
3415 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3418 procedure TMonster
.RevertAnim(R
: Boolean = True);
3420 if FAnim
<> nil then
3421 if FAnim
[FCurAnim
, FDirection
].IsReverse
<> R
then
3422 FAnim
[FCurAnim
, FDirection
].Revert(R
);
3425 function TMonster
.AnimIsReverse
: Boolean;
3427 if FAnim
<> nil then
3428 Result
:= FAnim
[FCurAnim
, FDirection
].IsReverse
3433 procedure TMonster
.ClientUpdate();
3435 a
, b
, sx
, sy
, oldvelx
: Integer;
3442 sx
:= 0; // SHUT UP COMPILER
3446 // Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup
3447 if (gLMSRespawn
> LMS_RESPAWN_NONE
) then exit
;
3449 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
3450 if FMonsterType
= MONSTER_FISH
then
3451 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3452 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
3455 // Ëåòàþùèå ìîíòñðû:
3456 if ((FMonsterType
= MONSTER_SOUL
) or
3457 (FMonsterType
= MONSTER_PAIN
) or
3458 (FMonsterType
= MONSTER_CACO
)) and
3459 (FState
<> MONSTATE_DIE
) and
3460 (FState
<> MONSTATE_DEAD
) then
3463 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
3464 if gTime
mod (GAME_TICK
*2) <> 0 then
3466 g_Obj_Move(@FObj
, fall
, True, True);
3467 positionChanged(); // this updates spatial accelerators
3471 if FPainTicks
> 0 then
3474 FPainSound
:= False;
3477 st
:= g_Obj_Move(@FObj
, fall
, True, True);
3478 positionChanged(); // this updates spatial accelerators
3480 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
3481 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
3482 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
3488 oldvelx
:= FObj
.Vel
.X
;
3490 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
3491 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
3492 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3494 if FFireTime
> 0 then
3496 if WordBool(st
and MOVE_INWATER
) then
3501 FFireTime
:= FFireTime
- 1;
3505 // Ìåðòâûé íè÷åãî íå äåëàåò:
3506 if (FState
= MONSTATE_DEAD
) then
3509 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
3510 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
3511 case FMonsterType
of
3513 if Random(4) = 0 then
3514 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3515 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3516 MONSTER_ROBO
, MONSTER_BARREL
:
3517 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3518 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3520 g_Game_Effect_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
3521 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
3524 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
3525 if FMonsterType
= MONSTER_BARREL
then
3527 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
3528 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3529 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3530 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
3534 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
3535 if FMonsterType
= MONSTER_SOUL
then
3536 if WordBool(st
and MOVE_HITAIR
) then
3537 g_Obj_SetSpeed(@FObj
, 16);
3542 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
3543 if FObj
.Vel
.Y
< 0 then
3544 if WordBool(st
and MOVE_INWATER
) then
3547 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
3548 FTargetTime
:= FTargetTime
+ 1;
3550 if FShellTimer
> -1 then
3551 if FShellTimer
= 0 then
3553 if FShellType
= SHELL_SHELL
then
3554 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3555 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3556 GameVelX
, GameVelY
-2, SHELL_SHELL
)
3557 else if FShellType
= SHELL_DBLSHELL
then
3559 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3560 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3561 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
3562 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3563 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3564 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
3567 end else Dec(FShellTimer
);
3569 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
3571 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
3572 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
3573 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3574 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
3575 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3576 (FObj
.Accel
.Y
= 0) then
3577 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3580 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
3582 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
3583 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
3585 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
3586 if gSoundEffectsDF
then PainSound();
3588 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
3591 // Ñíèæàåì áîëü ñî âðåìåíåì:
3594 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
3595 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
3597 SetState(MONSTATE_GO
);
3602 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
3605 FSleep
:= FSleep
+ 1;
3607 // Ïðîñïàëè äîñòàòî÷íî:
3608 if FSleep
>= 18 then
3614 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
3617 FSleep
:= FSleep
- 1;
3620 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
3622 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3623 if WordBool(st
and MOVE_BLOCK
) then
3627 SetState(MONSTATE_RUNOUT
);
3632 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
3633 if (FMonsterType
= MONSTER_VILE
) then
3634 if isCorpse(@FObj
, False) <> -1 then
3636 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
3642 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
3643 if Abs(sx
) < 40 then
3644 if FMonsterType
<> MONSTER_FISH
then
3646 SetState(MONSTATE_RUN
);
3652 // Óïåðëèñü â ñòåíó:
3653 if WordBool(st
and MOVE_HITWALL
) then
3655 case FMonsterType
of
3656 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
3658 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3659 (FObj
.Accel
.Y
= 0) then
3660 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
3661 // Ïðûæîê ÷åðåç ñòåíó:
3662 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3663 SetState(MONSTATE_CLIMB
);
3670 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
3671 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
3672 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
3674 if FMonsterType
= MONSTER_FISH
then
3676 if not WordBool(st
and MOVE_INWATER
) then
3677 begin // Ðûáà âíå âîäû:
3678 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
3679 begin // "Ñòîèò" òâåðäî
3680 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
3681 if FObj
.Accel
.Y
= 0 then
3683 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
3687 SetState(MONSTATE_PAIN
);
3688 FPain
:= FPain
+ 50;
3692 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3694 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3698 // Ðûáà ïëûâåò ââåðõ:
3699 if FObj
.Vel
.Y
< 0 then
3700 if not g_Obj_CollideLiquid(@FObj
, 0, -16) then
3702 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
3704 // Ïëàâàåì òóäà-ñþäà:
3705 SetState(MONSTATE_RUN
);
3710 else // Ëåòàþùèå ìîíñòðû
3712 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3714 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3719 else // "Íàçåìíûå" ìîíñòðû
3721 // Âîçìîæíî, ïèíàåì êóñêè:
3722 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
3724 b
:= Abs(FObj
.Vel
.X
);
3725 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3726 for a
:= 0 to High(gGibs
) do
3728 if gGibs
[a
].alive
and
3729 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3730 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
3733 if FObj
.Vel
.X
< 0 then
3735 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
3739 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
3741 positionChanged(); // this updates spatial accelerators
3745 // Áîññû ìîãóò ïèíàòü òðóïû:
3746 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
3747 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
3749 b
:= Abs(FObj
.Vel
.X
);
3750 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3751 for a
:= 0 to High(gCorpses
) do
3752 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
3754 co
:= gCorpses
[a
].Obj
;
3755 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3756 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
3758 if FObj
.Vel
.X
< 0 then
3759 gCorpses
[a
].Damage(b
*2, FUID
, -b
, Random(7)) // íàëåâî
3761 gCorpses
[a
].Damage(b
*2, FUID
, b
, Random(7)); // íàïðàâî
3766 FSleep
:= FSleep
+ 1;
3772 if Random(8) = 0 then
3776 // Áåæèì â âûáðàííóþ ñòîðîíó:
3777 if FDirection
= TDirection
.D_RIGHT
then
3778 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3780 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3782 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3783 if WordBool(st
and MOVE_INWATER
) then
3784 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3785 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3786 if FMonsterType
= MONSTER_FISH
then
3790 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
3792 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3793 if WordBool(st
and MOVE_BLOCK
) then
3795 SetState(MONSTATE_RUNOUT
);
3801 FSleep
:= FSleep
- 1;
3803 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
3804 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
3806 SetState(MONSTATE_GO
);
3810 if Random(8) = 0 then
3814 // Áåæèì â âûáðàííóþ ñòîðîíó:
3815 if FDirection
= TDirection
.D_RIGHT
then
3816 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3818 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3820 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3821 if WordBool(st
and MOVE_INWATER
) then
3822 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3823 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3824 if FMonsterType
= MONSTER_FISH
then
3828 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3830 // Âûøëè èç ÁëîêÌîíà:
3831 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3834 FSleep
:= FSleep
- 1;
3836 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3837 if FSleep
<= -18 then
3839 SetState(MONSTATE_GO
);
3843 if Random(8) = 0 then
3847 // Áåæèì â âûáðàííóþ ñòîðîíó:
3848 if FDirection
= TDirection
.D_RIGHT
then
3849 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3851 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3853 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3854 if WordBool(st
and MOVE_INWATER
) then
3855 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3856 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3857 if FMonsterType
= MONSTER_FISH
then
3861 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3863 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3864 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3865 (not WordBool(st
and MOVE_HITWALL
)) then
3867 SetState(MONSTATE_GO
);
3870 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3871 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3873 SetState(MONSTATE_RUN
);
3878 // Áåæèì â âûáðàííóþ ñòîðîíó:
3879 if FDirection
= TDirection
.D_RIGHT
then
3880 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3882 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3884 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3885 if WordBool(st
and MOVE_INWATER
) then
3886 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3887 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3888 if FMonsterType
= MONSTER_FISH
then
3892 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3893 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3895 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3896 if FMonsterType
= MONSTER_SOUL
then
3898 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3899 SetState(MONSTATE_GO
);
3904 // Çàìåäëÿåìñÿ ïðè àòàêå:
3905 if FMonsterType
<> MONSTER_FISH
then
3906 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3908 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3909 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3911 // Öåëü ïîãèáëà => èäåì äàëüøå:
3912 if not GetPos(FTargetUID
, @o
) then
3914 SetState(MONSTATE_GO
);
3919 // Öåëü íå âèäíî => èäåì äàëüøå:
3920 if not g_Look(@FObj
, @o
, FDirection
) then
3922 SetState(MONSTATE_GO
);
3927 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3928 if g_Obj_CollideWater(@o
, 0, 0) then
3930 SetState(MONSTATE_GO
);
3936 end; // case FState of ...
3940 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3941 if FState
= MONSTATE_REVIVE
then
3942 if FAnim
[FCurAnim
, FDirection
].Played
then
3943 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3944 FAnim
[FCurAnim
, FDirection
].Revert(False);
3945 SetState(MONSTATE_GO
);
3948 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3949 if vilefire
<> nil then
3952 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3953 if (FState
= MONSTATE_DIE
) and
3954 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3955 (FAnim
[FCurAnim
, FDirection
].Played
) then
3958 SetState(MONSTATE_DEAD
);
3960 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3961 if (FMonsterType
= MONSTER_PAIN
) or
3962 (FMonsterType
= MONSTER_SOUL
) or
3963 (FMonsterType
= MONSTER_BARREL
) then
3966 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3969 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3970 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3971 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3972 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3973 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3974 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3975 if FState
= MONSTATE_ATTACK
then
3976 begin // Ñîñòîÿíèå - Àòàêà
3977 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3978 if FMonsterType
<> MONSTER_SOUL
then
3979 SetState(MONSTATE_GO
);
3981 else // Ñîñòîÿíèå - Ñòðåëüáà
3983 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3984 if not FChainFire
then
3985 SetState(MONSTATE_GO
)
3987 begin // Íàäî ñòðåëÿòü åùå
3988 FChainFire
:= False;
3989 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3990 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3991 FAnim
[FCurAnim
, FDirection
].Reset();
3995 FWaitAttackAnim
:= False;
3998 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3999 if (FMonsterType
= MONSTER_SOUL
) or
4000 ( (not FWaitAttackAnim
) and
4001 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
4002 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
4004 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
4005 if FState
= MONSTATE_ATTACK
then
4006 begin // Ñîñòîÿíèå - Àòàêà
4007 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
4008 if FMonsterType
= MONSTER_SOUL
then
4009 FAnim
[FCurAnim
, FDirection
].Reset();
4011 case FMonsterType
of
4012 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
4013 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
4014 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
4015 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
4016 if FMonsterType
= MONSTER_SOUL
then
4017 SetState(MONSTATE_GO
);
4020 g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
);
4022 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4023 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
4024 if FCurAnim
= ANIM_ATTACK2
then
4027 o
.Vel
.X
:= IfThen(FDirection
= TDirection
.D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
4028 g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
);
4032 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
4033 if FCurAnim
= ANIM_ATTACK2
then
4035 sx
:= isCorpse(@FObj
, True);
4037 begin // Íàøëè, êîãî âîñêðåñèòü
4038 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
4039 // Âîñêðåøàòü - ñåáå âðåäèòü:
4040 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
4046 else // Ñîñòîÿíèå - Ñòðåëüáà
4048 // Ñêîðîñòðåëüíûå ìîíñòðû:
4049 if (FMonsterType
= MONSTER_CGUN
) or
4050 (FMonsterType
= MONSTER_SPIDER
) or
4051 (FMonsterType
= MONSTER_BSP
) or
4052 (FMonsterType
= MONSTER_MANCUB
) or
4053 (FMonsterType
= MONSTER_ROBO
) then
4054 if not GetPos(FTargetUID
, @o
) then
4055 // Öåëü ìåðòâà - èùåì íîâóþ:
4057 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
4058 if shoot(@o
, False) then
4062 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
4063 FWaitAttackAnim
:= True;
4066 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
4067 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
4069 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
4070 // Çâóêè ïðè ïåðåäâèæåíèè:
4071 case FMonsterType
of
4073 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4074 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4075 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
4077 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4078 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4079 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
4081 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4082 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
4083 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4085 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
4086 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
4087 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
4091 // Êîñòûëü äëÿ ïîòîêîâ
4092 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
4093 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
4094 FObj
.Vel
.X
:= oldvelx
;
4096 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
4097 if FAnim
[FCurAnim
, FDirection
] <> nil then
4098 FAnim
[FCurAnim
, FDirection
].Update();
4101 procedure TMonster
.ClientAttack(wx
, wy
, atx
, aty
: Integer);
4103 case FMonsterType
of
4106 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
4107 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4111 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
4113 FShellType
:= SHELL_SHELL
;
4117 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', wx
, wy
);
4119 FShellType
:= SHELL_DBLSHELL
;
4121 MONSTER_CGUN
, MONSTER_SPIDER
:
4123 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
4124 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
4127 g_Weapon_ball1(wx
, wy
, atx
, aty
, FUID
);
4129 g_Weapon_rocket(wx
, wy
, atx
, aty
, FUID
);
4131 g_Weapon_revf(wx
, wy
, atx
, aty
, FUID
, FTargetUID
);
4133 g_Weapon_aplasma(wx
, wy
, atx
, aty
, FUID
);
4135 g_Weapon_plasma(wx
, wy
, atx
, aty
, FUID
);
4137 g_Weapon_manfire(wx
, wy
, atx
, aty
, FUID
);
4138 MONSTER_BARON
, MONSTER_KNIGHT
:
4139 g_Weapon_ball7(wx
, wy
, atx
, aty
, FUID
);
4141 g_Weapon_ball2(wx
, wy
, atx
, aty
, FUID
);
4145 procedure TMonster
.Turn();
4148 if FDirection
= TDirection
.D_LEFT
then FDirection
:= TDirection
.D_RIGHT
else FDirection
:= TDirection
.D_LEFT
;
4150 // Áåæèì â âûáðàííóþ ñòîðîíó:
4151 if FDirection
= TDirection
.D_RIGHT
then
4152 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
4154 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
4157 function TMonster
.findNewPrey(): Boolean;
4161 PlayersSee
, MonstersSee
: Array of DWORD
;
4162 PlayerNear
, MonsterNear
: Integer;
4165 SetLength(MonstersSee
, 0);
4166 SetLength(PlayersSee
, 0);
4173 // Ïîåõàâøèå, êàííèáàëû, è äîáðûå èãðîêîâ íå òðîãàþò
4174 if (gPlayers
<> nil) and (FBehaviour
<> BH_INSANE
) and
4175 (FBehaviour
<> BH_CANNIBAL
) and (FBehaviour
<> BH_GOOD
) then
4176 for a
:= 0 to High(gPlayers
) do
4177 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
)
4178 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FPowerups
[MR_INVIS
] < gTime
) then
4180 if g_Look(@FObj
, @gPlayers
[a
].Obj
, FDirection
) then
4182 SetLength(PlayersSee
, Length(PlayersSee
) + 1);
4183 PlayersSee
[High(PlayersSee
)] := a
;
4185 l2
:= Abs(gPlayers
[a
].GameX
-FObj
.X
)+
4186 Abs(gPlayers
[a
].GameY
-FObj
.Y
);
4190 PlayerNear
:= Integer(a
);
4194 // Êèëëåðû è äîáðûå íå òðîãàþò ìîíñòðîâ
4195 if (gMonsters
<> nil) and (FBehaviour
<> BH_KILLER
) and (FBehaviour
<> BH_GOOD
) then
4196 for a
:= 0 to High(gMonsters
) do
4197 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].alive
) and
4198 (gMonsters
[a
].FUID
<> FUID
) then
4200 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
4201 Continue
; // Êàííèáàëû àòàêóþò òîëüêî ñîðîäè÷åé
4202 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
)
4203 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4204 Continue
; // Ïîåõàâøèå íå òðîãàþò äðóçåé, íî èì íå íðàâÿòñÿ áî÷êè
4205 if ((FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_MANIAC
))
4206 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4207 Continue
; // Îñòàâøèåñÿ òèïû, êðîìå êàííèáàëîâ, íå òðîãàþò ñâîèõ äðóçåé
4209 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
4211 SetLength(MonstersSee
, Length(MonstersSee
) + 1);
4212 MonstersSee
[High(MonstersSee
)] := a
;
4214 l2
:= Abs(gMonsters
[a
].FObj
.X
-FObj
.X
)+
4215 Abs(gMonsters
[a
].FObj
.Y
-FObj
.Y
);
4219 MonsterNear
:= Integer(a
);
4224 BH_NORMAL
, BH_KILLER
:
4226 // Îáû÷íûé è êèëëåð ñíà÷àëà èùóò èãðîêîâ â ïîëå çðåíèÿ
4227 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4229 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4230 FTargetUID
:= gPlayers
[a
].UID
;
4233 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4236 FTargetUID
:= gPlayers
[a
].UID
;
4238 // Ïîòîì îáû÷íûå èùóò ìîíñòðîâ â ïîëå çðåíèÿ
4239 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4241 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4242 FTargetUID
:= gMonsters
[a
].UID
;
4245 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4248 FTargetUID
:= gMonsters
[a
].UID
;
4251 BH_MANIAC
, BH_INSANE
, BH_CANNIBAL
:
4253 // Ìàíüÿêè, ïîåõàâøèå è êàííèáàëû ñíà÷àëà èñòðåáëÿþò âñ¸ â ïîëå çðåíèÿ
4254 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4256 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4257 FTargetUID
:= gPlayers
[a
].UID
;
4259 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4261 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4262 FTargetUID
:= gMonsters
[a
].UID
;
4264 // Çàòåì èùóò êîãî-òî ïîáëèçîñòè
4265 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4268 FTargetUID
:= gPlayers
[a
].UID
;
4270 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4273 FTargetUID
:= gMonsters
[a
].UID
;
4278 // Åñëè è ìîíñòðîâ íåò - íà÷èíàåì æäàòü öåëü:
4279 if FTargetUID
= 0 then
4281 // Ïîåõàâøèé ïûòàåòñÿ ñàìîóáèòüñÿ
4282 if FBehaviour
= BH_INSANE
then
4285 FTargetTime
:= MAX_ATM
;
4294 function TMonster
.kick(o
: PObj
): Boolean;
4298 case FMonsterType
of
4301 SetState(MONSTATE_ATTACK
);
4306 SetState(MONSTATE_ATTACK
);
4307 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj
.X
, FObj
.Y
);
4312 SetState(MONSTATE_ATTACK
);
4313 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj
.X
, FObj
.Y
);
4316 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4318 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
4319 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj
.X
, FObj
.Y
);
4322 MONSTER_BARON
, MONSTER_KNIGHT
,
4323 MONSTER_CACO
, MONSTER_MANCUB
:
4324 // Ýòè ìîíñòðû íå ïèíàþò - îíè ñòðåëÿþò â óïîð:
4325 if not g_Game_IsClient
then Result
:= shoot(o
, True);
4329 function TMonster
.shoot(o
: PObj
; immediately
: Boolean): Boolean;
4339 // Æäàòü âðåìåíè ãîòîâíîñòè ê âûñòðåëó:
4340 if not immediately
then
4341 case FMonsterType
of
4342 MONSTER_FISH
, MONSTER_BARREL
, MONSTER_DEMON
:
4343 Exit
; // íå ñòðåëÿþò
4344 MONSTER_CGUN
, MONSTER_BSP
, MONSTER_ROBO
:
4347 // Âðåìÿ âûñòðåëà óïóùåíî:
4349 FAmmo
:= IfThen(FMonsterType
= MONSTER_ROBO
, -200, -50);
4355 // Âðåìÿ âûñòðåëà óïóùåíî:
4362 // Âðåìÿ âûñòðåëà óïóùåíî:
4363 if FAmmo
>= 100 then
4368 // Ñòðåëÿåò íå âñåãäà:
4369 if Random(2) = 0 then
4372 // Âðåìÿ âûñòðåëà óïóùåíî:
4376 MONSTER_BARON
, MONSTER_KNIGHT
: if Random(8) <> 0 then Exit
;
4377 MONSTER_SKEL
: if Random(32) <> 0 then Exit
;
4378 MONSTER_VILE
: if Random(8) <> 0 then Exit
;
4379 MONSTER_PAIN
: if Random(8) <> 0 then Exit
;
4380 else if Random(16) <> 0 then Exit
;
4384 if not g_Look(@FObj
, o
, FDirection
) then
4389 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2)+((o
^.Vel
.X
{+o^.Accel.X})*12);
4390 ty
:= o
^.Y
+o
^.Rect
.Y
+(o
^.Rect
.Height
div 2)+((o
^.Vel
.Y
{+o^.Accel.Y})*12);
4392 // Ðàçíèöà ïî âûñîòå áîëüøå ðàçíèöû ïî ãîðèçîíòàëè
4393 // (íå ìîæåò ñòðåëÿòü ïîä òàêèì áîëüøèì óãëîì):
4394 if Abs(tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2))) <
4395 Abs(ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2))) then
4398 case FMonsterType
of
4399 MONSTER_IMP
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
:
4401 SetState(MONSTATE_SHOOT
);
4406 SetState(MONSTATE_SHOOT
);
4410 begin // Çàæèãàåì îãîíü
4411 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2);
4412 ty
:= o
^.Y
+o
^.Rect
.Y
;
4413 SetState(MONSTATE_SHOOT
);
4417 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ATTACK', FObj
.X
, FObj
.Y
);
4418 g_Sound_PlayExAt('SOUND_FIRE', o
^.X
, o
^.Y
);
4421 begin // Ëåòèò â ñòîðîíó öåëè:
4422 SetState(MONSTATE_ATTACK
);
4423 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj
.X
, FObj
.Y
);
4425 xd
:= tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
4426 yd
:= ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
4427 m
:= Max(Abs(xd
), Abs(yd
));
4431 FObj
.Vel
.X
:= (xd
*16) div m
;
4432 FObj
.Vel
.Y
:= (yd
*16) div m
;
4434 MONSTER_MANCUB
, MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_BSP
, MONSTER_ROBO
,
4435 MONSTER_CYBER
, MONSTER_CGUN
, MONSTER_SPIDER
, MONSTER_PAIN
, MONSTER_MAN
:
4437 // Ìàíêóáóñ ðÿâêàåò ïåðåä ïåðâîé àòàêîé:
4438 if FMonsterType
= MONSTER_MANCUB
then
4440 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj
.X
, FObj
.Y
);
4442 SetState(MONSTATE_SHOOT
);
4450 function TMonster
.alive(): Boolean;
4452 Result
:= (FHealth
> 0) and not (FState
in [MONSTATE_DIE
, MONSTATE_DEAD
]);
4455 procedure TMonster
.SetHealth(aH
: Integer);
4457 if (aH
> 0) and (aH
< 1000000) then
4460 if FHealth
> FMaxHealth
then
4461 FMaxHealth
:= FHealth
;
4465 procedure TMonster
.WakeUp();
4467 if g_Game_IsClient
then Exit
;
4468 SetState(MONSTATE_GO
);
4469 FTargetTime
:= MAX_ATM
;
4473 procedure TMonster
.SaveState (st
: TStream
);
4481 // Ñèãíàòóðà ìîíñòðà:
4482 utils
.writeSign(st
, 'MONS');
4483 utils
.writeInt(st
, Byte(0)); // version
4485 utils
.writeInt(st
, Word(FUID
));
4487 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
4488 utils
.writeInt(st
, Byte(b
));
4489 // Íàäî ëè óäàëèòü åãî
4490 utils
.writeBool(st
, FRemoved
);
4491 // Îñòàëîñü çäîðîâüÿ
4492 utils
.writeInt(st
, LongInt(FHealth
));
4494 utils
.writeInt(st
, Byte(FState
));
4496 utils
.writeInt(st
, Byte(FCurAnim
));
4498 utils
.writeInt(st
, Word(FTargetUID
));
4499 // Âðåìÿ ïîñëå ïîòåðè öåëè
4500 utils
.writeInt(st
, LongInt(FTargetTime
));
4501 // Ïîâåäåíèå ìîíñòðà
4502 utils
.writeInt(st
, Byte(FBehaviour
));
4503 // Ãîòîâíîñòü ê âûñòðåëó
4504 utils
.writeInt(st
, LongInt(FAmmo
));
4506 utils
.writeInt(st
, LongInt(FPain
));
4508 utils
.writeInt(st
, LongInt(FSleep
));
4509 // Îçâó÷èâàòü ëè áîëü
4510 utils
.writeBool(st
, FPainSound
);
4511 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4512 utils
.writeBool(st
, FWaitAttackAnim
);
4513 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4514 utils
.writeBool(st
, FChainFire
);
4515 // Ïîäëåæèò ëè ðåñïàâíó
4516 utils
.writeBool(st
, FNoRespawn
);
4518 utils
.writeInt(st
, LongInt(tx
));
4519 utils
.writeInt(st
, LongInt(ty
));
4520 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4521 utils
.writeInt(st
, LongInt(FStartID
));
4522 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4523 utils
.writeInt(st
, LongInt(FSpawnTrigger
));
4525 Obj_SaveState(st
, @FObj
);
4526 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4527 anim
:= (vilefire
<> nil);
4528 utils
.writeBool(st
, anim
);
4529 // Åñëè åñòü - ñîõðàíÿåì:
4530 if anim
then vilefire
.SaveState(st
);
4532 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4534 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4535 anim
:= (FAnim
[i
, TDirection
.D_LEFT
] <> nil);
4536 utils
.writeBool(st
, anim
);
4537 // Åñëè åñòü - ñîõðàíÿåì
4538 if anim
then FAnim
[i
, TDirection
.D_LEFT
].SaveState(st
);
4539 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4540 anim
:= (FAnim
[i
, TDirection
.D_RIGHT
] <> nil);
4541 utils
.writeBool(st
, anim
);
4542 // Åñëè åñòü - ñîõðàíÿåì
4543 if anim
then FAnim
[i
, TDirection
.D_RIGHT
].SaveState(st
);
4548 procedure TMonster
.LoadState (st
: TStream
);
4556 // Ñèãíàòóðà ìîíñòðà:
4557 if not utils
.checkSign(st
, 'MONS') then raise XStreamError
.Create('invalid monster signature');
4558 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid monster version');
4559 if (uidMap
[FUID
] <> nil) and (uidMap
[FUID
] <> self
) then raise Exception
.Create('internal error in monster loader (0)');
4560 uidMap
[FUID
] := nil;
4562 FUID
:= utils
.readWord(st
);
4563 //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
4564 if (uidMap
[FUID
] <> nil) then raise Exception
.Create('internal error in monster loader (1)');
4565 uidMap
[FUID
] := self
;
4567 b
:= utils
.readByte(st
);
4568 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
4569 // Íàäî ëè óäàëèòü åãî
4570 FRemoved
:= utils
.readBool(st
);
4571 // Îñòàëîñü çäîðîâüÿ
4572 FHealth
:= utils
.readLongInt(st
);
4574 FState
:= utils
.readByte(st
);
4576 FCurAnim
:= utils
.readByte(st
);
4578 FTargetUID
:= utils
.readWord(st
);
4579 // Âðåìÿ ïîñëå ïîòåðè öåëè
4580 FTargetTime
:= utils
.readLongInt(st
);
4581 // Ïîâåäåíèå ìîíñòðà
4582 FBehaviour
:= utils
.readByte(st
);
4583 // Ãîòîâíîñòü ê âûñòðåëó
4584 FAmmo
:= utils
.readLongInt(st
);
4586 FPain
:= utils
.readLongInt(st
);
4588 FSleep
:= utils
.readLongInt(st
);
4589 // Îçâó÷èâàòü ëè áîëü
4590 FPainSound
:= utils
.readBool(st
);
4591 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè
4592 FWaitAttackAnim
:= utils
.readBool(st
);
4593 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå
4594 FChainFire
:= utils
.readBool(st
);
4595 // Ïîäëåæèò ëè ðåñïàâíó
4596 FNoRespawn
:= utils
.readBool(st
);
4598 tx
:= utils
.readLongInt(st
);
4599 ty
:= utils
.readLongInt(st
);
4600 // ID ìîíñòðà ïðè ñòàðòå êàðòû
4601 FStartID
:= utils
.readLongInt(st
);
4602 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà
4603 FSpawnTrigger
:= utils
.readLongInt(st
);
4605 Obj_LoadState(@FObj
, st
);
4606 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà
4607 anim
:= utils
.readBool(st
);
4608 // Åñëè åñòü - çàãðóæàåì:
4611 Assert(vilefire
<> nil, 'TMonster.LoadState: no vilefire anim');
4612 vilefire
.LoadState(st
);
4615 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4617 // Åñòü ëè ëåâàÿ àíèìàöèÿ
4618 anim
:= utils
.readBool(st
);
4619 // Åñëè åñòü - çàãðóæàåì
4622 Assert(FAnim
[i
, TDirection
.D_LEFT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_left anim');
4623 FAnim
[i
, TDirection
.D_LEFT
].LoadState(st
);
4625 // Åñòü ëè ïðàâàÿ àíèìàöèÿ
4626 anim
:= utils
.readBool(st
);
4627 // Åñëè åñòü - çàãðóæàåì
4630 Assert(FAnim
[i
, TDirection
.D_RIGHT
] <> nil, 'TMonster.LoadState: no '+IntToStr(i
)+'_right anim');
4631 FAnim
[i
, TDirection
.D_RIGHT
].LoadState(st
);
4635 self
.positionChanged
4639 procedure TMonster
.ActivateTriggers();
4643 if FDieTriggers
<> nil then
4644 for a
:= 0 to High(FDieTriggers
) do
4645 g_Triggers_Press(FDieTriggers
[a
], ACTIVATE_MONSTERPRESS
);
4646 if FSpawnTrigger
> -1 then
4648 g_Triggers_DecreaseSpawner(FSpawnTrigger
);
4649 FSpawnTrigger
:= -1;
4653 procedure TMonster
.AddTrigger(t
: Integer);
4655 SetLength(FDieTriggers
, Length(FDieTriggers
)+1);
4656 FDieTriggers
[High(FDieTriggers
)] := t
;
4659 procedure TMonster
.ClearTriggers();
4661 SetLength(FDieTriggers
, 0);
4664 procedure TMonster
.CatchFire(Attacker
: Word; Timeout
: Integer = MON_BURN_TIME
);
4666 if FMonsterType
in [MONSTER_SOUL
, MONSTER_VILE
] then
4667 exit
; // àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
4668 if Timeout
<= 0 then exit
;
4669 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
4670 exit
; // íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
4671 if FFireTime
<= 0 then
4672 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
4673 FFireTime
:= Timeout
;
4674 FFireAttacker
:= Attacker
;
4675 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_MonsterState(FUID
);
4678 procedure TMonster
.OnFireFlame(Times
: DWORD
= 1);
4683 if (Random(10) = 1) and (Times
= 1) then
4686 if g_Frames_Get(id
, 'FRAMES_FLAME') then
4688 for i
:= 1 to Times
do
4690 Anim
:= TAnimation
.Create(id
, False, 3);
4692 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
4693 Obj
.Y
+8+Random(8+Times
*2)+IfThen(FState
= MONSTATE_DEAD
, 16, 0), Anim
, ONCEANIM_SMOKE
);
4700 // ////////////////////////////////////////////////////////////////////////// //
4701 // throws on invalid uid
4702 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
4704 result
:= g_Mons_ByIdx_NC(uid
);
4705 if (result
= nil) then raise Exception
.Create('g_Mons_ByIdx: invalid monster id');
4709 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
4711 if (uid
< 0) or (uid
> High(gMonsters
)) then begin result
:= nil; exit
; end;
4712 result
:= gMonsters
[uid
];
4715 function g_Mons_TotalCount (): Integer; inline;
4717 result
:= Length(gMonsters
);
4721 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
4727 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4728 for idx
:= 0 to High(gMonsters
) do
4730 mon
:= gMonsters
[idx
];
4731 if (mon
<> nil) then
4734 if result
then exit
;
4740 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
4746 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4747 for idx
:= 0 to High(gMonsters
) do
4749 mon
:= gMonsters
[idx
];
4750 if (mon
<> nil) and mon
.alive
then
4753 if result
then exit
;
4759 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
4761 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4763 result := mon.alive;// and g_Obj_Collide(x, y, width, height, @mon.Obj));
4770 it
: TMonsterGrid
.Iter
;
4773 if (width
< 1) or (height
< 1) then exit
;
4774 if gmon_debug_use_sqaccel
then
4776 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4777 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4778 for mit
in it
do if (mit
.alive
) then begin result
:= true; break
; end;
4783 for idx
:= 0 to High(gMonsters
) do
4785 mon
:= gMonsters
[idx
];
4786 if (mon
<> nil) and mon
.alive
then
4788 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4799 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4801 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4810 it
: TMonsterGrid
.Iter
;
4813 if (width
< 1) or (height
< 1) then exit
;
4814 if gmon_debug_use_sqaccel
then
4816 //result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4817 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4818 for mit
in it
do if (cb(mit
^)) then begin result
:= true; break
; end;
4823 for idx
:= 0 to High(gMonsters
) do
4825 mon
:= gMonsters
[idx
];
4826 if (mon
<> nil) and mon
.alive
then
4828 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4831 if result
then exit
;
4839 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4841 function monsCollCheck (mon: TMonster; atag: Integer): Boolean;
4844 //if mon.alive and g_Obj_Collide(x, y, width, height, @mon.Obj) then result := cb(mon);
4845 if mon.alive then result := cb(mon) else result := false;
4852 it
: TMonsterGrid
.Iter
;
4855 if (width
< 1) or (height
< 1) then exit
;
4856 if gmon_debug_use_sqaccel
then
4859 if (width = 1) and (height = 1) then
4861 result := (monsGrid.forEachAtPoint(x, y, monsCollCheck) <> nil);
4865 result := (monsGrid.forEachInAABB(x, y, width, height, monsCollCheck) <> nil);
4868 it
:= monsGrid
.forEachInAABB(x
, y
, width
, height
);
4871 if (mit
^.alive
) then
4873 if (cb(mit
^)) then begin result
:= true; break
; end;
4880 for idx
:= 0 to High(gMonsters
) do
4882 mon
:= gMonsters
[idx
];
4883 if (mon
<> nil) and mon
.alive
then
4885 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4888 if result
then exit
;