7 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
29 Animation
: TAnimation
;
35 Shots
: array of TShot
= nil;
36 LastShotID
: Integer = 0;
38 procedure g_Weapon_LoadData();
39 procedure g_Weapon_FreeData();
40 procedure g_Weapon_Init();
41 procedure g_Weapon_Free();
42 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
43 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
44 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
46 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
47 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
48 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
49 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
50 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
51 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
52 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
53 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
54 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
55 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
56 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
57 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
58 procedure g_Weapon_bfghit(x
, y
: Integer);
59 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
60 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
61 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
62 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
64 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
65 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
66 procedure g_Weapon_Update();
67 procedure g_Weapon_Draw();
68 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
69 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
71 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
72 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
81 WEAPON_ROCKETLAUNCHER
= 6;
84 WEAPON_SUPERPULEMET
= 9;
85 WEAPON_MEGAKASTET
= 10;
86 WEAPON_ZOMBY_PISTOL
= 20;
89 WEAPON_CACO_FIRE
= 23;
90 WEAPON_BARON_FIRE
= 24;
91 WEAPON_MANCUB_FIRE
= 25;
92 WEAPON_SKEL_FIRE
= 26;
97 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
98 g_console
, SysUtils
, g_options
, g_game
,
99 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
100 g_language
, g_netmsg
;
110 SHOT_ROCKETLAUNCHER_WIDTH
= 27;
111 SHOT_ROCKETLAUNCHER_HEIGHT
= 12;
113 SHOT_SKELFIRE_WIDTH
= 32;
114 SHOT_SKELFIRE_HEIGHT
= 16;
116 SHOT_PLASMA_WIDTH
= 16;
117 SHOT_PLASMA_HEIGHT
= 16;
120 SHOT_BFG_HEIGHT
= 32;
121 SHOT_BFG_DAMAGE
= 100;
122 SHOT_BFG_RADIUS
= 256;
124 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
127 WaterMap
: array of array of DWORD
= nil;
129 function FindShot(): DWORD
;
134 for i
:= 0 to High(Shots
) do
135 if Shots
[i
].ShotType
= 0 then
138 LastShotID
:= Result
;
144 SetLength(Shots
, 128);
149 Result
:= High(Shots
) + 1;
150 SetLength(Shots
, Length(Shots
) + 128);
152 LastShotID
:= Result
;
155 procedure CreateWaterMap();
157 WaterArray
: Array of TWaterPanel
;
164 SetLength(WaterArray
, Length(gWater
));
166 for a
:= 0 to High(gWater
) do
168 WaterArray
[a
].X
:= gWater
[a
].X
;
169 WaterArray
[a
].Y
:= gWater
[a
].Y
;
170 WaterArray
[a
].Width
:= gWater
[a
].Width
;
171 WaterArray
[a
].Height
:= gWater
[a
].Height
;
172 WaterArray
[a
].Active
:= True;
175 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
177 for a
:= 0 to High(WaterArray
) do
178 if WaterArray
[a
].Active
then
180 WaterArray
[a
].Active
:= False;
181 m
:= Length(WaterMap
);
182 SetLength(WaterMap
, m
+1);
183 SetLength(WaterMap
[m
], 1);
190 for b
:= 0 to High(WaterArray
) do
191 if WaterArray
[b
].Active
then
192 for c
:= 0 to High(WaterMap
[m
]) do
193 if g_CollideAround(WaterArray
[b
].X
,
196 WaterArray
[b
].Height
,
197 WaterArray
[WaterMap
[m
][c
]].X
,
198 WaterArray
[WaterMap
[m
][c
]].Y
,
199 WaterArray
[WaterMap
[m
][c
]].Width
,
200 WaterArray
[WaterMap
[m
][c
]].Height
) then
202 WaterArray
[b
].Active
:= False;
203 SetLength(WaterMap
[m
],
204 Length(WaterMap
[m
])+1);
205 WaterMap
[m
][High(WaterMap
[m
])] := b
;
211 g_Game_StepLoading();
217 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
219 a
, b
, c
, d
, i1
, i2
: Integer;
222 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
229 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
230 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
232 for a
:= 0 to High(WaterMap
) do
233 for b
:= 0 to High(WaterMap
[a
]) do
235 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
236 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
237 @Shots
[ID
].Obj
) then Continue
;
239 for c
:= 0 to High(WaterMap
[a
]) do
241 if gPlayers
<> nil then
243 for d
:= 0 to High(gPlayers
) do
244 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
245 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
246 if not InWArray(d
, pl
) then
254 if gMonsters
<> nil then
256 for d
:= 0 to High(gMonsters
) do
257 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
258 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
259 if not InWArray(d
, mn
) then
270 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
274 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
281 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
288 tt
:= g_GetUIDType(SpawnerUID
);
289 if tt
= UID_MONSTER
then
291 mon
:= g_Monsters_Get(SpawnerUID
);
293 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
300 if m
= nil then Exit
;
301 if m
.UID
= SpawnerUID
then
303 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
304 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
306 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
307 if (m
.MonsterType
= MONSTER_CYBER
) or
308 (m
.MonsterType
= MONSTER_BARREL
) then
315 if tt
= UID_MONSTER
then
317 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
318 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
321 // Îáà ìîíñòðà îäíîãî âèäà:
322 if mt
= m
.MonsterType
then
324 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
325 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
326 Exit
; // Ýòè íå áüþò ñâîèõ
330 if g_Game_IsServer
then
331 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
336 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
340 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
341 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
344 if g_Game_IsServer
then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
349 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
350 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
360 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
361 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
363 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
367 if Result
<> 0 then Exit
;
369 h
:= High(gMonsters
);
373 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
374 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
376 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
382 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
389 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
393 if gAdvCorpses
and (h
<> -1) then
395 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
397 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
398 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
399 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
400 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
403 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
404 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
408 pl
:= g_Player_Get(SpawnerUID
);
416 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
418 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
419 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
420 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
421 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
423 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
424 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
426 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
428 gPlayers
[i
].BFGHit();
431 h
:= High(gMonsters
);
435 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
437 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
438 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
439 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
440 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
441 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
444 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
446 find_id
, FramesID
: DWORD
;
449 find_id
:= FindShot()
453 if Integer(find_id
) >= High(Shots
) then
454 SetLength(Shots
, find_id
+ 64)
458 WEAPON_ROCKETLAUNCHER
:
460 with Shots
[find_id
] do
464 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
465 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
469 ShotType
:= WEAPON_ROCKETLAUNCHER
;
470 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
476 with Shots
[find_id
] do
480 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
481 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
484 ShotType
:= WEAPON_PLASMA
;
485 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
486 Animation
:= TAnimation
.Create(FramesID
, True, 5);
492 with Shots
[find_id
] do
496 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
497 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
500 ShotType
:= WEAPON_BFG
;
501 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
502 Animation
:= TAnimation
.Create(FramesID
, True, 6);
508 with Shots
[find_id
] do
512 Obj
.Rect
.Width
:= 16;
513 Obj
.Rect
.Height
:= 16;
516 ShotType
:= WEAPON_IMP_FIRE
;
517 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
518 Animation
:= TAnimation
.Create(FramesID
, True, 4);
524 with Shots
[find_id
] do
528 Obj
.Rect
.Width
:= 16;
529 Obj
.Rect
.Height
:= 16;
532 ShotType
:= WEAPON_CACO_FIRE
;
533 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
534 Animation
:= TAnimation
.Create(FramesID
, True, 4);
540 with Shots
[find_id
] do
544 Obj
.Rect
.Width
:= 32;
545 Obj
.Rect
.Height
:= 32;
548 ShotType
:= WEAPON_MANCUB_FIRE
;
549 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
550 Animation
:= TAnimation
.Create(FramesID
, True, 4);
556 with Shots
[find_id
] do
560 Obj
.Rect
.Width
:= 32;
561 Obj
.Rect
.Height
:= 16;
564 ShotType
:= WEAPON_BARON_FIRE
;
565 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
566 Animation
:= TAnimation
.Create(FramesID
, True, 4);
572 with Shots
[find_id
] do
576 Obj
.Rect
.Width
:= 16;
577 Obj
.Rect
.Height
:= 16;
580 ShotType
:= WEAPON_BSP_FIRE
;
581 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
582 Animation
:= TAnimation
.Create(FramesID
, True, 4);
588 with Shots
[find_id
] do
592 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
593 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
596 ShotType
:= WEAPON_SKEL_FIRE
;
598 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
599 Animation
:= TAnimation
.Create(FramesID
, True, 5);
604 Shots
[find_id
].Obj
.X
:= X
;
605 Shots
[find_id
].Obj
.Y
:= Y
;
606 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
607 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
608 Shots
[find_id
].Obj
.Accel
.X
:= 0;
609 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
610 Shots
[find_id
].SpawnerUID
:= Spawner
;
614 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
621 a
:= Max(Abs(xd
), Abs(yd
));
627 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
628 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
629 Shots
[i
].Obj
.Accel
.X
:= 0;
630 Shots
[i
].Obj
.Accel
.Y
:= 0;
631 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
632 Shots
[i
].Timeout
:= 900 // ~25 sec
634 Shots
[i
].Timeout
:= 550 // ~15 sec
637 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
641 function PlayerHit(Team
: Byte = 0): Boolean;
652 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
655 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
657 p
:= g_Player_Get(SpawnerUID
);
659 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
662 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
664 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
665 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
667 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
673 function MonsterHit(): Boolean;
678 h
:= High(gMonsters
);
682 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
683 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
685 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
686 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
698 if gAdvCorpses
and (h
<> -1) then
700 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
701 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
704 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
705 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
710 case gGameSettings
.GameMode
of
714 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
731 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
748 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
762 // È â êîíöå ñâîèõ èãðîêîâ
773 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
777 case g_GetUIDType(UID
) of
778 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
779 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
784 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
786 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
791 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
799 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
802 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
803 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
805 if dx
> 1000 then dx
:= 1000;
806 if dy
> 1000 then dy
:= 1000;
808 if dx
*dx
+dy
*dy
< r
then
810 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
811 // PLAYER_RECT.Width, PLAYER_RECT.Height);
813 mm
:= Max(abs(dx
), abs(dy
));
814 if mm
= 0 then mm
:= 1;
816 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
817 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
821 h
:= High(gMonsters
);
825 if gMonsters
[i
] <> nil then
828 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
829 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
831 if dx
> 1000 then dx
:= 1000;
832 if dy
> 1000 then dy
:= 1000;
834 if dx
*dx
+dy
*dy
< r
then
836 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
837 // Obj.Rect.Width, Obj.Rect.Height);
839 mm
:= Max(abs(dx
), abs(dy
));
840 if mm
= 0 then mm
:= 1;
842 if gMonsters
[i
].Live
then
843 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
844 0, 0, SpawnerUID
, HIT_ROCKET
);
846 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
852 if gAdvCorpses
and (h
<> -1) then
854 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
857 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
858 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
860 if dx
> 1000 then dx
:= 1000;
861 if dy
> 1000 then dy
:= 1000;
863 if dx
*dx
+dy
*dy
< r
then
865 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
866 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
868 mm
:= Max(abs(dx
), abs(dy
));
869 if mm
= 0 then mm
:= 1;
871 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
877 if gAdvGibs
and (h
<> -1) then
879 if gGibs
[i
].Live
then
882 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
883 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
885 if dx
> 1000 then dx
:= 1000;
886 if dy
> 1000 then dy
:= 1000;
888 if dx
*dx
+dy
*dy
< r
then
890 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
891 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
892 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
893 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
895 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
900 procedure g_Weapon_Init();
905 procedure g_Weapon_Free();
911 for i
:= 0 to High(Shots
) do
912 if Shots
[i
].ShotType
<> 0 then
913 Shots
[i
].Animation
.Free();
921 procedure g_Weapon_LoadData();
923 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
925 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
926 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
927 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
928 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
929 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
930 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
931 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
932 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
933 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
934 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
935 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
936 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
937 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
938 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
939 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
940 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
941 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
942 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
943 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
944 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
945 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
946 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
947 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
948 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
949 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
950 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
951 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
952 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
953 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
954 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
955 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
956 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
958 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
959 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
960 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
961 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
962 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
963 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
964 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
965 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
966 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
967 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
968 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
969 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
970 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
971 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
972 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
973 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
974 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
975 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
976 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
977 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
979 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
980 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
983 procedure g_Weapon_FreeData();
985 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
987 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
988 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
989 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
990 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
991 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
992 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
993 g_Sound_Delete('SOUND_WEAPON_HITSAW');
994 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
995 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
996 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
997 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
998 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
999 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1000 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1001 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1002 g_Sound_Delete('SOUND_FIRE');
1003 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1004 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1005 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1006 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1007 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1008 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1009 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1010 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1011 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1012 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1013 g_Sound_Delete('SOUND_PLAYER_JETON');
1014 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1015 g_Sound_Delete('SOUND_PLAYER_CASING1');
1016 g_Sound_Delete('SOUND_PLAYER_CASING2');
1017 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1018 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1020 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1021 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1022 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1023 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1024 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1025 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1026 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1027 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1028 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1029 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1030 g_Frames_DeleteByName('FRAMES_BFGHIT');
1031 g_Frames_DeleteByName('FRAMES_FIRE');
1032 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1033 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1034 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1035 g_Frames_DeleteByName('FRAMES_SMOKE');
1036 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1037 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1040 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1052 t1
, _collide
: Boolean;
1055 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1057 SinCos(DegToRad(-a
), s
, c
);
1059 if Abs(s
) < 0.01 then s
:= 0;
1060 if Abs(c
) < 0.01 then c
:= 0;
1062 x2
:= x
+Round(c
*gMapInfo
.Width
);
1063 y2
:= y
+Round(s
*gMapInfo
.Width
);
1065 t1
:= gWalls
<> nil;
1067 w
:= gMapInfo
.Width
;
1068 h
:= gMapInfo
.Height
;
1075 if (xd
= 0) and (yd
= 0) then Exit
;
1077 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1078 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1083 if dx
> dy
then d
:= dx
else d
:= dy
;
1085 //blood vel, for Monster.Damage()
1086 //vx := (dx*10 div d)*xi;
1087 //vy := (dy*10 div d)*yi;
1109 if (yy
> h
) or (yy
< 0) then Break
;
1110 if (xx
> w
) or (xx
< 0) then Break
;
1113 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1116 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1117 if g_Game_IsServer
and g_Game_IsNet
then
1118 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1121 if not _collide
then
1122 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1128 if CheckTrigger
and g_Game_IsServer
then
1129 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1132 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1140 obj
.rect
.Width
:= 39;
1141 obj
.rect
.Height
:= 52;
1147 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1148 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1150 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1153 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1161 obj
.rect
.Width
:= 32;
1162 obj
.rect
.Height
:= 52;
1168 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1171 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1172 Silent
: Boolean = False);
1178 find_id
:= FindShot()
1182 if Integer(find_id
) >= High(Shots
) then
1183 SetLength(Shots
, find_id
+ 64)
1186 with Shots
[find_id
] do
1190 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1191 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1193 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1194 dy
:= -(Obj
.Rect
.Height
div 2);
1195 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1199 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1200 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1203 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1206 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1209 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1210 WID
: Integer = -1; Silent
: Boolean = False);
1212 find_id
, FramesID
: DWORD
;
1216 find_id
:= FindShot()
1220 if Integer(find_id
) >= High(Shots
) then
1221 SetLength(Shots
, find_id
+ 64)
1224 with Shots
[find_id
] do
1228 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1229 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1231 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1232 dy
:= -(Obj
.Rect
.Height
div 2);
1233 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1236 ShotType
:= WEAPON_SKEL_FIRE
;
1237 target
:= TargetUID
;
1238 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1239 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1242 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1245 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1248 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1249 Silent
: Boolean = False);
1251 find_id
, FramesID
: DWORD
;
1255 find_id
:= FindShot()
1259 if Integer(find_id
) >= High(Shots
) then
1260 SetLength(Shots
, find_id
+ 64);
1263 with Shots
[find_id
] do
1267 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1268 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1270 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1271 dy
:= -(Obj
.Rect
.Height
div 2);
1272 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1275 ShotType
:= WEAPON_PLASMA
;
1276 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1277 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1280 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1283 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1286 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1287 Silent
: Boolean = False);
1289 find_id
, FramesID
: DWORD
;
1293 find_id
:= FindShot()
1297 if Integer(find_id
) >= High(Shots
) then
1298 SetLength(Shots
, find_id
+ 64)
1301 with Shots
[find_id
] do
1305 Obj
.Rect
.Width
:= 16;
1306 Obj
.Rect
.Height
:= 16;
1308 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1309 dy
:= -(Obj
.Rect
.Height
div 2);
1310 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1313 ShotType
:= WEAPON_IMP_FIRE
;
1314 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1315 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1318 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1321 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1324 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1325 Silent
: Boolean = False);
1327 find_id
, FramesID
: DWORD
;
1331 find_id
:= FindShot()
1335 if Integer(find_id
) >= High(Shots
) then
1336 SetLength(Shots
, find_id
+ 64)
1339 with Shots
[find_id
] do
1343 Obj
.Rect
.Width
:= 16;
1344 Obj
.Rect
.Height
:= 16;
1346 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1347 dy
:= -(Obj
.Rect
.Height
div 2);
1348 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1351 ShotType
:= WEAPON_CACO_FIRE
;
1352 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1353 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1356 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1359 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1362 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1363 Silent
: Boolean = False);
1365 find_id
, FramesID
: DWORD
;
1369 find_id
:= FindShot()
1373 if Integer(find_id
) >= High(Shots
) then
1374 SetLength(Shots
, find_id
+ 64)
1377 with Shots
[find_id
] do
1381 Obj
.Rect
.Width
:= 32;
1382 Obj
.Rect
.Height
:= 16;
1384 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1385 dy
:= -(Obj
.Rect
.Height
div 2);
1386 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1389 ShotType
:= WEAPON_BARON_FIRE
;
1390 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1391 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1394 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1397 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1400 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1401 Silent
: Boolean = False);
1403 find_id
, FramesID
: DWORD
;
1407 find_id
:= FindShot()
1411 if Integer(find_id
) >= High(Shots
) then
1412 SetLength(Shots
, find_id
+ 64)
1415 with Shots
[find_id
] do
1419 Obj
.Rect
.Width
:= 16;
1420 Obj
.Rect
.Height
:= 16;
1422 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1423 dy
:= -(Obj
.Rect
.Height
div 2);
1424 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1427 ShotType
:= WEAPON_BSP_FIRE
;
1428 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1429 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1432 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1435 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1438 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1439 Silent
: Boolean = False);
1441 find_id
, FramesID
: DWORD
;
1445 find_id
:= FindShot()
1449 if Integer(find_id
) >= High(Shots
) then
1450 SetLength(Shots
, find_id
+ 64)
1453 with Shots
[find_id
] do
1457 Obj
.Rect
.Width
:= 32;
1458 Obj
.Rect
.Height
:= 32;
1460 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1461 dy
:= -(Obj
.Rect
.Height
div 2);
1462 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1465 ShotType
:= WEAPON_MANCUB_FIRE
;
1466 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1467 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1470 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1473 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1476 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1477 Silent
: Boolean = False);
1479 find_id
, FramesID
: DWORD
;
1483 find_id
:= FindShot()
1487 if Integer(find_id
) >= High(Shots
) then
1488 SetLength(Shots
, find_id
+ 64)
1491 with Shots
[find_id
] do
1495 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1496 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1498 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1499 dy
:= -(Obj
.Rect
.Height
div 2);
1500 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1503 ShotType
:= WEAPON_BFG
;
1504 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1505 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1508 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1511 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1514 procedure g_Weapon_bfghit(x
, y
: Integer);
1519 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1521 Anim
:= TAnimation
.Create(ID
, False, 4);
1522 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1527 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1528 Silent
: Boolean = False);
1531 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1533 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1534 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1536 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1537 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1541 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1542 Silent
: Boolean = False);
1545 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1547 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1548 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1549 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1551 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1552 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1556 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1557 Silent
: Boolean = False);
1562 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1566 j
:= Random(17)-8; // -8 .. 8
1567 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1571 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1572 Silent
: Boolean = False);
1577 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1579 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1582 j
:= Random(41)-20; // -20 .. 20
1583 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1587 procedure g_Weapon_Update();
1589 i
, a
, h
, cx
, cy
, oldvx
, oldvy
: Integer;
1602 for i
:= 0 to High(Shots
) do
1604 if Shots
[i
].ShotType
= 0 then
1611 Timeout
:= Timeout
- 1;
1614 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1615 if g_Game_IsServer
then
1616 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1617 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1623 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1624 if triggers
= nil then
1631 if not InDWArray(t
[a
], triggers
) then
1633 SetLength(triggers
, Length(triggers
)+1);
1634 triggers
[High(triggers
)] := t
[a
];
1639 // Àíèìàöèÿ ñíàðÿäà:
1640 if Animation
<> nil then
1644 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1645 (ShotType
<> WEAPON_BFG
) and
1646 (ShotType
<> WEAPON_BSP_FIRE
);
1648 st
:= g_Obj_Move(@Obj
, False, spl
);
1650 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1651 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1653 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1659 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1660 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1663 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1665 // Âûëåòåëà èç âîäû:
1666 if WordBool(st
and MOVE_HITAIR
) then
1667 g_Obj_SetSpeed(@Obj
, 12);
1669 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1670 if WordBool(st
and MOVE_INWATER
) then
1671 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1672 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1673 1+Random(3), 16, 16)
1675 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1677 Anim
:= TAnimation
.Create(_id
, False, 3);
1679 g_GFX_OnceAnim(Obj
.X
-8+Random(9),
1680 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1681 Anim
, ONCEANIM_SMOKE
);
1685 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1686 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1687 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1693 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1695 if ShotType
= WEAPON_SKEL_FIRE
then
1696 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1697 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1699 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1700 Anim
.Blending
:= False;
1701 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
1706 begin // Âçðûâ Ðàêåòû
1707 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1709 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1710 Anim
.Blending
:= False;
1711 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1716 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1721 if ShotType
= WEAPON_SKEL_FIRE
then
1722 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1723 if GetPos(target
, @o
) then
1724 throw(i
, Obj
.X
, Obj
.Y
,
1725 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1726 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1731 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1733 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1734 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1736 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1737 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1743 if (ShotType
= WEAPON_PLASMA
) and
1744 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1749 if ShotType
= WEAPON_BSP_FIRE
then
1752 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1753 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1754 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1757 if ShotType
= WEAPON_PLASMA
then
1758 s
:= 'FRAMES_EXPLODE_PLASMA'
1760 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1763 if g_Frames_Get(TextureID
, s
) then
1765 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1766 Anim
.Blending
:= False;
1767 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1771 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1779 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1780 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1782 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1783 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1788 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1789 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1790 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
1794 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
1797 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
1799 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1800 Anim
.Blending
:= False;
1801 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1805 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
1811 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1814 if WordBool(st
and MOVE_HITAIR
) then
1815 g_Obj_SetSpeed(@Obj
, 16);
1818 if ShotType
= WEAPON_IMP_FIRE
then
1821 if ShotType
= WEAPON_CACO_FIRE
then
1826 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1827 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1828 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
1831 if ShotType
= WEAPON_IMP_FIRE
then
1832 s
:= 'FRAMES_EXPLODE_IMPFIRE'
1834 if ShotType
= WEAPON_CACO_FIRE
then
1835 s
:= 'FRAMES_EXPLODE_CACOFIRE'
1837 s
:= 'FRAMES_EXPLODE_BARONFIRE';
1840 if g_Frames_Get(TextureID
, s
) then
1842 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1843 Anim
.Blending
:= False;
1844 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
1848 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1854 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
1857 if WordBool(st
and MOVE_HITAIR
) then
1858 g_Obj_SetSpeed(@Obj
, 16);
1860 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1861 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1862 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
1866 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1868 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1869 Anim
.Blending
:= False;
1870 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1874 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1879 end; // case ShotType of...
1881 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
1882 if (ShotType
= 0) then
1884 if gGameSettings
.GameType
= GT_SERVER
then
1885 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
1889 else if (oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
) then
1890 if gGameSettings
.GameType
= GT_SERVER
then
1891 MH_SEND_UpdateShot(i
);
1896 procedure g_Weapon_Draw();
1905 for i
:= 0 to High(Shots
) do
1906 if Shots
[i
].ShotType
<> 0 then
1909 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
1910 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1911 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1912 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1913 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
1917 p
.X
:= Obj
.Rect
.Width
div 2;
1918 p
.Y
:= Obj
.Rect
.Height
div 2;
1920 if Animation
<> nil then
1922 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1923 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1924 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1925 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
1927 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
1931 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
1932 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
1934 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
1937 if g_debug_Frames
then
1939 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
1941 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
1942 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
1948 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
1957 for a
:= 0 to High(Shots
) do
1958 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
1959 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
1960 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
1961 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
1962 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
1963 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
1964 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
1971 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
1973 count
, i
, j
: Integer;
1976 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
1978 if Shots
<> nil then
1979 for i
:= 0 to High(Shots
) do
1980 if Shots
[i
].ShotType
<> 0 then
1983 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
1985 // Êîëè÷åñòâî ñíàðÿäîâ:
1986 Mem
.WriteInt(count
);
1991 for i
:= 0 to High(Shots
) do
1992 if Shots
[i
].ShotType
<> 0 then
1994 // Ñèãíàòóðà ñíàðÿäà:
1995 dw
:= SHOT_SIGNATURE
; // 'SHOT'
1998 Mem
.WriteByte(Shots
[i
].ShotType
);
2000 Mem
.WriteWord(Shots
[i
].Target
);
2002 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2003 // Ðàçìåð ïîëÿ Triggers:
2004 dw
:= Length(Shots
[i
].Triggers
);
2006 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2007 for j
:= 0 to Integer(dw
)-1 do
2008 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2010 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2014 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2016 count
, i
, j
: Integer;
2022 // Êîëè÷åñòâî ñíàðÿäîâ:
2025 SetLength(Shots
, count
);
2030 for i
:= 0 to count
-1 do
2032 // Ñèãíàòóðà ñíàðÿäà:
2034 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2036 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2039 Mem
.ReadByte(Shots
[i
].ShotType
);
2041 Mem
.ReadWord(Shots
[i
].Target
);
2043 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2044 // Ðàçìåð ïîëÿ Triggers:
2046 SetLength(Shots
[i
].Triggers
, dw
);
2047 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2048 for j
:= 0 to Integer(dw
)-1 do
2049 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2051 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2053 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2054 Shots
[i
].TextureID
:= DWORD(-1);
2055 Shots
[i
].Animation
:= nil;
2057 case Shots
[i
].ShotType
of
2058 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2060 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2064 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2065 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2069 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2070 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2074 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2075 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2079 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2080 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2084 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2085 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2089 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2090 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2094 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2095 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2101 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2109 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2113 if ShotType
= 0 then Exit
;
2116 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2117 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2120 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2124 if ShotType
= WEAPON_SKEL_FIRE
then
2125 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2126 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2128 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2129 Anim
.Blending
:= False;
2130 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2135 begin // Âçðûâ Ðàêåòû
2136 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2138 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2139 Anim
.Blending
:= False;
2140 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2144 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2148 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2150 if ShotType
= WEAPON_PLASMA
then
2151 s
:= 'FRAMES_EXPLODE_PLASMA'
2153 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2155 if g_Frames_Get(TextureID
, s
) and loud
then
2157 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2158 Anim
.Blending
:= False;
2159 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2162 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2169 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2171 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2172 Anim
.Blending
:= False;
2173 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2176 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2180 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2182 if ShotType
= WEAPON_IMP_FIRE
then
2183 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2185 if ShotType
= WEAPON_CACO_FIRE
then
2186 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2188 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2190 if g_Frames_Get(TextureID
, s
) and Loud
then
2192 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2193 Anim
.Blending
:= False;
2194 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2197 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2201 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2203 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2205 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2206 Anim
.Blending
:= False;
2207 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2210 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2213 end; // case ShotType of...