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
;
51 Shots
: array of TShot
= nil;
52 LastShotID
: Integer = 0;
54 procedure g_Weapon_LoadData();
55 procedure g_Weapon_FreeData();
56 procedure g_Weapon_Init();
57 procedure g_Weapon_Free();
58 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
59 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
60 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
62 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
63 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
64 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
65 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
66 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
67 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
68 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
69 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
70 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
71 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
72 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
73 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
74 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
75 procedure g_Weapon_bfghit(x
, y
: Integer);
76 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
77 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
78 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
79 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
81 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
82 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
83 procedure g_Weapon_Update();
84 procedure g_Weapon_Draw();
85 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
86 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
88 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
89 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
91 procedure g_Weapon_AddDynLights();
100 WEAPON_ROCKETLAUNCHER
= 6;
103 WEAPON_SUPERPULEMET
= 9;
104 WEAPON_FLAMETHROWER
= 10;
105 WEAPON_ZOMBY_PISTOL
= 20;
106 WEAPON_IMP_FIRE
= 21;
107 WEAPON_BSP_FIRE
= 22;
108 WEAPON_CACO_FIRE
= 23;
109 WEAPON_BARON_FIRE
= 24;
110 WEAPON_MANCUB_FIRE
= 25;
111 WEAPON_SKEL_FIRE
= 26;
113 WP_FIRST
= WEAPON_KASTET
;
114 WP_LAST
= WEAPON_FLAMETHROWER
;
119 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
120 g_console
, SysUtils
, g_options
, g_game
,
121 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
122 g_language
, g_netmsg
;
132 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
133 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
135 SHOT_SKELFIRE_WIDTH
= 14;
136 SHOT_SKELFIRE_HEIGHT
= 14;
138 SHOT_PLASMA_WIDTH
= 16;
139 SHOT_PLASMA_HEIGHT
= 16;
142 SHOT_BFG_HEIGHT
= 32;
143 SHOT_BFG_DAMAGE
= 100;
144 SHOT_BFG_RADIUS
= 256;
146 SHOT_FLAME_WIDTH
= 4;
147 SHOT_FLAME_HEIGHT
= 4;
148 SHOT_FLAME_LIFETIME
= 180;
150 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
153 WaterMap
: array of array of DWORD
= nil;
155 function FindShot(): DWORD
;
160 for i
:= 0 to High(Shots
) do
161 if Shots
[i
].ShotType
= 0 then
164 LastShotID
:= Result
;
170 SetLength(Shots
, 128);
175 Result
:= High(Shots
) + 1;
176 SetLength(Shots
, Length(Shots
) + 128);
178 LastShotID
:= Result
;
181 procedure CreateWaterMap();
183 WaterArray
: Array of TWaterPanel
;
190 SetLength(WaterArray
, Length(gWater
));
192 for a
:= 0 to High(gWater
) do
194 WaterArray
[a
].X
:= gWater
[a
].X
;
195 WaterArray
[a
].Y
:= gWater
[a
].Y
;
196 WaterArray
[a
].Width
:= gWater
[a
].Width
;
197 WaterArray
[a
].Height
:= gWater
[a
].Height
;
198 WaterArray
[a
].Active
:= True;
201 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
203 for a
:= 0 to High(WaterArray
) do
204 if WaterArray
[a
].Active
then
206 WaterArray
[a
].Active
:= False;
207 m
:= Length(WaterMap
);
208 SetLength(WaterMap
, m
+1);
209 SetLength(WaterMap
[m
], 1);
216 for b
:= 0 to High(WaterArray
) do
217 if WaterArray
[b
].Active
then
218 for c
:= 0 to High(WaterMap
[m
]) do
219 if g_CollideAround(WaterArray
[b
].X
,
222 WaterArray
[b
].Height
,
223 WaterArray
[WaterMap
[m
][c
]].X
,
224 WaterArray
[WaterMap
[m
][c
]].Y
,
225 WaterArray
[WaterMap
[m
][c
]].Width
,
226 WaterArray
[WaterMap
[m
][c
]].Height
) then
228 WaterArray
[b
].Active
:= False;
229 SetLength(WaterMap
[m
],
230 Length(WaterMap
[m
])+1);
231 WaterMap
[m
][High(WaterMap
[m
])] := b
;
237 g_Game_StepLoading();
243 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
245 a
, b
, c
, d
, i1
, i2
: Integer;
248 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
255 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
256 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
258 for a
:= 0 to High(WaterMap
) do
259 for b
:= 0 to High(WaterMap
[a
]) do
261 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
262 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
263 @Shots
[ID
].Obj
) then Continue
;
265 for c
:= 0 to High(WaterMap
[a
]) do
267 if gPlayers
<> nil then
269 for d
:= 0 to High(gPlayers
) do
270 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
271 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
272 if not InWArray(d
, pl
) then
280 if gMonsters
<> nil then
282 for d
:= 0 to High(gMonsters
) do
283 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
284 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
285 if not InWArray(d
, mn
) then
296 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
300 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
307 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
314 tt
:= g_GetUIDType(SpawnerUID
);
315 if tt
= UID_MONSTER
then
317 mon
:= g_Monsters_Get(SpawnerUID
);
319 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
326 if m
= nil then Exit
;
327 if m
.UID
= SpawnerUID
then
329 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
330 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
332 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
333 if (m
.MonsterType
= MONSTER_CYBER
) or
334 (m
.MonsterType
= MONSTER_BARREL
) then
341 if tt
= UID_MONSTER
then
343 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
344 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
347 // Îáà ìîíñòðà îäíîãî âèäà:
348 if mt
= m
.MonsterType
then
350 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
351 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
352 Exit
; // Ýòè íå áüþò ñâîèõ
356 if g_Game_IsServer
then
358 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
359 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
362 if t
= HIT_FLAME
then
363 m
.CatchFire(SpawnerUID
);
369 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
373 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
374 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
377 if g_Game_IsServer
then
379 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
380 p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
381 if (t
= HIT_FLAME
) then
382 p
.CatchFire(SpawnerUID
);
388 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
389 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
399 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
400 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
402 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
406 if Result
<> 0 then Exit
;
408 h
:= High(gMonsters
);
412 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
413 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
415 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
421 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
428 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
432 if gAdvCorpses
and (h
<> -1) then
434 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
436 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
437 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
438 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
439 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
442 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
443 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
447 pl
:= g_Player_Get(SpawnerUID
);
455 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
457 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
458 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
459 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
460 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
462 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
463 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
465 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
467 gPlayers
[i
].BFGHit();
470 h
:= High(gMonsters
);
474 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
476 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
477 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
478 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
479 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
480 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
483 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
485 find_id
, FramesID
: DWORD
;
488 find_id
:= FindShot()
492 if Integer(find_id
) >= High(Shots
) then
493 SetLength(Shots
, find_id
+ 64)
497 WEAPON_ROCKETLAUNCHER
:
499 with Shots
[find_id
] do
503 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
504 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
508 ShotType
:= WEAPON_ROCKETLAUNCHER
;
509 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
515 with Shots
[find_id
] do
519 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
520 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
523 ShotType
:= WEAPON_PLASMA
;
524 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
525 Animation
:= TAnimation
.Create(FramesID
, True, 5);
531 with Shots
[find_id
] do
535 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
536 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
539 ShotType
:= WEAPON_BFG
;
540 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
541 Animation
:= TAnimation
.Create(FramesID
, True, 6);
547 with Shots
[find_id
] do
551 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
552 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
555 ShotType
:= WEAPON_FLAMETHROWER
;
558 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
564 with Shots
[find_id
] do
568 Obj
.Rect
.Width
:= 16;
569 Obj
.Rect
.Height
:= 16;
572 ShotType
:= WEAPON_IMP_FIRE
;
573 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
574 Animation
:= TAnimation
.Create(FramesID
, True, 4);
580 with Shots
[find_id
] do
584 Obj
.Rect
.Width
:= 16;
585 Obj
.Rect
.Height
:= 16;
588 ShotType
:= WEAPON_CACO_FIRE
;
589 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
590 Animation
:= TAnimation
.Create(FramesID
, True, 4);
596 with Shots
[find_id
] do
600 Obj
.Rect
.Width
:= 32;
601 Obj
.Rect
.Height
:= 32;
604 ShotType
:= WEAPON_MANCUB_FIRE
;
605 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
606 Animation
:= TAnimation
.Create(FramesID
, True, 4);
612 with Shots
[find_id
] do
616 Obj
.Rect
.Width
:= 32;
617 Obj
.Rect
.Height
:= 16;
620 ShotType
:= WEAPON_BARON_FIRE
;
621 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
622 Animation
:= TAnimation
.Create(FramesID
, True, 4);
628 with Shots
[find_id
] do
632 Obj
.Rect
.Width
:= 16;
633 Obj
.Rect
.Height
:= 16;
636 ShotType
:= WEAPON_BSP_FIRE
;
637 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
638 Animation
:= TAnimation
.Create(FramesID
, True, 4);
644 with Shots
[find_id
] do
648 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
649 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
652 ShotType
:= WEAPON_SKEL_FIRE
;
654 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
655 Animation
:= TAnimation
.Create(FramesID
, True, 5);
660 Shots
[find_id
].Obj
.X
:= X
;
661 Shots
[find_id
].Obj
.Y
:= Y
;
662 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
663 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
664 Shots
[find_id
].Obj
.Accel
.X
:= 0;
665 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
666 Shots
[find_id
].SpawnerUID
:= Spawner
;
667 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
668 Shots
[find_id
].Stopped
:= 255
670 Shots
[find_id
].Stopped
:= 0;
674 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
681 a
:= Max(Abs(xd
), Abs(yd
));
687 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
688 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
689 Shots
[i
].Obj
.Accel
.X
:= 0;
690 Shots
[i
].Obj
.Accel
.Y
:= 0;
691 Shots
[i
].Stopped
:= 0;
692 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
693 Shots
[i
].Timeout
:= 900 // ~25 sec
696 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
697 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
699 Shots
[i
].Timeout
:= 550; // ~15 sec
703 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
707 function PlayerHit(Team
: Byte = 0): Boolean;
718 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
721 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
723 p
:= g_Player_Get(SpawnerUID
);
725 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
728 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
730 if t
<> HIT_FLAME
then
731 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
732 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
734 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
740 function MonsterHit(): Boolean;
745 h
:= High(gMonsters
);
749 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
750 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
752 if t
<> HIT_FLAME
then
753 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
754 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
766 if gAdvCorpses
and (h
<> -1) then
768 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
769 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
772 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
773 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
778 case gGameSettings
.GameMode
of
782 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
799 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
816 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
830 // È â êîíöå ñâîèõ èãðîêîâ
841 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
845 case g_GetUIDType(UID
) of
846 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
847 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
852 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
854 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
859 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
867 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
870 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
871 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
873 if dx
> 1000 then dx
:= 1000;
874 if dy
> 1000 then dy
:= 1000;
876 if dx
*dx
+dy
*dy
< r
then
878 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
879 // PLAYER_RECT.Width, PLAYER_RECT.Height);
881 mm
:= Max(abs(dx
), abs(dy
));
882 if mm
= 0 then mm
:= 1;
884 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
885 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
889 h
:= High(gMonsters
);
893 if gMonsters
[i
] <> nil then
896 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
897 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
899 if dx
> 1000 then dx
:= 1000;
900 if dy
> 1000 then dy
:= 1000;
902 if dx
*dx
+dy
*dy
< r
then
904 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
905 // Obj.Rect.Width, Obj.Rect.Height);
907 mm
:= Max(abs(dx
), abs(dy
));
908 if mm
= 0 then mm
:= 1;
910 if gMonsters
[i
].Live
then
911 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
912 0, 0, SpawnerUID
, HIT_ROCKET
);
914 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
920 if gAdvCorpses
and (h
<> -1) then
922 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
925 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
926 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
928 if dx
> 1000 then dx
:= 1000;
929 if dy
> 1000 then dy
:= 1000;
931 if dx
*dx
+dy
*dy
< r
then
933 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
934 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
936 mm
:= Max(abs(dx
), abs(dy
));
937 if mm
= 0 then mm
:= 1;
939 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
945 if gAdvGibs
and (h
<> -1) then
947 if gGibs
[i
].Live
then
950 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
951 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
953 if dx
> 1000 then dx
:= 1000;
954 if dy
> 1000 then dy
:= 1000;
956 if dx
*dx
+dy
*dy
< r
then
958 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
959 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
960 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
961 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
963 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
968 procedure g_Weapon_Init();
973 procedure g_Weapon_Free();
979 for i
:= 0 to High(Shots
) do
980 if Shots
[i
].ShotType
<> 0 then
981 Shots
[i
].Animation
.Free();
989 procedure g_Weapon_LoadData();
991 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
993 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
994 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
995 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
996 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
997 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
998 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
999 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1006 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1008 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1010 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1011 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1012 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1013 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1014 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1015 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1016 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1017 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1018 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1019 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1020 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1021 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1022 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1023 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1024 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1026 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1027 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1028 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1029 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1030 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1031 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1032 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1033 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1034 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1035 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1036 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1037 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1038 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1039 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1040 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1041 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1042 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1043 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1044 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1045 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1046 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1048 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1049 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1052 procedure g_Weapon_FreeData();
1054 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1056 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1057 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1058 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1059 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1060 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1061 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1062 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1063 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1064 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1065 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1066 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1067 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1068 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1069 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1070 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1071 g_Sound_Delete('SOUND_FIRE');
1072 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1073 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1074 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1075 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1076 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1077 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1078 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1079 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1080 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1081 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1082 g_Sound_Delete('SOUND_PLAYER_JETON');
1083 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1084 g_Sound_Delete('SOUND_PLAYER_CASING1');
1085 g_Sound_Delete('SOUND_PLAYER_CASING2');
1086 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1087 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1089 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1090 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1091 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1092 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1093 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1094 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1095 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1096 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1097 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1098 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1099 g_Frames_DeleteByName('FRAMES_BFGHIT');
1100 g_Frames_DeleteByName('FRAMES_FIRE');
1101 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1102 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1103 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1104 g_Frames_DeleteByName('FRAMES_SMOKE');
1105 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1106 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1109 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1121 t1
, _collide
: Boolean;
1124 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1126 SinCos(DegToRad(-a
), s
, c
);
1128 if Abs(s
) < 0.01 then s
:= 0;
1129 if Abs(c
) < 0.01 then c
:= 0;
1131 x2
:= x
+Round(c
*gMapInfo
.Width
);
1132 y2
:= y
+Round(s
*gMapInfo
.Width
);
1134 t1
:= gWalls
<> nil;
1136 w
:= gMapInfo
.Width
;
1137 h
:= gMapInfo
.Height
;
1144 if (xd
= 0) and (yd
= 0) then Exit
;
1146 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1147 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1152 if dx
> dy
then d
:= dx
else d
:= dy
;
1154 //blood vel, for Monster.Damage()
1155 //vx := (dx*10 div d)*xi;
1156 //vy := (dy*10 div d)*yi;
1178 if (yy
> h
) or (yy
< 0) then Break
;
1179 if (xx
> w
) or (xx
< 0) then Break
;
1182 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1185 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1186 if g_Game_IsServer
and g_Game_IsNet
then
1187 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1190 if not _collide
then
1191 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1197 if CheckTrigger
and g_Game_IsServer
then
1198 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1201 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1209 obj
.rect
.Width
:= 39;
1210 obj
.rect
.Height
:= 52;
1216 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1217 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1219 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1222 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1230 obj
.rect
.Width
:= 32;
1231 obj
.rect
.Height
:= 52;
1237 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1240 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1241 Silent
: Boolean = False);
1247 find_id
:= FindShot()
1251 if Integer(find_id
) >= High(Shots
) then
1252 SetLength(Shots
, find_id
+ 64)
1255 with Shots
[find_id
] do
1259 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1260 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1262 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1263 dy
:= -(Obj
.Rect
.Height
div 2);
1265 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1266 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1270 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1273 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1276 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1279 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1280 WID
: Integer = -1; Silent
: Boolean = False);
1282 find_id
, FramesID
: DWORD
;
1286 find_id
:= FindShot()
1290 if Integer(find_id
) >= High(Shots
) then
1291 SetLength(Shots
, find_id
+ 64)
1294 with Shots
[find_id
] do
1298 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1299 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1301 dx
:= -(Obj
.Rect
.Width
div 2);
1302 dy
:= -(Obj
.Rect
.Height
div 2);
1304 ShotType
:= WEAPON_SKEL_FIRE
;
1305 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1308 target
:= TargetUID
;
1309 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1310 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1313 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1316 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1319 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1320 Silent
: Boolean = False);
1322 find_id
, FramesID
: DWORD
;
1326 find_id
:= FindShot()
1330 if Integer(find_id
) >= High(Shots
) then
1331 SetLength(Shots
, find_id
+ 64);
1334 with Shots
[find_id
] do
1338 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1339 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1341 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1342 dy
:= -(Obj
.Rect
.Height
div 2);
1344 ShotType
:= WEAPON_PLASMA
;
1345 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1348 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1349 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1352 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1355 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1358 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1359 Silent
: Boolean = False);
1365 find_id
:= FindShot()
1369 if Integer(find_id
) >= High(Shots
) then
1370 SetLength(Shots
, find_id
+ 64);
1373 with Shots
[find_id
] do
1377 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1378 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1380 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1381 dy
:= -(Obj
.Rect
.Height
div 2);
1383 ShotType
:= WEAPON_FLAMETHROWER
;
1384 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1389 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
1392 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1394 // if not Silent then
1395 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1398 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1399 Silent
: Boolean = False);
1401 find_id
, FramesID
: DWORD
;
1405 find_id
:= FindShot()
1409 if Integer(find_id
) >= High(Shots
) then
1410 SetLength(Shots
, find_id
+ 64)
1413 with Shots
[find_id
] do
1417 Obj
.Rect
.Width
:= 16;
1418 Obj
.Rect
.Height
:= 16;
1420 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1421 dy
:= -(Obj
.Rect
.Height
div 2);
1423 ShotType
:= WEAPON_IMP_FIRE
;
1424 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1427 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1428 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1431 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1434 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1437 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1438 Silent
: Boolean = False);
1440 find_id
, FramesID
: DWORD
;
1444 find_id
:= FindShot()
1448 if Integer(find_id
) >= High(Shots
) then
1449 SetLength(Shots
, find_id
+ 64)
1452 with Shots
[find_id
] do
1456 Obj
.Rect
.Width
:= 16;
1457 Obj
.Rect
.Height
:= 16;
1459 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1460 dy
:= -(Obj
.Rect
.Height
div 2);
1462 ShotType
:= WEAPON_CACO_FIRE
;
1463 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1466 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1467 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1470 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1473 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1476 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1477 Silent
: Boolean = False);
1479 find_id
, FramesID
: DWORD
;
1483 find_id
:= FindShot()
1487 if Integer(find_id
) >= High(Shots
) then
1488 SetLength(Shots
, find_id
+ 64)
1491 with Shots
[find_id
] do
1495 Obj
.Rect
.Width
:= 32;
1496 Obj
.Rect
.Height
:= 16;
1498 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1499 dy
:= -(Obj
.Rect
.Height
div 2);
1501 ShotType
:= WEAPON_BARON_FIRE
;
1502 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1505 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1506 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1509 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1512 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1515 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1516 Silent
: Boolean = False);
1518 find_id
, FramesID
: DWORD
;
1522 find_id
:= FindShot()
1526 if Integer(find_id
) >= High(Shots
) then
1527 SetLength(Shots
, find_id
+ 64)
1530 with Shots
[find_id
] do
1534 Obj
.Rect
.Width
:= 16;
1535 Obj
.Rect
.Height
:= 16;
1537 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1538 dy
:= -(Obj
.Rect
.Height
div 2);
1540 ShotType
:= WEAPON_BSP_FIRE
;
1541 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1545 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1546 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1549 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1552 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1555 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1556 Silent
: Boolean = False);
1558 find_id
, FramesID
: DWORD
;
1562 find_id
:= FindShot()
1566 if Integer(find_id
) >= High(Shots
) then
1567 SetLength(Shots
, find_id
+ 64)
1570 with Shots
[find_id
] do
1574 Obj
.Rect
.Width
:= 32;
1575 Obj
.Rect
.Height
:= 32;
1577 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1578 dy
:= -(Obj
.Rect
.Height
div 2);
1580 ShotType
:= WEAPON_MANCUB_FIRE
;
1581 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1585 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1586 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1589 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1592 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1595 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1596 Silent
: Boolean = False);
1598 find_id
, FramesID
: DWORD
;
1602 find_id
:= FindShot()
1606 if Integer(find_id
) >= High(Shots
) then
1607 SetLength(Shots
, find_id
+ 64)
1610 with Shots
[find_id
] do
1614 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1615 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1617 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1618 dy
:= -(Obj
.Rect
.Height
div 2);
1620 ShotType
:= WEAPON_BFG
;
1621 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1624 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1625 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1628 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1631 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1634 procedure g_Weapon_bfghit(x
, y
: Integer);
1639 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1641 Anim
:= TAnimation
.Create(ID
, False, 4);
1642 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1647 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1648 Silent
: Boolean = False);
1651 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1653 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1654 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1656 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1657 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1661 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1662 Silent
: Boolean = False);
1665 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1667 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1668 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1669 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1671 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1672 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1676 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1677 Silent
: Boolean = False);
1682 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1686 j
:= Random(17)-8; // -8 .. 8
1687 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1691 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1692 Silent
: Boolean = False);
1697 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1699 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1702 j
:= Random(41)-20; // -20 .. 20
1703 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1707 procedure g_Weapon_Update();
1709 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
1723 for i
:= 0 to High(Shots
) do
1725 if Shots
[i
].ShotType
= 0 then
1732 Timeout
:= Timeout
- 1;
1735 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1736 if (Stopped
= 0) and g_Game_IsServer
then
1737 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1738 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1744 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1745 if triggers
= nil then
1752 if not InDWArray(t
[a
], triggers
) then
1754 SetLength(triggers
, Length(triggers
)+1);
1755 triggers
[High(triggers
)] := t
[a
];
1760 // Àíèìàöèÿ ñíàðÿäà:
1761 if Animation
<> nil then
1765 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1766 (ShotType
<> WEAPON_BFG
) and
1767 (ShotType
<> WEAPON_BSP_FIRE
) and
1768 (ShotType
<> WEAPON_FLAMETHROWER
);
1771 st
:= g_Obj_Move(@Obj
, False, spl
)
1775 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1776 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1778 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1784 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1785 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1788 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1790 // Âûëåòåëà èç âîäû:
1791 if WordBool(st
and MOVE_HITAIR
) then
1792 g_Obj_SetSpeed(@Obj
, 12);
1794 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1795 if WordBool(st
and MOVE_INWATER
) then
1796 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1797 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1798 1+Random(3), 16, 16)
1800 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1802 Anim
:= TAnimation
.Create(_id
, False, 3);
1804 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
1805 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1806 Anim
, ONCEANIM_SMOKE
);
1810 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1811 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1812 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1818 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1820 if ShotType
= WEAPON_SKEL_FIRE
then
1821 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1822 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1824 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1825 Anim
.Blending
:= False;
1826 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
1827 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
1832 begin // Âçðûâ Ðàêåòû
1833 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1835 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1836 Anim
.Blending
:= False;
1837 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1838 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
1843 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1848 if ShotType
= WEAPON_SKEL_FIRE
then
1849 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1850 if GetPos(target
, @o
) then
1851 throw(i
, Obj
.X
, Obj
.Y
,
1852 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1853 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1858 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1860 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1861 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1863 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1864 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1870 if (ShotType
= WEAPON_PLASMA
) and
1871 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1876 if ShotType
= WEAPON_BSP_FIRE
then
1879 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1880 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1881 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1884 if ShotType
= WEAPON_PLASMA
then
1885 s
:= 'FRAMES_EXPLODE_PLASMA'
1887 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1890 if g_Frames_Get(TextureID
, s
) then
1892 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1893 Anim
.Blending
:= False;
1894 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1896 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
1899 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1905 WEAPON_FLAMETHROWER
: // Îãíåìåò
1907 // Ñî âðåìåíåì óìèðàåò
1908 if (Timeout
< 1) then
1914 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
1916 if WordBool(st
and MOVE_HITWATER
) then
1918 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1920 Anim
:= TAnimation
.Create(_id
, False, 3);
1924 g_GFX_OnceAnim(cx
-4+tcx
-(Anim
.Width
div 2),
1925 cy
-4+tcy
-(Anim
.Height
div 2),
1926 Anim
, ONCEANIM_SMOKE
);
1931 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
1938 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
1939 // Ïîïàëè â ñòåíó èëè â âîäó:
1940 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
1946 if WordBool(st
and MOVE_HITWALL
) then
1947 Stopped
:= MOVE_HITWALL
1948 else if WordBool(st
and MOVE_HITLAND
) then
1949 Stopped
:= MOVE_HITLAND
1950 else if WordBool(st
and MOVE_HITCEIL
) then
1951 Stopped
:= MOVE_HITCEIL
;
1954 a
:= IfThen(Stopped
= 0, 3, 1);
1955 // Åñëè â êîãî-òî ïîïàëè
1956 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
1958 // HIT_FLAME ñàì ïîäîææåò
1959 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1969 if (gTime
mod tf
= 0) then
1971 Anim
:= TAnimation
.Create(TextureID
, False, 2 + Random(2));
1974 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
1975 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
1976 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
1977 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
1979 g_GFX_OnceAnim(tcx
-(Anim
.Width
div 2), tcy
-(Anim
.Height
div 2), Anim
, ONCEANIM_SMOKE
);
1981 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
1987 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1988 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1990 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1991 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1996 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1997 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1998 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2002 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2005 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
2007 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2008 Anim
.Blending
:= False;
2009 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2011 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2014 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2020 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2023 if WordBool(st
and MOVE_HITAIR
) then
2024 g_Obj_SetSpeed(@Obj
, 16);
2027 if ShotType
= WEAPON_IMP_FIRE
then
2030 if ShotType
= WEAPON_CACO_FIRE
then
2035 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2036 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2037 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2040 if ShotType
= WEAPON_IMP_FIRE
then
2041 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2043 if ShotType
= WEAPON_CACO_FIRE
then
2044 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2046 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2049 if g_Frames_Get(TextureID
, s
) then
2051 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2052 Anim
.Blending
:= False;
2053 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2057 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2063 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2066 if WordBool(st
and MOVE_HITAIR
) then
2067 g_Obj_SetSpeed(@Obj
, 16);
2069 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2070 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2071 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2075 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2077 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2078 Anim
.Blending
:= False;
2079 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2083 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2088 end; // case ShotType of...
2090 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2091 if (ShotType
= 0) then
2093 if gGameSettings
.GameType
= GT_SERVER
then
2094 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2095 if Animation
<> nil then
2101 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2102 if gGameSettings
.GameType
= GT_SERVER
then
2103 MH_SEND_UpdateShot(i
);
2108 procedure g_Weapon_Draw();
2117 for i
:= 0 to High(Shots
) do
2118 if Shots
[i
].ShotType
<> 0 then
2121 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2122 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2123 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2124 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2125 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
2129 p
.X
:= Obj
.Rect
.Width
div 2;
2130 p
.Y
:= Obj
.Rect
.Height
div 2;
2132 if Animation
<> nil then
2134 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2135 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2136 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2137 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
2139 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
2141 else if TextureID
<> 0 then
2143 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
2144 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
2145 else if (Shots
[i
].ShotType
<> WEAPON_FLAMETHROWER
) then
2146 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
2149 if g_debug_Frames
then
2151 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
2153 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
2154 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
2160 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2169 for a
:= 0 to High(Shots
) do
2170 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2171 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2172 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2173 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2174 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2175 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2176 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2183 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
2185 count
, i
, j
: Integer;
2188 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2190 if Shots
<> nil then
2191 for i
:= 0 to High(Shots
) do
2192 if Shots
[i
].ShotType
<> 0 then
2195 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2197 // Êîëè÷åñòâî ñíàðÿäîâ:
2198 Mem
.WriteInt(count
);
2203 for i
:= 0 to High(Shots
) do
2204 if Shots
[i
].ShotType
<> 0 then
2206 // Ñèãíàòóðà ñíàðÿäà:
2207 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2210 Mem
.WriteByte(Shots
[i
].ShotType
);
2212 Mem
.WriteWord(Shots
[i
].Target
);
2214 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2215 // Ðàçìåð ïîëÿ Triggers:
2216 dw
:= Length(Shots
[i
].Triggers
);
2218 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2219 for j
:= 0 to Integer(dw
)-1 do
2220 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2222 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2223 // Êîñòûëèíà åáàíàÿ:
2224 Mem
.WriteByte(Shots
[i
].Stopped
);
2228 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2230 count
, i
, j
: Integer;
2236 // Êîëè÷åñòâî ñíàðÿäîâ:
2239 SetLength(Shots
, count
);
2244 for i
:= 0 to count
-1 do
2246 // Ñèãíàòóðà ñíàðÿäà:
2248 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2250 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2253 Mem
.ReadByte(Shots
[i
].ShotType
);
2255 Mem
.ReadWord(Shots
[i
].Target
);
2257 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2258 // Ðàçìåð ïîëÿ Triggers:
2260 SetLength(Shots
[i
].Triggers
, dw
);
2261 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2262 for j
:= 0 to Integer(dw
)-1 do
2263 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2265 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2266 // Êîñòûëèíà åáàíàÿ:
2267 Mem
.ReadByte(Shots
[i
].Stopped
);
2269 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2270 Shots
[i
].TextureID
:= DWORD(-1);
2271 Shots
[i
].Animation
:= nil;
2273 case Shots
[i
].ShotType
of
2274 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2276 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2280 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2281 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2285 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2286 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2290 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2291 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2295 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2296 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2300 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2301 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2305 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2306 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2310 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2311 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2317 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2325 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2329 if ShotType
= 0 then Exit
;
2332 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2333 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2336 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2340 if ShotType
= WEAPON_SKEL_FIRE
then
2341 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2342 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2344 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2345 Anim
.Blending
:= False;
2346 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2351 begin // Âçðûâ Ðàêåòû
2352 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2354 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2355 Anim
.Blending
:= False;
2356 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2360 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2364 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2366 if ShotType
= WEAPON_PLASMA
then
2367 s
:= 'FRAMES_EXPLODE_PLASMA'
2369 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2371 if g_Frames_Get(TextureID
, s
) and loud
then
2373 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2374 Anim
.Blending
:= False;
2375 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2378 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2385 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2387 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2388 Anim
.Blending
:= False;
2389 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2392 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2396 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2398 if ShotType
= WEAPON_IMP_FIRE
then
2399 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2401 if ShotType
= WEAPON_CACO_FIRE
then
2402 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2404 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2406 if g_Frames_Get(TextureID
, s
) and Loud
then
2408 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2409 Anim
.Blending
:= False;
2410 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2413 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2417 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2419 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2421 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2422 Anim
.Blending
:= False;
2423 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2426 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2429 end; // case ShotType of...
2437 procedure g_Weapon_AddDynLights();
2441 if Shots
= nil then Exit
;
2442 for i
:= 0 to High(Shots
) do
2444 if Shots
[i
].ShotType
= 0 then continue
;
2445 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2446 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2447 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2448 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2449 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2450 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2451 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2452 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2453 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2454 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2455 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2458 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2459 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)
2460 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2461 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)
2462 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2463 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)
2465 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);