1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
44 Animation
: TAnimation
;
50 Shots
: array of TShot
= nil;
51 LastShotID
: Integer = 0;
53 procedure g_Weapon_LoadData();
54 procedure g_Weapon_FreeData();
55 procedure g_Weapon_Init();
56 procedure g_Weapon_Free();
57 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
58 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
59 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
61 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
62 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
63 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
64 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
65 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
66 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
67 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
68 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
69 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
70 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
71 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
72 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
73 procedure g_Weapon_bfghit(x
, y
: Integer);
74 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
75 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
76 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
77 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
79 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
80 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
81 procedure g_Weapon_Update();
82 procedure g_Weapon_Draw();
83 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
84 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
86 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
87 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
96 WEAPON_ROCKETLAUNCHER
= 6;
99 WEAPON_SUPERPULEMET
= 9;
100 WEAPON_MEGAKASTET
= 10;
101 WEAPON_ZOMBY_PISTOL
= 20;
102 WEAPON_IMP_FIRE
= 21;
103 WEAPON_BSP_FIRE
= 22;
104 WEAPON_CACO_FIRE
= 23;
105 WEAPON_BARON_FIRE
= 24;
106 WEAPON_MANCUB_FIRE
= 25;
107 WEAPON_SKEL_FIRE
= 26;
109 WP_FIRST
= WEAPON_KASTET
;
110 WP_LAST
= WEAPON_SUPERPULEMET
;
115 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
116 g_console
, SysUtils
, g_options
, g_game
,
117 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
118 g_language
, g_netmsg
;
128 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
129 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
131 SHOT_SKELFIRE_WIDTH
= 14;
132 SHOT_SKELFIRE_HEIGHT
= 14;
134 SHOT_PLASMA_WIDTH
= 16;
135 SHOT_PLASMA_HEIGHT
= 16;
138 SHOT_BFG_HEIGHT
= 32;
139 SHOT_BFG_DAMAGE
= 100;
140 SHOT_BFG_RADIUS
= 256;
142 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
145 WaterMap
: array of array of DWORD
= nil;
147 function FindShot(): DWORD
;
152 for i
:= 0 to High(Shots
) do
153 if Shots
[i
].ShotType
= 0 then
156 LastShotID
:= Result
;
162 SetLength(Shots
, 128);
167 Result
:= High(Shots
) + 1;
168 SetLength(Shots
, Length(Shots
) + 128);
170 LastShotID
:= Result
;
173 procedure CreateWaterMap();
175 WaterArray
: Array of TWaterPanel
;
182 SetLength(WaterArray
, Length(gWater
));
184 for a
:= 0 to High(gWater
) do
186 WaterArray
[a
].X
:= gWater
[a
].X
;
187 WaterArray
[a
].Y
:= gWater
[a
].Y
;
188 WaterArray
[a
].Width
:= gWater
[a
].Width
;
189 WaterArray
[a
].Height
:= gWater
[a
].Height
;
190 WaterArray
[a
].Active
:= True;
193 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
195 for a
:= 0 to High(WaterArray
) do
196 if WaterArray
[a
].Active
then
198 WaterArray
[a
].Active
:= False;
199 m
:= Length(WaterMap
);
200 SetLength(WaterMap
, m
+1);
201 SetLength(WaterMap
[m
], 1);
208 for b
:= 0 to High(WaterArray
) do
209 if WaterArray
[b
].Active
then
210 for c
:= 0 to High(WaterMap
[m
]) do
211 if g_CollideAround(WaterArray
[b
].X
,
214 WaterArray
[b
].Height
,
215 WaterArray
[WaterMap
[m
][c
]].X
,
216 WaterArray
[WaterMap
[m
][c
]].Y
,
217 WaterArray
[WaterMap
[m
][c
]].Width
,
218 WaterArray
[WaterMap
[m
][c
]].Height
) then
220 WaterArray
[b
].Active
:= False;
221 SetLength(WaterMap
[m
],
222 Length(WaterMap
[m
])+1);
223 WaterMap
[m
][High(WaterMap
[m
])] := b
;
229 g_Game_StepLoading();
235 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
237 a
, b
, c
, d
, i1
, i2
: Integer;
240 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
247 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
248 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
250 for a
:= 0 to High(WaterMap
) do
251 for b
:= 0 to High(WaterMap
[a
]) do
253 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
254 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
255 @Shots
[ID
].Obj
) then Continue
;
257 for c
:= 0 to High(WaterMap
[a
]) do
259 if gPlayers
<> nil then
261 for d
:= 0 to High(gPlayers
) do
262 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
263 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
264 if not InWArray(d
, pl
) then
272 if gMonsters
<> nil then
274 for d
:= 0 to High(gMonsters
) do
275 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
276 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
277 if not InWArray(d
, mn
) then
288 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
292 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
299 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
306 tt
:= g_GetUIDType(SpawnerUID
);
307 if tt
= UID_MONSTER
then
309 mon
:= g_Monsters_Get(SpawnerUID
);
311 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
318 if m
= nil then Exit
;
319 if m
.UID
= SpawnerUID
then
321 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
322 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
324 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
325 if (m
.MonsterType
= MONSTER_CYBER
) or
326 (m
.MonsterType
= MONSTER_BARREL
) then
333 if tt
= UID_MONSTER
then
335 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
336 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
339 // Îáà ìîíñòðà îäíîãî âèäà:
340 if mt
= m
.MonsterType
then
342 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
343 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
344 Exit
; // Ýòè íå áüþò ñâîèõ
348 if g_Game_IsServer
then
349 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
354 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
358 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
359 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
362 if g_Game_IsServer
then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
367 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
368 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
378 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
379 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
381 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
385 if Result
<> 0 then Exit
;
387 h
:= High(gMonsters
);
391 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
392 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
394 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
400 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
407 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
411 if gAdvCorpses
and (h
<> -1) then
413 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
415 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
416 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
417 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
418 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
421 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
422 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
426 pl
:= g_Player_Get(SpawnerUID
);
434 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
436 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
437 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
438 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
439 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
441 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
442 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
444 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
446 gPlayers
[i
].BFGHit();
449 h
:= High(gMonsters
);
453 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
455 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
456 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
457 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
458 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
459 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
462 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
464 find_id
, FramesID
: DWORD
;
467 find_id
:= FindShot()
471 if Integer(find_id
) >= High(Shots
) then
472 SetLength(Shots
, find_id
+ 64)
476 WEAPON_ROCKETLAUNCHER
:
478 with Shots
[find_id
] do
482 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
483 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
487 ShotType
:= WEAPON_ROCKETLAUNCHER
;
488 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
494 with Shots
[find_id
] do
498 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
499 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
502 ShotType
:= WEAPON_PLASMA
;
503 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
504 Animation
:= TAnimation
.Create(FramesID
, True, 5);
510 with Shots
[find_id
] do
514 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
515 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
518 ShotType
:= WEAPON_BFG
;
519 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
520 Animation
:= TAnimation
.Create(FramesID
, True, 6);
526 with Shots
[find_id
] do
530 Obj
.Rect
.Width
:= 16;
531 Obj
.Rect
.Height
:= 16;
534 ShotType
:= WEAPON_IMP_FIRE
;
535 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
536 Animation
:= TAnimation
.Create(FramesID
, True, 4);
542 with Shots
[find_id
] do
546 Obj
.Rect
.Width
:= 16;
547 Obj
.Rect
.Height
:= 16;
550 ShotType
:= WEAPON_CACO_FIRE
;
551 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
552 Animation
:= TAnimation
.Create(FramesID
, True, 4);
558 with Shots
[find_id
] do
562 Obj
.Rect
.Width
:= 32;
563 Obj
.Rect
.Height
:= 32;
566 ShotType
:= WEAPON_MANCUB_FIRE
;
567 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
568 Animation
:= TAnimation
.Create(FramesID
, True, 4);
574 with Shots
[find_id
] do
578 Obj
.Rect
.Width
:= 32;
579 Obj
.Rect
.Height
:= 16;
582 ShotType
:= WEAPON_BARON_FIRE
;
583 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
584 Animation
:= TAnimation
.Create(FramesID
, True, 4);
590 with Shots
[find_id
] do
594 Obj
.Rect
.Width
:= 16;
595 Obj
.Rect
.Height
:= 16;
598 ShotType
:= WEAPON_BSP_FIRE
;
599 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
600 Animation
:= TAnimation
.Create(FramesID
, True, 4);
606 with Shots
[find_id
] do
610 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
611 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
614 ShotType
:= WEAPON_SKEL_FIRE
;
616 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
617 Animation
:= TAnimation
.Create(FramesID
, True, 5);
622 Shots
[find_id
].Obj
.X
:= X
;
623 Shots
[find_id
].Obj
.Y
:= Y
;
624 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
625 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
626 Shots
[find_id
].Obj
.Accel
.X
:= 0;
627 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
628 Shots
[find_id
].SpawnerUID
:= Spawner
;
632 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
639 a
:= Max(Abs(xd
), Abs(yd
));
645 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
646 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
647 Shots
[i
].Obj
.Accel
.X
:= 0;
648 Shots
[i
].Obj
.Accel
.Y
:= 0;
649 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
650 Shots
[i
].Timeout
:= 900 // ~25 sec
652 Shots
[i
].Timeout
:= 550 // ~15 sec
655 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
659 function PlayerHit(Team
: Byte = 0): Boolean;
670 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
673 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
675 p
:= g_Player_Get(SpawnerUID
);
677 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
680 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
682 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
683 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
685 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
691 function MonsterHit(): Boolean;
696 h
:= High(gMonsters
);
700 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
701 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
703 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
704 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
716 if gAdvCorpses
and (h
<> -1) then
718 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
719 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
722 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
723 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
728 case gGameSettings
.GameMode
of
732 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
749 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
766 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
780 // È â êîíöå ñâîèõ èãðîêîâ
791 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
795 case g_GetUIDType(UID
) of
796 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
797 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
802 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
804 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
809 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
817 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
820 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
821 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
823 if dx
> 1000 then dx
:= 1000;
824 if dy
> 1000 then dy
:= 1000;
826 if dx
*dx
+dy
*dy
< r
then
828 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
829 // PLAYER_RECT.Width, PLAYER_RECT.Height);
831 mm
:= Max(abs(dx
), abs(dy
));
832 if mm
= 0 then mm
:= 1;
834 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
835 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
839 h
:= High(gMonsters
);
843 if gMonsters
[i
] <> nil then
846 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
847 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
849 if dx
> 1000 then dx
:= 1000;
850 if dy
> 1000 then dy
:= 1000;
852 if dx
*dx
+dy
*dy
< r
then
854 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
855 // Obj.Rect.Width, Obj.Rect.Height);
857 mm
:= Max(abs(dx
), abs(dy
));
858 if mm
= 0 then mm
:= 1;
860 if gMonsters
[i
].Live
then
861 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
862 0, 0, SpawnerUID
, HIT_ROCKET
);
864 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
870 if gAdvCorpses
and (h
<> -1) then
872 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
875 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
876 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
878 if dx
> 1000 then dx
:= 1000;
879 if dy
> 1000 then dy
:= 1000;
881 if dx
*dx
+dy
*dy
< r
then
883 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
884 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
886 mm
:= Max(abs(dx
), abs(dy
));
887 if mm
= 0 then mm
:= 1;
889 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
895 if gAdvGibs
and (h
<> -1) then
897 if gGibs
[i
].Live
then
900 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
901 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
903 if dx
> 1000 then dx
:= 1000;
904 if dy
> 1000 then dy
:= 1000;
906 if dx
*dx
+dy
*dy
< r
then
908 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
909 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
910 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
911 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
913 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
918 procedure g_Weapon_Init();
923 procedure g_Weapon_Free();
929 for i
:= 0 to High(Shots
) do
930 if Shots
[i
].ShotType
<> 0 then
931 Shots
[i
].Animation
.Free();
939 procedure g_Weapon_LoadData();
941 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
943 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
944 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
945 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
946 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
947 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
948 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
949 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
950 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
951 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
952 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
953 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
954 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
955 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
956 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
957 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
958 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
959 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
960 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
961 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
962 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
963 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
964 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
965 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
966 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
967 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
968 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
969 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
970 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
971 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
972 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
973 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
974 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
976 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
977 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
978 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
979 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
980 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
981 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
982 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
983 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
984 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
985 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
986 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
987 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
988 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
989 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
990 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
991 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
992 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
993 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
994 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
995 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
997 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
998 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1001 procedure g_Weapon_FreeData();
1003 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1005 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1006 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1007 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1008 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1009 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1010 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1011 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1012 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1013 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1014 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1015 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1016 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1017 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1018 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1019 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1020 g_Sound_Delete('SOUND_FIRE');
1021 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1022 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1023 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1024 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1025 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1026 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1027 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1028 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1029 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1030 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1031 g_Sound_Delete('SOUND_PLAYER_JETON');
1032 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1033 g_Sound_Delete('SOUND_PLAYER_CASING1');
1034 g_Sound_Delete('SOUND_PLAYER_CASING2');
1035 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1036 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1038 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1039 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1040 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1041 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1042 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1043 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1044 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1045 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1046 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1047 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1048 g_Frames_DeleteByName('FRAMES_BFGHIT');
1049 g_Frames_DeleteByName('FRAMES_FIRE');
1050 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1051 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1052 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1053 g_Frames_DeleteByName('FRAMES_SMOKE');
1054 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1055 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1058 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1070 t1
, _collide
: Boolean;
1073 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1075 SinCos(DegToRad(-a
), s
, c
);
1077 if Abs(s
) < 0.01 then s
:= 0;
1078 if Abs(c
) < 0.01 then c
:= 0;
1080 x2
:= x
+Round(c
*gMapInfo
.Width
);
1081 y2
:= y
+Round(s
*gMapInfo
.Width
);
1083 t1
:= gWalls
<> nil;
1085 w
:= gMapInfo
.Width
;
1086 h
:= gMapInfo
.Height
;
1093 if (xd
= 0) and (yd
= 0) then Exit
;
1095 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1096 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1101 if dx
> dy
then d
:= dx
else d
:= dy
;
1103 //blood vel, for Monster.Damage()
1104 //vx := (dx*10 div d)*xi;
1105 //vy := (dy*10 div d)*yi;
1127 if (yy
> h
) or (yy
< 0) then Break
;
1128 if (xx
> w
) or (xx
< 0) then Break
;
1131 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1134 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1135 if g_Game_IsServer
and g_Game_IsNet
then
1136 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1139 if not _collide
then
1140 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1146 if CheckTrigger
and g_Game_IsServer
then
1147 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1150 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1158 obj
.rect
.Width
:= 39;
1159 obj
.rect
.Height
:= 52;
1165 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1166 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1168 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1171 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1179 obj
.rect
.Width
:= 32;
1180 obj
.rect
.Height
:= 52;
1186 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1189 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1190 Silent
: Boolean = False);
1196 find_id
:= FindShot()
1200 if Integer(find_id
) >= High(Shots
) then
1201 SetLength(Shots
, find_id
+ 64)
1204 with Shots
[find_id
] do
1208 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1209 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1211 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1212 dy
:= -(Obj
.Rect
.Height
div 2);
1213 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1217 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1218 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1221 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1224 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1227 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1228 WID
: Integer = -1; Silent
: Boolean = False);
1230 find_id
, FramesID
: DWORD
;
1234 find_id
:= FindShot()
1238 if Integer(find_id
) >= High(Shots
) then
1239 SetLength(Shots
, find_id
+ 64)
1242 with Shots
[find_id
] do
1246 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1247 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1249 dx
:= -(Obj
.Rect
.Width
div 2);
1250 dy
:= -(Obj
.Rect
.Height
div 2);
1251 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1254 ShotType
:= WEAPON_SKEL_FIRE
;
1255 target
:= TargetUID
;
1256 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1257 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1260 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1263 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1266 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1267 Silent
: Boolean = False);
1269 find_id
, FramesID
: DWORD
;
1273 find_id
:= FindShot()
1277 if Integer(find_id
) >= High(Shots
) then
1278 SetLength(Shots
, find_id
+ 64);
1281 with Shots
[find_id
] do
1285 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1286 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1288 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1289 dy
:= -(Obj
.Rect
.Height
div 2);
1290 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1293 ShotType
:= WEAPON_PLASMA
;
1294 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1295 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1298 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1301 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1304 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1305 Silent
: Boolean = False);
1307 find_id
, FramesID
: DWORD
;
1311 find_id
:= FindShot()
1315 if Integer(find_id
) >= High(Shots
) then
1316 SetLength(Shots
, find_id
+ 64)
1319 with Shots
[find_id
] do
1323 Obj
.Rect
.Width
:= 16;
1324 Obj
.Rect
.Height
:= 16;
1326 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1327 dy
:= -(Obj
.Rect
.Height
div 2);
1328 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1331 ShotType
:= WEAPON_IMP_FIRE
;
1332 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1333 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1336 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1339 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1342 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1343 Silent
: Boolean = False);
1345 find_id
, FramesID
: DWORD
;
1349 find_id
:= FindShot()
1353 if Integer(find_id
) >= High(Shots
) then
1354 SetLength(Shots
, find_id
+ 64)
1357 with Shots
[find_id
] do
1361 Obj
.Rect
.Width
:= 16;
1362 Obj
.Rect
.Height
:= 16;
1364 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1365 dy
:= -(Obj
.Rect
.Height
div 2);
1366 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1369 ShotType
:= WEAPON_CACO_FIRE
;
1370 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1371 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1374 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1377 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1380 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1381 Silent
: Boolean = False);
1383 find_id
, FramesID
: DWORD
;
1387 find_id
:= FindShot()
1391 if Integer(find_id
) >= High(Shots
) then
1392 SetLength(Shots
, find_id
+ 64)
1395 with Shots
[find_id
] do
1399 Obj
.Rect
.Width
:= 32;
1400 Obj
.Rect
.Height
:= 16;
1402 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1403 dy
:= -(Obj
.Rect
.Height
div 2);
1404 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1407 ShotType
:= WEAPON_BARON_FIRE
;
1408 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1409 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1412 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1415 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1418 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1419 Silent
: Boolean = False);
1421 find_id
, FramesID
: DWORD
;
1425 find_id
:= FindShot()
1429 if Integer(find_id
) >= High(Shots
) then
1430 SetLength(Shots
, find_id
+ 64)
1433 with Shots
[find_id
] do
1437 Obj
.Rect
.Width
:= 16;
1438 Obj
.Rect
.Height
:= 16;
1440 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1441 dy
:= -(Obj
.Rect
.Height
div 2);
1442 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1445 ShotType
:= WEAPON_BSP_FIRE
;
1446 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1447 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1450 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1453 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1456 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1457 Silent
: Boolean = False);
1459 find_id
, FramesID
: DWORD
;
1463 find_id
:= FindShot()
1467 if Integer(find_id
) >= High(Shots
) then
1468 SetLength(Shots
, find_id
+ 64)
1471 with Shots
[find_id
] do
1475 Obj
.Rect
.Width
:= 32;
1476 Obj
.Rect
.Height
:= 32;
1478 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1479 dy
:= -(Obj
.Rect
.Height
div 2);
1480 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1483 ShotType
:= WEAPON_MANCUB_FIRE
;
1484 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1485 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1488 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1491 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1494 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1495 Silent
: Boolean = False);
1497 find_id
, FramesID
: DWORD
;
1501 find_id
:= FindShot()
1505 if Integer(find_id
) >= High(Shots
) then
1506 SetLength(Shots
, find_id
+ 64)
1509 with Shots
[find_id
] do
1513 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1514 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1516 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1517 dy
:= -(Obj
.Rect
.Height
div 2);
1518 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1521 ShotType
:= WEAPON_BFG
;
1522 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1523 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1526 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1529 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1532 procedure g_Weapon_bfghit(x
, y
: Integer);
1537 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1539 Anim
:= TAnimation
.Create(ID
, False, 4);
1540 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1545 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1546 Silent
: Boolean = False);
1549 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1551 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1552 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1554 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1555 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1559 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1560 Silent
: Boolean = False);
1563 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1565 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1566 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1567 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1569 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1570 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1574 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1575 Silent
: Boolean = False);
1580 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1584 j
:= Random(17)-8; // -8 .. 8
1585 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1589 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1590 Silent
: Boolean = False);
1595 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1597 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1600 j
:= Random(41)-20; // -20 .. 20
1601 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1605 procedure g_Weapon_Update();
1607 i
, a
, h
, cx
, cy
, oldvx
, oldvy
: Integer;
1620 for i
:= 0 to High(Shots
) do
1622 if Shots
[i
].ShotType
= 0 then
1629 Timeout
:= Timeout
- 1;
1632 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1633 if g_Game_IsServer
then
1634 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1635 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1641 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1642 if triggers
= nil then
1649 if not InDWArray(t
[a
], triggers
) then
1651 SetLength(triggers
, Length(triggers
)+1);
1652 triggers
[High(triggers
)] := t
[a
];
1657 // Àíèìàöèÿ ñíàðÿäà:
1658 if Animation
<> nil then
1662 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1663 (ShotType
<> WEAPON_BFG
) and
1664 (ShotType
<> WEAPON_BSP_FIRE
);
1666 st
:= g_Obj_Move(@Obj
, False, spl
);
1668 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1669 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1671 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1677 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1678 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1681 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1683 // Âûëåòåëà èç âîäû:
1684 if WordBool(st
and MOVE_HITAIR
) then
1685 g_Obj_SetSpeed(@Obj
, 12);
1687 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1688 if WordBool(st
and MOVE_INWATER
) then
1689 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1690 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1691 1+Random(3), 16, 16)
1693 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1695 Anim
:= TAnimation
.Create(_id
, False, 3);
1697 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
1698 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1699 Anim
, ONCEANIM_SMOKE
);
1703 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1704 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1705 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1711 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1713 if ShotType
= WEAPON_SKEL_FIRE
then
1714 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1715 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1717 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1718 Anim
.Blending
:= False;
1719 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
1724 begin // Âçðûâ Ðàêåòû
1725 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1727 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1728 Anim
.Blending
:= False;
1729 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1734 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1739 if ShotType
= WEAPON_SKEL_FIRE
then
1740 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1741 if GetPos(target
, @o
) then
1742 throw(i
, Obj
.X
, Obj
.Y
,
1743 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1744 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1749 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1751 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1752 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1754 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1755 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1761 if (ShotType
= WEAPON_PLASMA
) and
1762 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1767 if ShotType
= WEAPON_BSP_FIRE
then
1770 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1771 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1772 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1775 if ShotType
= WEAPON_PLASMA
then
1776 s
:= 'FRAMES_EXPLODE_PLASMA'
1778 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1781 if g_Frames_Get(TextureID
, s
) then
1783 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1784 Anim
.Blending
:= False;
1785 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1789 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1797 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1798 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1800 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1801 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1806 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1807 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1808 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
1812 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
1815 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
1817 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1818 Anim
.Blending
:= False;
1819 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1823 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
1829 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1832 if WordBool(st
and MOVE_HITAIR
) then
1833 g_Obj_SetSpeed(@Obj
, 16);
1836 if ShotType
= WEAPON_IMP_FIRE
then
1839 if ShotType
= WEAPON_CACO_FIRE
then
1844 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1845 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1846 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
1849 if ShotType
= WEAPON_IMP_FIRE
then
1850 s
:= 'FRAMES_EXPLODE_IMPFIRE'
1852 if ShotType
= WEAPON_CACO_FIRE
then
1853 s
:= 'FRAMES_EXPLODE_CACOFIRE'
1855 s
:= 'FRAMES_EXPLODE_BARONFIRE';
1858 if g_Frames_Get(TextureID
, s
) then
1860 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1861 Anim
.Blending
:= False;
1862 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
1866 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1872 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
1875 if WordBool(st
and MOVE_HITAIR
) then
1876 g_Obj_SetSpeed(@Obj
, 16);
1878 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1879 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1880 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
1884 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1886 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1887 Anim
.Blending
:= False;
1888 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1892 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1897 end; // case ShotType of...
1899 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
1900 if (ShotType
= 0) then
1902 if gGameSettings
.GameType
= GT_SERVER
then
1903 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
1907 else if (oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
) then
1908 if gGameSettings
.GameType
= GT_SERVER
then
1909 MH_SEND_UpdateShot(i
);
1914 procedure g_Weapon_Draw();
1923 for i
:= 0 to High(Shots
) do
1924 if Shots
[i
].ShotType
<> 0 then
1927 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
1928 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1929 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1930 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1931 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
1935 p
.X
:= Obj
.Rect
.Width
div 2;
1936 p
.Y
:= Obj
.Rect
.Height
div 2;
1938 if Animation
<> nil then
1940 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1941 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1942 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1943 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
1945 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
1949 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
1950 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
1952 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
1955 if g_debug_Frames
then
1957 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
1959 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
1960 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
1966 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
1975 for a
:= 0 to High(Shots
) do
1976 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
1977 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
1978 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
1979 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
1980 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
1981 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
1982 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
1989 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
1991 count
, i
, j
: Integer;
1994 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
1996 if Shots
<> nil then
1997 for i
:= 0 to High(Shots
) do
1998 if Shots
[i
].ShotType
<> 0 then
2001 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2003 // Êîëè÷åñòâî ñíàðÿäîâ:
2004 Mem
.WriteInt(count
);
2009 for i
:= 0 to High(Shots
) do
2010 if Shots
[i
].ShotType
<> 0 then
2012 // Ñèãíàòóðà ñíàðÿäà:
2013 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2016 Mem
.WriteByte(Shots
[i
].ShotType
);
2018 Mem
.WriteWord(Shots
[i
].Target
);
2020 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2021 // Ðàçìåð ïîëÿ Triggers:
2022 dw
:= Length(Shots
[i
].Triggers
);
2024 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2025 for j
:= 0 to Integer(dw
)-1 do
2026 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2028 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2032 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2034 count
, i
, j
: Integer;
2040 // Êîëè÷åñòâî ñíàðÿäîâ:
2043 SetLength(Shots
, count
);
2048 for i
:= 0 to count
-1 do
2050 // Ñèãíàòóðà ñíàðÿäà:
2052 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2054 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2057 Mem
.ReadByte(Shots
[i
].ShotType
);
2059 Mem
.ReadWord(Shots
[i
].Target
);
2061 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2062 // Ðàçìåð ïîëÿ Triggers:
2064 SetLength(Shots
[i
].Triggers
, dw
);
2065 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2066 for j
:= 0 to Integer(dw
)-1 do
2067 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2069 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2071 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2072 Shots
[i
].TextureID
:= DWORD(-1);
2073 Shots
[i
].Animation
:= nil;
2075 case Shots
[i
].ShotType
of
2076 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2078 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2082 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2083 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2087 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2088 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2092 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2093 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2097 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2098 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2102 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2103 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2107 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2108 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2112 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2113 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2119 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2127 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2131 if ShotType
= 0 then Exit
;
2134 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2135 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2138 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2142 if ShotType
= WEAPON_SKEL_FIRE
then
2143 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2144 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2146 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2147 Anim
.Blending
:= False;
2148 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2153 begin // Âçðûâ Ðàêåòû
2154 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2156 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2157 Anim
.Blending
:= False;
2158 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2162 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2166 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2168 if ShotType
= WEAPON_PLASMA
then
2169 s
:= 'FRAMES_EXPLODE_PLASMA'
2171 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2173 if g_Frames_Get(TextureID
, s
) and loud
then
2175 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2176 Anim
.Blending
:= False;
2177 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2180 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2187 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2189 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2190 Anim
.Blending
:= False;
2191 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2194 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2198 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2200 if ShotType
= WEAPON_IMP_FIRE
then
2201 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2203 if ShotType
= WEAPON_CACO_FIRE
then
2204 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2206 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2208 if g_Frames_Get(TextureID
, s
) and Loud
then
2210 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2211 Anim
.Blending
:= False;
2212 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2215 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2219 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2221 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2223 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2224 Anim
.Blending
:= False;
2225 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2228 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2231 end; // case ShotType of...