1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
44 Animation
: TAnimation
;
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
);
98 WEAPON_ROCKETLAUNCHER
= 6;
101 WEAPON_SUPERPULEMET
= 9;
102 WEAPON_FLAMETHROWER
= 10;
103 WEAPON_ZOMBY_PISTOL
= 20;
104 WEAPON_IMP_FIRE
= 21;
105 WEAPON_BSP_FIRE
= 22;
106 WEAPON_CACO_FIRE
= 23;
107 WEAPON_BARON_FIRE
= 24;
108 WEAPON_MANCUB_FIRE
= 25;
109 WEAPON_SKEL_FIRE
= 26;
111 WP_FIRST
= WEAPON_KASTET
;
112 WP_LAST
= WEAPON_FLAMETHROWER
;
117 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
,
118 g_console
, SysUtils
, g_options
, g_game
,
119 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
120 g_language
, g_netmsg
;
130 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
131 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
133 SHOT_SKELFIRE_WIDTH
= 14;
134 SHOT_SKELFIRE_HEIGHT
= 14;
136 SHOT_PLASMA_WIDTH
= 16;
137 SHOT_PLASMA_HEIGHT
= 16;
140 SHOT_BFG_HEIGHT
= 32;
141 SHOT_BFG_DAMAGE
= 100;
142 SHOT_BFG_RADIUS
= 256;
144 SHOT_FLAME_WIDTH
= 4;
145 SHOT_FLAME_HEIGHT
= 4;
146 SHOT_FLAME_LIFETIME
= 360;
148 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
151 WaterMap
: array of array of DWORD
= nil;
153 function FindShot(): DWORD
;
158 for i
:= 0 to High(Shots
) do
159 if Shots
[i
].ShotType
= 0 then
162 LastShotID
:= Result
;
168 SetLength(Shots
, 128);
173 Result
:= High(Shots
) + 1;
174 SetLength(Shots
, Length(Shots
) + 128);
176 LastShotID
:= Result
;
179 procedure CreateWaterMap();
181 WaterArray
: Array of TWaterPanel
;
188 SetLength(WaterArray
, Length(gWater
));
190 for a
:= 0 to High(gWater
) do
192 WaterArray
[a
].X
:= gWater
[a
].X
;
193 WaterArray
[a
].Y
:= gWater
[a
].Y
;
194 WaterArray
[a
].Width
:= gWater
[a
].Width
;
195 WaterArray
[a
].Height
:= gWater
[a
].Height
;
196 WaterArray
[a
].Active
:= True;
199 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
201 for a
:= 0 to High(WaterArray
) do
202 if WaterArray
[a
].Active
then
204 WaterArray
[a
].Active
:= False;
205 m
:= Length(WaterMap
);
206 SetLength(WaterMap
, m
+1);
207 SetLength(WaterMap
[m
], 1);
214 for b
:= 0 to High(WaterArray
) do
215 if WaterArray
[b
].Active
then
216 for c
:= 0 to High(WaterMap
[m
]) do
217 if g_CollideAround(WaterArray
[b
].X
,
220 WaterArray
[b
].Height
,
221 WaterArray
[WaterMap
[m
][c
]].X
,
222 WaterArray
[WaterMap
[m
][c
]].Y
,
223 WaterArray
[WaterMap
[m
][c
]].Width
,
224 WaterArray
[WaterMap
[m
][c
]].Height
) then
226 WaterArray
[b
].Active
:= False;
227 SetLength(WaterMap
[m
],
228 Length(WaterMap
[m
])+1);
229 WaterMap
[m
][High(WaterMap
[m
])] := b
;
235 g_Game_StepLoading();
241 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
243 a
, b
, c
, d
, i1
, i2
: Integer;
246 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
253 for d
:= 0 to 1023 do pl
[d
] := $FFFF;
254 for d
:= 0 to 1023 do mn
[d
] := $FFFF;
256 for a
:= 0 to High(WaterMap
) do
257 for b
:= 0 to High(WaterMap
[a
]) do
259 if not g_Obj_Collide(gWater
[WaterMap
[a
][b
]].X
, gWater
[WaterMap
[a
][b
]].Y
,
260 gWater
[WaterMap
[a
][b
]].Width
, gWater
[WaterMap
[a
][b
]].Height
,
261 @Shots
[ID
].Obj
) then Continue
;
263 for c
:= 0 to High(WaterMap
[a
]) do
265 if gPlayers
<> nil then
267 for d
:= 0 to High(gPlayers
) do
268 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
269 if gPlayers
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
270 if not InWArray(d
, pl
) then
278 if gMonsters
<> nil then
280 for d
:= 0 to High(gMonsters
) do
281 if (gMonsters
[d
] <> nil) and (gMonsters
[d
].Live
) then
282 if gMonsters
[d
].Collide(gWater
[WaterMap
[a
][c
]]) then
283 if not InWArray(d
, mn
) then
294 gPlayers
[pl
[d
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
298 gMonsters
[mn
[d
]].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
305 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
312 tt
:= g_GetUIDType(SpawnerUID
);
313 if tt
= UID_MONSTER
then
315 mon
:= g_Monsters_Get(SpawnerUID
);
317 mt
:= g_Monsters_Get(SpawnerUID
).MonsterType
324 if m
= nil then Exit
;
325 if m
.UID
= SpawnerUID
then
327 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
328 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
330 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
331 if (m
.MonsterType
= MONSTER_CYBER
) or
332 (m
.MonsterType
= MONSTER_BARREL
) then
339 if tt
= UID_MONSTER
then
341 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
342 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
345 // Îáà ìîíñòðà îäíîãî âèäà:
346 if mt
= m
.MonsterType
then
348 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
349 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
350 Exit
; // Ýòè íå áüþò ñâîèõ
354 if g_Game_IsServer
then
356 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
357 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
360 if t
= HIT_FLAME
then
367 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
371 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
372 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
375 if g_Game_IsServer
then
377 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
378 p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
379 if (t
= HIT_FLAME
) then
386 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
387 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
397 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
398 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
400 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
404 if Result
<> 0 then Exit
;
406 h
:= High(gMonsters
);
410 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and gMonsters
[i
].Collide(X
, Y
) then
411 if HitMonster(gMonsters
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
413 if AllowPush
then gMonsters
[i
].Push(vx
, vy
);
419 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
426 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
430 if gAdvCorpses
and (h
<> -1) then
432 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
434 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
435 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
436 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
437 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
440 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
441 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
445 pl
:= g_Player_Get(SpawnerUID
);
453 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
455 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
456 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
457 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
458 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
460 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
461 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
463 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
465 gPlayers
[i
].BFGHit();
468 h
:= High(gMonsters
);
472 if (gMonsters
[i
] <> nil) and (gMonsters
[i
].Live
) and (gMonsters
[i
].UID
<> SpawnerUID
) then
474 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
475 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
476 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
477 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
478 if HitMonster(gMonsters
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
) then gMonsters
[i
].BFGHit();
481 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord
;
483 find_id
, FramesID
: DWORD
;
486 find_id
:= FindShot()
490 if Integer(find_id
) >= High(Shots
) then
491 SetLength(Shots
, find_id
+ 64)
495 WEAPON_ROCKETLAUNCHER
:
497 with Shots
[find_id
] do
501 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
502 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
506 ShotType
:= WEAPON_ROCKETLAUNCHER
;
507 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
513 with Shots
[find_id
] do
517 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
518 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
521 ShotType
:= WEAPON_PLASMA
;
522 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
523 Animation
:= TAnimation
.Create(FramesID
, True, 5);
529 with Shots
[find_id
] do
533 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
534 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
537 ShotType
:= WEAPON_BFG
;
538 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
539 Animation
:= TAnimation
.Create(FramesID
, True, 6);
545 with Shots
[find_id
] do
549 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
550 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
553 ShotType
:= WEAPON_FLAMETHROWER
;
562 with Shots
[find_id
] do
566 Obj
.Rect
.Width
:= 16;
567 Obj
.Rect
.Height
:= 16;
570 ShotType
:= WEAPON_IMP_FIRE
;
571 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
572 Animation
:= TAnimation
.Create(FramesID
, True, 4);
578 with Shots
[find_id
] do
582 Obj
.Rect
.Width
:= 16;
583 Obj
.Rect
.Height
:= 16;
586 ShotType
:= WEAPON_CACO_FIRE
;
587 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
588 Animation
:= TAnimation
.Create(FramesID
, True, 4);
594 with Shots
[find_id
] do
598 Obj
.Rect
.Width
:= 32;
599 Obj
.Rect
.Height
:= 32;
602 ShotType
:= WEAPON_MANCUB_FIRE
;
603 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
604 Animation
:= TAnimation
.Create(FramesID
, True, 4);
610 with Shots
[find_id
] do
614 Obj
.Rect
.Width
:= 32;
615 Obj
.Rect
.Height
:= 16;
618 ShotType
:= WEAPON_BARON_FIRE
;
619 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
620 Animation
:= TAnimation
.Create(FramesID
, True, 4);
626 with Shots
[find_id
] do
630 Obj
.Rect
.Width
:= 16;
631 Obj
.Rect
.Height
:= 16;
634 ShotType
:= WEAPON_BSP_FIRE
;
635 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
636 Animation
:= TAnimation
.Create(FramesID
, True, 4);
642 with Shots
[find_id
] do
646 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
647 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
650 ShotType
:= WEAPON_SKEL_FIRE
;
652 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
653 Animation
:= TAnimation
.Create(FramesID
, True, 5);
658 Shots
[find_id
].Obj
.X
:= X
;
659 Shots
[find_id
].Obj
.Y
:= Y
;
660 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
661 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
662 Shots
[find_id
].Obj
.Accel
.X
:= 0;
663 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
664 Shots
[find_id
].SpawnerUID
:= Spawner
;
668 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
675 a
:= Max(Abs(xd
), Abs(yd
));
681 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
682 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
683 Shots
[i
].Obj
.Accel
.X
:= 0;
684 Shots
[i
].Obj
.Accel
.Y
:= 0;
685 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
686 Shots
[i
].Timeout
:= 900 // ~25 sec
687 else if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
688 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
690 Shots
[i
].Timeout
:= 550 // ~15 sec
693 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
697 function PlayerHit(Team
: Byte = 0): Boolean;
708 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
711 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
713 p
:= g_Player_Get(SpawnerUID
);
715 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
718 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
720 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
721 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
723 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
729 function MonsterHit(): Boolean;
734 h
:= High(gMonsters
);
738 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and g_Obj_Collide(obj
, @gMonsters
[i
].Obj
) then
739 if HitMonster(gMonsters
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
741 gMonsters
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
742 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
754 if gAdvCorpses
and (h
<> -1) then
756 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
757 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
760 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
761 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
766 case gGameSettings
.GameMode
of
770 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
787 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
804 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
818 // È â êîíöå ñâîèõ èãðîêîâ
829 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
833 case g_GetUIDType(UID
) of
834 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
835 UID_MONSTER
: Result
:= HitMonster(g_Monsters_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
840 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
842 i
, h
, r
, dx
, dy
, m
, mm
: Integer;
847 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
855 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
858 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
859 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
861 if dx
> 1000 then dx
:= 1000;
862 if dy
> 1000 then dy
:= 1000;
864 if dx
*dx
+dy
*dy
< r
then
866 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
867 // PLAYER_RECT.Width, PLAYER_RECT.Height);
869 mm
:= Max(abs(dx
), abs(dy
));
870 if mm
= 0 then mm
:= 1;
872 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
873 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
877 h
:= High(gMonsters
);
881 if gMonsters
[i
] <> nil then
884 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
885 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
887 if dx
> 1000 then dx
:= 1000;
888 if dy
> 1000 then dy
:= 1000;
890 if dx
*dx
+dy
*dy
< r
then
892 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
893 // Obj.Rect.Width, Obj.Rect.Height);
895 mm
:= Max(abs(dx
), abs(dy
));
896 if mm
= 0 then mm
:= 1;
898 if gMonsters
[i
].Live
then
899 HitMonster(gMonsters
[i
], ((gMonsters
[i
].Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
,
900 0, 0, SpawnerUID
, HIT_ROCKET
);
902 gMonsters
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
908 if gAdvCorpses
and (h
<> -1) then
910 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
913 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
914 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
916 if dx
> 1000 then dx
:= 1000;
917 if dy
> 1000 then dy
:= 1000;
919 if dx
*dx
+dy
*dy
< r
then
921 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
922 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
924 mm
:= Max(abs(dx
), abs(dy
));
925 if mm
= 0 then mm
:= 1;
927 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
933 if gAdvGibs
and (h
<> -1) then
935 if gGibs
[i
].Live
then
938 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
939 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
941 if dx
> 1000 then dx
:= 1000;
942 if dy
> 1000 then dy
:= 1000;
944 if dx
*dx
+dy
*dy
< r
then
946 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
947 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
948 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
949 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
951 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
956 procedure g_Weapon_Init();
961 procedure g_Weapon_Free();
967 for i
:= 0 to High(Shots
) do
968 if Shots
[i
].ShotType
<> 0 then
969 Shots
[i
].Animation
.Free();
977 procedure g_Weapon_LoadData();
979 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
981 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
982 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
983 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
984 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
985 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
986 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
987 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
988 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
989 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
990 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
991 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
992 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
993 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
994 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
995 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
996 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
997 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
998 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
999 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1006 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1007 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1008 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1009 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1010 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1011 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1012 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1014 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1015 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1016 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1017 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1018 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1019 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1020 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1021 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1022 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1023 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1024 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1025 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1026 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1027 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1028 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1029 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1030 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1031 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1032 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1033 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1034 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1036 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1037 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1040 procedure g_Weapon_FreeData();
1042 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1044 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1045 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1046 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1047 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1048 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1049 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1050 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1051 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1052 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1053 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1054 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1055 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1056 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1057 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1058 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1059 g_Sound_Delete('SOUND_FIRE');
1060 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1061 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1062 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1063 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1064 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1065 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1066 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1067 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1068 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1069 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1070 g_Sound_Delete('SOUND_PLAYER_JETON');
1071 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1072 g_Sound_Delete('SOUND_PLAYER_CASING1');
1073 g_Sound_Delete('SOUND_PLAYER_CASING2');
1074 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1075 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1077 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1078 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1079 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1080 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1081 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1082 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1083 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1084 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1085 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1086 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1087 g_Frames_DeleteByName('FRAMES_BFGHIT');
1088 g_Frames_DeleteByName('FRAMES_FIRE');
1089 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1090 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1091 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1092 g_Frames_DeleteByName('FRAMES_SMOKE');
1093 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1094 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1097 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1109 t1
, _collide
: Boolean;
1112 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1114 SinCos(DegToRad(-a
), s
, c
);
1116 if Abs(s
) < 0.01 then s
:= 0;
1117 if Abs(c
) < 0.01 then c
:= 0;
1119 x2
:= x
+Round(c
*gMapInfo
.Width
);
1120 y2
:= y
+Round(s
*gMapInfo
.Width
);
1122 t1
:= gWalls
<> nil;
1124 w
:= gMapInfo
.Width
;
1125 h
:= gMapInfo
.Height
;
1132 if (xd
= 0) and (yd
= 0) then Exit
;
1134 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1135 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1140 if dx
> dy
then d
:= dx
else d
:= dy
;
1142 //blood vel, for Monster.Damage()
1143 //vx := (dx*10 div d)*xi;
1144 //vy := (dy*10 div d)*yi;
1166 if (yy
> h
) or (yy
< 0) then Break
;
1167 if (xx
> w
) or (xx
< 0) then Break
;
1170 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1173 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1174 if g_Game_IsServer
and g_Game_IsNet
then
1175 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1178 if not _collide
then
1179 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1185 if CheckTrigger
and g_Game_IsServer
then
1186 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1189 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1197 obj
.rect
.Width
:= 39;
1198 obj
.rect
.Height
:= 52;
1204 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1205 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1207 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1210 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1218 obj
.rect
.Width
:= 32;
1219 obj
.rect
.Height
:= 52;
1225 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1228 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1229 Silent
: Boolean = False);
1235 find_id
:= FindShot()
1239 if Integer(find_id
) >= High(Shots
) then
1240 SetLength(Shots
, find_id
+ 64)
1243 with Shots
[find_id
] do
1247 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1248 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1250 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1251 dy
:= -(Obj
.Rect
.Height
div 2);
1252 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1256 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1257 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1260 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1263 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1266 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1267 WID
: Integer = -1; Silent
: Boolean = False);
1269 find_id
, FramesID
: DWORD
;
1273 find_id
:= FindShot()
1277 if Integer(find_id
) >= High(Shots
) then
1278 SetLength(Shots
, find_id
+ 64)
1281 with Shots
[find_id
] do
1285 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1286 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1288 dx
:= -(Obj
.Rect
.Width
div 2);
1289 dy
:= -(Obj
.Rect
.Height
div 2);
1290 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1293 ShotType
:= WEAPON_SKEL_FIRE
;
1294 target
:= TargetUID
;
1295 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1296 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1299 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1302 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1305 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1306 Silent
: Boolean = False);
1308 find_id
, FramesID
: DWORD
;
1312 find_id
:= FindShot()
1316 if Integer(find_id
) >= High(Shots
) then
1317 SetLength(Shots
, find_id
+ 64);
1320 with Shots
[find_id
] do
1324 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1325 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1327 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1328 dy
:= -(Obj
.Rect
.Height
div 2);
1329 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1332 ShotType
:= WEAPON_PLASMA
;
1333 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1334 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1337 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1340 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1343 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1344 Silent
: Boolean = False);
1346 find_id
, FramesID
: DWORD
;
1350 find_id
:= FindShot()
1354 if Integer(find_id
) >= High(Shots
) then
1355 SetLength(Shots
, find_id
+ 64);
1358 with Shots
[find_id
] do
1362 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1363 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1365 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1366 dy
:= -(Obj
.Rect
.Height
div 2);
1367 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1370 ShotType
:= WEAPON_FLAMETHROWER
;
1376 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1378 // if not Silent then
1379 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1382 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1383 Silent
: Boolean = False);
1385 find_id
, FramesID
: DWORD
;
1389 find_id
:= FindShot()
1393 if Integer(find_id
) >= High(Shots
) then
1394 SetLength(Shots
, find_id
+ 64)
1397 with Shots
[find_id
] do
1401 Obj
.Rect
.Width
:= 16;
1402 Obj
.Rect
.Height
:= 16;
1404 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1405 dy
:= -(Obj
.Rect
.Height
div 2);
1406 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1409 ShotType
:= WEAPON_IMP_FIRE
;
1410 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1411 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1414 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1417 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1420 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1421 Silent
: Boolean = False);
1423 find_id
, FramesID
: DWORD
;
1427 find_id
:= FindShot()
1431 if Integer(find_id
) >= High(Shots
) then
1432 SetLength(Shots
, find_id
+ 64)
1435 with Shots
[find_id
] do
1439 Obj
.Rect
.Width
:= 16;
1440 Obj
.Rect
.Height
:= 16;
1442 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1443 dy
:= -(Obj
.Rect
.Height
div 2);
1444 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1447 ShotType
:= WEAPON_CACO_FIRE
;
1448 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1449 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1452 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1455 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1458 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1459 Silent
: Boolean = False);
1461 find_id
, FramesID
: DWORD
;
1465 find_id
:= FindShot()
1469 if Integer(find_id
) >= High(Shots
) then
1470 SetLength(Shots
, find_id
+ 64)
1473 with Shots
[find_id
] do
1477 Obj
.Rect
.Width
:= 32;
1478 Obj
.Rect
.Height
:= 16;
1480 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1481 dy
:= -(Obj
.Rect
.Height
div 2);
1482 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1485 ShotType
:= WEAPON_BARON_FIRE
;
1486 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1487 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1490 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1493 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1496 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1497 Silent
: Boolean = False);
1499 find_id
, FramesID
: DWORD
;
1503 find_id
:= FindShot()
1507 if Integer(find_id
) >= High(Shots
) then
1508 SetLength(Shots
, find_id
+ 64)
1511 with Shots
[find_id
] do
1515 Obj
.Rect
.Width
:= 16;
1516 Obj
.Rect
.Height
:= 16;
1518 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1519 dy
:= -(Obj
.Rect
.Height
div 2);
1520 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1523 ShotType
:= WEAPON_BSP_FIRE
;
1524 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1525 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1528 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1531 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1534 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1535 Silent
: Boolean = False);
1537 find_id
, FramesID
: DWORD
;
1541 find_id
:= FindShot()
1545 if Integer(find_id
) >= High(Shots
) then
1546 SetLength(Shots
, find_id
+ 64)
1549 with Shots
[find_id
] do
1553 Obj
.Rect
.Width
:= 32;
1554 Obj
.Rect
.Height
:= 32;
1556 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1557 dy
:= -(Obj
.Rect
.Height
div 2);
1558 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1561 ShotType
:= WEAPON_MANCUB_FIRE
;
1562 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1563 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1566 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1569 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1572 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1573 Silent
: Boolean = False);
1575 find_id
, FramesID
: DWORD
;
1579 find_id
:= FindShot()
1583 if Integer(find_id
) >= High(Shots
) then
1584 SetLength(Shots
, find_id
+ 64)
1587 with Shots
[find_id
] do
1591 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1592 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1594 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1595 dy
:= -(Obj
.Rect
.Height
div 2);
1596 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1599 ShotType
:= WEAPON_BFG
;
1600 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1601 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1604 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1607 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1610 procedure g_Weapon_bfghit(x
, y
: Integer);
1615 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1617 Anim
:= TAnimation
.Create(ID
, False, 4);
1618 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1623 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1624 Silent
: Boolean = False);
1627 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1629 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1630 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1632 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1633 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1637 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1638 Silent
: Boolean = False);
1641 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1643 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1644 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1645 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1647 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1648 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1652 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1653 Silent
: Boolean = False);
1658 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1662 j
:= Random(17)-8; // -8 .. 8
1663 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1667 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1668 Silent
: Boolean = False);
1673 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1675 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1678 j
:= Random(41)-20; // -20 .. 20
1679 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1683 procedure g_Weapon_Update();
1685 i
, a
, h
, cx
, cy
, oldvx
, oldvy
: Integer;
1698 for i
:= 0 to High(Shots
) do
1700 if Shots
[i
].ShotType
= 0 then
1707 Timeout
:= Timeout
- 1;
1710 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1711 if g_Game_IsServer
then
1712 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1713 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1719 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1720 if triggers
= nil then
1727 if not InDWArray(t
[a
], triggers
) then
1729 SetLength(triggers
, Length(triggers
)+1);
1730 triggers
[High(triggers
)] := t
[a
];
1735 // Àíèìàöèÿ ñíàðÿäà:
1736 if Animation
<> nil then
1740 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1741 (ShotType
<> WEAPON_BFG
) and
1742 (ShotType
<> WEAPON_BSP_FIRE
);
1744 st
:= g_Obj_Move(@Obj
, False, spl
);
1746 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1747 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1749 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1755 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1756 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1759 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1761 // Âûëåòåëà èç âîäû:
1762 if WordBool(st
and MOVE_HITAIR
) then
1763 g_Obj_SetSpeed(@Obj
, 12);
1765 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1766 if WordBool(st
and MOVE_INWATER
) then
1767 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1768 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1769 1+Random(3), 16, 16)
1771 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1773 Anim
:= TAnimation
.Create(_id
, False, 3);
1775 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
1776 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1777 Anim
, ONCEANIM_SMOKE
);
1781 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1782 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1783 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1789 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1791 if ShotType
= WEAPON_SKEL_FIRE
then
1792 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1793 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1795 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1796 Anim
.Blending
:= False;
1797 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
1802 begin // Âçðûâ Ðàêåòû
1803 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1805 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1806 Anim
.Blending
:= False;
1807 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1812 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1817 if ShotType
= WEAPON_SKEL_FIRE
then
1818 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1819 if GetPos(target
, @o
) then
1820 throw(i
, Obj
.X
, Obj
.Y
,
1821 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1822 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1827 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1829 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1830 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1832 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1833 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1839 if (ShotType
= WEAPON_PLASMA
) and
1840 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1845 if ShotType
= WEAPON_BSP_FIRE
then
1848 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1849 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1850 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1853 if ShotType
= WEAPON_PLASMA
then
1854 s
:= 'FRAMES_EXPLODE_PLASMA'
1856 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1859 if g_Frames_Get(TextureID
, s
) then
1861 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1862 Anim
.Blending
:= False;
1863 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1867 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1873 WEAPON_FLAMETHROWER
: // Îãíåìåò
1875 // Ïîä âîäîé íå ñòðåëÿåò, ñî âðåìåíåì óìèðàåò
1876 if (Timeout
< 1) or WordBool(st
and (MOVE_INWATER
)) then
1884 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
1885 // Ïîïàëè â ñòåíó èëè â âîäó:
1886 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
1892 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITWATER
)) then
1898 a
:= IfThen(Stopped
= 0, 2, 1);
1899 // Åñëè â êîãî-òî ïîïàëè
1900 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
1902 // HIT_FLAME ñàì ïîäîææåò
1903 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1908 if g_Frames_Get(_id
, 'FRAMES_FLAME') then
1910 Anim
:= TAnimation
.Create(_id
, False, 3);
1913 0: g_GFX_OnceAnim(cx
-4+Random(8)-(Anim
.Width
div 2),
1914 cy
-4+Random(8)-(Anim
.Height
div 2),
1915 Anim
, ONCEANIM_SMOKE
);
1916 1: g_GFX_OnceAnim(cx
-4+Random(8)-(Anim
.Width
div 2),
1917 cy
-12+Random(24)-(Anim
.Height
div 2),
1918 Anim
, ONCEANIM_SMOKE
);
1919 2: g_GFX_OnceAnim(cx
-12+Random(24)-(Anim
.Width
div 2),
1920 cy
-4+Random(8)-(Anim
.Height
div 2),
1921 Anim
, ONCEANIM_SMOKE
);
1929 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1930 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1932 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
1933 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
1938 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1939 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1940 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
1944 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
1947 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
1949 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1950 Anim
.Blending
:= False;
1951 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1955 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
1961 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1964 if WordBool(st
and MOVE_HITAIR
) then
1965 g_Obj_SetSpeed(@Obj
, 16);
1968 if ShotType
= WEAPON_IMP_FIRE
then
1971 if ShotType
= WEAPON_CACO_FIRE
then
1976 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1977 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1978 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
1981 if ShotType
= WEAPON_IMP_FIRE
then
1982 s
:= 'FRAMES_EXPLODE_IMPFIRE'
1984 if ShotType
= WEAPON_CACO_FIRE
then
1985 s
:= 'FRAMES_EXPLODE_CACOFIRE'
1987 s
:= 'FRAMES_EXPLODE_BARONFIRE';
1990 if g_Frames_Get(TextureID
, s
) then
1992 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1993 Anim
.Blending
:= False;
1994 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
1998 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2004 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2007 if WordBool(st
and MOVE_HITAIR
) then
2008 g_Obj_SetSpeed(@Obj
, 16);
2010 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2011 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2012 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2016 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2018 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2019 Anim
.Blending
:= False;
2020 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2024 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2029 end; // case ShotType of...
2031 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2032 if (ShotType
= 0) then
2034 if gGameSettings
.GameType
= GT_SERVER
then
2035 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2036 if Animation
<> nil then
2042 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2043 if gGameSettings
.GameType
= GT_SERVER
then
2044 MH_SEND_UpdateShot(i
);
2049 procedure g_Weapon_Draw();
2058 for i
:= 0 to High(Shots
) do
2059 if Shots
[i
].ShotType
<> 0 then
2062 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2063 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2064 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2065 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2066 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
2070 p
.X
:= Obj
.Rect
.Width
div 2;
2071 p
.Y
:= Obj
.Rect
.Height
div 2;
2073 if Animation
<> nil then
2075 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2076 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2077 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2078 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
2080 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
2082 else if TextureID
<> 0 then
2084 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
2085 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
2087 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
2090 if g_debug_Frames
then
2092 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
2094 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
2095 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
2101 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2110 for a
:= 0 to High(Shots
) do
2111 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2112 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2113 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2114 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2115 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2116 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2117 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2124 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
2126 count
, i
, j
: Integer;
2129 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2131 if Shots
<> nil then
2132 for i
:= 0 to High(Shots
) do
2133 if Shots
[i
].ShotType
<> 0 then
2136 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2138 // Êîëè÷åñòâî ñíàðÿäîâ:
2139 Mem
.WriteInt(count
);
2144 for i
:= 0 to High(Shots
) do
2145 if Shots
[i
].ShotType
<> 0 then
2147 // Ñèãíàòóðà ñíàðÿäà:
2148 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2151 Mem
.WriteByte(Shots
[i
].ShotType
);
2153 Mem
.WriteWord(Shots
[i
].Target
);
2155 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2156 // Ðàçìåð ïîëÿ Triggers:
2157 dw
:= Length(Shots
[i
].Triggers
);
2159 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2160 for j
:= 0 to Integer(dw
)-1 do
2161 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2163 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2164 // Êîñòûëèíà åáàíàÿ:
2165 Mem
.WriteByte(Shots
[i
].Stopped
);
2169 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2171 count
, i
, j
: Integer;
2177 // Êîëè÷åñòâî ñíàðÿäîâ:
2180 SetLength(Shots
, count
);
2185 for i
:= 0 to count
-1 do
2187 // Ñèãíàòóðà ñíàðÿäà:
2189 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2191 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2194 Mem
.ReadByte(Shots
[i
].ShotType
);
2196 Mem
.ReadWord(Shots
[i
].Target
);
2198 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2199 // Ðàçìåð ïîëÿ Triggers:
2201 SetLength(Shots
[i
].Triggers
, dw
);
2202 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2203 for j
:= 0 to Integer(dw
)-1 do
2204 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2206 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2207 // Êîñòûëèíà åáàíàÿ:
2208 Mem
.ReadByte(Shots
[i
].Stopped
);
2210 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2211 Shots
[i
].TextureID
:= DWORD(-1);
2212 Shots
[i
].Animation
:= nil;
2214 case Shots
[i
].ShotType
of
2215 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2217 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2221 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2222 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2226 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2227 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2231 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2232 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2236 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2237 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2241 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2242 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2246 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2247 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2251 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2252 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2258 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2266 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2270 if ShotType
= 0 then Exit
;
2273 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2274 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2277 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2281 if ShotType
= WEAPON_SKEL_FIRE
then
2282 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2283 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2285 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2286 Anim
.Blending
:= False;
2287 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2292 begin // Âçðûâ Ðàêåòû
2293 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2295 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2296 Anim
.Blending
:= False;
2297 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2301 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2305 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2307 if ShotType
= WEAPON_PLASMA
then
2308 s
:= 'FRAMES_EXPLODE_PLASMA'
2310 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2312 if g_Frames_Get(TextureID
, s
) and loud
then
2314 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2315 Anim
.Blending
:= False;
2316 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2319 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2326 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2328 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2329 Anim
.Blending
:= False;
2330 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2333 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2337 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2339 if ShotType
= WEAPON_IMP_FIRE
then
2340 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2342 if ShotType
= WEAPON_CACO_FIRE
then
2343 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2345 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2347 if g_Frames_Get(TextureID
, s
) and Loud
then
2349 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2350 Anim
.Blending
:= False;
2351 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2354 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2358 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2360 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2362 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2363 Anim
.Blending
:= False;
2364 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2367 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2370 end; // case ShotType of...