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_animations
, g_basic
, g_phys
, xprofiler
;
33 Animation
: TAnimState
;
37 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
42 Shots
: array of TShot
= nil;
43 LastShotID
: Integer = 0;
45 procedure g_Weapon_LoadData();
46 procedure g_Weapon_FreeData();
47 procedure g_Weapon_Init();
48 procedure g_Weapon_Free();
49 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
50 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
51 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
53 procedure g_Weapon_gun(const x
, y
, xd
, yd
, v
, indmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
54 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
55 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
56 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
57 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
58 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
59 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
60 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
61 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
62 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
63 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
64 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
65 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False; compat
: Boolean = true);
66 procedure g_Weapon_bfghit(x
, y
: Integer);
67 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
68 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
69 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
70 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
72 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
73 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
74 procedure g_Weapon_PreUpdate();
75 procedure g_Weapon_Update();
76 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
77 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
79 procedure g_Weapon_SaveState (st
: TStream
);
80 procedure g_Weapon_LoadState (st
: TStream
);
82 procedure g_Weapon_AddDynLights();
91 WEAPON_ROCKETLAUNCHER
= 6;
94 WEAPON_SUPERPULEMET
= 9;
95 WEAPON_FLAMETHROWER
= 10;
96 WEAPON_ZOMBY_PISTOL
= 20;
99 WEAPON_CACO_FIRE
= 23;
100 WEAPON_BARON_FIRE
= 24;
101 WEAPON_MANCUB_FIRE
= 25;
102 WEAPON_SKEL_FIRE
= 26;
103 WEAPON_LAST
= WEAPON_SKEL_FIRE
;
105 WP_FIRST
= WEAPON_KASTET
;
106 WP_LAST
= WEAPON_FLAMETHROWER
;
109 gwep_debug_fast_trace
: Boolean = true;
121 {$IFDEF ENABLE_CORPSES}
124 Math
, g_map
, g_player
, g_sound
, g_panel
,
125 g_console
, g_options
, g_game
,
126 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
127 g_language
, g_netmsg
, g_grid
,
128 geom
, binheap
, hashtable
, utils
, xstreams
139 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
140 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
142 SHOT_SKELFIRE_WIDTH
= 14;
143 SHOT_SKELFIRE_HEIGHT
= 14;
145 SHOT_PLASMA_WIDTH
= 16;
146 SHOT_PLASMA_HEIGHT
= 16;
149 SHOT_BFG_HEIGHT
= 32;
150 SHOT_BFG_DAMAGE
= 100;
151 SHOT_BFG_RADIUS
= 256;
153 SHOT_FLAME_WIDTH
= 4;
154 SHOT_FLAME_HEIGHT
= 4;
155 SHOT_FLAME_LIFETIME
= 180;
157 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
160 PHitTime
= ^THitTime
;
164 plridx
: Integer; // if mon=nil
168 TBinHeapKeyHitTime
= class
170 class function less (const a
, b
: Integer): Boolean; inline;
173 // indicies in `wgunHitTime` array
174 TBinaryHeapHitTimes
= specialize TBinaryHeapBase
<Integer, TBinHeapKeyHitTime
>;
177 WaterMap
: array of array of DWORD
= nil;
178 //wgunMonHash: THashIntInt = nil;
179 wgunHitHeap
: TBinaryHeapHitTimes
= nil;
180 wgunHitTime
: array of THitTime
= nil;
181 wgunHitTimeUsed
: Integer = 0;
184 class function TBinHeapKeyHitTime
.less (const a
, b
: Integer): Boolean;
188 hta
:= @wgunHitTime
[a
];
189 htb
:= @wgunHitTime
[b
];
190 if (hta
.distSq
<> htb
.distSq
) then begin result
:= (hta
.distSq
< htb
.distSq
); exit
; end;
191 if (hta
.mon
<> nil) then
194 if (htb
.mon
= nil) then begin result
:= false; exit
; end; // players first
195 result
:= (hta
.mon
.UID
< htb
.mon
.UID
); // why not?
200 if (htb
.mon
<> nil) then begin result
:= true; exit
; end; // players first
201 result
:= (hta
.plridx
< htb
.plridx
); // why not?
206 procedure appendHitTimeMon (adistSq
: Integer; amon
: TMonster
; ax
, ay
: Integer);
208 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
209 with wgunHitTime
[wgunHitTimeUsed
] do
217 wgunHitHeap
.insert(wgunHitTimeUsed
);
218 Inc(wgunHitTimeUsed
);
222 procedure appendHitTimePlr (adistSq
: Integer; aplridx
: Integer; ax
, ay
: Integer);
224 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
225 with wgunHitTime
[wgunHitTimeUsed
] do
233 wgunHitHeap
.insert(wgunHitTimeUsed
);
234 Inc(wgunHitTimeUsed
);
238 function FindShot(): DWORD
;
243 for i
:= 0 to High(Shots
) do
244 if Shots
[i
].ShotType
= 0 then
247 LastShotID
:= Result
;
253 SetLength(Shots
, 128);
258 Result
:= High(Shots
) + 1;
259 SetLength(Shots
, Length(Shots
) + 128);
261 LastShotID
:= Result
;
264 procedure CreateWaterMap();
266 WaterArray
: Array of TWaterPanel
;
273 SetLength(WaterArray
, Length(gWater
));
275 for a
:= 0 to High(gWater
) do
277 WaterArray
[a
].X
:= gWater
[a
].X
;
278 WaterArray
[a
].Y
:= gWater
[a
].Y
;
279 WaterArray
[a
].Width
:= gWater
[a
].Width
;
280 WaterArray
[a
].Height
:= gWater
[a
].Height
;
281 WaterArray
[a
].Active
:= True;
284 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
286 for a
:= 0 to High(WaterArray
) do
287 if WaterArray
[a
].Active
then
289 WaterArray
[a
].Active
:= False;
290 m
:= Length(WaterMap
);
291 SetLength(WaterMap
, m
+1);
292 SetLength(WaterMap
[m
], 1);
299 for b
:= 0 to High(WaterArray
) do
300 if WaterArray
[b
].Active
then
301 for c
:= 0 to High(WaterMap
[m
]) do
302 if g_CollideAround(WaterArray
[b
].X
,
305 WaterArray
[b
].Height
,
306 WaterArray
[WaterMap
[m
][c
]].X
,
307 WaterArray
[WaterMap
[m
][c
]].Y
,
308 WaterArray
[WaterMap
[m
][c
]].Width
,
309 WaterArray
[WaterMap
[m
][c
]].Height
) then
311 WaterArray
[b
].Active
:= False;
312 SetLength(WaterMap
[m
],
313 Length(WaterMap
[m
])+1);
314 WaterMap
[m
][High(WaterMap
[m
])] := b
;
320 g_Game_StepLoading();
328 chkTrap_pl
: array [0..256] of Integer;
329 chkTrap_mn
: array [0..65535] of TMonster
;
331 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
333 //a, b, c, d, i1, i2: Integer;
334 //chkTrap_pl, chkTrap_mn: WArray;
335 plaCount
: Integer = 0;
336 mnaCount
: Integer = 0;
340 function monsWaterCheck (mon: TMonster): Boolean;
342 result := false; // don't stop
343 if mon.alive and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
346 chkTrap_mn[i2] := monidx;
351 function monsWaterCheck (mon
: TMonster
): Boolean;
353 result
:= false; // don't stop
354 if (mon
.trapCheckFrameId
<> frameId
) then
356 mon
.trapCheckFrameId
:= frameId
;
357 chkTrap_mn
[mnaCount
] := mon
;
363 a
, b
, c
, d
, f
: Integer;
366 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
368 frameId
:= g_Mons_getNewTrapFrameId();
373 //SetLength(chkTrap_pl, 1024);
374 //SetLength(chkTrap_mn, 1024);
375 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
376 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
378 for a
:= 0 to High(WaterMap
) do
380 for b
:= 0 to High(WaterMap
[a
]) do
382 pan
:= gWater
[WaterMap
[a
][b
]];
383 if not g_Obj_Collide(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, @Shots
[ID
].Obj
) then continue
;
385 for c
:= 0 to High(WaterMap
[a
]) do
387 pan
:= gWater
[WaterMap
[a
][c
]];
388 for d
:= 0 to High(gPlayers
) do
390 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].alive
) then
392 if gPlayers
[d
].Collide(pan
) then
395 while (f
< plaCount
) and (chkTrap_pl
[f
] <> d
) do Inc(f
);
396 if (f
= plaCount
) then
398 chkTrap_pl
[plaCount
] := d
;
400 if (plaCount
= Length(chkTrap_pl
)) then break
;
406 //g_Mons_ForEach(monsWaterCheck);
407 g_Mons_ForEachAliveAt(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, monsWaterCheck
);
410 for f
:= 0 to plaCount
-1 do gPlayers
[chkTrap_pl
[f
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
411 for f
:= 0 to mnaCount
-1 do chkTrap_mn
[f
].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
419 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
426 tt
:= g_GetUIDType(SpawnerUID
);
427 if tt
= UID_MONSTER
then
429 mon
:= g_Monsters_ByUID(SpawnerUID
);
431 mt
:= g_Monsters_ByUID(SpawnerUID
).MonsterType
438 if m
= nil then Exit
;
439 if m
.UID
= SpawnerUID
then
441 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
442 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
444 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
445 if (m
.MonsterType
= MONSTER_CYBER
) or
446 (m
.MonsterType
= MONSTER_BARREL
) then
453 if tt
= UID_MONSTER
then
455 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
456 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
459 // Îáà ìîíñòðà îäíîãî âèäà:
460 if mt
= m
.MonsterType
then
462 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
463 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
464 Exit
; // Ýòè íå áüþò ñâîèõ
468 if g_Game_IsServer
then
470 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
471 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
473 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
474 if t
= HIT_FLAME
then
475 m
.CatchFire(SpawnerUID
);
478 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
482 function HitPlayer (p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
486 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì
487 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then exit
;
489 if g_Game_IsServer
then
491 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
492 if (t
= HIT_FLAME
) then p
.CatchFire(SpawnerUID
);
499 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
501 function monsCheck (mon
: TMonster
): Boolean;
503 result
:= false; // don't stop
504 if (mon
.alive
) and (mon
.UID
<> SpawnerUID
) then
508 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
509 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
510 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
511 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
513 if HitMonster(mon
, 50, 0, 0, SpawnerUID
, HIT_SOME
) then mon
.BFGHit();
525 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
527 {$IFDEF ENABLE_CORPSES}
529 if gAdvCorpses
and (h
<> -1) then
533 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
537 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
538 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
539 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
540 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
542 Damage(50, SpawnerUID
, 0, 0);
543 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2), Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
552 pl
:= g_Player_Get(SpawnerUID
);
560 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].alive
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
562 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
563 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
564 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
565 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
567 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
568 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
570 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
572 gPlayers
[i
].BFGHit();
576 g_Mons_ForEachAlive(monsCheck
);
579 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
584 find_id
:= FindShot()
588 if Integer(find_id
) >= High(Shots
) then
589 SetLength(Shots
, find_id
+ 64)
593 WEAPON_ROCKETLAUNCHER
:
595 with Shots
[find_id
] do
599 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
600 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
603 ShotType
:= WEAPON_ROCKETLAUNCHER
;
604 Animation
.Invalidate
;
610 with Shots
[find_id
] do
614 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
615 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
618 ShotType
:= WEAPON_PLASMA
;
619 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
625 with Shots
[find_id
] do
629 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
630 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
633 ShotType
:= WEAPON_BFG
;
634 Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
640 with Shots
[find_id
] do
644 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
645 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
648 ShotType
:= WEAPON_FLAMETHROWER
;
649 Animation
.Invalidate
;
650 // Animation := TAnimState.Create(True, 6, 0); // drawed as gfx
656 with Shots
[find_id
] do
660 Obj
.Rect
.Width
:= 16;
661 Obj
.Rect
.Height
:= 16;
664 ShotType
:= WEAPON_IMP_FIRE
;
665 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
671 with Shots
[find_id
] do
675 Obj
.Rect
.Width
:= 16;
676 Obj
.Rect
.Height
:= 16;
679 ShotType
:= WEAPON_CACO_FIRE
;
680 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
686 with Shots
[find_id
] do
690 Obj
.Rect
.Width
:= 32;
691 Obj
.Rect
.Height
:= 32;
694 ShotType
:= WEAPON_MANCUB_FIRE
;
695 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
701 with Shots
[find_id
] do
705 Obj
.Rect
.Width
:= 16;
706 Obj
.Rect
.Height
:= 16;
709 ShotType
:= WEAPON_BARON_FIRE
;
710 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
716 with Shots
[find_id
] do
720 Obj
.Rect
.Width
:= 16;
721 Obj
.Rect
.Height
:= 16;
724 ShotType
:= WEAPON_BSP_FIRE
;
725 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
731 with Shots
[find_id
] do
735 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
736 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
739 ShotType
:= WEAPON_SKEL_FIRE
;
741 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
746 Shots
[find_id
].Obj
.oldX
:= X
;
747 Shots
[find_id
].Obj
.oldY
:= Y
;
748 Shots
[find_id
].Obj
.X
:= X
;
749 Shots
[find_id
].Obj
.Y
:= Y
;
750 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
751 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
752 Shots
[find_id
].Obj
.Accel
.X
:= 0;
753 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
754 Shots
[find_id
].SpawnerUID
:= Spawner
;
755 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
756 Shots
[find_id
].Stopped
:= 255
758 Shots
[find_id
].Stopped
:= 0;
762 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
769 a
:= Max(Abs(xd
), Abs(yd
));
773 Shots
[i
].Obj
.oldX
:= x
;
774 Shots
[i
].Obj
.oldY
:= y
;
777 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
778 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
779 Shots
[i
].Obj
.Accel
.X
:= 0;
780 Shots
[i
].Obj
.Accel
.Y
:= 0;
781 Shots
[i
].Stopped
:= 0;
782 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
783 Shots
[i
].Timeout
:= 900 // ~25 sec
786 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
787 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
789 Shots
[i
].Timeout
:= 550; // ~15 sec
793 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
794 {$IFDEF ENABLE_CORPSES}
799 function PlayerHit(Team
: Byte = 0): Boolean;
810 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
813 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
815 p
:= g_Player_Get(SpawnerUID
);
817 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
820 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
822 if t
<> HIT_FLAME
then
823 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
824 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
826 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
834 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
836 result := false; // don't stop
837 if mon.alive and g_Obj_Collide(obj, @mon.Obj) then
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);
852 function monsCheckHit (mon
: TMonster
): Boolean;
854 result
:= false; // don't stop
855 if HitMonster(mon
, d
, obj
.Vel
.X
, obj
.Vel
.Y
, SpawnerUID
, t
) then
857 if (t
<> HIT_FLAME
) then
859 mon
.Push((obj
.Vel
.X
+obj
.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
860 (obj
.Vel
.Y
+obj
.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
866 function MonsterHit(): Boolean;
868 //result := g_Mons_ForEach(monsCheckHit);
869 //FIXME: accelerate this!
870 result
:= g_Mons_ForEachAliveAt(obj
.X
+obj
.Rect
.X
, obj
.Y
+obj
.Rect
.Y
, obj
.Rect
.Width
, obj
.Rect
.Height
, monsCheckHit
);
876 {$IFDEF ENABLE_CORPSES}
880 if gAdvCorpses
and (h
<> -1) then
884 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
885 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
888 gCorpses
[i
].Damage(d
, SpawnerUID
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
889 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
897 case gGameSettings
.GameMode
of
901 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
908 // È â êîíöå èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
909 // (èëè ñíàðÿä îò ìîíñòðà, èëè friendlyfire, èëè friendly_hit_projectile)
910 if (g_GetUIDType(SpawnerUID
) <> UID_PLAYER
) or
911 LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
924 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
941 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
955 // È â êîíöå ñâîèõ èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
956 // (èëè friendlyfire, èëè friendly_hit_projectile)
957 if LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
970 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
974 case g_GetUIDType(UID
) of
975 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
976 UID_MONSTER
: Result
:= HitMonster(g_Monsters_ByUID(UID
), d
, 0, 0, SpawnerUID
, t
);
981 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
983 r
: Integer; // squared radius
985 function monsExCheck (mon
: TMonster
): Boolean;
989 result
:= false; // don't stop
991 dx
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-X
;
992 dy
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-Y
;
994 if dx
> 1000 then dx
:= 1000;
995 if dy
> 1000 then dy
:= 1000;
997 if (dx
*dx
+dy
*dy
< r
) then
999 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
1000 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
1002 mm
:= Max(abs(dx
), abs(dy
));
1003 if mm
= 0 then mm
:= 1;
1007 HitMonster(mon
, ((mon
.Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
, 0, 0, SpawnerUID
, HIT_ROCKET
);
1010 mon
.Push((dx
*7) div mm
, (dy
*7) div mm
);
1015 var i
, h
, dx
, dy
, mm
: Integer;
1016 {$IFDEF ENABLE_GIBS}
1017 var _angle
: SmallInt;
1019 {$IF DEFINED(ENABLE_GIBS) OR DEFINED(ENABLE_CORPSES)}
1025 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
1029 h
:= High(gPlayers
);
1033 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1036 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1037 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1039 if dx
> 1000 then dx
:= 1000;
1040 if dy
> 1000 then dy
:= 1000;
1042 if dx
*dx
+dy
*dy
< r
then
1044 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1045 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1047 mm
:= Max(abs(dx
), abs(dy
));
1048 if mm
= 0 then mm
:= 1;
1050 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
1051 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
1055 //g_Mons_ForEach(monsExCheck);
1056 g_Mons_ForEachAt(X
-(rad
+32), Y
-(rad
+32), (rad
+32)*2, (rad
+32)*2, monsExCheck
);
1058 {$IFDEF ENABLE_CORPSES}
1059 h
:= High(gCorpses
);
1060 if gAdvCorpses
and (h
<> -1) then
1064 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
1068 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1069 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1070 if dx
> 1000 then dx
:= 1000;
1071 if dy
> 1000 then dy
:= 1000;
1072 if dx
*dx
+dy
*dy
< r
then
1074 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1075 mm
:= Max(abs(dx
), abs(dy
));
1078 Damage(Round(100*(rad
-m
)/rad
), SpawnerUID
, (dx
*10) div mm
, (dy
*10) div mm
);
1086 {$IFDEF ENABLE_GIBS}
1088 if gAdvGibs
and (h
<> -1) then
1090 if gGibs
[i
].alive
then
1093 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1094 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1095 if dx
> 1000 then dx
:= 1000;
1096 if dy
> 1000 then dy
:= 1000;
1097 if dx
*dx
+dy
*dy
< r
then
1099 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1100 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1101 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
1102 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
1103 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
1104 positionChanged(); // this updates spatial accelerators
1110 procedure g_Weapon_Init();
1115 procedure g_Weapon_Free();
1121 procedure g_Weapon_LoadData();
1123 e_WriteLog('Loading weapons data...', TMsgType
.Notify
);
1125 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
1126 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
1127 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1128 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1129 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1130 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1131 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1132 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1133 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1134 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1135 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1136 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1137 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1138 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1139 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1140 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1141 g_Sound_CreateWADEx('SOUND_IGNITE', GameWAD
+':SOUNDS\IGNITE');
1142 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1143 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1144 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1145 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1146 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1147 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1148 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1149 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1150 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1151 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD
+':SOUNDS\STARTFLM');
1152 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD
+':SOUNDS\STOPFLM');
1153 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD
+':SOUNDS\WORKFLM');
1154 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1155 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1156 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1157 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1158 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1159 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1160 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1162 //wgunMonHash := hashNewIntInt();
1163 wgunHitHeap
:= TBinaryHeapHitTimes
.Create();
1166 procedure g_Weapon_FreeData();
1168 e_WriteLog('Releasing weapons data...', TMsgType
.Notify
);
1170 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1171 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1172 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1173 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1174 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1175 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1176 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1177 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1178 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1179 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1180 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1181 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1182 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1183 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1184 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1185 g_Sound_Delete('SOUND_FIRE');
1186 g_Sound_Delete('SOUND_IGNITE');
1187 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1188 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1189 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1190 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1191 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1192 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1193 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1194 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1195 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1196 g_Sound_Delete('SOUND_WEAPON_FLAMEON');
1197 g_Sound_Delete('SOUND_WEAPON_FLAMEOFF');
1198 g_Sound_Delete('SOUND_WEAPON_FLAMEWORK');
1199 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1200 g_Sound_Delete('SOUND_PLAYER_JETON');
1201 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1202 g_Sound_Delete('SOUND_PLAYER_CASING1');
1203 g_Sound_Delete('SOUND_PLAYER_CASING2');
1204 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1205 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1209 function GunHitPlayer (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Boolean;
1214 for i
:= 0 to High(gPlayers
) do
1216 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and gPlayers
[i
].Collide(X
, Y
) then
1218 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1220 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
1228 function GunHit (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Byte;
1230 function monsCheck (mon
: TMonster
): Boolean;
1232 result
:= false; // don't stop
1233 if HitMonster(mon
, dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1235 if AllowPush
then mon
.Push(vx
, vy
);
1242 if GunHitPlayer(X
, Y
, vx
, vy
, dmg
, SpawnerUID
, AllowPush
) then result
:= 1
1243 else if g_Mons_ForEachAliveAt(X
, Y
, 1, 1, monsCheck
) then result
:= 2;
1248 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1259 t1, _collide: Boolean;
1261 {$IF DEFINED(D2F_DEBUG)}
1263 showTime: Boolean = true;
1266 a := GetAngle(x, y, xd, yd)+180;
1268 SinCos(DegToRad(-a), s, c);
1270 if Abs(s) < 0.01 then s := 0;
1271 if Abs(c) < 0.01 then c := 0;
1273 x2 := x+Round(c*gMapInfo.Width);
1274 y2 := y+Round(s*gMapInfo.Width);
1276 t1 := gWalls <> nil;
1278 w := gMapInfo.Width;
1279 h := gMapInfo.Height;
1286 if (xd = 0) and (yd = 0) then Exit;
1288 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1289 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1294 if dx > dy then d := dx else d := dy;
1296 //blood vel, for Monster.Damage()
1297 //vx := (dx*10 div d)*xi;
1298 //vy := (dy*10 div d)*yi;
1300 {$IF DEFINED(D2F_DEBUG)}
1301 stt := getTimeMicro();
1324 if (yy > h) or (yy < 0) then Break;
1325 if (xx > w) or (xx < 0) then Break;
1328 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1331 {$IF DEFINED(D2F_DEBUG)}
1332 stt := getTimeMicro()-stt;
1333 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1336 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1337 if g_Game_IsServer and g_Game_IsNet then
1338 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1341 if not _collide then
1343 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1346 if _collide then Break;
1349 {$IF DEFINED(D2F_DEBUG)}
1352 stt := getTimeMicro()-stt;
1353 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1357 if CheckTrigger and g_Game_IsServer then
1358 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1364 procedure g_Weapon_gun (const x
, y
, xd
, yd
, v
, indmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1369 wallDistSq
: Integer = $3fffffff;
1370 spawnerPlr
: TPlayer
= nil;
1373 function doPlayerHit (idx
: Integer; hx
, hy
: Integer): Boolean;
1376 if (idx
< 0) or (idx
> High(gPlayers
)) then exit
;
1377 if (gPlayers
[idx
] = nil) or not gPlayers
[idx
].alive
then exit
;
1378 if (spawnerPlr
<> nil) then
1380 if ((gGameSettings
.Options
and (GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMDAMAGE
)) = 0) and
1381 (spawnerPlr
.Team
<> TEAM_NONE
) and (spawnerPlr
.Team
= gPlayers
[idx
].Team
) then
1383 if (spawnerPlr
<> gPlayers
[idx
]) and ((gGameSettings
.Options
and GAME_OPTION_TEAMABSORBDAMAGE
) = 0) then
1384 dmg
:= Max(1, dmg
div 2);
1388 result
:= HitPlayer(gPlayers
[idx
], dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1389 if result
and (v
<> 0) then gPlayers
[idx
].Push((xi
*v
), (yi
*v
));
1390 {$IF DEFINED(D2F_DEBUG)}
1391 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1395 function doMonsterHit (mon
: TMonster
; hx
, hy
: Integer): Boolean;
1398 if (mon
= nil) then exit
;
1399 result
:= HitMonster(mon
, dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1400 if result
and (v
<> 0) then mon
.Push((xi
*v
), (yi
*v
));
1401 {$IF DEFINED(D2F_DEBUG)}
1402 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1406 // collect players along hitray
1407 // return `true` if instant hit was detected
1408 function playerPossibleHit (): Boolean;
1411 px
, py
, pw
, ph
: Integer;
1417 for i
:= 0 to High(gPlayers
) do
1420 if (plr
<> nil) and plr
.alive
then
1422 plr
.getMapBox(px
, py
, pw
, ph
);
1423 if lineAABBIntersects(x
, y
, x2
, y2
, px
, py
, pw
, ph
, inx
, iny
) then
1425 distSq
:= distanceSq(x
, y
, inx
, iny
);
1426 if (distSq
= 0) then
1429 if doPlayerHit(i
, x
, y
) then begin result
:= true; exit
; end;
1431 else if (distSq
< wallDistSq
) then
1433 appendHitTimePlr(distSq
, i
, inx
, iny
);
1440 procedure sqchecker (mon
: TMonster
);
1442 mx
, my
, mw
, mh
: Integer;
1446 mon
.getMapBox(mx
, my
, mw
, mh
);
1447 if lineAABBIntersects(x0
, y0
, x2
, y2
, mx
, my
, mw
, mh
, inx
, iny
) then
1449 distSq
:= distanceSq(x0
, y0
, inx
, iny
);
1450 if (distSq
< wallDistSq
) then appendHitTimeMon(distSq
, mon
, inx
, iny
);
1460 wallHitFlag
: Boolean = false;
1461 wallHitX
: Integer = 0;
1462 wallHitY
: Integer = 0;
1463 didHit
: Boolean = false;
1464 {$IF DEFINED(D2F_DEBUG)}
1468 it
: TMonsterGrid
.Iter
;
1471 if not gwep_debug_fast_trace then
1473 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1478 if (xd
= 0) and (yd
= 0) then exit
;
1480 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1481 spawnerPlr
:= g_Player_Get(SpawnerUID
);
1485 //wgunMonHash.reset(); //FIXME: clear hash on level change
1486 wgunHitHeap
.clear();
1487 wgunHitTimeUsed
:= 0;
1489 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1491 SinCos(DegToRad(-a
), s
, c
);
1493 if Abs(s
) < 0.01 then s
:= 0;
1494 if Abs(c
) < 0.01 then c
:= 0;
1498 x2
:= x
+Round(c
*gMapInfo
.Width
);
1499 y2
:= y
+Round(s
*gMapInfo
.Width
);
1504 if (dx
> 0) then xi
:= 1 else if (dx
< 0) then xi
:= -1 else xi
:= 0;
1505 if (dy
> 0) then yi
:= 1 else if (dy
< 0) then yi
:= -1 else yi
:= 0;
1507 {$IF DEFINED(D2F_DEBUG)}
1508 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x
, y
, x2
, y2
]), TMsgType
.Notify
);
1509 stt
:= getTimeMicro();
1512 wallHitFlag
:= (g_Map_traceToNearestWall(x
, y
, x2
, y2
, @wallHitX
, @wallHitY
) <> nil);
1517 wallDistSq
:= distanceSq(x
, y
, wallHitX
, wallHitY
);
1525 if playerPossibleHit() then exit
; // instant hit
1528 //g_Mons_AlongLine(x, y, x2, y2, sqchecker);
1530 it
:= monsGrid
.forEachAlongLine(x
, y
, x2
, y2
, -1);
1531 for mit
in it
do sqchecker(mit
^);
1534 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1535 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1536 while (wgunHitHeap
.count
> 0) do
1538 // has some entities to check, do it
1539 i
:= wgunHitHeap
.front
;
1540 wgunHitHeap
.popFront();
1542 xe
:= wgunHitTime
[i
].x
;
1543 ye
:= wgunHitTime
[i
].y
;
1544 // check if it is not behind the wall
1545 if (wgunHitTime
[i
].mon
<> nil) then
1547 didHit
:= doMonsterHit(wgunHitTime
[i
].mon
, xe
, ye
);
1551 didHit
:= doPlayerHit(wgunHitTime
[i
].plridx
, xe
, ye
);
1555 // need new coords for trigger
1558 wallHitFlag
:= false; // no sparks
1566 {$IF DEFINED(D2F_DEBUG)}
1567 stt
:= getTimeMicro()-stt
;
1568 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1571 g_GFX_Spark(wallHitX
, wallHitY
, 2+Random(2), 180+a
, 0, 0);
1573 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(wallHitX
, wallHitY
, 180+a
, NET_GFX_SPARK
);
1577 {$IF DEFINED(D2F_DEBUG)}
1578 stt
:= getTimeMicro()-stt
;
1579 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1583 if CheckTrigger
and g_Game_IsServer
then g_Triggers_PressL(X
, Y
, wallHitX
, wallHitY
, SpawnerUID
, ACTIVATE_SHOT
);
1587 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1595 obj
.rect
.Width
:= 39;
1596 obj
.rect
.Height
:= 52;
1602 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1603 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1605 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1608 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1616 obj
.rect
.Width
:= 32;
1617 obj
.rect
.Height
:= 52;
1623 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1626 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1627 Silent
: Boolean = False; compat
: Boolean = true);
1633 find_id
:= FindShot()
1637 if Integer(find_id
) >= High(Shots
) then
1638 SetLength(Shots
, find_id
+ 64)
1641 with Shots
[find_id
] do
1645 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1646 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1649 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1651 dx
:= -(Obj
.Rect
.Width
div 2);
1652 dy
:= -(Obj
.Rect
.Height
div 2);
1654 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1655 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1657 Animation
.Invalidate
;
1661 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1664 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1667 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1668 WID
: Integer = -1; Silent
: Boolean = False);
1674 find_id
:= FindShot()
1678 if Integer(find_id
) >= High(Shots
) then
1679 SetLength(Shots
, find_id
+ 64)
1682 with Shots
[find_id
] do
1686 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1687 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1689 dx
:= -(Obj
.Rect
.Width
div 2);
1690 dy
:= -(Obj
.Rect
.Height
div 2);
1692 ShotType
:= WEAPON_SKEL_FIRE
;
1693 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1696 target
:= TargetUID
;
1697 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
1700 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1703 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1706 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1707 Silent
: Boolean = False; compat
: Boolean = true);
1713 find_id
:= FindShot()
1717 if Integer(find_id
) >= High(Shots
) then
1718 SetLength(Shots
, find_id
+ 64);
1721 with Shots
[find_id
] do
1725 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1726 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1729 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1731 dx
:= -(Obj
.Rect
.Width
div 2);
1732 dy
:= -(Obj
.Rect
.Height
div 2);
1734 ShotType
:= WEAPON_PLASMA
;
1735 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1738 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
1741 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1744 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1747 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1748 Silent
: Boolean = False; compat
: Boolean = true);
1754 find_id
:= FindShot()
1758 if Integer(find_id
) >= High(Shots
) then
1759 SetLength(Shots
, find_id
+ 64);
1762 with Shots
[find_id
] do
1766 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1767 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1770 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1772 dx
:= -(Obj
.Rect
.Width
div 2);
1773 dy
:= -(Obj
.Rect
.Height
div 2);
1775 ShotType
:= WEAPON_FLAMETHROWER
;
1776 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1779 Animation
.Invalidate
;
1782 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1784 // if not Silent then
1785 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1788 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1789 Silent
: Boolean = False; compat
: Boolean = true);
1795 find_id
:= FindShot()
1799 if Integer(find_id
) >= High(Shots
) then
1800 SetLength(Shots
, find_id
+ 64)
1803 with Shots
[find_id
] do
1807 Obj
.Rect
.Width
:= 16;
1808 Obj
.Rect
.Height
:= 16;
1811 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1813 dx
:= -(Obj
.Rect
.Width
div 2);
1814 dy
:= -(Obj
.Rect
.Height
div 2);
1816 ShotType
:= WEAPON_IMP_FIRE
;
1817 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1820 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1823 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1826 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1829 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1830 Silent
: Boolean = False; compat
: Boolean = true);
1836 find_id
:= FindShot()
1840 if Integer(find_id
) >= High(Shots
) then
1841 SetLength(Shots
, find_id
+ 64)
1844 with Shots
[find_id
] do
1848 Obj
.Rect
.Width
:= 16;
1849 Obj
.Rect
.Height
:= 16;
1852 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1854 dx
:= -(Obj
.Rect
.Width
div 2);
1855 dy
:= -(Obj
.Rect
.Height
div 2);
1857 ShotType
:= WEAPON_CACO_FIRE
;
1858 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1861 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1864 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1867 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1870 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1871 Silent
: Boolean = False; compat
: Boolean = true);
1877 find_id
:= FindShot()
1881 if Integer(find_id
) >= High(Shots
) then
1882 SetLength(Shots
, find_id
+ 64)
1885 with Shots
[find_id
] do
1889 Obj
.Rect
.Width
:= 32;
1890 Obj
.Rect
.Height
:= 16;
1893 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1895 dx
:= -(Obj
.Rect
.Width
div 2);
1896 dy
:= -(Obj
.Rect
.Height
div 2);
1898 ShotType
:= WEAPON_BARON_FIRE
;
1899 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1902 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1905 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1908 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1911 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1912 Silent
: Boolean = False; compat
: Boolean = true);
1918 find_id
:= FindShot()
1922 if Integer(find_id
) >= High(Shots
) then
1923 SetLength(Shots
, find_id
+ 64)
1926 with Shots
[find_id
] do
1930 Obj
.Rect
.Width
:= 16;
1931 Obj
.Rect
.Height
:= 16;
1934 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1936 dx
:= -(Obj
.Rect
.Width
div 2);
1937 dy
:= -(Obj
.Rect
.Height
div 2);
1939 ShotType
:= WEAPON_BSP_FIRE
;
1940 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1944 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1947 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1950 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1953 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1954 Silent
: Boolean = False; compat
: Boolean = true);
1960 find_id
:= FindShot()
1964 if Integer(find_id
) >= High(Shots
) then
1965 SetLength(Shots
, find_id
+ 64)
1968 with Shots
[find_id
] do
1972 Obj
.Rect
.Width
:= 32;
1973 Obj
.Rect
.Height
:= 32;
1976 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1978 dx
:= -(Obj
.Rect
.Width
div 2);
1979 dy
:= -(Obj
.Rect
.Height
div 2);
1981 ShotType
:= WEAPON_MANCUB_FIRE
;
1982 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1986 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1989 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1992 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1995 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1996 Silent
: Boolean = False; compat
: Boolean = true);
2002 find_id
:= FindShot()
2006 if Integer(find_id
) >= High(Shots
) then
2007 SetLength(Shots
, find_id
+ 64)
2010 with Shots
[find_id
] do
2014 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
2015 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
2018 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
2020 dx
:= -(Obj
.Rect
.Width
div 2);
2021 dy
:= -(Obj
.Rect
.Height
div 2);
2023 ShotType
:= WEAPON_BFG
;
2024 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
2027 Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
2030 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
2033 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
2036 procedure g_Weapon_bfghit(x
, y
: Integer);
2039 g_GFX_QueueEffect(R_GFX_BFG_HIT
, x
- 32, y
- 32);
2043 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2044 Silent
: Boolean = False);
2047 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
2049 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2050 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
2052 if ABS(x
-xd
) >= ABS(y
-yd
) then
2054 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
2055 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2059 g_Weapon_gun(x
+1, y
, xd
+1, yd
, 1, 3, SpawnerUID
, False);
2060 g_Weapon_gun(x
-1, y
, xd
-1, yd
, 1, 2, SpawnerUID
, False);
2065 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2066 Silent
: Boolean = False);
2069 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
2071 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2072 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
2073 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2075 if ABS(x
-xd
) >= ABS(y
-yd
) then
2077 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
2078 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2082 g_Weapon_gun(x
+1, y
, xd
+1, yd
, 1, 2, SpawnerUID
, False);
2083 g_Weapon_gun(x
-1, y
, xd
-1, yd
, 1, 2, SpawnerUID
, False);
2088 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2089 Silent
: Boolean = False);
2094 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
2099 if ABS(x
-xd
) >= ABS(y
-yd
) then j
:= Random(17) - 8 else k
:= Random(17) - 8; // -8 .. 8
2100 g_Weapon_gun(x
+k
, y
+j
, xd
+k
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
2104 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2105 Silent
: Boolean = False);
2107 a
, i
, j
, k
: Integer;
2110 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
2112 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
2116 if ABS(x
-xd
) >= ABS(y
-yd
) then j
:= Random(41) - 20 else k
:= Random(41) - 20; // -20 .. 20
2117 g_Weapon_gun(x
+k
, y
+j
, xd
+k
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
2121 procedure g_Weapon_PreUpdate();
2125 if Shots
= nil then Exit
;
2126 for i
:= 0 to High(Shots
) do
2127 if Shots
[i
].ShotType
<> 0 then
2129 Shots
[i
].Obj
.oldX
:= Shots
[i
].Obj
.X
;
2130 Shots
[i
].Obj
.oldY
:= Shots
[i
].Obj
.Y
;
2134 procedure g_Weapon_Update();
2136 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
2143 var tcx
, tcy
: Integer;
2149 for i
:= 0 to High(Shots
) do
2151 if Shots
[i
].ShotType
= 0 then
2158 Timeout
:= Timeout
- 1;
2161 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2162 if (Stopped
= 0) and g_Game_IsServer
then
2163 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
2164 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
2170 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2171 if triggers
= nil then
2178 if not InDWArray(t
[a
], triggers
) then
2180 SetLength(triggers
, Length(triggers
)+1);
2181 triggers
[High(triggers
)] := t
[a
];
2186 // Àíèìàöèÿ ñíàðÿäà:
2187 if Animation
.IsValid() then
2191 spl
:= (ShotType
<> WEAPON_PLASMA
) and
2192 (ShotType
<> WEAPON_BFG
) and
2193 (ShotType
<> WEAPON_BSP_FIRE
) and
2194 (ShotType
<> WEAPON_FLAMETHROWER
);
2198 st
:= g_Obj_Move_Projectile(@Obj
, False, spl
);
2204 positionChanged(); // this updates spatial accelerators
2206 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
2207 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
2209 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2211 Animation
.Invalidate();
2215 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2216 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2219 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2221 // Âûëåòåëà èç âîäû:
2222 if WordBool(st
and MOVE_HITAIR
) then
2223 g_Obj_SetSpeed(@Obj
, 12);
2225 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2226 if WordBool(st
and MOVE_INWATER
) then
2229 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2232 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx
, cy
)
2233 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx
, cy
);
2238 g_GFX_QueueEffect(R_GFX_SMOKE_TRANS
, Obj
.X
-14+Random(9), cy
-20+Random(9));
2242 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2243 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2244 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
2250 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
2252 if ShotType
= WEAPON_SKEL_FIRE
then
2253 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2255 g_GFX_QueueEffect(R_GFX_EXPLODE_SKELFIRE
, Obj
.X
+ 32 - 58, Obj
.Y
+ 8 - 36);
2256 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
2260 begin // Âçðûâ Ðàêåòû
2262 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2263 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
2267 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2272 if ShotType
= WEAPON_SKEL_FIRE
then
2273 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2274 if GetPos(target
, @o
) then
2275 throw(i
, Obj
.X
, Obj
.Y
,
2276 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
2277 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
2282 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2284 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2285 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2287 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
2288 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
2294 if (ShotType
= WEAPON_PLASMA
) and
2295 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
2300 if ShotType
= WEAPON_BSP_FIRE
then
2303 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2304 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2305 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
2309 if ShotType
= WEAPON_PLASMA
then
2310 g_GFX_QueueEffect(R_GFX_EXPLODE_PLASMA
, cx
- 16, cy
- 16)
2312 g_GFX_QueueEffect(R_GFX_EXPLODE_BSPFIRE
, cx
- 16, cy
- 16);
2313 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
2315 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2320 WEAPON_FLAMETHROWER
: // Îãíåìåò
2322 // Ñî âðåìåíåì óìèðàåò
2323 if (Timeout
< 1) then
2329 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
2331 if WordBool(st
and MOVE_HITWATER
) then
2336 g_GFX_QueueEffect(R_GFX_SMOKE
, cx
-4+tcx
-(R_GFX_SMOKE_WIDTH
div 2), cy
-4+tcy
-(R_GFX_SMOKE_HEIGHT
div 2));
2342 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2345 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx
, cy
)
2346 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx
, cy
);
2354 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
2355 // Ïîïàëè â ñòåíó èëè â âîäó:
2356 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
2362 if WordBool(st
and MOVE_HITWALL
) then
2363 Stopped
:= MOVE_HITWALL
2364 else if WordBool(st
and MOVE_HITLAND
) then
2365 Stopped
:= MOVE_HITLAND
2366 else if WordBool(st
and MOVE_HITCEIL
) then
2367 Stopped
:= MOVE_HITCEIL
;
2370 a
:= IfThen(Stopped
= 0, 10, 1);
2371 // Åñëè â êîãî-òî ïîïàëè
2372 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
2374 // HIT_FLAME ñàì ïîäîææåò
2375 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2385 if (gTime
mod LongWord(tf
) = 0) then
2389 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
2390 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
2391 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
2392 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
2394 g_GFX_QueueEffect(R_GFX_FLAME_RAND
, tcx
- (R_GFX_FLAME_WIDTH
div 2), tcy
- (R_GFX_FLAME_HEIGHT
div 2));
2395 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2402 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2403 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2405 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2406 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2411 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2412 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2413 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2417 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2419 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, cx
- 64, cy
- 64);
2420 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2422 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2427 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2430 if WordBool(st
and MOVE_HITAIR
) then
2431 g_Obj_SetSpeed(@Obj
, 16);
2434 if ShotType
= WEAPON_IMP_FIRE
then
2437 if ShotType
= WEAPON_CACO_FIRE
then
2442 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2443 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2444 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2449 WEAPON_IMP_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_IMPFIRE
, cx
- 32, cy
- 32);
2450 WEAPON_CACO_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_CACOFIRE
, cx
- 32, cy
- 32);
2451 WEAPON_BARON_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_BARONFIRE
, cx
- 32, cy
- 32);
2454 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2459 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2462 if WordBool(st
and MOVE_HITAIR
) then
2463 g_Obj_SetSpeed(@Obj
, 16);
2465 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2466 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2467 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2472 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2474 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2478 end; // case ShotType of...
2480 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2481 if (ShotType
= 0) then
2483 if gGameSettings
.GameType
= GT_SERVER
then
2484 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2485 Animation
.Invalidate
;
2487 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2488 if gGameSettings
.GameType
= GT_SERVER
then
2489 MH_SEND_UpdateShot(i
);
2494 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2503 for a
:= 0 to High(Shots
) do
2504 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2505 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2506 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2507 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2508 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2509 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2510 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2517 procedure g_Weapon_SaveState (st
: TStream
);
2519 count
, i
, j
: Integer;
2521 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2523 for i
:= 0 to High(Shots
) do if (Shots
[i
].ShotType
<> 0) then Inc(count
);
2525 // Êîëè÷åñòâî ñíàðÿäîâ
2526 utils
.WriteInt(st
, count
);
2528 if (count
= 0) then exit
;
2530 for i
:= 0 to High(Shots
) do
2532 if Shots
[i
].ShotType
<> 0 then
2534 // Ñèãíàòóðà ñíàðÿäà
2535 utils
.writeSign(st
, 'SHOT');
2536 utils
.writeInt(st
, Byte(0)); // version
2538 utils
.writeInt(st
, Byte(Shots
[i
].ShotType
));
2540 utils
.writeInt(st
, Word(Shots
[i
].Target
));
2542 utils
.writeInt(st
, Word(Shots
[i
].SpawnerUID
));
2543 // Ðàçìåð ïîëÿ Triggers
2544 utils
.writeInt(st
, Integer(Length(Shots
[i
].Triggers
)));
2545 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2546 for j
:= 0 to Length(Shots
[i
].Triggers
)-1 do utils
.writeInt(st
, LongWord(Shots
[i
].Triggers
[j
]));
2548 Obj_SaveState(st
, @Shots
[i
].Obj
);
2550 utils
.writeInt(st
, Byte(Shots
[i
].Stopped
));
2555 procedure g_Weapon_LoadState (st
: TStream
);
2557 count
, tc
, i
, j
: Integer;
2559 if (st
= nil) then exit
;
2561 // Êîëè÷åñòâî ñíàðÿäîâ
2562 count
:= utils
.readLongInt(st
);
2563 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid shots counter');
2565 SetLength(Shots
, count
);
2567 if (count
= 0) then exit
;
2569 for i
:= 0 to count
-1 do
2571 // Ñèãíàòóðà ñíàðÿäà
2572 if not utils
.checkSign(st
, 'SHOT') then raise XStreamError
.Create('invalid shot signature');
2573 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid shot version');
2575 Shots
[i
].ShotType
:= utils
.readByte(st
);
2577 Shots
[i
].Target
:= utils
.readWord(st
);
2579 Shots
[i
].SpawnerUID
:= utils
.readWord(st
);
2580 // Ðàçìåð ïîëÿ Triggers
2581 tc
:= utils
.readLongInt(st
);
2582 if (tc
< 0) or (tc
> 1024*1024) then raise XStreamError
.Create('invalid shot triggers counter');
2583 SetLength(Shots
[i
].Triggers
, tc
);
2584 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2585 for j
:= 0 to tc
-1 do Shots
[i
].Triggers
[j
] := utils
.readLongWord(st
);
2587 Obj_LoadState(@Shots
[i
].Obj
, st
);
2589 Shots
[i
].Stopped
:= utils
.readByte(st
);
2591 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2592 Shots
[i
].Animation
.Invalidate
;
2594 case Shots
[i
].ShotType
of
2595 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2600 Shots
[i
].Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
2604 Shots
[i
].Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
2608 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2612 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2616 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2620 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2624 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2630 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2632 var cx
, cy
: Integer;
2637 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2641 if ShotType
= 0 then Exit
;
2645 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2646 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2650 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2655 if ShotType
= WEAPON_SKEL_FIRE
then
2656 g_GFX_QueueEffect(R_GFX_EXPLODE_SKELFIRE
, (Obj
.X
+ 32) - 32, (Obj
.Y
+ 8) - 32)
2658 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2660 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2664 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2669 if ShotType
= WEAPON_PLASMA
then
2670 g_GFX_QueueEffect(R_GFX_EXPLODE_PLASMA
, cx
- 16, cy
- 16)
2672 g_GFX_QueueEffect(R_GFX_EXPLODE_BSPFIRE
, cx
- 16, cy
- 16);
2674 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2681 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, cx
- 64, cy
- 64);
2683 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2686 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2692 WEAPON_IMP_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_IMPFIRE
, cx
- 32, cy
- 32);
2693 WEAPON_CACO_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_CACOFIRE
, cx
- 32, cy
- 32);
2694 WEAPON_BARON_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_BARONFIRE
, cx
- 32, cy
- 32);
2697 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2701 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2704 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2706 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2708 end; // case ShotType of...
2711 Animation
.Invalidate
;
2716 procedure g_Weapon_AddDynLights();
2720 if Shots
= nil then Exit
;
2721 for i
:= 0 to High(Shots
) do
2723 if Shots
[i
].ShotType
= 0 then continue
;
2724 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2725 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2726 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2727 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2728 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2729 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2730 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2731 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2732 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2733 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2734 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2737 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2738 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)
2739 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2740 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)
2741 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2742 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)
2744 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);
2750 procedure TShot
.positionChanged (); begin end;