1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
17 {.$DEFINE GWEP_HITSCAN_TRACE_BITMAP_CHECKER}
24 g_textures
, g_basic
, e_graphics
, g_phys
, xprofiler
;
34 Animation
: TAnimation
;
39 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
44 Shots
: array of TShot
= nil;
45 LastShotID
: Integer = 0;
47 procedure g_Weapon_LoadData();
48 procedure g_Weapon_FreeData();
49 procedure g_Weapon_Init();
50 procedure g_Weapon_Free();
51 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
52 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
53 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
55 procedure g_Weapon_gun(const x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
56 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
57 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
58 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
59 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
60 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
61 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
62 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
63 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
64 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
65 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
66 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
67 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
68 procedure g_Weapon_bfghit(x
, y
: Integer);
69 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
70 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
71 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
72 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
74 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
75 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
76 procedure g_Weapon_Update();
77 procedure g_Weapon_Draw();
78 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
79 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
81 procedure g_Weapon_SaveState (st
: TStream
);
82 procedure g_Weapon_LoadState (st
: TStream
);
84 procedure g_Weapon_AddDynLights();
93 WEAPON_ROCKETLAUNCHER
= 6;
96 WEAPON_SUPERPULEMET
= 9;
97 WEAPON_FLAMETHROWER
= 10;
98 WEAPON_ZOMBY_PISTOL
= 20;
100 WEAPON_BSP_FIRE
= 22;
101 WEAPON_CACO_FIRE
= 23;
102 WEAPON_BARON_FIRE
= 24;
103 WEAPON_MANCUB_FIRE
= 25;
104 WEAPON_SKEL_FIRE
= 26;
106 WP_FIRST
= WEAPON_KASTET
;
107 WP_LAST
= WEAPON_FLAMETHROWER
;
111 gwep_debug_fast_trace
: Boolean = true;
117 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
, g_panel
,
118 g_console
, g_options
, g_game
,
119 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
120 g_language
, g_netmsg
, g_grid
,
121 geom
, binheap
, hashtable
, utils
, xstreams
;
131 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
132 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
134 SHOT_SKELFIRE_WIDTH
= 14;
135 SHOT_SKELFIRE_HEIGHT
= 14;
137 SHOT_PLASMA_WIDTH
= 16;
138 SHOT_PLASMA_HEIGHT
= 16;
141 SHOT_BFG_HEIGHT
= 32;
142 SHOT_BFG_DAMAGE
= 100;
143 SHOT_BFG_RADIUS
= 256;
145 SHOT_FLAME_WIDTH
= 4;
146 SHOT_FLAME_HEIGHT
= 4;
147 SHOT_FLAME_LIFETIME
= 180;
149 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
152 PHitTime
= ^THitTime
;
156 plridx
: Integer; // if mon=nil
160 // indicies in `wgunHitTime` array
161 TBinaryHeapHitTimes
= specialize TBinaryHeapBase
<Integer>;
164 WaterMap
: array of array of DWORD
= nil;
165 //wgunMonHash: THashIntInt = nil;
166 wgunHitHeap
: TBinaryHeapHitTimes
= nil;
167 wgunHitTime
: array of THitTime
= nil;
168 wgunHitTimeUsed
: Integer = 0;
171 function hitTimeLess (a
, b
: Integer): Boolean;
175 hta
:= @wgunHitTime
[a
];
176 htb
:= @wgunHitTime
[b
];
177 if (hta
.distSq
<> htb
.distSq
) then begin result
:= (hta
.distSq
< htb
.distSq
); exit
; end;
178 if (hta
.mon
<> nil) then
181 if (htb
.mon
= nil) then begin result
:= false; exit
; end; // players first
182 result
:= (hta
.mon
.UID
< htb
.mon
.UID
); // why not?
187 if (htb
.mon
<> nil) then begin result
:= true; exit
; end; // players first
188 result
:= (hta
.plridx
< htb
.plridx
); // why not?
193 procedure appendHitTimeMon (adistSq
: Integer; amon
: TMonster
; ax
, ay
: Integer);
195 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
196 with wgunHitTime
[wgunHitTimeUsed
] do
204 wgunHitHeap
.insert(wgunHitTimeUsed
);
205 Inc(wgunHitTimeUsed
);
209 procedure appendHitTimePlr (adistSq
: Integer; aplridx
: Integer; ax
, ay
: Integer);
211 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
212 with wgunHitTime
[wgunHitTimeUsed
] do
220 wgunHitHeap
.insert(wgunHitTimeUsed
);
221 Inc(wgunHitTimeUsed
);
225 function FindShot(): DWORD
;
230 for i
:= 0 to High(Shots
) do
231 if Shots
[i
].ShotType
= 0 then
234 LastShotID
:= Result
;
240 SetLength(Shots
, 128);
245 Result
:= High(Shots
) + 1;
246 SetLength(Shots
, Length(Shots
) + 128);
248 LastShotID
:= Result
;
251 procedure CreateWaterMap();
253 WaterArray
: Array of TWaterPanel
;
260 SetLength(WaterArray
, Length(gWater
));
262 for a
:= 0 to High(gWater
) do
264 WaterArray
[a
].X
:= gWater
[a
].X
;
265 WaterArray
[a
].Y
:= gWater
[a
].Y
;
266 WaterArray
[a
].Width
:= gWater
[a
].Width
;
267 WaterArray
[a
].Height
:= gWater
[a
].Height
;
268 WaterArray
[a
].Active
:= True;
271 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
273 for a
:= 0 to High(WaterArray
) do
274 if WaterArray
[a
].Active
then
276 WaterArray
[a
].Active
:= False;
277 m
:= Length(WaterMap
);
278 SetLength(WaterMap
, m
+1);
279 SetLength(WaterMap
[m
], 1);
286 for b
:= 0 to High(WaterArray
) do
287 if WaterArray
[b
].Active
then
288 for c
:= 0 to High(WaterMap
[m
]) do
289 if g_CollideAround(WaterArray
[b
].X
,
292 WaterArray
[b
].Height
,
293 WaterArray
[WaterMap
[m
][c
]].X
,
294 WaterArray
[WaterMap
[m
][c
]].Y
,
295 WaterArray
[WaterMap
[m
][c
]].Width
,
296 WaterArray
[WaterMap
[m
][c
]].Height
) then
298 WaterArray
[b
].Active
:= False;
299 SetLength(WaterMap
[m
],
300 Length(WaterMap
[m
])+1);
301 WaterMap
[m
][High(WaterMap
[m
])] := b
;
307 g_Game_StepLoading();
315 chkTrap_pl
: array [0..256] of Integer;
316 chkTrap_mn
: array [0..65535] of TMonster
;
318 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
320 //a, b, c, d, i1, i2: Integer;
321 //chkTrap_pl, chkTrap_mn: WArray;
322 plaCount
: Integer = 0;
323 mnaCount
: Integer = 0;
327 function monsWaterCheck (mon: TMonster): Boolean;
329 result := false; // don't stop
330 if mon.alive and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
333 chkTrap_mn[i2] := monidx;
338 function monsWaterCheck (mon
: TMonster
): Boolean;
340 result
:= false; // don't stop
341 if (mon
.trapCheckFrameId
<> frameId
) then
343 mon
.trapCheckFrameId
:= frameId
;
344 chkTrap_mn
[mnaCount
] := mon
;
350 a
, b
, c
, d
, f
: Integer;
353 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
355 frameId
:= g_Mons_getNewTrapFrameId();
360 //SetLength(chkTrap_pl, 1024);
361 //SetLength(chkTrap_mn, 1024);
362 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
363 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
365 for a
:= 0 to High(WaterMap
) do
367 for b
:= 0 to High(WaterMap
[a
]) do
369 pan
:= gWater
[WaterMap
[a
][b
]];
370 if not g_Obj_Collide(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, @Shots
[ID
].Obj
) then continue
;
372 for c
:= 0 to High(WaterMap
[a
]) do
374 pan
:= gWater
[WaterMap
[a
][c
]];
375 for d
:= 0 to High(gPlayers
) do
377 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].alive
) then
379 if gPlayers
[d
].Collide(pan
) then
382 while (f
< plaCount
) and (chkTrap_pl
[f
] <> d
) do Inc(f
);
383 if (f
= plaCount
) then
385 chkTrap_pl
[plaCount
] := d
;
387 if (plaCount
= Length(chkTrap_pl
)) then break
;
393 //g_Mons_ForEach(monsWaterCheck);
394 g_Mons_ForEachAliveAt(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, monsWaterCheck
);
397 for f
:= 0 to plaCount
-1 do gPlayers
[chkTrap_pl
[f
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
398 for f
:= 0 to mnaCount
-1 do chkTrap_mn
[f
].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
406 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
413 tt
:= g_GetUIDType(SpawnerUID
);
414 if tt
= UID_MONSTER
then
416 mon
:= g_Monsters_ByUID(SpawnerUID
);
418 mt
:= g_Monsters_ByUID(SpawnerUID
).MonsterType
425 if m
= nil then Exit
;
426 if m
.UID
= SpawnerUID
then
428 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
429 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
431 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
432 if (m
.MonsterType
= MONSTER_CYBER
) or
433 (m
.MonsterType
= MONSTER_BARREL
) then
440 if tt
= UID_MONSTER
then
442 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
443 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
446 // Îáà ìîíñòðà îäíîãî âèäà:
447 if mt
= m
.MonsterType
then
449 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
450 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
451 Exit
; // Ýòè íå áüþò ñâîèõ
455 if g_Game_IsServer
then
457 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
458 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
461 if t
= HIT_FLAME
then
462 m
.CatchFire(SpawnerUID
);
469 function HitPlayer (p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
473 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì
474 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then exit
;
476 if g_Game_IsServer
then
478 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
479 if (t
= HIT_FLAME
) then p
.CatchFire(SpawnerUID
);
486 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
488 function monsCheck (mon
: TMonster
): Boolean;
490 result
:= false; // don't stop
491 if (mon
.alive
) and (mon
.UID
<> SpawnerUID
) then
495 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
496 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
497 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
498 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
500 if HitMonster(mon
, 50, 0, 0, SpawnerUID
, HIT_SOME
) then mon
.BFGHit();
512 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
516 if gAdvCorpses
and (h
<> -1) then
518 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
520 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
521 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
522 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
523 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
526 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
527 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
531 pl
:= g_Player_Get(SpawnerUID
);
539 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].alive
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
541 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
542 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
543 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
544 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
546 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
547 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
549 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
551 gPlayers
[i
].BFGHit();
555 g_Mons_ForEachAlive(monsCheck
);
558 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
564 find_id
:= FindShot()
568 if Integer(find_id
) >= High(Shots
) then
569 SetLength(Shots
, find_id
+ 64)
573 WEAPON_ROCKETLAUNCHER
:
575 with Shots
[find_id
] do
579 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
580 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
584 ShotType
:= WEAPON_ROCKETLAUNCHER
;
585 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
591 with Shots
[find_id
] do
595 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
596 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
599 ShotType
:= WEAPON_PLASMA
;
600 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
601 Animation
:= TAnimation
.Create(FramesID
, True, 5);
607 with Shots
[find_id
] do
611 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
612 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
615 ShotType
:= WEAPON_BFG
;
616 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
617 Animation
:= TAnimation
.Create(FramesID
, True, 6);
623 with Shots
[find_id
] do
627 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
628 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
631 ShotType
:= WEAPON_FLAMETHROWER
;
634 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
640 with Shots
[find_id
] do
644 Obj
.Rect
.Width
:= 16;
645 Obj
.Rect
.Height
:= 16;
648 ShotType
:= WEAPON_IMP_FIRE
;
649 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
650 Animation
:= TAnimation
.Create(FramesID
, True, 4);
656 with Shots
[find_id
] do
660 Obj
.Rect
.Width
:= 16;
661 Obj
.Rect
.Height
:= 16;
664 ShotType
:= WEAPON_CACO_FIRE
;
665 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
666 Animation
:= TAnimation
.Create(FramesID
, True, 4);
672 with Shots
[find_id
] do
676 Obj
.Rect
.Width
:= 32;
677 Obj
.Rect
.Height
:= 32;
680 ShotType
:= WEAPON_MANCUB_FIRE
;
681 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
682 Animation
:= TAnimation
.Create(FramesID
, True, 4);
688 with Shots
[find_id
] do
692 Obj
.Rect
.Width
:= 32;
693 Obj
.Rect
.Height
:= 16;
696 ShotType
:= WEAPON_BARON_FIRE
;
697 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
698 Animation
:= TAnimation
.Create(FramesID
, True, 4);
704 with Shots
[find_id
] do
708 Obj
.Rect
.Width
:= 16;
709 Obj
.Rect
.Height
:= 16;
712 ShotType
:= WEAPON_BSP_FIRE
;
713 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
714 Animation
:= TAnimation
.Create(FramesID
, True, 4);
720 with Shots
[find_id
] do
724 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
725 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
728 ShotType
:= WEAPON_SKEL_FIRE
;
730 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
731 Animation
:= TAnimation
.Create(FramesID
, True, 5);
736 Shots
[find_id
].Obj
.X
:= X
;
737 Shots
[find_id
].Obj
.Y
:= Y
;
738 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
739 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
740 Shots
[find_id
].Obj
.Accel
.X
:= 0;
741 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
742 Shots
[find_id
].SpawnerUID
:= Spawner
;
743 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
744 Shots
[find_id
].Stopped
:= 255
746 Shots
[find_id
].Stopped
:= 0;
750 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
757 a
:= Max(Abs(xd
), Abs(yd
));
763 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
764 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
765 Shots
[i
].Obj
.Accel
.X
:= 0;
766 Shots
[i
].Obj
.Accel
.Y
:= 0;
767 Shots
[i
].Stopped
:= 0;
768 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
769 Shots
[i
].Timeout
:= 900 // ~25 sec
772 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
773 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
775 Shots
[i
].Timeout
:= 550; // ~15 sec
779 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
783 function PlayerHit(Team
: Byte = 0): Boolean;
794 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
797 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
799 p
:= g_Player_Get(SpawnerUID
);
801 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
804 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
806 if t
<> HIT_FLAME
then
807 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
808 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
810 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
818 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
820 result := false; // don't stop
821 if mon.alive and g_Obj_Collide(obj, @mon.Obj) then
823 if HitMonster(mon, d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
825 if (t <> HIT_FLAME) then
827 mon.Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
828 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
836 function monsCheckHit (mon
: TMonster
): Boolean;
838 result
:= false; // don't stop
839 if HitMonster(mon
, d
, obj
.Vel
.X
, obj
.Vel
.Y
, SpawnerUID
, t
) then
841 if (t
<> HIT_FLAME
) then
843 mon
.Push((obj
.Vel
.X
+obj
.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
844 (obj
.Vel
.Y
+obj
.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
850 function MonsterHit(): Boolean;
852 //result := g_Mons_ForEach(monsCheckHit);
853 //FIXME: accelerate this!
854 result
:= g_Mons_ForEachAliveAt(obj
.X
+obj
.Rect
.X
, obj
.Y
+obj
.Rect
.Y
, obj
.Rect
.Width
, obj
.Rect
.Height
, monsCheckHit
);
864 if gAdvCorpses
and (h
<> -1) then
866 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
867 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
870 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
871 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
876 case gGameSettings
.GameMode
of
880 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
897 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
914 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
928 // È â êîíöå ñâîèõ èãðîêîâ
939 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
943 case g_GetUIDType(UID
) of
944 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
945 UID_MONSTER
: Result
:= HitMonster(g_Monsters_ByUID(UID
), d
, 0, 0, SpawnerUID
, t
);
950 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
952 r
: Integer; // squared radius
954 function monsExCheck (mon
: TMonster
): Boolean;
958 result
:= false; // don't stop
960 dx
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-X
;
961 dy
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-Y
;
963 if dx
> 1000 then dx
:= 1000;
964 if dy
> 1000 then dy
:= 1000;
966 if (dx
*dx
+dy
*dy
< r
) then
968 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
969 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
971 mm
:= Max(abs(dx
), abs(dy
));
972 if mm
= 0 then mm
:= 1;
976 HitMonster(mon
, ((mon
.Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
, 0, 0, SpawnerUID
, HIT_ROCKET
);
979 mon
.Push((dx
*7) div mm
, (dy
*7) div mm
);
985 i
, h
, dx
, dy
, m
, mm
: Integer;
990 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
998 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1001 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1002 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1004 if dx
> 1000 then dx
:= 1000;
1005 if dy
> 1000 then dy
:= 1000;
1007 if dx
*dx
+dy
*dy
< r
then
1009 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1010 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1012 mm
:= Max(abs(dx
), abs(dy
));
1013 if mm
= 0 then mm
:= 1;
1015 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
1016 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
1020 //g_Mons_ForEach(monsExCheck);
1021 g_Mons_ForEachAt(X
-(rad
+32), Y
-(rad
+32), (rad
+32)*2, (rad
+32)*2, monsExCheck
);
1023 h
:= High(gCorpses
);
1025 if gAdvCorpses
and (h
<> -1) then
1027 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
1030 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1031 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1033 if dx
> 1000 then dx
:= 1000;
1034 if dy
> 1000 then dy
:= 1000;
1036 if dx
*dx
+dy
*dy
< r
then
1038 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1039 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1041 mm
:= Max(abs(dx
), abs(dy
));
1042 if mm
= 0 then mm
:= 1;
1044 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
1050 if gAdvGibs
and (h
<> -1) then
1052 if gGibs
[i
].alive
then
1055 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1056 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1058 if dx
> 1000 then dx
:= 1000;
1059 if dy
> 1000 then dy
:= 1000;
1061 if dx
*dx
+dy
*dy
< r
then
1063 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1064 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1065 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
1066 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
1068 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
1069 positionChanged(); // this updates spatial accelerators
1074 procedure g_Weapon_Init();
1079 procedure g_Weapon_Free();
1083 if Shots
<> nil then
1085 for i
:= 0 to High(Shots
) do
1086 if Shots
[i
].ShotType
<> 0 then
1087 Shots
[i
].Animation
.Free();
1095 procedure g_Weapon_LoadData();
1097 e_WriteLog('Loading weapons data...', TMsgType
.Notify
);
1099 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
1100 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
1101 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1102 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1103 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1104 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1105 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1106 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1107 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1108 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1109 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1110 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1111 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1112 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1113 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1114 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1115 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1116 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1117 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1118 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1119 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1120 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1121 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1122 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1123 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1124 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1125 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1126 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1127 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1128 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1129 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1130 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1132 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1133 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1134 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1135 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1136 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1137 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1138 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1139 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1140 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1141 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1142 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1143 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1144 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1145 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1146 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1147 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1148 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1149 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1150 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1151 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1152 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1154 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1155 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1157 //wgunMonHash := hashNewIntInt();
1158 wgunHitHeap
:= TBinaryHeapHitTimes
.Create(hitTimeLess
);
1161 procedure g_Weapon_FreeData();
1163 e_WriteLog('Releasing weapons data...', TMsgType
.Notify
);
1165 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1166 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1167 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1168 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1169 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1170 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1171 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1172 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1173 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1174 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1175 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1176 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1177 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1178 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1179 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1180 g_Sound_Delete('SOUND_FIRE');
1181 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1182 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1183 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1184 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1185 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1186 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1187 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1188 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1189 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1190 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1191 g_Sound_Delete('SOUND_PLAYER_JETON');
1192 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1193 g_Sound_Delete('SOUND_PLAYER_CASING1');
1194 g_Sound_Delete('SOUND_PLAYER_CASING2');
1195 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1196 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1198 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1199 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1200 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1201 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1202 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1203 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1204 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1205 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1206 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1207 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1208 g_Frames_DeleteByName('FRAMES_BFGHIT');
1209 g_Frames_DeleteByName('FRAMES_FIRE');
1210 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1211 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1212 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1213 g_Frames_DeleteByName('FRAMES_SMOKE');
1214 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1215 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1219 function GunHitPlayer (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Boolean;
1224 for i
:= 0 to High(gPlayers
) do
1226 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and gPlayers
[i
].Collide(X
, Y
) then
1228 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1230 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
1238 function GunHit (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Byte;
1240 function monsCheck (mon
: TMonster
): Boolean;
1242 result
:= false; // don't stop
1243 if HitMonster(mon
, dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1245 if AllowPush
then mon
.Push(vx
, vy
);
1252 if GunHitPlayer(X
, Y
, vx
, vy
, dmg
, SpawnerUID
, AllowPush
) then result
:= 1
1253 else if g_Mons_ForEachAliveAt(X
, Y
, 1, 1, monsCheck
) then result
:= 2;
1258 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1269 t1, _collide: Boolean;
1271 {$IF DEFINED(D2F_DEBUG)}
1273 showTime: Boolean = true;
1276 a := GetAngle(x, y, xd, yd)+180;
1278 SinCos(DegToRad(-a), s, c);
1280 if Abs(s) < 0.01 then s := 0;
1281 if Abs(c) < 0.01 then c := 0;
1283 x2 := x+Round(c*gMapInfo.Width);
1284 y2 := y+Round(s*gMapInfo.Width);
1286 t1 := gWalls <> nil;
1288 w := gMapInfo.Width;
1289 h := gMapInfo.Height;
1296 if (xd = 0) and (yd = 0) then Exit;
1298 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1299 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1304 if dx > dy then d := dx else d := dy;
1306 //blood vel, for Monster.Damage()
1307 //vx := (dx*10 div d)*xi;
1308 //vy := (dy*10 div d)*yi;
1310 {$IF DEFINED(D2F_DEBUG)}
1311 stt := getTimeMicro();
1334 if (yy > h) or (yy < 0) then Break;
1335 if (xx > w) or (xx < 0) then Break;
1338 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1341 {$IF DEFINED(D2F_DEBUG)}
1342 stt := getTimeMicro()-stt;
1343 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1346 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1347 if g_Game_IsServer and g_Game_IsNet then
1348 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1351 if not _collide then
1353 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1356 if _collide then Break;
1359 {$IF DEFINED(D2F_DEBUG)}
1362 stt := getTimeMicro()-stt;
1363 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1367 if CheckTrigger and g_Game_IsServer then
1368 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1374 procedure g_Weapon_gun (const x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1379 wallDistSq
: Integer = $3fffffff;
1381 function doPlayerHit (idx
: Integer; hx
, hy
: Integer): Boolean;
1384 if (idx
< 0) or (idx
> High(gPlayers
)) then exit
;
1385 if (gPlayers
[idx
] = nil) or not gPlayers
[idx
].alive
then exit
;
1386 result
:= HitPlayer(gPlayers
[idx
], dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1387 if result
and (v
<> 0) then gPlayers
[idx
].Push((xi
*v
), (yi
*v
));
1388 {$IF DEFINED(D2F_DEBUG)}
1389 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1393 function doMonsterHit (mon
: TMonster
; hx
, hy
: Integer): Boolean;
1396 if (mon
= nil) then exit
;
1397 result
:= HitMonster(mon
, dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1398 if result
and (v
<> 0) then mon
.Push((xi
*v
), (yi
*v
));
1399 {$IF DEFINED(D2F_DEBUG)}
1400 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1404 // collect players along hitray
1405 // return `true` if instant hit was detected
1406 function playerPossibleHit (): Boolean;
1409 px
, py
, pw
, ph
: Integer;
1415 for i
:= 0 to High(gPlayers
) do
1418 if (plr
<> nil) and plr
.alive
then
1420 plr
.getMapBox(px
, py
, pw
, ph
);
1421 if lineAABBIntersects(x
, y
, x2
, y2
, px
, py
, pw
, ph
, inx
, iny
) then
1423 distSq
:= distanceSq(x
, y
, inx
, iny
);
1424 if (distSq
= 0) then
1427 if doPlayerHit(i
, x
, y
) then begin result
:= true; exit
; end;
1429 else if (distSq
< wallDistSq
) then
1431 appendHitTimePlr(distSq
, i
, inx
, iny
);
1438 function sqchecker (mon
: TMonster
; tag
: Integer): Boolean;
1440 mx
, my
, mw
, mh
: Integer;
1444 result
:= false; // don't stop
1445 mon
.getMapBox(mx
, my
, mw
, mh
);
1446 if lineAABBIntersects(x0
, y0
, x2
, y2
, mx
, my
, mw
, mh
, inx
, iny
) then
1448 distSq
:= distanceSq(x0
, y0
, inx
, iny
);
1449 if (distSq
< wallDistSq
) then appendHitTimeMon(distSq
, mon
, inx
, iny
);
1459 wallHitFlag
: Boolean = false;
1460 wallHitX
: Integer = 0;
1461 wallHitY
: Integer = 0;
1462 didHit
: Boolean = false;
1463 {$IF DEFINED(D2F_DEBUG)}
1468 if not gwep_debug_fast_trace then
1470 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1475 if (xd
= 0) and (yd
= 0) then exit
;
1477 //wgunMonHash.reset(); //FIXME: clear hash on level change
1478 wgunHitHeap
.clear();
1479 wgunHitTimeUsed
:= 0;
1481 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1483 SinCos(DegToRad(-a
), s
, c
);
1485 if Abs(s
) < 0.01 then s
:= 0;
1486 if Abs(c
) < 0.01 then c
:= 0;
1490 x2
:= x
+Round(c
*gMapInfo
.Width
);
1491 y2
:= y
+Round(s
*gMapInfo
.Width
);
1496 if (dx
> 0) then xi
:= 1 else if (dx
< 0) then xi
:= -1 else xi
:= 0;
1497 if (dy
> 0) then yi
:= 1 else if (dy
< 0) then yi
:= -1 else yi
:= 0;
1499 {$IF DEFINED(D2F_DEBUG)}
1500 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x
, y
, x2
, y2
]), TMsgType
.Notify
);
1501 stt
:= getTimeMicro();
1504 wallHitFlag
:= (g_Map_traceToNearestWall(x
, y
, x2
, y2
, @wallHitX
, @wallHitY
) <> nil);
1509 wallDistSq
:= distanceSq(x
, y
, wallHitX
, wallHitY
);
1517 if playerPossibleHit() then exit
; // instant hit
1520 g_Mons_AlongLine(x
, y
, x2
, y2
, sqchecker
);
1522 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1523 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1524 while (wgunHitHeap
.count
> 0) do
1526 // has some entities to check, do it
1527 i
:= wgunHitHeap
.front
;
1528 wgunHitHeap
.popFront();
1530 xe
:= wgunHitTime
[i
].x
;
1531 ye
:= wgunHitTime
[i
].y
;
1532 // check if it is not behind the wall
1533 if (wgunHitTime
[i
].mon
<> nil) then
1535 didHit
:= doMonsterHit(wgunHitTime
[i
].mon
, xe
, ye
);
1539 didHit
:= doPlayerHit(wgunHitTime
[i
].plridx
, xe
, ye
);
1543 // need new coords for trigger
1546 wallHitFlag
:= false; // no sparks
1554 {$IF DEFINED(D2F_DEBUG)}
1555 stt
:= getTimeMicro()-stt
;
1556 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1558 g_GFX_Spark(wallHitX
, wallHitY
, 2+Random(2), 180+a
, 0, 0);
1559 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(wallHitX
, wallHitY
, 180+a
, NET_GFX_SPARK
);
1563 {$IF DEFINED(D2F_DEBUG)}
1564 stt
:= getTimeMicro()-stt
;
1565 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1569 if CheckTrigger
and g_Game_IsServer
then g_Triggers_PressL(X
, Y
, wallHitX
, wallHitY
, SpawnerUID
, ACTIVATE_SHOT
);
1573 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1581 obj
.rect
.Width
:= 39;
1582 obj
.rect
.Height
:= 52;
1588 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1589 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1591 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1594 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1602 obj
.rect
.Width
:= 32;
1603 obj
.rect
.Height
:= 52;
1609 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1612 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1613 Silent
: Boolean = False);
1619 find_id
:= FindShot()
1623 if Integer(find_id
) >= High(Shots
) then
1624 SetLength(Shots
, find_id
+ 64)
1627 with Shots
[find_id
] do
1631 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1632 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1634 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1635 dy
:= -(Obj
.Rect
.Height
div 2);
1637 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1638 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1642 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1645 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1648 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1651 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1652 WID
: Integer = -1; Silent
: Boolean = False);
1654 find_id
, FramesID
: DWORD
;
1658 find_id
:= FindShot()
1662 if Integer(find_id
) >= High(Shots
) then
1663 SetLength(Shots
, find_id
+ 64)
1666 with Shots
[find_id
] do
1670 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1671 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1673 dx
:= -(Obj
.Rect
.Width
div 2);
1674 dy
:= -(Obj
.Rect
.Height
div 2);
1676 ShotType
:= WEAPON_SKEL_FIRE
;
1677 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1680 target
:= TargetUID
;
1681 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1682 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1685 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1688 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1691 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1692 Silent
: Boolean = False);
1694 find_id
, FramesID
: DWORD
;
1698 find_id
:= FindShot()
1702 if Integer(find_id
) >= High(Shots
) then
1703 SetLength(Shots
, find_id
+ 64);
1706 with Shots
[find_id
] do
1710 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1711 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1713 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1714 dy
:= -(Obj
.Rect
.Height
div 2);
1716 ShotType
:= WEAPON_PLASMA
;
1717 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1720 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1721 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1724 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1727 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1730 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1731 Silent
: Boolean = False);
1737 find_id
:= FindShot()
1741 if Integer(find_id
) >= High(Shots
) then
1742 SetLength(Shots
, find_id
+ 64);
1745 with Shots
[find_id
] do
1749 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1750 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1752 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1753 dy
:= -(Obj
.Rect
.Height
div 2);
1755 ShotType
:= WEAPON_FLAMETHROWER
;
1756 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1761 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
1764 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1766 // if not Silent then
1767 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1770 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1771 Silent
: Boolean = False);
1773 find_id
, FramesID
: DWORD
;
1777 find_id
:= FindShot()
1781 if Integer(find_id
) >= High(Shots
) then
1782 SetLength(Shots
, find_id
+ 64)
1785 with Shots
[find_id
] do
1789 Obj
.Rect
.Width
:= 16;
1790 Obj
.Rect
.Height
:= 16;
1792 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1793 dy
:= -(Obj
.Rect
.Height
div 2);
1795 ShotType
:= WEAPON_IMP_FIRE
;
1796 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1799 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1800 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1803 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1806 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1809 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1810 Silent
: Boolean = False);
1812 find_id
, FramesID
: DWORD
;
1816 find_id
:= FindShot()
1820 if Integer(find_id
) >= High(Shots
) then
1821 SetLength(Shots
, find_id
+ 64)
1824 with Shots
[find_id
] do
1828 Obj
.Rect
.Width
:= 16;
1829 Obj
.Rect
.Height
:= 16;
1831 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1832 dy
:= -(Obj
.Rect
.Height
div 2);
1834 ShotType
:= WEAPON_CACO_FIRE
;
1835 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1838 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1839 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1842 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1845 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1848 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1849 Silent
: Boolean = False);
1851 find_id
, FramesID
: DWORD
;
1855 find_id
:= FindShot()
1859 if Integer(find_id
) >= High(Shots
) then
1860 SetLength(Shots
, find_id
+ 64)
1863 with Shots
[find_id
] do
1867 Obj
.Rect
.Width
:= 32;
1868 Obj
.Rect
.Height
:= 16;
1870 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1871 dy
:= -(Obj
.Rect
.Height
div 2);
1873 ShotType
:= WEAPON_BARON_FIRE
;
1874 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1877 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1878 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1881 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1884 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1887 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1888 Silent
: Boolean = False);
1890 find_id
, FramesID
: DWORD
;
1894 find_id
:= FindShot()
1898 if Integer(find_id
) >= High(Shots
) then
1899 SetLength(Shots
, find_id
+ 64)
1902 with Shots
[find_id
] do
1906 Obj
.Rect
.Width
:= 16;
1907 Obj
.Rect
.Height
:= 16;
1909 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1910 dy
:= -(Obj
.Rect
.Height
div 2);
1912 ShotType
:= WEAPON_BSP_FIRE
;
1913 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1917 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1918 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1921 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1924 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1927 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1928 Silent
: Boolean = False);
1930 find_id
, FramesID
: DWORD
;
1934 find_id
:= FindShot()
1938 if Integer(find_id
) >= High(Shots
) then
1939 SetLength(Shots
, find_id
+ 64)
1942 with Shots
[find_id
] do
1946 Obj
.Rect
.Width
:= 32;
1947 Obj
.Rect
.Height
:= 32;
1949 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1950 dy
:= -(Obj
.Rect
.Height
div 2);
1952 ShotType
:= WEAPON_MANCUB_FIRE
;
1953 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1957 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1958 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1961 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1964 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1967 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1968 Silent
: Boolean = False);
1970 find_id
, FramesID
: DWORD
;
1974 find_id
:= FindShot()
1978 if Integer(find_id
) >= High(Shots
) then
1979 SetLength(Shots
, find_id
+ 64)
1982 with Shots
[find_id
] do
1986 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1987 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1989 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1990 dy
:= -(Obj
.Rect
.Height
div 2);
1992 ShotType
:= WEAPON_BFG
;
1993 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1996 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1997 Animation
:= TAnimation
.Create(FramesID
, True, 6);
2000 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
2003 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
2006 procedure g_Weapon_bfghit(x
, y
: Integer);
2011 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
2013 Anim
:= TAnimation
.Create(ID
, False, 4);
2014 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
2019 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2020 Silent
: Boolean = False);
2023 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
2025 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2026 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
2028 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
2029 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2033 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2034 Silent
: Boolean = False);
2037 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
2039 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2040 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
2041 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2043 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
2044 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2048 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2049 Silent
: Boolean = False);
2054 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
2058 j
:= Random(17)-8; // -8 .. 8
2059 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
2063 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2064 Silent
: Boolean = False);
2069 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
2071 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
2074 j
:= Random(41)-20; // -20 .. 20
2075 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
2079 procedure g_Weapon_Update();
2081 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
2095 for i
:= 0 to High(Shots
) do
2097 if Shots
[i
].ShotType
= 0 then
2104 Timeout
:= Timeout
- 1;
2107 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2108 if (Stopped
= 0) and g_Game_IsServer
then
2109 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
2110 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
2116 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2117 if triggers
= nil then
2124 if not InDWArray(t
[a
], triggers
) then
2126 SetLength(triggers
, Length(triggers
)+1);
2127 triggers
[High(triggers
)] := t
[a
];
2132 // Àíèìàöèÿ ñíàðÿäà:
2133 if Animation
<> nil then
2137 spl
:= (ShotType
<> WEAPON_PLASMA
) and
2138 (ShotType
<> WEAPON_BFG
) and
2139 (ShotType
<> WEAPON_BSP_FIRE
) and
2140 (ShotType
<> WEAPON_FLAMETHROWER
);
2144 st
:= g_Obj_Move(@Obj
, False, spl
);
2150 positionChanged(); // this updates spatial accelerators
2152 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
2153 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
2155 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2161 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2162 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2165 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2167 // Âûëåòåëà èç âîäû:
2168 if WordBool(st
and MOVE_HITAIR
) then
2169 g_Obj_SetSpeed(@Obj
, 12);
2171 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2172 if WordBool(st
and MOVE_INWATER
) then
2173 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
2174 Obj
.Y
+(Obj
.Rect
.Height
div 2),
2175 1+Random(3), 16, 16)
2177 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
2179 Anim
:= TAnimation
.Create(_id
, False, 3);
2181 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
2182 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
2183 Anim
, ONCEANIM_SMOKE
);
2187 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2188 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2189 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
2195 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
2197 if ShotType
= WEAPON_SKEL_FIRE
then
2198 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2199 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2201 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2202 Anim
.Blending
:= False;
2203 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
2204 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
2209 begin // Âçðûâ Ðàêåòû
2210 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2212 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2213 Anim
.Blending
:= False;
2214 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2215 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
2220 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2225 if ShotType
= WEAPON_SKEL_FIRE
then
2226 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2227 if GetPos(target
, @o
) then
2228 throw(i
, Obj
.X
, Obj
.Y
,
2229 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
2230 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
2235 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2237 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2238 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2240 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
2241 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
2247 if (ShotType
= WEAPON_PLASMA
) and
2248 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
2253 if ShotType
= WEAPON_BSP_FIRE
then
2256 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2257 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2258 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
2261 if ShotType
= WEAPON_PLASMA
then
2262 s
:= 'FRAMES_EXPLODE_PLASMA'
2264 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2267 if g_Frames_Get(TextureID
, s
) then
2269 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2270 Anim
.Blending
:= False;
2271 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2273 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
2276 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2282 WEAPON_FLAMETHROWER
: // Îãíåìåò
2284 // Ñî âðåìåíåì óìèðàåò
2285 if (Timeout
< 1) then
2291 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
2293 if WordBool(st
and MOVE_HITWATER
) then
2295 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
2297 Anim
:= TAnimation
.Create(_id
, False, 3);
2301 g_GFX_OnceAnim(cx
-4+tcx
-(Anim
.Width
div 2),
2302 cy
-4+tcy
-(Anim
.Height
div 2),
2303 Anim
, ONCEANIM_SMOKE
);
2308 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2315 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
2316 // Ïîïàëè â ñòåíó èëè â âîäó:
2317 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
2323 if WordBool(st
and MOVE_HITWALL
) then
2324 Stopped
:= MOVE_HITWALL
2325 else if WordBool(st
and MOVE_HITLAND
) then
2326 Stopped
:= MOVE_HITLAND
2327 else if WordBool(st
and MOVE_HITCEIL
) then
2328 Stopped
:= MOVE_HITCEIL
;
2331 a
:= IfThen(Stopped
= 0, 3, 1);
2332 // Åñëè â êîãî-òî ïîïàëè
2333 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
2335 // HIT_FLAME ñàì ïîäîææåò
2336 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2346 if (gTime
mod LongWord(tf
) = 0) then
2348 Anim
:= TAnimation
.Create(TextureID
, False, 2 + Random(2));
2351 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
2352 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
2353 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
2354 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
2356 g_GFX_OnceAnim(tcx
-(Anim
.Width
div 2), tcy
-(Anim
.Height
div 2), Anim
, ONCEANIM_SMOKE
);
2358 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2364 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2365 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2367 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2368 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2373 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2374 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2375 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2379 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2382 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
2384 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2385 Anim
.Blending
:= False;
2386 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2388 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2391 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2397 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2400 if WordBool(st
and MOVE_HITAIR
) then
2401 g_Obj_SetSpeed(@Obj
, 16);
2404 if ShotType
= WEAPON_IMP_FIRE
then
2407 if ShotType
= WEAPON_CACO_FIRE
then
2412 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2413 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2414 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2417 if ShotType
= WEAPON_IMP_FIRE
then
2418 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2420 if ShotType
= WEAPON_CACO_FIRE
then
2421 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2423 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2426 if g_Frames_Get(TextureID
, s
) then
2428 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2429 Anim
.Blending
:= False;
2430 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2434 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2440 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2443 if WordBool(st
and MOVE_HITAIR
) then
2444 g_Obj_SetSpeed(@Obj
, 16);
2446 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2447 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2448 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2452 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2454 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2455 Anim
.Blending
:= False;
2456 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2460 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2465 end; // case ShotType of...
2467 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2468 if (ShotType
= 0) then
2470 if gGameSettings
.GameType
= GT_SERVER
then
2471 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2472 if Animation
<> nil then
2478 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2479 if gGameSettings
.GameType
= GT_SERVER
then
2480 MH_SEND_UpdateShot(i
);
2485 procedure g_Weapon_Draw();
2494 for i
:= 0 to High(Shots
) do
2495 if Shots
[i
].ShotType
<> 0 then
2498 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2499 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2500 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2501 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2502 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
2506 p
.X
:= Obj
.Rect
.Width
div 2;
2507 p
.Y
:= Obj
.Rect
.Height
div 2;
2509 if Animation
<> nil then
2511 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2512 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2513 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2514 Animation
.DrawEx(Obj
.X
, Obj
.Y
, TMirrorType
.None
, p
, a
)
2516 Animation
.Draw(Obj
.X
, Obj
.Y
, TMirrorType
.None
);
2518 else if TextureID
<> 0 then
2520 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
2521 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, TMirrorType
.None
)
2522 else if (Shots
[i
].ShotType
<> WEAPON_FLAMETHROWER
) then
2523 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
2526 if g_debug_Frames
then
2528 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
2530 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
2531 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
2537 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2546 for a
:= 0 to High(Shots
) do
2547 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2548 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2549 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2550 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2551 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2552 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2553 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2560 procedure g_Weapon_SaveState (st
: TStream
);
2562 count
, i
, j
: Integer;
2564 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2566 for i
:= 0 to High(Shots
) do if (Shots
[i
].ShotType
<> 0) then Inc(count
);
2568 // Êîëè÷åñòâî ñíàðÿäîâ
2569 utils
.WriteInt(st
, count
);
2571 if (count
= 0) then exit
;
2573 for i
:= 0 to High(Shots
) do
2575 if Shots
[i
].ShotType
<> 0 then
2577 // Ñèãíàòóðà ñíàðÿäà
2578 utils
.writeSign(st
, 'SHOT');
2579 utils
.writeInt(st
, Byte(0)); // version
2581 utils
.writeInt(st
, Byte(Shots
[i
].ShotType
));
2583 utils
.writeInt(st
, Word(Shots
[i
].Target
));
2585 utils
.writeInt(st
, Word(Shots
[i
].SpawnerUID
));
2586 // Ðàçìåð ïîëÿ Triggers
2587 utils
.writeInt(st
, Integer(Length(Shots
[i
].Triggers
)));
2588 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2589 for j
:= 0 to Length(Shots
[i
].Triggers
)-1 do utils
.writeInt(st
, LongWord(Shots
[i
].Triggers
[j
]));
2591 Obj_SaveState(st
, @Shots
[i
].Obj
);
2593 utils
.writeInt(st
, Byte(Shots
[i
].Stopped
));
2598 procedure g_Weapon_LoadState (st
: TStream
);
2600 count
, tc
, i
, j
: Integer;
2603 if (st
= nil) then exit
;
2605 // Êîëè÷åñòâî ñíàðÿäîâ
2606 count
:= utils
.readLongInt(st
);
2607 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid shots counter');
2609 SetLength(Shots
, count
);
2611 if (count
= 0) then exit
;
2613 for i
:= 0 to count
-1 do
2615 // Ñèãíàòóðà ñíàðÿäà
2616 if not utils
.checkSign(st
, 'SHOT') then raise XStreamError
.Create('invalid shot signature');
2617 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid shot version');
2619 Shots
[i
].ShotType
:= utils
.readByte(st
);
2621 Shots
[i
].Target
:= utils
.readWord(st
);
2623 Shots
[i
].SpawnerUID
:= utils
.readWord(st
);
2624 // Ðàçìåð ïîëÿ Triggers
2625 tc
:= utils
.readLongInt(st
);
2626 if (tc
< 0) or (tc
> 1024*1024) then raise XStreamError
.Create('invalid shot triggers counter');
2627 SetLength(Shots
[i
].Triggers
, tc
);
2628 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2629 for j
:= 0 to tc
-1 do Shots
[i
].Triggers
[j
] := utils
.readLongWord(st
);
2631 Obj_LoadState(@Shots
[i
].Obj
, st
);
2633 Shots
[i
].Stopped
:= utils
.readByte(st
);
2635 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2636 Shots
[i
].TextureID
:= DWORD(-1);
2637 Shots
[i
].Animation
:= nil;
2639 case Shots
[i
].ShotType
of
2640 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2642 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2646 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2647 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2651 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2652 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2656 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2657 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2661 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2662 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2666 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2667 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2671 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2672 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2676 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2677 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2683 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2691 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2695 if ShotType
= 0 then Exit
;
2698 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2699 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2702 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2706 if ShotType
= WEAPON_SKEL_FIRE
then
2707 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2708 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2710 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2711 Anim
.Blending
:= False;
2712 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2717 begin // Âçðûâ Ðàêåòû
2718 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2720 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2721 Anim
.Blending
:= False;
2722 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2726 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2730 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2732 if ShotType
= WEAPON_PLASMA
then
2733 s
:= 'FRAMES_EXPLODE_PLASMA'
2735 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2737 if g_Frames_Get(TextureID
, s
) and loud
then
2739 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2740 Anim
.Blending
:= False;
2741 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2744 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2751 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2753 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2754 Anim
.Blending
:= False;
2755 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2758 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2762 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2764 if ShotType
= WEAPON_IMP_FIRE
then
2765 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2767 if ShotType
= WEAPON_CACO_FIRE
then
2768 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2770 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2772 if g_Frames_Get(TextureID
, s
) and Loud
then
2774 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2775 Anim
.Blending
:= False;
2776 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2779 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2783 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2785 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2787 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2788 Anim
.Blending
:= False;
2789 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2792 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2795 end; // case ShotType of...
2803 procedure g_Weapon_AddDynLights();
2807 if Shots
= nil then Exit
;
2808 for i
:= 0 to High(Shots
) do
2810 if Shots
[i
].ShotType
= 0 then continue
;
2811 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2812 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2813 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2814 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2815 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2816 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2817 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2818 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2819 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2820 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2821 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2824 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2825 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)
2826 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2827 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)
2828 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2829 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)
2831 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);
2837 procedure TShot
.positionChanged (); begin end;