DEADSOFTWARE

game: fix monster projectiles in coop
[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 (g_GetUIDType(SpawnerUID) <> UID_PLAYER) or
899 LongBool(gGameSettings.Options and (GAME_OPTION_TEAMDAMAGE or GAME_OPTION_TEAMHITPROJECTILE)) then
900 begin
901 if PlayerHit() then
902 begin
903 Result := 1;
904 Exit;
905 end;
906 end;
907 end;
909 // Äåçìàò÷:
910 GM_DM:
911 begin
912 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
913 if PlayerHit() then
914 begin
915 Result := 1;
916 Exit;
917 end;
919 if MonsterHit() then
920 begin
921 Result := 2;
922 Exit;
923 end;
924 end;
926 // Êîìàíäíûå:
927 GM_TDM, GM_CTF:
928 begin
929 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
930 if PlayerHit(2) then
931 begin
932 Result := 1;
933 Exit;
934 end;
936 // Ïîòîì ìîíñòðîâ
937 if MonsterHit() then
938 begin
939 Result := 2;
940 Exit;
941 end;
943 // È â êîíöå ñâîèõ èãðîêîâ, íî òîëüêî åñëè ïîëîæåíî
944 // (èëè friendlyfire, èëè friendly_hit_projectile)
945 if LongBool(gGameSettings.Options and (GAME_OPTION_TEAMDAMAGE or GAME_OPTION_TEAMHITPROJECTILE)) then
946 begin
947 if PlayerHit(1) then
948 begin
949 Result := 1;
950 Exit;
951 end;
952 end;
953 end;
955 end;
956 end;
958 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
959 begin
960 Result := False;
962 case g_GetUIDType(UID) of
963 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
964 UID_MONSTER: Result := HitMonster(g_Monsters_ByUID(UID), d, 0, 0, SpawnerUID, t);
965 else Exit;
966 end;
967 end;
969 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
970 var
971 r: Integer; // squared radius
973 function monsExCheck (mon: TMonster): Boolean;
974 var
975 dx, dy, mm: Integer;
976 begin
977 result := false; // don't stop
978 begin
979 dx := mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-X;
980 dy := mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-Y;
982 if dx > 1000 then dx := 1000;
983 if dy > 1000 then dy := 1000;
985 if (dx*dx+dy*dy < r) then
986 begin
987 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
988 //e_WriteLog(Format('explo monster #%d: x=%d; y=%d; rad=%d; dx=%d; dy=%d', [monidx, X, Y, rad, dx, dy]), MSG_NOTIFY);
990 mm := Max(abs(dx), abs(dy));
991 if mm = 0 then mm := 1;
993 if mon.alive then
994 begin
995 HitMonster(mon, ((mon.Obj.Rect.Width div 4)*10*(rad-mm)) div rad, 0, 0, SpawnerUID, HIT_ROCKET);
996 end;
998 mon.Push((dx*7) div mm, (dy*7) div mm);
999 end;
1000 end;
1001 end;
1003 var
1004 i, h, dx, dy, m, mm: Integer;
1005 _angle: SmallInt;
1006 begin
1007 result := false;
1009 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
1011 r := rad*rad;
1013 h := High(gPlayers);
1015 if h <> -1 then
1016 for i := 0 to h do
1017 if (gPlayers[i] <> nil) and gPlayers[i].alive then
1018 with gPlayers[i] do
1019 begin
1020 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1021 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1023 if dx > 1000 then dx := 1000;
1024 if dy > 1000 then dy := 1000;
1026 if dx*dx+dy*dy < r then
1027 begin
1028 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
1029 // PLAYER_RECT.Width, PLAYER_RECT.Height);
1031 mm := Max(abs(dx), abs(dy));
1032 if mm = 0 then mm := 1;
1034 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
1035 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
1036 end;
1037 end;
1039 //g_Mons_ForEach(monsExCheck);
1040 g_Mons_ForEachAt(X-(rad+32), Y-(rad+32), (rad+32)*2, (rad+32)*2, monsExCheck);
1042 h := High(gCorpses);
1044 if gAdvCorpses and (h <> -1) then
1045 for i := 0 to h do
1046 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
1047 with gCorpses[i] do
1048 begin
1049 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1050 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1052 if dx > 1000 then dx := 1000;
1053 if dy > 1000 then dy := 1000;
1055 if dx*dx+dy*dy < r then
1056 begin
1057 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
1058 Obj.Rect.Width, Obj.Rect.Height);
1060 mm := Max(abs(dx), abs(dy));
1061 if mm = 0 then mm := 1;
1063 Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm);
1064 end;
1065 end;
1067 h := High(gGibs);
1069 if gAdvGibs and (h <> -1) then
1070 for i := 0 to h do
1071 if gGibs[i].alive then
1072 with gGibs[i] do
1073 begin
1074 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
1075 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
1077 if dx > 1000 then dx := 1000;
1078 if dy > 1000 then dy := 1000;
1080 if dx*dx+dy*dy < r then
1081 begin
1082 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
1083 Obj.Rect.Width, Obj.Rect.Height);
1084 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
1085 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
1087 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
1088 positionChanged(); // this updates spatial accelerators
1089 end;
1090 end;
1091 end;
1093 procedure g_Weapon_Init();
1094 begin
1095 CreateWaterMap();
1096 end;
1098 procedure g_Weapon_Free();
1099 var
1100 i: Integer;
1101 begin
1102 if Shots <> nil then
1103 begin
1104 for i := 0 to High(Shots) do
1105 if Shots[i].ShotType <> 0 then
1106 Shots[i].Animation.Free();
1108 Shots := nil;
1109 end;
1111 WaterMap := nil;
1112 end;
1114 procedure g_Weapon_LoadData();
1115 begin
1116 e_WriteLog('Loading weapons data...', TMsgType.Notify);
1118 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
1119 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
1120 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
1121 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
1122 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
1123 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
1124 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
1125 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
1126 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
1127 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
1128 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
1129 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
1130 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
1131 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
1132 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1133 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1134 g_Sound_CreateWADEx('SOUND_IGNITE', GameWAD+':SOUNDS\IGNITE');
1135 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1136 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1137 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1138 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1139 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1140 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1141 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1142 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1143 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1144 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD+':SOUNDS\STARTFLM');
1145 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD+':SOUNDS\STOPFLM');
1146 g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD+':SOUNDS\WORKFLM');
1147 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1148 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1149 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1150 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1151 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1152 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1153 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1155 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1156 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1157 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1158 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1159 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1160 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1161 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1162 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1163 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1164 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1165 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1166 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1167 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1168 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1169 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1170 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1171 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1172 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1173 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1174 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1175 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1177 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1178 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1180 //wgunMonHash := hashNewIntInt();
1181 wgunHitHeap := TBinaryHeapHitTimes.Create();
1182 end;
1184 procedure g_Weapon_FreeData();
1185 begin
1186 e_WriteLog('Releasing weapons data...', TMsgType.Notify);
1188 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1189 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1190 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1191 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1192 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1193 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1194 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1195 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1196 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1197 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1198 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1199 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1200 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1201 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1202 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1203 g_Sound_Delete('SOUND_FIRE');
1204 g_Sound_Delete('SOUND_IGNITE');
1205 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1206 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1207 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1208 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1209 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1210 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1211 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1212 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1213 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1214 g_Sound_Delete('SOUND_WEAPON_FLAMEON');
1215 g_Sound_Delete('SOUND_WEAPON_FLAMEOFF');
1216 g_Sound_Delete('SOUND_WEAPON_FLAMEWORK');
1217 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1218 g_Sound_Delete('SOUND_PLAYER_JETON');
1219 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1220 g_Sound_Delete('SOUND_PLAYER_CASING1');
1221 g_Sound_Delete('SOUND_PLAYER_CASING2');
1222 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1223 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1225 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1226 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1227 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1228 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1229 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1230 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1231 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1232 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1233 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1234 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1235 g_Frames_DeleteByName('FRAMES_BFGHIT');
1236 g_Frames_DeleteByName('FRAMES_FIRE');
1237 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1238 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1239 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1240 g_Frames_DeleteByName('FRAMES_SMOKE');
1241 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1242 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1243 end;
1246 function GunHitPlayer (X, Y: Integer; vx, vy: Integer; dmg: Integer; SpawnerUID: Word; AllowPush: Boolean): Boolean;
1247 var
1248 i: Integer;
1249 begin
1250 result := false;
1251 for i := 0 to High(gPlayers) do
1252 begin
1253 if (gPlayers[i] <> nil) and gPlayers[i].alive and gPlayers[i].Collide(X, Y) then
1254 begin
1255 if HitPlayer(gPlayers[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
1256 begin
1257 if AllowPush then gPlayers[i].Push(vx, vy);
1258 result := true;
1259 end;
1260 end;
1261 end;
1262 end;
1265 function GunHit (X, Y: Integer; vx, vy: Integer; dmg: Integer; SpawnerUID: Word; AllowPush: Boolean): Byte;
1267 function monsCheck (mon: TMonster): Boolean;
1268 begin
1269 result := false; // don't stop
1270 if HitMonster(mon, dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
1271 begin
1272 if AllowPush then mon.Push(vx, vy);
1273 result := true;
1274 end;
1275 end;
1277 begin
1278 result := 0;
1279 if GunHitPlayer(X, Y, vx, vy, dmg, SpawnerUID, AllowPush) then result := 1
1280 else if g_Mons_ForEachAliveAt(X, Y, 1, 1, monsCheck) then result := 2;
1281 end;
1284 (*
1285 procedure g_Weapon_gunOld(const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1286 var
1287 a: Integer;
1288 x2, y2: Integer;
1289 dx, dy: Integer;
1290 xe, ye: Integer;
1291 xi, yi: Integer;
1292 s, c: Extended;
1293 //vx, vy: Integer;
1294 xx, yy, d: Integer;
1295 i: Integer;
1296 t1, _collide: Boolean;
1297 w, h: Word;
1298 {$IF DEFINED(D2F_DEBUG)}
1299 stt: UInt64;
1300 showTime: Boolean = true;
1301 {$ENDIF}
1302 begin
1303 a := GetAngle(x, y, xd, yd)+180;
1305 SinCos(DegToRad(-a), s, c);
1307 if Abs(s) < 0.01 then s := 0;
1308 if Abs(c) < 0.01 then c := 0;
1310 x2 := x+Round(c*gMapInfo.Width);
1311 y2 := y+Round(s*gMapInfo.Width);
1313 t1 := gWalls <> nil;
1314 _collide := False;
1315 w := gMapInfo.Width;
1316 h := gMapInfo.Height;
1318 xe := 0;
1319 ye := 0;
1320 dx := x2-x;
1321 dy := y2-y;
1323 if (xd = 0) and (yd = 0) then Exit;
1325 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1326 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1328 dx := Abs(dx);
1329 dy := Abs(dy);
1331 if dx > dy then d := dx else d := dy;
1333 //blood vel, for Monster.Damage()
1334 //vx := (dx*10 div d)*xi;
1335 //vy := (dy*10 div d)*yi;
1337 {$IF DEFINED(D2F_DEBUG)}
1338 stt := getTimeMicro();
1339 {$ENDIF}
1341 xx := x;
1342 yy := y;
1344 for i := 1 to d do
1345 begin
1346 xe := xe+dx;
1347 ye := ye+dy;
1349 if xe > d then
1350 begin
1351 xe := xe-d;
1352 xx := xx+xi;
1353 end;
1355 if ye > d then
1356 begin
1357 ye := ye-d;
1358 yy := yy+yi;
1359 end;
1361 if (yy > h) or (yy < 0) then Break;
1362 if (xx > w) or (xx < 0) then Break;
1364 if t1 then
1365 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1366 begin
1367 _collide := True;
1368 {$IF DEFINED(D2F_DEBUG)}
1369 stt := getTimeMicro()-stt;
1370 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1371 showTime := false;
1372 {$ENDIF}
1373 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1374 if g_Game_IsServer and g_Game_IsNet then
1375 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1376 end;
1378 if not _collide then
1379 begin
1380 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1381 end;
1383 if _collide then Break;
1384 end;
1386 {$IF DEFINED(D2F_DEBUG)}
1387 if showTime then
1388 begin
1389 stt := getTimeMicro()-stt;
1390 e_WriteLog(Format('*** old trace time: %u microseconds', [LongWord(stt)]), MSG_NOTIFY);
1391 end;
1392 {$ENDIF}
1394 if CheckTrigger and g_Game_IsServer then
1395 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1396 end;
1397 *)
1400 //!!!FIXME!!!
1401 procedure g_Weapon_gun (const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1402 var
1403 x0, y0: Integer;
1404 x2, y2: Integer;
1405 xi, yi: Integer;
1406 wallDistSq: Integer = $3fffffff;
1407 spawnerPlr: TPlayer = nil;
1409 function doPlayerHit (idx: Integer; hx, hy: Integer): Boolean;
1410 begin
1411 result := false;
1412 if (idx < 0) or (idx > High(gPlayers)) then exit;
1413 if (gPlayers[idx] = nil) or not gPlayers[idx].alive then exit;
1414 if (spawnerPlr <> nil) then
1415 begin
1416 if ((gGameSettings.Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMDAMAGE)) = 0) and
1417 (spawnerPlr.Team <> TEAM_NONE) and (spawnerPlr.Team = gPlayers[idx].Team) then
1418 exit;
1419 end;
1420 result := HitPlayer(gPlayers[idx], dmg, (xi*v)*10, (yi*v)*10-3, SpawnerUID, HIT_SOME);
1421 if result and (v <> 0) then gPlayers[idx].Push((xi*v), (yi*v));
1422 {$IF DEFINED(D2F_DEBUG)}
1423 //if result then e_WriteLog(Format(' PLAYER #%d HIT', [idx]), MSG_NOTIFY);
1424 {$ENDIF}
1425 end;
1427 function doMonsterHit (mon: TMonster; hx, hy: Integer): Boolean;
1428 begin
1429 result := false;
1430 if (mon = nil) then exit;
1431 result := HitMonster(mon, dmg, (xi*v)*10, (yi*v)*10-3, SpawnerUID, HIT_SOME);
1432 if result and (v <> 0) then mon.Push((xi*v), (yi*v));
1433 {$IF DEFINED(D2F_DEBUG)}
1434 //if result then e_WriteLog(Format(' MONSTER #%u HIT', [LongWord(mon.UID)]), MSG_NOTIFY);
1435 {$ENDIF}
1436 end;
1438 // collect players along hitray
1439 // return `true` if instant hit was detected
1440 function playerPossibleHit (): Boolean;
1441 var
1442 i: Integer;
1443 px, py, pw, ph: Integer;
1444 inx, iny: Integer;
1445 distSq: Integer;
1446 plr: TPlayer;
1447 begin
1448 result := false;
1449 for i := 0 to High(gPlayers) do
1450 begin
1451 plr := gPlayers[i];
1452 if (plr <> nil) and plr.alive then
1453 begin
1454 plr.getMapBox(px, py, pw, ph);
1455 if lineAABBIntersects(x, y, x2, y2, px, py, pw, ph, inx, iny) then
1456 begin
1457 distSq := distanceSq(x, y, inx, iny);
1458 if (distSq = 0) then
1459 begin
1460 // contains
1461 if doPlayerHit(i, x, y) then begin result := true; exit; end;
1462 end
1463 else if (distSq < wallDistSq) then
1464 begin
1465 appendHitTimePlr(distSq, i, inx, iny);
1466 end;
1467 end;
1468 end;
1469 end;
1470 end;
1472 procedure sqchecker (mon: TMonster);
1473 var
1474 mx, my, mw, mh: Integer;
1475 inx, iny: Integer;
1476 distSq: Integer;
1477 begin
1478 mon.getMapBox(mx, my, mw, mh);
1479 if lineAABBIntersects(x0, y0, x2, y2, mx, my, mw, mh, inx, iny) then
1480 begin
1481 distSq := distanceSq(x0, y0, inx, iny);
1482 if (distSq < wallDistSq) then appendHitTimeMon(distSq, mon, inx, iny);
1483 end;
1484 end;
1486 var
1487 a: Integer;
1488 dx, dy: Integer;
1489 xe, ye: Integer;
1490 s, c: Extended;
1491 i: Integer;
1492 wallHitFlag: Boolean = false;
1493 wallHitX: Integer = 0;
1494 wallHitY: Integer = 0;
1495 didHit: Boolean = false;
1496 {$IF DEFINED(D2F_DEBUG)}
1497 stt: UInt64;
1498 {$ENDIF}
1499 mit: PMonster;
1500 it: TMonsterGrid.Iter;
1501 begin
1502 (*
1503 if not gwep_debug_fast_trace then
1504 begin
1505 g_Weapon_gunOld(x, y, xd, yd, v, dmg, SpawnerUID, CheckTrigger);
1506 exit;
1507 end;
1508 *)
1510 if (xd = 0) and (yd = 0) then exit;
1512 if (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1513 spawnerPlr := g_Player_Get(SpawnerUID);
1515 //wgunMonHash.reset(); //FIXME: clear hash on level change
1516 wgunHitHeap.clear();
1517 wgunHitTimeUsed := 0;
1519 a := GetAngle(x, y, xd, yd)+180;
1521 SinCos(DegToRad(-a), s, c);
1523 if Abs(s) < 0.01 then s := 0;
1524 if Abs(c) < 0.01 then c := 0;
1526 x0 := x;
1527 y0 := y;
1528 x2 := x+Round(c*gMapInfo.Width);
1529 y2 := y+Round(s*gMapInfo.Width);
1531 dx := x2-x;
1532 dy := y2-y;
1534 if (dx > 0) then xi := 1 else if (dx < 0) then xi := -1 else xi := 0;
1535 if (dy > 0) then yi := 1 else if (dy < 0) then yi := -1 else yi := 0;
1537 {$IF DEFINED(D2F_DEBUG)}
1538 e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x, y, x2, y2]), TMsgType.Notify);
1539 stt := getTimeMicro();
1540 {$ENDIF}
1542 wallHitFlag := (g_Map_traceToNearestWall(x, y, x2, y2, @wallHitX, @wallHitY) <> nil);
1543 if wallHitFlag then
1544 begin
1545 x2 := wallHitX;
1546 y2 := wallHitY;
1547 wallDistSq := distanceSq(x, y, wallHitX, wallHitY);
1548 end
1549 else
1550 begin
1551 wallHitX := x2;
1552 wallHitY := y2;
1553 end;
1555 if playerPossibleHit() then exit; // instant hit
1557 // collect monsters
1558 //g_Mons_AlongLine(x, y, x2, y2, sqchecker);
1560 it := monsGrid.forEachAlongLine(x, y, x2, y2, -1);
1561 for mit in it do sqchecker(mit^);
1562 it.release();
1564 // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
1565 // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
1566 while (wgunHitHeap.count > 0) do
1567 begin
1568 // has some entities to check, do it
1569 i := wgunHitHeap.front;
1570 wgunHitHeap.popFront();
1571 // hitpoint
1572 xe := wgunHitTime[i].x;
1573 ye := wgunHitTime[i].y;
1574 // check if it is not behind the wall
1575 if (wgunHitTime[i].mon <> nil) then
1576 begin
1577 didHit := doMonsterHit(wgunHitTime[i].mon, xe, ye);
1578 end
1579 else
1580 begin
1581 didHit := doPlayerHit(wgunHitTime[i].plridx, xe, ye);
1582 end;
1583 if didHit then
1584 begin
1585 // need new coords for trigger
1586 wallHitX := xe;
1587 wallHitY := ye;
1588 wallHitFlag := false; // no sparks
1589 break;
1590 end;
1591 end;
1593 // need sparks?
1594 if wallHitFlag then
1595 begin
1596 {$IF DEFINED(D2F_DEBUG)}
1597 stt := getTimeMicro()-stt;
1598 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt)]), TMsgType.Notify);
1599 {$ENDIF}
1600 g_GFX_Spark(wallHitX, wallHitY, 2+Random(2), 180+a, 0, 0);
1601 if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(wallHitX, wallHitY, 180+a, NET_GFX_SPARK);
1602 end
1603 else
1604 begin
1605 {$IF DEFINED(D2F_DEBUG)}
1606 stt := getTimeMicro()-stt;
1607 e_WriteLog(Format('*** new trace time: %u microseconds', [LongWord(stt)]), TMsgType.Notify);
1608 {$ENDIF}
1609 end;
1611 if CheckTrigger and g_Game_IsServer then g_Triggers_PressL(X, Y, wallHitX, wallHitY, SpawnerUID, ACTIVATE_SHOT);
1612 end;
1615 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1616 var
1617 obj: TObj;
1618 begin
1619 obj.X := X;
1620 obj.Y := Y;
1621 obj.rect.X := 0;
1622 obj.rect.Y := 0;
1623 obj.rect.Width := 39;
1624 obj.rect.Height := 52;
1625 obj.Vel.X := 0;
1626 obj.Vel.Y := 0;
1627 obj.Accel.X := 0;
1628 obj.Accel.Y := 0;
1630 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1631 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1632 else
1633 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1634 end;
1636 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1637 var
1638 obj: TObj;
1639 begin
1640 obj.X := X;
1641 obj.Y := Y;
1642 obj.rect.X := 0;
1643 obj.rect.Y := 0;
1644 obj.rect.Width := 32;
1645 obj.rect.Height := 52;
1646 obj.Vel.X := 0;
1647 obj.Vel.Y := 0;
1648 obj.Accel.X := 0;
1649 obj.Accel.Y := 0;
1651 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1652 end;
1654 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1655 Silent: Boolean = False);
1656 var
1657 find_id: DWORD;
1658 dx, dy: Integer;
1659 begin
1660 if WID < 0 then
1661 find_id := FindShot()
1662 else
1663 begin
1664 find_id := WID;
1665 if Integer(find_id) >= High(Shots) then
1666 SetLength(Shots, find_id + 64)
1667 end;
1669 with Shots[find_id] do
1670 begin
1671 g_Obj_Init(@Obj);
1673 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1674 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1676 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1677 dy := -(Obj.Rect.Height div 2);
1679 ShotType := WEAPON_ROCKETLAUNCHER;
1680 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1682 Animation := nil;
1683 triggers := nil;
1684 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1685 end;
1687 Shots[find_id].SpawnerUID := SpawnerUID;
1689 if not Silent then
1690 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1691 end;
1693 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1694 WID: Integer = -1; Silent: Boolean = False);
1695 var
1696 find_id, FramesID: DWORD;
1697 dx, dy: Integer;
1698 begin
1699 if WID < 0 then
1700 find_id := FindShot()
1701 else
1702 begin
1703 find_id := WID;
1704 if Integer(find_id) >= High(Shots) then
1705 SetLength(Shots, find_id + 64)
1706 end;
1708 with Shots[find_id] do
1709 begin
1710 g_Obj_Init(@Obj);
1712 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1713 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1715 dx := -(Obj.Rect.Width div 2);
1716 dy := -(Obj.Rect.Height div 2);
1718 ShotType := WEAPON_SKEL_FIRE;
1719 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1721 triggers := nil;
1722 target := TargetUID;
1723 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1724 Animation := TAnimation.Create(FramesID, True, 5);
1725 end;
1727 Shots[find_id].SpawnerUID := SpawnerUID;
1729 if not Silent then
1730 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1731 end;
1733 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1734 Silent: Boolean = False);
1735 var
1736 find_id, FramesID: DWORD;
1737 dx, dy: Integer;
1738 begin
1739 if WID < 0 then
1740 find_id := FindShot()
1741 else
1742 begin
1743 find_id := WID;
1744 if Integer(find_id) >= High(Shots) then
1745 SetLength(Shots, find_id + 64);
1746 end;
1748 with Shots[find_id] do
1749 begin
1750 g_Obj_Init(@Obj);
1752 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1753 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1755 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1756 dy := -(Obj.Rect.Height div 2);
1758 ShotType := WEAPON_PLASMA;
1759 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1761 triggers := nil;
1762 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1763 Animation := TAnimation.Create(FramesID, True, 5);
1764 end;
1766 Shots[find_id].SpawnerUID := SpawnerUID;
1768 if not Silent then
1769 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1770 end;
1772 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1773 Silent: Boolean = False);
1774 var
1775 find_id: DWORD;
1776 dx, dy: Integer;
1777 begin
1778 if WID < 0 then
1779 find_id := FindShot()
1780 else
1781 begin
1782 find_id := WID;
1783 if Integer(find_id) >= High(Shots) then
1784 SetLength(Shots, find_id + 64);
1785 end;
1787 with Shots[find_id] do
1788 begin
1789 g_Obj_Init(@Obj);
1791 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1792 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1794 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1795 dy := -(Obj.Rect.Height div 2);
1797 ShotType := WEAPON_FLAMETHROWER;
1798 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1800 triggers := nil;
1801 Animation := nil;
1802 TextureID := 0;
1803 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1804 end;
1806 Shots[find_id].SpawnerUID := SpawnerUID;
1808 // if not Silent then
1809 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1810 end;
1812 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1813 Silent: Boolean = False);
1814 var
1815 find_id, FramesID: DWORD;
1816 dx, dy: Integer;
1817 begin
1818 if WID < 0 then
1819 find_id := FindShot()
1820 else
1821 begin
1822 find_id := WID;
1823 if Integer(find_id) >= High(Shots) then
1824 SetLength(Shots, find_id + 64)
1825 end;
1827 with Shots[find_id] do
1828 begin
1829 g_Obj_Init(@Obj);
1831 Obj.Rect.Width := 16;
1832 Obj.Rect.Height := 16;
1834 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1835 dy := -(Obj.Rect.Height div 2);
1837 ShotType := WEAPON_IMP_FIRE;
1838 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1840 triggers := nil;
1841 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1842 Animation := TAnimation.Create(FramesID, True, 4);
1843 end;
1845 Shots[find_id].SpawnerUID := SpawnerUID;
1847 if not Silent then
1848 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1849 end;
1851 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1852 Silent: Boolean = False);
1853 var
1854 find_id, FramesID: DWORD;
1855 dx, dy: Integer;
1856 begin
1857 if WID < 0 then
1858 find_id := FindShot()
1859 else
1860 begin
1861 find_id := WID;
1862 if Integer(find_id) >= High(Shots) then
1863 SetLength(Shots, find_id + 64)
1864 end;
1866 with Shots[find_id] do
1867 begin
1868 g_Obj_Init(@Obj);
1870 Obj.Rect.Width := 16;
1871 Obj.Rect.Height := 16;
1873 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1874 dy := -(Obj.Rect.Height div 2);
1876 ShotType := WEAPON_CACO_FIRE;
1877 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1879 triggers := nil;
1880 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1881 Animation := TAnimation.Create(FramesID, True, 4);
1882 end;
1884 Shots[find_id].SpawnerUID := SpawnerUID;
1886 if not Silent then
1887 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1888 end;
1890 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1891 Silent: Boolean = False);
1892 var
1893 find_id, FramesID: DWORD;
1894 dx, dy: Integer;
1895 begin
1896 if WID < 0 then
1897 find_id := FindShot()
1898 else
1899 begin
1900 find_id := WID;
1901 if Integer(find_id) >= High(Shots) then
1902 SetLength(Shots, find_id + 64)
1903 end;
1905 with Shots[find_id] do
1906 begin
1907 g_Obj_Init(@Obj);
1909 Obj.Rect.Width := 32;
1910 Obj.Rect.Height := 16;
1912 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1913 dy := -(Obj.Rect.Height div 2);
1915 ShotType := WEAPON_BARON_FIRE;
1916 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1918 triggers := nil;
1919 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1920 Animation := TAnimation.Create(FramesID, True, 4);
1921 end;
1923 Shots[find_id].SpawnerUID := SpawnerUID;
1925 if not Silent then
1926 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1927 end;
1929 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1930 Silent: Boolean = False);
1931 var
1932 find_id, FramesID: DWORD;
1933 dx, dy: Integer;
1934 begin
1935 if WID < 0 then
1936 find_id := FindShot()
1937 else
1938 begin
1939 find_id := WID;
1940 if Integer(find_id) >= High(Shots) then
1941 SetLength(Shots, find_id + 64)
1942 end;
1944 with Shots[find_id] do
1945 begin
1946 g_Obj_Init(@Obj);
1948 Obj.Rect.Width := 16;
1949 Obj.Rect.Height := 16;
1951 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1952 dy := -(Obj.Rect.Height div 2);
1954 ShotType := WEAPON_BSP_FIRE;
1955 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1957 triggers := nil;
1959 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1960 Animation := TAnimation.Create(FramesID, True, 4);
1961 end;
1963 Shots[find_id].SpawnerUID := SpawnerUID;
1965 if not Silent then
1966 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1967 end;
1969 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1970 Silent: Boolean = False);
1971 var
1972 find_id, FramesID: DWORD;
1973 dx, dy: Integer;
1974 begin
1975 if WID < 0 then
1976 find_id := FindShot()
1977 else
1978 begin
1979 find_id := WID;
1980 if Integer(find_id) >= High(Shots) then
1981 SetLength(Shots, find_id + 64)
1982 end;
1984 with Shots[find_id] do
1985 begin
1986 g_Obj_Init(@Obj);
1988 Obj.Rect.Width := 32;
1989 Obj.Rect.Height := 32;
1991 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1992 dy := -(Obj.Rect.Height div 2);
1994 ShotType := WEAPON_MANCUB_FIRE;
1995 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1997 triggers := nil;
1999 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
2000 Animation := TAnimation.Create(FramesID, True, 4);
2001 end;
2003 Shots[find_id].SpawnerUID := SpawnerUID;
2005 if not Silent then
2006 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
2007 end;
2009 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
2010 Silent: Boolean = False);
2011 var
2012 find_id, FramesID: DWORD;
2013 dx, dy: Integer;
2014 begin
2015 if WID < 0 then
2016 find_id := FindShot()
2017 else
2018 begin
2019 find_id := WID;
2020 if Integer(find_id) >= High(Shots) then
2021 SetLength(Shots, find_id + 64)
2022 end;
2024 with Shots[find_id] do
2025 begin
2026 g_Obj_Init(@Obj);
2028 Obj.Rect.Width := SHOT_BFG_WIDTH;
2029 Obj.Rect.Height := SHOT_BFG_HEIGHT;
2031 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
2032 dy := -(Obj.Rect.Height div 2);
2034 ShotType := WEAPON_BFG;
2035 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
2037 triggers := nil;
2038 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
2039 Animation := TAnimation.Create(FramesID, True, 6);
2040 end;
2042 Shots[find_id].SpawnerUID := SpawnerUID;
2044 if not Silent then
2045 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
2046 end;
2048 procedure g_Weapon_bfghit(x, y: Integer);
2049 var
2050 ID: DWORD;
2051 Anim: TAnimation;
2052 begin
2053 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
2054 begin
2055 Anim := TAnimation.Create(ID, False, 4);
2056 g_GFX_OnceAnim(x-32, y-32, Anim);
2057 Anim.Free();
2058 end;
2059 end;
2061 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
2062 Silent: Boolean = False);
2063 begin
2064 if not Silent then
2065 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
2067 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
2068 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
2069 begin
2070 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
2071 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
2072 end;
2073 end;
2075 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2076 Silent: Boolean = False);
2077 begin
2078 if not Silent then
2079 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
2081 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
2082 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
2083 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
2084 begin
2085 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
2086 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
2087 end;
2088 end;
2090 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2091 Silent: Boolean = False);
2092 var
2093 i, j: Integer;
2094 begin
2095 if not Silent then
2096 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
2098 for i := 0 to 9 do
2099 begin
2100 j := Random(17)-8; // -8 .. 8
2101 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
2102 end;
2103 end;
2105 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
2106 Silent: Boolean = False);
2107 var
2108 a, i, j: Integer;
2109 begin
2110 if not Silent then
2111 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
2113 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
2114 for i := 0 to a do
2115 begin
2116 j := Random(41)-20; // -20 .. 20
2117 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
2118 end;
2119 end;
2121 procedure g_Weapon_PreUpdate();
2122 var
2123 i: Integer;
2124 begin
2125 if Shots = nil then Exit;
2126 for i := 0 to High(Shots) do
2127 if Shots[i].ShotType <> 0 then
2128 begin
2129 Shots[i].Obj.oldX := Shots[i].Obj.X;
2130 Shots[i].Obj.oldY := Shots[i].Obj.Y;
2131 end;
2132 end;
2134 procedure g_Weapon_Update();
2135 var
2136 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
2137 _id: DWORD;
2138 Anim: TAnimation;
2139 t: DWArray;
2140 st: Word;
2141 s: String;
2142 o: TObj;
2143 spl: Boolean;
2144 Loud: Boolean;
2145 tcx, tcy: Integer;
2146 begin
2147 if Shots = nil then
2148 Exit;
2150 for i := 0 to High(Shots) do
2151 begin
2152 if Shots[i].ShotType = 0 then
2153 Continue;
2155 Loud := True;
2157 with Shots[i] do
2158 begin
2159 Timeout := Timeout - 1;
2160 oldvx := Obj.Vel.X;
2161 oldvy := Obj.Vel.Y;
2162 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
2163 if (Stopped = 0) and g_Game_IsServer then
2164 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
2165 SpawnerUID, ACTIVATE_SHOT, triggers)
2166 else
2167 t := nil;
2169 if t <> nil then
2170 begin
2171 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
2172 if triggers = nil then
2173 triggers := t
2174 else
2175 begin
2176 h := High(t);
2178 for a := 0 to h do
2179 if not InDWArray(t[a], triggers) then
2180 begin
2181 SetLength(triggers, Length(triggers)+1);
2182 triggers[High(triggers)] := t[a];
2183 end;
2184 end;
2185 end;
2187 // Àíèìàöèÿ ñíàðÿäà:
2188 if Animation <> nil then
2189 Animation.Update();
2191 // Äâèæåíèå:
2192 spl := (ShotType <> WEAPON_PLASMA) and
2193 (ShotType <> WEAPON_BFG) and
2194 (ShotType <> WEAPON_BSP_FIRE) and
2195 (ShotType <> WEAPON_FLAMETHROWER);
2197 if Stopped = 0 then
2198 begin
2199 st := g_Obj_Move_Projectile(@Obj, False, spl);
2200 end
2201 else
2202 begin
2203 st := 0;
2204 end;
2205 positionChanged(); // this updates spatial accelerators
2207 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
2208 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
2209 begin
2210 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
2211 ShotType := 0;
2212 Animation.Free();
2213 Continue;
2214 end;
2216 cx := Obj.X + (Obj.Rect.Width div 2);
2217 cy := Obj.Y + (Obj.Rect.Height div 2);
2219 case ShotType of
2220 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2221 begin
2222 // Âûëåòåëà èç âîäû:
2223 if WordBool(st and MOVE_HITAIR) then
2224 g_Obj_SetSpeed(@Obj, 12);
2226 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
2227 if WordBool(st and MOVE_INWATER) then
2228 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
2229 Obj.Y+(Obj.Rect.Height div 2),
2230 1+Random(3), 16, 16)
2231 else
2232 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
2233 begin
2234 Anim := TAnimation.Create(_id, False, 3);
2235 Anim.Alpha := 150;
2236 g_GFX_OnceAnim(Obj.X-14+Random(9),
2237 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
2238 Anim, ONCEANIM_SMOKE);
2239 Anim.Free();
2240 end;
2242 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2243 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2244 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
2245 (Timeout < 1) then
2246 begin
2247 Obj.Vel.X := 0;
2248 Obj.Vel.Y := 0;
2250 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
2252 if ShotType = WEAPON_SKEL_FIRE then
2253 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2254 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2255 begin
2256 Anim := TAnimation.Create(TextureID, False, 8);
2257 Anim.Blending := False;
2258 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
2259 g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
2260 Anim.Free();
2261 end;
2262 end
2263 else
2264 begin // Âçðûâ Ðàêåòû
2265 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2266 begin
2267 Anim := TAnimation.Create(TextureID, False, 6);
2268 Anim.Blending := False;
2269 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2270 g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
2271 Anim.Free();
2272 end;
2273 end;
2275 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2277 ShotType := 0;
2278 end;
2280 if ShotType = WEAPON_SKEL_FIRE then
2281 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
2282 if GetPos(target, @o) then
2283 throw(i, Obj.X, Obj.Y,
2284 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
2285 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
2286 12);
2287 end;
2288 end;
2290 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2291 begin
2292 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2293 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
2294 begin
2295 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
2296 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
2297 ShotType := 0;
2298 Continue;
2299 end;
2301 // Âåëè÷èíà óðîíà:
2302 if (ShotType = WEAPON_PLASMA) and
2303 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
2304 a := 10
2305 else
2306 a := 5;
2308 if ShotType = WEAPON_BSP_FIRE then
2309 a := 10;
2311 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2312 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2313 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
2314 (Timeout < 1) then
2315 begin
2316 if ShotType = WEAPON_PLASMA then
2317 s := 'FRAMES_EXPLODE_PLASMA'
2318 else
2319 s := 'FRAMES_EXPLODE_BSPFIRE';
2321 // Âçðûâ Ïëàçìû:
2322 if g_Frames_Get(TextureID, s) then
2323 begin
2324 Anim := TAnimation.Create(TextureID, False, 3);
2325 Anim.Blending := False;
2326 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2327 Anim.Free();
2328 g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
2329 end;
2331 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2333 ShotType := 0;
2334 end;
2335 end;
2337 WEAPON_FLAMETHROWER: // Îãíåìåò
2338 begin
2339 // Ñî âðåìåíåì óìèðàåò
2340 if (Timeout < 1) then
2341 begin
2342 ShotType := 0;
2343 Continue;
2344 end;
2345 // Ïîä âîäîé òîæå
2346 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
2347 begin
2348 if WordBool(st and MOVE_HITWATER) then
2349 begin
2350 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
2351 begin
2352 Anim := TAnimation.Create(_id, False, 3);
2353 Anim.Alpha := 0;
2354 tcx := Random(8);
2355 tcy := Random(8);
2356 g_GFX_OnceAnim(cx-4+tcx-(Anim.Width div 2),
2357 cy-4+tcy-(Anim.Height div 2),
2358 Anim, ONCEANIM_SMOKE);
2359 Anim.Free();
2360 end;
2361 end
2362 else
2363 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
2364 ShotType := 0;
2365 Continue;
2366 end;
2368 // Ãðàâèòàöèÿ
2369 if Stopped = 0 then
2370 Obj.Accel.Y := Obj.Accel.Y + 1;
2371 // Ïîïàëè â ñòåíó èëè â âîäó:
2372 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
2373 begin
2374 // Ïðèëèïàåì:
2375 Obj.Vel.X := 0;
2376 Obj.Vel.Y := 0;
2377 Obj.Accel.Y := 0;
2378 if WordBool(st and MOVE_HITWALL) then
2379 Stopped := MOVE_HITWALL
2380 else if WordBool(st and MOVE_HITLAND) then
2381 Stopped := MOVE_HITLAND
2382 else if WordBool(st and MOVE_HITCEIL) then
2383 Stopped := MOVE_HITCEIL;
2384 end;
2386 a := IfThen(Stopped = 0, 10, 1);
2387 // Åñëè â êîãî-òî ïîïàëè
2388 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
2389 begin
2390 // HIT_FLAME ñàì ïîäîææåò
2391 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
2392 if Stopped = 0 then
2393 ShotType := 0;
2394 end;
2396 if Stopped = 0 then
2397 tf := 2
2398 else
2399 tf := 3;
2401 if (gTime mod LongWord(tf) = 0) then
2402 begin
2403 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
2404 Anim.Alpha := 0;
2405 case Stopped of
2406 MOVE_HITWALL: begin tcx := cx-4+Random(8); tcy := cy-12+Random(24); end;
2407 MOVE_HITLAND: begin tcx := cx-12+Random(24); tcy := cy-10+Random(8); end;
2408 MOVE_HITCEIL: begin tcx := cx-12+Random(24); tcy := cy+6+Random(8); end;
2409 else begin tcx := cx-4+Random(8); tcy := cy-4+Random(8); end;
2410 end;
2411 g_GFX_OnceAnim(tcx-(Anim.Width div 2), tcy-(Anim.Height div 2), Anim, ONCEANIM_SMOKE);
2412 Anim.Free();
2413 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
2414 end;
2415 end;
2417 WEAPON_BFG: // BFG
2418 begin
2419 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
2420 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
2421 begin
2422 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
2423 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
2424 ShotType := 0;
2425 Continue;
2426 end;
2428 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2429 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2430 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
2431 (Timeout < 1) then
2432 begin
2433 // Ëó÷è BFG:
2434 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
2436 // Âçðûâ BFG:
2437 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
2438 begin
2439 Anim := TAnimation.Create(TextureID, False, 6);
2440 Anim.Blending := False;
2441 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2442 Anim.Free();
2443 g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
2444 end;
2446 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2448 ShotType := 0;
2449 end;
2450 end;
2452 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2453 begin
2454 // Âûëåòåë èç âîäû:
2455 if WordBool(st and MOVE_HITAIR) then
2456 g_Obj_SetSpeed(@Obj, 16);
2458 // Âåëè÷èíà óðîíà:
2459 if ShotType = WEAPON_IMP_FIRE then
2460 a := 5
2461 else
2462 if ShotType = WEAPON_CACO_FIRE then
2463 a := 20
2464 else
2465 a := 40;
2467 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2468 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2469 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2470 (Timeout < 1) then
2471 begin
2472 if ShotType = WEAPON_IMP_FIRE then
2473 s := 'FRAMES_EXPLODE_IMPFIRE'
2474 else
2475 if ShotType = WEAPON_CACO_FIRE then
2476 s := 'FRAMES_EXPLODE_CACOFIRE'
2477 else
2478 s := 'FRAMES_EXPLODE_BARONFIRE';
2480 // Âçðûâ:
2481 if g_Frames_Get(TextureID, s) then
2482 begin
2483 Anim := TAnimation.Create(TextureID, False, 6);
2484 Anim.Blending := False;
2485 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2486 Anim.Free();
2487 end;
2489 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2491 ShotType := 0;
2492 end;
2493 end;
2495 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2496 begin
2497 // Âûëåòåë èç âîäû:
2498 if WordBool(st and MOVE_HITAIR) then
2499 g_Obj_SetSpeed(@Obj, 16);
2501 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2502 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2503 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2504 (Timeout < 1) then
2505 begin
2506 // Âçðûâ:
2507 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2508 begin
2509 Anim := TAnimation.Create(TextureID, False, 6);
2510 Anim.Blending := False;
2511 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2512 Anim.Free();
2513 end;
2515 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2517 ShotType := 0;
2518 end;
2519 end;
2520 end; // case ShotType of...
2522 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2523 if (ShotType = 0) then
2524 begin
2525 if gGameSettings.GameType = GT_SERVER then
2526 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2527 if Animation <> nil then
2528 begin
2529 Animation.Free();
2530 Animation := nil;
2531 end;
2532 end
2533 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2534 if gGameSettings.GameType = GT_SERVER then
2535 MH_SEND_UpdateShot(i);
2536 end;
2537 end;
2538 end;
2540 procedure g_Weapon_Draw();
2541 var
2542 i, fX, fY: Integer;
2543 a: SmallInt;
2544 p: TDFPoint;
2545 begin
2546 if Shots = nil then
2547 Exit;
2549 for i := 0 to High(Shots) do
2550 if Shots[i].ShotType <> 0 then
2551 with Shots[i] do
2552 begin
2553 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2554 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2555 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2556 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2557 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2558 else
2559 a := 0;
2561 Obj.lerp(gLerpFactor, fX, fY);
2562 p.X := Obj.Rect.Width div 2;
2563 p.Y := Obj.Rect.Height div 2;
2565 if Animation <> nil then
2566 begin
2567 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2568 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2569 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2570 Animation.DrawEx(fX, fY, TMirrorType.None, p, a)
2571 else
2572 Animation.Draw(fX, fY, TMirrorType.None);
2573 end
2574 else if TextureID <> 0 then
2575 begin
2576 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2577 e_DrawAdv(TextureID, fX, fY, 0, True, False, a, @p, TMirrorType.None)
2578 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2579 e_Draw(TextureID, fX, fY, 0, True, False);
2580 end;
2582 if g_debug_Frames then
2583 begin
2584 e_DrawQuad(Obj.X+Obj.Rect.X,
2585 Obj.Y+Obj.Rect.Y,
2586 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2587 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2588 0, 255, 0);
2589 end;
2590 end;
2591 end;
2593 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2594 var
2595 a: Integer;
2596 begin
2597 Result := False;
2599 if Shots = nil then
2600 Exit;
2602 for a := 0 to High(Shots) do
2603 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2604 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2605 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2606 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2607 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2608 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2609 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2610 begin
2611 Result := True;
2612 Exit;
2613 end;
2614 end;
2616 procedure g_Weapon_SaveState (st: TStream);
2617 var
2618 count, i, j: Integer;
2619 begin
2620 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ
2621 count := 0;
2622 for i := 0 to High(Shots) do if (Shots[i].ShotType <> 0) then Inc(count);
2624 // Êîëè÷åñòâî ñíàðÿäîâ
2625 utils.WriteInt(st, count);
2627 if (count = 0) then exit;
2629 for i := 0 to High(Shots) do
2630 begin
2631 if Shots[i].ShotType <> 0 then
2632 begin
2633 // Ñèãíàòóðà ñíàðÿäà
2634 utils.writeSign(st, 'SHOT');
2635 utils.writeInt(st, Byte(0)); // version
2636 // Òèï ñíàðÿäà
2637 utils.writeInt(st, Byte(Shots[i].ShotType));
2638 // Öåëü
2639 utils.writeInt(st, Word(Shots[i].Target));
2640 // UID ñòðåëÿâøåãî
2641 utils.writeInt(st, Word(Shots[i].SpawnerUID));
2642 // Ðàçìåð ïîëÿ Triggers
2643 utils.writeInt(st, Integer(Length(Shots[i].Triggers)));
2644 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2645 for j := 0 to Length(Shots[i].Triggers)-1 do utils.writeInt(st, LongWord(Shots[i].Triggers[j]));
2646 // Îáúåêò ñíàðÿäà
2647 Obj_SaveState(st, @Shots[i].Obj);
2648 // Êîñòûëèíà åáàíàÿ
2649 utils.writeInt(st, Byte(Shots[i].Stopped));
2650 end;
2651 end;
2652 end;
2654 procedure g_Weapon_LoadState (st: TStream);
2655 var
2656 count, tc, i, j: Integer;
2657 dw: LongWord;
2658 begin
2659 if (st = nil) then exit;
2661 // Êîëè÷åñòâî ñíàðÿäîâ
2662 count := utils.readLongInt(st);
2663 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid shots counter');
2665 SetLength(Shots, count);
2667 if (count = 0) then exit;
2669 for i := 0 to count-1 do
2670 begin
2671 // Ñèãíàòóðà ñíàðÿäà
2672 if not utils.checkSign(st, 'SHOT') then raise XStreamError.Create('invalid shot signature');
2673 if (utils.readByte(st) <> 0) then raise XStreamError.Create('invalid shot version');
2674 // Òèï ñíàðÿäà:
2675 Shots[i].ShotType := utils.readByte(st);
2676 // Öåëü
2677 Shots[i].Target := utils.readWord(st);
2678 // UID ñòðåëÿâøåãî
2679 Shots[i].SpawnerUID := utils.readWord(st);
2680 // Ðàçìåð ïîëÿ Triggers
2681 tc := utils.readLongInt(st);
2682 if (tc < 0) or (tc > 1024*1024) then raise XStreamError.Create('invalid shot triggers counter');
2683 SetLength(Shots[i].Triggers, tc);
2684 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì
2685 for j := 0 to tc-1 do Shots[i].Triggers[j] := utils.readLongWord(st);
2686 // Îáúåêò ïðåäìåòà
2687 Obj_LoadState(@Shots[i].Obj, st);
2688 // Êîñòûëèíà åáàíàÿ
2689 Shots[i].Stopped := utils.readByte(st);
2691 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
2692 Shots[i].TextureID := DWORD(-1);
2693 Shots[i].Animation := nil;
2695 case Shots[i].ShotType of
2696 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2697 begin
2698 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2699 end;
2700 WEAPON_PLASMA:
2701 begin
2702 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2703 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2704 end;
2705 WEAPON_BFG:
2706 begin
2707 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2708 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2709 end;
2710 WEAPON_IMP_FIRE:
2711 begin
2712 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2713 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2714 end;
2715 WEAPON_BSP_FIRE:
2716 begin
2717 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2718 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2719 end;
2720 WEAPON_CACO_FIRE:
2721 begin
2722 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2723 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2724 end;
2725 WEAPON_BARON_FIRE:
2726 begin
2727 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2728 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2729 end;
2730 WEAPON_MANCUB_FIRE:
2731 begin
2732 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2733 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2734 end;
2735 end;
2736 end;
2737 end;
2739 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2740 var
2741 cx, cy: Integer;
2742 Anim: TAnimation;
2743 s: string;
2744 begin
2745 if Shots = nil then
2746 Exit;
2747 if (I > High(Shots)) or (I < 0) then Exit;
2749 with Shots[I] do
2750 begin
2751 if ShotType = 0 then Exit;
2752 Obj.X := X;
2753 Obj.Y := Y;
2754 cx := Obj.X + (Obj.Rect.Width div 2);
2755 cy := Obj.Y + (Obj.Rect.Height div 2);
2757 case ShotType of
2758 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2759 begin
2760 if Loud then
2761 begin
2762 if ShotType = WEAPON_SKEL_FIRE then
2763 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2764 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2765 begin
2766 Anim := TAnimation.Create(TextureID, False, 8);
2767 Anim.Blending := False;
2768 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2769 Anim.Free();
2770 end;
2771 end
2772 else
2773 begin // Âçðûâ Ðàêåòû
2774 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2775 begin
2776 Anim := TAnimation.Create(TextureID, False, 6);
2777 Anim.Blending := False;
2778 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2779 Anim.Free();
2780 end;
2781 end;
2782 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2783 end;
2784 end;
2786 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2787 begin
2788 if ShotType = WEAPON_PLASMA then
2789 s := 'FRAMES_EXPLODE_PLASMA'
2790 else
2791 s := 'FRAMES_EXPLODE_BSPFIRE';
2793 if g_Frames_Get(TextureID, s) and loud then
2794 begin
2795 Anim := TAnimation.Create(TextureID, False, 3);
2796 Anim.Blending := False;
2797 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2798 Anim.Free();
2800 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2801 end;
2802 end;
2804 WEAPON_BFG: // BFG
2805 begin
2806 // Âçðûâ BFG:
2807 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2808 begin
2809 Anim := TAnimation.Create(TextureID, False, 6);
2810 Anim.Blending := False;
2811 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2812 Anim.Free();
2814 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2815 end;
2816 end;
2818 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2819 begin
2820 if ShotType = WEAPON_IMP_FIRE then
2821 s := 'FRAMES_EXPLODE_IMPFIRE'
2822 else
2823 if ShotType = WEAPON_CACO_FIRE then
2824 s := 'FRAMES_EXPLODE_CACOFIRE'
2825 else
2826 s := 'FRAMES_EXPLODE_BARONFIRE';
2828 if g_Frames_Get(TextureID, s) and Loud then
2829 begin
2830 Anim := TAnimation.Create(TextureID, False, 6);
2831 Anim.Blending := False;
2832 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2833 Anim.Free();
2835 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2836 end;
2837 end;
2839 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2840 begin
2841 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2842 begin
2843 Anim := TAnimation.Create(TextureID, False, 6);
2844 Anim.Blending := False;
2845 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2846 Anim.Free();
2848 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2849 end;
2850 end;
2851 end; // case ShotType of...
2853 ShotType := 0;
2854 Animation.Free();
2855 end;
2856 end;
2859 procedure g_Weapon_AddDynLights();
2860 var
2861 i: Integer;
2862 begin
2863 if Shots = nil then Exit;
2864 for i := 0 to High(Shots) do
2865 begin
2866 if Shots[i].ShotType = 0 then continue;
2867 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2868 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2869 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2870 (Shots[i].ShotType = WEAPON_SKEL_FIRE) or
2871 (Shots[i].ShotType = WEAPON_IMP_FIRE) or
2872 (Shots[i].ShotType = WEAPON_CACO_FIRE) or
2873 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2874 (Shots[i].ShotType = WEAPON_BSP_FIRE) or
2875 (Shots[i].ShotType = WEAPON_PLASMA) or
2876 (Shots[i].ShotType = WEAPON_BFG) or
2877 (Shots[i].ShotType = WEAPON_FLAMETHROWER) or
2878 false then
2879 begin
2880 if (Shots[i].ShotType = WEAPON_PLASMA) then
2881 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)
2882 else if (Shots[i].ShotType = WEAPON_BFG) then
2883 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)
2884 else if (Shots[i].ShotType = WEAPON_FLAMETHROWER) then
2885 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)
2886 else
2887 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);
2888 end;
2889 end;
2890 end;
2893 procedure TShot.positionChanged (); begin end;
2896 end.