DEADSOFTWARE

game: add option to disable hits on friendly players
[d2df-sdl.git] / src / game / g_weapons.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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.
6 *
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.
11 *
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/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 {.$DEFINE GWEP_HITSCAN_TRACE_BITMAP_CHECKER}
17 unit g_weapons;
19 interface
21 uses
22 SysUtils, Classes, mempool,
23 g_textures, g_basic, e_graphics, g_phys, xprofiler;
26 type
27 TShot = record
28 ShotType: Byte;
29 Target: Word;
30 SpawnerUID: Word;
31 Triggers: DWArray;
32 Obj: TObj;
33 Animation: TAnimation;
34 TextureID: DWORD;
35 Timeout: DWORD;
36 Stopped: Byte;
38 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
39 end;
42 var
43 Shots: array of TShot = nil;
44 LastShotID: Integer = 0;
46 procedure g_Weapon_LoadData();
47 procedure g_Weapon_FreeData();
48 procedure g_Weapon_Init();
49 procedure g_Weapon_Free();
50 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
51 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
52 function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
54 procedure g_Weapon_gun(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
55 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
56 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
57 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
58 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word; WID: Integer = -1; Silent: Boolean = False);
59 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
60 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
61 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
62 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
63 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
64 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
65 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
66 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
67 procedure g_Weapon_bfghit(x, y: Integer);
68 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
69 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
70 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
71 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
73 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
74 procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word);
75 procedure g_Weapon_PreUpdate();
76 procedure g_Weapon_Update();
77 procedure g_Weapon_Draw();
78 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
79 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
81 procedure g_Weapon_SaveState (st: TStream);
82 procedure g_Weapon_LoadState (st: TStream);
84 procedure g_Weapon_AddDynLights();
86 const
87 WEAPON_KASTET = 0;
88 WEAPON_SAW = 1;
89 WEAPON_PISTOL = 2;
90 WEAPON_SHOTGUN1 = 3;
91 WEAPON_SHOTGUN2 = 4;
92 WEAPON_CHAINGUN = 5;
93 WEAPON_ROCKETLAUNCHER = 6;
94 WEAPON_PLASMA = 7;
95 WEAPON_BFG = 8;
96 WEAPON_SUPERPULEMET = 9;
97 WEAPON_FLAMETHROWER = 10;
98 WEAPON_ZOMBY_PISTOL = 20;
99 WEAPON_IMP_FIRE = 21;
100 WEAPON_BSP_FIRE = 22;
101 WEAPON_CACO_FIRE = 23;
102 WEAPON_BARON_FIRE = 24;
103 WEAPON_MANCUB_FIRE = 25;
104 WEAPON_SKEL_FIRE = 26;
106 WP_FIRST = WEAPON_KASTET;
107 WP_LAST = WEAPON_FLAMETHROWER;
110 var
111 gwep_debug_fast_trace: Boolean = true;
114 implementation
116 uses
117 Math, g_map, g_player, g_gfx, g_sound, g_main, g_panel,
118 g_console, g_options, g_game,
119 g_triggers, MAPDEF, e_log, g_monsters, g_saveload,
120 g_language, g_netmsg, g_grid,
121 geom, binheap, hashtable, utils, xstreams;
123 type
124 TWaterPanel = record
125 X, Y: Integer;
126 Width, Height: Word;
127 Active: Boolean;
128 end;
130 const
131 SHOT_ROCKETLAUNCHER_WIDTH = 14;
132 SHOT_ROCKETLAUNCHER_HEIGHT = 14;
134 SHOT_SKELFIRE_WIDTH = 14;
135 SHOT_SKELFIRE_HEIGHT = 14;
137 SHOT_PLASMA_WIDTH = 16;
138 SHOT_PLASMA_HEIGHT = 16;
140 SHOT_BFG_WIDTH = 32;
141 SHOT_BFG_HEIGHT = 32;
142 SHOT_BFG_DAMAGE = 100;
143 SHOT_BFG_RADIUS = 256;
145 SHOT_FLAME_WIDTH = 4;
146 SHOT_FLAME_HEIGHT = 4;
147 SHOT_FLAME_LIFETIME = 180;
149 SHOT_SIGNATURE = $544F4853; // 'SHOT'
151 type
152 PHitTime = ^THitTime;
153 THitTime = record
154 distSq: Integer;
155 mon: TMonster;
156 plridx: Integer; // if mon=nil
157 x, y: Integer;
158 end;
160 TBinHeapKeyHitTime = class
161 public
162 class function less (const a, b: Integer): Boolean; inline;
163 end;
165 // indicies in `wgunHitTime` array
166 TBinaryHeapHitTimes = specialize TBinaryHeapBase<Integer, TBinHeapKeyHitTime>;
168 var
169 WaterMap: array of array of DWORD = nil;
170 //wgunMonHash: THashIntInt = nil;
171 wgunHitHeap: TBinaryHeapHitTimes = nil;
172 wgunHitTime: array of THitTime = nil;
173 wgunHitTimeUsed: Integer = 0;
176 class function TBinHeapKeyHitTime.less (const a, b: Integer): Boolean;
177 var
178 hta, htb: PHitTime;
179 begin
180 hta := @wgunHitTime[a];
181 htb := @wgunHitTime[b];
182 if (hta.distSq <> htb.distSq) then begin result := (hta.distSq < htb.distSq); exit; end;
183 if (hta.mon <> nil) then
184 begin
185 // a is monster
186 if (htb.mon = nil) then begin result := false; exit; end; // players first
187 result := (hta.mon.UID < htb.mon.UID); // why not?
188 end
189 else
190 begin
191 // a is player
192 if (htb.mon <> nil) then begin result := true; exit; end; // players first
193 result := (hta.plridx < htb.plridx); // why not?
194 end;
195 end;
198 procedure appendHitTimeMon (adistSq: Integer; amon: TMonster; ax, ay: Integer);
199 begin
200 if (wgunHitTimeUsed = Length(wgunHitTime)) then SetLength(wgunHitTime, wgunHitTimeUsed+128);
201 with wgunHitTime[wgunHitTimeUsed] do
202 begin
203 distSq := adistSq;
204 mon := amon;
205 plridx := -1;
206 x := ax;
207 y := ay;
208 end;
209 wgunHitHeap.insert(wgunHitTimeUsed);
210 Inc(wgunHitTimeUsed);
211 end;
214 procedure appendHitTimePlr (adistSq: Integer; aplridx: Integer; ax, ay: Integer);
215 begin
216 if (wgunHitTimeUsed = Length(wgunHitTime)) then SetLength(wgunHitTime, wgunHitTimeUsed+128);
217 with wgunHitTime[wgunHitTimeUsed] do
218 begin
219 distSq := adistSq;
220 mon := nil;
221 plridx := aplridx;
222 x := ax;
223 y := ay;
224 end;
225 wgunHitHeap.insert(wgunHitTimeUsed);
226 Inc(wgunHitTimeUsed);
227 end;
230 function FindShot(): DWORD;
231 var
232 i: Integer;
233 begin
234 if Shots <> nil then
235 for i := 0 to High(Shots) do
236 if Shots[i].ShotType = 0 then
237 begin
238 Result := i;
239 LastShotID := Result;
240 Exit;
241 end;
243 if Shots = nil then
244 begin
245 SetLength(Shots, 128);
246 Result := 0;
247 end
248 else
249 begin
250 Result := High(Shots) + 1;
251 SetLength(Shots, Length(Shots) + 128);
252 end;
253 LastShotID := Result;
254 end;
256 procedure CreateWaterMap();
257 var
258 WaterArray: Array of TWaterPanel;
259 a, b, c, m: Integer;
260 ok: Boolean;
261 begin
262 if gWater = nil then
263 Exit;
265 SetLength(WaterArray, Length(gWater));
267 for a := 0 to High(gWater) do
268 begin
269 WaterArray[a].X := gWater[a].X;
270 WaterArray[a].Y := gWater[a].Y;
271 WaterArray[a].Width := gWater[a].Width;
272 WaterArray[a].Height := gWater[a].Height;
273 WaterArray[a].Active := True;
274 end;
276 g_Game_SetLoadingText(_lc[I_LOAD_WATER_MAP], High(WaterArray), False);
278 for a := 0 to High(WaterArray) do
279 if WaterArray[a].Active then
280 begin
281 WaterArray[a].Active := False;
282 m := Length(WaterMap);
283 SetLength(WaterMap, m+1);
284 SetLength(WaterMap[m], 1);
285 WaterMap[m][0] := a;
286 ok := True;
288 while ok do
289 begin
290 ok := False;
291 for b := 0 to High(WaterArray) do
292 if WaterArray[b].Active then
293 for c := 0 to High(WaterMap[m]) do
294 if g_CollideAround(WaterArray[b].X,
295 WaterArray[b].Y,
296 WaterArray[b].Width,
297 WaterArray[b].Height,
298 WaterArray[WaterMap[m][c]].X,
299 WaterArray[WaterMap[m][c]].Y,
300 WaterArray[WaterMap[m][c]].Width,
301 WaterArray[WaterMap[m][c]].Height) then
302 begin
303 WaterArray[b].Active := False;
304 SetLength(WaterMap[m],
305 Length(WaterMap[m])+1);
306 WaterMap[m][High(WaterMap[m])] := b;
307 ok := True;
308 Break;
309 end;
310 end;
312 g_Game_StepLoading();
313 end;
315 WaterArray := nil;
316 end;
319 var
320 chkTrap_pl: array [0..256] of Integer;
321 chkTrap_mn: array [0..65535] of TMonster;
323 procedure CheckTrap(ID: DWORD; dm: Integer; t: Byte);
324 var
325 //a, b, c, d, i1, i2: Integer;
326 //chkTrap_pl, chkTrap_mn: WArray;
327 plaCount: Integer = 0;
328 mnaCount: Integer = 0;
329 frameId: DWord;
332 function monsWaterCheck (mon: TMonster): Boolean;
333 begin
334 result := false; // don't stop
335 if mon.alive and mon.Collide(gWater[WaterMap[a][c]]) and (not InWArray(monidx, chkTrap_mn)) and (i2 < 1023) then //FIXME
336 begin
337 i2 += 1;
338 chkTrap_mn[i2] := monidx;
339 end;
340 end;
343 function monsWaterCheck (mon: TMonster): Boolean;
344 begin
345 result := false; // don't stop
346 if (mon.trapCheckFrameId <> frameId) then
347 begin
348 mon.trapCheckFrameId := frameId;
349 chkTrap_mn[mnaCount] := mon;
350 Inc(mnaCount);
351 end;
352 end;
354 var
355 a, b, c, d, f: Integer;
356 pan: TPanel;
357 begin
358 if (gWater = nil) or (WaterMap = nil) then Exit;
360 frameId := g_Mons_getNewTrapFrameId();
362 //i1 := -1;
363 //i2 := -1;
365 //SetLength(chkTrap_pl, 1024);
366 //SetLength(chkTrap_mn, 1024);
367 //for d := 0 to 1023 do chkTrap_pl[d] := $FFFF;
368 //for d := 0 to 1023 do chkTrap_mn[d] := $FFFF;
370 for a := 0 to High(WaterMap) do
371 begin
372 for b := 0 to High(WaterMap[a]) do
373 begin
374 pan := gWater[WaterMap[a][b]];
375 if not g_Obj_Collide(pan.X, pan.Y, pan.Width, pan.Height, @Shots[ID].Obj) then continue;
377 for c := 0 to High(WaterMap[a]) do
378 begin
379 pan := gWater[WaterMap[a][c]];
380 for d := 0 to High(gPlayers) do
381 begin
382 if (gPlayers[d] <> nil) and (gPlayers[d].alive) then
383 begin
384 if gPlayers[d].Collide(pan) then
385 begin
386 f := 0;
387 while (f < plaCount) and (chkTrap_pl[f] <> d) do Inc(f);
388 if (f = plaCount) then
389 begin
390 chkTrap_pl[plaCount] := d;
391 Inc(plaCount);
392 if (plaCount = Length(chkTrap_pl)) then break;
393 end;
394 end;
395 end;
396 end;
398 //g_Mons_ForEach(monsWaterCheck);
399 g_Mons_ForEachAliveAt(pan.X, pan.Y, pan.Width, pan.Height, monsWaterCheck);
400 end;
402 for f := 0 to plaCount-1 do gPlayers[chkTrap_pl[f]].Damage(dm, Shots[ID].SpawnerUID, 0, 0, t);
403 for f := 0 to mnaCount-1 do chkTrap_mn[f].Damage(dm, 0, 0, Shots[ID].SpawnerUID, t);
404 end;
405 end;
407 //chkTrap_pl := nil;
408 //chkTrap_mn := nil;
409 end;
411 function HitMonster(m: TMonster; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
412 var
413 tt, mt: Byte;
414 mon: TMonster;
415 begin
416 Result := False;
418 tt := g_GetUIDType(SpawnerUID);
419 if tt = UID_MONSTER then
420 begin
421 mon := g_Monsters_ByUID(SpawnerUID);
422 if mon <> nil then
423 mt := g_Monsters_ByUID(SpawnerUID).MonsterType
424 else
425 mt := 0;
426 end
427 else
428 mt := 0;
430 if m = nil then Exit;
431 if m.UID = SpawnerUID then
432 begin
433 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
434 if (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then
435 Exit;
436 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
437 if (m.MonsterType = MONSTER_CYBER) or
438 (m.MonsterType = MONSTER_BARREL) then
439 begin
440 Result := True;
441 Exit;
442 end;
443 end;
445 if tt = UID_MONSTER then
446 begin
447 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
448 if (mt = MONSTER_SOUL) and (m.MonsterType = MONSTER_PAIN) then
449 Exit;
451 // Îáà ìîíñòðà îäíîãî âèäà:
452 if mt = m.MonsterType then
453 case mt of
454 MONSTER_IMP, MONSTER_DEMON, MONSTER_BARON, MONSTER_KNIGHT, MONSTER_CACO,
455 MONSTER_SOUL, MONSTER_MANCUB, MONSTER_SKEL, MONSTER_FISH:
456 Exit; // Ýòè íå áüþò ñâîèõ
457 end;
458 end;
460 if g_Game_IsServer then
461 begin
462 if (t <> HIT_FLAME) or (m.FFireTime = 0) or (vx <> 0) or (vy <> 0) then
463 Result := m.Damage(d, vx, vy, SpawnerUID, t)
464 else
465 Result := (gLMSRespawn = LMS_RESPAWN_NONE); // don't hit monsters when it's warmup time
466 if t = HIT_FLAME then
467 m.CatchFire(SpawnerUID);
468 end
469 else
470 Result := (gLMSRespawn = LMS_RESPAWN_NONE); // don't hit monsters when it's warmup time
471 end;
474 function HitPlayer (p: TPlayer; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
475 begin
476 result := False;
478 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì
479 if (p.UID = SpawnerUID) and (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then exit;
481 if g_Game_IsServer then
482 begin
483 if (t <> HIT_FLAME) or (p.FFireTime = 0) or (vx <> 0) or (vy <> 0) then p.Damage(d, SpawnerUID, vx, vy, t);
484 if (t = HIT_FLAME) then p.CatchFire(SpawnerUID);
485 end;
487 result := true;
488 end;
491 procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word);
493 function monsCheck (mon: TMonster): Boolean;
494 begin
495 result := false; // don't stop
496 if (mon.alive) and (mon.UID <> SpawnerUID) then
497 begin
498 with mon do
499 begin
500 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
501 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
502 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
503 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
504 begin
505 if HitMonster(mon, 50, 0, 0, SpawnerUID, HIT_SOME) then mon.BFGHit();
506 end;
507 end;
508 end;
509 end;
511 var
512 i, h: Integer;
513 st: Byte;
514 pl: TPlayer;
515 b: Boolean;
516 begin
517 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
519 h := High(gCorpses);
521 if gAdvCorpses and (h <> -1) then
522 for i := 0 to h do
523 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
524 with gCorpses[i] do
525 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
526 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
527 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
528 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
529 begin
530 Damage(50, SpawnerUID, 0, 0);
531 g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
532 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2));
533 end;
535 st := TEAM_NONE;
536 pl := g_Player_Get(SpawnerUID);
537 if pl <> nil then
538 st := pl.Team;
540 h := High(gPlayers);
542 if h <> -1 then
543 for i := 0 to h do
544 if (gPlayers[i] <> nil) and (gPlayers[i].alive) and (gPlayers[i].UID <> SpawnerUID) then
545 with gPlayers[i] do
546 if (g_PatchLength(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
547 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) <= SHOT_BFG_RADIUS) and
548 g_TraceVector(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
549 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) then
550 begin
551 if (st = TEAM_NONE) or (st <> gPlayers[i].Team) then
552 b := HitPlayer(gPlayers[i], 50, 0, 0, SpawnerUID, HIT_SOME)
553 else
554 b := HitPlayer(gPlayers[i], 25, 0, 0, SpawnerUID, HIT_SOME);
555 if b then
556 gPlayers[i].BFGHit();
557 end;
559 //FIXME
560 g_Mons_ForEachAlive(monsCheck);
561 end;
563 function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
564 var
565 find_id: DWord;
566 FramesID: DWORD = 0;
567 begin
568 if I < 0 then
569 find_id := FindShot()
570 else
571 begin
572 find_id := I;
573 if Integer(find_id) >= High(Shots) then
574 SetLength(Shots, find_id + 64)
575 end;
577 case ShotType of
578 WEAPON_ROCKETLAUNCHER:
579 begin
580 with Shots[find_id] do
581 begin
582 g_Obj_Init(@Obj);
584 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
585 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
587 Animation := nil;
588 Triggers := nil;
589 ShotType := WEAPON_ROCKETLAUNCHER;
590 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
591 end;
592 end;
594 WEAPON_PLASMA:
595 begin
596 with Shots[find_id] do
597 begin
598 g_Obj_Init(@Obj);
600 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
601 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
603 Triggers := nil;
604 ShotType := WEAPON_PLASMA;
605 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
606 Animation := TAnimation.Create(FramesID, True, 5);
607 end;
608 end;
610 WEAPON_BFG:
611 begin
612 with Shots[find_id] do
613 begin
614 g_Obj_Init(@Obj);
616 Obj.Rect.Width := SHOT_BFG_WIDTH;
617 Obj.Rect.Height := SHOT_BFG_HEIGHT;
619 Triggers := nil;
620 ShotType := WEAPON_BFG;
621 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
622 Animation := TAnimation.Create(FramesID, True, 6);
623 end;
624 end;
626 WEAPON_FLAMETHROWER:
627 begin
628 with Shots[find_id] do
629 begin
630 g_Obj_Init(@Obj);
632 Obj.Rect.Width := SHOT_FLAME_WIDTH;
633 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
635 Triggers := nil;
636 ShotType := WEAPON_FLAMETHROWER;
637 Animation := nil;
638 TextureID := 0;
639 g_Frames_Get(TextureID, 'FRAMES_FLAME');
640 end;
641 end;
643 WEAPON_IMP_FIRE:
644 begin
645 with Shots[find_id] do
646 begin
647 g_Obj_Init(@Obj);
649 Obj.Rect.Width := 16;
650 Obj.Rect.Height := 16;
652 Triggers := nil;
653 ShotType := WEAPON_IMP_FIRE;
654 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
655 Animation := TAnimation.Create(FramesID, True, 4);
656 end;
657 end;
659 WEAPON_CACO_FIRE:
660 begin
661 with Shots[find_id] do
662 begin
663 g_Obj_Init(@Obj);
665 Obj.Rect.Width := 16;
666 Obj.Rect.Height := 16;
668 Triggers := nil;
669 ShotType := WEAPON_CACO_FIRE;
670 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
671 Animation := TAnimation.Create(FramesID, True, 4);
672 end;
673 end;
675 WEAPON_MANCUB_FIRE:
676 begin
677 with Shots[find_id] do
678 begin
679 g_Obj_Init(@Obj);
681 Obj.Rect.Width := 32;
682 Obj.Rect.Height := 32;
684 Triggers := nil;
685 ShotType := WEAPON_MANCUB_FIRE;
686 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
687 Animation := TAnimation.Create(FramesID, True, 4);
688 end;
689 end;
691 WEAPON_BARON_FIRE:
692 begin
693 with Shots[find_id] do
694 begin
695 g_Obj_Init(@Obj);
697 Obj.Rect.Width := 32;
698 Obj.Rect.Height := 16;
700 Triggers := nil;
701 ShotType := WEAPON_BARON_FIRE;
702 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
703 Animation := TAnimation.Create(FramesID, True, 4);
704 end;
705 end;
707 WEAPON_BSP_FIRE:
708 begin
709 with Shots[find_id] do
710 begin
711 g_Obj_Init(@Obj);
713 Obj.Rect.Width := 16;
714 Obj.Rect.Height := 16;
716 Triggers := nil;
717 ShotType := WEAPON_BSP_FIRE;
718 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
719 Animation := TAnimation.Create(FramesID, True, 4);
720 end;
721 end;
723 WEAPON_SKEL_FIRE:
724 begin
725 with Shots[find_id] do
726 begin
727 g_Obj_Init(@Obj);
729 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
730 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
732 Triggers := nil;
733 ShotType := WEAPON_SKEL_FIRE;
734 target := TargetUID;
735 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
736 Animation := TAnimation.Create(FramesID, True, 5);
737 end;
738 end;
739 end;
741 Shots[find_id].Obj.oldX := X;
742 Shots[find_id].Obj.oldY := Y;
743 Shots[find_id].Obj.X := X;
744 Shots[find_id].Obj.Y := Y;
745 Shots[find_id].Obj.Vel.X := XV;
746 Shots[find_id].Obj.Vel.Y := YV;
747 Shots[find_id].Obj.Accel.X := 0;
748 Shots[find_id].Obj.Accel.Y := 0;
749 Shots[find_id].SpawnerUID := Spawner;
750 if (ShotType = WEAPON_FLAMETHROWER) and (XV = 0) and (YV = 0) then
751 Shots[find_id].Stopped := 255
752 else
753 Shots[find_id].Stopped := 0;
754 Result := find_id;
755 end;
757 procedure throw(i, x, y, xd, yd, s: Integer);
758 var
759 a: Integer;
760 begin
761 yd := yd - y;
762 xd := xd - x;
764 a := Max(Abs(xd), Abs(yd));
765 if a = 0 then
766 a := 1;
768 Shots[i].Obj.oldX := x;
769 Shots[i].Obj.oldY := y;
770 Shots[i].Obj.X := x;
771 Shots[i].Obj.Y := y;
772 Shots[i].Obj.Vel.X := (xd*s) div a;
773 Shots[i].Obj.Vel.Y := (yd*s) div a;
774 Shots[i].Obj.Accel.X := 0;
775 Shots[i].Obj.Accel.Y := 0;
776 Shots[i].Stopped := 0;
777 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BFG] then
778 Shots[i].Timeout := 900 // ~25 sec
779 else
780 begin
781 if Shots[i].ShotType = WEAPON_FLAMETHROWER then
782 Shots[i].Timeout := SHOT_FLAME_LIFETIME
783 else
784 Shots[i].Timeout := 550; // ~15 sec
785 end;
786 end;
788 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
789 var
790 i, h: Integer;
792 function PlayerHit(Team: Byte = 0): Boolean;
793 var
794 i: Integer;
795 ChkTeam: Boolean;
796 p: TPlayer;
797 begin
798 Result := False;
799 h := High(gPlayers);
801 if h <> -1 then
802 for i := 0 to h do
803 if (gPlayers[i] <> nil) and gPlayers[i].alive and g_Obj_Collide(obj, @gPlayers[i].Obj) then
804 begin
805 ChkTeam := True;
806 if (Team > 0) and (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
807 begin
808 p := g_Player_Get(SpawnerUID);
809 if p <> nil then
810 ChkTeam := (p.Team = gPlayers[i].Team) xor (Team = 2);
811 end;
812 if ChkTeam then
813 if HitPlayer(gPlayers[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
814 begin
815 if t <> HIT_FLAME then
816 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
817 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
818 if t = HIT_BFG then
819 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
820 Result := True;
821 break;
822 end;
823 end;
824 end;
827 function monsCheckHit (monidx: Integer; mon: TMonster): Boolean;
828 begin
829 result := false; // don't stop
830 if mon.alive and g_Obj_Collide(obj, @mon.Obj) then
831 begin
832 if HitMonster(mon, d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
833 begin
834 if (t <> HIT_FLAME) then
835 begin
836 mon.Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
837 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
838 end;
839 result := True;
840 end;
841 end;
842 end;
845 function monsCheckHit (mon: TMonster): Boolean;
846 begin
847 result := false; // don't stop
848 if HitMonster(mon, d, obj.Vel.X, obj.Vel.Y, SpawnerUID, t) then
849 begin
850 if (t <> HIT_FLAME) then
851 begin
852 mon.Push((obj.Vel.X+obj.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
853 (obj.Vel.Y+obj.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
854 end;
855 result := true;
856 end;
857 end;
859 function MonsterHit(): Boolean;
860 begin
861 //result := g_Mons_ForEach(monsCheckHit);
862 //FIXME: accelerate this!
863 result := g_Mons_ForEachAliveAt(obj.X+obj.Rect.X, obj.Y+obj.Rect.Y, obj.Rect.Width, obj.Rect.Height, monsCheckHit);
864 end;
866 begin
867 Result := 0;
869 if HitCorpses then
870 begin
871 h := High(gCorpses);
873 if gAdvCorpses and (h <> -1) then
874 for i := 0 to h do
875 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
876 g_Obj_Collide(obj, @gCorpses[i].Obj) then
877 begin
878 // Ðàñïèëèâàåì òðóï:
879 gCorpses[i].Damage(d, SpawnerUID, (obj^.Vel.X+obj^.Accel.X) div 4,
880 (obj^.Vel.Y+obj^.Accel.Y) div 4);
881 Result := 1;
882 end;
883 end;
885 case gGameSettings.GameMode of
886 // Êàìïàíèÿ:
887 GM_COOP, GM_SINGLE:
888 begin
889 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
890 if MonsterHit() then
891 begin
892 Result := 2;
893 Exit;
894 end;
896 // È â êîíöå èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
897 // (èëè friendlyfire, èëè friendly_hit_projectile)
898 if LongBool(gGameSettings.Options and (GAME_OPTION_TEAMDAMAGE or GAME_OPTION_TEAMHITPROJECTILE)) then
899 begin
900 if PlayerHit() then
901 begin
902 Result := 1;
903 Exit;
904 end;
905 end;
906 end;
908 // Äåçìàò÷:
909 GM_DM:
910 begin
911 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
912 if PlayerHit() then
913 begin
914 Result := 1;
915 Exit;
916 end;
918 if MonsterHit() then
919 begin
920 Result := 2;
921 Exit;
922 end;
923 end;
925 // Êîìàíäíûå:
926 GM_TDM, GM_CTF:
927 begin
928 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
929 if PlayerHit(2) then
930 begin
931 Result := 1;
932 Exit;
933 end;
935 // Ïîòîì ìîíñòðîâ
936 if MonsterHit() then
937 begin
938 Result := 2;
939 Exit;
940 end;
942 // È â êîíöå ñâîèõ èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
943 // (èëè friendlyfire, èëè friendly_hit_projectile)
944 if LongBool(gGameSettings.Options and (GAME_OPTION_TEAMDAMAGE or GAME_OPTION_TEAMHITPROJECTILE)) then
945 begin
946 if PlayerHit(1) then
947 begin
948 Result := 1;
949 Exit;
950 end;
951 end;
952 end;
954 end;
955 end;
957 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
958 begin
959 Result := False;
961 case g_GetUIDType(UID) of
962 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
963 UID_MONSTER: Result := HitMonster(g_Monsters_ByUID(UID), d, 0, 0, SpawnerUID, t);
964 else Exit;
965 end;
966 end;
968 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
969 var
970 r: Integer; // squared radius
972 function monsExCheck (mon: TMonster): Boolean;
973 var
974 dx, dy, mm: Integer;
975 begin
976 result := false; // don't stop
977 begin
978 dx := mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-X;
979 dy := mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-Y;
981 if dx > 1000 then dx := 1000;
982 if dy > 1000 then dy := 1000;
984 if (dx*dx+dy*dy < r) then
985 begin
986 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
987 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
989 mm := Max(abs(dx), abs(dy));
990 if mm = 0 then mm := 1;
992 if mon.alive then
993 begin
994 HitMonster(mon, ((mon.Obj.Rect.Width div 4)*10*(rad-mm)) div rad, 0, 0, SpawnerUID, HIT_ROCKET);
995 end;
997 mon.Push((dx*7) div mm, (dy*7) div mm);
998 end;
999 end;
1000 end;
1002 var
1003 i, h, dx, dy, m, mm: Integer;
1004 _angle: SmallInt;
1005 begin
1006 result := false;
1008 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
1010 r := rad*rad;
1012 h := High(gPlayers);
1014 if h <> -1 then
1015 for i := 0 to h do
1016 if (gPlayers[i] <> nil) and gPlayers[i].alive then
1017 with gPlayers[i] do
1018 begin
1019 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1020 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1022 if dx > 1000 then dx := 1000;
1023 if dy > 1000 then dy := 1000;
1025 if dx*dx+dy*dy < r then
1026 begin
1027 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1028 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1030 mm := Max(abs(dx), abs(dy));
1031 if mm = 0 then mm := 1;
1033 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
1034 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
1035 end;
1036 end;
1038 //g_Mons_ForEach(monsExCheck);
1039 g_Mons_ForEachAt(X-(rad+32), Y-(rad+32), (rad+32)*2, (rad+32)*2, monsExCheck);
1041 h := High(gCorpses);
1043 if gAdvCorpses and (h <> -1) then
1044 for i := 0 to h do
1045 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
1046 with gCorpses[i] do
1047 begin
1048 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1049 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1051 if dx > 1000 then dx := 1000;
1052 if dy > 1000 then dy := 1000;
1054 if dx*dx+dy*dy < r then
1055 begin
1056 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
1057 Obj.Rect.Width, Obj.Rect.Height);
1059 mm := Max(abs(dx), abs(dy));
1060 if mm = 0 then mm := 1;
1062 Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm);
1063 end;
1064 end;
1066 h := High(gGibs);
1068 if gAdvGibs and (h <> -1) then
1069 for i := 0 to h do
1070 if gGibs[i].alive then
1071 with gGibs[i] do
1072 begin
1073 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1074 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1076 if dx > 1000 then dx := 1000;
1077 if dy > 1000 then dy := 1000;
1079 if dx*dx+dy*dy < r then
1080 begin
1081 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
1082 Obj.Rect.Width, Obj.Rect.Height);
1083 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
1084 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
1086 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
1087 positionChanged(); // this updates spatial accelerators
1088 end;
1089 end;
1090 end;
1092 procedure g_Weapon_Init();
1093 begin
1094 CreateWaterMap();
1095 end;
1097 procedure g_Weapon_Free();
1098 var
1099 i: Integer;
1100 begin
1101 if Shots <> nil then
1102 begin
1103 for i := 0 to High(Shots) do
1104 if Shots[i].ShotType <> 0 then
1105 Shots[i].Animation.Free();
1107 Shots := nil;
1108 end;
1110 WaterMap := nil;
1111 end;
1113 procedure g_Weapon_LoadData();
1114 begin
1115 e_WriteLog('Loading weapons data...', TMsgType.Notify);
1117 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
1118 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
1119 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
1120 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
1121 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
1122 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
1123 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
1124 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
1125 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
1126 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
1127 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
1128 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
1129 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
1130 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
1131 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1132 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1133 g_Sound_CreateWADEx('SOUND_IGNITE', GameWAD+':SOUNDS\IGNITE');
1134 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1135 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1136 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1137 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1138 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1139 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1140 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1141 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1142 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1143 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD+':SOUNDS\STARTFLM');
1144 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD+':SOUNDS\STOPFLM');
1145 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD+':SOUNDS\WORKFLM');
1146 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1147 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1148 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1149 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1150 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1151 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1152 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1154 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1155 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1156 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1157 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1158 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1159 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1160 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1161 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1162 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1163 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1164 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1165 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1166 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1167 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1168 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1169 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1170 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1171 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1172 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1173 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1174 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1176 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1177 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1179 //wgunMonHash := hashNewIntInt();
1180 wgunHitHeap := TBinaryHeapHitTimes.Create();
1181 end;
1183 procedure g_Weapon_FreeData();
1184 begin
1185 e_WriteLog('Releasing weapons data...', TMsgType.Notify);
1187 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1188 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1189 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1190 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1191 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1192 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1193 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1194 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1195 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1196 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1197 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1198 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1199 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1200 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1201 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1202 g_Sound_Delete('SOUND_FIRE');
1203 g_Sound_Delete('SOUND_IGNITE');
1204 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1205 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1206 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1207 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1208 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1209 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1210 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1211 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1212 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1213 g_Sound_Delete('SOUND_WEAPON_FLAMEON');
1214 g_Sound_Delete('SOUND_WEAPON_FLAMEOFF');
1215 g_Sound_Delete('SOUND_WEAPON_FLAMEWORK');
1216 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1217 g_Sound_Delete('SOUND_PLAYER_JETON');
1218 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1219 g_Sound_Delete('SOUND_PLAYER_CASING1');
1220 g_Sound_Delete('SOUND_PLAYER_CASING2');
1221 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1222 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1224 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1225 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1226 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1227 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1228 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1229 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1230 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1231 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1232 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1233 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1234 g_Frames_DeleteByName('FRAMES_BFGHIT');
1235 g_Frames_DeleteByName('FRAMES_FIRE');
1236 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1237 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1238 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1239 g_Frames_DeleteByName('FRAMES_SMOKE');
1240 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1241 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1242 end;
1245 function GunHitPlayer (X, Y: Integer; vx, vy: Integer; dmg: Integer; SpawnerUID: Word; AllowPush: Boolean): Boolean;
1246 var
1247 i: Integer;
1248 begin
1249 result := false;
1250 for i := 0 to High(gPlayers) do
1251 begin
1252 if (gPlayers[i] <> nil) and gPlayers[i].alive and gPlayers[i].Collide(X, Y) then
1253 begin
1254 if HitPlayer(gPlayers[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
1255 begin
1256 if AllowPush then gPlayers[i].Push(vx, vy);
1257 result := true;
1258 end;
1259 end;
1260 end;
1261 end;
1264 function GunHit (X, Y: Integer; vx, vy: Integer; dmg: Integer; SpawnerUID: Word; AllowPush: Boolean): Byte;
1266 function monsCheck (mon: TMonster): Boolean;
1267 begin
1268 result := false; // don't stop
1269 if HitMonster(mon, dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
1270 begin
1271 if AllowPush then mon.Push(vx, vy);
1272 result := true;
1273 end;
1274 end;
1276 begin
1277 result := 0;
1278 if GunHitPlayer(X, Y, vx, vy, dmg, SpawnerUID, AllowPush) then result := 1
1279 else if g_Mons_ForEachAliveAt(X, Y, 1, 1, monsCheck) then result := 2;
1280 end;
1283 (*
1284 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1285 var
1286 a: Integer;
1287 x2, y2: Integer;
1288 dx, dy: Integer;
1289 xe, ye: Integer;
1290 xi, yi: Integer;
1291 s, c: Extended;
1292 //vx, vy: Integer;
1293 xx, yy, d: Integer;
1294 i: Integer;
1295 t1, _collide: Boolean;
1296 w, h: Word;
1297 {$IF DEFINED(D2F_DEBUG)}
1298 stt: UInt64;
1299 showTime: Boolean = true;
1300 {$ENDIF}
1301 begin
1302 a := GetAngle(x, y, xd, yd)+180;
1304 SinCos(DegToRad(-a), s, c);
1306 if Abs(s) < 0.01 then s := 0;
1307 if Abs(c) < 0.01 then c := 0;
1309 x2 := x+Round(c*gMapInfo.Width);
1310 y2 := y+Round(s*gMapInfo.Width);
1312 t1 := gWalls <> nil;
1313 _collide := False;
1314 w := gMapInfo.Width;
1315 h := gMapInfo.Height;
1317 xe := 0;
1318 ye := 0;
1319 dx := x2-x;
1320 dy := y2-y;
1322 if (xd = 0) and (yd = 0) then Exit;
1324 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1325 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1327 dx := Abs(dx);
1328 dy := Abs(dy);
1330 if dx > dy then d := dx else d := dy;
1332 //blood vel, for Monster.Damage()
1333 //vx := (dx*10 div d)*xi;
1334 //vy := (dy*10 div d)*yi;
1336 {$IF DEFINED(D2F_DEBUG)}
1337 stt := getTimeMicro();
1338 {$ENDIF}
1340 xx := x;
1341 yy := y;
1343 for i := 1 to d do
1344 begin
1345 xe := xe+dx;
1346 ye := ye+dy;
1348 if xe > d then
1349 begin
1350 xe := xe-d;
1351 xx := xx+xi;
1352 end;
1354 if ye > d then
1355 begin
1356 ye := ye-d;
1357 yy := yy+yi;
1358 end;
1360 if (yy > h) or (yy < 0) then Break;
1361 if (xx > w) or (xx < 0) then Break;
1363 if t1 then
1364 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1365 begin
1366 _collide := True;
1367 {$IF DEFINED(D2F_DEBUG)}
1368 stt := getTimeMicro()-stt;
1369 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1370 showTime := false;
1371 {$ENDIF}
1372 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1373 if g_Game_IsServer and g_Game_IsNet then
1374 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1375 end;
1377 if not _collide then
1378 begin
1379 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1380 end;
1382 if _collide then Break;
1383 end;
1385 {$IF DEFINED(D2F_DEBUG)}
1386 if showTime then
1387 begin
1388 stt := getTimeMicro()-stt;
1389 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1390 end;
1391 {$ENDIF}
1393 if CheckTrigger and g_Game_IsServer then
1394 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1395 end;
1396 *)
1399 //!!!FIXME!!!
1400 procedure g_Weapon_gun (const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1401 var
1402 x0, y0: Integer;
1403 x2, y2: Integer;
1404 xi, yi: Integer;
1405 wallDistSq: Integer = $3fffffff;
1406 spawnerPlr: TPlayer = nil;
1408 function doPlayerHit (idx: Integer; hx, hy: Integer): Boolean;
1409 begin
1410 result := false;
1411 if (idx < 0) or (idx > High(gPlayers)) then exit;
1412 if (gPlayers[idx] = nil) or not gPlayers[idx].alive then exit;
1413 if (spawnerPlr <> nil) then
1414 begin
1415 if ((gGameSettings.Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMDAMAGE)) = 0) and
1416 (spawnerPlr.Team <> TEAM_NONE) and (spawnerPlr.Team = gPlayers[idx].Team) then
1417 exit;
1418 end;
1419 result := HitPlayer(gPlayers[idx], dmg, (xi*v)*10, (yi*v)*10-3, SpawnerUID, HIT_SOME);
1420 if result and (v <> 0) then gPlayers[idx].Push((xi*v), (yi*v));
1421 {$IF DEFINED(D2F_DEBUG)}
1422 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1423 {$ENDIF}
1424 end;
1426 function doMonsterHit (mon: TMonster; hx, hy: Integer): Boolean;
1427 begin
1428 result := false;
1429 if (mon = nil) then exit;
1430 result := HitMonster(mon, dmg, (xi*v)*10, (yi*v)*10-3, SpawnerUID, HIT_SOME);
1431 if result and (v <> 0) then mon.Push((xi*v), (yi*v));
1432 {$IF DEFINED(D2F_DEBUG)}
1433 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1434 {$ENDIF}
1435 end;
1437 // collect players along hitray
1438 // return `true` if instant hit was detected
1439 function playerPossibleHit (): Boolean;
1440 var
1441 i: Integer;
1442 px, py, pw, ph: Integer;
1443 inx, iny: Integer;
1444 distSq: Integer;
1445 plr: TPlayer;
1446 begin
1447 result := false;
1448 for i := 0 to High(gPlayers) do
1449 begin
1450 plr := gPlayers[i];
1451 if (plr <> nil) and plr.alive then
1452 begin
1453 plr.getMapBox(px, py, pw, ph);
1454 if lineAABBIntersects(x, y, x2, y2, px, py, pw, ph, inx, iny) then
1455 begin
1456 distSq := distanceSq(x, y, inx, iny);
1457 if (distSq = 0) then
1458 begin
1459 // contains
1460 if doPlayerHit(i, x, y) then begin result := true; exit; end;
1461 end
1462 else if (distSq < wallDistSq) then
1463 begin
1464 appendHitTimePlr(distSq, i, inx, iny);
1465 end;
1466 end;
1467 end;
1468 end;
1469 end;
1471 procedure sqchecker (mon: TMonster);
1472 var
1473 mx, my, mw, mh: Integer;
1474 inx, iny: Integer;
1475 distSq: Integer;
1476 begin
1477 mon.getMapBox(mx, my, mw, mh);
1478 if lineAABBIntersects(x0, y0, x2, y2, mx, my, mw, mh, inx, iny) then
1479 begin
1480 distSq := distanceSq(x0, y0, inx, iny);
1481 if (distSq < wallDistSq) then appendHitTimeMon(distSq, mon, inx, iny);
1482 end;
1483 end;
1485 var
1486 a: Integer;
1487 dx, dy: Integer;
1488 xe, ye: Integer;
1489 s, c: Extended;
1490 i: Integer;
1491 wallHitFlag: Boolean = false;
1492 wallHitX: Integer = 0;
1493 wallHitY: Integer = 0;
1494 didHit: Boolean = false;
1495 {$IF DEFINED(D2F_DEBUG)}
1496 stt: UInt64;
1497 {$ENDIF}
1498 mit: PMonster;
1499 it: TMonsterGrid.Iter;
1500 begin
1501 (*
1502 if not gwep_debug_fast_trace then
1503 begin
1504 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1505 exit;
1506 end;
1507 *)
1509 if (xd = 0) and (yd = 0) then exit;
1511 if (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1512 spawnerPlr := g_Player_Get(SpawnerUID);
1514 //wgunMonHash.reset(); //FIXME: clear hash on level change
1515 wgunHitHeap.clear();
1516 wgunHitTimeUsed := 0;
1518 a := GetAngle(x, y, xd, yd)+180;
1520 SinCos(DegToRad(-a), s, c);
1522 if Abs(s) < 0.01 then s := 0;
1523 if Abs(c) < 0.01 then c := 0;
1525 x0 := x;
1526 y0 := y;
1527 x2 := x+Round(c*gMapInfo.Width);
1528 y2 := y+Round(s*gMapInfo.Width);
1530 dx := x2-x;
1531 dy := y2-y;
1533 if (dx > 0) then xi := 1 else if (dx < 0) then xi := -1 else xi := 0;
1534 if (dy > 0) then yi := 1 else if (dy < 0) then yi := -1 else yi := 0;
1536 {$IF DEFINED(D2F_DEBUG)}
1537 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x, y, x2, y2]), TMsgType.Notify);
1538 stt := getTimeMicro();
1539 {$ENDIF}
1541 wallHitFlag := (g_Map_traceToNearestWall(x, y, x2, y2, @wallHitX, @wallHitY) <> nil);
1542 if wallHitFlag then
1543 begin
1544 x2 := wallHitX;
1545 y2 := wallHitY;
1546 wallDistSq := distanceSq(x, y, wallHitX, wallHitY);
1547 end
1548 else
1549 begin
1550 wallHitX := x2;
1551 wallHitY := y2;
1552 end;
1554 if playerPossibleHit() then exit; // instant hit
1556 // collect monsters
1557 //g_Mons_AlongLine(x, y, x2, y2, sqchecker);
1559 it := monsGrid.forEachAlongLine(x, y, x2, y2, -1);
1560 for mit in it do sqchecker(mit^);
1561 it.release();
1563 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1564 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1565 while (wgunHitHeap.count > 0) do
1566 begin
1567 // has some entities to check, do it
1568 i := wgunHitHeap.front;
1569 wgunHitHeap.popFront();
1570 // hitpoint
1571 xe := wgunHitTime[i].x;
1572 ye := wgunHitTime[i].y;
1573 // check if it is not behind the wall
1574 if (wgunHitTime[i].mon <> nil) then
1575 begin
1576 didHit := doMonsterHit(wgunHitTime[i].mon, xe, ye);
1577 end
1578 else
1579 begin
1580 didHit := doPlayerHit(wgunHitTime[i].plridx, xe, ye);
1581 end;
1582 if didHit then
1583 begin
1584 // need new coords for trigger
1585 wallHitX := xe;
1586 wallHitY := ye;
1587 wallHitFlag := false; // no sparks
1588 break;
1589 end;
1590 end;
1592 // need sparks?
1593 if wallHitFlag then
1594 begin
1595 {$IF DEFINED(D2F_DEBUG)}
1596 stt := getTimeMicro()-stt;
1597 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt)]), TMsgType.Notify);
1598 {$ENDIF}
1599 g_GFX_Spark(wallHitX, wallHitY, 2+Random(2), 180+a, 0, 0);
1600 if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(wallHitX, wallHitY, 180+a, NET_GFX_SPARK);
1601 end
1602 else
1603 begin
1604 {$IF DEFINED(D2F_DEBUG)}
1605 stt := getTimeMicro()-stt;
1606 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt)]), TMsgType.Notify);
1607 {$ENDIF}
1608 end;
1610 if CheckTrigger and g_Game_IsServer then g_Triggers_PressL(X, Y, wallHitX, wallHitY, SpawnerUID, ACTIVATE_SHOT);
1611 end;
1614 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1615 var
1616 obj: TObj;
1617 begin
1618 obj.X := X;
1619 obj.Y := Y;
1620 obj.rect.X := 0;
1621 obj.rect.Y := 0;
1622 obj.rect.Width := 39;
1623 obj.rect.Height := 52;
1624 obj.Vel.X := 0;
1625 obj.Vel.Y := 0;
1626 obj.Accel.X := 0;
1627 obj.Accel.Y := 0;
1629 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1630 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1631 else
1632 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1633 end;
1635 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1636 var
1637 obj: TObj;
1638 begin
1639 obj.X := X;
1640 obj.Y := Y;
1641 obj.rect.X := 0;
1642 obj.rect.Y := 0;
1643 obj.rect.Width := 32;
1644 obj.rect.Height := 52;
1645 obj.Vel.X := 0;
1646 obj.Vel.Y := 0;
1647 obj.Accel.X := 0;
1648 obj.Accel.Y := 0;
1650 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1651 end;
1653 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1654 Silent: Boolean = False);
1655 var
1656 find_id: DWORD;
1657 dx, dy: Integer;
1658 begin
1659 if WID < 0 then
1660 find_id := FindShot()
1661 else
1662 begin
1663 find_id := WID;
1664 if Integer(find_id) >= High(Shots) then
1665 SetLength(Shots, find_id + 64)
1666 end;
1668 with Shots[find_id] do
1669 begin
1670 g_Obj_Init(@Obj);
1672 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1673 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1675 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1676 dy := -(Obj.Rect.Height div 2);
1678 ShotType := WEAPON_ROCKETLAUNCHER;
1679 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1681 Animation := nil;
1682 triggers := nil;
1683 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1684 end;
1686 Shots[find_id].SpawnerUID := SpawnerUID;
1688 if not Silent then
1689 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1690 end;
1692 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1693 WID: Integer = -1; Silent: Boolean = False);
1694 var
1695 find_id, FramesID: DWORD;
1696 dx, dy: Integer;
1697 begin
1698 if WID < 0 then
1699 find_id := FindShot()
1700 else
1701 begin
1702 find_id := WID;
1703 if Integer(find_id) >= High(Shots) then
1704 SetLength(Shots, find_id + 64)
1705 end;
1707 with Shots[find_id] do
1708 begin
1709 g_Obj_Init(@Obj);
1711 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1712 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1714 dx := -(Obj.Rect.Width div 2);
1715 dy := -(Obj.Rect.Height div 2);
1717 ShotType := WEAPON_SKEL_FIRE;
1718 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1720 triggers := nil;
1721 target := TargetUID;
1722 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1723 Animation := TAnimation.Create(FramesID, True, 5);
1724 end;
1726 Shots[find_id].SpawnerUID := SpawnerUID;
1728 if not Silent then
1729 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1730 end;
1732 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1733 Silent: Boolean = False);
1734 var
1735 find_id, FramesID: DWORD;
1736 dx, dy: Integer;
1737 begin
1738 if WID < 0 then
1739 find_id := FindShot()
1740 else
1741 begin
1742 find_id := WID;
1743 if Integer(find_id) >= High(Shots) then
1744 SetLength(Shots, find_id + 64);
1745 end;
1747 with Shots[find_id] do
1748 begin
1749 g_Obj_Init(@Obj);
1751 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1752 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1754 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1755 dy := -(Obj.Rect.Height div 2);
1757 ShotType := WEAPON_PLASMA;
1758 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1760 triggers := nil;
1761 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1762 Animation := TAnimation.Create(FramesID, True, 5);
1763 end;
1765 Shots[find_id].SpawnerUID := SpawnerUID;
1767 if not Silent then
1768 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1769 end;
1771 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1772 Silent: Boolean = False);
1773 var
1774 find_id: DWORD;
1775 dx, dy: Integer;
1776 begin
1777 if WID < 0 then
1778 find_id := FindShot()
1779 else
1780 begin
1781 find_id := WID;
1782 if Integer(find_id) >= High(Shots) then
1783 SetLength(Shots, find_id + 64);
1784 end;
1786 with Shots[find_id] do
1787 begin
1788 g_Obj_Init(@Obj);
1790 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1791 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1793 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1794 dy := -(Obj.Rect.Height div 2);
1796 ShotType := WEAPON_FLAMETHROWER;
1797 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1799 triggers := nil;
1800 Animation := nil;
1801 TextureID := 0;
1802 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1803 end;
1805 Shots[find_id].SpawnerUID := SpawnerUID;
1807 // if not Silent then
1808 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1809 end;
1811 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1812 Silent: Boolean = False);
1813 var
1814 find_id, FramesID: DWORD;
1815 dx, dy: Integer;
1816 begin
1817 if WID < 0 then
1818 find_id := FindShot()
1819 else
1820 begin
1821 find_id := WID;
1822 if Integer(find_id) >= High(Shots) then
1823 SetLength(Shots, find_id + 64)
1824 end;
1826 with Shots[find_id] do
1827 begin
1828 g_Obj_Init(@Obj);
1830 Obj.Rect.Width := 16;
1831 Obj.Rect.Height := 16;
1833 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1834 dy := -(Obj.Rect.Height div 2);
1836 ShotType := WEAPON_IMP_FIRE;
1837 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1839 triggers := nil;
1840 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1841 Animation := TAnimation.Create(FramesID, True, 4);
1842 end;
1844 Shots[find_id].SpawnerUID := SpawnerUID;
1846 if not Silent then
1847 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1848 end;
1850 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1851 Silent: Boolean = False);
1852 var
1853 find_id, FramesID: DWORD;
1854 dx, dy: Integer;
1855 begin
1856 if WID < 0 then
1857 find_id := FindShot()
1858 else
1859 begin
1860 find_id := WID;
1861 if Integer(find_id) >= High(Shots) then
1862 SetLength(Shots, find_id + 64)
1863 end;
1865 with Shots[find_id] do
1866 begin
1867 g_Obj_Init(@Obj);
1869 Obj.Rect.Width := 16;
1870 Obj.Rect.Height := 16;
1872 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1873 dy := -(Obj.Rect.Height div 2);
1875 ShotType := WEAPON_CACO_FIRE;
1876 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1878 triggers := nil;
1879 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1880 Animation := TAnimation.Create(FramesID, True, 4);
1881 end;
1883 Shots[find_id].SpawnerUID := SpawnerUID;
1885 if not Silent then
1886 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1887 end;
1889 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1890 Silent: Boolean = False);
1891 var
1892 find_id, FramesID: DWORD;
1893 dx, dy: Integer;
1894 begin
1895 if WID < 0 then
1896 find_id := FindShot()
1897 else
1898 begin
1899 find_id := WID;
1900 if Integer(find_id) >= High(Shots) then
1901 SetLength(Shots, find_id + 64)
1902 end;
1904 with Shots[find_id] do
1905 begin
1906 g_Obj_Init(@Obj);
1908 Obj.Rect.Width := 32;
1909 Obj.Rect.Height := 16;
1911 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1912 dy := -(Obj.Rect.Height div 2);
1914 ShotType := WEAPON_BARON_FIRE;
1915 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1917 triggers := nil;
1918 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1919 Animation := TAnimation.Create(FramesID, True, 4);
1920 end;
1922 Shots[find_id].SpawnerUID := SpawnerUID;
1924 if not Silent then
1925 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1926 end;
1928 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1929 Silent: Boolean = False);
1930 var
1931 find_id, FramesID: DWORD;
1932 dx, dy: Integer;
1933 begin
1934 if WID < 0 then
1935 find_id := FindShot()
1936 else
1937 begin
1938 find_id := WID;
1939 if Integer(find_id) >= High(Shots) then
1940 SetLength(Shots, find_id + 64)
1941 end;
1943 with Shots[find_id] do
1944 begin
1945 g_Obj_Init(@Obj);
1947 Obj.Rect.Width := 16;
1948 Obj.Rect.Height := 16;
1950 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1951 dy := -(Obj.Rect.Height div 2);
1953 ShotType := WEAPON_BSP_FIRE;
1954 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1956 triggers := nil;
1958 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1959 Animation := TAnimation.Create(FramesID, True, 4);
1960 end;
1962 Shots[find_id].SpawnerUID := SpawnerUID;
1964 if not Silent then
1965 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1966 end;
1968 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1969 Silent: Boolean = False);
1970 var
1971 find_id, FramesID: DWORD;
1972 dx, dy: Integer;
1973 begin
1974 if WID < 0 then
1975 find_id := FindShot()
1976 else
1977 begin
1978 find_id := WID;
1979 if Integer(find_id) >= High(Shots) then
1980 SetLength(Shots, find_id + 64)
1981 end;
1983 with Shots[find_id] do
1984 begin
1985 g_Obj_Init(@Obj);
1987 Obj.Rect.Width := 32;
1988 Obj.Rect.Height := 32;
1990 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1991 dy := -(Obj.Rect.Height div 2);
1993 ShotType := WEAPON_MANCUB_FIRE;
1994 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1996 triggers := nil;
1998 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1999 Animation := TAnimation.Create(FramesID, True, 4);
2000 end;
2002 Shots[find_id].SpawnerUID := SpawnerUID;
2004 if not Silent then
2005 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
2006 end;
2008 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
2009 Silent: Boolean = False);
2010 var
2011 find_id, FramesID: DWORD;
2012 dx, dy: Integer;
2013 begin
2014 if WID < 0 then
2015 find_id := FindShot()
2016 else
2017 begin
2018 find_id := WID;
2019 if Integer(find_id) >= High(Shots) then
2020 SetLength(Shots, find_id + 64)
2021 end;
2023 with Shots[find_id] do
2024 begin
2025 g_Obj_Init(@Obj);
2027 Obj.Rect.Width := SHOT_BFG_WIDTH;
2028 Obj.Rect.Height := SHOT_BFG_HEIGHT;
2030 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
2031 dy := -(Obj.Rect.Height div 2);
2033 ShotType := WEAPON_BFG;
2034 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
2036 triggers := nil;
2037 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
2038 Animation := TAnimation.Create(FramesID, True, 6);
2039 end;
2041 Shots[find_id].SpawnerUID := SpawnerUID;
2043 if not Silent then
2044 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
2045 end;
2047 procedure g_Weapon_bfghit(x, y: Integer);
2048 var
2049 ID: DWORD;
2050 Anim: TAnimation;
2051 begin
2052 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
2053 begin
2054 Anim := TAnimation.Create(ID, False, 4);
2055 g_GFX_OnceAnim(x-32, y-32, Anim);
2056 Anim.Free();
2057 end;
2058 end;
2060 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
2061 Silent: Boolean = False);
2062 begin
2063 if not Silent then
2064 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
2066 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
2067 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
2068 begin
2069 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
2070 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
2071 end;
2072 end;
2074 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2075 Silent: Boolean = False);
2076 begin
2077 if not Silent then
2078 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
2080 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
2081 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
2082 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
2083 begin
2084 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
2085 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
2086 end;
2087 end;
2089 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2090 Silent: Boolean = False);
2091 var
2092 i, j: Integer;
2093 begin
2094 if not Silent then
2095 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
2097 for i := 0 to 9 do
2098 begin
2099 j := Random(17)-8; // -8 .. 8
2100 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
2101 end;
2102 end;
2104 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2105 Silent: Boolean = False);
2106 var
2107 a, i, j: Integer;
2108 begin
2109 if not Silent then
2110 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
2112 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
2113 for i := 0 to a do
2114 begin
2115 j := Random(41)-20; // -20 .. 20
2116 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
2117 end;
2118 end;
2120 procedure g_Weapon_PreUpdate();
2121 var
2122 i: Integer;
2123 begin
2124 if Shots = nil then Exit;
2125 for i := 0 to High(Shots) do
2126 if Shots[i].ShotType <> 0 then
2127 begin
2128 Shots[i].Obj.oldX := Shots[i].Obj.X;
2129 Shots[i].Obj.oldY := Shots[i].Obj.Y;
2130 end;
2131 end;
2133 procedure g_Weapon_Update();
2134 var
2135 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
2136 _id: DWORD;
2137 Anim: TAnimation;
2138 t: DWArray;
2139 st: Word;
2140 s: String;
2141 o: TObj;
2142 spl: Boolean;
2143 Loud: Boolean;
2144 tcx, tcy: Integer;
2145 begin
2146 if Shots = nil then
2147 Exit;
2149 for i := 0 to High(Shots) do
2150 begin
2151 if Shots[i].ShotType = 0 then
2152 Continue;
2154 Loud := True;
2156 with Shots[i] do
2157 begin
2158 Timeout := Timeout - 1;
2159 oldvx := Obj.Vel.X;
2160 oldvy := Obj.Vel.Y;
2161 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2162 if (Stopped = 0) and g_Game_IsServer then
2163 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
2164 SpawnerUID, ACTIVATE_SHOT, triggers)
2165 else
2166 t := nil;
2168 if t <> nil then
2169 begin
2170 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2171 if triggers = nil then
2172 triggers := t
2173 else
2174 begin
2175 h := High(t);
2177 for a := 0 to h do
2178 if not InDWArray(t[a], triggers) then
2179 begin
2180 SetLength(triggers, Length(triggers)+1);
2181 triggers[High(triggers)] := t[a];
2182 end;
2183 end;
2184 end;
2186 // Àíèìàöèÿ ñíàðÿäà:
2187 if Animation <> nil then
2188 Animation.Update();
2190 // Äâèæåíèå:
2191 spl := (ShotType <> WEAPON_PLASMA) and
2192 (ShotType <> WEAPON_BFG) and
2193 (ShotType <> WEAPON_BSP_FIRE) and
2194 (ShotType <> WEAPON_FLAMETHROWER);
2196 if Stopped = 0 then
2197 begin
2198 st := g_Obj_Move_Projectile(@Obj, False, spl);
2199 end
2200 else
2201 begin
2202 st := 0;
2203 end;
2204 positionChanged(); // this updates spatial accelerators
2206 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
2207 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
2208 begin
2209 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2210 ShotType := 0;
2211 Animation.Free();
2212 Continue;
2213 end;
2215 cx := Obj.X + (Obj.Rect.Width div 2);
2216 cy := Obj.Y + (Obj.Rect.Height div 2);
2218 case ShotType of
2219 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2220 begin
2221 // Âûëåòåëà èç âîäû:
2222 if WordBool(st and MOVE_HITAIR) then
2223 g_Obj_SetSpeed(@Obj, 12);
2225 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2226 if WordBool(st and MOVE_INWATER) then
2227 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
2228 Obj.Y+(Obj.Rect.Height div 2),
2229 1+Random(3), 16, 16)
2230 else
2231 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
2232 begin
2233 Anim := TAnimation.Create(_id, False, 3);
2234 Anim.Alpha := 150;
2235 g_GFX_OnceAnim(Obj.X-14+Random(9),
2236 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
2237 Anim, ONCEANIM_SMOKE);
2238 Anim.Free();
2239 end;
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
2244 (Timeout < 1) then
2245 begin
2246 Obj.Vel.X := 0;
2247 Obj.Vel.Y := 0;
2249 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
2251 if ShotType = WEAPON_SKEL_FIRE then
2252 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2253 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2254 begin
2255 Anim := TAnimation.Create(TextureID, False, 8);
2256 Anim.Blending := False;
2257 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
2258 g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
2259 Anim.Free();
2260 end;
2261 end
2262 else
2263 begin // Âçðûâ Ðàêåòû
2264 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2265 begin
2266 Anim := TAnimation.Create(TextureID, False, 6);
2267 Anim.Blending := False;
2268 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2269 g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
2270 Anim.Free();
2271 end;
2272 end;
2274 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2276 ShotType := 0;
2277 end;
2279 if ShotType = WEAPON_SKEL_FIRE then
2280 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2281 if GetPos(target, @o) then
2282 throw(i, Obj.X, Obj.Y,
2283 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
2284 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
2285 12);
2286 end;
2287 end;
2289 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2290 begin
2291 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2292 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
2293 begin
2294 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
2295 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
2296 ShotType := 0;
2297 Continue;
2298 end;
2300 // Âåëè÷èíà óðîíà:
2301 if (ShotType = WEAPON_PLASMA) and
2302 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
2303 a := 10
2304 else
2305 a := 5;
2307 if ShotType = WEAPON_BSP_FIRE then
2308 a := 10;
2310 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2311 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2312 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
2313 (Timeout < 1) then
2314 begin
2315 if ShotType = WEAPON_PLASMA then
2316 s := 'FRAMES_EXPLODE_PLASMA'
2317 else
2318 s := 'FRAMES_EXPLODE_BSPFIRE';
2320 // Âçðûâ Ïëàçìû:
2321 if g_Frames_Get(TextureID, s) then
2322 begin
2323 Anim := TAnimation.Create(TextureID, False, 3);
2324 Anim.Blending := False;
2325 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2326 Anim.Free();
2327 g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
2328 end;
2330 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2332 ShotType := 0;
2333 end;
2334 end;
2336 WEAPON_FLAMETHROWER: // Îãíåìåò
2337 begin
2338 // Ñî âðåìåíåì óìèðàåò
2339 if (Timeout < 1) then
2340 begin
2341 ShotType := 0;
2342 Continue;
2343 end;
2344 // Ïîä âîäîé òîæå
2345 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
2346 begin
2347 if WordBool(st and MOVE_HITWATER) then
2348 begin
2349 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
2350 begin
2351 Anim := TAnimation.Create(_id, False, 3);
2352 Anim.Alpha := 0;
2353 tcx := Random(8);
2354 tcy := Random(8);
2355 g_GFX_OnceAnim(cx-4+tcx-(Anim.Width div 2),
2356 cy-4+tcy-(Anim.Height div 2),
2357 Anim, ONCEANIM_SMOKE);
2358 Anim.Free();
2359 end;
2360 end
2361 else
2362 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
2363 ShotType := 0;
2364 Continue;
2365 end;
2367 // Ãðàâèòàöèÿ
2368 if Stopped = 0 then
2369 Obj.Accel.Y := Obj.Accel.Y + 1;
2370 // Ïîïàëè â ñòåíó èëè â âîäó:
2371 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
2372 begin
2373 // Ïðèëèïàåì:
2374 Obj.Vel.X := 0;
2375 Obj.Vel.Y := 0;
2376 Obj.Accel.Y := 0;
2377 if WordBool(st and MOVE_HITWALL) then
2378 Stopped := MOVE_HITWALL
2379 else if WordBool(st and MOVE_HITLAND) then
2380 Stopped := MOVE_HITLAND
2381 else if WordBool(st and MOVE_HITCEIL) then
2382 Stopped := MOVE_HITCEIL;
2383 end;
2385 a := IfThen(Stopped = 0, 10, 1);
2386 // Åñëè â êîãî-òî ïîïàëè
2387 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
2388 begin
2389 // HIT_FLAME ñàì ïîäîææåò
2390 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2391 if Stopped = 0 then
2392 ShotType := 0;
2393 end;
2395 if Stopped = 0 then
2396 tf := 2
2397 else
2398 tf := 3;
2400 if (gTime mod LongWord(tf) = 0) then
2401 begin
2402 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
2403 Anim.Alpha := 0;
2404 case Stopped of
2405 MOVE_HITWALL: begin tcx := cx-4+Random(8); tcy := cy-12+Random(24); end;
2406 MOVE_HITLAND: begin tcx := cx-12+Random(24); tcy := cy-10+Random(8); end;
2407 MOVE_HITCEIL: begin tcx := cx-12+Random(24); tcy := cy+6+Random(8); end;
2408 else begin tcx := cx-4+Random(8); tcy := cy-4+Random(8); end;
2409 end;
2410 g_GFX_OnceAnim(tcx-(Anim.Width div 2), tcy-(Anim.Height div 2), Anim, ONCEANIM_SMOKE);
2411 Anim.Free();
2412 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2413 end;
2414 end;
2416 WEAPON_BFG: // BFG
2417 begin
2418 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2419 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
2420 begin
2421 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
2422 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
2423 ShotType := 0;
2424 Continue;
2425 end;
2427 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2428 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2429 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
2430 (Timeout < 1) then
2431 begin
2432 // Ëó÷è BFG:
2433 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
2435 // Âçðûâ BFG:
2436 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
2437 begin
2438 Anim := TAnimation.Create(TextureID, False, 6);
2439 Anim.Blending := False;
2440 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2441 Anim.Free();
2442 g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
2443 end;
2445 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2447 ShotType := 0;
2448 end;
2449 end;
2451 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2452 begin
2453 // Âûëåòåë èç âîäû:
2454 if WordBool(st and MOVE_HITAIR) then
2455 g_Obj_SetSpeed(@Obj, 16);
2457 // Âåëè÷èíà óðîíà:
2458 if ShotType = WEAPON_IMP_FIRE then
2459 a := 5
2460 else
2461 if ShotType = WEAPON_CACO_FIRE then
2462 a := 20
2463 else
2464 a := 40;
2466 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2467 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2468 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2469 (Timeout < 1) then
2470 begin
2471 if ShotType = WEAPON_IMP_FIRE then
2472 s := 'FRAMES_EXPLODE_IMPFIRE'
2473 else
2474 if ShotType = WEAPON_CACO_FIRE then
2475 s := 'FRAMES_EXPLODE_CACOFIRE'
2476 else
2477 s := 'FRAMES_EXPLODE_BARONFIRE';
2479 // Âçðûâ:
2480 if g_Frames_Get(TextureID, s) then
2481 begin
2482 Anim := TAnimation.Create(TextureID, False, 6);
2483 Anim.Blending := False;
2484 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2485 Anim.Free();
2486 end;
2488 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2490 ShotType := 0;
2491 end;
2492 end;
2494 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2495 begin
2496 // Âûëåòåë èç âîäû:
2497 if WordBool(st and MOVE_HITAIR) then
2498 g_Obj_SetSpeed(@Obj, 16);
2500 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2501 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2502 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2503 (Timeout < 1) then
2504 begin
2505 // Âçðûâ:
2506 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2507 begin
2508 Anim := TAnimation.Create(TextureID, False, 6);
2509 Anim.Blending := False;
2510 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2511 Anim.Free();
2512 end;
2514 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2516 ShotType := 0;
2517 end;
2518 end;
2519 end; // case ShotType of...
2521 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2522 if (ShotType = 0) then
2523 begin
2524 if gGameSettings.GameType = GT_SERVER then
2525 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2526 if Animation <> nil then
2527 begin
2528 Animation.Free();
2529 Animation := nil;
2530 end;
2531 end
2532 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2533 if gGameSettings.GameType = GT_SERVER then
2534 MH_SEND_UpdateShot(i);
2535 end;
2536 end;
2537 end;
2539 procedure g_Weapon_Draw();
2540 var
2541 i, fX, fY: Integer;
2542 a: SmallInt;
2543 p: TDFPoint;
2544 begin
2545 if Shots = nil then
2546 Exit;
2548 for i := 0 to High(Shots) do
2549 if Shots[i].ShotType <> 0 then
2550 with Shots[i] do
2551 begin
2552 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2553 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2554 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2555 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2556 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2557 else
2558 a := 0;
2560 Obj.lerp(gLerpFactor, fX, fY);
2561 p.X := Obj.Rect.Width div 2;
2562 p.Y := Obj.Rect.Height div 2;
2564 if Animation <> nil then
2565 begin
2566 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2567 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2568 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2569 Animation.DrawEx(fX, fY, TMirrorType.None, p, a)
2570 else
2571 Animation.Draw(fX, fY, TMirrorType.None);
2572 end
2573 else if TextureID <> 0 then
2574 begin
2575 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2576 e_DrawAdv(TextureID, fX, fY, 0, True, False, a, @p, TMirrorType.None)
2577 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2578 e_Draw(TextureID, fX, fY, 0, True, False);
2579 end;
2581 if g_debug_Frames then
2582 begin
2583 e_DrawQuad(Obj.X+Obj.Rect.X,
2584 Obj.Y+Obj.Rect.Y,
2585 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2586 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2587 0, 255, 0);
2588 end;
2589 end;
2590 end;
2592 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2593 var
2594 a: Integer;
2595 begin
2596 Result := False;
2598 if Shots = nil then
2599 Exit;
2601 for a := 0 to High(Shots) do
2602 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2603 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2604 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2605 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2606 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2607 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2608 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2609 begin
2610 Result := True;
2611 Exit;
2612 end;
2613 end;
2615 procedure g_Weapon_SaveState (st: TStream);
2616 var
2617 count, i, j: Integer;
2618 begin
2619 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2620 count := 0;
2621 for i := 0 to High(Shots) do if (Shots[i].ShotType <> 0) then Inc(count);
2623 // Êîëè÷åñòâî ñíàðÿäîâ
2624 utils.WriteInt(st, count);
2626 if (count = 0) then exit;
2628 for i := 0 to High(Shots) do
2629 begin
2630 if Shots[i].ShotType <> 0 then
2631 begin
2632 // Ñèãíàòóðà ñíàðÿäà
2633 utils.writeSign(st, 'SHOT');
2634 utils.writeInt(st, Byte(0)); // version
2635 // Òèï ñíàðÿäà
2636 utils.writeInt(st, Byte(Shots[i].ShotType));
2637 // Öåëü
2638 utils.writeInt(st, Word(Shots[i].Target));
2639 // UID ñòðåëÿâøåãî
2640 utils.writeInt(st, Word(Shots[i].SpawnerUID));
2641 // Ðàçìåð ïîëÿ Triggers
2642 utils.writeInt(st, Integer(Length(Shots[i].Triggers)));
2643 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2644 for j := 0 to Length(Shots[i].Triggers)-1 do utils.writeInt(st, LongWord(Shots[i].Triggers[j]));
2645 // Îáúåêò ñíàðÿäà
2646 Obj_SaveState(st, @Shots[i].Obj);
2647 // Êîñòûëèíà åáàíàÿ
2648 utils.writeInt(st, Byte(Shots[i].Stopped));
2649 end;
2650 end;
2651 end;
2653 procedure g_Weapon_LoadState (st: TStream);
2654 var
2655 count, tc, i, j: Integer;
2656 dw: LongWord;
2657 begin
2658 if (st = nil) then exit;
2660 // Êîëè÷åñòâî ñíàðÿäîâ
2661 count := utils.readLongInt(st);
2662 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid shots counter');
2664 SetLength(Shots, count);
2666 if (count = 0) then exit;
2668 for i := 0 to count-1 do
2669 begin
2670 // Ñèãíàòóðà ñíàðÿäà
2671 if not utils.checkSign(st, 'SHOT') then raise XStreamError.Create('invalid shot signature');
2672 if (utils.readByte(st) <> 0) then raise XStreamError.Create('invalid shot version');
2673 // Òèï ñíàðÿäà:
2674 Shots[i].ShotType := utils.readByte(st);
2675 // Öåëü
2676 Shots[i].Target := utils.readWord(st);
2677 // UID ñòðåëÿâøåãî
2678 Shots[i].SpawnerUID := utils.readWord(st);
2679 // Ðàçìåð ïîëÿ Triggers
2680 tc := utils.readLongInt(st);
2681 if (tc < 0) or (tc > 1024*1024) then raise XStreamError.Create('invalid shot triggers counter');
2682 SetLength(Shots[i].Triggers, tc);
2683 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2684 for j := 0 to tc-1 do Shots[i].Triggers[j] := utils.readLongWord(st);
2685 // Îáúåêò ïðåäìåòà
2686 Obj_LoadState(@Shots[i].Obj, st);
2687 // Êîñòûëèíà åáàíàÿ
2688 Shots[i].Stopped := utils.readByte(st);
2690 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2691 Shots[i].TextureID := DWORD(-1);
2692 Shots[i].Animation := nil;
2694 case Shots[i].ShotType of
2695 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2696 begin
2697 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2698 end;
2699 WEAPON_PLASMA:
2700 begin
2701 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2702 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2703 end;
2704 WEAPON_BFG:
2705 begin
2706 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2707 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2708 end;
2709 WEAPON_IMP_FIRE:
2710 begin
2711 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2712 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2713 end;
2714 WEAPON_BSP_FIRE:
2715 begin
2716 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2717 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2718 end;
2719 WEAPON_CACO_FIRE:
2720 begin
2721 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2722 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2723 end;
2724 WEAPON_BARON_FIRE:
2725 begin
2726 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2727 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2728 end;
2729 WEAPON_MANCUB_FIRE:
2730 begin
2731 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2732 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2733 end;
2734 end;
2735 end;
2736 end;
2738 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2739 var
2740 cx, cy: Integer;
2741 Anim: TAnimation;
2742 s: string;
2743 begin
2744 if Shots = nil then
2745 Exit;
2746 if (I > High(Shots)) or (I < 0) then Exit;
2748 with Shots[I] do
2749 begin
2750 if ShotType = 0 then Exit;
2751 Obj.X := X;
2752 Obj.Y := Y;
2753 cx := Obj.X + (Obj.Rect.Width div 2);
2754 cy := Obj.Y + (Obj.Rect.Height div 2);
2756 case ShotType of
2757 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2758 begin
2759 if Loud then
2760 begin
2761 if ShotType = WEAPON_SKEL_FIRE then
2762 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2763 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2764 begin
2765 Anim := TAnimation.Create(TextureID, False, 8);
2766 Anim.Blending := False;
2767 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2768 Anim.Free();
2769 end;
2770 end
2771 else
2772 begin // Âçðûâ Ðàêåòû
2773 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2774 begin
2775 Anim := TAnimation.Create(TextureID, False, 6);
2776 Anim.Blending := False;
2777 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2778 Anim.Free();
2779 end;
2780 end;
2781 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2782 end;
2783 end;
2785 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2786 begin
2787 if ShotType = WEAPON_PLASMA then
2788 s := 'FRAMES_EXPLODE_PLASMA'
2789 else
2790 s := 'FRAMES_EXPLODE_BSPFIRE';
2792 if g_Frames_Get(TextureID, s) and loud then
2793 begin
2794 Anim := TAnimation.Create(TextureID, False, 3);
2795 Anim.Blending := False;
2796 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2797 Anim.Free();
2799 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2800 end;
2801 end;
2803 WEAPON_BFG: // BFG
2804 begin
2805 // Âçðûâ BFG:
2806 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2807 begin
2808 Anim := TAnimation.Create(TextureID, False, 6);
2809 Anim.Blending := False;
2810 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2811 Anim.Free();
2813 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2814 end;
2815 end;
2817 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2818 begin
2819 if ShotType = WEAPON_IMP_FIRE then
2820 s := 'FRAMES_EXPLODE_IMPFIRE'
2821 else
2822 if ShotType = WEAPON_CACO_FIRE then
2823 s := 'FRAMES_EXPLODE_CACOFIRE'
2824 else
2825 s := 'FRAMES_EXPLODE_BARONFIRE';
2827 if g_Frames_Get(TextureID, s) and Loud then
2828 begin
2829 Anim := TAnimation.Create(TextureID, False, 6);
2830 Anim.Blending := False;
2831 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2832 Anim.Free();
2834 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2835 end;
2836 end;
2838 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2839 begin
2840 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2841 begin
2842 Anim := TAnimation.Create(TextureID, False, 6);
2843 Anim.Blending := False;
2844 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2845 Anim.Free();
2847 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2848 end;
2849 end;
2850 end; // case ShotType of...
2852 ShotType := 0;
2853 Animation.Free();
2854 end;
2855 end;
2858 procedure g_Weapon_AddDynLights();
2859 var
2860 i: Integer;
2861 begin
2862 if Shots = nil then Exit;
2863 for i := 0 to High(Shots) do
2864 begin
2865 if Shots[i].ShotType = 0 then continue;
2866 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2867 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2868 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2869 (Shots[i].ShotType = WEAPON_SKEL_FIRE) or
2870 (Shots[i].ShotType = WEAPON_IMP_FIRE) or
2871 (Shots[i].ShotType = WEAPON_CACO_FIRE) or
2872 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2873 (Shots[i].ShotType = WEAPON_BSP_FIRE) or
2874 (Shots[i].ShotType = WEAPON_PLASMA) or
2875 (Shots[i].ShotType = WEAPON_BFG) or
2876 (Shots[i].ShotType = WEAPON_FLAMETHROWER) or
2877 false then
2878 begin
2879 if (Shots[i].ShotType = WEAPON_PLASMA) then
2880 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)
2881 else if (Shots[i].ShotType = WEAPON_BFG) then
2882 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)
2883 else if (Shots[i].ShotType = WEAPON_FLAMETHROWER) then
2884 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)
2885 else
2886 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);
2887 end;
2888 end;
2889 end;
2892 procedure TShot.positionChanged (); begin end;
2895 end.