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; IgnoreTrigger
: Integer = -1): 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;
112 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
113 g_console
, SysUtils
, g_options
, g_game
,
114 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
115 g_language
, g_netmsg
;
125 SHOT_ROCKETLAUNCHER_WIDTH
= 27;
126 SHOT_ROCKETLAUNCHER_HEIGHT
= 12;
128 SHOT_SKELFIRE_WIDTH
= 32;
129 SHOT_SKELFIRE_HEIGHT
= 16;
131 SHOT_PLASMA_WIDTH
= 16;
132 SHOT_PLASMA_HEIGHT
= 16;
135 SHOT_BFG_HEIGHT
= 32;
136 SHOT_BFG_DAMAGE
= 100;
137 SHOT_BFG_RADIUS
= 256;
139 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
142 WaterMap
: array of array of DWORD
= nil;
144 function FindShot(): DWORD
;
149 for i
:= 0 to High(Shots
) do
150 if Shots
[i
].ShotType
= 0 then
153 LastShotID
:= Result
;
159 SetLength(Shots
, 128);
164 Result
:= High(Shots
) + 1;
165 SetLength(Shots
, Length(Shots
) + 128);
167 LastShotID
:= Result
;
170 procedure CreateWaterMap();
172 WaterArray
: Array of TWaterPanel
;
179 SetLength(WaterArray
, Length(gWater
));
181 for a
:= 0 to High(gWater
) do
183 WaterArray
[a
].X
:= gWater
[a
].X
;
184 WaterArray
[a
].Y
:= gWater
[a
].Y
;
185 WaterArray
[a
].Width
:= gWater
[a
].Width
;
186 WaterArray
[a
].Height
:= gWater
[a
].Height
;
187 WaterArray
[a
].Active
:= True;
190 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
192 for a
:= 0 to High(WaterArray
) do
193 if WaterArray
[a
].Active
then
195 WaterArray
[a
].Active
:= False;
196 m
:= Length(WaterMap
);
197 SetLength(WaterMap
, m
+1);
198 SetLength(WaterMap
[m
], 1);
205 for b
:= 0 to High(WaterArray
) do
206 if WaterArray
[b
].Active
then
207 for c
:= 0 to High(WaterMap
[m
]) do
208 if g_CollideAround(WaterArray
[b
].X
,
211 WaterArray
[b
].Height
,
212 WaterArray
[WaterMap
[m
][c
]].X
,
213 WaterArray
[WaterMap
[m
][c
]].Y
,
214 WaterArray
[WaterMap
[m
][c
]].Width
,
215 WaterArray
[WaterMap
[m
][c
]].Height
) then
217 WaterArray
[b
].Active
:= False;
218 SetLength(WaterMap
[m
],
219 Length(WaterMap
[m
])+1);
220 WaterMap
[m
][High(WaterMap
[m
])] := b
;
226 g_Game_StepLoading();
232 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
234 a
, b
, c
, d
, i1
, i2
: Integer;
237 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
244 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
245 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
247 for a
:= 0 to High(WaterMap
) do
248 for b
:= 0 to High(WaterMap
[a
]) do
250 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
251 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
252 @Shots
[ID
].Obj
) then Continue
;
254 for c
:= 0 to High(WaterMap
[a
]) do
256 if gPlayers
<> nil then
258 for d
:= 0 to High(gPlayers
) do
259 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
260 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
261 if not InWArray(d
, pl
) then
269 if gMonsters
<> nil then
271 for d
:= 0 to High(gMonsters
) do
272 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
273 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
274 if not InWArray(d
, mn
) then
285 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
289 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
296 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
303 tt
:= g_GetUIDType(SpawnerUID
);
304 if tt
= UID_MONSTER
then
306 mon
:= g_Monsters_Get(SpawnerUID
);
308 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
315 if m
= nil then Exit
;
316 if m
.UID
= SpawnerUID
then
318 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
319 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
321 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
322 if (m
.MonsterType
= MONSTER_CYBER
) or
323 (m
.MonsterType
= MONSTER_BARREL
) then
330 if tt
= UID_MONSTER
then
332 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
333 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
336 // Îáà ìîíñòðà îäíîãî âèäà:
337 if mt
= m
.MonsterType
then
339 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
340 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
341 Exit
; // Ýòè íå áüþò ñâîèõ
345 if g_Game_IsServer
then
346 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
351 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
355 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
356 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
359 if g_Game_IsServer
then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
364 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
365 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
375 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
376 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
378 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
382 if Result
<> 0 then Exit
;
384 h
:= High(gMonsters
);
388 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
389 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
391 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
397 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
404 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
408 if gAdvCorpses
and (h
<> -1) then
410 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
412 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
413 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
414 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
415 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
418 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
419 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
423 pl
:= g_Player_Get(SpawnerUID
);
431 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
433 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
434 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
435 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
436 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
438 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
439 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
441 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
443 gPlayers
[i
].BFGHit();
446 h
:= High(gMonsters
);
450 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
452 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
453 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
454 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
455 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
456 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
459 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
461 find_id
, FramesID
: DWORD
;
464 find_id
:= FindShot()
468 if Integer(find_id
) >= High(Shots
) then
469 SetLength(Shots
, find_id
+ 64)
473 WEAPON_ROCKETLAUNCHER
:
475 with Shots
[find_id
] do
479 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
480 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
484 ShotType
:= WEAPON_ROCKETLAUNCHER
;
485 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
491 with Shots
[find_id
] do
495 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
496 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
499 ShotType
:= WEAPON_PLASMA
;
500 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
501 Animation
:= TAnimation
.Create(FramesID
, True, 5);
507 with Shots
[find_id
] do
511 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
512 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
515 ShotType
:= WEAPON_BFG
;
516 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
517 Animation
:= TAnimation
.Create(FramesID
, True, 6);
523 with Shots
[find_id
] do
527 Obj
.Rect
.Width
:= 16;
528 Obj
.Rect
.Height
:= 16;
531 ShotType
:= WEAPON_IMP_FIRE
;
532 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
533 Animation
:= TAnimation
.Create(FramesID
, True, 4);
539 with Shots
[find_id
] do
543 Obj
.Rect
.Width
:= 16;
544 Obj
.Rect
.Height
:= 16;
547 ShotType
:= WEAPON_CACO_FIRE
;
548 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
549 Animation
:= TAnimation
.Create(FramesID
, True, 4);
555 with Shots
[find_id
] do
559 Obj
.Rect
.Width
:= 32;
560 Obj
.Rect
.Height
:= 32;
563 ShotType
:= WEAPON_MANCUB_FIRE
;
564 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
565 Animation
:= TAnimation
.Create(FramesID
, True, 4);
571 with Shots
[find_id
] do
575 Obj
.Rect
.Width
:= 32;
576 Obj
.Rect
.Height
:= 16;
579 ShotType
:= WEAPON_BARON_FIRE
;
580 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
581 Animation
:= TAnimation
.Create(FramesID
, True, 4);
587 with Shots
[find_id
] do
591 Obj
.Rect
.Width
:= 16;
592 Obj
.Rect
.Height
:= 16;
595 ShotType
:= WEAPON_BSP_FIRE
;
596 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
597 Animation
:= TAnimation
.Create(FramesID
, True, 4);
603 with Shots
[find_id
] do
607 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
608 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
611 ShotType
:= WEAPON_SKEL_FIRE
;
613 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
614 Animation
:= TAnimation
.Create(FramesID
, True, 5);
619 Shots
[find_id
].Obj
.X
:= X
;
620 Shots
[find_id
].Obj
.Y
:= Y
;
621 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
622 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
623 Shots
[find_id
].Obj
.Accel
.X
:= 0;
624 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
625 Shots
[find_id
].SpawnerUID
:= Spawner
;
629 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
636 a
:= Max(Abs(xd
), Abs(yd
));
642 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
643 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
644 Shots
[i
].Obj
.Accel
.X
:= 0;
645 Shots
[i
].Obj
.Accel
.Y
:= 0;
646 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
647 Shots
[i
].Timeout
:= 900 // ~25 sec
649 Shots
[i
].Timeout
:= 550 // ~15 sec
652 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
656 function PlayerHit(Team
: Byte = 0): Boolean;
667 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
670 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
672 p
:= g_Player_Get(SpawnerUID
);
674 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
677 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
679 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
680 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
682 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
688 function MonsterHit(): Boolean;
693 h
:= High(gMonsters
);
697 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
698 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
700 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
701 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
713 if gAdvCorpses
and (h
<> -1) then
715 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
716 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
719 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
720 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
725 case gGameSettings
.GameMode
of
729 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
746 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
763 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
777 // È â êîíöå ñâîèõ èãðîêîâ
788 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
792 case g_GetUIDType(UID
) of
793 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
794 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
799 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word; IgnoreTrigger
: Integer = -1): Boolean;
801 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
806 // don't let turret explosions use the turret
807 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
, IgnoreTrigger
);
815 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
818 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
819 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
821 if dx
> 1000 then dx
:= 1000;
822 if dy
> 1000 then dy
:= 1000;
824 if dx
*dx
+dy
*dy
< r
then
826 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
827 // PLAYER_RECT.Width, PLAYER_RECT.Height);
829 mm
:= Max(abs(dx
), abs(dy
));
830 if mm
= 0 then mm
:= 1;
832 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
833 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
837 h
:= High(gMonsters
);
841 if gMonsters
[i
] <> nil then
844 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
845 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
847 if dx
> 1000 then dx
:= 1000;
848 if dy
> 1000 then dy
:= 1000;
850 if dx
*dx
+dy
*dy
< r
then
852 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
853 // Obj.Rect.Width, Obj.Rect.Height);
855 mm
:= Max(abs(dx
), abs(dy
));
856 if mm
= 0 then mm
:= 1;
858 if gMonsters
[i
].Live
then
859 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
860 0, 0, SpawnerUID
, HIT_ROCKET
);
862 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
868 if gAdvCorpses
and (h
<> -1) then
870 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
873 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
874 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
876 if dx
> 1000 then dx
:= 1000;
877 if dy
> 1000 then dy
:= 1000;
879 if dx
*dx
+dy
*dy
< r
then
881 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
882 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
884 mm
:= Max(abs(dx
), abs(dy
));
885 if mm
= 0 then mm
:= 1;
887 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
893 if gAdvGibs
and (h
<> -1) then
895 if gGibs
[i
].Live
then
898 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
899 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
901 if dx
> 1000 then dx
:= 1000;
902 if dy
> 1000 then dy
:= 1000;
904 if dx
*dx
+dy
*dy
< r
then
906 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
907 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
908 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
909 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
911 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
916 procedure g_Weapon_Init();
921 procedure g_Weapon_Free();
927 for i
:= 0 to High(Shots
) do
928 if Shots
[i
].ShotType
<> 0 then
929 Shots
[i
].Animation
.Free();
937 procedure g_Weapon_LoadData();
939 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
941 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
942 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
943 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
944 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
945 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
946 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
947 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
948 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
949 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
950 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
951 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
952 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
953 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
954 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
955 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
956 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
957 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
958 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
959 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
960 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
961 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
962 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
963 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
964 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
965 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
966 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
967 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
968 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
969 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
970 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
971 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
972 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
974 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
975 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
976 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
977 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
978 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
979 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
980 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
981 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
982 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
983 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
984 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
985 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
986 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
987 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
988 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
989 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
990 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
991 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
992 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
993 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
995 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
996 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
999 procedure g_Weapon_FreeData();
1001 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1003 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1004 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1005 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1006 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1007 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1008 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1009 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1010 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1011 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1012 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1013 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1014 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1015 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1016 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1017 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1018 g_Sound_Delete('SOUND_FIRE');
1019 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1020 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1021 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1022 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1023 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1024 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1025 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1026 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1027 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1028 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1029 g_Sound_Delete('SOUND_PLAYER_JETON');
1030 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1031 g_Sound_Delete('SOUND_PLAYER_CASING1');
1032 g_Sound_Delete('SOUND_PLAYER_CASING2');
1033 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1034 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1036 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1037 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1038 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1039 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1040 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1041 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1042 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1043 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1044 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1045 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1046 g_Frames_DeleteByName('FRAMES_BFGHIT');
1047 g_Frames_DeleteByName('FRAMES_FIRE');
1048 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1049 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1050 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1051 g_Frames_DeleteByName('FRAMES_SMOKE');
1052 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1053 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1056 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1068 t1
, _collide
: Boolean;
1071 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1073 SinCos(DegToRad(-a
), s
, c
);
1075 if Abs(s
) < 0.01 then s
:= 0;
1076 if Abs(c
) < 0.01 then c
:= 0;
1078 x2
:= x
+Round(c
*gMapInfo
.Width
);
1079 y2
:= y
+Round(s
*gMapInfo
.Width
);
1081 t1
:= gWalls
<> nil;
1083 w
:= gMapInfo
.Width
;
1084 h
:= gMapInfo
.Height
;
1091 if (xd
= 0) and (yd
= 0) then Exit
;
1093 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1094 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1099 if dx
> dy
then d
:= dx
else d
:= dy
;
1101 //blood vel, for Monster.Damage()
1102 //vx := (dx*10 div d)*xi;
1103 //vy := (dy*10 div d)*yi;
1125 if (yy
> h
) or (yy
< 0) then Break
;
1126 if (xx
> w
) or (xx
< 0) then Break
;
1129 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1132 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1133 if g_Game_IsServer
and g_Game_IsNet
then
1134 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1137 if not _collide
then
1138 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1144 if CheckTrigger
and g_Game_IsServer
then
1145 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1148 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1156 obj
.rect
.Width
:= 39;
1157 obj
.rect
.Height
:= 52;
1163 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1164 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1166 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1169 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1177 obj
.rect
.Width
:= 32;
1178 obj
.rect
.Height
:= 52;
1184 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1187 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1188 Silent
: Boolean = False);
1194 find_id
:= FindShot()
1198 if Integer(find_id
) >= High(Shots
) then
1199 SetLength(Shots
, find_id
+ 64)
1202 with Shots
[find_id
] do
1206 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1207 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1209 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1210 dy
:= -(Obj
.Rect
.Height
div 2);
1211 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1215 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1216 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1219 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1222 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1225 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1226 WID
: Integer = -1; Silent
: Boolean = False);
1228 find_id
, FramesID
: DWORD
;
1232 find_id
:= FindShot()
1236 if Integer(find_id
) >= High(Shots
) then
1237 SetLength(Shots
, find_id
+ 64)
1240 with Shots
[find_id
] do
1244 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1245 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1247 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1248 dy
:= -(Obj
.Rect
.Height
div 2);
1249 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1252 ShotType
:= WEAPON_SKEL_FIRE
;
1253 target
:= TargetUID
;
1254 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1255 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1258 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1261 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1264 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1265 Silent
: Boolean = False);
1267 find_id
, FramesID
: DWORD
;
1271 find_id
:= FindShot()
1275 if Integer(find_id
) >= High(Shots
) then
1276 SetLength(Shots
, find_id
+ 64);
1279 with Shots
[find_id
] do
1283 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1284 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1286 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1287 dy
:= -(Obj
.Rect
.Height
div 2);
1288 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1291 ShotType
:= WEAPON_PLASMA
;
1292 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1293 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1296 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1299 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1302 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1303 Silent
: Boolean = False);
1305 find_id
, FramesID
: DWORD
;
1309 find_id
:= FindShot()
1313 if Integer(find_id
) >= High(Shots
) then
1314 SetLength(Shots
, find_id
+ 64)
1317 with Shots
[find_id
] do
1321 Obj
.Rect
.Width
:= 16;
1322 Obj
.Rect
.Height
:= 16;
1324 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1325 dy
:= -(Obj
.Rect
.Height
div 2);
1326 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1329 ShotType
:= WEAPON_IMP_FIRE
;
1330 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1331 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1334 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1337 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1340 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1341 Silent
: Boolean = False);
1343 find_id
, FramesID
: DWORD
;
1347 find_id
:= FindShot()
1351 if Integer(find_id
) >= High(Shots
) then
1352 SetLength(Shots
, find_id
+ 64)
1355 with Shots
[find_id
] do
1359 Obj
.Rect
.Width
:= 16;
1360 Obj
.Rect
.Height
:= 16;
1362 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1363 dy
:= -(Obj
.Rect
.Height
div 2);
1364 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1367 ShotType
:= WEAPON_CACO_FIRE
;
1368 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1369 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1372 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1375 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1378 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1379 Silent
: Boolean = False);
1381 find_id
, FramesID
: DWORD
;
1385 find_id
:= FindShot()
1389 if Integer(find_id
) >= High(Shots
) then
1390 SetLength(Shots
, find_id
+ 64)
1393 with Shots
[find_id
] do
1397 Obj
.Rect
.Width
:= 32;
1398 Obj
.Rect
.Height
:= 16;
1400 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1401 dy
:= -(Obj
.Rect
.Height
div 2);
1402 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1405 ShotType
:= WEAPON_BARON_FIRE
;
1406 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1407 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1410 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1413 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1416 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1417 Silent
: Boolean = False);
1419 find_id
, FramesID
: DWORD
;
1423 find_id
:= FindShot()
1427 if Integer(find_id
) >= High(Shots
) then
1428 SetLength(Shots
, find_id
+ 64)
1431 with Shots
[find_id
] do
1435 Obj
.Rect
.Width
:= 16;
1436 Obj
.Rect
.Height
:= 16;
1438 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1439 dy
:= -(Obj
.Rect
.Height
div 2);
1440 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1443 ShotType
:= WEAPON_BSP_FIRE
;
1444 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1445 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1448 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1451 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1454 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1455 Silent
: Boolean = False);
1457 find_id
, FramesID
: DWORD
;
1461 find_id
:= FindShot()
1465 if Integer(find_id
) >= High(Shots
) then
1466 SetLength(Shots
, find_id
+ 64)
1469 with Shots
[find_id
] do
1473 Obj
.Rect
.Width
:= 32;
1474 Obj
.Rect
.Height
:= 32;
1476 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1477 dy
:= -(Obj
.Rect
.Height
div 2);
1478 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1481 ShotType
:= WEAPON_MANCUB_FIRE
;
1482 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1483 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1486 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1489 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1492 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1493 Silent
: Boolean = False);
1495 find_id
, FramesID
: DWORD
;
1499 find_id
:= FindShot()
1503 if Integer(find_id
) >= High(Shots
) then
1504 SetLength(Shots
, find_id
+ 64)
1507 with Shots
[find_id
] do
1511 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1512 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1514 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1515 dy
:= -(Obj
.Rect
.Height
div 2);
1516 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1519 ShotType
:= WEAPON_BFG
;
1520 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1521 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1524 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1527 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1530 procedure g_Weapon_bfghit(x
, y
: Integer);
1535 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1537 Anim
:= TAnimation
.Create(ID
, False, 4);
1538 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1543 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1544 Silent
: Boolean = False);
1547 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1549 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1550 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1552 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1553 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1557 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1558 Silent
: Boolean = False);
1561 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1563 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1564 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1565 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1567 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1568 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1572 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1573 Silent
: Boolean = False);
1578 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1582 j
:= Random(17)-8; // -8 .. 8
1583 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1587 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1588 Silent
: Boolean = False);
1593 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1595 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1598 j
:= Random(41)-20; // -20 .. 20
1599 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1603 procedure g_Weapon_Update();
1605 i
, a
, h
, cx
, cy
, oldvx
, oldvy
: Integer;
1618 for i
:= 0 to High(Shots
) do
1620 if Shots
[i
].ShotType
= 0 then
1627 Timeout
:= Timeout
- 1;
1630 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1631 if g_Game_IsServer
then
1632 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1633 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1639 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1640 if triggers
= nil then
1647 if not InDWArray(t
[a
], triggers
) then
1649 SetLength(triggers
, Length(triggers
)+1);
1650 triggers
[High(triggers
)] := t
[a
];
1655 // Àíèìàöèÿ ñíàðÿäà:
1656 if Animation
<> nil then
1660 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1661 (ShotType
<> WEAPON_BFG
) and
1662 (ShotType
<> WEAPON_BSP_FIRE
);
1664 st
:= g_Obj_Move(@Obj
, False, spl
);
1666 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1667 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1669 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1675 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1676 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1679 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1681 // Âûëåòåëà èç âîäû:
1682 if WordBool(st
and MOVE_HITAIR
) then
1683 g_Obj_SetSpeed(@Obj
, 12);
1685 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1686 if WordBool(st
and MOVE_INWATER
) then
1687 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1688 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1689 1+Random(3), 16, 16)
1691 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1693 Anim
:= TAnimation
.Create(_id
, False, 3);
1695 g_GFX_OnceAnim(Obj
.X
-8+Random(9),
1696 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1697 Anim
, ONCEANIM_SMOKE
);
1701 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1702 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1703 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1709 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1711 if ShotType
= WEAPON_SKEL_FIRE
then
1712 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1713 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1715 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1716 Anim
.Blending
:= False;
1717 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
1722 begin // Âçðûâ Ðàêåòû
1723 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1725 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1726 Anim
.Blending
:= False;
1727 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1732 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1737 if ShotType
= WEAPON_SKEL_FIRE
then
1738 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1739 if GetPos(target
, @o
) then
1740 throw(i
, Obj
.X
, Obj
.Y
,
1741 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1742 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1747 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1749 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1750 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1752 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1753 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1759 if (ShotType
= WEAPON_PLASMA
) and
1760 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1765 if ShotType
= WEAPON_BSP_FIRE
then
1768 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1769 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1770 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1773 if ShotType
= WEAPON_PLASMA
then
1774 s
:= 'FRAMES_EXPLODE_PLASMA'
1776 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1779 if g_Frames_Get(TextureID
, s
) then
1781 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1782 Anim
.Blending
:= False;
1783 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1787 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1795 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1796 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1798 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1799 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1804 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1805 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1806 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
1810 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
1813 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
1815 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1816 Anim
.Blending
:= False;
1817 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1821 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
1827 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1830 if WordBool(st
and MOVE_HITAIR
) then
1831 g_Obj_SetSpeed(@Obj
, 16);
1834 if ShotType
= WEAPON_IMP_FIRE
then
1837 if ShotType
= WEAPON_CACO_FIRE
then
1842 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1843 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1844 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
1847 if ShotType
= WEAPON_IMP_FIRE
then
1848 s
:= 'FRAMES_EXPLODE_IMPFIRE'
1850 if ShotType
= WEAPON_CACO_FIRE
then
1851 s
:= 'FRAMES_EXPLODE_CACOFIRE'
1853 s
:= 'FRAMES_EXPLODE_BARONFIRE';
1856 if g_Frames_Get(TextureID
, s
) then
1858 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1859 Anim
.Blending
:= False;
1860 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
1864 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1870 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
1873 if WordBool(st
and MOVE_HITAIR
) then
1874 g_Obj_SetSpeed(@Obj
, 16);
1876 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1877 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1878 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
1882 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1884 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1885 Anim
.Blending
:= False;
1886 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1890 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
1895 end; // case ShotType of...
1897 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
1898 if (ShotType
= 0) then
1900 if gGameSettings
.GameType
= GT_SERVER
then
1901 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
1905 else if (oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
) then
1906 if gGameSettings
.GameType
= GT_SERVER
then
1907 MH_SEND_UpdateShot(i
);
1912 procedure g_Weapon_Draw();
1921 for i
:= 0 to High(Shots
) do
1922 if Shots
[i
].ShotType
<> 0 then
1925 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
1926 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1927 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1928 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1929 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
1933 p
.X
:= Obj
.Rect
.Width
div 2;
1934 p
.Y
:= Obj
.Rect
.Height
div 2;
1936 if Animation
<> nil then
1938 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
1939 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
1940 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
1941 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
1943 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
1947 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
1948 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
1950 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
1953 if g_debug_Frames
then
1955 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
1957 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
1958 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
1964 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
1973 for a
:= 0 to High(Shots
) do
1974 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
1975 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
1976 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
1977 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
1978 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
1979 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
1980 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
1987 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
1989 count
, i
, j
: Integer;
1992 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
1994 if Shots
<> nil then
1995 for i
:= 0 to High(Shots
) do
1996 if Shots
[i
].ShotType
<> 0 then
1999 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2001 // Êîëè÷åñòâî ñíàðÿäîâ:
2002 Mem
.WriteInt(count
);
2007 for i
:= 0 to High(Shots
) do
2008 if Shots
[i
].ShotType
<> 0 then
2010 // Ñèãíàòóðà ñíàðÿäà:
2011 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2014 Mem
.WriteByte(Shots
[i
].ShotType
);
2016 Mem
.WriteWord(Shots
[i
].Target
);
2018 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2019 // Ðàçìåð ïîëÿ Triggers:
2020 dw
:= Length(Shots
[i
].Triggers
);
2022 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2023 for j
:= 0 to Integer(dw
)-1 do
2024 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2026 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2030 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2032 count
, i
, j
: Integer;
2038 // Êîëè÷åñòâî ñíàðÿäîâ:
2041 SetLength(Shots
, count
);
2046 for i
:= 0 to count
-1 do
2048 // Ñèãíàòóðà ñíàðÿäà:
2050 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2052 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2055 Mem
.ReadByte(Shots
[i
].ShotType
);
2057 Mem
.ReadWord(Shots
[i
].Target
);
2059 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2060 // Ðàçìåð ïîëÿ Triggers:
2062 SetLength(Shots
[i
].Triggers
, dw
);
2063 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2064 for j
:= 0 to Integer(dw
)-1 do
2065 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2067 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2069 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2070 Shots
[i
].TextureID
:= DWORD(-1);
2071 Shots
[i
].Animation
:= nil;
2073 case Shots
[i
].ShotType
of
2074 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2076 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2080 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2081 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2085 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2086 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2090 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2091 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2095 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2096 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2100 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2101 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2105 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2106 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2110 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2111 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2117 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2125 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2129 if ShotType
= 0 then Exit
;
2132 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2133 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2136 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2140 if ShotType
= WEAPON_SKEL_FIRE
then
2141 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2142 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2144 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2145 Anim
.Blending
:= False;
2146 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2151 begin // Âçðûâ Ðàêåòû
2152 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2154 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2155 Anim
.Blending
:= False;
2156 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2160 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2164 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2166 if ShotType
= WEAPON_PLASMA
then
2167 s
:= 'FRAMES_EXPLODE_PLASMA'
2169 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2171 if g_Frames_Get(TextureID
, s
) and loud
then
2173 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2174 Anim
.Blending
:= False;
2175 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2178 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2185 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2187 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2188 Anim
.Blending
:= False;
2189 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2192 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2196 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2198 if ShotType
= WEAPON_IMP_FIRE
then
2199 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2201 if ShotType
= WEAPON_CACO_FIRE
then
2202 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2204 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2206 if g_Frames_Get(TextureID
, s
) and Loud
then
2208 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2209 Anim
.Blending
:= False;
2210 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2213 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2217 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2219 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2221 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2222 Anim
.Blending
:= False;
2223 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2226 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2229 end; // case ShotType of...