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, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
16 {.$DEFINE GWEP_HITSCAN_TRACE_BITMAP_CHECKER}
22 SysUtils
, Classes
, mempool
,
23 g_textures
, g_basic
, g_phys
, xprofiler
;
33 Animation
: TAnimation
;
38 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
43 Shots
: array of TShot
= nil;
44 LastShotID
: Integer = 0;
46 procedure g_Weapon_LoadData();
47 procedure g_Weapon_FreeData();
48 procedure g_Weapon_Init();
49 procedure g_Weapon_Free();
50 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
51 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
52 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
54 procedure g_Weapon_gun(const x
, y
, xd
, yd
, v
, indmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
55 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
56 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
57 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
58 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
59 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
60 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
61 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
62 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
63 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
64 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
65 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
66 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
67 procedure g_Weapon_bfghit(x
, y
: Integer);
68 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
69 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
70 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
71 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
73 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
74 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
75 procedure g_Weapon_PreUpdate();
76 procedure g_Weapon_Update();
77 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
78 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
80 procedure g_Weapon_SaveState (st
: TStream
);
81 procedure g_Weapon_LoadState (st
: TStream
);
83 procedure g_Weapon_AddDynLights();
92 WEAPON_ROCKETLAUNCHER
= 6;
95 WEAPON_SUPERPULEMET
= 9;
96 WEAPON_FLAMETHROWER
= 10;
97 WEAPON_ZOMBY_PISTOL
= 20;
100 WEAPON_CACO_FIRE
= 23;
101 WEAPON_BARON_FIRE
= 24;
102 WEAPON_MANCUB_FIRE
= 25;
103 WEAPON_SKEL_FIRE
= 26;
105 WP_FIRST
= WEAPON_KASTET
;
106 WP_LAST
= WEAPON_FLAMETHROWER
;
110 gwep_debug_fast_trace
: Boolean = true;
116 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
, g_panel
,
117 g_console
, g_options
, g_game
,
118 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
119 g_language
, g_netmsg
, g_grid
,
120 geom
, binheap
, hashtable
, utils
, xstreams
;
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
= 180;
148 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
151 PHitTime
= ^THitTime
;
155 plridx
: Integer; // if mon=nil
159 TBinHeapKeyHitTime
= class
161 class function less (const a
, b
: Integer): Boolean; inline;
164 // indicies in `wgunHitTime` array
165 TBinaryHeapHitTimes
= specialize TBinaryHeapBase
<Integer, TBinHeapKeyHitTime
>;
168 WaterMap
: array of array of DWORD
= nil;
169 //wgunMonHash: THashIntInt = nil;
170 wgunHitHeap
: TBinaryHeapHitTimes
= nil;
171 wgunHitTime
: array of THitTime
= nil;
172 wgunHitTimeUsed
: Integer = 0;
175 class function TBinHeapKeyHitTime
.less (const a
, b
: Integer): Boolean;
179 hta
:= @wgunHitTime
[a
];
180 htb
:= @wgunHitTime
[b
];
181 if (hta
.distSq
<> htb
.distSq
) then begin result
:= (hta
.distSq
< htb
.distSq
); exit
; end;
182 if (hta
.mon
<> nil) then
185 if (htb
.mon
= nil) then begin result
:= false; exit
; end; // players first
186 result
:= (hta
.mon
.UID
< htb
.mon
.UID
); // why not?
191 if (htb
.mon
<> nil) then begin result
:= true; exit
; end; // players first
192 result
:= (hta
.plridx
< htb
.plridx
); // why not?
197 procedure appendHitTimeMon (adistSq
: Integer; amon
: TMonster
; ax
, ay
: Integer);
199 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
200 with wgunHitTime
[wgunHitTimeUsed
] do
208 wgunHitHeap
.insert(wgunHitTimeUsed
);
209 Inc(wgunHitTimeUsed
);
213 procedure appendHitTimePlr (adistSq
: Integer; aplridx
: Integer; ax
, ay
: Integer);
215 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
216 with wgunHitTime
[wgunHitTimeUsed
] do
224 wgunHitHeap
.insert(wgunHitTimeUsed
);
225 Inc(wgunHitTimeUsed
);
229 function FindShot(): DWORD
;
234 for i
:= 0 to High(Shots
) do
235 if Shots
[i
].ShotType
= 0 then
238 LastShotID
:= Result
;
244 SetLength(Shots
, 128);
249 Result
:= High(Shots
) + 1;
250 SetLength(Shots
, Length(Shots
) + 128);
252 LastShotID
:= Result
;
255 procedure CreateWaterMap();
257 WaterArray
: Array of TWaterPanel
;
264 SetLength(WaterArray
, Length(gWater
));
266 for a
:= 0 to High(gWater
) do
268 WaterArray
[a
].X
:= gWater
[a
].X
;
269 WaterArray
[a
].Y
:= gWater
[a
].Y
;
270 WaterArray
[a
].Width
:= gWater
[a
].Width
;
271 WaterArray
[a
].Height
:= gWater
[a
].Height
;
272 WaterArray
[a
].Active
:= True;
275 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
277 for a
:= 0 to High(WaterArray
) do
278 if WaterArray
[a
].Active
then
280 WaterArray
[a
].Active
:= False;
281 m
:= Length(WaterMap
);
282 SetLength(WaterMap
, m
+1);
283 SetLength(WaterMap
[m
], 1);
290 for b
:= 0 to High(WaterArray
) do
291 if WaterArray
[b
].Active
then
292 for c
:= 0 to High(WaterMap
[m
]) do
293 if g_CollideAround(WaterArray
[b
].X
,
296 WaterArray
[b
].Height
,
297 WaterArray
[WaterMap
[m
][c
]].X
,
298 WaterArray
[WaterMap
[m
][c
]].Y
,
299 WaterArray
[WaterMap
[m
][c
]].Width
,
300 WaterArray
[WaterMap
[m
][c
]].Height
) then
302 WaterArray
[b
].Active
:= False;
303 SetLength(WaterMap
[m
],
304 Length(WaterMap
[m
])+1);
305 WaterMap
[m
][High(WaterMap
[m
])] := b
;
311 g_Game_StepLoading();
319 chkTrap_pl
: array [0..256] of Integer;
320 chkTrap_mn
: array [0..65535] of TMonster
;
322 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
324 //a, b, c, d, i1, i2: Integer;
325 //chkTrap_pl, chkTrap_mn: WArray;
326 plaCount
: Integer = 0;
327 mnaCount
: Integer = 0;
331 function monsWaterCheck (mon: TMonster): Boolean;
333 result := false; // don't stop
334 if mon.alive and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
337 chkTrap_mn[i2] := monidx;
342 function monsWaterCheck (mon
: TMonster
): Boolean;
344 result
:= false; // don't stop
345 if (mon
.trapCheckFrameId
<> frameId
) then
347 mon
.trapCheckFrameId
:= frameId
;
348 chkTrap_mn
[mnaCount
] := mon
;
354 a
, b
, c
, d
, f
: Integer;
357 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
359 frameId
:= g_Mons_getNewTrapFrameId();
364 //SetLength(chkTrap_pl, 1024);
365 //SetLength(chkTrap_mn, 1024);
366 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
367 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
369 for a
:= 0 to High(WaterMap
) do
371 for b
:= 0 to High(WaterMap
[a
]) do
373 pan
:= gWater
[WaterMap
[a
][b
]];
374 if not g_Obj_Collide(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, @Shots
[ID
].Obj
) then continue
;
376 for c
:= 0 to High(WaterMap
[a
]) do
378 pan
:= gWater
[WaterMap
[a
][c
]];
379 for d
:= 0 to High(gPlayers
) do
381 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].alive
) then
383 if gPlayers
[d
].Collide(pan
) then
386 while (f
< plaCount
) and (chkTrap_pl
[f
] <> d
) do Inc(f
);
387 if (f
= plaCount
) then
389 chkTrap_pl
[plaCount
] := d
;
391 if (plaCount
= Length(chkTrap_pl
)) then break
;
397 //g_Mons_ForEach(monsWaterCheck);
398 g_Mons_ForEachAliveAt(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, monsWaterCheck
);
401 for f
:= 0 to plaCount
-1 do gPlayers
[chkTrap_pl
[f
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
402 for f
:= 0 to mnaCount
-1 do chkTrap_mn
[f
].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
410 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
417 tt
:= g_GetUIDType(SpawnerUID
);
418 if tt
= UID_MONSTER
then
420 mon
:= g_Monsters_ByUID(SpawnerUID
);
422 mt
:= g_Monsters_ByUID(SpawnerUID
).MonsterType
429 if m
= nil then Exit
;
430 if m
.UID
= SpawnerUID
then
432 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
433 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
435 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
436 if (m
.MonsterType
= MONSTER_CYBER
) or
437 (m
.MonsterType
= MONSTER_BARREL
) then
444 if tt
= UID_MONSTER
then
446 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
447 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
450 // Îáà ìîíñòðà îäíîãî âèäà:
451 if mt
= m
.MonsterType
then
453 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
454 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
455 Exit
; // Ýòè íå áüþò ñâîèõ
459 if g_Game_IsServer
then
461 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
462 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
464 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
465 if t
= HIT_FLAME
then
466 m
.CatchFire(SpawnerUID
);
469 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
473 function HitPlayer (p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
477 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì
478 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then exit
;
480 if g_Game_IsServer
then
482 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
483 if (t
= HIT_FLAME
) then p
.CatchFire(SpawnerUID
);
490 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
492 function monsCheck (mon
: TMonster
): Boolean;
494 result
:= false; // don't stop
495 if (mon
.alive
) and (mon
.UID
<> SpawnerUID
) then
499 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
500 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
501 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
502 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
504 if HitMonster(mon
, 50, 0, 0, SpawnerUID
, HIT_SOME
) then mon
.BFGHit();
516 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
520 if gAdvCorpses
and (h
<> -1) then
522 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
524 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
525 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
526 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
527 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
529 Damage(50, SpawnerUID
, 0, 0);
530 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
531 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
535 pl
:= g_Player_Get(SpawnerUID
);
543 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].alive
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
545 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
546 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
547 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
548 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
550 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
551 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
553 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
555 gPlayers
[i
].BFGHit();
559 g_Mons_ForEachAlive(monsCheck
);
562 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
568 find_id
:= FindShot()
572 if Integer(find_id
) >= High(Shots
) then
573 SetLength(Shots
, find_id
+ 64)
577 WEAPON_ROCKETLAUNCHER
:
579 with Shots
[find_id
] do
583 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
584 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
588 ShotType
:= WEAPON_ROCKETLAUNCHER
;
589 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
595 with Shots
[find_id
] do
599 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
600 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
603 ShotType
:= WEAPON_PLASMA
;
604 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
605 Animation
:= TAnimation
.Create(FramesID
, True, 5);
611 with Shots
[find_id
] do
615 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
616 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
619 ShotType
:= WEAPON_BFG
;
620 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
621 Animation
:= TAnimation
.Create(FramesID
, True, 6);
627 with Shots
[find_id
] do
631 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
632 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
635 ShotType
:= WEAPON_FLAMETHROWER
;
638 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
644 with Shots
[find_id
] do
648 Obj
.Rect
.Width
:= 16;
649 Obj
.Rect
.Height
:= 16;
652 ShotType
:= WEAPON_IMP_FIRE
;
653 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
654 Animation
:= TAnimation
.Create(FramesID
, True, 4);
660 with Shots
[find_id
] do
664 Obj
.Rect
.Width
:= 16;
665 Obj
.Rect
.Height
:= 16;
668 ShotType
:= WEAPON_CACO_FIRE
;
669 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
670 Animation
:= TAnimation
.Create(FramesID
, True, 4);
676 with Shots
[find_id
] do
680 Obj
.Rect
.Width
:= 32;
681 Obj
.Rect
.Height
:= 32;
684 ShotType
:= WEAPON_MANCUB_FIRE
;
685 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
686 Animation
:= TAnimation
.Create(FramesID
, True, 4);
692 with Shots
[find_id
] do
696 Obj
.Rect
.Width
:= 32;
697 Obj
.Rect
.Height
:= 16;
700 ShotType
:= WEAPON_BARON_FIRE
;
701 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
702 Animation
:= TAnimation
.Create(FramesID
, True, 4);
708 with Shots
[find_id
] do
712 Obj
.Rect
.Width
:= 16;
713 Obj
.Rect
.Height
:= 16;
716 ShotType
:= WEAPON_BSP_FIRE
;
717 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
718 Animation
:= TAnimation
.Create(FramesID
, True, 4);
724 with Shots
[find_id
] do
728 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
729 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
732 ShotType
:= WEAPON_SKEL_FIRE
;
734 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
735 Animation
:= TAnimation
.Create(FramesID
, True, 5);
740 Shots
[find_id
].Obj
.oldX
:= X
;
741 Shots
[find_id
].Obj
.oldY
:= Y
;
742 Shots
[find_id
].Obj
.X
:= X
;
743 Shots
[find_id
].Obj
.Y
:= Y
;
744 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
745 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
746 Shots
[find_id
].Obj
.Accel
.X
:= 0;
747 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
748 Shots
[find_id
].SpawnerUID
:= Spawner
;
749 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
750 Shots
[find_id
].Stopped
:= 255
752 Shots
[find_id
].Stopped
:= 0;
756 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
763 a
:= Max(Abs(xd
), Abs(yd
));
767 Shots
[i
].Obj
.oldX
:= x
;
768 Shots
[i
].Obj
.oldY
:= y
;
771 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
772 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
773 Shots
[i
].Obj
.Accel
.X
:= 0;
774 Shots
[i
].Obj
.Accel
.Y
:= 0;
775 Shots
[i
].Stopped
:= 0;
776 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
777 Shots
[i
].Timeout
:= 900 // ~25 sec
780 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
781 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
783 Shots
[i
].Timeout
:= 550; // ~15 sec
787 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
791 function PlayerHit(Team
: Byte = 0): Boolean;
802 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
805 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
807 p
:= g_Player_Get(SpawnerUID
);
809 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
812 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
814 if t
<> HIT_FLAME
then
815 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
816 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
818 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
826 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
828 result := false; // don't stop
829 if mon.alive and g_Obj_Collide(obj, @mon.Obj) then
831 if HitMonster(mon, d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
833 if (t <> HIT_FLAME) then
835 mon.Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
836 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
844 function monsCheckHit (mon
: TMonster
): Boolean;
846 result
:= false; // don't stop
847 if HitMonster(mon
, d
, obj
.Vel
.X
, obj
.Vel
.Y
, SpawnerUID
, t
) then
849 if (t
<> HIT_FLAME
) then
851 mon
.Push((obj
.Vel
.X
+obj
.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
852 (obj
.Vel
.Y
+obj
.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
858 function MonsterHit(): Boolean;
860 //result := g_Mons_ForEach(monsCheckHit);
861 //FIXME: accelerate this!
862 result
:= g_Mons_ForEachAliveAt(obj
.X
+obj
.Rect
.X
, obj
.Y
+obj
.Rect
.Y
, obj
.Rect
.Width
, obj
.Rect
.Height
, monsCheckHit
);
872 if gAdvCorpses
and (h
<> -1) then
874 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
875 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
878 gCorpses
[i
].Damage(d
, SpawnerUID
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
879 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
884 case gGameSettings
.GameMode
of
888 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
895 // È â êîíöå èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
896 // (èëè ñíàðÿä îò ìîíñòðà, èëè friendlyfire, èëè friendly_hit_projectile)
897 if (g_GetUIDType(SpawnerUID
) <> UID_PLAYER
) or
898 LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
911 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
928 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
942 // È â êîíöå ñâîèõ èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
943 // (èëè friendlyfire, èëè friendly_hit_projectile)
944 if LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
957 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
961 case g_GetUIDType(UID
) of
962 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
963 UID_MONSTER
: Result
:= HitMonster(g_Monsters_ByUID(UID
), d
, 0, 0, SpawnerUID
, t
);
968 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
970 r
: Integer; // squared radius
972 function monsExCheck (mon
: TMonster
): Boolean;
976 result
:= false; // don't stop
978 dx
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-X
;
979 dy
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-Y
;
981 if dx
> 1000 then dx
:= 1000;
982 if dy
> 1000 then dy
:= 1000;
984 if (dx
*dx
+dy
*dy
< r
) then
986 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
987 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
989 mm
:= Max(abs(dx
), abs(dy
));
990 if mm
= 0 then mm
:= 1;
994 HitMonster(mon
, ((mon
.Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
, 0, 0, SpawnerUID
, HIT_ROCKET
);
997 mon
.Push((dx
*7) div mm
, (dy
*7) div mm
);
1003 i
, h
, dx
, dy
, m
, mm
: Integer;
1008 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
1012 h
:= High(gPlayers
);
1016 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1019 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1020 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1022 if dx
> 1000 then dx
:= 1000;
1023 if dy
> 1000 then dy
:= 1000;
1025 if dx
*dx
+dy
*dy
< r
then
1027 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1028 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1030 mm
:= Max(abs(dx
), abs(dy
));
1031 if mm
= 0 then mm
:= 1;
1033 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
1034 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
1038 //g_Mons_ForEach(monsExCheck);
1039 g_Mons_ForEachAt(X
-(rad
+32), Y
-(rad
+32), (rad
+32)*2, (rad
+32)*2, monsExCheck
);
1041 h
:= High(gCorpses
);
1043 if gAdvCorpses
and (h
<> -1) then
1045 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
1048 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1049 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1051 if dx
> 1000 then dx
:= 1000;
1052 if dy
> 1000 then dy
:= 1000;
1054 if dx
*dx
+dy
*dy
< r
then
1056 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1057 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1059 mm
:= Max(abs(dx
), abs(dy
));
1060 if mm
= 0 then mm
:= 1;
1062 Damage(Round(100*(rad
-m
)/rad
), SpawnerUID
, (dx
*10) div mm
, (dy
*10) div mm
);
1068 if gAdvGibs
and (h
<> -1) then
1070 if gGibs
[i
].alive
then
1073 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1074 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1076 if dx
> 1000 then dx
:= 1000;
1077 if dy
> 1000 then dy
:= 1000;
1079 if dx
*dx
+dy
*dy
< r
then
1081 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1082 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1083 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
1084 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
1086 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
1087 positionChanged(); // this updates spatial accelerators
1092 procedure g_Weapon_Init();
1097 procedure g_Weapon_Free();
1101 if Shots
<> nil then
1103 for i
:= 0 to High(Shots
) do
1104 if Shots
[i
].ShotType
<> 0 then
1105 Shots
[i
].Animation
.Free();
1113 procedure g_Weapon_LoadData();
1115 e_WriteLog('Loading weapons data...', TMsgType
.Notify
);
1117 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
1118 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
1119 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1120 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1121 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1122 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1123 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1124 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1125 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1126 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1127 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1128 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1129 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1130 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1131 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1132 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1133 g_Sound_CreateWADEx('SOUND_IGNITE', GameWAD
+':SOUNDS\IGNITE');
1134 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1135 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1136 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1137 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1138 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1139 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1140 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1141 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1142 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1143 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD
+':SOUNDS\STARTFLM');
1144 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD
+':SOUNDS\STOPFLM');
1145 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD
+':SOUNDS\WORKFLM');
1146 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1147 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1148 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1149 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1150 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1151 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1152 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1154 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1155 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1156 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1157 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1158 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1159 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1160 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1161 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1162 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1163 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1164 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1165 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1166 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1167 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1168 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1169 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1170 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1171 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1172 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1173 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1174 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1176 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1177 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1179 //wgunMonHash := hashNewIntInt();
1180 wgunHitHeap
:= TBinaryHeapHitTimes
.Create();
1183 procedure g_Weapon_FreeData();
1185 e_WriteLog('Releasing weapons data...', TMsgType
.Notify
);
1187 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1188 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1189 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1190 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1191 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1192 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1193 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1194 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1195 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1196 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1197 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1198 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1199 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1200 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1201 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1202 g_Sound_Delete('SOUND_FIRE');
1203 g_Sound_Delete('SOUND_IGNITE');
1204 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1205 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1206 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1207 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1208 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1209 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1210 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1211 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1212 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1213 g_Sound_Delete('SOUND_WEAPON_FLAMEON');
1214 g_Sound_Delete('SOUND_WEAPON_FLAMEOFF');
1215 g_Sound_Delete('SOUND_WEAPON_FLAMEWORK');
1216 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1217 g_Sound_Delete('SOUND_PLAYER_JETON');
1218 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1219 g_Sound_Delete('SOUND_PLAYER_CASING1');
1220 g_Sound_Delete('SOUND_PLAYER_CASING2');
1221 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1222 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1224 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1225 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1226 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1227 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1228 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1229 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1230 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1231 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1232 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1233 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1234 g_Frames_DeleteByName('FRAMES_BFGHIT');
1235 g_Frames_DeleteByName('FRAMES_FIRE');
1236 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1237 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1238 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1239 g_Frames_DeleteByName('FRAMES_SMOKE');
1240 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1241 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1245 function GunHitPlayer (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Boolean;
1250 for i
:= 0 to High(gPlayers
) do
1252 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and gPlayers
[i
].Collide(X
, Y
) then
1254 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1256 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
1264 function GunHit (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Byte;
1266 function monsCheck (mon
: TMonster
): Boolean;
1268 result
:= false; // don't stop
1269 if HitMonster(mon
, dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1271 if AllowPush
then mon
.Push(vx
, vy
);
1278 if GunHitPlayer(X
, Y
, vx
, vy
, dmg
, SpawnerUID
, AllowPush
) then result
:= 1
1279 else if g_Mons_ForEachAliveAt(X
, Y
, 1, 1, monsCheck
) then result
:= 2;
1284 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1295 t1, _collide: Boolean;
1297 {$IF DEFINED(D2F_DEBUG)}
1299 showTime: Boolean = true;
1302 a := GetAngle(x, y, xd, yd)+180;
1304 SinCos(DegToRad(-a), s, c);
1306 if Abs(s) < 0.01 then s := 0;
1307 if Abs(c) < 0.01 then c := 0;
1309 x2 := x+Round(c*gMapInfo.Width);
1310 y2 := y+Round(s*gMapInfo.Width);
1312 t1 := gWalls <> nil;
1314 w := gMapInfo.Width;
1315 h := gMapInfo.Height;
1322 if (xd = 0) and (yd = 0) then Exit;
1324 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1325 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1330 if dx > dy then d := dx else d := dy;
1332 //blood vel, for Monster.Damage()
1333 //vx := (dx*10 div d)*xi;
1334 //vy := (dy*10 div d)*yi;
1336 {$IF DEFINED(D2F_DEBUG)}
1337 stt := getTimeMicro();
1360 if (yy > h) or (yy < 0) then Break;
1361 if (xx > w) or (xx < 0) then Break;
1364 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1367 {$IF DEFINED(D2F_DEBUG)}
1368 stt := getTimeMicro()-stt;
1369 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1372 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1373 if g_Game_IsServer and g_Game_IsNet then
1374 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1377 if not _collide then
1379 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1382 if _collide then Break;
1385 {$IF DEFINED(D2F_DEBUG)}
1388 stt := getTimeMicro()-stt;
1389 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1393 if CheckTrigger and g_Game_IsServer then
1394 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1400 procedure g_Weapon_gun (const x
, y
, xd
, yd
, v
, indmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1405 wallDistSq
: Integer = $3fffffff;
1406 spawnerPlr
: TPlayer
= nil;
1409 function doPlayerHit (idx
: Integer; hx
, hy
: Integer): Boolean;
1412 if (idx
< 0) or (idx
> High(gPlayers
)) then exit
;
1413 if (gPlayers
[idx
] = nil) or not gPlayers
[idx
].alive
then exit
;
1414 if (spawnerPlr
<> nil) then
1416 if ((gGameSettings
.Options
and (GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMDAMAGE
)) = 0) and
1417 (spawnerPlr
.Team
<> TEAM_NONE
) and (spawnerPlr
.Team
= gPlayers
[idx
].Team
) then
1419 if (spawnerPlr
<> gPlayers
[idx
]) and ((gGameSettings
.Options
and GAME_OPTION_TEAMABSORBDAMAGE
) = 0) then
1420 dmg
:= Max(1, dmg
div 2);
1424 result
:= HitPlayer(gPlayers
[idx
], dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1425 if result
and (v
<> 0) then gPlayers
[idx
].Push((xi
*v
), (yi
*v
));
1426 {$IF DEFINED(D2F_DEBUG)}
1427 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1431 function doMonsterHit (mon
: TMonster
; hx
, hy
: Integer): Boolean;
1434 if (mon
= nil) then exit
;
1435 result
:= HitMonster(mon
, dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1436 if result
and (v
<> 0) then mon
.Push((xi
*v
), (yi
*v
));
1437 {$IF DEFINED(D2F_DEBUG)}
1438 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1442 // collect players along hitray
1443 // return `true` if instant hit was detected
1444 function playerPossibleHit (): Boolean;
1447 px
, py
, pw
, ph
: Integer;
1453 for i
:= 0 to High(gPlayers
) do
1456 if (plr
<> nil) and plr
.alive
then
1458 plr
.getMapBox(px
, py
, pw
, ph
);
1459 if lineAABBIntersects(x
, y
, x2
, y2
, px
, py
, pw
, ph
, inx
, iny
) then
1461 distSq
:= distanceSq(x
, y
, inx
, iny
);
1462 if (distSq
= 0) then
1465 if doPlayerHit(i
, x
, y
) then begin result
:= true; exit
; end;
1467 else if (distSq
< wallDistSq
) then
1469 appendHitTimePlr(distSq
, i
, inx
, iny
);
1476 procedure sqchecker (mon
: TMonster
);
1478 mx
, my
, mw
, mh
: Integer;
1482 mon
.getMapBox(mx
, my
, mw
, mh
);
1483 if lineAABBIntersects(x0
, y0
, x2
, y2
, mx
, my
, mw
, mh
, inx
, iny
) then
1485 distSq
:= distanceSq(x0
, y0
, inx
, iny
);
1486 if (distSq
< wallDistSq
) then appendHitTimeMon(distSq
, mon
, inx
, iny
);
1496 wallHitFlag
: Boolean = false;
1497 wallHitX
: Integer = 0;
1498 wallHitY
: Integer = 0;
1499 didHit
: Boolean = false;
1500 {$IF DEFINED(D2F_DEBUG)}
1504 it
: TMonsterGrid
.Iter
;
1507 if not gwep_debug_fast_trace then
1509 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1514 if (xd
= 0) and (yd
= 0) then exit
;
1516 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1517 spawnerPlr
:= g_Player_Get(SpawnerUID
);
1521 //wgunMonHash.reset(); //FIXME: clear hash on level change
1522 wgunHitHeap
.clear();
1523 wgunHitTimeUsed
:= 0;
1525 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1527 SinCos(DegToRad(-a
), s
, c
);
1529 if Abs(s
) < 0.01 then s
:= 0;
1530 if Abs(c
) < 0.01 then c
:= 0;
1534 x2
:= x
+Round(c
*gMapInfo
.Width
);
1535 y2
:= y
+Round(s
*gMapInfo
.Width
);
1540 if (dx
> 0) then xi
:= 1 else if (dx
< 0) then xi
:= -1 else xi
:= 0;
1541 if (dy
> 0) then yi
:= 1 else if (dy
< 0) then yi
:= -1 else yi
:= 0;
1543 {$IF DEFINED(D2F_DEBUG)}
1544 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x
, y
, x2
, y2
]), TMsgType
.Notify
);
1545 stt
:= getTimeMicro();
1548 wallHitFlag
:= (g_Map_traceToNearestWall(x
, y
, x2
, y2
, @wallHitX
, @wallHitY
) <> nil);
1553 wallDistSq
:= distanceSq(x
, y
, wallHitX
, wallHitY
);
1561 if playerPossibleHit() then exit
; // instant hit
1564 //g_Mons_AlongLine(x, y, x2, y2, sqchecker);
1566 it
:= monsGrid
.forEachAlongLine(x
, y
, x2
, y2
, -1);
1567 for mit
in it
do sqchecker(mit
^);
1570 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1571 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1572 while (wgunHitHeap
.count
> 0) do
1574 // has some entities to check, do it
1575 i
:= wgunHitHeap
.front
;
1576 wgunHitHeap
.popFront();
1578 xe
:= wgunHitTime
[i
].x
;
1579 ye
:= wgunHitTime
[i
].y
;
1580 // check if it is not behind the wall
1581 if (wgunHitTime
[i
].mon
<> nil) then
1583 didHit
:= doMonsterHit(wgunHitTime
[i
].mon
, xe
, ye
);
1587 didHit
:= doPlayerHit(wgunHitTime
[i
].plridx
, xe
, ye
);
1591 // need new coords for trigger
1594 wallHitFlag
:= false; // no sparks
1602 {$IF DEFINED(D2F_DEBUG)}
1603 stt
:= getTimeMicro()-stt
;
1604 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1606 g_GFX_Spark(wallHitX
, wallHitY
, 2+Random(2), 180+a
, 0, 0);
1607 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(wallHitX
, wallHitY
, 180+a
, NET_GFX_SPARK
);
1611 {$IF DEFINED(D2F_DEBUG)}
1612 stt
:= getTimeMicro()-stt
;
1613 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1617 if CheckTrigger
and g_Game_IsServer
then g_Triggers_PressL(X
, Y
, wallHitX
, wallHitY
, SpawnerUID
, ACTIVATE_SHOT
);
1621 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1629 obj
.rect
.Width
:= 39;
1630 obj
.rect
.Height
:= 52;
1636 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1637 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1639 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1642 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1650 obj
.rect
.Width
:= 32;
1651 obj
.rect
.Height
:= 52;
1657 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1660 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1661 Silent
: Boolean = False);
1667 find_id
:= FindShot()
1671 if Integer(find_id
) >= High(Shots
) then
1672 SetLength(Shots
, find_id
+ 64)
1675 with Shots
[find_id
] do
1679 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1680 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1682 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1683 dy
:= -(Obj
.Rect
.Height
div 2);
1685 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1686 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1690 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1693 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1696 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1699 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1700 WID
: Integer = -1; Silent
: Boolean = False);
1702 find_id
, FramesID
: DWORD
;
1706 find_id
:= FindShot()
1710 if Integer(find_id
) >= High(Shots
) then
1711 SetLength(Shots
, find_id
+ 64)
1714 with Shots
[find_id
] do
1718 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1719 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1721 dx
:= -(Obj
.Rect
.Width
div 2);
1722 dy
:= -(Obj
.Rect
.Height
div 2);
1724 ShotType
:= WEAPON_SKEL_FIRE
;
1725 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1728 target
:= TargetUID
;
1729 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1730 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1733 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1736 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1739 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1740 Silent
: Boolean = False);
1742 find_id
, FramesID
: DWORD
;
1746 find_id
:= FindShot()
1750 if Integer(find_id
) >= High(Shots
) then
1751 SetLength(Shots
, find_id
+ 64);
1754 with Shots
[find_id
] do
1758 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1759 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1761 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1762 dy
:= -(Obj
.Rect
.Height
div 2);
1764 ShotType
:= WEAPON_PLASMA
;
1765 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1768 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1769 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1772 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1775 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1778 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1779 Silent
: Boolean = False);
1785 find_id
:= FindShot()
1789 if Integer(find_id
) >= High(Shots
) then
1790 SetLength(Shots
, find_id
+ 64);
1793 with Shots
[find_id
] do
1797 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1798 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1800 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1801 dy
:= -(Obj
.Rect
.Height
div 2);
1803 ShotType
:= WEAPON_FLAMETHROWER
;
1804 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1809 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
1812 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1814 // if not Silent then
1815 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1818 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1819 Silent
: Boolean = False);
1821 find_id
, FramesID
: DWORD
;
1825 find_id
:= FindShot()
1829 if Integer(find_id
) >= High(Shots
) then
1830 SetLength(Shots
, find_id
+ 64)
1833 with Shots
[find_id
] do
1837 Obj
.Rect
.Width
:= 16;
1838 Obj
.Rect
.Height
:= 16;
1840 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1841 dy
:= -(Obj
.Rect
.Height
div 2);
1843 ShotType
:= WEAPON_IMP_FIRE
;
1844 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1847 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1848 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1851 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1854 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1857 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1858 Silent
: Boolean = False);
1860 find_id
, FramesID
: DWORD
;
1864 find_id
:= FindShot()
1868 if Integer(find_id
) >= High(Shots
) then
1869 SetLength(Shots
, find_id
+ 64)
1872 with Shots
[find_id
] do
1876 Obj
.Rect
.Width
:= 16;
1877 Obj
.Rect
.Height
:= 16;
1879 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1880 dy
:= -(Obj
.Rect
.Height
div 2);
1882 ShotType
:= WEAPON_CACO_FIRE
;
1883 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1886 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1887 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1890 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1893 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1896 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1897 Silent
: Boolean = False);
1899 find_id
, FramesID
: DWORD
;
1903 find_id
:= FindShot()
1907 if Integer(find_id
) >= High(Shots
) then
1908 SetLength(Shots
, find_id
+ 64)
1911 with Shots
[find_id
] do
1915 Obj
.Rect
.Width
:= 32;
1916 Obj
.Rect
.Height
:= 16;
1918 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1919 dy
:= -(Obj
.Rect
.Height
div 2);
1921 ShotType
:= WEAPON_BARON_FIRE
;
1922 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1925 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1926 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1929 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1932 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1935 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1936 Silent
: Boolean = False);
1938 find_id
, FramesID
: DWORD
;
1942 find_id
:= FindShot()
1946 if Integer(find_id
) >= High(Shots
) then
1947 SetLength(Shots
, find_id
+ 64)
1950 with Shots
[find_id
] do
1954 Obj
.Rect
.Width
:= 16;
1955 Obj
.Rect
.Height
:= 16;
1957 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1958 dy
:= -(Obj
.Rect
.Height
div 2);
1960 ShotType
:= WEAPON_BSP_FIRE
;
1961 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1965 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1966 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1969 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1972 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1975 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1976 Silent
: Boolean = False);
1978 find_id
, FramesID
: DWORD
;
1982 find_id
:= FindShot()
1986 if Integer(find_id
) >= High(Shots
) then
1987 SetLength(Shots
, find_id
+ 64)
1990 with Shots
[find_id
] do
1994 Obj
.Rect
.Width
:= 32;
1995 Obj
.Rect
.Height
:= 32;
1997 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1998 dy
:= -(Obj
.Rect
.Height
div 2);
2000 ShotType
:= WEAPON_MANCUB_FIRE
;
2001 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
2005 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
2006 Animation
:= TAnimation
.Create(FramesID
, True, 4);
2009 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
2012 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
2015 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
2016 Silent
: Boolean = False);
2018 find_id
, FramesID
: DWORD
;
2022 find_id
:= FindShot()
2026 if Integer(find_id
) >= High(Shots
) then
2027 SetLength(Shots
, find_id
+ 64)
2030 with Shots
[find_id
] do
2034 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
2035 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
2037 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
2038 dy
:= -(Obj
.Rect
.Height
div 2);
2040 ShotType
:= WEAPON_BFG
;
2041 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
2044 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
2045 Animation
:= TAnimation
.Create(FramesID
, True, 6);
2048 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
2051 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
2054 procedure g_Weapon_bfghit(x
, y
: Integer);
2059 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
2061 Anim
:= TAnimation
.Create(ID
, False, 4);
2062 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
2067 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2068 Silent
: Boolean = False);
2071 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
2073 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2074 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
2076 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
2077 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2081 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2082 Silent
: Boolean = False);
2085 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
2087 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2088 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
2089 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2091 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
2092 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2096 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2097 Silent
: Boolean = False);
2102 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
2106 j
:= Random(17)-8; // -8 .. 8
2107 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
2111 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2112 Silent
: Boolean = False);
2117 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
2119 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
2122 j
:= Random(41)-20; // -20 .. 20
2123 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
2127 procedure g_Weapon_PreUpdate();
2131 if Shots
= nil then Exit
;
2132 for i
:= 0 to High(Shots
) do
2133 if Shots
[i
].ShotType
<> 0 then
2135 Shots
[i
].Obj
.oldX
:= Shots
[i
].Obj
.X
;
2136 Shots
[i
].Obj
.oldY
:= Shots
[i
].Obj
.Y
;
2140 procedure g_Weapon_Update();
2142 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
2156 for i
:= 0 to High(Shots
) do
2158 if Shots
[i
].ShotType
= 0 then
2165 Timeout
:= Timeout
- 1;
2168 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2169 if (Stopped
= 0) and g_Game_IsServer
then
2170 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
2171 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
2177 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2178 if triggers
= nil then
2185 if not InDWArray(t
[a
], triggers
) then
2187 SetLength(triggers
, Length(triggers
)+1);
2188 triggers
[High(triggers
)] := t
[a
];
2193 // Àíèìàöèÿ ñíàðÿäà:
2194 if Animation
<> nil then
2198 spl
:= (ShotType
<> WEAPON_PLASMA
) and
2199 (ShotType
<> WEAPON_BFG
) and
2200 (ShotType
<> WEAPON_BSP_FIRE
) and
2201 (ShotType
<> WEAPON_FLAMETHROWER
);
2205 st
:= g_Obj_Move_Projectile(@Obj
, False, spl
);
2211 positionChanged(); // this updates spatial accelerators
2213 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
2214 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
2216 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2222 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2223 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2226 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2228 // Âûëåòåëà èç âîäû:
2229 if WordBool(st
and MOVE_HITAIR
) then
2230 g_Obj_SetSpeed(@Obj
, 12);
2232 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2233 if WordBool(st
and MOVE_INWATER
) then
2234 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
2235 Obj
.Y
+(Obj
.Rect
.Height
div 2),
2236 1+Random(3), 16, 16)
2238 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
2240 Anim
:= TAnimation
.Create(_id
, False, 3);
2242 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
2243 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
2244 Anim
, ONCEANIM_SMOKE
);
2248 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2249 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2250 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
2256 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
2258 if ShotType
= WEAPON_SKEL_FIRE
then
2259 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2260 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2262 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2263 Anim
.Blending
:= False;
2264 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
2265 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
2270 begin // Âçðûâ Ðàêåòû
2271 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2273 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2274 Anim
.Blending
:= False;
2275 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2276 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
2281 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2286 if ShotType
= WEAPON_SKEL_FIRE
then
2287 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2288 if GetPos(target
, @o
) then
2289 throw(i
, Obj
.X
, Obj
.Y
,
2290 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
2291 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
2296 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2298 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2299 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2301 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
2302 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
2308 if (ShotType
= WEAPON_PLASMA
) and
2309 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
2314 if ShotType
= WEAPON_BSP_FIRE
then
2317 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2318 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2319 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
2322 if ShotType
= WEAPON_PLASMA
then
2323 s
:= 'FRAMES_EXPLODE_PLASMA'
2325 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2328 if g_Frames_Get(TextureID
, s
) then
2330 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2331 Anim
.Blending
:= False;
2332 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2334 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
2337 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2343 WEAPON_FLAMETHROWER
: // Îãíåìåò
2345 // Ñî âðåìåíåì óìèðàåò
2346 if (Timeout
< 1) then
2352 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
2354 if WordBool(st
and MOVE_HITWATER
) then
2356 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
2358 Anim
:= TAnimation
.Create(_id
, False, 3);
2362 g_GFX_OnceAnim(cx
-4+tcx
-(Anim
.Width
div 2),
2363 cy
-4+tcy
-(Anim
.Height
div 2),
2364 Anim
, ONCEANIM_SMOKE
);
2369 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2376 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
2377 // Ïîïàëè â ñòåíó èëè â âîäó:
2378 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
2384 if WordBool(st
and MOVE_HITWALL
) then
2385 Stopped
:= MOVE_HITWALL
2386 else if WordBool(st
and MOVE_HITLAND
) then
2387 Stopped
:= MOVE_HITLAND
2388 else if WordBool(st
and MOVE_HITCEIL
) then
2389 Stopped
:= MOVE_HITCEIL
;
2392 a
:= IfThen(Stopped
= 0, 10, 1);
2393 // Åñëè â êîãî-òî ïîïàëè
2394 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
2396 // HIT_FLAME ñàì ïîäîææåò
2397 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2407 if (gTime
mod LongWord(tf
) = 0) then
2409 Anim
:= TAnimation
.Create(TextureID
, False, 2 + Random(2));
2412 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
2413 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
2414 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
2415 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
2417 g_GFX_OnceAnim(tcx
-(Anim
.Width
div 2), tcy
-(Anim
.Height
div 2), Anim
, ONCEANIM_SMOKE
);
2419 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2425 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2426 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2428 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2429 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2434 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2435 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2436 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2440 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2443 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
2445 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2446 Anim
.Blending
:= False;
2447 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2449 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2452 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2458 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2461 if WordBool(st
and MOVE_HITAIR
) then
2462 g_Obj_SetSpeed(@Obj
, 16);
2465 if ShotType
= WEAPON_IMP_FIRE
then
2468 if ShotType
= WEAPON_CACO_FIRE
then
2473 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2474 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2475 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2478 if ShotType
= WEAPON_IMP_FIRE
then
2479 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2481 if ShotType
= WEAPON_CACO_FIRE
then
2482 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2484 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2487 if g_Frames_Get(TextureID
, s
) then
2489 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2490 Anim
.Blending
:= False;
2491 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2495 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2501 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2504 if WordBool(st
and MOVE_HITAIR
) then
2505 g_Obj_SetSpeed(@Obj
, 16);
2507 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2508 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2509 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2513 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2515 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2516 Anim
.Blending
:= False;
2517 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2521 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2526 end; // case ShotType of...
2528 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2529 if (ShotType
= 0) then
2531 if gGameSettings
.GameType
= GT_SERVER
then
2532 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2533 if Animation
<> nil then
2539 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2540 if gGameSettings
.GameType
= GT_SERVER
then
2541 MH_SEND_UpdateShot(i
);
2546 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2555 for a
:= 0 to High(Shots
) do
2556 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2557 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2558 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2559 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2560 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2561 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2562 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2569 procedure g_Weapon_SaveState (st
: TStream
);
2571 count
, i
, j
: Integer;
2573 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2575 for i
:= 0 to High(Shots
) do if (Shots
[i
].ShotType
<> 0) then Inc(count
);
2577 // Êîëè÷åñòâî ñíàðÿäîâ
2578 utils
.WriteInt(st
, count
);
2580 if (count
= 0) then exit
;
2582 for i
:= 0 to High(Shots
) do
2584 if Shots
[i
].ShotType
<> 0 then
2586 // Ñèãíàòóðà ñíàðÿäà
2587 utils
.writeSign(st
, 'SHOT');
2588 utils
.writeInt(st
, Byte(0)); // version
2590 utils
.writeInt(st
, Byte(Shots
[i
].ShotType
));
2592 utils
.writeInt(st
, Word(Shots
[i
].Target
));
2594 utils
.writeInt(st
, Word(Shots
[i
].SpawnerUID
));
2595 // Ðàçìåð ïîëÿ Triggers
2596 utils
.writeInt(st
, Integer(Length(Shots
[i
].Triggers
)));
2597 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2598 for j
:= 0 to Length(Shots
[i
].Triggers
)-1 do utils
.writeInt(st
, LongWord(Shots
[i
].Triggers
[j
]));
2600 Obj_SaveState(st
, @Shots
[i
].Obj
);
2602 utils
.writeInt(st
, Byte(Shots
[i
].Stopped
));
2607 procedure g_Weapon_LoadState (st
: TStream
);
2609 count
, tc
, i
, j
: Integer;
2612 if (st
= nil) then exit
;
2614 // Êîëè÷åñòâî ñíàðÿäîâ
2615 count
:= utils
.readLongInt(st
);
2616 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid shots counter');
2618 SetLength(Shots
, count
);
2620 if (count
= 0) then exit
;
2622 for i
:= 0 to count
-1 do
2624 // Ñèãíàòóðà ñíàðÿäà
2625 if not utils
.checkSign(st
, 'SHOT') then raise XStreamError
.Create('invalid shot signature');
2626 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid shot version');
2628 Shots
[i
].ShotType
:= utils
.readByte(st
);
2630 Shots
[i
].Target
:= utils
.readWord(st
);
2632 Shots
[i
].SpawnerUID
:= utils
.readWord(st
);
2633 // Ðàçìåð ïîëÿ Triggers
2634 tc
:= utils
.readLongInt(st
);
2635 if (tc
< 0) or (tc
> 1024*1024) then raise XStreamError
.Create('invalid shot triggers counter');
2636 SetLength(Shots
[i
].Triggers
, tc
);
2637 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2638 for j
:= 0 to tc
-1 do Shots
[i
].Triggers
[j
] := utils
.readLongWord(st
);
2640 Obj_LoadState(@Shots
[i
].Obj
, st
);
2642 Shots
[i
].Stopped
:= utils
.readByte(st
);
2644 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2645 Shots
[i
].TextureID
:= DWORD(-1);
2646 Shots
[i
].Animation
:= nil;
2648 case Shots
[i
].ShotType
of
2649 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2651 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2655 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2656 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2660 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2661 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2665 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2666 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2670 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2671 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2675 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2676 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2680 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2681 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2685 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2686 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2692 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2700 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2704 if ShotType
= 0 then Exit
;
2707 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2708 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2711 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2715 if ShotType
= WEAPON_SKEL_FIRE
then
2716 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2717 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2719 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2720 Anim
.Blending
:= False;
2721 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2726 begin // Âçðûâ Ðàêåòû
2727 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2729 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2730 Anim
.Blending
:= False;
2731 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2735 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2739 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2741 if ShotType
= WEAPON_PLASMA
then
2742 s
:= 'FRAMES_EXPLODE_PLASMA'
2744 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2746 if g_Frames_Get(TextureID
, s
) and loud
then
2748 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2749 Anim
.Blending
:= False;
2750 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2753 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2760 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2762 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2763 Anim
.Blending
:= False;
2764 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2767 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2771 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2773 if ShotType
= WEAPON_IMP_FIRE
then
2774 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2776 if ShotType
= WEAPON_CACO_FIRE
then
2777 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2779 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2781 if g_Frames_Get(TextureID
, s
) and Loud
then
2783 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2784 Anim
.Blending
:= False;
2785 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2788 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2792 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2794 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2796 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2797 Anim
.Blending
:= False;
2798 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2801 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2804 end; // case ShotType of...
2812 procedure g_Weapon_AddDynLights();
2816 if Shots
= nil then Exit
;
2817 for i
:= 0 to High(Shots
) do
2819 if Shots
[i
].ShotType
= 0 then continue
;
2820 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2821 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2822 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2823 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2824 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2825 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2826 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2827 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2828 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2829 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2830 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2833 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2834 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)
2835 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2836 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)
2837 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2838 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)
2840 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);
2846 procedure TShot
.positionChanged (); begin end;