1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 g_textures
, g_basic
, e_graphics
, g_phys
, BinEditor
;
44 Animation
: TAnimation
;
49 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
54 Shots
: array of TShot
= nil;
55 LastShotID
: Integer = 0;
57 procedure g_Weapon_LoadData();
58 procedure g_Weapon_FreeData();
59 procedure g_Weapon_Init();
60 procedure g_Weapon_Free();
61 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
62 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
63 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
65 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
66 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
67 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
68 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
69 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
70 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
71 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
72 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
73 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
74 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
75 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
76 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
77 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1; Silent
: Boolean = False);
78 procedure g_Weapon_bfghit(x
, y
: Integer);
79 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
80 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
81 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
82 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; Silent
: Boolean = False);
84 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
85 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
86 procedure g_Weapon_Update();
87 procedure g_Weapon_Draw();
88 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
89 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
91 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
92 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
94 procedure g_Weapon_AddDynLights();
103 WEAPON_ROCKETLAUNCHER
= 6;
106 WEAPON_SUPERPULEMET
= 9;
107 WEAPON_FLAMETHROWER
= 10;
108 WEAPON_ZOMBY_PISTOL
= 20;
109 WEAPON_IMP_FIRE
= 21;
110 WEAPON_BSP_FIRE
= 22;
111 WEAPON_CACO_FIRE
= 23;
112 WEAPON_BARON_FIRE
= 24;
113 WEAPON_MANCUB_FIRE
= 25;
114 WEAPON_SKEL_FIRE
= 26;
116 WP_FIRST
= WEAPON_KASTET
;
117 WP_LAST
= WEAPON_FLAMETHROWER
;
122 Math
, g_map
, g_player
, g_gfx
, g_sound
, g_main
, g_panel
,
123 g_console
, SysUtils
, g_options
, g_game
,
124 g_triggers
, MAPDEF
, e_log
, g_monsters
, g_saveload
,
125 g_language
, g_netmsg
;
135 SHOT_ROCKETLAUNCHER_WIDTH
= 14;
136 SHOT_ROCKETLAUNCHER_HEIGHT
= 14;
138 SHOT_SKELFIRE_WIDTH
= 14;
139 SHOT_SKELFIRE_HEIGHT
= 14;
141 SHOT_PLASMA_WIDTH
= 16;
142 SHOT_PLASMA_HEIGHT
= 16;
145 SHOT_BFG_HEIGHT
= 32;
146 SHOT_BFG_DAMAGE
= 100;
147 SHOT_BFG_RADIUS
= 256;
149 SHOT_FLAME_WIDTH
= 4;
150 SHOT_FLAME_HEIGHT
= 4;
151 SHOT_FLAME_LIFETIME
= 180;
153 SHOT_SIGNATURE
= $544F4853; // 'SHOT'
156 WaterMap
: array of array of DWORD
= nil;
158 function FindShot(): DWORD
;
163 for i
:= 0 to High(Shots
) do
164 if Shots
[i
].ShotType
= 0 then
167 LastShotID
:= Result
;
173 SetLength(Shots
, 128);
178 Result
:= High(Shots
) + 1;
179 SetLength(Shots
, Length(Shots
) + 128);
181 LastShotID
:= Result
;
184 procedure CreateWaterMap();
186 WaterArray
: Array of TWaterPanel
;
193 SetLength(WaterArray
, Length(gWater
));
195 for a
:= 0 to High(gWater
) do
197 WaterArray
[a
].X
:= gWater
[a
].X
;
198 WaterArray
[a
].Y
:= gWater
[a
].Y
;
199 WaterArray
[a
].Width
:= gWater
[a
].Width
;
200 WaterArray
[a
].Height
:= gWater
[a
].Height
;
201 WaterArray
[a
].Active
:= True;
204 g_Game_SetLoadingText(_lc
[I_LOAD_WATER_MAP
], High(WaterArray
), False);
206 for a
:= 0 to High(WaterArray
) do
207 if WaterArray
[a
].Active
then
209 WaterArray
[a
].Active
:= False;
210 m
:= Length(WaterMap
);
211 SetLength(WaterMap
, m
+1);
212 SetLength(WaterMap
[m
], 1);
219 for b
:= 0 to High(WaterArray
) do
220 if WaterArray
[b
].Active
then
221 for c
:= 0 to High(WaterMap
[m
]) do
222 if g_CollideAround(WaterArray
[b
].X
,
225 WaterArray
[b
].Height
,
226 WaterArray
[WaterMap
[m
][c
]].X
,
227 WaterArray
[WaterMap
[m
][c
]].Y
,
228 WaterArray
[WaterMap
[m
][c
]].Width
,
229 WaterArray
[WaterMap
[m
][c
]].Height
) then
231 WaterArray
[b
].Active
:= False;
232 SetLength(WaterMap
[m
],
233 Length(WaterMap
[m
])+1);
234 WaterMap
[m
][High(WaterMap
[m
])] := b
;
240 g_Game_StepLoading();
248 chkTrap_pl
: array [0..256] of Integer;
249 chkTrap_mn
: array [0..65535] of TMonster
;
251 procedure CheckTrap(ID
: DWORD
; dm
: Integer; t
: Byte);
253 //a, b, c, d, i1, i2: Integer;
254 //chkTrap_pl, chkTrap_mn: WArray;
255 plaCount
: Integer = 0;
256 mnaCount
: Integer = 0;
260 function monsWaterCheck (monidx: Integer; mon: TMonster): Boolean;
262 result := false; // don't stop
263 if mon.Live and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
266 chkTrap_mn[i2] := monidx;
271 function monsWaterCheck (monidx
: Integer; mon
: TMonster
): Boolean;
273 result
:= false; // don't stop
274 if (mon
.trapCheckFrameId
<> frameId
) then
276 mon
.trapCheckFrameId
:= frameId
;
277 chkTrap_mn
[mnaCount
] := mon
;
283 a
, b
, c
, d
, f
: Integer;
286 if (gWater
= nil) or (WaterMap
= nil) then Exit
;
288 frameId
:= g_Mons_getNewTrapFrameId();
293 //SetLength(chkTrap_pl, 1024);
294 //SetLength(chkTrap_mn, 1024);
295 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
296 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
298 for a
:= 0 to High(WaterMap
) do
300 for b
:= 0 to High(WaterMap
[a
]) do
302 pan
:= gWater
[WaterMap
[a
][b
]];
303 if not g_Obj_Collide(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, @Shots
[ID
].Obj
) then continue
;
305 for c
:= 0 to High(WaterMap
[a
]) do
307 pan
:= gWater
[WaterMap
[a
][c
]];
308 for d
:= 0 to High(gPlayers
) do
310 if (gPlayers
[d
] <> nil) and (gPlayers
[d
].Live
) then
312 if gPlayers
[d
].Collide(pan
) then
315 while (f
< plaCount
) and (chkTrap_pl
[f
] <> d
) do Inc(f
);
316 if (f
= plaCount
) then
318 chkTrap_pl
[plaCount
] := d
;
320 if (plaCount
= Length(chkTrap_pl
)) then break
;
326 //g_Mons_ForEach(monsWaterCheck);
327 g_Mons_ForEachAtAlive(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, monsWaterCheck
);
330 for f
:= 0 to plaCount
-1 do gPlayers
[chkTrap_pl
[f
]].Damage(dm
, Shots
[ID
].SpawnerUID
, 0, 0, t
);
331 for f
:= 0 to mnaCount
-1 do chkTrap_mn
[f
].Damage(dm
, 0, 0, Shots
[ID
].SpawnerUID
, t
);
339 function HitMonster(m
: TMonster
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
346 tt
:= g_GetUIDType(SpawnerUID
);
347 if tt
= UID_MONSTER
then
349 mon
:= g_Monsters_ByUID(SpawnerUID
);
351 mt
:= g_Monsters_ByUID(SpawnerUID
).MonsterType
358 if m
= nil then Exit
;
359 if m
.UID
= SpawnerUID
then
361 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
362 if (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
364 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
365 if (m
.MonsterType
= MONSTER_CYBER
) or
366 (m
.MonsterType
= MONSTER_BARREL
) then
373 if tt
= UID_MONSTER
then
375 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
376 if (mt
= MONSTER_SOUL
) and (m
.MonsterType
= MONSTER_PAIN
) then
379 // Îáà ìîíñòðà îäíîãî âèäà:
380 if mt
= m
.MonsterType
then
382 MONSTER_IMP
, MONSTER_DEMON
, MONSTER_BARON
, MONSTER_KNIGHT
, MONSTER_CACO
,
383 MONSTER_SOUL
, MONSTER_MANCUB
, MONSTER_SKEL
, MONSTER_FISH
:
384 Exit
; // Ýòè íå áüþò ñâîèõ
388 if g_Game_IsServer
then
390 if (t
<> HIT_FLAME
) or (m
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
391 Result
:= m
.Damage(d
, vx
, vy
, SpawnerUID
, t
)
394 if t
= HIT_FLAME
then
395 m
.CatchFire(SpawnerUID
);
401 function HitPlayer(p
: TPlayer
; d
: Integer; vx
, vy
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
405 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
406 if (p
.UID
= SpawnerUID
) and (t
<> HIT_ROCKET
) and (t
<> HIT_ELECTRO
) then
409 if g_Game_IsServer
then
411 if (t
<> HIT_FLAME
) or (p
.FFireTime
= 0) or (vx
<> 0) or (vy
<> 0) then
412 p
.Damage(d
, SpawnerUID
, vx
, vy
, t
);
413 if (t
= HIT_FLAME
) then
414 p
.CatchFire(SpawnerUID
);
420 function GunHit(X
, Y
: Integer; vx
, vy
: Integer; dmg
: Integer;
421 SpawnerUID
: Word; AllowPush
: Boolean): Byte;
423 {function monsCheck (monidx: Integer; mon: TMonster): Boolean;
425 result := false; // don't stop
426 if mon.Live and mon.Collide(X, Y) then
428 if HitMonster(mon, dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
430 if AllowPush then mon.Push(vx, vy);
436 function monsCheck (monidx
: Integer; mon
: TMonster
): Boolean;
438 result
:= false; // don't stop
439 if HitMonster(mon
, dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
441 if AllowPush
then mon
.Push(vx
, vy
);
455 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and gPlayers
[i
].Collide(X
, Y
) then
456 if HitPlayer(gPlayers
[i
], dmg
, vx
*10, vy
*10-3, SpawnerUID
, HIT_SOME
) then
458 if AllowPush
then gPlayers
[i
].Push(vx
, vy
);
462 if Result
<> 0 then Exit
;
464 //if g_Mons_ForEach(monsCheck) then result := 2;
465 if g_Mons_ForEachAtAlive(X
, Y
, 1, 1, monsCheck
) then result
:= 2;
468 procedure g_Weapon_BFG9000(X
, Y
: Integer; SpawnerUID
: Word);
470 function monsCheck (monidx
: Integer; mon
: TMonster
): Boolean;
472 result
:= false; // don't stop
473 if (mon
.Live
) and (mon
.UID
<> SpawnerUID
) then
477 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
478 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
479 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
480 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
482 if HitMonster(mon
, 50, 0, 0, SpawnerUID
, HIT_SOME
) then mon
.BFGHit();
494 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
498 if gAdvCorpses
and (h
<> -1) then
500 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
502 if (g_PatchLength(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
503 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
504 g_TraceVector(X
, Y
, Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
505 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)) then
508 g_Weapon_BFGHit(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
509 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2));
513 pl
:= g_Player_Get(SpawnerUID
);
521 if (gPlayers
[i
] <> nil) and (gPlayers
[i
].Live
) and (gPlayers
[i
].UID
<> SpawnerUID
) then
523 if (g_PatchLength(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
524 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) <= SHOT_BFG_RADIUS
) and
525 g_TraceVector(X
, Y
, GameX
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
526 GameY
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)) then
528 if (st
= TEAM_NONE
) or (st
<> gPlayers
[i
].Team
) then
529 b
:= HitPlayer(gPlayers
[i
], 50, 0, 0, SpawnerUID
, HIT_SOME
)
531 b
:= HitPlayer(gPlayers
[i
], 25, 0, 0, SpawnerUID
, HIT_SOME
);
533 gPlayers
[i
].BFGHit();
537 g_Mons_ForEach(monsCheck
);
540 function g_Weapon_CreateShot(I
: Integer; ShotType
: Byte; Spawner
, TargetUID
: Word; X
, Y
, XV
, YV
: Integer): LongWord;
542 find_id
, FramesID
: DWORD
;
545 find_id
:= FindShot()
549 if Integer(find_id
) >= High(Shots
) then
550 SetLength(Shots
, find_id
+ 64)
554 WEAPON_ROCKETLAUNCHER
:
556 with Shots
[find_id
] do
560 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
561 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
565 ShotType
:= WEAPON_ROCKETLAUNCHER
;
566 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
572 with Shots
[find_id
] do
576 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
577 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
580 ShotType
:= WEAPON_PLASMA
;
581 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
582 Animation
:= TAnimation
.Create(FramesID
, True, 5);
588 with Shots
[find_id
] do
592 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
593 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
596 ShotType
:= WEAPON_BFG
;
597 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
598 Animation
:= TAnimation
.Create(FramesID
, True, 6);
604 with Shots
[find_id
] do
608 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
609 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
612 ShotType
:= WEAPON_FLAMETHROWER
;
615 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
621 with Shots
[find_id
] do
625 Obj
.Rect
.Width
:= 16;
626 Obj
.Rect
.Height
:= 16;
629 ShotType
:= WEAPON_IMP_FIRE
;
630 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
631 Animation
:= TAnimation
.Create(FramesID
, True, 4);
637 with Shots
[find_id
] do
641 Obj
.Rect
.Width
:= 16;
642 Obj
.Rect
.Height
:= 16;
645 ShotType
:= WEAPON_CACO_FIRE
;
646 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
647 Animation
:= TAnimation
.Create(FramesID
, True, 4);
653 with Shots
[find_id
] do
657 Obj
.Rect
.Width
:= 32;
658 Obj
.Rect
.Height
:= 32;
661 ShotType
:= WEAPON_MANCUB_FIRE
;
662 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
663 Animation
:= TAnimation
.Create(FramesID
, True, 4);
669 with Shots
[find_id
] do
673 Obj
.Rect
.Width
:= 32;
674 Obj
.Rect
.Height
:= 16;
677 ShotType
:= WEAPON_BARON_FIRE
;
678 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
679 Animation
:= TAnimation
.Create(FramesID
, True, 4);
685 with Shots
[find_id
] do
689 Obj
.Rect
.Width
:= 16;
690 Obj
.Rect
.Height
:= 16;
693 ShotType
:= WEAPON_BSP_FIRE
;
694 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
695 Animation
:= TAnimation
.Create(FramesID
, True, 4);
701 with Shots
[find_id
] do
705 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
706 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
709 ShotType
:= WEAPON_SKEL_FIRE
;
711 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
712 Animation
:= TAnimation
.Create(FramesID
, True, 5);
717 Shots
[find_id
].Obj
.X
:= X
;
718 Shots
[find_id
].Obj
.Y
:= Y
;
719 Shots
[find_id
].Obj
.Vel
.X
:= XV
;
720 Shots
[find_id
].Obj
.Vel
.Y
:= YV
;
721 Shots
[find_id
].Obj
.Accel
.X
:= 0;
722 Shots
[find_id
].Obj
.Accel
.Y
:= 0;
723 Shots
[find_id
].SpawnerUID
:= Spawner
;
724 if (ShotType
= WEAPON_FLAMETHROWER
) and (XV
= 0) and (YV
= 0) then
725 Shots
[find_id
].Stopped
:= 255
727 Shots
[find_id
].Stopped
:= 0;
731 procedure throw(i
, x
, y
, xd
, yd
, s
: Integer);
738 a
:= Max(Abs(xd
), Abs(yd
));
744 Shots
[i
].Obj
.Vel
.X
:= (xd
*s
) div a
;
745 Shots
[i
].Obj
.Vel
.Y
:= (yd
*s
) div a
;
746 Shots
[i
].Obj
.Accel
.X
:= 0;
747 Shots
[i
].Obj
.Accel
.Y
:= 0;
748 Shots
[i
].Stopped
:= 0;
749 if Shots
[i
].ShotType
in [WEAPON_ROCKETLAUNCHER
, WEAPON_BFG
] then
750 Shots
[i
].Timeout
:= 900 // ~25 sec
753 if Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
then
754 Shots
[i
].Timeout
:= SHOT_FLAME_LIFETIME
756 Shots
[i
].Timeout
:= 550; // ~15 sec
760 function g_Weapon_Hit(obj
: PObj
; d
: Integer; SpawnerUID
: Word; t
: Byte; HitCorpses
: Boolean = True): Byte;
764 function PlayerHit(Team
: Byte = 0): Boolean;
775 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and g_Obj_Collide(obj
, @gPlayers
[i
].Obj
) then
778 if (Team
> 0) and (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
780 p
:= g_Player_Get(SpawnerUID
);
782 ChkTeam
:= (p
.Team
= gPlayers
[i
].Team
) xor (Team
= 2);
785 if HitPlayer(gPlayers
[i
], d
, obj
^.Vel
.X
, obj
^.Vel
.Y
, SpawnerUID
, t
) then
787 if t
<> HIT_FLAME
then
788 gPlayers
[i
].Push((obj
^.Vel
.X
+obj
^.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
789 (obj
^.Vel
.Y
+obj
^.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
791 g_Game_DelayEvent(DE_BFGHIT
, 1000, SpawnerUID
);
799 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
801 result := false; // don't stop
802 if mon.Live and g_Obj_Collide(obj, @mon.Obj) then
804 if HitMonster(mon, d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
806 if (t <> HIT_FLAME) then
808 mon.Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
809 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
817 function monsCheckHit (monidx
: Integer; mon
: TMonster
): Boolean;
819 result
:= false; // don't stop
820 if HitMonster(mon
, d
, obj
.Vel
.X
, obj
.Vel
.Y
, SpawnerUID
, t
) then
822 if (t
<> HIT_FLAME
) then
824 mon
.Push((obj
.Vel
.X
+obj
.Accel
.X
)*IfThen(t
= HIT_BFG
, 8, 1) div 4,
825 (obj
.Vel
.Y
+obj
.Accel
.Y
)*IfThen(t
= HIT_BFG
, 8, 1) div 4);
831 function MonsterHit(): Boolean;
833 //result := g_Mons_ForEach(monsCheckHit);
834 result
:= g_Mons_ForEachAtAlive(obj
.X
+obj
.Rect
.X
, obj
.Y
+obj
.Rect
.Y
, obj
.Rect
.Width
, obj
.Rect
.Height
, monsCheckHit
);
844 if gAdvCorpses
and (h
<> -1) then
846 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) and
847 g_Obj_Collide(obj
, @gCorpses
[i
].Obj
) then
850 gCorpses
[i
].Damage(d
, (obj
^.Vel
.X
+obj
^.Accel
.X
) div 4,
851 (obj
^.Vel
.Y
+obj
^.Accel
.Y
) div 4);
856 case gGameSettings
.GameMode
of
860 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
877 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
894 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
908 // È â êîíöå ñâîèõ èãðîêîâ
919 function g_Weapon_HitUID(UID
: Word; d
: Integer; SpawnerUID
: Word; t
: Byte): Boolean;
923 case g_GetUIDType(UID
) of
924 UID_PLAYER
: Result
:= HitPlayer(g_Player_Get(UID
), d
, 0, 0, SpawnerUID
, t
);
925 UID_MONSTER
: Result
:= HitMonster(g_Monsters_ByUID(UID
), d
, 0, 0, SpawnerUID
, t
);
930 function g_Weapon_Explode(X
, Y
: Integer; rad
: Integer; SpawnerUID
: Word): Boolean;
932 r
: Integer; // squared radius
934 function monsExCheck (monidx
: Integer; mon
: TMonster
): Boolean;
938 result
:= false; // don't stop
940 dx
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-X
;
941 dy
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-Y
;
943 if dx
> 1000 then dx
:= 1000;
944 if dy
> 1000 then dy
:= 1000;
946 if (dx
*dx
+dy
*dy
< r
) then
948 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
949 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
951 mm
:= Max(abs(dx
), abs(dy
));
952 if mm
= 0 then mm
:= 1;
956 HitMonster(mon
, ((mon
.Obj
.Rect
.Width
div 4)*10*(rad
-mm
)) div rad
, 0, 0, SpawnerUID
, HIT_ROCKET
);
959 mon
.Push((dx
*7) div mm
, (dy
*7) div mm
);
965 i
, h
, dx
, dy
, m
, mm
: Integer;
970 g_Triggers_PressC(X
, Y
, rad
, SpawnerUID
, ACTIVATE_SHOT
);
978 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
981 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
982 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
984 if dx
> 1000 then dx
:= 1000;
985 if dy
> 1000 then dy
:= 1000;
987 if dx
*dx
+dy
*dy
< r
then
989 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
990 // PLAYER_RECT.Width, PLAYER_RECT.Height);
992 mm
:= Max(abs(dx
), abs(dy
));
993 if mm
= 0 then mm
:= 1;
995 HitPlayer(gPlayers
[i
], (100*(rad
-mm
)) div rad
, (dx
*10) div mm
, (dy
*10) div mm
, SpawnerUID
, HIT_ROCKET
);
996 gPlayers
[i
].Push((dx
*7) div mm
, (dy
*7) div mm
);
1000 //g_Mons_ForEach(monsExCheck);
1001 g_Mons_ForEachAt(X
-(rad
+32), Y
-(rad
+32), (rad
+32)*2, (rad
+32)*2, monsExCheck
);
1003 h
:= High(gCorpses
);
1005 if gAdvCorpses
and (h
<> -1) then
1007 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].State
<> CORPSE_STATE_REMOVEME
) then
1010 dx
:= Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)-X
;
1011 dy
:= Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2)-Y
;
1013 if dx
> 1000 then dx
:= 1000;
1014 if dy
> 1000 then dy
:= 1000;
1016 if dx
*dx
+dy
*dy
< r
then
1018 m
:= PointToRect(X
, Y
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1019 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1021 mm
:= Max(abs(dx
), abs(dy
));
1022 if mm
= 0 then mm
:= 1;
1024 Damage(Round(100*(rad
-m
)/rad
), (dx
*10) div mm
, (dy
*10) div mm
);
1030 if gAdvGibs
and (h
<> -1) then
1032 if gGibs
[i
].Live
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
, Obj
.X
+Obj
.Rect
.X
, Obj
.Y
+Obj
.Rect
.Y
,
1044 Obj
.Rect
.Width
, Obj
.Rect
.Height
);
1045 _angle
:= GetAngle(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2),
1046 Obj
.Y
+Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2), X
, Y
);
1048 g_Obj_PushA(@Obj
, Round(15*(rad
-m
)/rad
), _angle
);
1049 positionChanged(); // this updates spatial accelerators
1054 procedure g_Weapon_Init();
1059 procedure g_Weapon_Free();
1063 if Shots
<> nil then
1065 for i
:= 0 to High(Shots
) do
1066 if Shots
[i
].ShotType
<> 0 then
1067 Shots
[i
].Animation
.Free();
1075 procedure g_Weapon_LoadData();
1077 e_WriteLog('Loading weapons data...', MSG_NOTIFY
);
1079 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD
+':SOUNDS\HITPUNCH');
1080 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD
+':SOUNDS\MISSPUNCH');
1081 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD
+':SOUNDS\HITBERSERK');
1082 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD
+':SOUNDS\MISSBERSERK');
1083 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD
+':SOUNDS\SELECTSAW');
1084 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD
+':SOUNDS\IDLESAW');
1085 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD
+':SOUNDS\HITSAW');
1086 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD
+':SOUNDS\FIRESHOTGUN2');
1087 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD
+':SOUNDS\FIRESHOTGUN');
1088 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD
+':SOUNDS\FIRESAW');
1089 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD
+':SOUNDS\FIREROCKET');
1090 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD
+':SOUNDS\FIREPLASMA');
1091 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD
+':SOUNDS\FIREPISTOL');
1092 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD
+':SOUNDS\FIRECGUN');
1093 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD
+':SOUNDS\FIREBFG');
1094 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD
+':SOUNDS\FIRE');
1095 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD
+':SOUNDS\STARTFIREBFG');
1096 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD
+':SOUNDS\EXPLODEROCKET');
1097 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD
+':SOUNDS\EXPLODEBFG');
1098 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD
+':SOUNDS\BFGWATER');
1099 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD
+':SOUNDS\EXPLODEPLASMA');
1100 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD
+':SOUNDS\PLASMAWATER');
1101 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD
+':SOUNDS\FIREBALL');
1102 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD
+':SOUNDS\EXPLODEBALL');
1103 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD
+':SOUNDS\FIREREV');
1104 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD
+':SOUNDS\WORKJETPACK');
1105 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD
+':SOUNDS\STARTJETPACK');
1106 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD
+':SOUNDS\STOPJETPACK');
1107 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD
+':SOUNDS\CASING1');
1108 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD
+':SOUNDS\CASING2');
1109 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD
+':SOUNDS\SHELL1');
1110 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD
+':SOUNDS\SHELL2');
1112 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD
+':TEXTURES\BROCKET');
1113 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD
+':TEXTURES\BSKELFIRE', 64, 16, 2);
1114 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD
+':TEXTURES\BBFG', 64, 64, 2);
1115 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD
+':TEXTURES\BPLASMA', 16, 16, 2);
1116 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD
+':TEXTURES\BIMPFIRE', 16, 16, 2);
1117 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD
+':TEXTURES\BBSPFIRE', 16, 16, 2);
1118 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD
+':TEXTURES\BCACOFIRE', 16, 16, 2);
1119 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD
+':TEXTURES\BBARONFIRE', 64, 16, 2);
1120 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD
+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1121 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD
+':TEXTURES\EROCKET', 128, 128, 6);
1122 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD
+':TEXTURES\ESKELFIRE', 64, 64, 3);
1123 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD
+':TEXTURES\EBFG', 128, 128, 6);
1124 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD
+':TEXTURES\EIMPFIRE', 64, 64, 3);
1125 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD
+':TEXTURES\BFGHIT', 64, 64, 4);
1126 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD
+':TEXTURES\FIRE', 64, 128, 8);
1127 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD
+':TEXTURES\FLAME', 32, 32, 11);
1128 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD
+':TEXTURES\EPLASMA', 32, 32, 4, True);
1129 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD
+':TEXTURES\EBSPFIRE', 32, 32, 5);
1130 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD
+':TEXTURES\ECACOFIRE', 64, 64, 3);
1131 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD
+':TEXTURES\EBARONFIRE', 64, 64, 3);
1132 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD
+':TEXTURES\SMOKE', 32, 32, 10, False);
1134 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD
+':TEXTURES\EBULLET');
1135 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD
+':TEXTURES\ESHELL');
1138 procedure g_Weapon_FreeData();
1140 e_WriteLog('Releasing weapons data...', MSG_NOTIFY
);
1142 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1143 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1144 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1145 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1146 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1147 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1148 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1149 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1150 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1151 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1152 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1153 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1154 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1155 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1156 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1157 g_Sound_Delete('SOUND_FIRE');
1158 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1159 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1160 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1161 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1162 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1163 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1164 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1165 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1166 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1167 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1168 g_Sound_Delete('SOUND_PLAYER_JETON');
1169 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1170 g_Sound_Delete('SOUND_PLAYER_CASING1');
1171 g_Sound_Delete('SOUND_PLAYER_CASING2');
1172 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1173 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1175 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1176 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1177 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1178 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1179 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1180 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1181 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1182 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1183 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1184 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1185 g_Frames_DeleteByName('FRAMES_BFGHIT');
1186 g_Frames_DeleteByName('FRAMES_FIRE');
1187 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1188 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1189 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1190 g_Frames_DeleteByName('FRAMES_SMOKE');
1191 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1192 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1195 procedure g_Weapon_gun(x
, y
, xd
, yd
, v
, dmg
: Integer; SpawnerUID
: Word; CheckTrigger
: Boolean);
1207 t1
, _collide
: Boolean;
1210 a
:= GetAngle(x
, y
, xd
, yd
)+180;
1212 SinCos(DegToRad(-a
), s
, c
);
1214 if Abs(s
) < 0.01 then s
:= 0;
1215 if Abs(c
) < 0.01 then c
:= 0;
1217 x2
:= x
+Round(c
*gMapInfo
.Width
);
1218 y2
:= y
+Round(s
*gMapInfo
.Width
);
1220 t1
:= gWalls
<> nil;
1222 w
:= gMapInfo
.Width
;
1223 h
:= gMapInfo
.Height
;
1230 if (xd
= 0) and (yd
= 0) then Exit
;
1232 if dx
> 0 then xi
:= 1 else if dx
< 0 then xi
:= -1 else xi
:= 0;
1233 if dy
> 0 then yi
:= 1 else if dy
< 0 then yi
:= -1 else yi
:= 0;
1238 if dx
> dy
then d
:= dx
else d
:= dy
;
1240 //blood vel, for Monster.Damage()
1241 //vx := (dx*10 div d)*xi;
1242 //vy := (dy*10 div d)*yi;
1264 if (yy
> h
) or (yy
< 0) then Break
;
1265 if (xx
> w
) or (xx
< 0) then Break
;
1268 if ByteBool(gCollideMap
[yy
, xx
] and MARK_BLOCKED
) then
1271 g_GFX_Spark(xx
-xi
, yy
-yi
, 2+Random(2), 180+a
, 0, 0);
1272 if g_Game_IsServer
and g_Game_IsNet
then
1273 MH_SEND_Effect(xx
-xi
, yy
-yi
, 180+a
, NET_GFX_SPARK
);
1276 if not _collide
then
1277 _collide
:= GunHit(xx
, yy
, xi
*v
, yi
*v
, dmg
, SpawnerUID
, v
<> 0) <> 0;
1283 if CheckTrigger
and g_Game_IsServer
then
1284 g_Triggers_PressL(X
, Y
, xx
-xi
, yy
-yi
, SpawnerUID
, ACTIVATE_SHOT
);
1287 procedure g_Weapon_punch(x
, y
: Integer; d
, SpawnerUID
: Word);
1295 obj
.rect
.Width
:= 39;
1296 obj
.rect
.Height
:= 52;
1302 if g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
) <> 0 then
1303 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x
, y
)
1305 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x
, y
);
1308 function g_Weapon_chainsaw(x
, y
: Integer; d
, SpawnerUID
: Word): Integer;
1316 obj
.rect
.Width
:= 32;
1317 obj
.rect
.Height
:= 52;
1323 Result
:= g_Weapon_Hit(@obj
, d
, SpawnerUID
, HIT_SOME
);
1326 procedure g_Weapon_rocket(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1327 Silent
: Boolean = False);
1333 find_id
:= FindShot()
1337 if Integer(find_id
) >= High(Shots
) then
1338 SetLength(Shots
, find_id
+ 64)
1341 with Shots
[find_id
] do
1345 Obj
.Rect
.Width
:= SHOT_ROCKETLAUNCHER_WIDTH
;
1346 Obj
.Rect
.Height
:= SHOT_ROCKETLAUNCHER_HEIGHT
;
1348 dx
:= IfThen(xd
> x
, -Obj
.Rect
.Width
, 0);
1349 dy
:= -(Obj
.Rect
.Height
div 2);
1351 ShotType
:= WEAPON_ROCKETLAUNCHER
;
1352 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1356 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID
);
1359 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1362 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x
, y
);
1365 procedure g_Weapon_revf(x
, y
, xd
, yd
: Integer; SpawnerUID
, TargetUID
: Word;
1366 WID
: Integer = -1; Silent
: Boolean = False);
1368 find_id
, FramesID
: DWORD
;
1372 find_id
:= FindShot()
1376 if Integer(find_id
) >= High(Shots
) then
1377 SetLength(Shots
, find_id
+ 64)
1380 with Shots
[find_id
] do
1384 Obj
.Rect
.Width
:= SHOT_SKELFIRE_WIDTH
;
1385 Obj
.Rect
.Height
:= SHOT_SKELFIRE_HEIGHT
;
1387 dx
:= -(Obj
.Rect
.Width
div 2);
1388 dy
:= -(Obj
.Rect
.Height
div 2);
1390 ShotType
:= WEAPON_SKEL_FIRE
;
1391 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 12);
1394 target
:= TargetUID
;
1395 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_SKELFIRE');
1396 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1399 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1402 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x
, y
);
1405 procedure g_Weapon_plasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1406 Silent
: Boolean = False);
1408 find_id
, FramesID
: DWORD
;
1412 find_id
:= FindShot()
1416 if Integer(find_id
) >= High(Shots
) then
1417 SetLength(Shots
, find_id
+ 64);
1420 with Shots
[find_id
] do
1424 Obj
.Rect
.Width
:= SHOT_PLASMA_WIDTH
;
1425 Obj
.Rect
.Height
:= SHOT_PLASMA_HEIGHT
;
1427 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1428 dy
:= -(Obj
.Rect
.Height
div 2);
1430 ShotType
:= WEAPON_PLASMA
;
1431 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1434 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_PLASMA');
1435 Animation
:= TAnimation
.Create(FramesID
, True, 5);
1438 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1441 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1444 procedure g_Weapon_flame(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1445 Silent
: Boolean = False);
1451 find_id
:= FindShot()
1455 if Integer(find_id
) >= High(Shots
) then
1456 SetLength(Shots
, find_id
+ 64);
1459 with Shots
[find_id
] do
1463 Obj
.Rect
.Width
:= SHOT_FLAME_WIDTH
;
1464 Obj
.Rect
.Height
:= SHOT_FLAME_HEIGHT
;
1466 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1467 dy
:= -(Obj
.Rect
.Height
div 2);
1469 ShotType
:= WEAPON_FLAMETHROWER
;
1470 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1475 g_Frames_Get(TextureID
, 'FRAMES_FLAME');
1478 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1480 // if not Silent then
1481 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1484 procedure g_Weapon_ball1(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1485 Silent
: Boolean = False);
1487 find_id
, FramesID
: DWORD
;
1491 find_id
:= FindShot()
1495 if Integer(find_id
) >= High(Shots
) then
1496 SetLength(Shots
, find_id
+ 64)
1499 with Shots
[find_id
] do
1503 Obj
.Rect
.Width
:= 16;
1504 Obj
.Rect
.Height
:= 16;
1506 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1507 dy
:= -(Obj
.Rect
.Height
div 2);
1509 ShotType
:= WEAPON_IMP_FIRE
;
1510 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1513 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_IMPFIRE');
1514 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1517 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1520 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1523 procedure g_Weapon_ball2(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1524 Silent
: Boolean = False);
1526 find_id
, FramesID
: DWORD
;
1530 find_id
:= FindShot()
1534 if Integer(find_id
) >= High(Shots
) then
1535 SetLength(Shots
, find_id
+ 64)
1538 with Shots
[find_id
] do
1542 Obj
.Rect
.Width
:= 16;
1543 Obj
.Rect
.Height
:= 16;
1545 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1546 dy
:= -(Obj
.Rect
.Height
div 2);
1548 ShotType
:= WEAPON_CACO_FIRE
;
1549 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1552 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_CACOFIRE');
1553 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1556 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1559 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1562 procedure g_Weapon_ball7(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1563 Silent
: Boolean = False);
1565 find_id
, FramesID
: DWORD
;
1569 find_id
:= FindShot()
1573 if Integer(find_id
) >= High(Shots
) then
1574 SetLength(Shots
, find_id
+ 64)
1577 with Shots
[find_id
] do
1581 Obj
.Rect
.Width
:= 32;
1582 Obj
.Rect
.Height
:= 16;
1584 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1585 dy
:= -(Obj
.Rect
.Height
div 2);
1587 ShotType
:= WEAPON_BARON_FIRE
;
1588 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1591 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BARONFIRE');
1592 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1595 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1598 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1601 procedure g_Weapon_aplasma(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1602 Silent
: Boolean = False);
1604 find_id
, FramesID
: DWORD
;
1608 find_id
:= FindShot()
1612 if Integer(find_id
) >= High(Shots
) then
1613 SetLength(Shots
, find_id
+ 64)
1616 with Shots
[find_id
] do
1620 Obj
.Rect
.Width
:= 16;
1621 Obj
.Rect
.Height
:= 16;
1623 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1624 dy
:= -(Obj
.Rect
.Height
div 2);
1626 ShotType
:= WEAPON_BSP_FIRE
;
1627 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1631 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BSPFIRE');
1632 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1635 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1638 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x
, y
);
1641 procedure g_Weapon_manfire(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1642 Silent
: Boolean = False);
1644 find_id
, FramesID
: DWORD
;
1648 find_id
:= FindShot()
1652 if Integer(find_id
) >= High(Shots
) then
1653 SetLength(Shots
, find_id
+ 64)
1656 with Shots
[find_id
] do
1660 Obj
.Rect
.Width
:= 32;
1661 Obj
.Rect
.Height
:= 32;
1663 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1664 dy
:= -(Obj
.Rect
.Height
div 2);
1666 ShotType
:= WEAPON_MANCUB_FIRE
;
1667 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1671 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_MANCUBFIRE');
1672 Animation
:= TAnimation
.Create(FramesID
, True, 4);
1675 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1678 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x
, y
);
1681 procedure g_Weapon_bfgshot(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word; WID
: Integer = -1;
1682 Silent
: Boolean = False);
1684 find_id
, FramesID
: DWORD
;
1688 find_id
:= FindShot()
1692 if Integer(find_id
) >= High(Shots
) then
1693 SetLength(Shots
, find_id
+ 64)
1696 with Shots
[find_id
] do
1700 Obj
.Rect
.Width
:= SHOT_BFG_WIDTH
;
1701 Obj
.Rect
.Height
:= SHOT_BFG_HEIGHT
;
1703 dx
:= IfThen(xd
>x
, -Obj
.Rect
.Width
, 0);
1704 dy
:= -(Obj
.Rect
.Height
div 2);
1706 ShotType
:= WEAPON_BFG
;
1707 throw(find_id
, x
+dx
, y
+dy
, xd
+dx
, yd
+dy
, 16);
1710 g_Frames_Get(FramesID
, 'FRAMES_WEAPON_BFG');
1711 Animation
:= TAnimation
.Create(FramesID
, True, 6);
1714 Shots
[find_id
].SpawnerUID
:= SpawnerUID
;
1717 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x
, y
);
1720 procedure g_Weapon_bfghit(x
, y
: Integer);
1725 if g_Frames_Get(ID
, 'FRAMES_BFGHIT') then
1727 Anim
:= TAnimation
.Create(ID
, False, 4);
1728 g_GFX_OnceAnim(x
-32, y
-32, Anim
);
1733 procedure g_Weapon_pistol(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1734 Silent
: Boolean = False);
1737 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x
, y
);
1739 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1740 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
1742 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 3, SpawnerUID
, False);
1743 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1747 procedure g_Weapon_mgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1748 Silent
: Boolean = False);
1751 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x
, y
);
1753 g_Weapon_gun(x
, y
, xd
, yd
, 1, 3, SpawnerUID
, True);
1754 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
1755 (g_GetUIDType(SpawnerUID
) = UID_PLAYER
) then
1757 g_Weapon_gun(x
, y
+1, xd
, yd
+1, 1, 2, SpawnerUID
, False);
1758 g_Weapon_gun(x
, y
-1, xd
, yd
-1, 1, 2, SpawnerUID
, False);
1762 procedure g_Weapon_shotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1763 Silent
: Boolean = False);
1768 if gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x
, y
);
1772 j
:= Random(17)-8; // -8 .. 8
1773 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 2 <> 0, 1, 0), 3, SpawnerUID
, i
=0);
1777 procedure g_Weapon_dshotgun(x
, y
, xd
, yd
: Integer; SpawnerUID
: Word;
1778 Silent
: Boolean = False);
1783 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x
, y
);
1785 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then a
:= 25 else a
:= 20;
1788 j
:= Random(41)-20; // -20 .. 20
1789 g_Weapon_gun(x
, y
+j
, xd
, yd
+j
, IfThen(i
mod 3 <> 0, 0, 1), 3, SpawnerUID
, i
=0);
1793 procedure g_Weapon_Update();
1795 i
, a
, h
, cx
, cy
, oldvx
, oldvy
, tf
: Integer;
1809 for i
:= 0 to High(Shots
) do
1811 if Shots
[i
].ShotType
= 0 then
1818 Timeout
:= Timeout
- 1;
1821 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1822 if (Stopped
= 0) and g_Game_IsServer
then
1823 t
:= g_Triggers_PressR(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
1824 SpawnerUID
, ACTIVATE_SHOT
, triggers
)
1830 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1831 if triggers
= nil then
1838 if not InDWArray(t
[a
], triggers
) then
1840 SetLength(triggers
, Length(triggers
)+1);
1841 triggers
[High(triggers
)] := t
[a
];
1846 // Àíèìàöèÿ ñíàðÿäà:
1847 if Animation
<> nil then
1851 spl
:= (ShotType
<> WEAPON_PLASMA
) and
1852 (ShotType
<> WEAPON_BFG
) and
1853 (ShotType
<> WEAPON_BSP_FIRE
) and
1854 (ShotType
<> WEAPON_FLAMETHROWER
);
1858 st
:= g_Obj_Move(@Obj
, False, spl
);
1864 positionChanged(); // this updates spatial accelerators
1866 if WordBool(st
and MOVE_FALLOUT
) or (Obj
.X
< -1000) or
1867 (Obj
.X
> gMapInfo
.Width
+1000) or (Obj
.Y
< -1000) then
1869 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1875 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
1876 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
1879 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1881 // Âûëåòåëà èç âîäû:
1882 if WordBool(st
and MOVE_HITAIR
) then
1883 g_Obj_SetSpeed(@Obj
, 12);
1885 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1886 if WordBool(st
and MOVE_INWATER
) then
1887 g_GFX_Bubbles(Obj
.X
+(Obj
.Rect
.Width
div 2),
1888 Obj
.Y
+(Obj
.Rect
.Height
div 2),
1889 1+Random(3), 16, 16)
1891 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
1893 Anim
:= TAnimation
.Create(_id
, False, 3);
1895 g_GFX_OnceAnim(Obj
.X
-14+Random(9),
1896 Obj
.Y
+(Obj
.Rect
.Height
div 2)-20+Random(9),
1897 Anim
, ONCEANIM_SMOKE
);
1901 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1902 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1903 (g_Weapon_Hit(@Obj
, 10, SpawnerUID
, HIT_SOME
, False) <> 0) or
1909 g_Weapon_Explode(cx
, cy
, 60, SpawnerUID
);
1911 if ShotType
= WEAPON_SKEL_FIRE
then
1912 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1913 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
1915 Anim
:= TAnimation
.Create(TextureID
, False, 8);
1916 Anim
.Blending
:= False;
1917 g_GFX_OnceAnim((Obj
.X
+32)-58, (Obj
.Y
+8)-36, Anim
);
1918 g_DynLightExplosion((Obj
.X
+32), (Obj
.Y
+8), 64, 1, 0, 0);
1923 begin // Âçðûâ Ðàêåòû
1924 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
1926 Anim
:= TAnimation
.Create(TextureID
, False, 6);
1927 Anim
.Blending
:= False;
1928 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
1929 g_DynLightExplosion(cx
, cy
, 64, 1, 0, 0);
1934 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
1939 if ShotType
= WEAPON_SKEL_FIRE
then
1940 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1941 if GetPos(target
, @o
) then
1942 throw(i
, Obj
.X
, Obj
.Y
,
1943 o
.X
+o
.Rect
.X
+(o
.Rect
.Width
div 2)+o
.Vel
.X
+o
.Accel
.X
,
1944 o
.Y
+o
.Rect
.Y
+(o
.Rect
.Height
div 2)+o
.Vel
.Y
+o
.Accel
.Y
,
1949 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1951 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1952 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
1954 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj
.X
, Obj
.Y
);
1955 if g_Game_IsServer
then CheckTrap(i
, 10, HIT_ELECTRO
);
1961 if (ShotType
= WEAPON_PLASMA
) and
1962 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1967 if ShotType
= WEAPON_BSP_FIRE
then
1970 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1971 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
1972 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
, False) <> 0) or
1975 if ShotType
= WEAPON_PLASMA
then
1976 s
:= 'FRAMES_EXPLODE_PLASMA'
1978 s
:= 'FRAMES_EXPLODE_BSPFIRE';
1981 if g_Frames_Get(TextureID
, s
) then
1983 Anim
:= TAnimation
.Create(TextureID
, False, 3);
1984 Anim
.Blending
:= False;
1985 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
1987 g_DynLightExplosion(cx
, cy
, 32, 0, 0.5, 0.5);
1990 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
1996 WEAPON_FLAMETHROWER
: // Îãíåìåò
1998 // Ñî âðåìåíåì óìèðàåò
1999 if (Timeout
< 1) then
2005 if WordBool(st
and (MOVE_HITWATER
or MOVE_INWATER
)) then
2007 if WordBool(st
and MOVE_HITWATER
) then
2009 if g_Frames_Get(_id
, 'FRAMES_SMOKE') then
2011 Anim
:= TAnimation
.Create(_id
, False, 3);
2015 g_GFX_OnceAnim(cx
-4+tcx
-(Anim
.Width
div 2),
2016 cy
-4+tcy
-(Anim
.Height
div 2),
2017 Anim
, ONCEANIM_SMOKE
);
2022 g_GFX_Bubbles(cx
, cy
, 1+Random(3), 16, 16);
2029 Obj
.Accel
.Y
:= Obj
.Accel
.Y
+ 1;
2030 // Ïîïàëè â ñòåíó èëè â âîäó:
2031 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
or MOVE_HITWATER
)) then
2037 if WordBool(st
and MOVE_HITWALL
) then
2038 Stopped
:= MOVE_HITWALL
2039 else if WordBool(st
and MOVE_HITLAND
) then
2040 Stopped
:= MOVE_HITLAND
2041 else if WordBool(st
and MOVE_HITCEIL
) then
2042 Stopped
:= MOVE_HITCEIL
;
2045 a
:= IfThen(Stopped
= 0, 3, 1);
2046 // Åñëè â êîãî-òî ïîïàëè
2047 if g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_FLAME
, False) <> 0 then
2049 // HIT_FLAME ñàì ïîäîææåò
2050 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2060 if (gTime
mod tf
= 0) then
2062 Anim
:= TAnimation
.Create(TextureID
, False, 2 + Random(2));
2065 MOVE_HITWALL
: begin tcx
:= cx
-4+Random(8); tcy
:= cy
-12+Random(24); end;
2066 MOVE_HITLAND
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
-10+Random(8); end;
2067 MOVE_HITCEIL
: begin tcx
:= cx
-12+Random(24); tcy
:= cy
+6+Random(8); end;
2068 else begin tcx
:= cx
-4+Random(8); tcy
:= cy
-4+Random(8); end;
2070 g_GFX_OnceAnim(tcx
-(Anim
.Width
div 2), tcy
-(Anim
.Height
div 2), Anim
, ONCEANIM_SMOKE
);
2072 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2078 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2079 if WordBool(st
and (MOVE_INWATER
or MOVE_HITWATER
)) then
2081 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj
.X
, Obj
.Y
);
2082 if g_Game_IsServer
then CheckTrap(i
, 1000, HIT_ELECTRO
);
2087 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2088 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2089 (g_Weapon_Hit(@Obj
, SHOT_BFG_DAMAGE
, SpawnerUID
, HIT_BFG
, False) <> 0) or
2093 if g_Game_IsServer
then g_Weapon_BFG9000(cx
, cy
, SpawnerUID
);
2096 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
2098 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2099 Anim
.Blending
:= False;
2100 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2102 g_DynLightExplosion(cx
, cy
, 96, 0, 1, 0);
2105 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2111 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2114 if WordBool(st
and MOVE_HITAIR
) then
2115 g_Obj_SetSpeed(@Obj
, 16);
2118 if ShotType
= WEAPON_IMP_FIRE
then
2121 if ShotType
= WEAPON_CACO_FIRE
then
2126 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2127 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2128 (g_Weapon_Hit(@Obj
, a
, SpawnerUID
, HIT_SOME
) <> 0) or
2131 if ShotType
= WEAPON_IMP_FIRE
then
2132 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2134 if ShotType
= WEAPON_CACO_FIRE
then
2135 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2137 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2140 if g_Frames_Get(TextureID
, s
) then
2142 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2143 Anim
.Blending
:= False;
2144 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2148 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2154 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2157 if WordBool(st
and MOVE_HITAIR
) then
2158 g_Obj_SetSpeed(@Obj
, 16);
2160 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2161 if WordBool(st
and (MOVE_HITWALL
or MOVE_HITLAND
or MOVE_HITCEIL
)) or
2162 (g_Weapon_Hit(@Obj
, 40, SpawnerUID
, HIT_SOME
, False) <> 0) or
2166 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2168 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2169 Anim
.Blending
:= False;
2170 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2174 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2179 end; // case ShotType of...
2181 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2182 if (ShotType
= 0) then
2184 if gGameSettings
.GameType
= GT_SERVER
then
2185 MH_SEND_DeleteShot(i
, Obj
.X
, Obj
.Y
, Loud
);
2186 if Animation
<> nil then
2192 else if (ShotType
<> WEAPON_FLAMETHROWER
) and ((oldvx
<> Obj
.Vel
.X
) or (oldvy
<> Obj
.Vel
.Y
)) then
2193 if gGameSettings
.GameType
= GT_SERVER
then
2194 MH_SEND_UpdateShot(i
);
2199 procedure g_Weapon_Draw();
2208 for i
:= 0 to High(Shots
) do
2209 if Shots
[i
].ShotType
<> 0 then
2212 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2213 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2214 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2215 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2216 a
:= -GetAngle2(Obj
.Vel
.X
, Obj
.Vel
.Y
)
2220 p
.X
:= Obj
.Rect
.Width
div 2;
2221 p
.Y
:= Obj
.Rect
.Height
div 2;
2223 if Animation
<> nil then
2225 if (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2226 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2227 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) then
2228 Animation
.DrawEx(Obj
.X
, Obj
.Y
, M_NONE
, p
, a
)
2230 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
2232 else if TextureID
<> 0 then
2234 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) then
2235 e_DrawAdv(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False, a
, @p
, M_NONE
)
2236 else if (Shots
[i
].ShotType
<> WEAPON_FLAMETHROWER
) then
2237 e_Draw(TextureID
, Obj
.X
, Obj
.Y
, 0, True, False);
2240 if g_debug_Frames
then
2242 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
2244 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
2245 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
2251 function g_Weapon_Danger(UID
: Word; X
, Y
: Integer; Width
, Height
: Word; Time
: Byte): Boolean;
2260 for a
:= 0 to High(Shots
) do
2261 if (Shots
[a
].ShotType
<> 0) and (Shots
[a
].SpawnerUID
<> UID
) then
2262 if ((Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
> 0) and (Shots
[a
].Obj
.X
< X
)) or
2263 (Shots
[a
].Obj
.Vel
.Y
= 0) and (Shots
[a
].Obj
.Vel
.X
< 0) and (Shots
[a
].Obj
.X
> X
) then
2264 if (Abs(X
-Shots
[a
].Obj
.X
) < Abs(Shots
[a
].Obj
.Vel
.X
*Time
)) and
2265 g_Collide(X
, Y
, Width
, Height
, X
, Shots
[a
].Obj
.Y
,
2266 Shots
[a
].Obj
.Rect
.Width
, Shots
[a
].Obj
.Rect
.Height
) and
2267 g_TraceVector(X
, Y
, Shots
[a
].Obj
.X
, Shots
[a
].Obj
.Y
) then
2274 procedure g_Weapon_SaveState(var Mem
: TBinMemoryWriter
);
2276 count
, i
, j
: Integer;
2279 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2281 if Shots
<> nil then
2282 for i
:= 0 to High(Shots
) do
2283 if Shots
[i
].ShotType
<> 0 then
2286 Mem
:= TBinMemoryWriter
.Create((count
+1) * 80);
2288 // Êîëè÷åñòâî ñíàðÿäîâ:
2289 Mem
.WriteInt(count
);
2294 for i
:= 0 to High(Shots
) do
2295 if Shots
[i
].ShotType
<> 0 then
2297 // Ñèãíàòóðà ñíàðÿäà:
2298 dw
:= SHOT_SIGNATURE
; // 'SHOT'
2301 Mem
.WriteByte(Shots
[i
].ShotType
);
2303 Mem
.WriteWord(Shots
[i
].Target
);
2305 Mem
.WriteWord(Shots
[i
].SpawnerUID
);
2306 // Ðàçìåð ïîëÿ Triggers:
2307 dw
:= Length(Shots
[i
].Triggers
);
2309 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2310 for j
:= 0 to Integer(dw
)-1 do
2311 Mem
.WriteDWORD(Shots
[i
].Triggers
[j
]);
2313 Obj_SaveState(@Shots
[i
].Obj
, Mem
);
2314 // Êîñòûëèíà åáàíàÿ:
2315 Mem
.WriteByte(Shots
[i
].Stopped
);
2319 procedure g_Weapon_LoadState(var Mem
: TBinMemoryReader
);
2321 count
, i
, j
: Integer;
2327 // Êîëè÷åñòâî ñíàðÿäîâ:
2330 SetLength(Shots
, count
);
2335 for i
:= 0 to count
-1 do
2337 // Ñèãíàòóðà ñíàðÿäà:
2339 if dw
<> SHOT_SIGNATURE
then // 'SHOT'
2341 raise EBinSizeError
.Create('g_Weapons_LoadState: Wrong Shot Signature');
2344 Mem
.ReadByte(Shots
[i
].ShotType
);
2346 Mem
.ReadWord(Shots
[i
].Target
);
2348 Mem
.ReadWord(Shots
[i
].SpawnerUID
);
2349 // Ðàçìåð ïîëÿ Triggers:
2351 SetLength(Shots
[i
].Triggers
, dw
);
2352 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2353 for j
:= 0 to Integer(dw
)-1 do
2354 Mem
.ReadDWORD(Shots
[i
].Triggers
[j
]);
2356 Obj_LoadState(@Shots
[i
].Obj
, Mem
);
2357 // Êîñòûëèíà åáàíàÿ:
2358 Mem
.ReadByte(Shots
[i
].Stopped
);
2360 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2361 Shots
[i
].TextureID
:= DWORD(-1);
2362 Shots
[i
].Animation
:= nil;
2364 case Shots
[i
].ShotType
of
2365 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
:
2367 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots
[i
].TextureID
);
2371 g_Frames_Get(dw
, 'FRAMES_WEAPON_PLASMA');
2372 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 5);
2376 g_Frames_Get(dw
, 'FRAMES_WEAPON_BFG');
2377 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 6);
2381 g_Frames_Get(dw
, 'FRAMES_WEAPON_IMPFIRE');
2382 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2386 g_Frames_Get(dw
, 'FRAMES_WEAPON_BSPFIRE');
2387 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2391 g_Frames_Get(dw
, 'FRAMES_WEAPON_CACOFIRE');
2392 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2396 g_Frames_Get(dw
, 'FRAMES_WEAPON_BARONFIRE');
2397 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2401 g_Frames_Get(dw
, 'FRAMES_WEAPON_MANCUBFIRE');
2402 Shots
[i
].Animation
:= TAnimation
.Create(dw
, True, 4);
2408 procedure g_Weapon_DestroyShot(I
: Integer; X
, Y
: Integer; Loud
: Boolean = True);
2416 if (I
> High(Shots
)) or (I
< 0) then Exit
;
2420 if ShotType
= 0 then Exit
;
2423 cx
:= Obj
.X
+ (Obj
.Rect
.Width
div 2);
2424 cy
:= Obj
.Y
+ (Obj
.Rect
.Height
div 2);
2427 WEAPON_ROCKETLAUNCHER
, WEAPON_SKEL_FIRE
: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2431 if ShotType
= WEAPON_SKEL_FIRE
then
2432 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2433 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_SKELFIRE') then
2435 Anim
:= TAnimation
.Create(TextureID
, False, 8);
2436 Anim
.Blending
:= False;
2437 g_GFX_OnceAnim((Obj
.X
+32)-32, (Obj
.Y
+8)-32, Anim
);
2442 begin // Âçðûâ Ðàêåòû
2443 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
2445 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2446 Anim
.Blending
:= False;
2447 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2451 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj
.X
, Obj
.Y
);
2455 WEAPON_PLASMA
, WEAPON_BSP_FIRE
: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2457 if ShotType
= WEAPON_PLASMA
then
2458 s
:= 'FRAMES_EXPLODE_PLASMA'
2460 s
:= 'FRAMES_EXPLODE_BSPFIRE';
2462 if g_Frames_Get(TextureID
, s
) and loud
then
2464 Anim
:= TAnimation
.Create(TextureID
, False, 3);
2465 Anim
.Blending
:= False;
2466 g_GFX_OnceAnim(cx
-16, cy
-16, Anim
);
2469 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj
.X
, Obj
.Y
);
2476 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') and Loud
then
2478 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2479 Anim
.Blending
:= False;
2480 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2483 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj
.X
, Obj
.Y
);
2487 WEAPON_IMP_FIRE
, WEAPON_CACO_FIRE
, WEAPON_BARON_FIRE
: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2489 if ShotType
= WEAPON_IMP_FIRE
then
2490 s
:= 'FRAMES_EXPLODE_IMPFIRE'
2492 if ShotType
= WEAPON_CACO_FIRE
then
2493 s
:= 'FRAMES_EXPLODE_CACOFIRE'
2495 s
:= 'FRAMES_EXPLODE_BARONFIRE';
2497 if g_Frames_Get(TextureID
, s
) and Loud
then
2499 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2500 Anim
.Blending
:= False;
2501 g_GFX_OnceAnim(cx
-32, cy
-32, Anim
);
2504 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2508 WEAPON_MANCUB_FIRE
: // Âûñòðåë Ìàíêóáóñà
2510 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') and Loud
then
2512 Anim
:= TAnimation
.Create(TextureID
, False, 6);
2513 Anim
.Blending
:= False;
2514 g_GFX_OnceAnim(cx
-64, cy
-64, Anim
);
2517 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj
.X
, Obj
.Y
);
2520 end; // case ShotType of...
2528 procedure g_Weapon_AddDynLights();
2532 if Shots
= nil then Exit
;
2533 for i
:= 0 to High(Shots
) do
2535 if Shots
[i
].ShotType
= 0 then continue
;
2536 if (Shots
[i
].ShotType
= WEAPON_ROCKETLAUNCHER
) or
2537 (Shots
[i
].ShotType
= WEAPON_BARON_FIRE
) or
2538 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2539 (Shots
[i
].ShotType
= WEAPON_SKEL_FIRE
) or
2540 (Shots
[i
].ShotType
= WEAPON_IMP_FIRE
) or
2541 (Shots
[i
].ShotType
= WEAPON_CACO_FIRE
) or
2542 (Shots
[i
].ShotType
= WEAPON_MANCUB_FIRE
) or
2543 (Shots
[i
].ShotType
= WEAPON_BSP_FIRE
) or
2544 (Shots
[i
].ShotType
= WEAPON_PLASMA
) or
2545 (Shots
[i
].ShotType
= WEAPON_BFG
) or
2546 (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) or
2549 if (Shots
[i
].ShotType
= WEAPON_PLASMA
) then
2550 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)
2551 else if (Shots
[i
].ShotType
= WEAPON_BFG
) then
2552 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)
2553 else if (Shots
[i
].ShotType
= WEAPON_FLAMETHROWER
) then
2554 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)
2556 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);
2562 procedure TShot
.positionChanged (); begin end;