1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
44 Animation
: TAnimation
;
49 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
54 Shots
: array of TShot
= nil;
55 LastShotID
: Integer = 0;
57 procedure g_Weapon_LoadData();
58 procedure g_Weapon_FreeData();
59 procedure g_Weapon_Init();
60 procedure g_Weapon_Free();
61 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
62 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
63 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
65 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
66 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
67 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
68 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
69 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
70 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
71 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
72 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
73 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
74 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
75 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
76 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
77 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
78 procedure g_Weapon_bfghit(x
, y
: Integer);
79 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
80 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
81 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
82 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
84 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
85 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
86 procedure g_Weapon_Update();
87 procedure g_Weapon_Draw();
88 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
89 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
91 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
92 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
94 procedure g_Weapon_AddDynLights();
103 WEAPON_ROCKETLAUNCHER
= 6;
106 WEAPON_SUPERPULEMET
= 9;
107 WEAPON_FLAMETHROWER
= 10;
108 WEAPON_ZOMBY_PISTOL
= 20;
109 WEAPON_IMP_FIRE
= 21;
110 WEAPON_BSP_FIRE
= 22;
111 WEAPON_CACO_FIRE
= 23;
112 WEAPON_BARON_FIRE
= 24;
113 WEAPON_MANCUB_FIRE
= 25;
114 WEAPON_SKEL_FIRE
= 26;
116 WP_FIRST
= WEAPON_KASTET
;
117 WP_LAST
= WEAPON_FLAMETHROWER
;
122 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
123 g_console
, SysUtils
, g_options
, g_game
,
124 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
125 g_language
, g_netmsg
;
135 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
136 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
138 SHOT_SKELFIRE_WIDTH
= 14;
139 SHOT_SKELFIRE_HEIGHT
= 14;
141 SHOT_PLASMA_WIDTH
= 16;
142 SHOT_PLASMA_HEIGHT
= 16;
145 SHOT_BFG_HEIGHT
= 32;
146 SHOT_BFG_DAMAGE
= 100;
147 SHOT_BFG_RADIUS
= 256;
149 SHOT_FLAME_WIDTH
= 4;
150 SHOT_FLAME_HEIGHT
= 4;
151 SHOT_FLAME_LIFETIME
= 180;
153 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
156 WaterMap
: array of array of DWORD
= nil;
158 function FindShot(): DWORD
;
163 for i
:= 0 to High(Shots
) do
164 if Shots
[i
].ShotType
= 0 then
167 LastShotID
:= Result
;
173 SetLength(Shots
, 128);
178 Result
:= High(Shots
) + 1;
179 SetLength(Shots
, Length(Shots
) + 128);
181 LastShotID
:= Result
;
184 procedure CreateWaterMap();
186 WaterArray
: Array of TWaterPanel
;
193 SetLength(WaterArray
, Length(gWater
));
195 for a
:= 0 to High(gWater
) do
197 WaterArray
[a
].X
:= gWater
[a
].X
;
198 WaterArray
[a
].Y
:= gWater
[a
].Y
;
199 WaterArray
[a
].Width
:= gWater
[a
].Width
;
200 WaterArray
[a
].Height
:= gWater
[a
].Height
;
201 WaterArray
[a
].Active
:= True;
204 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
206 for a
:= 0 to High(WaterArray
) do
207 if WaterArray
[a
].Active
then
209 WaterArray
[a
].Active
:= False;
210 m
:= Length(WaterMap
);
211 SetLength(WaterMap
, m
+1);
212 SetLength(WaterMap
[m
], 1);
219 for b
:= 0 to High(WaterArray
) do
220 if WaterArray
[b
].Active
then
221 for c
:= 0 to High(WaterMap
[m
]) do
222 if g_CollideAround(WaterArray
[b
].X
,
225 WaterArray
[b
].Height
,
226 WaterArray
[WaterMap
[m
][c
]].X
,
227 WaterArray
[WaterMap
[m
][c
]].Y
,
228 WaterArray
[WaterMap
[m
][c
]].Width
,
229 WaterArray
[WaterMap
[m
][c
]].Height
) then
231 WaterArray
[b
].Active
:= False;
232 SetLength(WaterMap
[m
],
233 Length(WaterMap
[m
])+1);
234 WaterMap
[m
][High(WaterMap
[m
])] := b
;
240 g_Game_StepLoading();
246 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
248 a
, b
, c
, d
, i1
, i2
: Integer;
251 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
258 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
259 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
261 for a
:= 0 to High(WaterMap
) do
262 for b
:= 0 to High(WaterMap
[a
]) do
264 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
265 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
266 @Shots
[ID
].Obj
) then Continue
;
268 for c
:= 0 to High(WaterMap
[a
]) do
270 if gPlayers
<> nil then
272 for d
:= 0 to High(gPlayers
) do
273 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
274 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
275 if not InWArray(d
, pl
) then
283 if gMonsters
<> nil then
285 for d
:= 0 to High(gMonsters
) do
286 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
287 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
288 if not InWArray(d
, mn
) then
299 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
303 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
310 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
317 tt
:= g_GetUIDType(SpawnerUID
);
318 if tt
= UID_MONSTER
then
320 mon
:= g_Monsters_Get(SpawnerUID
);
322 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
329 if m
= nil then Exit
;
330 if m
.UID
= SpawnerUID
then
332 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
333 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
335 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
336 if (m
.MonsterType
= MONSTER_CYBER
) or
337 (m
.MonsterType
= MONSTER_BARREL
) then
344 if tt
= UID_MONSTER
then
346 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
347 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
350 // Îáà ìîíñòðà îäíîãî âèäà:
351 if mt
= m
.MonsterType
then
353 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
354 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
355 Exit
; // Ýòè íå áüþò ñâîèõ
359 if g_Game_IsServer
then
361 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
362 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
365 if t
= HIT_FLAME
then
366 m
.CatchFire(SpawnerUID
);
372 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
376 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
377 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
380 if g_Game_IsServer
then
382 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
383 p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
384 if (t
= HIT_FLAME
) then
385 p
.CatchFire(SpawnerUID
);
391 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
392 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
402 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
403 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
405 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
409 if Result
<> 0 then Exit
;
411 h
:= High(gMonsters
);
415 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
416 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
418 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
424 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
431 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
435 if gAdvCorpses
and (h
<> -1) then
437 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
439 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
440 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
441 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
442 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
445 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
446 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
450 pl
:= g_Player_Get(SpawnerUID
);
458 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
460 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
461 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
462 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
463 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
465 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
466 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
468 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
470 gPlayers
[i
].BFGHit();
473 h
:= High(gMonsters
);
477 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
479 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
480 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
481 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
482 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
483 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
486 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
488 find_id
, FramesID
: DWORD
;
491 find_id
:= FindShot()
495 if Integer(find_id
) >= High(Shots
) then
496 SetLength(Shots
, find_id
+ 64)
500 WEAPON_ROCKETLAUNCHER
:
502 with Shots
[find_id
] do
506 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
507 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
511 ShotType
:= WEAPON_ROCKETLAUNCHER
;
512 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
518 with Shots
[find_id
] do
522 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
523 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
526 ShotType
:= WEAPON_PLASMA
;
527 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
528 Animation
:= TAnimation
.Create(FramesID
, True, 5);
534 with Shots
[find_id
] do
538 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
539 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
542 ShotType
:= WEAPON_BFG
;
543 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
544 Animation
:= TAnimation
.Create(FramesID
, True, 6);
550 with Shots
[find_id
] do
554 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
555 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
558 ShotType
:= WEAPON_FLAMETHROWER
;
561 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
567 with Shots
[find_id
] do
571 Obj
.Rect
.Width
:= 16;
572 Obj
.Rect
.Height
:= 16;
575 ShotType
:= WEAPON_IMP_FIRE
;
576 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
577 Animation
:= TAnimation
.Create(FramesID
, True, 4);
583 with Shots
[find_id
] do
587 Obj
.Rect
.Width
:= 16;
588 Obj
.Rect
.Height
:= 16;
591 ShotType
:= WEAPON_CACO_FIRE
;
592 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
593 Animation
:= TAnimation
.Create(FramesID
, True, 4);
599 with Shots
[find_id
] do
603 Obj
.Rect
.Width
:= 32;
604 Obj
.Rect
.Height
:= 32;
607 ShotType
:= WEAPON_MANCUB_FIRE
;
608 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
609 Animation
:= TAnimation
.Create(FramesID
, True, 4);
615 with Shots
[find_id
] do
619 Obj
.Rect
.Width
:= 32;
620 Obj
.Rect
.Height
:= 16;
623 ShotType
:= WEAPON_BARON_FIRE
;
624 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
625 Animation
:= TAnimation
.Create(FramesID
, True, 4);
631 with Shots
[find_id
] do
635 Obj
.Rect
.Width
:= 16;
636 Obj
.Rect
.Height
:= 16;
639 ShotType
:= WEAPON_BSP_FIRE
;
640 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
641 Animation
:= TAnimation
.Create(FramesID
, True, 4);
647 with Shots
[find_id
] do
651 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
652 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
655 ShotType
:= WEAPON_SKEL_FIRE
;
657 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
658 Animation
:= TAnimation
.Create(FramesID
, True, 5);
663 Shots
[find_id
].Obj
.X
:= X
;
664 Shots
[find_id
].Obj
.Y
:= Y
;
665 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
666 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
667 Shots
[find_id
].Obj
.Accel
.X
:= 0;
668 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
669 Shots
[find_id
].SpawnerUID
:= Spawner
;
670 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
671 Shots
[find_id
].Stopped
:= 255
673 Shots
[find_id
].Stopped
:= 0;
677 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
684 a
:= Max(Abs(xd
), Abs(yd
));
690 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
691 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
692 Shots
[i
].Obj
.Accel
.X
:= 0;
693 Shots
[i
].Obj
.Accel
.Y
:= 0;
694 Shots
[i
].Stopped
:= 0;
695 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
696 Shots
[i
].Timeout
:= 900 // ~25 sec
699 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
700 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
702 Shots
[i
].Timeout
:= 550; // ~15 sec
706 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
710 function PlayerHit(Team
: Byte = 0): Boolean;
721 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
724 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
726 p
:= g_Player_Get(SpawnerUID
);
728 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
731 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
733 if t
<> HIT_FLAME
then
734 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
735 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
737 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
743 function MonsterHit(): Boolean;
748 h
:= High(gMonsters
);
752 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
753 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
755 if t
<> HIT_FLAME
then
756 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
757 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
769 if gAdvCorpses
and (h
<> -1) then
771 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
772 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
775 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
776 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
781 case gGameSettings
.GameMode
of
785 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
802 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
819 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
833 // È â êîíöå ñâîèõ èãðîêîâ
844 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
848 case g_GetUIDType(UID
) of
849 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
850 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
855 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
857 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
862 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
870 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
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, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
882 // PLAYER_RECT.Width, PLAYER_RECT.Height);
884 mm
:= Max(abs(dx
), abs(dy
));
885 if mm
= 0 then mm
:= 1;
887 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
888 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
892 h
:= High(gMonsters
);
896 if gMonsters
[i
] <> nil then
899 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
900 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
902 if dx
> 1000 then dx
:= 1000;
903 if dy
> 1000 then dy
:= 1000;
905 if dx
*dx
+dy
*dy
< r
then
907 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
908 // Obj.Rect.Width, Obj.Rect.Height);
910 mm
:= Max(abs(dx
), abs(dy
));
911 if mm
= 0 then mm
:= 1;
913 if gMonsters
[i
].Live
then
914 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
915 0, 0, SpawnerUID
, HIT_ROCKET
);
917 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
923 if gAdvCorpses
and (h
<> -1) then
925 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
928 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
929 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
931 if dx
> 1000 then dx
:= 1000;
932 if dy
> 1000 then dy
:= 1000;
934 if dx
*dx
+dy
*dy
< r
then
936 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
937 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
939 mm
:= Max(abs(dx
), abs(dy
));
940 if mm
= 0 then mm
:= 1;
942 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
948 if gAdvGibs
and (h
<> -1) then
950 if gGibs
[i
].Live
then
953 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
954 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
956 if dx
> 1000 then dx
:= 1000;
957 if dy
> 1000 then dy
:= 1000;
959 if dx
*dx
+dy
*dy
< r
then
961 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
962 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
963 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
964 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
966 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
967 positionChanged(); // this updates spatial accelerators
972 procedure g_Weapon_Init();
977 procedure g_Weapon_Free();
983 for i
:= 0 to High(Shots
) do
984 if Shots
[i
].ShotType
<> 0 then
985 Shots
[i
].Animation
.Free();
993 procedure g_Weapon_LoadData();
995 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
997 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
998 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
999 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1006 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1008 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1010 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1011 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1012 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1013 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1014 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1015 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1016 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1017 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1018 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1019 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1020 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1021 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1022 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1023 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1024 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1025 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1026 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1027 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1028 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1030 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1031 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1032 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1033 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1034 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1035 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1036 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1037 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1038 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1039 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1040 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1041 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1042 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1043 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1044 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1045 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1046 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1047 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1048 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1049 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1050 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1052 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1053 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1056 procedure g_Weapon_FreeData();
1058 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1060 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1061 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1062 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1063 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1064 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1065 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1066 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1067 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1068 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1069 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1070 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1071 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1072 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1073 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1074 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1075 g_Sound_Delete('SOUND_FIRE');
1076 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1077 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1078 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1079 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1080 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1081 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1082 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1083 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1084 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1085 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1086 g_Sound_Delete('SOUND_PLAYER_JETON');
1087 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1088 g_Sound_Delete('SOUND_PLAYER_CASING1');
1089 g_Sound_Delete('SOUND_PLAYER_CASING2');
1090 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1091 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1093 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1094 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1095 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1096 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1097 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1098 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1099 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1100 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1101 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1102 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1103 g_Frames_DeleteByName('FRAMES_BFGHIT');
1104 g_Frames_DeleteByName('FRAMES_FIRE');
1105 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1106 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1107 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1108 g_Frames_DeleteByName('FRAMES_SMOKE');
1109 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1110 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1113 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1125 t1
, _collide
: Boolean;
1128 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1130 SinCos(DegToRad(-a
), s
, c
);
1132 if Abs(s
) < 0.01 then s
:= 0;
1133 if Abs(c
) < 0.01 then c
:= 0;
1135 x2
:= x
+Round(c
*gMapInfo
.Width
);
1136 y2
:= y
+Round(s
*gMapInfo
.Width
);
1138 t1
:= gWalls
<> nil;
1140 w
:= gMapInfo
.Width
;
1141 h
:= gMapInfo
.Height
;
1148 if (xd
= 0) and (yd
= 0) then Exit
;
1150 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1151 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1156 if dx
> dy
then d
:= dx
else d
:= dy
;
1158 //blood vel, for Monster.Damage()
1159 //vx := (dx*10 div d)*xi;
1160 //vy := (dy*10 div d)*yi;
1182 if (yy
> h
) or (yy
< 0) then Break
;
1183 if (xx
> w
) or (xx
< 0) then Break
;
1186 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1189 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1190 if g_Game_IsServer
and g_Game_IsNet
then
1191 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1194 if not _collide
then
1195 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1201 if CheckTrigger
and g_Game_IsServer
then
1202 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1205 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1213 obj
.rect
.Width
:= 39;
1214 obj
.rect
.Height
:= 52;
1220 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1221 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1223 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1226 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1234 obj
.rect
.Width
:= 32;
1235 obj
.rect
.Height
:= 52;
1241 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1244 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1245 Silent
: Boolean = False);
1251 find_id
:= FindShot()
1255 if Integer(find_id
) >= High(Shots
) then
1256 SetLength(Shots
, find_id
+ 64)
1259 with Shots
[find_id
] do
1263 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1264 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1266 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1267 dy
:= -(Obj
.Rect
.Height
div 2);
1269 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1270 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1274 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1277 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1280 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1283 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1284 WID
: Integer = -1; Silent
: Boolean = False);
1286 find_id
, FramesID
: DWORD
;
1290 find_id
:= FindShot()
1294 if Integer(find_id
) >= High(Shots
) then
1295 SetLength(Shots
, find_id
+ 64)
1298 with Shots
[find_id
] do
1302 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1303 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1305 dx
:= -(Obj
.Rect
.Width
div 2);
1306 dy
:= -(Obj
.Rect
.Height
div 2);
1308 ShotType
:= WEAPON_SKEL_FIRE
;
1309 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1312 target
:= TargetUID
;
1313 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1314 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1317 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1320 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1323 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1324 Silent
: Boolean = False);
1326 find_id
, FramesID
: DWORD
;
1330 find_id
:= FindShot()
1334 if Integer(find_id
) >= High(Shots
) then
1335 SetLength(Shots
, find_id
+ 64);
1338 with Shots
[find_id
] do
1342 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1343 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1345 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1346 dy
:= -(Obj
.Rect
.Height
div 2);
1348 ShotType
:= WEAPON_PLASMA
;
1349 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1352 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1353 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1356 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1359 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1362 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1363 Silent
: Boolean = False);
1369 find_id
:= FindShot()
1373 if Integer(find_id
) >= High(Shots
) then
1374 SetLength(Shots
, find_id
+ 64);
1377 with Shots
[find_id
] do
1381 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1382 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1384 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1385 dy
:= -(Obj
.Rect
.Height
div 2);
1387 ShotType
:= WEAPON_FLAMETHROWER
;
1388 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1393 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
1396 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1398 // if not Silent then
1399 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1402 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1403 Silent
: Boolean = False);
1405 find_id
, FramesID
: DWORD
;
1409 find_id
:= FindShot()
1413 if Integer(find_id
) >= High(Shots
) then
1414 SetLength(Shots
, find_id
+ 64)
1417 with Shots
[find_id
] do
1421 Obj
.Rect
.Width
:= 16;
1422 Obj
.Rect
.Height
:= 16;
1424 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1425 dy
:= -(Obj
.Rect
.Height
div 2);
1427 ShotType
:= WEAPON_IMP_FIRE
;
1428 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1431 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1432 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1435 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1438 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1441 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1442 Silent
: Boolean = False);
1444 find_id
, FramesID
: DWORD
;
1448 find_id
:= FindShot()
1452 if Integer(find_id
) >= High(Shots
) then
1453 SetLength(Shots
, find_id
+ 64)
1456 with Shots
[find_id
] do
1460 Obj
.Rect
.Width
:= 16;
1461 Obj
.Rect
.Height
:= 16;
1463 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1464 dy
:= -(Obj
.Rect
.Height
div 2);
1466 ShotType
:= WEAPON_CACO_FIRE
;
1467 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1470 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1471 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1474 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1477 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1480 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1481 Silent
: Boolean = False);
1483 find_id
, FramesID
: DWORD
;
1487 find_id
:= FindShot()
1491 if Integer(find_id
) >= High(Shots
) then
1492 SetLength(Shots
, find_id
+ 64)
1495 with Shots
[find_id
] do
1499 Obj
.Rect
.Width
:= 32;
1500 Obj
.Rect
.Height
:= 16;
1502 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1503 dy
:= -(Obj
.Rect
.Height
div 2);
1505 ShotType
:= WEAPON_BARON_FIRE
;
1506 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1509 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1510 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1513 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1516 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1519 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1520 Silent
: Boolean = False);
1522 find_id
, FramesID
: DWORD
;
1526 find_id
:= FindShot()
1530 if Integer(find_id
) >= High(Shots
) then
1531 SetLength(Shots
, find_id
+ 64)
1534 with Shots
[find_id
] do
1538 Obj
.Rect
.Width
:= 16;
1539 Obj
.Rect
.Height
:= 16;
1541 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1542 dy
:= -(Obj
.Rect
.Height
div 2);
1544 ShotType
:= WEAPON_BSP_FIRE
;
1545 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1549 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1550 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1553 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1556 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1559 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1560 Silent
: Boolean = False);
1562 find_id
, FramesID
: DWORD
;
1566 find_id
:= FindShot()
1570 if Integer(find_id
) >= High(Shots
) then
1571 SetLength(Shots
, find_id
+ 64)
1574 with Shots
[find_id
] do
1578 Obj
.Rect
.Width
:= 32;
1579 Obj
.Rect
.Height
:= 32;
1581 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1582 dy
:= -(Obj
.Rect
.Height
div 2);
1584 ShotType
:= WEAPON_MANCUB_FIRE
;
1585 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1589 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1590 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1593 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1596 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1599 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1600 Silent
: Boolean = False);
1602 find_id
, FramesID
: DWORD
;
1606 find_id
:= FindShot()
1610 if Integer(find_id
) >= High(Shots
) then
1611 SetLength(Shots
, find_id
+ 64)
1614 with Shots
[find_id
] do
1618 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1619 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1621 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1622 dy
:= -(Obj
.Rect
.Height
div 2);
1624 ShotType
:= WEAPON_BFG
;
1625 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1628 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1629 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1632 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1635 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1638 procedure g_Weapon_bfghit(x
, y
: Integer);
1643 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1645 Anim
:= TAnimation
.Create(ID
, False, 4);
1646 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1651 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1652 Silent
: Boolean = False);
1655 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1657 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1658 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1660 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1661 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1665 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1666 Silent
: Boolean = False);
1669 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1671 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1672 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1673 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1675 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1676 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1680 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1681 Silent
: Boolean = False);
1686 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1690 j
:= Random(17)-8; // -8 .. 8
1691 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1695 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1696 Silent
: Boolean = False);
1701 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1703 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1706 j
:= Random(41)-20; // -20 .. 20
1707 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1711 procedure g_Weapon_Update();
1713 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
1727 for i
:= 0 to High(Shots
) do
1729 if Shots
[i
].ShotType
= 0 then
1736 Timeout
:= Timeout
- 1;
1739 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1740 if (Stopped
= 0) and g_Game_IsServer
then
1741 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1742 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1748 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1749 if triggers
= nil then
1756 if not InDWArray(t
[a
], triggers
) then
1758 SetLength(triggers
, Length(triggers
)+1);
1759 triggers
[High(triggers
)] := t
[a
];
1764 // Àíèìàöèÿ ñíàðÿäà:
1765 if Animation
<> nil then
1769 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1770 (ShotType
<> WEAPON_BFG
) and
1771 (ShotType
<> WEAPON_BSP_FIRE
) and
1772 (ShotType
<> WEAPON_FLAMETHROWER
);
1776 st
:= g_Obj_Move(@Obj
, False, spl
);
1782 positionChanged(); // this updates spatial accelerators
1784 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1785 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1787 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1793 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1794 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1797 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1799 // Âûëåòåëà èç âîäû:
1800 if WordBool(st
and MOVE_HITAIR
) then
1801 g_Obj_SetSpeed(@Obj
, 12);
1803 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1804 if WordBool(st
and MOVE_INWATER
) then
1805 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1806 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1807 1+Random(3), 16, 16)
1809 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1811 Anim
:= TAnimation
.Create(_id
, False, 3);
1813 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
1814 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1815 Anim
, ONCEANIM_SMOKE
);
1819 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1820 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1821 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1827 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1829 if ShotType
= WEAPON_SKEL_FIRE
then
1830 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1831 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1833 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1834 Anim
.Blending
:= False;
1835 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
1836 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
1841 begin // Âçðûâ Ðàêåòû
1842 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1844 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1845 Anim
.Blending
:= False;
1846 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1847 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
1852 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1857 if ShotType
= WEAPON_SKEL_FIRE
then
1858 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1859 if GetPos(target
, @o
) then
1860 throw(i
, Obj
.X
, Obj
.Y
,
1861 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1862 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1867 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1869 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1870 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1872 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1873 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1879 if (ShotType
= WEAPON_PLASMA
) and
1880 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1885 if ShotType
= WEAPON_BSP_FIRE
then
1888 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1889 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1890 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1893 if ShotType
= WEAPON_PLASMA
then
1894 s
:= 'FRAMES_EXPLODE_PLASMA'
1896 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1899 if g_Frames_Get(TextureID
, s
) then
1901 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1902 Anim
.Blending
:= False;
1903 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1905 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
1908 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1914 WEAPON_FLAMETHROWER
: // Îãíåìåò
1916 // Ñî âðåìåíåì óìèðàåò
1917 if (Timeout
< 1) then
1923 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
1925 if WordBool(st
and MOVE_HITWATER
) then
1927 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1929 Anim
:= TAnimation
.Create(_id
, False, 3);
1933 g_GFX_OnceAnim(cx
-4+tcx
-(Anim
.Width
div 2),
1934 cy
-4+tcy
-(Anim
.Height
div 2),
1935 Anim
, ONCEANIM_SMOKE
);
1940 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
1947 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
1948 // Ïîïàëè â ñòåíó èëè â âîäó:
1949 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
1955 if WordBool(st
and MOVE_HITWALL
) then
1956 Stopped
:= MOVE_HITWALL
1957 else if WordBool(st
and MOVE_HITLAND
) then
1958 Stopped
:= MOVE_HITLAND
1959 else if WordBool(st
and MOVE_HITCEIL
) then
1960 Stopped
:= MOVE_HITCEIL
;
1963 a
:= IfThen(Stopped
= 0, 3, 1);
1964 // Åñëè â êîãî-òî ïîïàëè
1965 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
1967 // HIT_FLAME ñàì ïîäîææåò
1968 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1978 if (gTime
mod tf
= 0) then
1980 Anim
:= TAnimation
.Create(TextureID
, False, 2 + Random(2));
1983 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
1984 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
1985 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
1986 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
1988 g_GFX_OnceAnim(tcx
-(Anim
.Width
div 2), tcy
-(Anim
.Height
div 2), Anim
, ONCEANIM_SMOKE
);
1990 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
1996 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1997 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1999 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2000 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2005 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2006 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2007 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2011 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2014 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
2016 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2017 Anim
.Blending
:= False;
2018 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2020 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2023 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2029 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2032 if WordBool(st
and MOVE_HITAIR
) then
2033 g_Obj_SetSpeed(@Obj
, 16);
2036 if ShotType
= WEAPON_IMP_FIRE
then
2039 if ShotType
= WEAPON_CACO_FIRE
then
2044 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2045 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2046 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2049 if ShotType
= WEAPON_IMP_FIRE
then
2050 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2052 if ShotType
= WEAPON_CACO_FIRE
then
2053 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2055 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2058 if g_Frames_Get(TextureID
, s
) then
2060 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2061 Anim
.Blending
:= False;
2062 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2066 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2072 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2075 if WordBool(st
and MOVE_HITAIR
) then
2076 g_Obj_SetSpeed(@Obj
, 16);
2078 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2079 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2080 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2084 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2086 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2087 Anim
.Blending
:= False;
2088 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2092 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2097 end; // case ShotType of...
2099 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2100 if (ShotType
= 0) then
2102 if gGameSettings
.GameType
= GT_SERVER
then
2103 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2104 if Animation
<> nil then
2110 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2111 if gGameSettings
.GameType
= GT_SERVER
then
2112 MH_SEND_UpdateShot(i
);
2117 procedure g_Weapon_Draw();
2126 for i
:= 0 to High(Shots
) do
2127 if Shots
[i
].ShotType
<> 0 then
2130 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2131 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2132 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2133 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2134 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
2138 p
.X
:= Obj
.Rect
.Width
div 2;
2139 p
.Y
:= Obj
.Rect
.Height
div 2;
2141 if Animation
<> nil then
2143 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2144 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2145 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2146 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
2148 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
2150 else if TextureID
<> 0 then
2152 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
2153 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
2154 else if (Shots
[i
].ShotType
<> WEAPON_FLAMETHROWER
) then
2155 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
2158 if g_debug_Frames
then
2160 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
2162 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
2163 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
2169 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2178 for a
:= 0 to High(Shots
) do
2179 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2180 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2181 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2182 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2183 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2184 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2185 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2192 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
2194 count
, i
, j
: Integer;
2197 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2199 if Shots
<> nil then
2200 for i
:= 0 to High(Shots
) do
2201 if Shots
[i
].ShotType
<> 0 then
2204 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2206 // Êîëè÷åñòâî ñíàðÿäîâ:
2207 Mem
.WriteInt(count
);
2212 for i
:= 0 to High(Shots
) do
2213 if Shots
[i
].ShotType
<> 0 then
2215 // Ñèãíàòóðà ñíàðÿäà:
2216 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2219 Mem
.WriteByte(Shots
[i
].ShotType
);
2221 Mem
.WriteWord(Shots
[i
].Target
);
2223 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2224 // Ðàçìåð ïîëÿ Triggers:
2225 dw
:= Length(Shots
[i
].Triggers
);
2227 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2228 for j
:= 0 to Integer(dw
)-1 do
2229 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2231 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2232 // Êîñòûëèíà åáàíàÿ:
2233 Mem
.WriteByte(Shots
[i
].Stopped
);
2237 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2239 count
, i
, j
: Integer;
2245 // Êîëè÷åñòâî ñíàðÿäîâ:
2248 SetLength(Shots
, count
);
2253 for i
:= 0 to count
-1 do
2255 // Ñèãíàòóðà ñíàðÿäà:
2257 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2259 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2262 Mem
.ReadByte(Shots
[i
].ShotType
);
2264 Mem
.ReadWord(Shots
[i
].Target
);
2266 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2267 // Ðàçìåð ïîëÿ Triggers:
2269 SetLength(Shots
[i
].Triggers
, dw
);
2270 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2271 for j
:= 0 to Integer(dw
)-1 do
2272 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2274 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2275 // Êîñòûëèíà åáàíàÿ:
2276 Mem
.ReadByte(Shots
[i
].Stopped
);
2278 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2279 Shots
[i
].TextureID
:= DWORD(-1);
2280 Shots
[i
].Animation
:= nil;
2282 case Shots
[i
].ShotType
of
2283 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2285 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2289 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2290 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2294 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2295 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2299 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2300 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2304 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2305 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2309 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2310 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2314 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2315 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2319 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2320 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2326 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2334 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2338 if ShotType
= 0 then Exit
;
2341 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2342 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2345 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2349 if ShotType
= WEAPON_SKEL_FIRE
then
2350 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2351 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2353 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2354 Anim
.Blending
:= False;
2355 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2360 begin // Âçðûâ Ðàêåòû
2361 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2363 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2364 Anim
.Blending
:= False;
2365 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2369 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2373 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2375 if ShotType
= WEAPON_PLASMA
then
2376 s
:= 'FRAMES_EXPLODE_PLASMA'
2378 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2380 if g_Frames_Get(TextureID
, s
) and loud
then
2382 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2383 Anim
.Blending
:= False;
2384 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2387 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2394 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2396 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2397 Anim
.Blending
:= False;
2398 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2401 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2405 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2407 if ShotType
= WEAPON_IMP_FIRE
then
2408 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2410 if ShotType
= WEAPON_CACO_FIRE
then
2411 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2413 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2415 if g_Frames_Get(TextureID
, s
) and Loud
then
2417 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2418 Anim
.Blending
:= False;
2419 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2422 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2426 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2428 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2430 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2431 Anim
.Blending
:= False;
2432 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2435 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2438 end; // case ShotType of...
2446 procedure g_Weapon_AddDynLights();
2450 if Shots
= nil then Exit
;
2451 for i
:= 0 to High(Shots
) do
2453 if Shots
[i
].ShotType
= 0 then continue
;
2454 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2455 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2456 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2457 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2458 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2459 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2460 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2461 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2462 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2463 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2464 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2467 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2468 g_AddDynLight(Shots
[i
].Obj
.X
+(Shots
[i
].Obj
.Rect
.Width
div 2), Shots
[i
].Obj
.Y
+(Shots
[i
].Obj
.Rect
.Height
div 2), 128, 0, 0.3, 1, 0.4)
2469 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2470 g_AddDynLight(Shots
[i
].Obj
.X
+(Shots
[i
].Obj
.Rect
.Width
div 2), Shots
[i
].Obj
.Y
+(Shots
[i
].Obj
.Rect
.Height
div 2), 128, 0, 1, 0, 0.5)
2471 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2472 g_AddDynLight(Shots
[i
].Obj
.X
+(Shots
[i
].Obj
.Rect
.Width
div 2), Shots
[i
].Obj
.Y
+(Shots
[i
].Obj
.Rect
.Height
div 2), 42, 1, 0.8, 0, 0.4)
2474 g_AddDynLight(Shots
[i
].Obj
.X
+(Shots
[i
].Obj
.Rect
.Width
div 2), Shots
[i
].Obj
.Y
+(Shots
[i
].Obj
.Rect
.Height
div 2), 128, 1, 0, 0, 0.4);
2480 procedure TShot
.positionChanged (); begin end;