6 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
28 Animation
: TAnimation
;
34 Shots
: array of TShot
= nil;
35 LastShotID
: Integer = 0;
37 procedure g_Weapon_LoadData();
38 procedure g_Weapon_FreeData();
39 procedure g_Weapon_Init();
40 procedure g_Weapon_Free();
41 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
42 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
43 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
45 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
46 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
47 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
48 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
49 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
50 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
51 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
52 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
53 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
54 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
55 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
56 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
57 procedure g_Weapon_bfghit(x
, y
: Integer);
58 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
59 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
60 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
61 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
63 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
64 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
65 procedure g_Weapon_Update();
66 procedure g_Weapon_Draw();
67 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
68 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
70 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
71 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
80 WEAPON_ROCKETLAUNCHER
= 6;
83 WEAPON_SUPERPULEMET
= 9;
84 WEAPON_MEGAKASTET
= 10;
85 WEAPON_ZOMBY_PISTOL
= 20;
88 WEAPON_CACO_FIRE
= 23;
89 WEAPON_BARON_FIRE
= 24;
90 WEAPON_MANCUB_FIRE
= 25;
91 WEAPON_SKEL_FIRE
= 26;
96 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
97 g_console
, SysUtils
, g_options
, g_game
,
98 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
109 SHOT_ROCKETLAUNCHER_WIDTH
= 27;
110 SHOT_ROCKETLAUNCHER_HEIGHT
= 12;
112 SHOT_SKELFIRE_WIDTH
= 32;
113 SHOT_SKELFIRE_HEIGHT
= 16;
115 SHOT_PLASMA_WIDTH
= 16;
116 SHOT_PLASMA_HEIGHT
= 16;
119 SHOT_BFG_HEIGHT
= 32;
120 SHOT_BFG_DAMAGE
= 100;
121 SHOT_BFG_RADIUS
= 256;
123 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
126 WaterMap
: array of array of DWORD
= nil;
128 function FindShot(): DWORD
;
133 for i
:= 0 to High(Shots
) do
134 if Shots
[i
].ShotType
= 0 then
137 LastShotID
:= Result
;
143 SetLength(Shots
, 128);
148 Result
:= High(Shots
) + 1;
149 SetLength(Shots
, Length(Shots
) + 128);
151 LastShotID
:= Result
;
154 procedure CreateWaterMap();
156 WaterArray
: Array of TWaterPanel
;
163 SetLength(WaterArray
, Length(gWater
));
165 for a
:= 0 to High(gWater
) do
167 WaterArray
[a
].X
:= gWater
[a
].X
;
168 WaterArray
[a
].Y
:= gWater
[a
].Y
;
169 WaterArray
[a
].Width
:= gWater
[a
].Width
;
170 WaterArray
[a
].Height
:= gWater
[a
].Height
;
171 WaterArray
[a
].Active
:= True;
174 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
176 for a
:= 0 to High(WaterArray
) do
177 if WaterArray
[a
].Active
then
179 WaterArray
[a
].Active
:= False;
180 m
:= Length(WaterMap
);
181 SetLength(WaterMap
, m
+1);
182 SetLength(WaterMap
[m
], 1);
189 for b
:= 0 to High(WaterArray
) do
190 if WaterArray
[b
].Active
then
191 for c
:= 0 to High(WaterMap
[m
]) do
192 if g_CollideAround(WaterArray
[b
].X
,
195 WaterArray
[b
].Height
,
196 WaterArray
[WaterMap
[m
][c
]].X
,
197 WaterArray
[WaterMap
[m
][c
]].Y
,
198 WaterArray
[WaterMap
[m
][c
]].Width
,
199 WaterArray
[WaterMap
[m
][c
]].Height
) then
201 WaterArray
[b
].Active
:= False;
202 SetLength(WaterMap
[m
],
203 Length(WaterMap
[m
])+1);
204 WaterMap
[m
][High(WaterMap
[m
])] := b
;
210 g_Game_StepLoading();
216 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
218 a
, b
, c
, d
, i1
, i2
: Integer;
221 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
228 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
229 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
231 for a
:= 0 to High(WaterMap
) do
232 for b
:= 0 to High(WaterMap
[a
]) do
234 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
235 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
236 @Shots
[ID
].Obj
) then Continue
;
238 for c
:= 0 to High(WaterMap
[a
]) do
240 if gPlayers
<> nil then
242 for d
:= 0 to High(gPlayers
) do
243 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
244 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
245 if not InWArray(d
, pl
) then
253 if gMonsters
<> nil then
255 for d
:= 0 to High(gMonsters
) do
256 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
257 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
258 if not InWArray(d
, mn
) then
269 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
273 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
280 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
287 tt
:= g_GetUIDType(SpawnerUID
);
288 if tt
= UID_MONSTER
then
290 mon
:= g_Monsters_Get(SpawnerUID
);
292 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
299 if m
= nil then Exit
;
300 if m
.UID
= SpawnerUID
then
302 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
303 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
305 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
306 if (m
.MonsterType
= MONSTER_CYBER
) or
307 (m
.MonsterType
= MONSTER_BARREL
) then
314 if tt
= UID_MONSTER
then
316 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
317 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
320 // Îáà ìîíñòðà îäíîãî âèäà:
321 if mt
= m
.MonsterType
then
323 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
324 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
325 Exit
; // Ýòè íå áüþò ñâîèõ
329 if g_Game_IsServer
then
330 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
335 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
339 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
340 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
343 if g_Game_IsServer
then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
348 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
349 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
359 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
360 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
362 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
366 if Result
<> 0 then Exit
;
368 h
:= High(gMonsters
);
372 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
373 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
375 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
381 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
388 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
392 if gAdvCorpses
and (h
<> -1) then
394 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
396 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
397 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
398 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
399 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
402 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
403 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
407 pl
:= g_Player_Get(SpawnerUID
);
415 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
417 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
418 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
419 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
420 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
422 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
423 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
425 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
427 gPlayers
[i
].BFGHit();
430 h
:= High(gMonsters
);
434 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
436 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
437 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
438 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
439 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
440 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
443 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
445 find_id
, FramesID
: DWORD
;
448 find_id
:= FindShot()
452 if Integer(find_id
) >= High(Shots
) then
453 SetLength(Shots
, find_id
+ 64)
457 WEAPON_ROCKETLAUNCHER
:
459 with Shots
[find_id
] do
463 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
464 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
468 ShotType
:= WEAPON_ROCKETLAUNCHER
;
469 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
475 with Shots
[find_id
] do
479 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
480 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
483 ShotType
:= WEAPON_PLASMA
;
484 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
485 Animation
:= TAnimation
.Create(FramesID
, True, 5);
491 with Shots
[find_id
] do
495 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
496 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
499 ShotType
:= WEAPON_BFG
;
500 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
501 Animation
:= TAnimation
.Create(FramesID
, True, 6);
507 with Shots
[find_id
] do
511 Obj
.Rect
.Width
:= 16;
512 Obj
.Rect
.Height
:= 16;
515 ShotType
:= WEAPON_IMP_FIRE
;
516 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
517 Animation
:= TAnimation
.Create(FramesID
, True, 4);
523 with Shots
[find_id
] do
527 Obj
.Rect
.Width
:= 16;
528 Obj
.Rect
.Height
:= 16;
531 ShotType
:= WEAPON_CACO_FIRE
;
532 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
533 Animation
:= TAnimation
.Create(FramesID
, True, 4);
539 with Shots
[find_id
] do
543 Obj
.Rect
.Width
:= 32;
544 Obj
.Rect
.Height
:= 32;
547 ShotType
:= WEAPON_MANCUB_FIRE
;
548 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
549 Animation
:= TAnimation
.Create(FramesID
, True, 4);
555 with Shots
[find_id
] do
559 Obj
.Rect
.Width
:= 32;
560 Obj
.Rect
.Height
:= 16;
563 ShotType
:= WEAPON_BARON_FIRE
;
564 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
565 Animation
:= TAnimation
.Create(FramesID
, True, 4);
571 with Shots
[find_id
] do
575 Obj
.Rect
.Width
:= 16;
576 Obj
.Rect
.Height
:= 16;
579 ShotType
:= WEAPON_BSP_FIRE
;
580 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
581 Animation
:= TAnimation
.Create(FramesID
, True, 4);
587 with Shots
[find_id
] do
591 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
592 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
595 ShotType
:= WEAPON_SKEL_FIRE
;
597 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
598 Animation
:= TAnimation
.Create(FramesID
, True, 5);
603 Shots
[find_id
].Obj
.X
:= X
;
604 Shots
[find_id
].Obj
.Y
:= Y
;
605 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
606 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
607 Shots
[find_id
].Obj
.Accel
.X
:= 0;
608 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
609 Shots
[find_id
].SpawnerUID
:= Spawner
;
613 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
620 a
:= Max(Abs(xd
), Abs(yd
));
626 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
627 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
628 Shots
[i
].Obj
.Accel
.X
:= 0;
629 Shots
[i
].Obj
.Accel
.Y
:= 0;
630 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
631 Shots
[i
].Timeout
:= 900 // ~25 sec
633 Shots
[i
].Timeout
:= 550 // ~15 sec
636 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
640 function PlayerHit(Team
: Byte = 0): Boolean;
651 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
654 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
656 p
:= g_Player_Get(SpawnerUID
);
658 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
661 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
663 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
664 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
666 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
672 function MonsterHit(): Boolean;
677 h
:= High(gMonsters
);
681 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
682 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
684 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
685 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
697 if gAdvCorpses
and (h
<> -1) then
699 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
700 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
703 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
704 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
709 case gGameSettings
.GameMode
of
713 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
730 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
747 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
761 // È â êîíöå ñâîèõ èãðîêîâ
772 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
776 case g_GetUIDType(UID
) of
777 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
778 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
783 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
785 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
790 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
798 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
801 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
802 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
804 if dx
> 1000 then dx
:= 1000;
805 if dy
> 1000 then dy
:= 1000;
807 if dx
*dx
+dy
*dy
< r
then
809 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
810 // PLAYER_RECT.Width, PLAYER_RECT.Height);
812 mm
:= Max(abs(dx
), abs(dy
));
813 if mm
= 0 then mm
:= 1;
815 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
816 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
820 h
:= High(gMonsters
);
824 if gMonsters
[i
] <> nil then
827 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
828 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
830 if dx
> 1000 then dx
:= 1000;
831 if dy
> 1000 then dy
:= 1000;
833 if dx
*dx
+dy
*dy
< r
then
835 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
836 // Obj.Rect.Width, Obj.Rect.Height);
838 mm
:= Max(abs(dx
), abs(dy
));
839 if mm
= 0 then mm
:= 1;
841 if gMonsters
[i
].Live
then
842 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
843 0, 0, SpawnerUID
, HIT_ROCKET
);
845 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
851 if gAdvCorpses
and (h
<> -1) then
853 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
856 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
857 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
859 if dx
> 1000 then dx
:= 1000;
860 if dy
> 1000 then dy
:= 1000;
862 if dx
*dx
+dy
*dy
< r
then
864 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
865 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
867 mm
:= Max(abs(dx
), abs(dy
));
868 if mm
= 0 then mm
:= 1;
870 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
876 if gAdvGibs
and (h
<> -1) then
878 if gGibs
[i
].Live
then
881 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
882 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
884 if dx
> 1000 then dx
:= 1000;
885 if dy
> 1000 then dy
:= 1000;
887 if dx
*dx
+dy
*dy
< r
then
889 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
890 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
891 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
892 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
894 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
899 procedure g_Weapon_Init();
904 procedure g_Weapon_Free();
910 for i
:= 0 to High(Shots
) do
911 if Shots
[i
].ShotType
<> 0 then
912 Shots
[i
].Animation
.Free();
920 procedure g_Weapon_LoadData();
922 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
924 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
925 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
926 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
927 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
928 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
929 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
930 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
931 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
932 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
933 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
934 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
935 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
936 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
937 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
938 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
939 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
940 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
941 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
942 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
943 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
944 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
945 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
946 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
947 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
948 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
949 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
950 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
951 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
952 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
953 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
954 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
955 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
957 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
958 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
959 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
960 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
961 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
962 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
964 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
965 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
966 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
967 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
968 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
969 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
970 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
971 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
972 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
973 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
974 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
975 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
976 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
978 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
979 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
982 procedure g_Weapon_FreeData();
984 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
986 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
987 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
988 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
989 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
990 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
991 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
992 g_Sound_Delete('SOUND_WEAPON_HITSAW');
993 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
994 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
995 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
996 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
997 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
998 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
999 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1000 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1001 g_Sound_Delete('SOUND_FIRE');
1002 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1003 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1004 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1005 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1006 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1007 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1008 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1009 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1010 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1011 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1012 g_Sound_Delete('SOUND_PLAYER_JETON');
1013 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1014 g_Sound_Delete('SOUND_PLAYER_CASING1');
1015 g_Sound_Delete('SOUND_PLAYER_CASING2');
1016 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1017 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1019 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1020 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1021 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1022 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1023 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1024 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1025 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1026 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1027 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1028 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1029 g_Frames_DeleteByName('FRAMES_BFGHIT');
1030 g_Frames_DeleteByName('FRAMES_FIRE');
1031 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1032 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1033 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1034 g_Frames_DeleteByName('FRAMES_SMOKE');
1035 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1036 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1039 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1051 t1
, _collide
: Boolean;
1054 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1056 SinCos(DegToRad(-a
), s
, c
);
1058 if Abs(s
) < 0.01 then s
:= 0;
1059 if Abs(c
) < 0.01 then c
:= 0;
1061 x2
:= x
+Round(c
*gMapInfo
.Width
);
1062 y2
:= y
+Round(s
*gMapInfo
.Width
);
1064 t1
:= gWalls
<> nil;
1066 w
:= gMapInfo
.Width
;
1067 h
:= gMapInfo
.Height
;
1074 if (xd
= 0) and (yd
= 0) then Exit
;
1076 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1077 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1082 if dx
> dy
then d
:= dx
else d
:= dy
;
1084 //blood vel, for Monster.Damage()
1085 //vx := (dx*10 div d)*xi;
1086 //vy := (dy*10 div d)*yi;
1108 if (yy
> h
) or (yy
< 0) then Break
;
1109 if (xx
> w
) or (xx
< 0) then Break
;
1112 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1115 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1116 if g_Game_IsServer
and g_Game_IsNet
then
1117 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1120 if not _collide
then
1121 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1127 if CheckTrigger
and g_Game_IsServer
then
1128 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1131 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1139 obj
.rect
.Width
:= 39;
1140 obj
.rect
.Height
:= 52;
1146 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1147 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1149 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1152 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1160 obj
.rect
.Width
:= 32;
1161 obj
.rect
.Height
:= 52;
1167 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1170 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1171 Silent
: Boolean = False);
1177 find_id
:= FindShot()
1181 if Integer(find_id
) >= High(Shots
) then
1182 SetLength(Shots
, find_id
+ 64)
1185 with Shots
[find_id
] do
1189 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1190 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1192 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1193 dy
:= -(Obj
.Rect
.Height
div 2);
1194 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1198 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1199 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1202 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1205 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1208 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1209 WID
: Integer = -1; Silent
: Boolean = False);
1211 find_id
, FramesID
: DWORD
;
1215 find_id
:= FindShot()
1219 if Integer(find_id
) >= High(Shots
) then
1220 SetLength(Shots
, find_id
+ 64)
1223 with Shots
[find_id
] do
1227 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1228 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1230 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1231 dy
:= -(Obj
.Rect
.Height
div 2);
1232 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1235 ShotType
:= WEAPON_SKEL_FIRE
;
1236 target
:= TargetUID
;
1237 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1238 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1241 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1244 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1247 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1248 Silent
: Boolean = False);
1250 find_id
, FramesID
: DWORD
;
1254 find_id
:= FindShot()
1258 if Integer(find_id
) >= High(Shots
) then
1259 SetLength(Shots
, find_id
+ 64);
1262 with Shots
[find_id
] do
1266 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1267 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1269 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1270 dy
:= -(Obj
.Rect
.Height
div 2);
1271 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1274 ShotType
:= WEAPON_PLASMA
;
1275 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1276 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1279 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1282 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1285 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1286 Silent
: Boolean = False);
1288 find_id
, FramesID
: DWORD
;
1292 find_id
:= FindShot()
1296 if Integer(find_id
) >= High(Shots
) then
1297 SetLength(Shots
, find_id
+ 64)
1300 with Shots
[find_id
] do
1304 Obj
.Rect
.Width
:= 16;
1305 Obj
.Rect
.Height
:= 16;
1307 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1308 dy
:= -(Obj
.Rect
.Height
div 2);
1309 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1312 ShotType
:= WEAPON_IMP_FIRE
;
1313 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1314 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1317 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1320 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1323 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1324 Silent
: Boolean = False);
1326 find_id
, FramesID
: DWORD
;
1330 find_id
:= FindShot()
1334 if Integer(find_id
) >= High(Shots
) then
1335 SetLength(Shots
, find_id
+ 64)
1338 with Shots
[find_id
] do
1342 Obj
.Rect
.Width
:= 16;
1343 Obj
.Rect
.Height
:= 16;
1345 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1346 dy
:= -(Obj
.Rect
.Height
div 2);
1347 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1350 ShotType
:= WEAPON_CACO_FIRE
;
1351 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1352 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1355 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1358 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1361 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1362 Silent
: Boolean = False);
1364 find_id
, FramesID
: DWORD
;
1368 find_id
:= FindShot()
1372 if Integer(find_id
) >= High(Shots
) then
1373 SetLength(Shots
, find_id
+ 64)
1376 with Shots
[find_id
] do
1380 Obj
.Rect
.Width
:= 32;
1381 Obj
.Rect
.Height
:= 16;
1383 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1384 dy
:= -(Obj
.Rect
.Height
div 2);
1385 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1388 ShotType
:= WEAPON_BARON_FIRE
;
1389 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1390 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1393 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1396 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1399 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1400 Silent
: Boolean = False);
1402 find_id
, FramesID
: DWORD
;
1406 find_id
:= FindShot()
1410 if Integer(find_id
) >= High(Shots
) then
1411 SetLength(Shots
, find_id
+ 64)
1414 with Shots
[find_id
] do
1418 Obj
.Rect
.Width
:= 16;
1419 Obj
.Rect
.Height
:= 16;
1421 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1422 dy
:= -(Obj
.Rect
.Height
div 2);
1423 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1426 ShotType
:= WEAPON_BSP_FIRE
;
1427 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1428 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1431 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1434 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1437 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1438 Silent
: Boolean = False);
1440 find_id
, FramesID
: DWORD
;
1444 find_id
:= FindShot()
1448 if Integer(find_id
) >= High(Shots
) then
1449 SetLength(Shots
, find_id
+ 64)
1452 with Shots
[find_id
] do
1456 Obj
.Rect
.Width
:= 32;
1457 Obj
.Rect
.Height
:= 32;
1459 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1460 dy
:= -(Obj
.Rect
.Height
div 2);
1461 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1464 ShotType
:= WEAPON_MANCUB_FIRE
;
1465 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1466 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1469 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1472 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1475 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1476 Silent
: Boolean = False);
1478 find_id
, FramesID
: DWORD
;
1482 find_id
:= FindShot()
1486 if Integer(find_id
) >= High(Shots
) then
1487 SetLength(Shots
, find_id
+ 64)
1490 with Shots
[find_id
] do
1494 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1495 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1497 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1498 dy
:= -(Obj
.Rect
.Height
div 2);
1499 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1502 ShotType
:= WEAPON_BFG
;
1503 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1504 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1507 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1510 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1513 procedure g_Weapon_bfghit(x
, y
: Integer);
1518 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1520 Anim
:= TAnimation
.Create(ID
, False, 4);
1521 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1526 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1527 Silent
: Boolean = False);
1530 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1532 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1533 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1535 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1536 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1540 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1541 Silent
: Boolean = False);
1544 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1546 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1547 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1548 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1550 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1551 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1555 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1556 Silent
: Boolean = False);
1561 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1565 j
:= Random(17)-8; // -8 .. 8
1566 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1570 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1571 Silent
: Boolean = False);
1576 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1578 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1581 j
:= Random(41)-20; // -20 .. 20
1582 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1586 procedure g_Weapon_Update();
1588 i
, a
, h
, cx
, cy
, oldvx
, oldvy
: Integer;
1601 for i
:= 0 to High(Shots
) do
1603 if Shots
[i
].ShotType
= 0 then
1610 Timeout
:= Timeout
- 1;
1613 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1614 if g_Game_IsServer
then
1615 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1616 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1622 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1623 if triggers
= nil then
1630 if not InDWArray(t
[a
], triggers
) then
1632 SetLength(triggers
, Length(triggers
)+1);
1633 triggers
[High(triggers
)] := t
[a
];
1638 // Àíèìàöèÿ ñíàðÿäà:
1639 if Animation
<> nil then
1643 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1644 (ShotType
<> WEAPON_BFG
) and
1645 (ShotType
<> WEAPON_BSP_FIRE
);
1647 st
:= g_Obj_Move(@Obj
, False, spl
);
1649 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1650 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1652 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1658 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1659 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1662 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1664 // Âûëåòåëà èç âîäû:
1665 if WordBool(st
and MOVE_HITAIR
) then
1666 g_Obj_SetSpeed(@Obj
, 12);
1668 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1669 if WordBool(st
and MOVE_INWATER
) then
1670 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1671 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1672 1+Random(3), 16, 16)
1674 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1676 Anim
:= TAnimation
.Create(_id
, False, 3);
1678 g_GFX_OnceAnim(Obj
.X
-8+Random(9),
1679 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1680 Anim
, ONCEANIM_SMOKE
);
1684 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1685 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1686 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1692 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1694 if ShotType
= WEAPON_SKEL_FIRE
then
1695 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1696 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1698 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1699 Anim
.Blending
:= False;
1700 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
1705 begin // Âçðûâ Ðàêåòû
1706 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1708 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1709 Anim
.Blending
:= False;
1710 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1715 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1720 if ShotType
= WEAPON_SKEL_FIRE
then
1721 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1722 if GetPos(target
, @o
) then
1723 throw(i
, Obj
.X
, Obj
.Y
,
1724 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1725 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1730 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1732 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1733 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1735 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1736 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1742 if (ShotType
= WEAPON_PLASMA
) and
1743 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1748 if ShotType
= WEAPON_BSP_FIRE
then
1751 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1752 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1753 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1756 if ShotType
= WEAPON_PLASMA
then
1757 s
:= 'FRAMES_EXPLODE_PLASMA'
1759 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1762 if g_Frames_Get(TextureID
, s
) then
1764 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1765 Anim
.Blending
:= False;
1766 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1770 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1778 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1779 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1781 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1782 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1787 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1788 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1789 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
1793 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
1796 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
1798 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1799 Anim
.Blending
:= False;
1800 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1804 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
1810 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1813 if WordBool(st
and MOVE_HITAIR
) then
1814 g_Obj_SetSpeed(@Obj
, 16);
1817 if ShotType
= WEAPON_IMP_FIRE
then
1820 if ShotType
= WEAPON_CACO_FIRE
then
1825 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1826 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1827 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
1830 if ShotType
= WEAPON_IMP_FIRE
then
1831 s
:= 'FRAMES_EXPLODE_IMPFIRE'
1833 if ShotType
= WEAPON_CACO_FIRE
then
1834 s
:= 'FRAMES_EXPLODE_CACOFIRE'
1836 s
:= 'FRAMES_EXPLODE_BARONFIRE';
1839 if g_Frames_Get(TextureID
, s
) then
1841 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1842 Anim
.Blending
:= False;
1843 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
1847 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1853 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
1856 if WordBool(st
and MOVE_HITAIR
) then
1857 g_Obj_SetSpeed(@Obj
, 16);
1859 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1860 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1861 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
1865 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1867 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1868 Anim
.Blending
:= False;
1869 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1873 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1878 end; // case ShotType of...
1880 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
1881 if (ShotType
= 0) then
1883 if gGameSettings
.GameType
= GT_SERVER
then
1884 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
1888 else if (oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
) then
1889 if gGameSettings
.GameType
= GT_SERVER
then
1890 MH_SEND_UpdateShot(i
);
1895 procedure g_Weapon_Draw();
1904 for i
:= 0 to High(Shots
) do
1905 if Shots
[i
].ShotType
<> 0 then
1908 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
1909 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1910 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1911 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1912 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
1916 p
.X
:= Obj
.Rect
.Width
div 2;
1917 p
.Y
:= Obj
.Rect
.Height
div 2;
1919 if Animation
<> nil then
1921 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1922 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1923 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1924 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
1926 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
1930 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
1931 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
1933 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
1936 if g_debug_Frames
then
1938 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
1940 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
1941 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
1947 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
1956 for a
:= 0 to High(Shots
) do
1957 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
1958 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
1959 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
1960 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
1961 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
1962 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
1963 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
1970 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
1972 count
, i
, j
: Integer;
1975 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
1977 if Shots
<> nil then
1978 for i
:= 0 to High(Shots
) do
1979 if Shots
[i
].ShotType
<> 0 then
1982 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
1984 // Êîëè÷åñòâî ñíàðÿäîâ:
1985 Mem
.WriteInt(count
);
1990 for i
:= 0 to High(Shots
) do
1991 if Shots
[i
].ShotType
<> 0 then
1993 // Ñèãíàòóðà ñíàðÿäà:
1994 dw
:= SHOT_SIGNATURE
; // 'SHOT'
1997 Mem
.WriteByte(Shots
[i
].ShotType
);
1999 Mem
.WriteWord(Shots
[i
].Target
);
2001 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2002 // Ðàçìåð ïîëÿ Triggers:
2003 dw
:= Length(Shots
[i
].Triggers
);
2005 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2006 for j
:= 0 to Integer(dw
)-1 do
2007 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2009 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2013 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2015 count
, i
, j
: Integer;
2021 // Êîëè÷åñòâî ñíàðÿäîâ:
2024 SetLength(Shots
, count
);
2029 for i
:= 0 to count
-1 do
2031 // Ñèãíàòóðà ñíàðÿäà:
2033 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2035 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2038 Mem
.ReadByte(Shots
[i
].ShotType
);
2040 Mem
.ReadWord(Shots
[i
].Target
);
2042 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2043 // Ðàçìåð ïîëÿ Triggers:
2045 SetLength(Shots
[i
].Triggers
, dw
);
2046 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2047 for j
:= 0 to Integer(dw
)-1 do
2048 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2050 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2052 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2053 Shots
[i
].TextureID
:= DWORD(-1);
2054 Shots
[i
].Animation
:= nil;
2056 case Shots
[i
].ShotType
of
2057 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2059 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2063 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2064 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2068 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2069 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2073 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2074 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2078 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2079 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2083 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2084 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2088 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2089 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2093 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2094 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2100 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2108 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2112 if ShotType
= 0 then Exit
;
2115 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2116 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2119 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2123 if ShotType
= WEAPON_SKEL_FIRE
then
2124 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2125 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2127 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2128 Anim
.Blending
:= False;
2129 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2134 begin // Âçðûâ Ðàêåòû
2135 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2137 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2138 Anim
.Blending
:= False;
2139 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2143 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2147 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2149 if ShotType
= WEAPON_PLASMA
then
2150 s
:= 'FRAMES_EXPLODE_PLASMA'
2152 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2154 if g_Frames_Get(TextureID
, s
) and loud
then
2156 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2157 Anim
.Blending
:= False;
2158 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2161 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2168 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2170 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2171 Anim
.Blending
:= False;
2172 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2175 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2179 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2181 if ShotType
= WEAPON_IMP_FIRE
then
2182 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2184 if ShotType
= WEAPON_CACO_FIRE
then
2185 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2187 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2189 if g_Frames_Get(TextureID
, s
) and Loud
then
2191 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2192 Anim
.Blending
:= False;
2193 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2196 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2200 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2202 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2204 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2205 Anim
.Blending
:= False;
2206 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2209 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2212 end; // case ShotType of...