1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
16 {.$DEFINE GWEP_HITSCAN_TRACE_BITMAP_CHECKER}
22 SysUtils
, Classes
, mempool
,
23 g_textures
, g_basic
, g_phys
, xprofiler
;
33 Animation
: 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;
104 WP_FIRST
= WEAPON_KASTET
;
105 WP_LAST
= WEAPON_FLAMETHROWER
;
108 gwep_debug_fast_trace
: Boolean = true;
120 {$IFDEF ENABLE_CORPSES}
123 Math
, g_map
, g_player
, g_sound
, g_panel
,
124 g_console
, g_options
, g_game
,
125 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
126 g_language
, g_netmsg
, g_grid
,
127 geom
, binheap
, hashtable
, utils
, xstreams
138 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
139 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
141 SHOT_SKELFIRE_WIDTH
= 14;
142 SHOT_SKELFIRE_HEIGHT
= 14;
144 SHOT_PLASMA_WIDTH
= 16;
145 SHOT_PLASMA_HEIGHT
= 16;
148 SHOT_BFG_HEIGHT
= 32;
149 SHOT_BFG_DAMAGE
= 100;
150 SHOT_BFG_RADIUS
= 256;
152 SHOT_FLAME_WIDTH
= 4;
153 SHOT_FLAME_HEIGHT
= 4;
154 SHOT_FLAME_LIFETIME
= 180;
156 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
159 PHitTime
= ^THitTime
;
163 plridx
: Integer; // if mon=nil
167 TBinHeapKeyHitTime
= class
169 class function less (const a
, b
: Integer): Boolean; inline;
172 // indicies in `wgunHitTime` array
173 TBinaryHeapHitTimes
= specialize TBinaryHeapBase
<Integer, TBinHeapKeyHitTime
>;
176 WaterMap
: array of array of DWORD
= nil;
177 //wgunMonHash: THashIntInt = nil;
178 wgunHitHeap
: TBinaryHeapHitTimes
= nil;
179 wgunHitTime
: array of THitTime
= nil;
180 wgunHitTimeUsed
: Integer = 0;
183 class function TBinHeapKeyHitTime
.less (const a
, b
: Integer): Boolean;
187 hta
:= @wgunHitTime
[a
];
188 htb
:= @wgunHitTime
[b
];
189 if (hta
.distSq
<> htb
.distSq
) then begin result
:= (hta
.distSq
< htb
.distSq
); exit
; end;
190 if (hta
.mon
<> nil) then
193 if (htb
.mon
= nil) then begin result
:= false; exit
; end; // players first
194 result
:= (hta
.mon
.UID
< htb
.mon
.UID
); // why not?
199 if (htb
.mon
<> nil) then begin result
:= true; exit
; end; // players first
200 result
:= (hta
.plridx
< htb
.plridx
); // why not?
205 procedure appendHitTimeMon (adistSq
: Integer; amon
: TMonster
; ax
, ay
: Integer);
207 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
208 with wgunHitTime
[wgunHitTimeUsed
] do
216 wgunHitHeap
.insert(wgunHitTimeUsed
);
217 Inc(wgunHitTimeUsed
);
221 procedure appendHitTimePlr (adistSq
: Integer; aplridx
: Integer; ax
, ay
: Integer);
223 if (wgunHitTimeUsed
= Length(wgunHitTime
)) then SetLength(wgunHitTime
, wgunHitTimeUsed
+128);
224 with wgunHitTime
[wgunHitTimeUsed
] do
232 wgunHitHeap
.insert(wgunHitTimeUsed
);
233 Inc(wgunHitTimeUsed
);
237 function FindShot(): DWORD
;
242 for i
:= 0 to High(Shots
) do
243 if Shots
[i
].ShotType
= 0 then
246 LastShotID
:= Result
;
252 SetLength(Shots
, 128);
257 Result
:= High(Shots
) + 1;
258 SetLength(Shots
, Length(Shots
) + 128);
260 LastShotID
:= Result
;
263 procedure CreateWaterMap();
265 WaterArray
: Array of TWaterPanel
;
272 SetLength(WaterArray
, Length(gWater
));
274 for a
:= 0 to High(gWater
) do
276 WaterArray
[a
].X
:= gWater
[a
].X
;
277 WaterArray
[a
].Y
:= gWater
[a
].Y
;
278 WaterArray
[a
].Width
:= gWater
[a
].Width
;
279 WaterArray
[a
].Height
:= gWater
[a
].Height
;
280 WaterArray
[a
].Active
:= True;
283 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
285 for a
:= 0 to High(WaterArray
) do
286 if WaterArray
[a
].Active
then
288 WaterArray
[a
].Active
:= False;
289 m
:= Length(WaterMap
);
290 SetLength(WaterMap
, m
+1);
291 SetLength(WaterMap
[m
], 1);
298 for b
:= 0 to High(WaterArray
) do
299 if WaterArray
[b
].Active
then
300 for c
:= 0 to High(WaterMap
[m
]) do
301 if g_CollideAround(WaterArray
[b
].X
,
304 WaterArray
[b
].Height
,
305 WaterArray
[WaterMap
[m
][c
]].X
,
306 WaterArray
[WaterMap
[m
][c
]].Y
,
307 WaterArray
[WaterMap
[m
][c
]].Width
,
308 WaterArray
[WaterMap
[m
][c
]].Height
) then
310 WaterArray
[b
].Active
:= False;
311 SetLength(WaterMap
[m
],
312 Length(WaterMap
[m
])+1);
313 WaterMap
[m
][High(WaterMap
[m
])] := b
;
319 g_Game_StepLoading();
327 chkTrap_pl
: array [0..256] of Integer;
328 chkTrap_mn
: array [0..65535] of TMonster
;
330 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
332 //a, b, c, d, i1, i2: Integer;
333 //chkTrap_pl, chkTrap_mn: WArray;
334 plaCount
: Integer = 0;
335 mnaCount
: Integer = 0;
339 function monsWaterCheck (mon: TMonster): Boolean;
341 result := false; // don't stop
342 if mon.alive and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
345 chkTrap_mn[i2] := monidx;
350 function monsWaterCheck (mon
: TMonster
): Boolean;
352 result
:= false; // don't stop
353 if (mon
.trapCheckFrameId
<> frameId
) then
355 mon
.trapCheckFrameId
:= frameId
;
356 chkTrap_mn
[mnaCount
] := mon
;
362 a
, b
, c
, d
, f
: Integer;
365 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
367 frameId
:= g_Mons_getNewTrapFrameId();
372 //SetLength(chkTrap_pl, 1024);
373 //SetLength(chkTrap_mn, 1024);
374 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
375 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
377 for a
:= 0 to High(WaterMap
) do
379 for b
:= 0 to High(WaterMap
[a
]) do
381 pan
:= gWater
[WaterMap
[a
][b
]];
382 if not g_Obj_Collide(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, @Shots
[ID
].Obj
) then continue
;
384 for c
:= 0 to High(WaterMap
[a
]) do
386 pan
:= gWater
[WaterMap
[a
][c
]];
387 for d
:= 0 to High(gPlayers
) do
389 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].alive
) then
391 if gPlayers
[d
].Collide(pan
) then
394 while (f
< plaCount
) and (chkTrap_pl
[f
] <> d
) do Inc(f
);
395 if (f
= plaCount
) then
397 chkTrap_pl
[plaCount
] := d
;
399 if (plaCount
= Length(chkTrap_pl
)) then break
;
405 //g_Mons_ForEach(monsWaterCheck);
406 g_Mons_ForEachAliveAt(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, monsWaterCheck
);
409 for f
:= 0 to plaCount
-1 do gPlayers
[chkTrap_pl
[f
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
410 for f
:= 0 to mnaCount
-1 do chkTrap_mn
[f
].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
418 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
425 tt
:= g_GetUIDType(SpawnerUID
);
426 if tt
= UID_MONSTER
then
428 mon
:= g_Monsters_ByUID(SpawnerUID
);
430 mt
:= g_Monsters_ByUID(SpawnerUID
).MonsterType
437 if m
= nil then Exit
;
438 if m
.UID
= SpawnerUID
then
440 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
441 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
443 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
444 if (m
.MonsterType
= MONSTER_CYBER
) or
445 (m
.MonsterType
= MONSTER_BARREL
) then
452 if tt
= UID_MONSTER
then
454 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
455 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
458 // Îáà ìîíñòðà îäíîãî âèäà:
459 if mt
= m
.MonsterType
then
461 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
462 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
463 Exit
; // Ýòè íå áüþò ñâîèõ
467 if g_Game_IsServer
then
469 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
470 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
472 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
473 if t
= HIT_FLAME
then
474 m
.CatchFire(SpawnerUID
);
477 Result
:= (gLMSRespawn
= LMS_RESPAWN_NONE
); // don't hit monsters when it's warmup time
481 function HitPlayer (p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
485 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì
486 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then exit
;
488 if g_Game_IsServer
then
490 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
491 if (t
= HIT_FLAME
) then p
.CatchFire(SpawnerUID
);
498 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
500 function monsCheck (mon
: TMonster
): Boolean;
502 result
:= false; // don't stop
503 if (mon
.alive
) and (mon
.UID
<> SpawnerUID
) then
507 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
508 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
509 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
510 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
512 if HitMonster(mon
, 50, 0, 0, SpawnerUID
, HIT_SOME
) then mon
.BFGHit();
524 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
526 {$IFDEF ENABLE_CORPSES}
528 if gAdvCorpses
and (h
<> -1) then
532 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
536 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
537 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
538 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
539 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
541 Damage(50, SpawnerUID
, 0, 0);
542 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2), Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
551 pl
:= g_Player_Get(SpawnerUID
);
559 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].alive
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
561 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
562 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
563 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
564 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
566 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
567 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
569 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
571 gPlayers
[i
].BFGHit();
575 g_Mons_ForEachAlive(monsCheck
);
578 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
583 find_id
:= FindShot()
587 if Integer(find_id
) >= High(Shots
) then
588 SetLength(Shots
, find_id
+ 64)
592 WEAPON_ROCKETLAUNCHER
:
594 with Shots
[find_id
] do
598 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
599 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
602 ShotType
:= WEAPON_ROCKETLAUNCHER
;
603 Animation
.Invalidate
;
609 with Shots
[find_id
] do
613 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
614 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
617 ShotType
:= WEAPON_PLASMA
;
618 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
624 with Shots
[find_id
] do
628 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
629 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
632 ShotType
:= WEAPON_BFG
;
633 Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
639 with Shots
[find_id
] do
643 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
644 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
647 ShotType
:= WEAPON_FLAMETHROWER
;
648 Animation
.Invalidate
;
649 // Animation := TAnimState.Create(True, 6, 0); // drawed as gfx
655 with Shots
[find_id
] do
659 Obj
.Rect
.Width
:= 16;
660 Obj
.Rect
.Height
:= 16;
663 ShotType
:= WEAPON_IMP_FIRE
;
664 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
670 with Shots
[find_id
] do
674 Obj
.Rect
.Width
:= 16;
675 Obj
.Rect
.Height
:= 16;
678 ShotType
:= WEAPON_CACO_FIRE
;
679 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
685 with Shots
[find_id
] do
689 Obj
.Rect
.Width
:= 32;
690 Obj
.Rect
.Height
:= 32;
693 ShotType
:= WEAPON_MANCUB_FIRE
;
694 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
700 with Shots
[find_id
] do
704 Obj
.Rect
.Width
:= 16;
705 Obj
.Rect
.Height
:= 16;
708 ShotType
:= WEAPON_BARON_FIRE
;
709 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
715 with Shots
[find_id
] do
719 Obj
.Rect
.Width
:= 16;
720 Obj
.Rect
.Height
:= 16;
723 ShotType
:= WEAPON_BSP_FIRE
;
724 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
730 with Shots
[find_id
] do
734 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
735 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
738 ShotType
:= WEAPON_SKEL_FIRE
;
740 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
745 Shots
[find_id
].Obj
.oldX
:= X
;
746 Shots
[find_id
].Obj
.oldY
:= Y
;
747 Shots
[find_id
].Obj
.X
:= X
;
748 Shots
[find_id
].Obj
.Y
:= Y
;
749 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
750 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
751 Shots
[find_id
].Obj
.Accel
.X
:= 0;
752 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
753 Shots
[find_id
].SpawnerUID
:= Spawner
;
754 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
755 Shots
[find_id
].Stopped
:= 255
757 Shots
[find_id
].Stopped
:= 0;
761 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
768 a
:= Max(Abs(xd
), Abs(yd
));
772 Shots
[i
].Obj
.oldX
:= x
;
773 Shots
[i
].Obj
.oldY
:= y
;
776 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
777 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
778 Shots
[i
].Obj
.Accel
.X
:= 0;
779 Shots
[i
].Obj
.Accel
.Y
:= 0;
780 Shots
[i
].Stopped
:= 0;
781 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
782 Shots
[i
].Timeout
:= 900 // ~25 sec
785 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
786 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
788 Shots
[i
].Timeout
:= 550; // ~15 sec
792 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
793 {$IFDEF ENABLE_CORPSES}
798 function PlayerHit(Team
: Byte = 0): Boolean;
809 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
812 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
814 p
:= g_Player_Get(SpawnerUID
);
816 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
819 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
821 if t
<> HIT_FLAME
then
822 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
823 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
825 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
833 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
835 result := false; // don't stop
836 if mon.alive and g_Obj_Collide(obj, @mon.Obj) then
838 if HitMonster(mon, d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
840 if (t <> HIT_FLAME) then
842 mon.Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
843 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
851 function monsCheckHit (mon
: TMonster
): Boolean;
853 result
:= false; // don't stop
854 if HitMonster(mon
, d
, obj
.Vel
.X
, obj
.Vel
.Y
, SpawnerUID
, t
) then
856 if (t
<> HIT_FLAME
) then
858 mon
.Push((obj
.Vel
.X
+obj
.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
859 (obj
.Vel
.Y
+obj
.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
865 function MonsterHit(): Boolean;
867 //result := g_Mons_ForEach(monsCheckHit);
868 //FIXME: accelerate this!
869 result
:= g_Mons_ForEachAliveAt(obj
.X
+obj
.Rect
.X
, obj
.Y
+obj
.Rect
.Y
, obj
.Rect
.Width
, obj
.Rect
.Height
, monsCheckHit
);
875 {$IFDEF ENABLE_CORPSES}
879 if gAdvCorpses
and (h
<> -1) then
883 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
884 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
887 gCorpses
[i
].Damage(d
, SpawnerUID
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
888 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
896 case gGameSettings
.GameMode
of
900 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
907 // È â êîíöå èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
908 // (èëè ñíàðÿä îò ìîíñòðà, èëè friendlyfire, èëè friendly_hit_projectile)
909 if (g_GetUIDType(SpawnerUID
) <> UID_PLAYER
) or
910 LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
923 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
940 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
954 // È â êîíöå ñâîèõ èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
955 // (èëè friendlyfire, èëè friendly_hit_projectile)
956 if LongBool(gGameSettings
.Options
and (GAME_OPTION_TEAMDAMAGE
or GAME_OPTION_TEAMHITPROJECTILE
)) then
969 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
973 case g_GetUIDType(UID
) of
974 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
975 UID_MONSTER
: Result
:= HitMonster(g_Monsters_ByUID(UID
), d
, 0, 0, SpawnerUID
, t
);
980 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
982 r
: Integer; // squared radius
984 function monsExCheck (mon
: TMonster
): Boolean;
988 result
:= false; // don't stop
990 dx
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-X
;
991 dy
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-Y
;
993 if dx
> 1000 then dx
:= 1000;
994 if dy
> 1000 then dy
:= 1000;
996 if (dx
*dx
+dy
*dy
< r
) then
998 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
999 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
1001 mm
:= Max(abs(dx
), abs(dy
));
1002 if mm
= 0 then mm
:= 1;
1006 HitMonster(mon
, ((mon
.Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
, 0, 0, SpawnerUID
, HIT_ROCKET
);
1009 mon
.Push((dx
*7) div mm
, (dy
*7) div mm
);
1014 var i
, h
, dx
, dy
, mm
: Integer;
1015 {$IFDEF ENABLE_GIBS}
1016 var _angle
: SmallInt;
1018 {$IF DEFINED(ENABLE_GIBS) OR DEFINED(ENABLE_CORPSES)}
1024 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
1028 h
:= High(gPlayers
);
1032 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1035 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1036 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1038 if dx
> 1000 then dx
:= 1000;
1039 if dy
> 1000 then dy
:= 1000;
1041 if dx
*dx
+dy
*dy
< r
then
1043 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1044 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1046 mm
:= Max(abs(dx
), abs(dy
));
1047 if mm
= 0 then mm
:= 1;
1049 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
1050 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
1054 //g_Mons_ForEach(monsExCheck);
1055 g_Mons_ForEachAt(X
-(rad
+32), Y
-(rad
+32), (rad
+32)*2, (rad
+32)*2, monsExCheck
);
1057 {$IFDEF ENABLE_CORPSES}
1058 h
:= High(gCorpses
);
1059 if gAdvCorpses
and (h
<> -1) then
1063 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
1067 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1068 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1069 if dx
> 1000 then dx
:= 1000;
1070 if dy
> 1000 then dy
:= 1000;
1071 if dx
*dx
+dy
*dy
< r
then
1073 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1074 mm
:= Max(abs(dx
), abs(dy
));
1077 Damage(Round(100*(rad
-m
)/rad
), SpawnerUID
, (dx
*10) div mm
, (dy
*10) div mm
);
1085 {$IFDEF ENABLE_GIBS}
1087 if gAdvGibs
and (h
<> -1) then
1089 if gGibs
[i
].alive
then
1092 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1093 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1094 if dx
> 1000 then dx
:= 1000;
1095 if dy
> 1000 then dy
:= 1000;
1096 if dx
*dx
+dy
*dy
< r
then
1098 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1099 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1100 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
1101 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
1102 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
1103 positionChanged(); // this updates spatial accelerators
1109 procedure g_Weapon_Init();
1114 procedure g_Weapon_Free();
1120 procedure g_Weapon_LoadData();
1122 e_WriteLog('Loading weapons data...', TMsgType
.Notify
);
1124 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
1125 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
1126 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1127 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1128 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1129 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1130 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1131 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1132 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1133 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1134 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1135 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1136 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1137 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1138 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1139 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1140 g_Sound_CreateWADEx('SOUND_IGNITE', GameWAD
+':SOUNDS\IGNITE');
1141 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1142 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1143 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1144 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1145 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1146 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1147 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1148 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1149 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1150 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD
+':SOUNDS\STARTFLM');
1151 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD
+':SOUNDS\STOPFLM');
1152 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD
+':SOUNDS\WORKFLM');
1153 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1154 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1155 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1156 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1157 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1158 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1159 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1161 //wgunMonHash := hashNewIntInt();
1162 wgunHitHeap
:= TBinaryHeapHitTimes
.Create();
1165 procedure g_Weapon_FreeData();
1167 e_WriteLog('Releasing weapons data...', TMsgType
.Notify
);
1169 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1170 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1171 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1172 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1173 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1174 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1175 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1176 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1177 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1178 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1179 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1180 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1181 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1182 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1183 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1184 g_Sound_Delete('SOUND_FIRE');
1185 g_Sound_Delete('SOUND_IGNITE');
1186 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1187 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1188 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1189 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1190 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1191 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1192 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1193 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1194 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1195 g_Sound_Delete('SOUND_WEAPON_FLAMEON');
1196 g_Sound_Delete('SOUND_WEAPON_FLAMEOFF');
1197 g_Sound_Delete('SOUND_WEAPON_FLAMEWORK');
1198 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1199 g_Sound_Delete('SOUND_PLAYER_JETON');
1200 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1201 g_Sound_Delete('SOUND_PLAYER_CASING1');
1202 g_Sound_Delete('SOUND_PLAYER_CASING2');
1203 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1204 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1208 function GunHitPlayer (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Boolean;
1213 for i
:= 0 to High(gPlayers
) do
1215 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
and gPlayers
[i
].Collide(X
, Y
) then
1217 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1219 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
1227 function GunHit (X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer; SpawnerUID
: Word; AllowPush
: Boolean): Byte;
1229 function monsCheck (mon
: TMonster
): Boolean;
1231 result
:= false; // don't stop
1232 if HitMonster(mon
, dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
1234 if AllowPush
then mon
.Push(vx
, vy
);
1241 if GunHitPlayer(X
, Y
, vx
, vy
, dmg
, SpawnerUID
, AllowPush
) then result
:= 1
1242 else if g_Mons_ForEachAliveAt(X
, Y
, 1, 1, monsCheck
) then result
:= 2;
1247 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1258 t1, _collide: Boolean;
1260 {$IF DEFINED(D2F_DEBUG)}
1262 showTime: Boolean = true;
1265 a := GetAngle(x, y, xd, yd)+180;
1267 SinCos(DegToRad(-a), s, c);
1269 if Abs(s) < 0.01 then s := 0;
1270 if Abs(c) < 0.01 then c := 0;
1272 x2 := x+Round(c*gMapInfo.Width);
1273 y2 := y+Round(s*gMapInfo.Width);
1275 t1 := gWalls <> nil;
1277 w := gMapInfo.Width;
1278 h := gMapInfo.Height;
1285 if (xd = 0) and (yd = 0) then Exit;
1287 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1288 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1293 if dx > dy then d := dx else d := dy;
1295 //blood vel, for Monster.Damage()
1296 //vx := (dx*10 div d)*xi;
1297 //vy := (dy*10 div d)*yi;
1299 {$IF DEFINED(D2F_DEBUG)}
1300 stt := getTimeMicro();
1323 if (yy > h) or (yy < 0) then Break;
1324 if (xx > w) or (xx < 0) then Break;
1327 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1330 {$IF DEFINED(D2F_DEBUG)}
1331 stt := getTimeMicro()-stt;
1332 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1335 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1336 if g_Game_IsServer and g_Game_IsNet then
1337 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1340 if not _collide then
1342 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1345 if _collide then Break;
1348 {$IF DEFINED(D2F_DEBUG)}
1351 stt := getTimeMicro()-stt;
1352 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1356 if CheckTrigger and g_Game_IsServer then
1357 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1363 procedure g_Weapon_gun (const x
, y
, xd
, yd
, v
, indmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1368 wallDistSq
: Integer = $3fffffff;
1369 spawnerPlr
: TPlayer
= nil;
1372 function doPlayerHit (idx
: Integer; hx
, hy
: Integer): Boolean;
1375 if (idx
< 0) or (idx
> High(gPlayers
)) then exit
;
1376 if (gPlayers
[idx
] = nil) or not gPlayers
[idx
].alive
then exit
;
1377 if (spawnerPlr
<> nil) then
1379 if ((gGameSettings
.Options
and (GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMDAMAGE
)) = 0) and
1380 (spawnerPlr
.Team
<> TEAM_NONE
) and (spawnerPlr
.Team
= gPlayers
[idx
].Team
) then
1382 if (spawnerPlr
<> gPlayers
[idx
]) and ((gGameSettings
.Options
and GAME_OPTION_TEAMABSORBDAMAGE
) = 0) then
1383 dmg
:= Max(1, dmg
div 2);
1387 result
:= HitPlayer(gPlayers
[idx
], dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1388 if result
and (v
<> 0) then gPlayers
[idx
].Push((xi
*v
), (yi
*v
));
1389 {$IF DEFINED(D2F_DEBUG)}
1390 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1394 function doMonsterHit (mon
: TMonster
; hx
, hy
: Integer): Boolean;
1397 if (mon
= nil) then exit
;
1398 result
:= HitMonster(mon
, dmg
, (xi
*v
)*10, (yi
*v
)*10-3, SpawnerUID
, HIT_SOME
);
1399 if result
and (v
<> 0) then mon
.Push((xi
*v
), (yi
*v
));
1400 {$IF DEFINED(D2F_DEBUG)}
1401 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1405 // collect players along hitray
1406 // return `true` if instant hit was detected
1407 function playerPossibleHit (): Boolean;
1410 px
, py
, pw
, ph
: Integer;
1416 for i
:= 0 to High(gPlayers
) do
1419 if (plr
<> nil) and plr
.alive
then
1421 plr
.getMapBox(px
, py
, pw
, ph
);
1422 if lineAABBIntersects(x
, y
, x2
, y2
, px
, py
, pw
, ph
, inx
, iny
) then
1424 distSq
:= distanceSq(x
, y
, inx
, iny
);
1425 if (distSq
= 0) then
1428 if doPlayerHit(i
, x
, y
) then begin result
:= true; exit
; end;
1430 else if (distSq
< wallDistSq
) then
1432 appendHitTimePlr(distSq
, i
, inx
, iny
);
1439 procedure sqchecker (mon
: TMonster
);
1441 mx
, my
, mw
, mh
: Integer;
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)}
1467 it
: TMonsterGrid
.Iter
;
1470 if not gwep_debug_fast_trace then
1472 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1477 if (xd
= 0) and (yd
= 0) then exit
;
1479 if (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1480 spawnerPlr
:= g_Player_Get(SpawnerUID
);
1484 //wgunMonHash.reset(); //FIXME: clear hash on level change
1485 wgunHitHeap
.clear();
1486 wgunHitTimeUsed
:= 0;
1488 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1490 SinCos(DegToRad(-a
), s
, c
);
1492 if Abs(s
) < 0.01 then s
:= 0;
1493 if Abs(c
) < 0.01 then c
:= 0;
1497 x2
:= x
+Round(c
*gMapInfo
.Width
);
1498 y2
:= y
+Round(s
*gMapInfo
.Width
);
1503 if (dx
> 0) then xi
:= 1 else if (dx
< 0) then xi
:= -1 else xi
:= 0;
1504 if (dy
> 0) then yi
:= 1 else if (dy
< 0) then yi
:= -1 else yi
:= 0;
1506 {$IF DEFINED(D2F_DEBUG)}
1507 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x
, y
, x2
, y2
]), TMsgType
.Notify
);
1508 stt
:= getTimeMicro();
1511 wallHitFlag
:= (g_Map_traceToNearestWall(x
, y
, x2
, y2
, @wallHitX
, @wallHitY
) <> nil);
1516 wallDistSq
:= distanceSq(x
, y
, wallHitX
, wallHitY
);
1524 if playerPossibleHit() then exit
; // instant hit
1527 //g_Mons_AlongLine(x, y, x2, y2, sqchecker);
1529 it
:= monsGrid
.forEachAlongLine(x
, y
, x2
, y2
, -1);
1530 for mit
in it
do sqchecker(mit
^);
1533 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1534 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1535 while (wgunHitHeap
.count
> 0) do
1537 // has some entities to check, do it
1538 i
:= wgunHitHeap
.front
;
1539 wgunHitHeap
.popFront();
1541 xe
:= wgunHitTime
[i
].x
;
1542 ye
:= wgunHitTime
[i
].y
;
1543 // check if it is not behind the wall
1544 if (wgunHitTime
[i
].mon
<> nil) then
1546 didHit
:= doMonsterHit(wgunHitTime
[i
].mon
, xe
, ye
);
1550 didHit
:= doPlayerHit(wgunHitTime
[i
].plridx
, xe
, ye
);
1554 // need new coords for trigger
1557 wallHitFlag
:= false; // no sparks
1565 {$IF DEFINED(D2F_DEBUG)}
1566 stt
:= getTimeMicro()-stt
;
1567 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1570 g_GFX_Spark(wallHitX
, wallHitY
, 2+Random(2), 180+a
, 0, 0);
1572 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(wallHitX
, wallHitY
, 180+a
, NET_GFX_SPARK
);
1576 {$IF DEFINED(D2F_DEBUG)}
1577 stt
:= getTimeMicro()-stt
;
1578 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt
)]), TMsgType
.Notify
);
1582 if CheckTrigger
and g_Game_IsServer
then g_Triggers_PressL(X
, Y
, wallHitX
, wallHitY
, SpawnerUID
, ACTIVATE_SHOT
);
1586 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1594 obj
.rect
.Width
:= 39;
1595 obj
.rect
.Height
:= 52;
1601 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1602 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1604 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1607 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1615 obj
.rect
.Width
:= 32;
1616 obj
.rect
.Height
:= 52;
1622 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1625 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1626 Silent
: Boolean = False; compat
: Boolean = true);
1632 find_id
:= FindShot()
1636 if Integer(find_id
) >= High(Shots
) then
1637 SetLength(Shots
, find_id
+ 64)
1640 with Shots
[find_id
] do
1644 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1645 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1648 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1650 dx
:= -(Obj
.Rect
.Width
div 2);
1651 dy
:= -(Obj
.Rect
.Height
div 2);
1653 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1654 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1656 Animation
.Invalidate
;
1660 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1663 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1666 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1667 WID
: Integer = -1; Silent
: Boolean = False);
1673 find_id
:= FindShot()
1677 if Integer(find_id
) >= High(Shots
) then
1678 SetLength(Shots
, find_id
+ 64)
1681 with Shots
[find_id
] do
1685 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1686 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1688 dx
:= -(Obj
.Rect
.Width
div 2);
1689 dy
:= -(Obj
.Rect
.Height
div 2);
1691 ShotType
:= WEAPON_SKEL_FIRE
;
1692 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1695 target
:= TargetUID
;
1696 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
1699 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1702 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1705 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1706 Silent
: Boolean = False; compat
: Boolean = true);
1712 find_id
:= FindShot()
1716 if Integer(find_id
) >= High(Shots
) then
1717 SetLength(Shots
, find_id
+ 64);
1720 with Shots
[find_id
] do
1724 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1725 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1728 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1730 dx
:= -(Obj
.Rect
.Width
div 2);
1731 dy
:= -(Obj
.Rect
.Height
div 2);
1733 ShotType
:= WEAPON_PLASMA
;
1734 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1737 Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
1740 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1743 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1746 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1747 Silent
: Boolean = False; compat
: Boolean = true);
1753 find_id
:= FindShot()
1757 if Integer(find_id
) >= High(Shots
) then
1758 SetLength(Shots
, find_id
+ 64);
1761 with Shots
[find_id
] do
1765 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1766 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1769 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1771 dx
:= -(Obj
.Rect
.Width
div 2);
1772 dy
:= -(Obj
.Rect
.Height
div 2);
1774 ShotType
:= WEAPON_FLAMETHROWER
;
1775 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1778 Animation
.Invalidate
;
1781 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1783 // if not Silent then
1784 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1787 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1788 Silent
: Boolean = False; compat
: Boolean = true);
1794 find_id
:= FindShot()
1798 if Integer(find_id
) >= High(Shots
) then
1799 SetLength(Shots
, find_id
+ 64)
1802 with Shots
[find_id
] do
1806 Obj
.Rect
.Width
:= 16;
1807 Obj
.Rect
.Height
:= 16;
1810 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1812 dx
:= -(Obj
.Rect
.Width
div 2);
1813 dy
:= -(Obj
.Rect
.Height
div 2);
1815 ShotType
:= WEAPON_IMP_FIRE
;
1816 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1819 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1822 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1825 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1828 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1829 Silent
: Boolean = False; compat
: Boolean = true);
1835 find_id
:= FindShot()
1839 if Integer(find_id
) >= High(Shots
) then
1840 SetLength(Shots
, find_id
+ 64)
1843 with Shots
[find_id
] do
1847 Obj
.Rect
.Width
:= 16;
1848 Obj
.Rect
.Height
:= 16;
1851 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1853 dx
:= -(Obj
.Rect
.Width
div 2);
1854 dy
:= -(Obj
.Rect
.Height
div 2);
1856 ShotType
:= WEAPON_CACO_FIRE
;
1857 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1860 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1863 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1866 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1869 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1870 Silent
: Boolean = False; compat
: Boolean = true);
1876 find_id
:= FindShot()
1880 if Integer(find_id
) >= High(Shots
) then
1881 SetLength(Shots
, find_id
+ 64)
1884 with Shots
[find_id
] do
1888 Obj
.Rect
.Width
:= 32;
1889 Obj
.Rect
.Height
:= 16;
1892 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1894 dx
:= -(Obj
.Rect
.Width
div 2);
1895 dy
:= -(Obj
.Rect
.Height
div 2);
1897 ShotType
:= WEAPON_BARON_FIRE
;
1898 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1901 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1904 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1907 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1910 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1911 Silent
: Boolean = False; compat
: Boolean = true);
1917 find_id
:= FindShot()
1921 if Integer(find_id
) >= High(Shots
) then
1922 SetLength(Shots
, find_id
+ 64)
1925 with Shots
[find_id
] do
1929 Obj
.Rect
.Width
:= 16;
1930 Obj
.Rect
.Height
:= 16;
1933 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1935 dx
:= -(Obj
.Rect
.Width
div 2);
1936 dy
:= -(Obj
.Rect
.Height
div 2);
1938 ShotType
:= WEAPON_BSP_FIRE
;
1939 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1943 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1946 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1949 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1952 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1953 Silent
: Boolean = False; compat
: Boolean = true);
1959 find_id
:= FindShot()
1963 if Integer(find_id
) >= High(Shots
) then
1964 SetLength(Shots
, find_id
+ 64)
1967 with Shots
[find_id
] do
1971 Obj
.Rect
.Width
:= 32;
1972 Obj
.Rect
.Height
:= 32;
1975 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
1977 dx
:= -(Obj
.Rect
.Width
div 2);
1978 dy
:= -(Obj
.Rect
.Height
div 2);
1980 ShotType
:= WEAPON_MANCUB_FIRE
;
1981 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1985 Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
1988 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1991 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1994 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1995 Silent
: Boolean = False; compat
: Boolean = true);
2001 find_id
:= FindShot()
2005 if Integer(find_id
) >= High(Shots
) then
2006 SetLength(Shots
, find_id
+ 64)
2009 with Shots
[find_id
] do
2013 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
2014 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
2017 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0)
2019 dx
:= -(Obj
.Rect
.Width
div 2);
2020 dy
:= -(Obj
.Rect
.Height
div 2);
2022 ShotType
:= WEAPON_BFG
;
2023 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
2026 Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
2029 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
2032 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
2035 procedure g_Weapon_bfghit(x
, y
: Integer);
2038 g_GFX_QueueEffect(R_GFX_BFG_HIT
, x
- 32, y
- 32);
2042 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2043 Silent
: Boolean = False);
2046 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
2048 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2049 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
2051 if ABS(x
-xd
) >= ABS(y
-yd
) then
2053 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
2054 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2058 g_Weapon_gun(x
+1, y
, xd
+1, yd
, 1, 3, SpawnerUID
, False);
2059 g_Weapon_gun(x
-1, y
, xd
-1, yd
, 1, 2, SpawnerUID
, False);
2064 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2065 Silent
: Boolean = False);
2068 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
2070 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
2071 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
2072 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
2074 if ABS(x
-xd
) >= ABS(y
-yd
) then
2076 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
2077 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
2081 g_Weapon_gun(x
+1, y
, xd
+1, yd
, 1, 2, SpawnerUID
, False);
2082 g_Weapon_gun(x
-1, y
, xd
-1, yd
, 1, 2, SpawnerUID
, False);
2087 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2088 Silent
: Boolean = False);
2093 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
2098 if ABS(x
-xd
) >= ABS(y
-yd
) then j
:= Random(17) - 8 else k
:= Random(17) - 8; // -8 .. 8
2099 g_Weapon_gun(x
+k
, y
+j
, xd
+k
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
2103 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
2104 Silent
: Boolean = False);
2106 a
, i
, j
, k
: Integer;
2109 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
2111 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
2115 if ABS(x
-xd
) >= ABS(y
-yd
) then j
:= Random(41) - 20 else k
:= Random(41) - 20; // -20 .. 20
2116 g_Weapon_gun(x
+k
, y
+j
, xd
+k
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
2120 procedure g_Weapon_PreUpdate();
2124 if Shots
= nil then Exit
;
2125 for i
:= 0 to High(Shots
) do
2126 if Shots
[i
].ShotType
<> 0 then
2128 Shots
[i
].Obj
.oldX
:= Shots
[i
].Obj
.X
;
2129 Shots
[i
].Obj
.oldY
:= Shots
[i
].Obj
.Y
;
2133 procedure g_Weapon_Update();
2135 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
2142 var tcx
, tcy
: Integer;
2148 for i
:= 0 to High(Shots
) do
2150 if Shots
[i
].ShotType
= 0 then
2157 Timeout
:= Timeout
- 1;
2160 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2161 if (Stopped
= 0) and g_Game_IsServer
then
2162 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
2163 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
2169 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2170 if triggers
= nil then
2177 if not InDWArray(t
[a
], triggers
) then
2179 SetLength(triggers
, Length(triggers
)+1);
2180 triggers
[High(triggers
)] := t
[a
];
2185 // Àíèìàöèÿ ñíàðÿäà:
2186 if Animation
.IsValid() then
2190 spl
:= (ShotType
<> WEAPON_PLASMA
) and
2191 (ShotType
<> WEAPON_BFG
) and
2192 (ShotType
<> WEAPON_BSP_FIRE
) and
2193 (ShotType
<> WEAPON_FLAMETHROWER
);
2197 st
:= g_Obj_Move_Projectile(@Obj
, False, spl
);
2203 positionChanged(); // this updates spatial accelerators
2205 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
2206 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
2208 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2210 Animation
.Invalidate();
2214 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2215 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2218 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2220 // Âûëåòåëà èç âîäû:
2221 if WordBool(st
and MOVE_HITAIR
) then
2222 g_Obj_SetSpeed(@Obj
, 12);
2224 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2225 if WordBool(st
and MOVE_INWATER
) then
2228 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2231 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx
, cy
)
2232 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx
, cy
);
2237 g_GFX_QueueEffect(R_GFX_SMOKE_TRANS
, Obj
.X
-14+Random(9), cy
-20+Random(9));
2241 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2242 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2243 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
2249 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
2251 if ShotType
= WEAPON_SKEL_FIRE
then
2252 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2254 g_GFX_QueueEffect(R_GFX_EXPLODE_SKELFIRE
, Obj
.X
+ 32 - 58, Obj
.Y
+ 8 - 36);
2255 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
2259 begin // Âçðûâ Ðàêåòû
2261 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2262 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
2266 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2271 if ShotType
= WEAPON_SKEL_FIRE
then
2272 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2273 if GetPos(target
, @o
) then
2274 throw(i
, Obj
.X
, Obj
.Y
,
2275 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
2276 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
2281 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2283 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2284 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2286 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
2287 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
2293 if (ShotType
= WEAPON_PLASMA
) and
2294 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
2299 if ShotType
= WEAPON_BSP_FIRE
then
2302 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2303 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2304 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
2308 if ShotType
= WEAPON_PLASMA
then
2309 g_GFX_QueueEffect(R_GFX_EXPLODE_PLASMA
, cx
- 16, cy
- 16)
2311 g_GFX_QueueEffect(R_GFX_EXPLODE_BSPFIRE
, cx
- 16, cy
- 16);
2312 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
2314 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2319 WEAPON_FLAMETHROWER
: // Îãíåìåò
2321 // Ñî âðåìåíåì óìèðàåò
2322 if (Timeout
< 1) then
2328 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
2330 if WordBool(st
and MOVE_HITWATER
) then
2335 g_GFX_QueueEffect(R_GFX_SMOKE
, cx
-4+tcx
-(R_GFX_SMOKE_WIDTH
div 2), cy
-4+tcy
-(R_GFX_SMOKE_HEIGHT
div 2));
2341 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2344 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx
, cy
)
2345 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx
, cy
);
2353 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
2354 // Ïîïàëè â ñòåíó èëè â âîäó:
2355 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
2361 if WordBool(st
and MOVE_HITWALL
) then
2362 Stopped
:= MOVE_HITWALL
2363 else if WordBool(st
and MOVE_HITLAND
) then
2364 Stopped
:= MOVE_HITLAND
2365 else if WordBool(st
and MOVE_HITCEIL
) then
2366 Stopped
:= MOVE_HITCEIL
;
2369 a
:= IfThen(Stopped
= 0, 10, 1);
2370 // Åñëè â êîãî-òî ïîïàëè
2371 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
2373 // HIT_FLAME ñàì ïîäîææåò
2374 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2384 if (gTime
mod LongWord(tf
) = 0) then
2388 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
2389 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
2390 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
2391 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
2393 g_GFX_QueueEffect(R_GFX_FLAME_RAND
, tcx
- (R_GFX_FLAME_WIDTH
div 2), tcy
- (R_GFX_FLAME_HEIGHT
div 2));
2394 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2401 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2402 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2404 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2405 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2410 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2411 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2412 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2416 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2418 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, cx
- 64, cy
- 64);
2419 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2421 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2426 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2429 if WordBool(st
and MOVE_HITAIR
) then
2430 g_Obj_SetSpeed(@Obj
, 16);
2433 if ShotType
= WEAPON_IMP_FIRE
then
2436 if ShotType
= WEAPON_CACO_FIRE
then
2441 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2442 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2443 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2448 WEAPON_IMP_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_IMPFIRE
, cx
- 32, cy
- 32);
2449 WEAPON_CACO_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_CACOFIRE
, cx
- 32, cy
- 32);
2450 WEAPON_BARON_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_BARONFIRE
, cx
- 32, cy
- 32);
2453 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2458 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2461 if WordBool(st
and MOVE_HITAIR
) then
2462 g_Obj_SetSpeed(@Obj
, 16);
2464 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2465 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2466 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2471 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2473 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2477 end; // case ShotType of...
2479 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2480 if (ShotType
= 0) then
2482 if gGameSettings
.GameType
= GT_SERVER
then
2483 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2484 Animation
.Invalidate
;
2486 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2487 if gGameSettings
.GameType
= GT_SERVER
then
2488 MH_SEND_UpdateShot(i
);
2493 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2502 for a
:= 0 to High(Shots
) do
2503 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2504 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2505 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2506 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2507 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2508 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2509 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2516 procedure g_Weapon_SaveState (st
: TStream
);
2518 count
, i
, j
: Integer;
2520 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2522 for i
:= 0 to High(Shots
) do if (Shots
[i
].ShotType
<> 0) then Inc(count
);
2524 // Êîëè÷åñòâî ñíàðÿäîâ
2525 utils
.WriteInt(st
, count
);
2527 if (count
= 0) then exit
;
2529 for i
:= 0 to High(Shots
) do
2531 if Shots
[i
].ShotType
<> 0 then
2533 // Ñèãíàòóðà ñíàðÿäà
2534 utils
.writeSign(st
, 'SHOT');
2535 utils
.writeInt(st
, Byte(0)); // version
2537 utils
.writeInt(st
, Byte(Shots
[i
].ShotType
));
2539 utils
.writeInt(st
, Word(Shots
[i
].Target
));
2541 utils
.writeInt(st
, Word(Shots
[i
].SpawnerUID
));
2542 // Ðàçìåð ïîëÿ Triggers
2543 utils
.writeInt(st
, Integer(Length(Shots
[i
].Triggers
)));
2544 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2545 for j
:= 0 to Length(Shots
[i
].Triggers
)-1 do utils
.writeInt(st
, LongWord(Shots
[i
].Triggers
[j
]));
2547 Obj_SaveState(st
, @Shots
[i
].Obj
);
2549 utils
.writeInt(st
, Byte(Shots
[i
].Stopped
));
2554 procedure g_Weapon_LoadState (st
: TStream
);
2556 count
, tc
, i
, j
: Integer;
2558 if (st
= nil) then exit
;
2560 // Êîëè÷åñòâî ñíàðÿäîâ
2561 count
:= utils
.readLongInt(st
);
2562 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid shots counter');
2564 SetLength(Shots
, count
);
2566 if (count
= 0) then exit
;
2568 for i
:= 0 to count
-1 do
2570 // Ñèãíàòóðà ñíàðÿäà
2571 if not utils
.checkSign(st
, 'SHOT') then raise XStreamError
.Create('invalid shot signature');
2572 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid shot version');
2574 Shots
[i
].ShotType
:= utils
.readByte(st
);
2576 Shots
[i
].Target
:= utils
.readWord(st
);
2578 Shots
[i
].SpawnerUID
:= utils
.readWord(st
);
2579 // Ðàçìåð ïîëÿ Triggers
2580 tc
:= utils
.readLongInt(st
);
2581 if (tc
< 0) or (tc
> 1024*1024) then raise XStreamError
.Create('invalid shot triggers counter');
2582 SetLength(Shots
[i
].Triggers
, tc
);
2583 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2584 for j
:= 0 to tc
-1 do Shots
[i
].Triggers
[j
] := utils
.readLongWord(st
);
2586 Obj_LoadState(@Shots
[i
].Obj
, st
);
2588 Shots
[i
].Stopped
:= utils
.readByte(st
);
2590 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2591 Shots
[i
].Animation
.Invalidate
;
2593 case Shots
[i
].ShotType
of
2594 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2599 Shots
[i
].Animation
:= TAnimState
.Create(True, 5, 2); // !!! put values into table
2603 Shots
[i
].Animation
:= TAnimState
.Create(True, 6, 2); // !!! put values into table
2607 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2611 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2615 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2619 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2623 Shots
[i
].Animation
:= TAnimState
.Create(True, 4, 2); // !!! put values into table
2629 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2631 var cx
, cy
: Integer;
2636 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2640 if ShotType
= 0 then Exit
;
2644 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2645 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2649 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2654 if ShotType
= WEAPON_SKEL_FIRE
then
2655 g_GFX_QueueEffect(R_GFX_EXPLODE_SKELFIRE
, (Obj
.X
+ 32) - 32, (Obj
.Y
+ 8) - 32)
2657 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2659 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2663 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2668 if ShotType
= WEAPON_PLASMA
then
2669 g_GFX_QueueEffect(R_GFX_EXPLODE_PLASMA
, cx
- 16, cy
- 16)
2671 g_GFX_QueueEffect(R_GFX_EXPLODE_BSPFIRE
, cx
- 16, cy
- 16);
2673 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2680 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, cx
- 64, cy
- 64);
2682 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2685 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2691 WEAPON_IMP_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_IMPFIRE
, cx
- 32, cy
- 32);
2692 WEAPON_CACO_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_CACOFIRE
, cx
- 32, cy
- 32);
2693 WEAPON_BARON_FIRE
: g_GFX_QueueEffect(R_GFX_EXPLODE_BARONFIRE
, cx
- 32, cy
- 32);
2696 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2700 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2703 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, cx
- 64, cy
- 64);
2705 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2707 end; // case ShotType of...
2710 Animation
.Invalidate
;
2715 procedure g_Weapon_AddDynLights();
2719 if Shots
= nil then Exit
;
2720 for i
:= 0 to High(Shots
) do
2722 if Shots
[i
].ShotType
= 0 then continue
;
2723 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2724 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2725 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2726 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2727 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2728 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2729 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2730 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2731 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2732 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2733 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2736 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2737 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)
2738 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2739 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)
2740 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2741 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)
2743 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);
2749 procedure TShot
.positionChanged (); begin end;