1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
17 {.$DEFINE D2F_DEBUG_MONS_MOVE}
23 g_basic
, e_graphics
, g_phys
, g_textures
, g_grid
,
24 g_saveload
, BinEditor
, g_panel
, xprofiler
;
48 TMonster
= Class (TObject
)
52 FDirection
: TDirection
;
53 FStartDirection
: TDirection
;
54 FStartX
, FStartY
: Integer;
60 FAnim
: Array of Array [D_LEFT
..D_RIGHT
] of TAnimation
;
69 FWaitAttackAnim
: Boolean;
80 FFirePainTime
: Integer;
83 mProxyId
: Integer; // node in dyntree or -1
84 mArrIdx
: Integer; // in gMonsters
86 FDieTriggers
: Array of Integer;
87 FSpawnTrigger
: Integer;
90 function findNewPrey(): Boolean;
91 procedure ActivateTriggers();
96 trapCheckFrameId
: DWord
; // for `g_weapons.CheckTrap()`
98 constructor Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
99 destructor Destroy(); override;
100 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
101 function Collide(Panel
: TPanel
): Boolean; overload
;
102 function Collide(X
, Y
: Integer): Boolean; overload
;
103 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
104 function Live(): Boolean;
105 procedure SetHealth(aH
: Integer);
106 procedure Push(vx
, vy
: Integer);
107 function Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
108 function Heal(Value
: Word): Boolean;
111 procedure ClientUpdate();
112 procedure ClientAttack(wx
, wy
, atx
, aty
: Integer);
113 procedure SetDeadAnim
;
116 procedure WakeUpSound();
117 procedure DieSound();
118 procedure PainSound();
119 procedure ActionSound();
120 procedure AddTrigger(t
: Integer);
121 procedure ClearTriggers();
123 procedure SaveState(var Mem
: TBinMemoryWriter
);
124 procedure LoadState(var Mem
: TBinMemoryReader
);
125 procedure SetState(State
: Byte; ForceAnim
: Byte = 255);
126 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
127 procedure MakeBloodSimple(Count
: Word);
128 procedure RevertAnim(R
: Boolean = True);
129 function AnimIsReverse
: Boolean;
130 function shoot(o
: PObj
; immediately
: Boolean): Boolean;
131 function kick(o
: PObj
): Boolean;
132 procedure CatchFire(Attacker
: Word);
133 procedure OnFireFlame(Times
: DWORD
= 1);
135 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
137 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
139 property MonsterType
: Byte read FMonsterType
;
140 property MonsterHealth
: Integer read FHealth write FHealth
;
141 property MonsterAmmo
: Integer read FAmmo write FAmmo
;
142 property MonsterTargetUID
: Word read FTargetUID write FTargetUID
;
143 property MonsterTargetTime
: Integer read FTargetTime write FTargetTime
;
144 property MonsterBehaviour
: Byte read FBehaviour write FBehaviour
;
145 property MonsterSleep
: Integer read FSleep write FSleep
;
146 property MonsterState
: Byte read FState write FState
;
147 property MonsterRemoved
: Boolean read FRemoved write FRemoved
;
148 property MonsterPain
: Integer read FPain write FPain
;
149 property MonsterAnim
: Byte read FCurAnim write FCurAnim
;
151 property Obj
: TObj read FObj
;
152 property UID
: Word read FUID write FUID
;
153 property SpawnTrigger
: Integer read FSpawnTrigger write FSpawnTrigger
;
155 property GameX
: Integer read FObj
.X write FObj
.X
;
156 property GameY
: Integer read FObj
.Y write FObj
.Y
;
157 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
158 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
159 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
160 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
161 property GameDirection
: TDirection read FDirection write FDirection
;
163 property StartID
: Integer read FStartID
;
165 property proxyId
: Integer read mProxyId
;
166 property arrIdx
: Integer read mArrIdx
;
170 // will be called from map loader
171 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
173 procedure g_Monsters_LoadData ();
174 procedure g_Monsters_FreeData ();
175 procedure g_Monsters_Init ();
176 procedure g_Monsters_Free (clearGrid
: Boolean=true);
177 function g_Monsters_Create (MonsterType
: Byte; X
, Y
: Integer; Direction
: TDirection
;
178 AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
179 procedure g_Monsters_Update ();
180 procedure g_Monsters_Draw ();
181 procedure g_Monsters_DrawHealth ();
182 function g_Monsters_ByUID (UID
: Word): TMonster
;
183 procedure g_Monsters_killedp ();
184 procedure g_Monsters_SaveState (var Mem
: TBinMemoryWriter
);
185 procedure g_Monsters_LoadState (var Mem
: TBinMemoryReader
);
186 function g_Monsters_GetIDByName (name
: String): Integer;
187 function g_Monsters_GetNameByID (MonsterType
: Byte): String;
188 function g_Monsters_GetKilledBy (MonsterType
: Byte): String;
192 TEachMonsterCB
= function (mon
: TMonster
): Boolean is nested
; // return `true` to stop
194 // throws on invalid uid
195 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
198 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
200 function g_Mons_TotalCount (): Integer; inline;
202 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
204 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
205 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
207 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
208 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
210 function g_Mons_getNewTrapFrameId (): DWord
;
214 TMonsAlongLineCB
= function (mon
: TMonster
; tag
: Integer): Boolean is nested
;
216 function g_Mons_AlongLine (x0
, y0
, x1
, y1
: Integer; cb
: TMonsAlongLineCB
; log
: Boolean=false): TMonster
;
220 gmon_debug_use_sqaccel
: Boolean = true;
224 procedure g_Mons_ProfilersBegin ();
225 procedure g_Mons_ProfilersEnd ();
227 procedure g_Mons_LOS_Start (); inline;
228 procedure g_Mons_LOS_End (); inline;
231 profMonsLOS
: TProfiler
= nil; //WARNING: FOR DEBUGGING ONLY!
235 TMonsterGrid
= specialize TBodyGridBase
<TMonster
>;
238 monsGrid
: TMonsterGrid
= nil; // DO NOT USE! public for debugging only!
242 gmon_debug_think
: Boolean = true;
243 gmon_debug_one_think_step
: Boolean = false;
249 e_log
, g_main
, g_sound
, g_gfx
, g_player
, g_game
,
250 g_weapons
, g_triggers
, MAPDEF
, g_items
, g_options
,
251 g_console
, g_map
, Math
, SysUtils
, g_menu
, wadreader
,
252 g_language
, g_netmsg
, idpool
;
255 // ////////////////////////////////////////////////////////////////////////// //
256 procedure g_Mons_ProfilersBegin ();
258 if (profMonsLOS
= nil) then profMonsLOS
:= TProfiler
.Create('LOS CALC', g_profile_history_size
);
259 profMonsLOS
.mainBegin(g_profile_los
);
260 if g_profile_los
then
262 profMonsLOS
.sectionBegin('loscalc');
263 profMonsLOS
.sectionEnd();
267 procedure g_Mons_ProfilersEnd ();
269 if (profMonsLOS
<> nil) and (g_profile_los
) then profMapCollision
.mainEnd();
272 procedure g_Mons_LOS_Start (); inline;
274 profMonsLOS
.sectionBeginAccum('loscalc');
277 procedure g_Mons_LOS_End (); inline;
279 profMonsLOS
.sectionEnd();
283 // ////////////////////////////////////////////////////////////////////////// //
285 monCheckTrapLastFrameId
: DWord
;
288 procedure TMonster
.getMapBox (out x
, y
, w
, h
: Integer); inline;
290 x
:= FObj
.X
+FObj
.Rect
.X
;
291 y
:= FObj
.Y
+FObj
.Rect
.Y
;
292 w
:= FObj
.Rect
.Width
;
293 h
:= FObj
.Rect
.Height
;
297 // ////////////////////////////////////////////////////////////////////////// //
298 function g_Mons_AlongLine (x0
, y0
, x1
, y1
: Integer; cb
: TMonsAlongLineCB
; log
: Boolean=false): TMonster
;
300 if not assigned(cb
) then begin result
:= nil; exit
; end;
301 result
:= monsGrid
.forEachAlongLine(x0
, y0
, x1
, y1
, cb
, -1, log
);
305 //WARNING! call this after monster position was changed, or coldet will not work right!
306 procedure TMonster
.positionChanged ();
309 nx
, ny
, nw
, nh
: Integer;
311 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
312 //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);
314 if (mProxyId
= -1) then
316 mProxyId
:= monsGrid
.insertBody(self
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
);
317 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
318 monsGrid
.getBodyXY(mProxyId
, x
, y
);
319 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
);
324 monsGrid
.getBodyDims(mProxyId
, x
, y
, w
, h
);
325 getMapBox(nx
, ny
, nw
, nh
);
327 if (w
<> nw
) or (h
<> nh
) then
329 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
330 e_WriteLog(Format('monster #%d:(%u): resized; mProxyid=%d; gx=%d; gy=%d', [mArrIdx
, UID
, mProxyId
, x
-monsGrid
.gridX0
, y
-monsGrid
.gridY0
]), MSG_NOTIFY
);
332 monsGrid
.moveResizeBody(mProxyId
, nx
, ny
, nw
, nh
);
334 else if (x
<> nx
) or (y
<> ny
) then
336 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
337 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
);
339 monsGrid
.moveBody(mProxyId
, nx
, ny
);
343 exit
; // nothing to do
345 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
346 monsGrid
.getBodyXY(mProxyId
, x
, y
);
347 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
);
353 // ////////////////////////////////////////////////////////////////////////// //
363 MONSTER_SIGNATURE
= $534E4F4D; // 'MONS'
365 // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ:
366 ANIMTABLE
: Array [ANIM_SLEEP
..ANIM_PAIN
] of
370 end = ((name
: 'SLEEP'; loop
: True),
371 (name
: 'GO'; loop
: True),
372 (name
: 'DIE'; loop
: False),
373 (name
: 'MESS'; loop
: False),
374 (name
: 'ATTACK'; loop
: False),
375 (name
: 'ATTACK2'; loop
: False),
376 (name
: 'PAIN'; loop
: False));
378 // Òàáëèöà õàðàêòåðèñòèê ìîíñòðîâ:
379 MONSTERTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
389 ((Name
:'DEMON'; Rect
:(X
:7; Y
:8; Width
:50; Height
:52); Health
:60;
390 RunVel
: 7; MinPain
: 10; Pain
: 20; Jump
: 10),
392 (Name
:'IMP'; Rect
:(X
:15; Y
:10; Width
:34; Height
:50); Health
:25;
393 RunVel
: 3; MinPain
: 0; Pain
: 15; Jump
: 10),
395 (Name
:'ZOMBY'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:15;
396 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
398 (Name
:'SERG'; Rect
:(X
:15; Y
:8; Width
:34; Height
:52); Health
:20;
399 RunVel
: 3; MinPain
: 0; Pain
: 10; Jump
: 10),
401 (Name
:'CYBER'; Rect
:(X
:24; Y
:9; Width
:80; Height
:110); Health
:500;
402 RunVel
: 5; MinPain
: 50; Pain
: 70; Jump
: 10),
404 (Name
:'CGUN'; Rect
:(X
:15; Y
:4; Width
:34; Height
:56); Health
:60;
405 RunVel
: 3; MinPain
: 10; Pain
: 20; Jump
: 10),
407 (Name
:'BARON'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:150;
408 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
410 (Name
:'KNIGHT'; Rect
:(X
:39; Y
:32; Width
:50; Height
:64); Health
:75;
411 RunVel
: 3; MinPain
: 30; Pain
: 40; Jump
: 10),
413 (Name
:'CACO'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
414 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
416 (Name
:'SOUL'; Rect
:(X
:16; Y
:14; Width
:32; Height
:36); Health
:60;
417 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
419 (Name
:'PAIN'; Rect
:(X
:34; Y
:36; Width
:60; Height
:56); Health
:100;
420 RunVel
: 4; MinPain
: 0; Pain
: 10; Jump
: 4),
422 (Name
:'SPIDER'; Rect
:(X
:23; Y
:14; Width
:210; Height
:100); Health
:500;
423 RunVel
: 4; MinPain
: 50; Pain
: 70; Jump
: 10),
425 (Name
:'BSP'; Rect
:(X
:14; Y
:17; Width
:100; Height
:42); Health
:150;
426 RunVel
: 4; MinPain
: 0; Pain
: 20; Jump
: 10),
428 (Name
:'MANCUB'; Rect
:(X
:28; Y
:34; Width
:72; Height
:60); Health
:200;
429 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 7),
431 (Name
:'SKEL'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:200;
432 RunVel
: 6; MinPain
: 20; Pain
: 40; Jump
: 11),
434 (Name
:'VILE'; Rect
:(X
:30; Y
:28; Width
:68; Height
:72); Health
:150;
435 RunVel
: 7; MinPain
: 10; Pain
: 30; Jump
: 12),
437 (Name
:'FISH'; Rect
:(X
:6; Y
:11; Width
:20; Height
:10); Health
:35;
438 RunVel
: 14; MinPain
: 10; Pain
: 20; Jump
: 6),
440 (Name
:'BARREL'; Rect
:(X
:20; Y
:13; Width
:24; Height
:36); Health
:20;
441 RunVel
: 0; MinPain
: 0; Pain
: 0; Jump
: 0),
443 (Name
:'ROBO'; Rect
:(X
:30; Y
:26; Width
:68; Height
:76); Health
:20;
444 RunVel
: 3; MinPain
: 20; Pain
: 40; Jump
: 6),
446 (Name
:'MAN'; Rect
:(X
:15; Y
:6; Width
:34; Height
:52); Health
:400;
447 RunVel
: 8; MinPain
: 50; Pain
: 70; Jump
: 10));
449 // Òàáëèöà ïàðàìåòðîâ àíèìàöèè ìîíñòðîâ:
450 MONSTER_ANIMTABLE
: Array [MONSTER_DEMON
..MONSTER_MAN
] of
453 wX
, wY
: Integer; // Îòêóäà âûëåòèò ïóëÿ
454 AnimSpeed
: Array [ANIM_SLEEP
..ANIM_PAIN
] of Byte;
455 AnimDeltaRight
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
456 AnimDeltaLeft
: Array [ANIM_SLEEP
..ANIM_PAIN
] of TDFPoint
;
457 end = // SLEEP GO DIE MESS ATTACK ATTACK2 PAIN
458 ((LeftAnim
: False; wX
: 54; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //DEMON
459 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));
460 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))),
462 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //IMP
463 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));
464 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))),
466 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //ZOMBY
467 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));
468 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))),
470 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 2, 3, 0, 4); //SERG
471 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));
472 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))),
474 (LeftAnim
: True; wX
: 70; wY
: 73; AnimSpeed
:(3, 3, 3, 3, 3, 4, 3); //CYBER
475 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));
476 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))),
478 (LeftAnim
: True; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 1, 0, 4); //CGUN
479 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));
480 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))),
482 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //BARON
483 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));
484 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))),
486 (LeftAnim
: True; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //KNIGHT
487 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));
488 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))),
490 (LeftAnim
: False; wX
: 88; wY
: 69; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //CACO
491 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));
492 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))),
494 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //SOUL
495 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));
496 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))),
498 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 3, 4, 2, 0, 4); //PAIN
499 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));
500 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))),
502 (LeftAnim
: True; wX
: 128; wY
: 64; AnimSpeed
:(3, 2, 4, 4, 1, 0, 4); //SPIDER
503 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));
504 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))),
506 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 2, 3, 4, 1, 0, 4); //BSP
507 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));
508 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))),
510 (LeftAnim
: False; wX
: 64; wY
: 64; AnimSpeed
:(3, 2, 2, 4, 2, 0, 4); //MANCUB
511 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));
512 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))),
514 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //SKEL
515 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));
516 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))),
518 (LeftAnim
: True; wX
: 64; wY
: 32; AnimSpeed
:(3, 3, 3, 3, 3, 3, 3); //VILE
519 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));
520 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))),
522 (LeftAnim
: False; wX
: 8; wY
: 8; AnimSpeed
:(2, 2, 2, 2, 3, 0, 1); //FISH
523 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));
524 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 ))),
526 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 0, 3, 0, 0, 0, 5); //BARREL
527 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));
528 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))),
530 (LeftAnim
: False; wX
: 95; wY
: 57; AnimSpeed
:(1, 2, 1, 0, 1, 1, 0); //ROBO
531 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));
532 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))),
534 (LeftAnim
: False; wX
: 32; wY
: 32; AnimSpeed
:(3, 2, 2, 2, 2, 0, 5); //MAN
535 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));
536 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))) );
538 MAX_ATM
= 89; // Âðåìÿ îæèäàíèÿ ïîñëå ïîòåðè öåëè
539 MAX_SOUL
= 512; // Îãðàíè÷åíèå Lost_Soul'îâ
543 gMonsters
: array of TMonster
;
544 uidMap
: array [0..65535] of TMonster
; // monster knows it's index
545 freeInds
: TIdPool
= nil;
548 procedure clearUidMap ();
552 for idx
:= 0 to High(uidMap
) do uidMap
[idx
] := nil;
557 function g_Mons_getNewTrapFrameId (): DWord
;
561 Inc(monCheckTrapLastFrameId
);
562 if monCheckTrapLastFrameId
= 0 then
565 monCheckTrapLastFrameId
:= 1;
566 for f
:= 0 to High(gMonsters
) do
568 if (gMonsters
[f
] <> nil) then gMonsters
[f
].trapCheckFrameId
:= 0;
571 result
:= monCheckTrapLastFrameId
;
580 soulcount
: Integer = 0;
583 function allocMonster (): DWORD
;
587 result
:= freeInds
.alloc();
588 if (result
> High(gMonsters
)) then
590 olen
:= Length(gMonsters
);
591 SetLength(gMonsters
, result
+64);
592 for f
:= olen
to High(gMonsters
) do gMonsters
[f
] := nil;
597 function IsFriend(a
, b
: Byte): Boolean;
601 // Áî÷êà - âñåì äðóã:
602 if (a
= MONSTER_BARREL
) or (b
= MONSTER_BARREL
) then
605 // Ìîíñòðû îäíîãî âèäà:
608 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
609 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
610 Exit
; // Ýòè íå áüþò ñâîèõ
613 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
614 if (a
= MONSTER_SOUL
) and (b
= MONSTER_PAIN
) then
616 // Pain_Elemental íå ìîæåò ðàíèòü Lost_Soul'à:
617 if (b
= MONSTER_SOUL
) and (a
= MONSTER_PAIN
) then
620 //  îñòàëüíûõ ñëó÷àÿõ - áóäóò áèòü äðóã äðóãà:
625 function BehaviourDamage(SpawnerUID
: Word; BH
, SelfType
: Byte): Boolean;
628 UIDType
, MonsterType
: Byte;
633 UIDType
:= g_GetUIDType(SpawnerUID
);
634 if UIDType
= UID_MONSTER
then
636 m
:= g_Monsters_ByUID(SpawnerUID
);
637 if m
= nil then Exit
;
638 MonsterType
:= m
.FMonsterType
;
642 BH_NORMAL
: Result
:= (UIDType
= UID_PLAYER
) or
643 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
645 BH_KILLER
: Result
:= UIDType
= UID_PLAYER
;
646 BH_MANIAC
: Result
:= (UIDType
= UID_PLAYER
) or
647 ((UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
)));
649 BH_INSANE
: Result
:= (UIDType
= UID_MONSTER
) and (not IsFriend(MonsterType
, SelfType
));
650 BH_CANNIBAL
: Result
:= (UIDType
= UID_MONSTER
) and (MonsterType
= SelfType
);
655 function canShoot(m
: Byte): Boolean;
660 MONSTER_DEMON
, MONSTER_FISH
, MONSTER_BARREL
:
668 function isCorpse (o
: PObj
; immediately
: Boolean): Integer;
670 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
672 atag
:= atag
; // shut up, fpc!
673 result
:= false; // don't stop
674 if (mon
.FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @mon
.FObj
) then
676 case mon
.FMonsterType
of // Íå âîñêðåñèòü:
677 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
678 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: exit
;
680 // Îñòàëüíûõ ìîæíî âîñêðåñèòü
691 // Åñëè íóæíà âåðîÿòíîñòü
692 if not immediately
and (Random(8) <> 0) then exit
;
694 // Èùåì ìåðòâûõ ìîíñòðîâ ïîáëèçîñòè
695 if gmon_debug_use_sqaccel
then
697 mon
:= monsGrid
.forEachInAABB(o
.X
+o
.Rect
.X
, o
.Y
+o
.Rect
.Y
, o
.Rect
.Width
, o
.Rect
.Height
, monsCollCheck
);
698 if (mon
<> nil) then result
:= mon
.mArrIdx
;
702 for a
:= 0 to High(gMonsters
) do
704 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].FState
= MONSTATE_DEAD
) and g_Obj_Collide(o
, @gMonsters
[a
].FObj
) then
706 case gMonsters
[a
].FMonsterType
of // Íå âîñêðåñèòü:
707 MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_CYBER
, MONSTER_SPIDER
,
708 MONSTER_VILE
, MONSTER_BARREL
, MONSTER_ROBO
: Continue
;
709 else // Îñòàëüíûõ ìîæíî âîñêðåñèòü
720 procedure g_Monsters_LoadData();
722 e_WriteLog('Loading monsters data...', MSG_NOTIFY
);
724 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 0%', 0, False);
725 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_SLEEP', GameWAD
+':MTEXTURES\BARREL_SLEEP', 64, 64, 3);
726 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_DIE', GameWAD
+':MTEXTURES\BARREL_DIE', 64, 64, 4);
727 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARREL_PAIN', GameWAD
+':MTEXTURES\BARREL_PAIN', 64, 64, 1);
728 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_SLEEP', GameWAD
+':MTEXTURES\ZOMBY_SLEEP', 64, 64, 2);
729 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_GO', GameWAD
+':MTEXTURES\ZOMBY_GO', 64, 64, 4);
730 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_DIE', GameWAD
+':MTEXTURES\ZOMBY_DIE', 64, 64, 6);
731 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 5%', 0, True);
732 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_MESS', GameWAD
+':MTEXTURES\ZOMBY_MESS', 64, 64, 9);
733 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_ATTACK', GameWAD
+':MTEXTURES\ZOMBY_ATTACK', 64, 64, 2);
734 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ZOMBY_PAIN', GameWAD
+':MTEXTURES\ZOMBY_PAIN', 64, 64, 1);
735 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_SLEEP', GameWAD
+':MTEXTURES\SERG_SLEEP', 64, 64, 2);
736 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_GO', GameWAD
+':MTEXTURES\SERG_GO', 64, 64, 4);
737 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_DIE', GameWAD
+':MTEXTURES\SERG_DIE', 64, 64, 5);
738 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 10%', 0, True);
739 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_MESS', GameWAD
+':MTEXTURES\SERG_MESS', 64, 64, 9);
740 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_ATTACK', GameWAD
+':MTEXTURES\SERG_ATTACK', 64, 64, 2);
741 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SERG_PAIN', GameWAD
+':MTEXTURES\SERG_PAIN', 64, 64, 1);
742 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_SLEEP', GameWAD
+':MTEXTURES\MAN_SLEEP', 64, 64, 2);
743 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_GO', GameWAD
+':MTEXTURES\MAN_GO', 64, 64, 4);
744 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_DIE', GameWAD
+':MTEXTURES\MAN_DIE', 64, 64, 7);
745 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 15%', 0, True);
746 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_MESS', GameWAD
+':MTEXTURES\MAN_MESS', 64, 64, 9);
747 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_ATTACK', GameWAD
+':MTEXTURES\MAN_ATTACK', 64, 64, 2);
748 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MAN_PAIN', GameWAD
+':MTEXTURES\MAN_PAIN', 64, 64, 1);
749 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP', GameWAD
+':MTEXTURES\CGUN_SLEEP', 64, 64, 2);
750 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_SLEEP_L', GameWAD
+':MTEXTURES\CGUN_SLEEP_L', 64, 64, 2);
751 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO', GameWAD
+':MTEXTURES\CGUN_GO', 64, 64, 4);
752 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 20%', 0, True);
753 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_GO_L', GameWAD
+':MTEXTURES\CGUN_GO_L', 64, 64, 4);
754 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_DIE', GameWAD
+':MTEXTURES\CGUN_DIE', 64, 64, 7);
755 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_MESS', GameWAD
+':MTEXTURES\CGUN_MESS', 64, 64, 6);
756 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK', GameWAD
+':MTEXTURES\CGUN_ATTACK', 64, 64, 2);
757 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_ATTACK_L', GameWAD
+':MTEXTURES\CGUN_ATTACK_L', 64, 64, 2);
758 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN', GameWAD
+':MTEXTURES\CGUN_PAIN', 64, 64, 1);
759 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 25%', 0, True);
760 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CGUN_PAIN_L', GameWAD
+':MTEXTURES\CGUN_PAIN_L', 64, 64, 1);
761 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_SLEEP', GameWAD
+':MTEXTURES\IMP_SLEEP', 64, 64, 2);
762 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_GO', GameWAD
+':MTEXTURES\IMP_GO', 64, 64, 4);
763 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_DIE', GameWAD
+':MTEXTURES\IMP_DIE', 64, 64, 5);
764 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_MESS', GameWAD
+':MTEXTURES\IMP_MESS', 64, 64, 8);
765 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_ATTACK', GameWAD
+':MTEXTURES\IMP_ATTACK', 64, 64, 3);
766 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 30%', 0, True);
767 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_IMP_PAIN', GameWAD
+':MTEXTURES\IMP_PAIN', 64, 64, 1);
768 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_SLEEP', GameWAD
+':MTEXTURES\DEMON_SLEEP', 64, 64, 2);
769 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_GO', GameWAD
+':MTEXTURES\DEMON_GO', 64, 64, 4);
770 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_DIE', GameWAD
+':MTEXTURES\DEMON_DIE', 64, 64, 6);
771 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_ATTACK', GameWAD
+':MTEXTURES\DEMON_ATTACK', 64, 64, 3);
772 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_DEMON_PAIN', GameWAD
+':MTEXTURES\DEMON_PAIN', 64, 64, 1);
773 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 35%', 0, True);
774 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_SLEEP', GameWAD
+':MTEXTURES\SOUL_SLEEP', 64, 64, 2);
775 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_GO', GameWAD
+':MTEXTURES\SOUL_GO', 64, 64, 2);
776 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_PAIN', GameWAD
+':MTEXTURES\SOUL_PAIN', 64, 64, 1);
777 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_ATTACK', GameWAD
+':MTEXTURES\SOUL_ATTACK', 64, 64, 2);
778 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SOUL_DIE', GameWAD
+':MTEXTURES\SOUL_DIE', 128, 128, 7);
779 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_SLEEP', GameWAD
+':MTEXTURES\FISH_SLEEP', 32, 32, 2);
780 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 40%', 0, True);
781 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_GO', GameWAD
+':MTEXTURES\FISH_GO', 32, 32, 4);
782 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_PAIN', GameWAD
+':MTEXTURES\FISH_PAIN', 32, 32, 3);
783 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_ATTACK', GameWAD
+':MTEXTURES\FISH_ATTACK', 32, 32, 2);
784 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_FISH_DIE', GameWAD
+':MTEXTURES\FISH_DIE', 32, 32, 1);
785 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_SLEEP', GameWAD
+':MTEXTURES\SPIDER_SLEEP', 256, 128, 2);
786 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_GO', GameWAD
+':MTEXTURES\SPIDER_GO', 256, 128, 6);
787 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 45%', 0, True);
788 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN', GameWAD
+':MTEXTURES\SPIDER_PAIN', 256, 128, 1);
789 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_PAIN_L', GameWAD
+':MTEXTURES\SPIDER_PAIN_L', 256, 128, 1);
790 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_ATTACK', GameWAD
+':MTEXTURES\SPIDER_ATTACK', 256, 128, 2);
791 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SPIDER_DIE', GameWAD
+':MTEXTURES\SPIDER_DIE', 256, 128, 10);
792 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_SLEEP', GameWAD
+':MTEXTURES\BSP_SLEEP', 128, 64, 2);
793 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_GO', GameWAD
+':MTEXTURES\BSP_GO', 128, 64, 6);
794 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 50%', 0, True);
795 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN', GameWAD
+':MTEXTURES\BSP_PAIN', 128, 64, 1);
796 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_PAIN_L', GameWAD
+':MTEXTURES\BSP_PAIN_L', 128, 64, 1);
797 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_ATTACK', GameWAD
+':MTEXTURES\BSP_ATTACK', 128, 64, 2);
798 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BSP_DIE', GameWAD
+':MTEXTURES\BSP_DIE', 128, 64, 7);
799 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_SLEEP', GameWAD
+':MTEXTURES\CACO_SLEEP', 128, 128, 1);
800 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_GO', GameWAD
+':MTEXTURES\CACO_GO', 128, 128, 1);
801 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 55%', 0, True);
802 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_PAIN', GameWAD
+':MTEXTURES\CACO_PAIN', 128, 128, 1);
803 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_ATTACK', GameWAD
+':MTEXTURES\CACO_ATTACK', 128, 128, 6);
804 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CACO_DIE', GameWAD
+':MTEXTURES\CACO_DIE', 128, 128, 7);
805 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_SLEEP', GameWAD
+':MTEXTURES\PAIN_SLEEP', 128, 128, 4);
806 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_GO', GameWAD
+':MTEXTURES\PAIN_GO', 128, 128, 4);
807 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_PAIN', GameWAD
+':MTEXTURES\PAIN_PAIN', 128, 128, 1);
808 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 60%', 0, True);
809 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_ATTACK', GameWAD
+':MTEXTURES\PAIN_ATTACK', 128, 128, 4);
810 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_PAIN_DIE', GameWAD
+':MTEXTURES\PAIN_DIE', 128, 128, 7);
811 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP', GameWAD
+':MTEXTURES\BARON_SLEEP', 128, 128, 2);
812 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_SLEEP_L', GameWAD
+':MTEXTURES\BARON_SLEEP_L', 128, 128, 2);
813 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_GO', GameWAD
+':MTEXTURES\BARON_GO', 128, 128, 4);
814 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN', GameWAD
+':MTEXTURES\BARON_PAIN', 128, 128, 1);
815 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 65%', 0, True);
816 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_PAIN_L', GameWAD
+':MTEXTURES\BARON_PAIN_L', 128, 128, 1);
817 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK', GameWAD
+':MTEXTURES\BARON_ATTACK', 128, 128, 3);
818 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_ATTACK_L', GameWAD
+':MTEXTURES\BARON_ATTACK_L', 128, 128, 3);
819 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_BARON_DIE', GameWAD
+':MTEXTURES\BARON_DIE', 128, 128, 7);
820 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP', GameWAD
+':MTEXTURES\KNIGHT_SLEEP', 128, 128, 2);
821 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_SLEEP_L', GameWAD
+':MTEXTURES\KNIGHT_SLEEP_L', 128, 128, 2);
822 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 70%', 0, True);
823 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_GO', GameWAD
+':MTEXTURES\KNIGHT_GO', 128, 128, 4);
824 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN', GameWAD
+':MTEXTURES\KNIGHT_PAIN', 128, 128, 1);
825 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_PAIN_L', GameWAD
+':MTEXTURES\KNIGHT_PAIN_L', 128, 128, 1);
826 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK', GameWAD
+':MTEXTURES\KNIGHT_ATTACK', 128, 128, 3);
827 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_ATTACK_L', GameWAD
+':MTEXTURES\KNIGHT_ATTACK_L', 128, 128, 3);
828 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_KNIGHT_DIE', GameWAD
+':MTEXTURES\KNIGHT_DIE', 128, 128, 7);
829 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 75%', 0, True);
830 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_SLEEP', GameWAD
+':MTEXTURES\MANCUB_SLEEP', 128, 128, 2);
831 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_GO', GameWAD
+':MTEXTURES\MANCUB_GO', 128, 128, 6);
832 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_PAIN', GameWAD
+':MTEXTURES\MANCUB_PAIN', 128, 128, 1);
833 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_ATTACK', GameWAD
+':MTEXTURES\MANCUB_ATTACK', 128, 128, 3);
834 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_MANCUB_DIE', GameWAD
+':MTEXTURES\MANCUB_DIE', 128, 128, 10);
835 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP', GameWAD
+':MTEXTURES\SKEL_SLEEP', 128, 128, 2);
836 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 80%', 0, True);
837 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_SLEEP_L', GameWAD
+':MTEXTURES\SKEL_SLEEP_L', 128, 128, 2);
838 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_GO', GameWAD
+':MTEXTURES\SKEL_GO', 128, 128, 6);
839 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN', GameWAD
+':MTEXTURES\SKEL_PAIN', 128, 128, 1);
840 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_PAIN_L', GameWAD
+':MTEXTURES\SKEL_PAIN_L', 128, 128, 1);
841 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK', GameWAD
+':MTEXTURES\SKEL_ATTACK', 128, 128, 2);
842 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK_L', GameWAD
+':MTEXTURES\SKEL_ATTACK_L', 128, 128, 2);
843 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 85%', 0, True);
844 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2', GameWAD
+':MTEXTURES\SKEL_ATTACK2', 128, 128, 2);
845 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_ATTACK2_L', GameWAD
+':MTEXTURES\SKEL_ATTACK2_L', 128, 128, 2);
846 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_SKEL_DIE', GameWAD
+':MTEXTURES\SKEL_DIE', 128, 128, 5);
847 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP', GameWAD
+':MTEXTURES\VILE_SLEEP', 128, 128, 2);
848 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_SLEEP_L', GameWAD
+':MTEXTURES\VILE_SLEEP_L', 128, 128, 2);
849 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_GO', GameWAD
+':MTEXTURES\VILE_GO', 128, 128, 6);
850 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 90%', 0, True);
851 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN', GameWAD
+':MTEXTURES\VILE_PAIN', 128, 128, 1);
852 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_PAIN_L', GameWAD
+':MTEXTURES\VILE_PAIN_L', 128, 128, 1);
853 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK', GameWAD
+':MTEXTURES\VILE_ATTACK', 128, 128, 10);
854 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK_L', GameWAD
+':MTEXTURES\VILE_ATTACK_L', 128, 128, 10);
855 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2', GameWAD
+':MTEXTURES\VILE_ATTACK2', 128, 128, 3);
856 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_ATTACK2_L', GameWAD
+':MTEXTURES\VILE_ATTACK2_L', 128, 128, 3);
857 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 95%', 0, True);
858 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_VILE_DIE', GameWAD
+':MTEXTURES\VILE_DIE', 128, 128, 9);
859 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_SLEEP', GameWAD
+':MTEXTURES\ROBO_SLEEP', 128, 128, 1);
860 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_GO', GameWAD
+':MTEXTURES\ROBO_GO', 128, 128, 12);
861 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK', GameWAD
+':MTEXTURES\ROBO_ATTACK', 128, 128, 2);
862 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_ATTACK2', GameWAD
+':MTEXTURES\ROBO_ATTACK2', 128, 128, 4);
863 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_ROBO_DIE', GameWAD
+':MTEXTURES\ROBO_DIE', 128, 128, 1);
864 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_TEXTURES
]+' 100%', 0, True);
865 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP', GameWAD
+':MTEXTURES\CYBER_SLEEP', 128, 128, 2);
866 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_SLEEP_L', GameWAD
+':MTEXTURES\CYBER_SLEEP_L', 128, 128, 2);
867 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO', GameWAD
+':MTEXTURES\CYBER_GO', 128, 128, 4);
868 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_GO_L', GameWAD
+':MTEXTURES\CYBER_GO_L', 128, 128, 4);
869 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN', GameWAD
+':MTEXTURES\CYBER_PAIN', 128, 128, 1);
870 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_PAIN_L', GameWAD
+':MTEXTURES\CYBER_PAIN_L', 128, 128, 1);
871 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK', GameWAD
+':MTEXTURES\CYBER_ATTACK', 128, 128, 2);
872 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK_L', GameWAD
+':MTEXTURES\CYBER_ATTACK_L', 128, 128, 2);
873 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2', GameWAD
+':MTEXTURES\CYBER_ATTACK2', 128, 128, 2);
874 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_ATTACK2_L', GameWAD
+':MTEXTURES\CYBER_ATTACK2_L', 128, 128, 2);
875 g_Frames_CreateWAD(nil, 'FRAMES_MONSTER_CYBER_DIE', GameWAD
+':MTEXTURES\CYBER_DIE', 128, 128, 9);
877 g_Game_SetLoadingText(_lc
[I_LOAD_MONSTER_SOUNDS
], 0, False);
879 g_Sound_CreateWADEx('SOUND_MONSTER_BARREL_DIE', GameWAD
+':MSOUNDS\BARREL_DIE');
881 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN', GameWAD
+':MSOUNDS\PAIN');
882 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN2', GameWAD
+':MSOUNDS\PAIN2');
883 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION', GameWAD
+':MSOUNDS\ACTION');
884 g_Sound_CreateWADEx('SOUND_MONSTER_ACTION2', GameWAD
+':MSOUNDS\ACTION2');
885 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_1', GameWAD
+':MSOUNDS\ALERT_1');
886 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_2', GameWAD
+':MSOUNDS\ALERT_2');
887 g_Sound_CreateWADEx('SOUND_MONSTER_ALERT_3', GameWAD
+':MSOUNDS\ALERT_3');
888 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_1', GameWAD
+':MSOUNDS\DIE_1');
889 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_2', GameWAD
+':MSOUNDS\DIE_2');
890 g_Sound_CreateWADEx('SOUND_MONSTER_DIE_3', GameWAD
+':MSOUNDS\DIE_3');
891 g_Sound_CreateWADEx('SOUND_MONSTER_SLOP', GameWAD
+':MSOUNDS\SLOP');
893 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ATTACK', GameWAD
+':MSOUNDS\DEMON_ATTACK');
894 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_ALERT', GameWAD
+':MSOUNDS\DEMON_ALERT');
895 g_Sound_CreateWADEx('SOUND_MONSTER_DEMON_DIE', GameWAD
+':MSOUNDS\DEMON_DIE');
897 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_1', GameWAD
+':MSOUNDS\IMP_ALERT_1');
898 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ALERT_2', GameWAD
+':MSOUNDS\IMP_ALERT_2');
899 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_1', GameWAD
+':MSOUNDS\IMP_DIE_1');
900 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_DIE_2', GameWAD
+':MSOUNDS\IMP_DIE_2');
901 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ACTION', GameWAD
+':MSOUNDS\IMP_ACTION');
902 g_Sound_CreateWADEx('SOUND_MONSTER_IMP_ATTACK', GameWAD
+':MSOUNDS\IMP_ATTACK');
904 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_PAIN', GameWAD
+':MSOUNDS\MAN_PAIN');
905 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_ALERT', GameWAD
+':MSOUNDS\MAN_ALERT');
906 g_Sound_CreateWADEx('SOUND_MONSTER_MAN_DIE', GameWAD
+':MSOUNDS\MAN_DIE');
907 g_Sound_CreateWADEx('SOUND_MONSTER_HAHA', GameWAD
+':MSOUNDS\HAHA');
908 g_Sound_CreateWADEx('SOUND_MONSTER_TRUP', GameWAD
+':MSOUNDS\TRUP');
910 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_ATTACK', GameWAD
+':MSOUNDS\SOUL_ATTACK');
911 g_Sound_CreateWADEx('SOUND_MONSTER_SOUL_DIE', GameWAD
+':MSOUNDS\SOUL_DIE');
913 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ACTION', GameWAD
+':MSOUNDS\BSP_ACTION');
914 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_DIE', GameWAD
+':MSOUNDS\BSP_DIE');
915 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_ALERT', GameWAD
+':MSOUNDS\BSP_ALERT');
916 g_Sound_CreateWADEx('SOUND_MONSTER_BSP_WALK', GameWAD
+':MSOUNDS\BSP_WALK');
918 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ACTION', GameWAD
+':MSOUNDS\VILE_ACTION');
919 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_PAIN', GameWAD
+':MSOUNDS\VILE_PAIN');
920 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_DIE', GameWAD
+':MSOUNDS\VILE_DIE');
921 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ALERT', GameWAD
+':MSOUNDS\VILE_ALERT');
922 g_Sound_CreateWADEx('SOUND_MONSTER_VILE_ATTACK', GameWAD
+':MSOUNDS\VILE_ATTACK');
924 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ACTION', GameWAD
+':MSOUNDS\SKEL_ACTION');
925 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_DIE', GameWAD
+':MSOUNDS\SKEL_DIE');
926 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ALERT', GameWAD
+':MSOUNDS\SKEL_ALERT');
927 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_ATTACK', GameWAD
+':MSOUNDS\SKEL_ATTACK');
928 g_Sound_CreateWADEx('SOUND_MONSTER_SKEL_HIT', GameWAD
+':MSOUNDS\SKEL_HIT');
930 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_PAIN', GameWAD
+':MSOUNDS\MANCUB_PAIN');
931 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_DIE', GameWAD
+':MSOUNDS\MANCUB_DIE');
932 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ALERT', GameWAD
+':MSOUNDS\MANCUB_ALERT');
933 g_Sound_CreateWADEx('SOUND_MONSTER_MANCUB_ATTACK', GameWAD
+':MSOUNDS\MANCUB_ATTACK');
935 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_PAIN', GameWAD
+':MSOUNDS\PAIN_PAIN');
936 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_DIE', GameWAD
+':MSOUNDS\PAIN_DIE');
937 g_Sound_CreateWADEx('SOUND_MONSTER_PAIN_ALERT', GameWAD
+':MSOUNDS\PAIN_ALERT');
939 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_DIE', GameWAD
+':MSOUNDS\BARON_DIE');
940 g_Sound_CreateWADEx('SOUND_MONSTER_BARON_ALERT', GameWAD
+':MSOUNDS\BARON_ALERT');
942 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_DIE', GameWAD
+':MSOUNDS\CACO_DIE');
943 g_Sound_CreateWADEx('SOUND_MONSTER_CACO_ALERT', GameWAD
+':MSOUNDS\CACO_ALERT');
945 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_DIE', GameWAD
+':MSOUNDS\CYBER_DIE');
946 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_ALERT', GameWAD
+':MSOUNDS\CYBER_ALERT');
947 g_Sound_CreateWADEx('SOUND_MONSTER_CYBER_WALK', GameWAD
+':MSOUNDS\CYBER_WALK');
949 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_DIE', GameWAD
+':MSOUNDS\KNIGHT_DIE');
950 g_Sound_CreateWADEx('SOUND_MONSTER_KNIGHT_ALERT', GameWAD
+':MSOUNDS\KNIGHT_ALERT');
952 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_DIE', GameWAD
+':MSOUNDS\SPIDER_DIE');
953 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_ALERT', GameWAD
+':MSOUNDS\SPIDER_ALERT');
954 g_Sound_CreateWADEx('SOUND_MONSTER_SPIDER_WALK', GameWAD
+':MSOUNDS\SPIDER_WALK');
956 g_Sound_CreateWADEx('SOUND_MONSTER_FISH_ATTACK', GameWAD
+':MSOUNDS\FISH_ATTACK');
958 freeInds
:= TIdPool
.Create();
960 monCheckTrapLastFrameId
:= 0;
963 procedure g_Monsters_FreeData();
965 e_WriteLog('Releasing monsters data...', MSG_NOTIFY
);
967 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_SLEEP');
968 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_PAIN');
969 g_Frames_DeleteByName('FRAMES_MONSTER_BARREL_DIE');
970 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_SLEEP');
971 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_GO');
972 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_DIE');
973 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_MESS');
974 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_ATTACK');
975 g_Frames_DeleteByName('FRAMES_MONSTER_ZOMBY_PAIN');
976 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_SLEEP');
977 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_GO');
978 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_DIE');
979 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_MESS');
980 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_ATTACK');
981 g_Frames_DeleteByName('FRAMES_MONSTER_SERG_PAIN');
982 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_SLEEP');
983 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_GO');
984 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_DIE');
985 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_MESS');
986 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_ATTACK');
987 g_Frames_DeleteByName('FRAMES_MONSTER_MAN_PAIN');
988 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP');
989 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_SLEEP_L');
990 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO');
991 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_GO_L');
992 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_DIE');
993 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_MESS');
994 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK');
995 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_ATTACK_L');
996 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN');
997 g_Frames_DeleteByName('FRAMES_MONSTER_CGUN_PAIN_L');
998 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_SLEEP');
999 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_GO');
1000 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_DIE');
1001 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_MESS');
1002 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_ATTACK');
1003 g_Frames_DeleteByName('FRAMES_MONSTER_IMP_PAIN');
1004 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_SLEEP');
1005 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_GO');
1006 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_DIE');
1007 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_ATTACK');
1008 g_Frames_DeleteByName('FRAMES_MONSTER_DEMON_PAIN');
1009 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_SLEEP');
1010 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_GO');
1011 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_PAIN');
1012 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_ATTACK');
1013 g_Frames_DeleteByName('FRAMES_MONSTER_SOUL_DIE');
1014 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_SLEEP');
1015 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_GO');
1016 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_PAIN');
1017 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_ATTACK');
1018 g_Frames_DeleteByName('FRAMES_MONSTER_FISH_DIE');
1019 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_SLEEP');
1020 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_GO');
1021 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN');
1022 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_PAIN_L');
1023 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_ATTACK');
1024 g_Frames_DeleteByName('FRAMES_MONSTER_SPIDER_DIE');
1025 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_SLEEP');
1026 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_GO');
1027 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN');
1028 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_PAIN_L');
1029 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_ATTACK');
1030 g_Frames_DeleteByName('FRAMES_MONSTER_BSP_DIE');
1031 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_SLEEP');
1032 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_GO');
1033 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_PAIN');
1034 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_ATTACK');
1035 g_Frames_DeleteByName('FRAMES_MONSTER_CACO_DIE');
1036 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_SLEEP');
1037 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_GO');
1038 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_PAIN');
1039 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_ATTACK');
1040 g_Frames_DeleteByName('FRAMES_MONSTER_PAIN_DIE');
1041 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP');
1042 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_SLEEP_L');
1043 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_GO');
1044 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN');
1045 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_PAIN_L');
1046 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK');
1047 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_ATTACK_L');
1048 g_Frames_DeleteByName('FRAMES_MONSTER_BARON_DIE');
1049 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP');
1050 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_SLEEP_L');
1051 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_GO');
1052 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN');
1053 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_PAIN_L');
1054 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK');
1055 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_ATTACK_L');
1056 g_Frames_DeleteByName('FRAMES_MONSTER_KNIGHT_DIE');
1057 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_SLEEP');
1058 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_GO');
1059 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_PAIN');
1060 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_ATTACK');
1061 g_Frames_DeleteByName('FRAMES_MONSTER_MANCUB_DIE');
1062 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP');
1063 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_SLEEP_L');
1064 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_GO');
1065 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN');
1066 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_PAIN_L');
1067 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK');
1068 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK_L');
1069 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2');
1070 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_ATTACK2_L');
1071 g_Frames_DeleteByName('FRAMES_MONSTER_SKEL_DIE');
1072 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP');
1073 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_SLEEP_L');
1074 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_GO');
1075 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN');
1076 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_PAIN_L');
1077 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK');
1078 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK_L');
1079 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2');
1080 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_ATTACK2_L');
1081 g_Frames_DeleteByName('FRAMES_MONSTER_VILE_DIE');
1082 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_SLEEP');
1083 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_GO');
1084 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK');
1085 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_ATTACK2');
1086 g_Frames_DeleteByName('FRAMES_MONSTER_ROBO_DIE');
1087 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP');
1088 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_SLEEP_L');
1089 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO');
1090 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_GO_L');
1091 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN');
1092 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_PAIN_L');
1093 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK');
1094 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK_L');
1095 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2');
1096 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_ATTACK2_L');
1097 g_Frames_DeleteByName('FRAMES_MONSTER_CYBER_DIE');
1099 g_Sound_Delete('SOUND_MONSTER_BARREL_DIE');
1101 g_Sound_Delete('SOUND_MONSTER_PAIN');
1102 g_Sound_Delete('SOUND_MONSTER_PAIN2');
1103 g_Sound_Delete('SOUND_MONSTER_ACTION');
1104 g_Sound_Delete('SOUND_MONSTER_ACTION2');
1105 g_Sound_Delete('SOUND_MONSTER_ALERT_1');
1106 g_Sound_Delete('SOUND_MONSTER_ALERT_2');
1107 g_Sound_Delete('SOUND_MONSTER_ALERT_3');
1108 g_Sound_Delete('SOUND_MONSTER_DIE_1');
1109 g_Sound_Delete('SOUND_MONSTER_DIE_2');
1110 g_Sound_Delete('SOUND_MONSTER_DIE_3');
1111 g_Sound_Delete('SOUND_MONSTER_SLOP');
1113 g_Sound_Delete('SOUND_MONSTER_DEMON_ATTACK');
1114 g_Sound_Delete('SOUND_MONSTER_DEMON_ALERT');
1115 g_Sound_Delete('SOUND_MONSTER_DEMON_DIE');
1117 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_1');
1118 g_Sound_Delete('SOUND_MONSTER_IMP_ALERT_2');
1119 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_1');
1120 g_Sound_Delete('SOUND_MONSTER_IMP_DIE_2');
1121 g_Sound_Delete('SOUND_MONSTER_IMP_ACTION');
1122 g_Sound_Delete('SOUND_MONSTER_IMP_ATTACK');
1124 g_Sound_Delete('SOUND_MONSTER_MAN_PAIN');
1125 g_Sound_Delete('SOUND_MONSTER_MAN_ALERT');
1126 g_Sound_Delete('SOUND_MONSTER_MAN_DIE');
1127 g_Sound_Delete('SOUND_MONSTER_HAHA');
1128 g_Sound_Delete('SOUND_MONSTER_TRUP');
1130 g_Sound_Delete('SOUND_MONSTER_SOUL_ATTACK');
1131 g_Sound_Delete('SOUND_MONSTER_SOUL_DIE');
1133 g_Sound_Delete('SOUND_MONSTER_BSP_ACTION');
1134 g_Sound_Delete('SOUND_MONSTER_BSP_DIE');
1135 g_Sound_Delete('SOUND_MONSTER_BSP_ALERT');
1136 g_Sound_Delete('SOUND_MONSTER_BSP_WALK');
1138 g_Sound_Delete('SOUND_MONSTER_VILE_ACTION');
1139 g_Sound_Delete('SOUND_MONSTER_VILE_PAIN');
1140 g_Sound_Delete('SOUND_MONSTER_VILE_DIE');
1141 g_Sound_Delete('SOUND_MONSTER_VILE_ALERT');
1142 g_Sound_Delete('SOUND_MONSTER_VILE_ATTACK');
1144 g_Sound_Delete('SOUND_MONSTER_SKEL_ACTION');
1145 g_Sound_Delete('SOUND_MONSTER_SKEL_DIE');
1146 g_Sound_Delete('SOUND_MONSTER_SKEL_ALERT');
1147 g_Sound_Delete('SOUND_MONSTER_SKEL_ATTACK');
1148 g_Sound_Delete('SOUND_MONSTER_SKEL_HIT');
1150 g_Sound_Delete('SOUND_MONSTER_MANCUB_PAIN');
1151 g_Sound_Delete('SOUND_MONSTER_MANCUB_DIE');
1152 g_Sound_Delete('SOUND_MONSTER_MANCUB_ALERT');
1153 g_Sound_Delete('SOUND_MONSTER_MANCUB_ATTACK');
1155 g_Sound_Delete('SOUND_MONSTER_PAIN_PAIN');
1156 g_Sound_Delete('SOUND_MONSTER_PAIN_DIE');
1157 g_Sound_Delete('SOUND_MONSTER_PAIN_ALERT');
1159 g_Sound_Delete('SOUND_MONSTER_BARON_DIE');
1160 g_Sound_Delete('SOUND_MONSTER_BARON_ALERT');
1162 g_Sound_Delete('SOUND_MONSTER_CACO_DIE');
1163 g_Sound_Delete('SOUND_MONSTER_CACO_ALERT');
1165 g_Sound_Delete('SOUND_MONSTER_CYBER_DIE');
1166 g_Sound_Delete('SOUND_MONSTER_CYBER_ALERT');
1167 g_Sound_Delete('SOUND_MONSTER_CYBER_WALK');
1169 g_Sound_Delete('SOUND_MONSTER_KNIGHT_DIE');
1170 g_Sound_Delete('SOUND_MONSTER_KNIGHT_ALERT');
1172 g_Sound_Delete('SOUND_MONSTER_SPIDER_DIE');
1173 g_Sound_Delete('SOUND_MONSTER_SPIDER_ALERT');
1174 g_Sound_Delete('SOUND_MONSTER_SPIDER_WALK');
1176 g_Sound_Delete('SOUND_MONSTER_FISH_ATTACK');
1182 procedure g_Monsters_Init();
1187 procedure g_Monsters_Free (clearGrid
: Boolean=true);
1191 e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid
]);
1197 for a
:= 0 to High(gMonsters
) do gMonsters
[a
].Free();
1200 monCheckTrapLastFrameId
:= 0;
1204 // will be called from map loader
1205 procedure g_Mons_InitTree (x
, y
, w
, h
: Integer);
1208 monsGrid
:= TMonsterGrid
.Create(x
, y
, w
, h
);
1209 //clearUidMap(); // why not?
1210 e_LogWritefln('%s', ['Recreated monster tree']);
1214 function g_Monsters_Create(MonsterType
: Byte; X
, Y
: Integer;
1215 Direction
: TDirection
; AdjCoord
: Boolean = False; ForcedUID
: Integer = -1): TMonster
;
1222 // Íåò òàêîãî ìîíñòðà
1223 if (MonsterType
> MONSTER_MAN
) or (MonsterType
= 0) then exit
;
1225 // Ñîáëþäàåì îãðàíè÷åíèå Lost_Soul'îâ
1226 if MonsterType
= MONSTER_SOUL
then
1228 if soulcount
> MAX_SOUL
then exit
;
1229 soulcount
:= soulcount
+ 1;
1232 find_id
:= allocMonster();
1234 mon
:= TMonster
.Create(MonsterType
, find_id
, ForcedUID
);
1235 gMonsters
[find_id
] := mon
;
1236 mon
.mArrIdx
:= find_id
;
1239 uidMap
[mon
.FUID
] := mon
;
1241 // Íàñòðàèâàåì ïîëîæåíèå
1246 FObj
.X
:= X
-FObj
.Rect
.X
- (FObj
.Rect
.Width
div 2);
1247 FObj
.Y
:= Y
-FObj
.Rect
.Y
- FObj
.Rect
.Height
;
1251 FObj
.X
:= X
-FObj
.Rect
.X
;
1252 FObj
.Y
:= Y
-FObj
.Rect
.Y
;
1255 FDirection
:= Direction
;
1256 FStartDirection
:= Direction
;
1261 mon
.positionChanged();
1266 procedure g_Monsters_killedp();
1270 if gMonsters
= nil then
1273 // Ïðèêîëèñò ñìååòñÿ íàä ñìåðòüþ èãðîêà:
1274 h
:= High(gMonsters
);
1277 if (gMonsters
[a
] <> nil) then
1279 with gMonsters
[a
] do
1281 if (FMonsterType
= MONSTER_MAN
) and
1282 (FState
<> MONSTATE_DEAD
) and
1283 (FState
<> MONSTATE_SLEEP
) and
1284 (FState
<> MONSTATE_DIE
) then
1286 g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj
.X
, FObj
.Y
);
1294 procedure g_Monsters_Update();
1299 if gTime
mod (GAME_TICK
*2) = 0 then
1303 if abs(pt_x
) > 246 then pt_xs
:= -pt_xs
;
1304 if abs(pt_y
) > 100 then pt_ys
:= -pt_ys
;
1307 gMon
:= True; // Äëÿ ðàáîòû BlockMon'à
1309 if gmon_debug_think
or gmon_debug_one_think_step
then
1311 gmon_debug_one_think_step
:= false;
1312 for a
:= 0 to High(gMonsters
) do
1314 if (gMonsters
[a
] = nil) then continue
;
1315 if not gMonsters
[a
].FRemoved
then
1317 if g_Game_IsClient
then
1318 gMonsters
[a
].ClientUpdate()
1320 gMonsters
[a
].Update();
1324 gMonsters
[a
].Free();
1325 gMonsters
[a
] := nil;
1333 procedure g_Monsters_Draw();
1337 if gMonsters
<> nil then
1339 for a
:= 0 to High(gMonsters
) do
1341 if (gMonsters
[a
] <> nil) then gMonsters
[a
].Draw();
1346 procedure g_Monsters_DrawHealth();
1351 if gMonsters
= nil then Exit
;
1352 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1354 for a
:= 0 to High(gMonsters
) do
1356 if gMonsters
[a
] <> nil then
1358 e_TextureFontPrint(gMonsters
[a
].FObj
.X
+ gMonsters
[a
].FObj
.Rect
.X
,
1359 gMonsters
[a
].FObj
.Y
+ gMonsters
[a
].FObj
.Rect
.Y
+ gMonsters
[a
].FObj
.Rect
.Height
- fH
,
1360 IntToStr(gMonsters
[a
].FHealth
), gStdFont
);
1365 function g_Monsters_ByUID (UID
: Word): TMonster
;
1367 result
:= uidMap
[UID
];
1370 procedure g_Monsters_SaveState(var Mem
: TBinMemoryWriter
);
1375 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ìîíñòðîâ:
1377 if (gMonsters
<> nil) then
1379 for i
:= 0 to High(gMonsters
) do
1381 if (gMonsters
[i
] <> nil) then
1383 if (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then count
+= 1;
1388 Mem
:= TBinMemoryWriter
.Create((count
+1) * 350);
1390 // Ñîõðàíÿåì èíôîðìàöèþ öåëåóêàçàòåëÿ:
1392 Mem
.WriteInt(pt_xs
);
1394 Mem
.WriteInt(pt_ys
);
1396 // Êîëè÷åñòâî ìîíñòðîâ:
1397 Mem
.WriteInt(count
);
1402 // Ñîõðàíÿåì ìîíñòðîâ:
1403 for i
:= 0 to High(gMonsters
) do
1405 if (gMonsters
[i
] <> nil) then
1407 if (gMonsters
[i
].FMonsterType
<> MONSTER_NONE
) then
1410 b
:= gMonsters
[i
].MonsterType
;
1412 // Ñîõðàíÿåì äàííûå ìîíñòðà:
1413 gMonsters
[i
].SaveState(Mem
);
1419 procedure g_Monsters_LoadState(var Mem
: TBinMemoryReader
);
1425 if Mem
= nil then exit
;
1427 g_Monsters_Free(false);
1429 // Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
1435 // Êîëè÷åñòâî ìîíñòðîâ
1438 if count
= 0 then exit
;
1440 // Çàãðóæàåì ìîíñòðîâ
1441 for a
:= 0 to count
-1 do
1446 mon
:= g_Monsters_Create(b
, 0, 0, D_LEFT
);
1447 if mon
= nil then raise EBinSizeError
.Create('g_Monsters_LoadState: ID = -1 (Can''t create)');
1448 // Çàãðóæàåì äàííûå ìîíñòðà
1453 function g_Monsters_GetIDByName(name
: String): Integer;
1457 name
:= UpperCase(name
);
1459 while (i
<= MONSTER_MAN
) do
1461 if name
= MONSTERTABLE
[i
].Name
then
1472 function g_Monsters_GetNameByID(MonsterType
: Byte): String;
1474 if MonsterType
in [MONSTER_DEMON
..MONSTER_MAN
] then
1475 Result
:= MONSTERTABLE
[MonsterType
].Name
1480 function g_Monsters_GetKilledBy(MonsterType
: Byte): String;
1482 if MonsterType
in [MONSTER_DEMON
..MONSTER_MAN
] then
1483 Result
:= KilledByMonster
[MonsterType
]
1488 { T M o n s t e r : }
1490 procedure TMonster
.ActionSound();
1492 case FMonsterType
of
1494 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ACTION', FObj
.X
, FObj
.Y
);
1495 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
,
1497 g_Sound_PlayExAt('SOUND_MONSTER_ACTION', FObj
.X
, FObj
.Y
);
1498 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1499 MONSTER_KNIGHT
, MONSTER_PAIN
, MONSTER_DEMON
,
1501 g_Sound_PlayExAt('SOUND_MONSTER_ACTION2', FObj
.X
, FObj
.Y
);
1503 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ACTION', FObj
.X
, FObj
.Y
);
1505 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ACTION', FObj
.X
, FObj
.Y
);
1507 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ACTION', FObj
.X
, FObj
.Y
);
1511 g_Sound_PlayExAt('SOUND_MONSTER_HAHA', FObj
.X
, FObj
.Y
);
1515 procedure TMonster
.PainSound();
1523 case FMonsterType
of
1524 MONSTER_IMP
, MONSTER_ZOMBY
, MONSTER_SERG
,
1525 MONSTER_SKEL
, MONSTER_CGUN
:
1526 g_Sound_PlayExAt('SOUND_MONSTER_PAIN', FObj
.X
, FObj
.Y
);
1527 MONSTER_SOUL
, MONSTER_BARON
, MONSTER_CACO
,
1528 MONSTER_KNIGHT
, MONSTER_DEMON
, MONSTER_SPIDER
,
1529 MONSTER_BSP
, MONSTER_CYBER
:
1530 g_Sound_PlayExAt('SOUND_MONSTER_PAIN2', FObj
.X
, FObj
.Y
);
1532 g_Sound_PlayExAt('SOUND_MONSTER_VILE_PAIN', FObj
.X
, FObj
.Y
);
1534 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_PAIN', FObj
.X
, FObj
.Y
);
1536 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_PAIN', FObj
.X
, FObj
.Y
);
1538 g_Sound_PlayExAt('SOUND_MONSTER_MAN_PAIN', FObj
.X
, FObj
.Y
);
1542 procedure TMonster
.DieSound();
1544 case FMonsterType
of
1547 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_1', FObj
.X
, FObj
.Y
);
1548 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_DIE_2', FObj
.X
, FObj
.Y
);
1550 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1552 0: g_Sound_PlayExAt('SOUND_MONSTER_DIE_1', FObj
.X
, FObj
.Y
);
1553 1: g_Sound_PlayExAt('SOUND_MONSTER_DIE_2', FObj
.X
, FObj
.Y
);
1554 2: g_Sound_PlayExAt('SOUND_MONSTER_DIE_3', FObj
.X
, FObj
.Y
);
1557 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_DIE', FObj
.X
, FObj
.Y
);
1559 g_Sound_PlayExAt('SOUND_MONSTER_BARREL_DIE', FObj
.X
, FObj
.Y
);
1561 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_DIE', FObj
.X
, FObj
.Y
);
1563 g_Sound_PlayExAt('SOUND_MONSTER_BSP_DIE', FObj
.X
, FObj
.Y
);
1565 g_Sound_PlayExAt('SOUND_MONSTER_VILE_DIE', FObj
.X
, FObj
.Y
);
1567 g_Sound_PlayExAt('SOUND_MONSTER_BARON_DIE', FObj
.X
, FObj
.Y
);
1569 g_Sound_PlayExAt('SOUND_MONSTER_CACO_DIE', FObj
.X
, FObj
.Y
);
1571 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_DIE', FObj
.X
, FObj
.Y
);
1573 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_DIE', FObj
.X
, FObj
.Y
);
1575 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_DIE', FObj
.X
, FObj
.Y
);
1577 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_DIE', FObj
.X
, FObj
.Y
);
1579 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_DIE', FObj
.X
, FObj
.Y
);
1581 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_DIE', FObj
.X
, FObj
.Y
);
1583 g_Sound_PlayExAt('SOUND_MONSTER_MAN_DIE', FObj
.X
, FObj
.Y
);
1587 procedure TMonster
.WakeUpSound();
1589 case FMonsterType
of
1592 0: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_1', FObj
.X
, FObj
.Y
);
1593 1: g_Sound_PlayExAt('SOUND_MONSTER_IMP_ALERT_2', FObj
.X
, FObj
.Y
);
1595 MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_CGUN
:
1597 0: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_1', FObj
.X
, FObj
.Y
);
1598 1: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_2', FObj
.X
, FObj
.Y
);
1599 2: g_Sound_PlayExAt('SOUND_MONSTER_ALERT_3', FObj
.X
, FObj
.Y
);
1602 g_Sound_PlayExAt('SOUND_MONSTER_MAN_ALERT', FObj
.X
, FObj
.Y
);
1604 g_Sound_PlayExAt('SOUND_MONSTER_BSP_ALERT', FObj
.X
, FObj
.Y
);
1606 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ALERT', FObj
.X
, FObj
.Y
);
1608 g_Sound_PlayExAt('SOUND_MONSTER_BARON_ALERT', FObj
.X
, FObj
.Y
);
1610 g_Sound_PlayExAt('SOUND_MONSTER_CACO_ALERT', FObj
.X
, FObj
.Y
);
1612 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_ALERT', FObj
.X
, FObj
.Y
);
1614 g_Sound_PlayExAt('SOUND_MONSTER_KNIGHT_ALERT', FObj
.X
, FObj
.Y
);
1616 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ALERT', FObj
.X
, FObj
.Y
);
1618 g_Sound_PlayExAt('SOUND_MONSTER_PAIN_ALERT', FObj
.X
, FObj
.Y
);
1620 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ALERT', FObj
.X
, FObj
.Y
);
1622 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ALERT', FObj
.X
, FObj
.Y
);
1624 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_ALERT', FObj
.X
, FObj
.Y
);
1630 procedure TMonster
.BFGHit();
1632 if FMonsterType
= MONSTER_FISH
then
1635 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1636 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1637 {if g_Game_IsServer and g_Game_IsNet then
1638 MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
1639 FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
1643 function TMonster
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
1645 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1653 function TMonster
.Collide(Panel
: TPanel
): Boolean;
1655 Result
:= g_Collide(FObj
.X
+FObj
.Rect
.X
,
1660 Panel
.Width
, Panel
.Height
);
1663 function TMonster
.Collide(X
, Y
: Integer): Boolean;
1665 X
:= X
- FObj
.X
- FObj
.Rect
.X
;
1666 Y
:= Y
- FObj
.Y
- FObj
.Rect
.Y
;
1667 Result
:= (x
>= 0) and (x
<= FObj
.Rect
.Width
) and
1668 (y
>= 0) and (y
<= FObj
.Rect
.Height
);
1671 procedure TMonster
.Respawn
;
1677 FDirection
:= FStartDirection
;
1680 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
1681 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
1686 FDieTriggers
:= nil;
1687 FWaitAttackAnim
:= False;
1688 FChainFire
:= False;
1691 FState
:= MONSTATE_SLEEP
;
1692 FCurAnim
:= ANIM_SLEEP
;
1694 positionChanged(); // this updates spatial accelerators
1696 if g_Game_IsNet
and g_Game_IsServer
then
1698 MH_SEND_MonsterPos(FUID
);
1699 MH_SEND_MonsterState(FUID
);
1703 constructor TMonster
.Create(MonsterType
: Byte; aID
: Integer; ForcedUID
: Integer = -1);
1706 FramesID
: DWORD
= 0;
1710 if ForcedUID
< 0 then
1711 FUID
:= g_CreateUID(UID_MONSTER
)
1715 FMonsterType
:= MonsterType
;
1719 FState
:= MONSTATE_SLEEP
;
1720 FCurAnim
:= ANIM_SLEEP
;
1721 FHealth
:= MONSTERTABLE
[MonsterType
].Health
;
1722 FMaxHealth
:= FHealth
;
1723 FObj
.Rect
:= MONSTERTABLE
[MonsterType
].Rect
;
1724 FDieTriggers
:= nil;
1725 FSpawnTrigger
:= -1;
1726 FWaitAttackAnim
:= False;
1727 FChainFire
:= False;
1729 FNoRespawn
:= False;
1731 FBehaviour
:= BH_NORMAL
;
1738 trapCheckFrameId
:= 0;
1740 if FMonsterType
in [MONSTER_ROBO
, MONSTER_BARREL
] then
1741 FBloodKind
:= BLOOD_SPARKS
1743 FBloodKind
:= BLOOD_NORMAL
;
1744 if FMonsterType
= MONSTER_CACO
then
1750 else if FMonsterType
in [MONSTER_BARON
, MONSTER_KNIGHT
] then
1763 SetLength(FAnim
, Length(ANIMTABLE
));
1765 for a
:= 0 to High(FAnim
) do
1767 FAnim
[a
, D_LEFT
] := nil;
1768 FAnim
[a
, D_RIGHT
] := nil;
1771 for a
:= ANIM_SLEEP
to ANIM_PAIN
do
1772 if (ANIMTABLE
[a
].name
<> '') and
1773 (MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
] <> 0) then
1775 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1776 '_'+ANIMTABLE
[a
].name
;
1778 res
:= g_Frames_Exists(s
);
1781 res
:= g_Frames_Get(FramesID
, s
);
1783 // Åñëè íåò òàêîé àíèìàöèè, òî ïðîáóåì çàìåíèòü åå íà àíèìàöèþ ñìåðòè:
1786 // Çàìåíÿåì òîëüêî ANIM_MESS íà ANIM_DIE:
1787 if a
<> ANIM_MESS
then
1790 if g_Frames_Get(FramesID
, 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1791 '_'+ANIMTABLE
[ANIM_DIE
].name
) then
1793 FAnim
[a
, D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1794 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1795 FAnim
[a
, D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[ANIM_DIE
].loop
,
1796 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[ANIM_DIE
]);
1801 FAnim
[a
, D_RIGHT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1802 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1804 // Åñëè åñòü îòäåëüíàÿ ëåâàÿ àíèìàöèÿ - çàãðóæàåì:
1805 if MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
then
1807 s
:= 'FRAMES_MONSTER_'+MONSTERTABLE
[MonsterType
].Name
+
1808 '_'+ANIMTABLE
[a
].name
+'_L';
1809 if g_Frames_Exists(s
) then
1810 g_Frames_Get(FramesID
, s
);
1813 FAnim
[a
, D_LEFT
] := TAnimation
.Create(FramesID
, ANIMTABLE
[a
].loop
,
1814 MONSTER_ANIMTABLE
[MonsterType
].AnimSpeed
[a
]);
1817 // Äëÿ êîëäóíà çàãðóæàåì òàêæå àíèìàöèþ îãíÿ:
1818 if MonsterType
= MONSTER_VILE
then
1820 g_Frames_Get(FramesID
, 'FRAMES_FIRE');
1821 vilefire
:= TAnimation
.Create(FramesID
, True, 2);
1827 function TMonster
.Damage(aDamage
: Word; VelX
, VelY
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
1834 // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
1835 if (FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_REVIVE
) then
1838 // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà:
1839 if (t
= HIT_ELECTRO
) and (FMonsterType
= MONSTER_FISH
) and g_Game_IsServer
then
1842 if Random(2) = 0 then
1843 FDirection
:= D_RIGHT
1845 FDirection
:= D_LEFT
;
1847 SetState(MONSTATE_RUN
);
1851 // Ëîâóøêà óáèâàåò ñðàçó:
1852 if t
= HIT_TRAP
then
1855 // Ðîáîòó óðîíà íåò:
1856 if FMonsterType
= MONSTER_ROBO
then
1860 if g_Game_IsServer
then Dec(FHealth
, aDamage
);
1862 // Óñèëèâàåì áîëü ìîíñòðà îò óðîíà:
1865 FPain
:= FPain
+aDamage
;
1867 // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå:
1868 if FState
<> MONSTATE_PAIN
then
1869 if (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) and
1870 (FMonsterType
<> MONSTER_BARREL
) then
1871 SetState(MONSTATE_PAIN
);
1873 // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè:
1874 if (gBloodCount
> 0) then
1876 c
:= Min(aDamage
, 200);
1877 c
:= c
*gBloodCount
- (aDamage
div 4) + Random(c
div 2);
1879 if (VelX
= 0) and (VelY
= 0) then
1883 HIT_TRAP
, HIT_ACID
, HIT_ELECTRO
, HIT_FLAME
: MakeBloodSimple(c
);
1884 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, VelX
, VelY
);
1888 // Òåïåðü öåëü - óäàðèâøèé, åñëè òîëüêî íå ñàì ñåáÿ:
1889 if (SpawnerUID
<> FUID
) and (BehaviourDamage(SpawnerUID
, FBehaviour
, FMonsterType
)) then
1891 FTargetUID
:= SpawnerUID
;
1895 // Çäîðîâüå çàêîí÷èëîñü:
1896 if FHealth
<= 0 then
1898 // Åñëè ýòî íå áî÷êà è óáèë èãðîê, òî åìó +1:
1899 if (FMonsterType
<> MONSTER_BARREL
) then
1901 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1903 p
:= g_Player_Get(SpawnerUID
);
1904 if (p
<> nil) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
1906 p
.MonsterKills
:= p
.MonsterKills
+1;
1907 if gGameSettings
.GameMode
= GM_COOP
then
1908 p
.Frags
:= p
.Frags
+ 1;
1909 // Uncomment this if you want to double-kill monsters
1913 if gLMSRespawn
= LMS_RESPAWN_NONE
then
1915 Inc(gCoopMonstersKilled
);
1916 if g_Game_IsNet
then
1922 case FMonsterType
of
1923 MONSTER_ZOMBY
: c
:= ITEM_AMMO_BULLETS
;
1924 MONSTER_SERG
: c
:= ITEM_WEAPON_SHOTGUN1
;
1925 MONSTER_CGUN
: c
:= ITEM_WEAPON_CHAINGUN
;
1926 MONSTER_MAN
: c
:= ITEM_KEY_RED
;
1933 it
:= g_Items_Create(FObj
.X
+ (FObj
.Rect
.Width
div 2),
1934 FObj
.Y
+ (FObj
.Rect
.Height
div 2),
1936 g_Obj_Push(g_Items_ObjByIdx(it
), (FObj
.Vel
.X
div 2)-3+Random(7),
1937 (FObj
.Vel
.Y
div 2)-Random(4));
1938 positionChanged(); // this updates spatial accelerators
1939 if g_Game_IsServer
and g_Game_IsNet
then
1940 MH_SEND_ItemSpawn(True, it
);
1943 // Òðóï äàëüøå íå èäåò:
1946 // Ó òðóïà ðàçìåðû ìåíüøå:
1947 if (FMonsterType
<> MONSTER_FISH
) and (FMonsterType
<> MONSTER_PAIN
) then
1949 FObj
.Rect
.Y
:= FObj
.Rect
.Y
+ FObj
.Rect
.Height
-12;
1950 FObj
.Rect
.Height
:= 12;
1954 // Óðîí áûë ñèëüíûì => ñëàáûå - â êàøó:
1955 if (FHealth
<= -30) and
1956 ((FMonsterType
= MONSTER_IMP
) or (FMonsterType
= MONSTER_ZOMBY
) or
1957 (FMonsterType
= MONSTER_SERG
) or (FMonsterType
= MONSTER_CGUN
) or
1958 (FMonsterType
= MONSTER_MAN
)) then
1960 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
1961 SetState(MONSTATE_DIE
, ANIM_MESS
);
1966 SetState(MONSTATE_DIE
);
1969 // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà:
1970 if g_Game_IsServer
then ActivateTriggers();
1975 if FState
= MONSTATE_SLEEP
then
1976 begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì:
1977 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
1978 SetState(MONSTATE_GO
);
1981 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
1985 function TMonster
.Heal(Value
: Word): Boolean;
1988 if g_Game_IsClient
then
1993 if FHealth
< FMaxHealth
then
1995 IncMax(FHealth
, Value
, FMaxHealth
);
1996 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
);
2001 destructor TMonster
.Destroy();
2005 for a
:= 0 to High(FAnim
) do
2007 FAnim
[a
, D_LEFT
].Free();
2008 FAnim
[a
, D_RIGHT
].Free();
2013 if (mProxyId
<> -1) then
2015 if (monsGrid
<> nil) then
2017 monsGrid
.removeBody(mProxyId
);
2018 {$IF DEFINED(D2F_DEBUG_MONS_MOVE)}
2019 e_WriteLog(Format('monster #%d:(%u): removed from grid; mProxyid=%d', [mArrIdx
, UID
, mProxyId
]), MSG_NOTIFY
);
2025 if (mArrIdx
<> -1) and (mArrIdx
< Length(gMonsters
)) then
2027 freeInds
.release(mArrIdx
);
2028 gMonsters
[mArrIdx
] := nil;
2032 uidMap
[FUID
] := nil;
2034 inherited Destroy();
2037 procedure TMonster
.Draw();
2043 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType));
2044 //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState));
2046 // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
2047 if FMonsterType
= MONSTER_VILE
then
2048 if FState
= MONSTATE_SHOOT
then
2049 if GetPos(FTargetUID
, @o
) then
2050 vilefire
.Draw(o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-32,
2051 o
.Y
+o
.Rect
.Y
+o
.Rect
.Height
-128, M_NONE
);
2053 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
2054 if not g_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
,
2055 sX
-128, sY
-128, sWidth
+256, sHeight
+256) then
2058 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
2059 if FState
= MONSTATE_DEAD
then
2060 case FMonsterType
of
2061 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
2064 // Åñòü ÷òî ðèñîâàòü ïðè òåêóùåì ïîâåäåíèè:
2065 if FAnim
[FCurAnim
, FDirection
] <> nil then
2067 // Åñëè íåò ëåâîé àíèìàöèè èëè îíà ñîâïàäàåò ñ ïðàâîé => îòðàæàåì ïðàâóþ:
2068 if (FDirection
= D_LEFT
) and
2069 ((not MONSTER_ANIMTABLE
[FMonsterType
].LeftAnim
) or
2070 (FAnim
[FCurAnim
, D_LEFT
].FramesID
= FAnim
[FCurAnim
, D_RIGHT
].FramesID
)) and
2071 (FMonsterType
<> MONSTER_BARREL
) then
2076 // Ëåâàÿ àíèìàöèÿ => ìåíÿåì ñìåùåíèå îòíîñèòåëüíî öåíòðà:
2077 if (FDirection
= D_LEFT
) and
2078 (FMonsterType
<> MONSTER_BARREL
) then
2080 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].X
;
2081 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaLeft
[FCurAnim
].Y
;
2083 if m
= M_HORIZONTAL
then
2084 begin // Íåò îòäåëüíîé ëåâîé àíèìàöèè
2085 // Ðàññòîÿíèå îò êðàÿ òåêñòóðû äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2086 c
:= (MONSTERTABLE
[FMonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[FMonsterType
].Rect
.Width
;
2087 // Ðàññòîÿíèå îò êðàÿ õèò áîêñà äî êðàÿ âèçóàëüíîãî ïîëîæåíèÿ îáúåêòà íà òåêñòóðå:
2088 dx
:= FAnim
[FCurAnim
, FDirection
].Width
- c
- MONSTERTABLE
[FMonsterType
].Rect
.X
;
2089 // Ò.ê. äâèãàòü òåêñòóðó íóæíî áóäåò â ïðîòèâîïîëîæíîì íàïðàâëåíèè:
2091 // Ýòî çíà÷èò: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
2094 else // Ïðàâàÿ àíèìàöèÿ
2096 dx
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].X
;
2097 dy
:= MONSTER_ANIMTABLE
[FMonsterType
].AnimDeltaRight
[FCurAnim
].Y
;
2101 FAnim
[FCurAnim
, FDirection
].Draw(Obj
.X
+dx
, Obj
.Y
+dy
, m
);
2104 if g_debug_Frames
then
2106 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2108 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2109 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2114 procedure TMonster
.MakeBloodSimple(Count
: Word);
2116 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)+8,
2117 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2118 Count
div 2, 3, -1, 16, (FObj
.Rect
.Height
*2 div 3),
2119 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2120 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-8,
2121 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2122 Count
div 2, -3, -1, 16, (FObj
.Rect
.Height
*2) div 3,
2123 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2126 procedure TMonster
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
2128 g_GFX_Blood(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2129 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2130 Count
, VelX
, VelY
, 16, (FObj
.Rect
.Height
*2) div 3,
2131 FBloodRed
, FBloodGreen
, FBloodBlue
, FBloodKind
);
2134 procedure TMonster
.Push(vx
, vy
: Integer);
2136 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
2137 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
2138 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2141 procedure TMonster
.SetState(State
: Byte; ForceAnim
: Byte = 255);
2145 // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul,
2146 // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ:
2147 if (State
= MONSTATE_DIE
) and (MonsterType
= MONSTER_SOUL
) then
2148 soulcount
:= soulcount
-1;
2150 // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü:
2152 MONSTATE_DIE
, MONSTATE_DEAD
, MONSTATE_REVIVE
:
2153 if (State
<> MONSTATE_DEAD
) and (State
<> MONSTATE_REVIVE
) and
2154 (State
<> MONSTATE_GO
) then
2161 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterState(FUID
, ForceAnim
);
2163 // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè:
2165 MONSTATE_SLEEP
: Anim
:= ANIM_SLEEP
;
2166 MONSTATE_PAIN
: Anim
:= ANIM_PAIN
;
2167 MONSTATE_WAIT
: Anim
:= ANIM_SLEEP
;
2168 MONSTATE_CLIMB
, MONSTATE_RUN
, MONSTATE_RUNOUT
, MONSTATE_GO
: Anim
:= ANIM_GO
;
2169 MONSTATE_SHOOT
: Anim
:= ANIM_ATTACK
;
2170 MONSTATE_ATTACK
: Anim
:= ANIM_ATTACK
;
2171 MONSTATE_DIE
: Anim
:= ANIM_DIE
;
2173 begin // íà÷àëè âîñðåøàòüñÿ
2175 FAnim
[Anim
, FDirection
].Revert(True);
2177 FObj
.Rect
:= MONSTERTABLE
[FMonsterType
].Rect
;
2178 FHealth
:= MONSTERTABLE
[FMonsterType
].Health
;
2185 // Íàäî ñìåíèòü àíèìàöèþ íà íåñòàíäàðòíóþ:
2186 if ForceAnim
<> 255 then
2189 // Åñëè àíèìàöèÿ íîâàÿ - ïåðåçàïóñêàåì å¸:
2190 if FCurAnim
<> Anim
then
2191 if FAnim
[Anim
, FDirection
] <> nil then
2193 FAnim
[Anim
, FDirection
].Reset();
2198 function TMonster
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
2205 //  òî÷êå íàçíà÷åíèÿ ñòåíà:
2206 if g_CollideLevel(X
, Y
, FObj
.Rect
.Width
, FObj
.Rect
.Height
) then
2208 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
2209 if g_Game_IsServer
and g_Game_IsNet
then
2210 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
2216 // Ýôôåêò òåëåïîðòà â ïîçèöèè ìîíñòðà:
2219 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
2220 TA
:= TAnimation
.Create(FramesID
, False, 6);
2221 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj
.X
, Obj
.Y
);
2222 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2223 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2225 if g_Game_IsServer
and g_Game_IsNet
then
2226 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2227 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 1,
2231 FObj
.X
:= X
- FObj
.Rect
.X
;
2232 FObj
.Y
:= Y
- FObj
.Rect
.Y
;
2236 FDirection
:= D_LEFT
2239 FDirection
:= D_RIGHT
2243 if FDirection
= D_RIGHT
then
2244 FDirection
:= D_LEFT
2246 FDirection
:= D_RIGHT
;
2249 // Ýôôåêò òåëåïîðòà â òî÷êå íàçíà÷åíèÿ:
2250 if not silent
and (TA
<> nil) then
2252 g_GFX_OnceAnim(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2253 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, TA
);
2256 if g_Game_IsServer
and g_Game_IsNet
then
2257 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-32,
2258 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-32, 0,
2262 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_MonsterPos(FUID
);
2266 procedure TMonster
.Update();
2268 a
, b
, sx
, sy
, wx
, wy
, oldvelx
: Integer;
2278 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
2279 if FMonsterType
= MONSTER_FISH
then
2280 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
2281 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2284 // Ëåòàþùèå ìîíòñðû:
2285 if ((FMonsterType
= MONSTER_SOUL
) or
2286 (FMonsterType
= MONSTER_PAIN
) or
2287 (FMonsterType
= MONSTER_CACO
)) and
2288 (FState
<> MONSTATE_DIE
) and
2289 (FState
<> MONSTATE_DEAD
) then
2292 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
2293 if gTime
mod (GAME_TICK
*2) <> 0 then
2295 g_Obj_Move(@FObj
, fall
, True, True);
2296 positionChanged(); // this updates spatial accelerators
2300 if FPainTicks
> 0 then
2303 FPainSound
:= False;
2306 st
:= g_Obj_Move(@FObj
, fall
, True, True);
2307 positionChanged(); // this updates spatial accelerators
2309 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
2310 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
2311 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
2314 if Live
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2316 Inc(gCoopMonstersKilled
);
2317 if g_Game_IsNet
then
2324 oldvelx
:= FObj
.Vel
.X
;
2326 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
2327 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
2328 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2330 if FFireTime
> 0 then
2332 if WordBool(st
and MOVE_INWATER
) then
2337 FFireTime
:= FFireTime
- 1;
2338 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
2339 if FFirePainTime
= 0 then
2341 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
2342 FFirePainTime
:= 18;
2345 FFirePainTime
:= FFirePainTime
- 1;
2349 // Ìåðòâûé íè÷åãî íå äåëàåò:
2350 if (FState
= MONSTATE_DEAD
) then
2353 // AI ìîíñòðîâ âûêëþ÷åí:
2354 if g_debug_MonsterOff
then
2357 if FState
<> MONSTATE_SLEEP
then
2358 SetState(MONSTATE_SLEEP
);
2361 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
2362 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
2363 case FMonsterType
of
2365 if Random(4) = 0 then
2366 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2367 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2368 MONSTER_ROBO
, MONSTER_BARREL
:
2369 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
2370 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
2372 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
2373 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
2374 if Random(2) = 0 then
2375 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
2377 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
2381 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
2382 if FMonsterType
= MONSTER_BARREL
then
2384 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
2385 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
2386 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2387 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
2391 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
2392 if FMonsterType
= MONSTER_SOUL
then
2393 if WordBool(st
and MOVE_HITAIR
) then
2394 g_Obj_SetSpeed(@FObj
, 16);
2399 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
2400 if FObj
.Vel
.Y
< 0 then
2401 if WordBool(st
and MOVE_INWATER
) then
2404 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
2405 FTargetTime
:= FTargetTime
+ 1;
2408 if FShellTimer
> -1 then
2409 if FShellTimer
= 0 then
2411 if FShellType
= SHELL_SHELL
then
2412 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2413 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2414 GameVelX
, GameVelY
-2, SHELL_SHELL
)
2415 else if FShellType
= SHELL_DBLSHELL
then
2417 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2418 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2419 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
2420 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2421 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2422 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
2425 end else Dec(FShellTimer
);
2427 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
2429 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
2430 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
2431 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2432 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
2433 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2434 (FObj
.Accel
.Y
= 0) then
2435 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2438 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
2440 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
2441 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
2443 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
2444 if gSoundEffectsDF
then PainSound();
2446 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
2449 // Ñíèæàåì áîëü ñî âðåìåíåì:
2452 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
2453 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
2457 SetState(MONSTATE_GO
);
2461 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
2464 FSleep
:= FSleep
+ 1;
2466 // Ïðîñïàëè äîñòàòî÷íî:
2467 if FSleep
>= 18 then
2472 // Íà èãðîêîâ èäóò òîëüêî îáû÷íûå ìîíñòðû, êèëëåðû è ìàíüÿêè
2473 if (FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_KILLER
) or (FBehaviour
= BH_MANIAC
) then
2474 // Åñëè åñòü èãðîê ðÿäîì, ïðîñûïàåìñÿ è èäåì ê íåìó:
2475 if (gPlayers
<> nil) then
2476 for a
:= 0 to High(gPlayers
) do
2477 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
)
2478 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
2480 if g_Look(@FObj
, @Obj
, FDirection
) then
2482 FTargetUID
:= gPlayers
[a
].UID
;
2485 SetState(MONSTATE_GO
);
2489 // Íà ìîíñòðîâ òÿíåò ìàíüÿêîâ, ïîåõàâøèõ è êàííèáàëîâ
2490 if (FTargetUID
= 0) and ((FBehaviour
= BH_MANIAC
)
2491 or (FBehaviour
= BH_INSANE
) or (FBehaviour
= BH_CANNIBAL
)) then
2492 // Åñëè åñòü ïîäõîäÿùèé ìîíñòð ðÿäîì:
2493 if gMonsters
<> nil then
2494 for a
:= 0 to High(gMonsters
) do
2495 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
2496 (gMonsters
[a
].FUID
<> FUID
) then
2498 // Ìàíüÿêè íàïàäàþò íà âñåõ ìîíñòðîâ, êðîìå äðóçåé
2499 if (FBehaviour
= BH_MANIAC
) and
2500 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2502 // Ïîåõàâøèå òàêæå, íî ìîãóò îáîçëèòüñÿ íà áî÷êó
2503 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
) and
2504 (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
2506 // Êàííèáàëû íàïàäàþò íà ñåáå ïîäîáíûõ
2507 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
2509 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
2511 FTargetUID
:= gMonsters
[a
].UID
;
2514 SetState(MONSTATE_GO
);
2520 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
2523 FSleep
:= FSleep
- 1;
2525 // Âûæäàëè äîñòàòî÷íî - èäåì:
2527 SetState(MONSTATE_GO
);
2530 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
2532 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2533 if WordBool(st
and MOVE_BLOCK
) then
2537 SetState(MONSTATE_RUNOUT
);
2542 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
2543 if (FMonsterType
= MONSTER_VILE
) then
2544 if isCorpse(@FObj
, False) <> -1 then
2547 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
2552 // Öåëü ïîãèáëà èëè äàâíî æäåì:
2553 if (not GetPos(FTargetUID
, @o
)) or (FTargetTime
> MAX_ATM
) then
2554 if not findNewPrey() then
2555 begin // Íîâûõ öåëåé íåò
2563 o
.Rect
:= _Rect(0, 0, 0, 1);
2565 else // Íîâàÿ öåëü åñòü - áåðåì åå êîîðäèíàòû
2566 GetPos(FTargetUID
, @o
);
2568 // Öåëü î÷åíü áëèçêî - ïèíàåì:
2569 if g_Obj_Collide(@FObj
, @o
) and (FTargetUID
<> 0) then
2572 if (FMonsterType
<> MONSTER_CYBER
) or (Random(2) = 0) then
2579 // Ðàññòîÿíèå äî öåëè:
2580 sx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
2581 sy
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2583 // Ïîâîðà÷èâàåìñÿ â ñòîðîíó öåëè:
2585 FDirection
:= D_RIGHT
2587 FDirection
:= D_LEFT
;
2589 // Åñëè ìîíñòð óìååò ñòðåëÿòü è åñòü ïî êîìó - ñòðåëÿåì:
2590 if canShoot(FMonsterType
) and (FTargetUID
<> 0) then
2591 if Abs(sx
) > Abs(sy
) then // óãîë âûñòðåëà óäîáíûé
2592 if shoot(@o
, False) then
2595 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
2596 if Abs(sx
) < 40 then
2597 if FMonsterType
<> MONSTER_FISH
then
2600 SetState(MONSTATE_RUN
);
2601 if Random(2) = 0 then
2602 FDirection
:= D_LEFT
2604 FDirection
:= D_RIGHT
;
2609 // Óïåðëèñü â ñòåíó:
2610 if WordBool(st
and MOVE_HITWALL
) then
2612 if g_Triggers_PressR(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, FObj
.Rect
.Width
,
2613 FObj
.Rect
.Height
, FUID
, ACTIVATE_MONSTERPRESS
) <> nil then
2614 begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå
2616 SetState(MONSTATE_WAIT
);
2621 case FMonsterType
of
2622 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
2624 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
2625 (FObj
.Accel
.Y
= 0) then
2626 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
2627 // Ïðûæîê ÷åðåç ñòåíó:
2628 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2629 SetState(MONSTATE_CLIMB
);
2636 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
2637 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
2638 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
2640 if FMonsterType
= MONSTER_FISH
then
2642 if not WordBool(st
and MOVE_INWATER
) then
2643 begin // Ðûáà âíå âîäû:
2644 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2645 begin // "Ñòîèò" òâåðäî
2646 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
2647 if FObj
.Accel
.Y
= 0 then FObj
.Vel
.Y
:= -6;
2648 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
2652 SetState(MONSTATE_PAIN
);
2653 FPain
:= FPain
+ 50;
2657 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2659 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2663 // Ðûáà ïëûâåò ââåðõ:
2664 if FObj
.Vel
.Y
< 0 then
2665 if not g_Obj_CollideWater(@FObj
, 0, -16) then
2667 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
2669 // Ïëàâàåì òóäà-ñþäà:
2670 if Random(2) = 0 then
2671 FDirection
:= D_LEFT
2673 FDirection
:= D_RIGHT
;
2675 SetState(MONSTATE_RUN
);
2679 else // Ëåòàþùèå ìîíñòðû
2681 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
2683 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
2688 else // "Íàçåìíûå" ìîíñòðû
2690 // Âîçìîæíî, ïèíàåì êóñêè:
2691 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
2693 b
:= Abs(FObj
.Vel
.X
);
2694 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2695 for a
:= 0 to High(gGibs
) do
2697 if gGibs
[a
].Live
and
2698 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2699 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
2702 if FObj
.Vel
.X
< 0 then
2704 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
2708 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
2713 // Áîññû ìîãóò ïèíàòü òðóïû:
2714 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
2715 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
2717 b
:= Abs(FObj
.Vel
.X
);
2718 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
2719 for a
:= 0 to High(gCorpses
) do
2720 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
2722 co
:= gCorpses
[a
].Obj
;
2723 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
2724 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
2726 if FObj
.Vel
.X
< 0 then
2727 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
2729 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
2732 // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
2734 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
2736 if (Random(4) = 0) and (FObj
.Accel
.Y
= 0) then
2737 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
2740 FSleep
:= FSleep
+ 1;
2746 if Random(8) = 0 then
2750 // Áåæèì â âûáðàííóþ ñòîðîíó:
2751 if FDirection
= D_RIGHT
then
2752 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2754 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2756 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2757 if WordBool(st
and MOVE_INWATER
) then
2758 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2759 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2760 if FMonsterType
= MONSTER_FISH
then
2764 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
2766 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
2767 if WordBool(st
and MOVE_BLOCK
) then
2771 SetState(MONSTATE_RUNOUT
);
2776 FSleep
:= FSleep
- 1;
2778 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
2779 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
2782 SetState(MONSTATE_GO
);
2783 // Ñòåíà - èäåì îáðàòíî:
2784 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2787 if Random(8) = 0 then
2791 // Áåæèì â âûáðàííóþ ñòîðîíó:
2792 if FDirection
= D_RIGHT
then
2793 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2795 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2797 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2798 if WordBool(st
and MOVE_INWATER
) then
2799 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2800 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2801 if FMonsterType
= MONSTER_FISH
then
2805 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
2807 // Âûøëè èç ÁëîêÌîíà:
2808 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
2811 FSleep
:= FSleep
- 1;
2813 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
2814 if FSleep
<= -18 then
2817 SetState(MONSTATE_GO
);
2818 // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî:
2819 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2822 if Random(8) = 0 then
2826 // Áåæèì â âûáðàííóþ ñòîðîíó:
2827 if FDirection
= D_RIGHT
then
2828 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2830 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2832 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2833 if WordBool(st
and MOVE_INWATER
) then
2834 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2835 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2836 if FMonsterType
= MONSTER_FISH
then
2840 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
2842 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
2843 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
2844 (not WordBool(st
and MOVE_HITWALL
)) then
2847 SetState(MONSTATE_GO
);
2849 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
2850 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
2854 SetState(MONSTATE_RUN
);
2858 // Áåæèì â âûáðàííóþ ñòîðîíó:
2859 if FDirection
= D_RIGHT
then
2860 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
2862 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
2864 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
2865 if WordBool(st
and MOVE_INWATER
) then
2866 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
2867 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
2868 if FMonsterType
= MONSTER_FISH
then
2872 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
2873 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
2875 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
2876 if FMonsterType
= MONSTER_SOUL
then
2878 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
2879 SetState(MONSTATE_GO
);
2884 // Çàìåäëÿåìñÿ ïðè àòàêå:
2885 if FMonsterType
<> MONSTER_FISH
then
2886 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
2888 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
2889 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
2891 // Öåëü ïîãèáëà => èäåì äàëüøå:
2892 if not GetPos(FTargetUID
, @o
) then
2894 SetState(MONSTATE_GO
);
2899 // Öåëü íå âèäíî => èäåì äàëüøå:
2900 if not g_Look(@FObj
, @o
, FDirection
) then
2902 SetState(MONSTATE_GO
);
2907 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
2908 if g_Obj_CollideWater(@o
, 0, 0) then
2910 SetState(MONSTATE_GO
);
2916 tx
:= o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2);
2917 ty
:= o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2);
2918 g_Weapon_HitUID(FTargetUID
, 2, FUID
, HIT_SOME
);
2921 end; // case FState of ...
2925 // Ñîñòîÿíèå - Âîñêðåøåíèå:
2926 if FState
= MONSTATE_REVIVE
then
2927 if FAnim
[FCurAnim
, FDirection
].Played
then
2928 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
2929 FAnim
[FCurAnim
, FDirection
].Revert(False);
2930 SetState(MONSTATE_GO
);
2933 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
2934 if vilefire
<> nil then
2937 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
2938 if (FState
= MONSTATE_DIE
) and
2939 (FAnim
[FCurAnim
, FDirection
] <> nil) and
2940 (FAnim
[FCurAnim
, FDirection
].Played
) then
2943 SetState(MONSTATE_DEAD
);
2945 // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à:
2946 if (FMonsterType
= MONSTER_PAIN
) then
2948 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-30,
2949 FObj
.Y
+FObj
.Rect
.Y
+20, D_LEFT
);
2952 mon
.SetState(MONSTATE_GO
);
2953 mon
.FNoRespawn
:= True;
2954 Inc(gTotalMonsters
);
2955 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
2958 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2959 FObj
.Y
+FObj
.Rect
.Y
+20, D_RIGHT
);
2962 mon
.SetState(MONSTATE_GO
);
2963 mon
.FNoRespawn
:= True;
2964 Inc(gTotalMonsters
);
2965 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
2968 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-15,
2969 FObj
.Y
+FObj
.Rect
.Y
, D_RIGHT
);
2972 mon
.SetState(MONSTATE_GO
);
2973 mon
.FNoRespawn
:= True;
2974 Inc(gTotalMonsters
);
2975 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
2978 if g_Game_IsNet
then MH_SEND_CoopStats();
2981 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
2982 if (FMonsterType
= MONSTER_PAIN
) or
2983 (FMonsterType
= MONSTER_SOUL
) or
2984 (FMonsterType
= MONSTER_BARREL
) then
2988 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
2989 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
2990 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
2991 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
2992 if (FAnim
[FCurAnim
, FDirection
].Played
) then
2993 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
2994 if FState
= MONSTATE_ATTACK
then
2995 begin // Ñîñòîÿíèå - Àòàêà
2996 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
2997 if FMonsterType
<> MONSTER_SOUL
then
2998 SetState(MONSTATE_GO
);
3000 else // Ñîñòîÿíèå - Ñòðåëüáà
3002 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3003 if not FChainFire
then
3004 SetState(MONSTATE_GO
)
3006 begin // Íàäî ñòðåëÿòü åùå
3007 FChainFire
:= False;
3008 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3009 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3010 FAnim
[FCurAnim
, FDirection
].Reset();
3014 FWaitAttackAnim
:= False;
3017 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3018 if (FMonsterType
= MONSTER_SOUL
) or
3019 ( (not FWaitAttackAnim
) and
3020 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3021 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3023 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3024 if FState
= MONSTATE_ATTACK
then
3025 begin // Ñîñòîÿíèå - Àòàêà
3026 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3027 if FMonsterType
= MONSTER_SOUL
then
3028 FAnim
[FCurAnim
, FDirection
].Reset();
3030 case FMonsterType
of
3031 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3032 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3033 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3034 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3035 if FMonsterType
= MONSTER_SOUL
then
3036 SetState(MONSTATE_GO
);
3039 // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì:
3040 if g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
) <> 0 then
3041 g_Sound_PlayExAt('SOUND_MONSTER_FISH_ATTACK', FObj
.X
, FObj
.Y
);
3043 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3044 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3045 if FCurAnim
= ANIM_ATTACK2
then
3048 o
.Vel
.X
:= IfThen(FDirection
= D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3049 if g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
) <> 0 then
3050 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_HIT', FObj
.X
, FObj
.Y
);
3054 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3055 if FCurAnim
= ANIM_ATTACK2
then
3057 sx
:= isCorpse(@FObj
, True);
3059 begin // Íàøëè, êîãî âîñêðåñèòü
3060 gMonsters
[sx
].SetState(MONSTATE_REVIVE
);
3061 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3062 // Âîñêðåøàòü - ñåáå âðåäèòü:
3063 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3069 else // Ñîñòîÿíèå - Ñòðåëüáà
3071 // Âû÷èñëÿåì êîîðäèíàòû, îòêóäà âûëåòèò ïóëÿ:
3072 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
;
3074 if FDirection
= D_LEFT
then
3076 wx
:= MONSTER_ANIMTABLE
[FMonsterType
].wX
-(MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2));
3077 wx
:= MONSTERTABLE
[FMonsterType
].Rect
.X
+(MONSTERTABLE
[FMonsterType
].Rect
.Width
div 2)-wx
;
3078 end; // Ýòî çíà÷èò: wx := hitX + (hitWidth / 2) - (wx - (hitX + (hitWidth / 2)))
3081 wy
:= FObj
.Y
+ MONSTER_ANIMTABLE
[FMonsterType
].wY
;
3083 // Äåëàåì âûñòðåë íóæíûì îðóæèåì:
3084 case FMonsterType
of
3086 g_Weapon_ball1(wx
, wy
, tx
, ty
, FUID
);
3089 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3090 g_Weapon_gun(wx
, wy
, tx
, ty
, 1, 3, FUID
, False);
3091 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3095 g_Weapon_shotgun(wx
, wy
, tx
, ty
, FUID
);
3096 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3098 FShellType
:= SHELL_SHELL
;
3102 g_Weapon_dshotgun(wx
, wy
, tx
, ty
, FUID
);
3104 FShellType
:= SHELL_DBLSHELL
;
3109 g_Weapon_rocket(wx
, wy
, tx
, ty
, FUID
);
3110 // MH_SEND_MonsterAttack(FUID, wx, wy, tx, ty);
3113 g_Weapon_revf(wx
, wy
, tx
, ty
, FUID
, FTargetUID
);
3116 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3117 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3118 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3122 g_Weapon_mgun(wx
, wy
, tx
, ty
, FUID
);
3123 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3124 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
3127 g_Weapon_aplasma(wx
, wy
, tx
, ty
, FUID
);
3129 g_Weapon_plasma(wx
, wy
, tx
, ty
, FUID
);
3131 g_Weapon_manfire(wx
, wy
, tx
, ty
, FUID
);
3132 MONSTER_BARON
, MONSTER_KNIGHT
:
3133 g_Weapon_ball7(wx
, wy
, tx
, ty
, FUID
);
3135 g_Weapon_ball2(wx
, wy
, tx
, ty
, FUID
);
3137 begin // Ñîçäàåì Lost_Soul:
3138 mon
:= g_Monsters_Create(MONSTER_SOUL
, FObj
.X
+(FObj
.Rect
.Width
div 2),
3139 FObj
.Y
+FObj
.Rect
.Y
, FDirection
);
3142 begin // Öåëü - öåëü Pain_Elemental'à. Ëåòèì ê íåé:
3143 mon
.FTargetUID
:= FTargetUID
;
3144 GetPos(FTargetUID
, @o
);
3145 mon
.FTargetTime
:= 0;
3146 mon
.FNoRespawn
:= True;
3147 mon
.SetState(MONSTATE_GO
);
3148 mon
.shoot(@o
, True);
3149 Inc(gTotalMonsters
);
3151 if g_Game_IsNet
then MH_SEND_MonsterSpawn(mon
.UID
);
3156 if FMonsterType
<> MONSTER_PAIN
then
3157 if g_Game_IsNet
then
3158 MH_SEND_MonsterShot(FUID
, wx
, wy
, tx
, ty
);
3160 // Ñêîðîñòðåëüíûå ìîíñòðû:
3161 if (FMonsterType
= MONSTER_CGUN
) or
3162 (FMonsterType
= MONSTER_SPIDER
) or
3163 (FMonsterType
= MONSTER_BSP
) or
3164 (FMonsterType
= MONSTER_MANCUB
) or
3165 (FMonsterType
= MONSTER_ROBO
) then
3166 if not GetPos(FTargetUID
, @o
) then
3167 // Öåëü ìåðòâà - èùåì íîâóþ:
3169 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3170 if shoot(@o
, False) then
3174 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3175 FWaitAttackAnim
:= True;
3178 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3179 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3181 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3182 // Çâóêè ïðè ïåðåäâèæåíèè:
3183 case FMonsterType
of
3185 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3186 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3187 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3189 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3190 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3191 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3193 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3194 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3195 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3197 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3198 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3199 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3203 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3204 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3205 FObj
.Vel
.X
:= oldvelx
;
3207 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3208 if FAnim
[FCurAnim
, FDirection
] <> nil then
3209 FAnim
[FCurAnim
, FDirection
].Update();
3212 procedure TMonster
.SetDeadAnim
;
3214 if FAnim
<> nil then
3215 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3218 procedure TMonster
.RevertAnim(R
: Boolean = True);
3220 if FAnim
<> nil then
3221 if FAnim
[FCurAnim
, FDirection
].IsReverse
<> R
then
3222 FAnim
[FCurAnim
, FDirection
].Revert(R
);
3225 function TMonster
.AnimIsReverse
: Boolean;
3227 if FAnim
<> nil then
3228 Result
:= FAnim
[FCurAnim
, FDirection
].IsReverse
3233 procedure TMonster
.ClientUpdate();
3235 a
, b
, sx
, sy
, oldvelx
: Integer;
3242 sx
:= 0; // SHUT UP COMPILER
3245 // Ðûáû "ëåòàþò" òîëüêî â âîäå:
3246 if FMonsterType
= MONSTER_FISH
then
3247 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3248 if (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) then
3251 // Ëåòàþùèå ìîíòñðû:
3252 if ((FMonsterType
= MONSTER_SOUL
) or
3253 (FMonsterType
= MONSTER_PAIN
) or
3254 (FMonsterType
= MONSTER_CACO
)) and
3255 (FState
<> MONSTATE_DIE
) and
3256 (FState
<> MONSTATE_DEAD
) then
3259 // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì:
3260 if gTime
mod (GAME_TICK
*2) <> 0 then
3262 g_Obj_Move(@FObj
, fall
, True, True);
3263 positionChanged(); // this updates spatial accelerators
3267 if FPainTicks
> 0 then
3270 FPainSound
:= False;
3273 st
:= g_Obj_Move(@FObj
, fall
, True, True);
3274 positionChanged(); // this updates spatial accelerators
3276 // Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
3277 if WordBool(st
and MOVE_FALLOUT
) or (FObj
.X
< -1000) or
3278 (FObj
.X
> gMapInfo
.Width
+1000) or (FObj
.Y
< -1000) then
3284 oldvelx
:= FObj
.Vel
.X
;
3286 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
3287 if (FState
= MONSTATE_DIE
) or (FState
= MONSTATE_DEAD
) then
3288 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3290 if FFireTime
> 0 then
3292 if WordBool(st
and MOVE_INWATER
) then
3297 FFireTime
:= FFireTime
- 1;
3301 // Ìåðòâûé íè÷åãî íå äåëàåò:
3302 if (FState
= MONSTATE_DEAD
) then
3305 // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå:
3306 if WordBool(st
and MOVE_INWATER
) and (Random(32) = 0) then
3307 case FMonsterType
of
3309 if Random(4) = 0 then
3310 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3311 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3312 MONSTER_ROBO
, MONSTER_BARREL
:
3313 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
),
3314 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 1, 0, 0);
3316 g_GFX_Bubbles(FObj
.X
+FObj
.Rect
.X
+ Random(FObj
.Rect
.Width
-4),
3317 FObj
.Y
+FObj
.Rect
.Y
+ Random(4), 5, 4, 4);
3318 if Random(2) = 0 then
3319 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
3321 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
3325 // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ:
3326 if FMonsterType
= MONSTER_BARREL
then
3328 if (FState
= MONSTATE_DIE
) and (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 1) and
3329 (FAnim
[FCurAnim
, FDirection
].Counter
= 0) then
3330 g_Weapon_Explode(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3331 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-16,
3335 // Lost_Soul âûëåòåë èç âîäû => óñêîðÿåòñÿ:
3336 if FMonsterType
= MONSTER_SOUL
then
3337 if WordBool(st
and MOVE_HITAIR
) then
3338 g_Obj_SetSpeed(@FObj
, 16);
3343 // Åñëè íà÷àëè âñïëûâàòü, òî ïðîäîëæàåì:
3344 if FObj
.Vel
.Y
< 0 then
3345 if WordBool(st
and MOVE_INWATER
) then
3348 // Òàéìåð - æäåì ïîñëå ïîòåðè öåëè:
3349 FTargetTime
:= FTargetTime
+ 1;
3351 if FShellTimer
> -1 then
3352 if FShellTimer
= 0 then
3354 if FShellType
= SHELL_SHELL
then
3355 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3356 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3357 GameVelX
, GameVelY
-2, SHELL_SHELL
)
3358 else if FShellType
= SHELL_DBLSHELL
then
3360 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3361 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3362 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
3363 g_Player_CreateShell(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
3364 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
3365 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
3368 end else Dec(FShellTimer
);
3370 // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè:
3372 if (FState
in [MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_RUNOUT
,
3373 MONSTATE_ATTACK
, MONSTATE_SHOOT
]) then
3374 if g_Weapon_Danger(FUID
, FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3375 FObj
.Rect
.Width
, FObj
.Rect
.Height
, 50) then
3376 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3377 (FObj
.Accel
.Y
= 0) then
3378 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3381 MONSTATE_PAIN
: // Ñîñòîÿíèå - Áîëü
3383 // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò:
3384 if FPain
>= MONSTERTABLE
[FMonsterType
].Pain
then
3386 FPain
:= MONSTERTABLE
[FMonsterType
].Pain
;
3387 if gSoundEffectsDF
then PainSound();
3389 if (not gSoundEffectsDF
) and (FPain
>= MONSTERTABLE
[FMonsterType
].MinPain
) then
3392 // Ñíèæàåì áîëü ñî âðåìåíåì:
3395 // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå:
3396 if FPain
<= MONSTERTABLE
[FMonsterType
].MinPain
then
3398 SetState(MONSTATE_GO
);
3403 MONSTATE_SLEEP
: // Ñîñòîÿíèå - Ñîí
3406 FSleep
:= FSleep
+ 1;
3408 // Ïðîñïàëè äîñòàòî÷íî:
3409 if FSleep
>= 18 then
3415 MONSTATE_WAIT
: // Ñîñòîÿíèå - Îæèäàíèå
3418 FSleep
:= FSleep
- 1;
3421 MONSTATE_GO
: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè)
3423 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3424 if WordBool(st
and MOVE_BLOCK
) then
3428 SetState(MONSTATE_RUNOUT
);
3433 // Åñëè ìîíñòð - êîëäóí, òî ïðîáóåì âîñêðåñèòü êîãî-íèáóäü:
3434 if (FMonsterType
= MONSTER_VILE
) then
3435 if isCorpse(@FObj
, False) <> -1 then
3437 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
3443 // Åñëè öåëü ïî÷òè íà îäíîé âåðòèêàëè - áåãàåì òóäà-ñþäà:
3444 if Abs(sx
) < 40 then
3445 if FMonsterType
<> MONSTER_FISH
then
3447 SetState(MONSTATE_RUN
);
3453 // Óïåðëèñü â ñòåíó:
3454 if WordBool(st
and MOVE_HITWALL
) then
3456 case FMonsterType
of
3457 MONSTER_CACO
, MONSTER_SOUL
, MONSTER_PAIN
, MONSTER_FISH
: ;
3459 if (g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
)) and
3460 (FObj
.Accel
.Y
= 0) then
3461 begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè
3462 // Ïðûæîê ÷åðåç ñòåíó:
3463 FObj
.Vel
.Y
:= -MONSTERTABLE
[FMonsterType
].Jump
;
3464 SetState(MONSTATE_CLIMB
);
3471 // Ìîíñòðû, íå ïîäâåðæåííûå ãðàâèòàöèè:
3472 if (FMonsterType
= MONSTER_CACO
) or (FMonsterType
= MONSTER_SOUL
) or
3473 (FMonsterType
= MONSTER_PAIN
) or (FMonsterType
= MONSTER_FISH
) then
3475 if FMonsterType
= MONSTER_FISH
then
3477 if not WordBool(st
and MOVE_INWATER
) then
3478 begin // Ðûáà âíå âîäû:
3479 if g_Obj_CollideLevel(@FObj
, 0, 1) or g_Obj_StayOnStep(@FObj
) then
3480 begin // "Ñòîèò" òâåðäî
3481 // Ðûáà òðåïûõàåòñÿ íà ïîâåðõíîñòè:
3482 if FObj
.Accel
.Y
= 0 then
3484 FObj
.Accel
.X
:= FObj
.Accel
.X
- 8 + Random(17);
3488 SetState(MONSTATE_PAIN
);
3489 FPain
:= FPain
+ 50;
3493 // Ïëûâåì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3495 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3499 // Ðûáà ïëûâåò ââåðõ:
3500 if FObj
.Vel
.Y
< 0 then
3501 if not g_Obj_CollideWater(@FObj
, 0, -16) then
3503 // Âñïëûëè äî ïîâåðõíîñòè - ñòîï:
3505 // Ïëàâàåì òóäà-ñþäà:
3506 SetState(MONSTATE_RUN
);
3511 else // Ëåòàþùèå ìîíñòðû
3513 // Ëåòèì â ñòîðîíó öåëè ïî-âåðòèêàëè:
3515 FObj
.Vel
.Y
:= g_basic
.Sign(sy
)*4
3520 else // "Íàçåìíûå" ìîíñòðû
3522 // Âîçìîæíî, ïèíàåì êóñêè:
3523 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
3525 b
:= Abs(FObj
.Vel
.X
);
3526 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3527 for a
:= 0 to High(gGibs
) do
3529 if gGibs
[a
].Live
and
3530 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3531 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
3534 if FObj
.Vel
.X
< 0 then
3536 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120); // íàëåâî
3540 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
3542 positionChanged(); // this updates spatial accelerators
3546 // Áîññû ìîãóò ïèíàòü òðóïû:
3547 if (FMonsterType
in [MONSTER_CYBER
, MONSTER_SPIDER
, MONSTER_ROBO
]) and
3548 (FObj
.Vel
.X
<> 0) and (gCorpses
<> nil) then
3550 b
:= Abs(FObj
.Vel
.X
);
3551 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
3552 for a
:= 0 to High(gCorpses
) do
3553 if (gCorpses
[a
] <> nil) and (gCorpses
[a
].State
> 0) then
3555 co
:= gCorpses
[a
].Obj
;
3556 if g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
3557 FObj
.Rect
.Width
, 8, @co
) and (Random(3) = 0) then
3559 if FObj
.Vel
.X
< 0 then
3560 gCorpses
[a
].Damage(b
*2, -b
, Random(7)) // íàëåâî
3562 gCorpses
[a
].Damage(b
*2, b
, Random(7)); // íàïðàâî
3567 FSleep
:= FSleep
+ 1;
3573 if Random(8) = 0 then
3577 // Áåæèì â âûáðàííóþ ñòîðîíó:
3578 if FDirection
= D_RIGHT
then
3579 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3581 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3583 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3584 if WordBool(st
and MOVE_INWATER
) then
3585 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3586 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3587 if FMonsterType
= MONSTER_FISH
then
3591 MONSTATE_RUN
: // Ñîñòîÿíèå - Áåã
3593 // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî:
3594 if WordBool(st
and MOVE_BLOCK
) then
3596 SetState(MONSTATE_RUNOUT
);
3602 FSleep
:= FSleep
- 1;
3604 // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã:
3605 if (FSleep
<= 0) or (WordBool(st
and MOVE_HITWALL
) and ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) = 0)) then
3607 SetState(MONSTATE_GO
);
3611 if Random(8) = 0 then
3615 // Áåæèì â âûáðàííóþ ñòîðîíó:
3616 if FDirection
= D_RIGHT
then
3617 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3619 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3621 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3622 if WordBool(st
and MOVE_INWATER
) then
3623 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3624 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3625 if FMonsterType
= MONSTER_FISH
then
3629 MONSTATE_RUNOUT
: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî
3631 // Âûøëè èç ÁëîêÌîíà:
3632 if (not WordBool(st
and MOVE_BLOCK
)) and (FSleep
> 0) then
3635 FSleep
:= FSleep
- 1;
3637 // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã:
3638 if FSleep
<= -18 then
3640 SetState(MONSTATE_GO
);
3644 if Random(8) = 0 then
3648 // Áåæèì â âûáðàííóþ ñòîðîíó:
3649 if FDirection
= D_RIGHT
then
3650 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3652 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3654 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3655 if WordBool(st
and MOVE_INWATER
) then
3656 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3657 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3658 if FMonsterType
= MONSTER_FISH
then
3662 MONSTATE_CLIMB
: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó)
3664 // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã:
3665 if ((FObj
.Vel
.Y
+FObj
.Accel
.Y
) >= 0) or
3666 (not WordBool(st
and MOVE_HITWALL
)) then
3668 SetState(MONSTATE_GO
);
3671 // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå:
3672 if WordBool(st
and (MOVE_HITWALL
or MOVE_BLOCK
)) then
3674 SetState(MONSTATE_RUN
);
3679 // Áåæèì â âûáðàííóþ ñòîðîíó:
3680 if FDirection
= D_RIGHT
then
3681 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3683 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3685 // Åñëè â âîäå, òî çàìåäëÿåìñÿ:
3686 if WordBool(st
and MOVE_INWATER
) then
3687 FObj
.Vel
.X
:= FObj
.Vel
.X
div 2
3688 else // Ðûáàì íå íóæíî çàìåäëÿòüñÿ
3689 if FMonsterType
= MONSTER_FISH
then
3693 MONSTATE_ATTACK
, // Ñîñòîÿíèå - Àòàêà
3694 MONSTATE_SHOOT
: // Ñîñòîÿíèå - Ñòðåëüáà
3696 // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã:
3697 if FMonsterType
= MONSTER_SOUL
then
3699 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITCEIL
or MOVE_HITLAND
)) then
3700 SetState(MONSTATE_GO
);
3705 // Çàìåäëÿåìñÿ ïðè àòàêå:
3706 if FMonsterType
<> MONSTER_FISH
then
3707 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
3709 // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí:
3710 if (FMonsterType
= MONSTER_VILE
) and (FState
= MONSTATE_SHOOT
) then
3712 // Öåëü ïîãèáëà => èäåì äàëüøå:
3713 if not GetPos(FTargetUID
, @o
) then
3715 SetState(MONSTATE_GO
);
3720 // Öåëü íå âèäíî => èäåì äàëüøå:
3721 if not g_Look(@FObj
, @o
, FDirection
) then
3723 SetState(MONSTATE_GO
);
3728 // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå:
3729 if g_Obj_CollideWater(@o
, 0, 0) then
3731 SetState(MONSTATE_GO
);
3737 end; // case FState of ...
3741 // Ñîñòîÿíèå - Âîñêðåøåíèå:
3742 if FState
= MONSTATE_REVIVE
then
3743 if FAnim
[FCurAnim
, FDirection
].Played
then
3744 begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå:
3745 FAnim
[FCurAnim
, FDirection
].Revert(False);
3746 SetState(MONSTATE_GO
);
3749 // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò:
3750 if vilefire
<> nil then
3753 // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà:
3754 if (FState
= MONSTATE_DIE
) and
3755 (FAnim
[FCurAnim
, FDirection
] <> nil) and
3756 (FAnim
[FCurAnim
, FDirection
].Played
) then
3759 SetState(MONSTATE_DEAD
);
3761 // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ:
3762 if (FMonsterType
= MONSTER_PAIN
) or
3763 (FMonsterType
= MONSTER_SOUL
) or
3764 (FMonsterType
= MONSTER_BARREL
) then
3767 FAnim
[FCurAnim
, FDirection
].CurrentFrame
:= FAnim
[FCurAnim
, FDirection
].TotalFrames
- 1;
3770 // Ñîâåðøåíèå àòàêè è ñòðåëüáû:
3771 if (FState
= MONSTATE_ATTACK
) or (FState
= MONSTATE_SHOOT
) then
3772 if (FAnim
[FCurAnim
, FDirection
] <> nil) then
3773 // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü
3774 if (FAnim
[FCurAnim
, FDirection
].Played
) then
3775 begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã
3776 if FState
= MONSTATE_ATTACK
then
3777 begin // Ñîñòîÿíèå - Àòàêà
3778 // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã:
3779 if FMonsterType
<> MONSTER_SOUL
then
3780 SetState(MONSTATE_GO
);
3782 else // Ñîñòîÿíèå - Ñòðåëüáà
3784 // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç:
3785 if not FChainFire
then
3786 SetState(MONSTATE_GO
)
3788 begin // Íàäî ñòðåëÿòü åùå
3789 FChainFire
:= False;
3790 // Ò.ê. ñîñòîÿíèå íå èçìåíèëîñü, è íóæåí
3791 // íîâûé öèêë îæèäàíèÿ çàâåðøåíèÿ àíèìàöèè:
3792 FAnim
[FCurAnim
, FDirection
].Reset();
3796 FWaitAttackAnim
:= False;
3799 else // Àíèìàöèÿ àòàêè åùå èäåò (èñêëþ÷åíèå - Lost_Soul):
3800 if (FMonsterType
= MONSTER_SOUL
) or
3801 ( (not FWaitAttackAnim
) and
3802 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
=
3803 (FAnim
[FCurAnim
, FDirection
].TotalFrames
div 2))
3805 begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè
3806 if FState
= MONSTATE_ATTACK
then
3807 begin // Ñîñòîÿíèå - Àòàêà
3808 // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè:
3809 if FMonsterType
= MONSTER_SOUL
then
3810 FAnim
[FCurAnim
, FDirection
].Reset();
3812 case FMonsterType
of
3813 MONSTER_SOUL
, MONSTER_IMP
, MONSTER_DEMON
:
3814 // Ãðûçåì ïåðâîãî ïîïàâøåãîñÿ:
3815 if g_Weapon_Hit(@FObj
, 15, FUID
, HIT_SOME
) <> 0 then
3816 // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã:
3817 if FMonsterType
= MONSTER_SOUL
then
3818 SetState(MONSTATE_GO
);
3821 g_Weapon_Hit(@FObj
, 10, FUID
, HIT_SOME
);
3823 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
3824 // Ðîáîò, êèáåð èëè ñêåëåò ñèëüíî ïèíàþòñÿ:
3825 if FCurAnim
= ANIM_ATTACK2
then
3828 o
.Vel
.X
:= IfThen(FDirection
= D_RIGHT
, 1, -1)*IfThen(FMonsterType
= MONSTER_CYBER
, 60, 50);
3829 g_Weapon_Hit(@o
, IfThen(FMonsterType
= MONSTER_CYBER
, 33, 50), FUID
, HIT_SOME
);
3833 // Êîëäóí ïûòàåòñÿ âîñêðåøàòü:
3834 if FCurAnim
= ANIM_ATTACK2
then
3836 sx
:= isCorpse(@FObj
, True);
3838 begin // Íàøëè, êîãî âîñêðåñèòü
3839 g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj
.X
, FObj
.Y
);
3840 // Âîñêðåøàòü - ñåáå âðåäèòü:
3841 {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);}
3847 else // Ñîñòîÿíèå - Ñòðåëüáà
3849 // Ñêîðîñòðåëüíûå ìîíñòðû:
3850 if (FMonsterType
= MONSTER_CGUN
) or
3851 (FMonsterType
= MONSTER_SPIDER
) or
3852 (FMonsterType
= MONSTER_BSP
) or
3853 (FMonsterType
= MONSTER_MANCUB
) or
3854 (FMonsterType
= MONSTER_ROBO
) then
3855 if not GetPos(FTargetUID
, @o
) then
3856 // Öåëü ìåðòâà - èùåì íîâóþ:
3858 else // Öåëü æèâà - ïðîäîëæàåì ñòðåëÿòü:
3859 if shoot(@o
, False) then
3863 // Àòàêà òîëüêî 1 ðàç çà àíèìàöèþ àòàêè:
3864 FWaitAttackAnim
:= True;
3867 // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè:
3868 if FAnim
[FCurAnim
, FDirection
].Counter
= FAnim
[FCurAnim
, FDirection
].Speed
-1 then
3870 MONSTATE_GO
, MONSTATE_RUN
, MONSTATE_CLIMB
, MONSTATE_RUNOUT
:
3871 // Çâóêè ïðè ïåðåäâèæåíèè:
3872 case FMonsterType
of
3874 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3875 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3876 g_Sound_PlayExAt('SOUND_MONSTER_CYBER_WALK', FObj
.X
, FObj
.Y
);
3878 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3879 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3880 g_Sound_PlayExAt('SOUND_MONSTER_SPIDER_WALK', FObj
.X
, FObj
.Y
);
3882 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3883 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 2) then
3884 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3886 if (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 0) or
3887 (FAnim
[FCurAnim
, FDirection
].CurrentFrame
= 5) then
3888 g_Sound_PlayExAt('SOUND_MONSTER_BSP_WALK', FObj
.X
, FObj
.Y
);
3892 // Êîñòûëü äëÿ ïîòîêîâ
3893 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
) and
3894 not ((FState
= MONSTATE_DEAD
) or (FState
= MONSTATE_DIE
)) then
3895 FObj
.Vel
.X
:= oldvelx
;
3897 // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò:
3898 if FAnim
[FCurAnim
, FDirection
] <> nil then
3899 FAnim
[FCurAnim
, FDirection
].Update();
3902 procedure TMonster
.ClientAttack(wx
, wy
, atx
, aty
: Integer);
3904 case FMonsterType
of
3907 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3908 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3912 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3914 FShellType
:= SHELL_SHELL
;
3918 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', wx
, wy
);
3920 FShellType
:= SHELL_DBLSHELL
;
3922 MONSTER_CGUN
, MONSTER_SPIDER
:
3924 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3925 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
3928 g_Weapon_ball1(wx
, wy
, atx
, aty
, FUID
);
3930 g_Weapon_rocket(wx
, wy
, atx
, aty
, FUID
);
3932 g_Weapon_revf(wx
, wy
, atx
, aty
, FUID
, FTargetUID
);
3934 g_Weapon_aplasma(wx
, wy
, atx
, aty
, FUID
);
3936 g_Weapon_plasma(wx
, wy
, atx
, aty
, FUID
);
3938 g_Weapon_manfire(wx
, wy
, atx
, aty
, FUID
);
3939 MONSTER_BARON
, MONSTER_KNIGHT
:
3940 g_Weapon_ball7(wx
, wy
, atx
, aty
, FUID
);
3942 g_Weapon_ball2(wx
, wy
, atx
, aty
, FUID
);
3946 procedure TMonster
.Turn();
3949 if FDirection
= D_LEFT
then
3950 FDirection
:= D_RIGHT
3952 FDirection
:= D_LEFT
;
3954 // Áåæèì â âûáðàííóþ ñòîðîíó:
3955 if FDirection
= D_RIGHT
then
3956 FObj
.Vel
.X
:= MONSTERTABLE
[FMonsterType
].RunVel
3958 FObj
.Vel
.X
:= -MONSTERTABLE
[FMonsterType
].RunVel
;
3961 function TMonster
.findNewPrey(): Boolean;
3965 PlayersSee
, MonstersSee
: Array of DWORD
;
3966 PlayerNear
, MonsterNear
: Integer;
3969 SetLength(MonstersSee
, 0);
3970 SetLength(PlayersSee
, 0);
3977 // Ïîåõàâøèå, êàííèáàëû, è äîáðûå èãðîêîâ íå òðîãàþò
3978 if (gPlayers
<> nil) and (FBehaviour
<> BH_INSANE
) and
3979 (FBehaviour
<> BH_CANNIBAL
) and (FBehaviour
<> BH_GOOD
) then
3980 for a
:= 0 to High(gPlayers
) do
3981 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
)
3982 and (not gPlayers
[a
].NoTarget
) and (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
3984 if g_Look(@FObj
, @gPlayers
[a
].Obj
, FDirection
) then
3986 SetLength(PlayersSee
, Length(PlayersSee
) + 1);
3987 PlayersSee
[High(PlayersSee
)] := a
;
3989 l2
:= Abs(gPlayers
[a
].GameX
-FObj
.X
)+
3990 Abs(gPlayers
[a
].GameY
-FObj
.Y
);
3994 PlayerNear
:= Integer(a
);
3998 // Êèëëåðû è äîáðûå íå òðîãàþò ìîíñòðîâ
3999 if (gMonsters
<> nil) and (FBehaviour
<> BH_KILLER
) and (FBehaviour
<> BH_GOOD
) then
4000 for a
:= 0 to High(gMonsters
) do
4001 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
4002 (gMonsters
[a
].FUID
<> FUID
) then
4004 if (FBehaviour
= BH_CANNIBAL
) and (gMonsters
[a
].FMonsterType
<> FMonsterType
) then
4005 Continue
; // Êàííèáàëû àòàêóþò òîëüêî ñîðîäè÷åé
4006 if (FBehaviour
= BH_INSANE
) and (gMonsters
[a
].FMonsterType
<> MONSTER_BARREL
)
4007 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4008 Continue
; // Ïîåõàâøèå íå òðîãàþò äðóçåé, íî èì íå íðàâÿòñÿ áî÷êè
4009 if ((FBehaviour
= BH_NORMAL
) or (FBehaviour
= BH_MANIAC
))
4010 and (IsFriend(gMonsters
[a
].FMonsterType
, FMonsterType
)) then
4011 Continue
; // Îñòàâøèåñÿ òèïû, êðîìå êàííèáàëîâ, íå òðîãàþò ñâîèõ äðóçåé
4013 if g_Look(@FObj
, @gMonsters
[a
].Obj
, FDirection
) then
4015 SetLength(MonstersSee
, Length(MonstersSee
) + 1);
4016 MonstersSee
[High(MonstersSee
)] := a
;
4018 l2
:= Abs(gMonsters
[a
].FObj
.X
-FObj
.X
)+
4019 Abs(gMonsters
[a
].FObj
.Y
-FObj
.Y
);
4023 MonsterNear
:= Integer(a
);
4028 BH_NORMAL
, BH_KILLER
:
4030 // Îáû÷íûé è êèëëåð ñíà÷àëà èùóò èãðîêîâ â ïîëå çðåíèÿ
4031 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4033 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4034 FTargetUID
:= gPlayers
[a
].UID
;
4037 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4040 FTargetUID
:= gPlayers
[a
].UID
;
4042 // Ïîòîì îáû÷íûå èùóò ìîíñòðîâ â ïîëå çðåíèÿ
4043 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4045 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4046 FTargetUID
:= gMonsters
[a
].UID
;
4049 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4052 FTargetUID
:= gMonsters
[a
].UID
;
4055 BH_MANIAC
, BH_INSANE
, BH_CANNIBAL
:
4057 // Ìàíüÿêè, ïîåõàâøèå è êàííèáàëû ñíà÷àëà èñòðåáëÿþò âñ¸ â ïîëå çðåíèÿ
4058 if (FTargetUID
= 0) and (Length(PlayersSee
) > 0) then
4060 a
:= PlayersSee
[Random(Length(PlayersSee
))];
4061 FTargetUID
:= gPlayers
[a
].UID
;
4063 if (FTargetUID
= 0) and (Length(MonstersSee
) > 0) then
4065 a
:= MonstersSee
[Random(Length(MonstersSee
))];
4066 FTargetUID
:= gMonsters
[a
].UID
;
4068 // Çàòåì èùóò êîãî-òî ïîáëèçîñòè
4069 if (FTargetUID
= 0) and (PlayerNear
> -1) then
4072 FTargetUID
:= gPlayers
[a
].UID
;
4074 if (FTargetUID
= 0) and (MonsterNear
> -1) then
4077 FTargetUID
:= gMonsters
[a
].UID
;
4082 // Åñëè è ìîíñòðîâ íåò - íà÷èíàåì æäàòü öåëü:
4083 if FTargetUID
= 0 then
4085 // Ïîåõàâøèé ïûòàåòñÿ ñàìîóáèòüñÿ
4086 if FBehaviour
= BH_INSANE
then
4089 FTargetTime
:= MAX_ATM
;
4098 function TMonster
.kick(o
: PObj
): Boolean;
4102 case FMonsterType
of
4105 SetState(MONSTATE_ATTACK
);
4110 SetState(MONSTATE_ATTACK
);
4111 g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj
.X
, FObj
.Y
);
4116 SetState(MONSTATE_ATTACK
);
4117 g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj
.X
, FObj
.Y
);
4120 MONSTER_SKEL
, MONSTER_ROBO
, MONSTER_CYBER
:
4122 SetState(MONSTATE_ATTACK
, ANIM_ATTACK2
);
4123 g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj
.X
, FObj
.Y
);
4126 MONSTER_BARON
, MONSTER_KNIGHT
,
4127 MONSTER_CACO
, MONSTER_MANCUB
:
4128 // Ýòè ìîíñòðû íå ïèíàþò - îíè ñòðåëÿþò â óïîð:
4129 if not g_Game_IsClient
then Result
:= shoot(o
, True);
4133 function TMonster
.shoot(o
: PObj
; immediately
: Boolean): Boolean;
4143 // Æäàòü âðåìåíè ãîòîâíîñòè ê âûñòðåëó:
4144 if not immediately
then
4145 case FMonsterType
of
4146 MONSTER_FISH
, MONSTER_BARREL
, MONSTER_DEMON
:
4147 Exit
; // íå ñòðåëÿþò
4148 MONSTER_CGUN
, MONSTER_BSP
, MONSTER_ROBO
:
4151 // Âðåìÿ âûñòðåëà óïóùåíî:
4153 FAmmo
:= IfThen(FMonsterType
= MONSTER_ROBO
, -200, -50);
4159 // Âðåìÿ âûñòðåëà óïóùåíî:
4166 // Âðåìÿ âûñòðåëà óïóùåíî:
4167 if FAmmo
>= 100 then
4172 // Ñòðåëÿåò íå âñåãäà:
4173 if Random(2) = 0 then
4176 // Âðåìÿ âûñòðåëà óïóùåíî:
4180 MONSTER_BARON
, MONSTER_KNIGHT
: if Random(8) <> 0 then Exit
;
4181 MONSTER_SKEL
: if Random(32) <> 0 then Exit
;
4182 MONSTER_VILE
: if Random(8) <> 0 then Exit
;
4183 MONSTER_PAIN
: if Random(8) <> 0 then Exit
;
4184 else if Random(16) <> 0 then Exit
;
4188 if not g_Look(@FObj
, o
, FDirection
) then
4193 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2)+((o
^.Vel
.X
{+o^.Accel.X})*12);
4194 ty
:= o
^.Y
+o
^.Rect
.Y
+(o
^.Rect
.Height
div 2)+((o
^.Vel
.Y
{+o^.Accel.Y})*12);
4196 // Ðàçíèöà ïî âûñîòå áîëüøå ðàçíèöû ïî ãîðèçîíòàëè
4197 // (íå ìîæåò ñòðåëÿòü ïîä òàêèì áîëüøèì óãëîì):
4198 if Abs(tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2))) <
4199 Abs(ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2))) then
4202 case FMonsterType
of
4203 MONSTER_IMP
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
:
4205 SetState(MONSTATE_SHOOT
);
4210 SetState(MONSTATE_SHOOT
);
4214 begin // Çàæèãàåì îãîíü
4215 tx
:= o
^.X
+o
^.Rect
.X
+(o
^.Rect
.Width
div 2);
4216 ty
:= o
^.Y
+o
^.Rect
.Y
;
4217 SetState(MONSTATE_SHOOT
);
4221 g_Sound_PlayExAt('SOUND_MONSTER_VILE_ATTACK', FObj
.X
, FObj
.Y
);
4222 g_Sound_PlayExAt('SOUND_FIRE', o
^.X
, o
^.Y
);
4225 begin // Ëåòèò â ñòîðîíó öåëè:
4226 SetState(MONSTATE_ATTACK
);
4227 g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj
.X
, FObj
.Y
);
4229 xd
:= tx
-(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2));
4230 yd
:= ty
-(FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
4231 m
:= Max(Abs(xd
), Abs(yd
));
4235 FObj
.Vel
.X
:= (xd
*16) div m
;
4236 FObj
.Vel
.Y
:= (yd
*16) div m
;
4238 MONSTER_MANCUB
, MONSTER_ZOMBY
, MONSTER_SERG
, MONSTER_BSP
, MONSTER_ROBO
,
4239 MONSTER_CYBER
, MONSTER_CGUN
, MONSTER_SPIDER
, MONSTER_PAIN
, MONSTER_MAN
:
4241 // Ìàíêóáóñ ðÿâêàåò ïåðåä ïåðâîé àòàêîé:
4242 if FMonsterType
= MONSTER_MANCUB
then
4244 g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj
.X
, FObj
.Y
);
4246 SetState(MONSTATE_SHOOT
);
4254 function TMonster
.Live(): Boolean;
4256 Result
:= (FState
<> MONSTATE_DIE
) and (FState
<> MONSTATE_DEAD
) and (FHealth
> 0);
4259 procedure TMonster
.SetHealth(aH
: Integer);
4261 if (aH
> 0) and (aH
< 1000000) then
4264 if FHealth
> FMaxHealth
then
4265 FMaxHealth
:= FHealth
;
4269 procedure TMonster
.WakeUp();
4271 if g_Game_IsClient
then Exit
;
4272 SetState(MONSTATE_GO
);
4273 FTargetTime
:= MAX_ATM
;
4277 procedure TMonster
.SaveState(var Mem
: TBinMemoryWriter
);
4287 // Ñèãíàòóðà ìîíñòðà:
4288 sig
:= MONSTER_SIGNATURE
; // 'MONS'
4289 Mem
.WriteDWORD(sig
);
4291 Mem
.WriteWord(FUID
);
4293 if FDirection
= D_LEFT
then
4298 // Íàäî ëè óäàëèòü åãî:
4299 Mem
.WriteBoolean(FRemoved
);
4300 // Îñòàëîñü çäîðîâüÿ:
4301 Mem
.WriteInt(FHealth
);
4303 Mem
.WriteByte(FState
);
4304 // Òåêóùàÿ àíèìàöèÿ:
4305 Mem
.WriteByte(FCurAnim
);
4307 Mem
.WriteWord(FTargetUID
);
4308 // Âðåìÿ ïîñëå ïîòåðè öåëè:
4309 Mem
.WriteInt(FTargetTime
);
4310 // Ïîâåäåíèå ìîíñòðà:
4311 Mem
.WriteByte(FBehaviour
);
4312 // Ãîòîâíîñòü ê âûñòðåëó:
4313 Mem
.WriteInt(FAmmo
);
4315 Mem
.WriteInt(FPain
);
4317 Mem
.WriteInt(FSleep
);
4318 // Îçâó÷èâàòü ëè áîëü:
4319 Mem
.WriteBoolean(FPainSound
);
4320 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè:
4321 Mem
.WriteBoolean(FWaitAttackAnim
);
4322 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå:
4323 Mem
.WriteBoolean(FChainFire
);
4324 // Ïîäëåæèò ëè ðåñïàâíó:
4325 Mem
.WriteBoolean(FNoRespawn
);
4329 // ID ìîíñòðà ïðè ñòàðòå êàðòû:
4330 Mem
.WriteInt(FStartID
);
4331 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà:
4332 Mem
.WriteInt(FSpawnTrigger
);
4334 Obj_SaveState(@FObj
, Mem
);
4335 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà:
4336 anim
:= vilefire
<> nil;
4337 Mem
.WriteBoolean(anim
);
4338 // Åñëè åñòü - ñîõðàíÿåì:
4340 vilefire
.SaveState(Mem
);
4342 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4344 // Åñòü ëè ëåâàÿ àíèìàöèÿ:
4345 anim
:= FAnim
[i
, D_LEFT
] <> nil;
4346 Mem
.WriteBoolean(anim
);
4347 // Åñëè åñòü - ñîõðàíÿåì:
4349 FAnim
[i
, D_LEFT
].SaveState(Mem
);
4350 // Åñòü ëè ïðàâàÿ àíèìàöèÿ:
4351 anim
:= FAnim
[i
, D_RIGHT
] <> nil;
4352 Mem
.WriteBoolean(anim
);
4353 // Åñëè åñòü - ñîõðàíÿåì:
4355 FAnim
[i
, D_RIGHT
].SaveState(Mem
);
4360 procedure TMonster
.LoadState(var Mem
: TBinMemoryReader
);
4370 // Ñèãíàòóðà ìîíñòðà:
4372 if sig
<> MONSTER_SIGNATURE
then // 'MONS'
4374 raise EBinSizeError
.Create('TMonster.LoadState: Wrong Monster Signature');
4376 if (uidMap
[FUID
] <> nil) and (uidMap
[FUID
] <> self
) then raise Exception
.Create('internal error in monster loader (0)');
4377 uidMap
[FUID
] := nil;
4380 //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
4381 if (uidMap
[FUID
] <> nil) then raise Exception
.Create('internal error in monster loader (1)');
4382 uidMap
[FUID
] := self
;
4386 FDirection
:= D_LEFT
4388 FDirection
:= D_RIGHT
;
4389 // Íàäî ëè óäàëèòü åãî:
4390 Mem
.ReadBoolean(FRemoved
);
4391 // Îñòàëîñü çäîðîâüÿ:
4392 Mem
.ReadInt(FHealth
);
4394 Mem
.ReadByte(FState
);
4395 // Òåêóùàÿ àíèìàöèÿ:
4396 Mem
.ReadByte(FCurAnim
);
4398 Mem
.ReadWord(FTargetUID
);
4399 // Âðåìÿ ïîñëå ïîòåðè öåëè:
4400 Mem
.ReadInt(FTargetTime
);
4401 // Ïîâåäåíèå ìîíñòðà:
4402 Mem
.ReadByte(FBehaviour
);
4403 // Ãîòîâíîñòü ê âûñòðåëó:
4408 Mem
.ReadInt(FSleep
);
4409 // Îçâó÷èâàòü ëè áîëü:
4410 Mem
.ReadBoolean(FPainSound
);
4411 // Áûëà ëè àòàêà âî âðåìÿ àíèìàöèè àòàêè:
4412 Mem
.ReadBoolean(FWaitAttackAnim
);
4413 // Íàäî ëè ñòðåëÿòü íà ñëåäóþùåì øàãå:
4414 Mem
.ReadBoolean(FChainFire
);
4415 // Ïîäëåæèò ëè ðåñïàâíó
4416 Mem
.ReadBoolean(FNoRespawn
);
4420 // ID ìîíñòðà ïðè ñòàðòå êàðòû:
4421 Mem
.ReadInt(FStartID
);
4422 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ìîíñòðà:
4423 Mem
.ReadInt(FSpawnTrigger
);
4425 Obj_LoadState(@FObj
, Mem
);
4426 // Åñòü ëè àíèìàöèÿ îãíÿ êîëäóíà:
4427 Mem
.ReadBoolean(anim
);
4428 // Åñëè åñòü - çàãðóæàåì:
4431 Assert(vilefire
<> nil, 'TMonster.LoadState: no vilefire anim');
4432 vilefire
.LoadState(Mem
);
4435 for i
:= ANIM_SLEEP
to ANIM_PAIN
do
4437 // Åñòü ëè ëåâàÿ àíèìàöèÿ:
4438 Mem
.ReadBoolean(anim
);
4439 // Åñëè åñòü - çàãðóæàåì:
4442 Assert(FAnim
[i
, D_LEFT
] <> nil,
4443 'TMonster.LoadState: no '+IntToStr(i
)+'_left anim');
4444 FAnim
[i
, D_LEFT
].LoadState(Mem
);
4446 // Åñòü ëè ïðàâàÿ àíèìàöèÿ:
4447 Mem
.ReadBoolean(anim
);
4448 // Åñëè åñòü - çàãðóæàåì:
4451 Assert(FAnim
[i
, D_RIGHT
] <> nil,
4452 'TMonster.LoadState: no '+IntToStr(i
)+'_right anim');
4453 FAnim
[i
, D_RIGHT
].LoadState(Mem
);
4458 procedure TMonster
.ActivateTriggers();
4462 if FDieTriggers
<> nil then
4463 for a
:= 0 to High(FDieTriggers
) do
4464 g_Triggers_Press(FDieTriggers
[a
], ACTIVATE_MONSTERPRESS
);
4465 if FSpawnTrigger
> -1 then
4467 g_Triggers_DecreaseSpawner(FSpawnTrigger
);
4468 FSpawnTrigger
:= -1;
4472 procedure TMonster
.AddTrigger(t
: Integer);
4474 SetLength(FDieTriggers
, Length(FDieTriggers
)+1);
4475 FDieTriggers
[High(FDieTriggers
)] := t
;
4478 procedure TMonster
.ClearTriggers();
4480 SetLength(FDieTriggers
, 0);
4483 procedure TMonster
.CatchFire(Attacker
: Word);
4486 FFireAttacker
:= Attacker
;
4487 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_MonsterState(FUID
);
4490 procedure TMonster
.OnFireFlame(Times
: DWORD
= 1);
4495 if (Random(10) = 1) and (Times
= 1) then
4498 if g_Frames_Get(id
, 'FRAMES_FLAME') then
4500 for i
:= 1 to Times
do
4502 Anim
:= TAnimation
.Create(id
, False, 3);
4504 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
4505 Obj
.Y
+8+Random(8+Times
*2)+IfThen(FState
= MONSTATE_DEAD
, 16, 0), Anim
, ONCEANIM_SMOKE
);
4512 // ////////////////////////////////////////////////////////////////////////// //
4513 // throws on invalid uid
4514 function g_Mons_ByIdx (uid
: Integer): TMonster
; inline;
4516 result
:= g_Mons_ByIdx_NC(uid
);
4517 if (result
= nil) then raise Exception
.Create('g_Mons_ByIdx: invalid monster id');
4521 function g_Mons_ByIdx_NC (uid
: Integer): TMonster
; inline;
4523 if (uid
< 0) or (uid
> High(gMonsters
)) then begin result
:= nil; exit
; end;
4524 result
:= gMonsters
[uid
];
4527 function g_Mons_TotalCount (): Integer; inline;
4529 result
:= Length(gMonsters
);
4533 function g_Mons_ForEach (cb
: TEachMonsterCB
): Boolean;
4539 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4540 for idx
:= 0 to High(gMonsters
) do
4542 mon
:= gMonsters
[idx
];
4543 if (mon
<> nil) then
4546 if result
then exit
;
4552 function g_Mons_ForEachAlive (cb
: TEachMonsterCB
): Boolean;
4558 if (gMonsters
= nil) or not assigned(cb
) then exit
;
4559 for idx
:= 0 to High(gMonsters
) do
4561 mon
:= gMonsters
[idx
];
4562 if (mon
<> nil) and mon
.Live
then
4565 if result
then exit
;
4571 function g_Mons_IsAnyAliveAt (x
, y
: Integer; width
, height
: Integer): Boolean;
4573 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4575 result
:= mon
.Live
;// and g_Obj_Collide(x, y, width, height, @mon.Obj));
4583 if (width
< 1) or (height
< 1) then exit
;
4584 if gmon_debug_use_sqaccel
then
4586 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4590 for idx
:= 0 to High(gMonsters
) do
4592 mon
:= gMonsters
[idx
];
4593 if (mon
<> nil) and mon
.Live
then
4595 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4606 function g_Mons_ForEachAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4608 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4618 if (width
< 1) or (height
< 1) then exit
;
4619 if gmon_debug_use_sqaccel
then
4621 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4625 for idx
:= 0 to High(gMonsters
) do
4627 mon
:= gMonsters
[idx
];
4628 if (mon
<> nil) and mon
.Live
then
4630 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4633 if result
then exit
;
4641 function g_Mons_ForEachAliveAt (x
, y
: Integer; width
, height
: Integer; cb
: TEachMonsterCB
): Boolean;
4643 function monsCollCheck (mon
: TMonster
; atag
: Integer): Boolean;
4646 //if mon.Live and g_Obj_Collide(x, y, width, height, @mon.Obj) then result := cb(mon);
4647 if mon
.Live
then result
:= cb(mon
) else result
:= false;
4655 if (width
< 1) or (height
< 1) then exit
;
4656 if gmon_debug_use_sqaccel
then
4658 if (width
= 1) and (height
= 1) then
4660 result
:= (monsGrid
.forEachAtPoint(x
, y
, monsCollCheck
) <> nil);
4664 result
:= (monsGrid
.forEachInAABB(x
, y
, width
, height
, monsCollCheck
) <> nil);
4669 for idx
:= 0 to High(gMonsters
) do
4671 mon
:= gMonsters
[idx
];
4672 if (mon
<> nil) and mon
.Live
then
4674 if g_Obj_Collide(x
, y
, width
, height
, @mon
.Obj
) then
4677 if result
then exit
;