DEADSOFTWARE

flamer projectiles don't push
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE g_amodes.inc}
17 unit g_weapons;
19 interface
21 uses
22 g_textures, g_basic, e_graphics, g_phys, BinEditor;
24 const
25 HIT_SOME = 0;
26 HIT_ROCKET = 1;
27 HIT_BFG = 2;
28 HIT_TRAP = 3;
29 HIT_FALL = 4;
30 HIT_WATER = 5;
31 HIT_ACID = 6;
32 HIT_ELECTRO = 7;
33 HIT_FLAME = 8;
34 HIT_SELF = 9;
35 HIT_DISCON = 10;
37 type
38 TShot = record
39 ShotType: Byte;
40 Target: Word;
41 SpawnerUID: Word;
42 Triggers: DWArray;
43 Obj: TObj;
44 Animation: TAnimation;
45 TextureID: DWORD;
46 Timeout: DWORD;
47 Stopped: Byte;
48 end;
50 var
51 Shots: array of TShot = nil;
52 LastShotID: Integer = 0;
54 procedure g_Weapon_LoadData();
55 procedure g_Weapon_FreeData();
56 procedure g_Weapon_Init();
57 procedure g_Weapon_Free();
58 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
59 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
60 function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
62 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
63 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
64 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
65 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
66 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word; WID: Integer = -1; Silent: Boolean = False);
67 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
68 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
69 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
70 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
71 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
72 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
73 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
74 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1; Silent: Boolean = False);
75 procedure g_Weapon_bfghit(x, y: Integer);
76 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
77 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
78 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
79 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word; Silent: Boolean = False);
81 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
82 procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word);
83 procedure g_Weapon_Update();
84 procedure g_Weapon_Draw();
85 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
86 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
88 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
89 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
91 procedure g_Weapon_AddDynLights();
93 const
94 WEAPON_KASTET = 0;
95 WEAPON_SAW = 1;
96 WEAPON_PISTOL = 2;
97 WEAPON_SHOTGUN1 = 3;
98 WEAPON_SHOTGUN2 = 4;
99 WEAPON_CHAINGUN = 5;
100 WEAPON_ROCKETLAUNCHER = 6;
101 WEAPON_PLASMA = 7;
102 WEAPON_BFG = 8;
103 WEAPON_SUPERPULEMET = 9;
104 WEAPON_FLAMETHROWER = 10;
105 WEAPON_ZOMBY_PISTOL = 20;
106 WEAPON_IMP_FIRE = 21;
107 WEAPON_BSP_FIRE = 22;
108 WEAPON_CACO_FIRE = 23;
109 WEAPON_BARON_FIRE = 24;
110 WEAPON_MANCUB_FIRE = 25;
111 WEAPON_SKEL_FIRE = 26;
113 WP_FIRST = WEAPON_KASTET;
114 WP_LAST = WEAPON_FLAMETHROWER;
116 implementation
118 uses
119 Math, g_map, g_player, g_gfx, g_sound, g_main,
120 g_console, SysUtils, g_options, g_game,
121 g_triggers, MAPDEF, e_log, g_monsters, g_saveload,
122 g_language, g_netmsg;
124 type
125 TWaterPanel = record
126 X, Y: Integer;
127 Width, Height: Word;
128 Active: Boolean;
129 end;
131 const
132 SHOT_ROCKETLAUNCHER_WIDTH = 14;
133 SHOT_ROCKETLAUNCHER_HEIGHT = 14;
135 SHOT_SKELFIRE_WIDTH = 14;
136 SHOT_SKELFIRE_HEIGHT = 14;
138 SHOT_PLASMA_WIDTH = 16;
139 SHOT_PLASMA_HEIGHT = 16;
141 SHOT_BFG_WIDTH = 32;
142 SHOT_BFG_HEIGHT = 32;
143 SHOT_BFG_DAMAGE = 100;
144 SHOT_BFG_RADIUS = 256;
146 SHOT_FLAME_WIDTH = 4;
147 SHOT_FLAME_HEIGHT = 4;
148 SHOT_FLAME_LIFETIME = 180;
150 SHOT_SIGNATURE = $544F4853; // 'SHOT'
152 var
153 WaterMap: array of array of DWORD = nil;
155 function FindShot(): DWORD;
156 var
157 i: Integer;
158 begin
159 if Shots <> nil then
160 for i := 0 to High(Shots) do
161 if Shots[i].ShotType = 0 then
162 begin
163 Result := i;
164 LastShotID := Result;
165 Exit;
166 end;
168 if Shots = nil then
169 begin
170 SetLength(Shots, 128);
171 Result := 0;
172 end
173 else
174 begin
175 Result := High(Shots) + 1;
176 SetLength(Shots, Length(Shots) + 128);
177 end;
178 LastShotID := Result;
179 end;
181 procedure CreateWaterMap();
182 var
183 WaterArray: Array of TWaterPanel;
184 a, b, c, m: Integer;
185 ok: Boolean;
186 begin
187 if gWater = nil then
188 Exit;
190 SetLength(WaterArray, Length(gWater));
192 for a := 0 to High(gWater) do
193 begin
194 WaterArray[a].X := gWater[a].X;
195 WaterArray[a].Y := gWater[a].Y;
196 WaterArray[a].Width := gWater[a].Width;
197 WaterArray[a].Height := gWater[a].Height;
198 WaterArray[a].Active := True;
199 end;
201 g_Game_SetLoadingText(_lc[I_LOAD_WATER_MAP], High(WaterArray), False);
203 for a := 0 to High(WaterArray) do
204 if WaterArray[a].Active then
205 begin
206 WaterArray[a].Active := False;
207 m := Length(WaterMap);
208 SetLength(WaterMap, m+1);
209 SetLength(WaterMap[m], 1);
210 WaterMap[m][0] := a;
211 ok := True;
213 while ok do
214 begin
215 ok := False;
216 for b := 0 to High(WaterArray) do
217 if WaterArray[b].Active then
218 for c := 0 to High(WaterMap[m]) do
219 if g_CollideAround(WaterArray[b].X,
220 WaterArray[b].Y,
221 WaterArray[b].Width,
222 WaterArray[b].Height,
223 WaterArray[WaterMap[m][c]].X,
224 WaterArray[WaterMap[m][c]].Y,
225 WaterArray[WaterMap[m][c]].Width,
226 WaterArray[WaterMap[m][c]].Height) then
227 begin
228 WaterArray[b].Active := False;
229 SetLength(WaterMap[m],
230 Length(WaterMap[m])+1);
231 WaterMap[m][High(WaterMap[m])] := b;
232 ok := True;
233 Break;
234 end;
235 end;
237 g_Game_StepLoading();
238 end;
240 WaterArray := nil;
241 end;
243 procedure CheckTrap(ID: DWORD; dm: Integer; t: Byte);
244 var
245 a, b, c, d, i1, i2: Integer;
246 pl, mn: WArray;
247 begin
248 if (gWater = nil) or (WaterMap = nil) then Exit;
250 i1 := -1;
251 i2 := -1;
253 SetLength(pl, 1024);
254 SetLength(mn, 1024);
255 for d := 0 to 1023 do pl[d] := $FFFF;
256 for d := 0 to 1023 do mn[d] := $FFFF;
258 for a := 0 to High(WaterMap) do
259 for b := 0 to High(WaterMap[a]) do
260 begin
261 if not g_Obj_Collide(gWater[WaterMap[a][b]].X, gWater[WaterMap[a][b]].Y,
262 gWater[WaterMap[a][b]].Width, gWater[WaterMap[a][b]].Height,
263 @Shots[ID].Obj) then Continue;
265 for c := 0 to High(WaterMap[a]) do
266 begin
267 if gPlayers <> nil then
268 begin
269 for d := 0 to High(gPlayers) do
270 if (gPlayers[d] <> nil) and (gPlayers[d].Live) then
271 if gPlayers[d].Collide(gWater[WaterMap[a][c]]) then
272 if not InWArray(d, pl) then
273 if i1 < 1023 then
274 begin
275 i1 := i1+1;
276 pl[i1] := d;
277 end;
278 end;
280 if gMonsters <> nil then
281 begin
282 for d := 0 to High(gMonsters) do
283 if (gMonsters[d] <> nil) and (gMonsters[d].Live) then
284 if gMonsters[d].Collide(gWater[WaterMap[a][c]]) then
285 if not InWArray(d, mn) then
286 if i2 < 1023 then
287 begin
288 i2 := i2+1;
289 mn[i2] := d;
290 end;
291 end;
292 end;
294 if i1 <> -1 then
295 for d := 0 to i1 do
296 gPlayers[pl[d]].Damage(dm, Shots[ID].SpawnerUID, 0, 0, t);
298 if i2 <> -1 then
299 for d := 0 to i2 do
300 gMonsters[mn[d]].Damage(dm, 0, 0, Shots[ID].SpawnerUID, t);
301 end;
303 pl := nil;
304 mn := nil;
305 end;
307 function HitMonster(m: TMonster; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
308 var
309 tt, mt: Byte;
310 mon: TMonster;
311 begin
312 Result := False;
314 tt := g_GetUIDType(SpawnerUID);
315 if tt = UID_MONSTER then
316 begin
317 mon := g_Monsters_Get(SpawnerUID);
318 if mon <> nil then
319 mt := g_Monsters_Get(SpawnerUID).MonsterType
320 else
321 mt := 0;
322 end
323 else
324 mt := 0;
326 if m = nil then Exit;
327 if m.UID = SpawnerUID then
328 begin
329 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
330 if (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then
331 Exit;
332 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
333 if (m.MonsterType = MONSTER_CYBER) or
334 (m.MonsterType = MONSTER_BARREL) then
335 begin
336 Result := True;
337 Exit;
338 end;
339 end;
341 if tt = UID_MONSTER then
342 begin
343 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
344 if (mt = MONSTER_SOUL) and (m.MonsterType = MONSTER_PAIN) then
345 Exit;
347 // Îáà ìîíñòðà îäíîãî âèäà:
348 if mt = m.MonsterType then
349 case mt of
350 MONSTER_IMP, MONSTER_DEMON, MONSTER_BARON, MONSTER_KNIGHT, MONSTER_CACO,
351 MONSTER_SOUL, MONSTER_MANCUB, MONSTER_SKEL, MONSTER_FISH:
352 Exit; // Ýòè íå áüþò ñâîèõ
353 end;
354 end;
356 if g_Game_IsServer then
357 begin
358 if (t <> HIT_FLAME) or (m.FFireTime = 0) or (vx <> 0) or (vy <> 0) then
359 Result := m.Damage(d, vx, vy, SpawnerUID, t)
360 else
361 Result := True;
362 if t = HIT_FLAME then
363 m.CatchFire(SpawnerUID);
364 end
365 else
366 Result := True;
367 end;
369 function HitPlayer(p: TPlayer; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
370 begin
371 Result := False;
373 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
374 if (p.UID = SpawnerUID) and (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then
375 Exit;
377 if g_Game_IsServer then
378 begin
379 if (t <> HIT_FLAME) or (p.FFireTime = 0) or (vx <> 0) or (vy <> 0) then
380 p.Damage(d, SpawnerUID, vx, vy, t);
381 if (t = HIT_FLAME) then
382 p.CatchFire(SpawnerUID);
383 end;
385 Result := True;
386 end;
388 function GunHit(X, Y: Integer; vx, vy: Integer; dmg: Integer;
389 SpawnerUID: Word; AllowPush: Boolean): Byte;
390 var
391 i, h: Integer;
392 begin
393 Result := 0;
395 h := High(gPlayers);
397 if h <> -1 then
398 for i := 0 to h do
399 if (gPlayers[i] <> nil) and gPlayers[i].Live and gPlayers[i].Collide(X, Y) then
400 if HitPlayer(gPlayers[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
401 begin
402 if AllowPush then gPlayers[i].Push(vx, vy);
403 Result := 1;
404 end;
406 if Result <> 0 then Exit;
408 h := High(gMonsters);
410 if h <> -1 then
411 for i := 0 to h do
412 if (gMonsters[i] <> nil) and gMonsters[i].Live and gMonsters[i].Collide(X, Y) then
413 if HitMonster(gMonsters[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
414 begin
415 if AllowPush then gMonsters[i].Push(vx, vy);
416 Result := 2;
417 Exit;
418 end;
419 end;
421 procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word);
422 var
423 i, h: Integer;
424 st: Byte;
425 pl: TPlayer;
426 b: Boolean;
427 begin
428 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
430 h := High(gCorpses);
432 if gAdvCorpses and (h <> -1) then
433 for i := 0 to h do
434 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
435 with gCorpses[i] do
436 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
437 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
438 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
439 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
440 begin
441 Damage(50, 0, 0);
442 g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
443 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2));
444 end;
446 st := TEAM_NONE;
447 pl := g_Player_Get(SpawnerUID);
448 if pl <> nil then
449 st := pl.Team;
451 h := High(gPlayers);
453 if h <> -1 then
454 for i := 0 to h do
455 if (gPlayers[i] <> nil) and (gPlayers[i].Live) and (gPlayers[i].UID <> SpawnerUID) then
456 with gPlayers[i] do
457 if (g_PatchLength(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
458 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) <= SHOT_BFG_RADIUS) and
459 g_TraceVector(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
460 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) then
461 begin
462 if (st = TEAM_NONE) or (st <> gPlayers[i].Team) then
463 b := HitPlayer(gPlayers[i], 50, 0, 0, SpawnerUID, HIT_SOME)
464 else
465 b := HitPlayer(gPlayers[i], 25, 0, 0, SpawnerUID, HIT_SOME);
466 if b then
467 gPlayers[i].BFGHit();
468 end;
470 h := High(gMonsters);
472 if h <> -1 then
473 for i := 0 to h do
474 if (gMonsters[i] <> nil) and (gMonsters[i].Live) and (gMonsters[i].UID <> SpawnerUID) then
475 with gMonsters[i] do
476 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
477 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
478 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
479 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
480 if HitMonster(gMonsters[i], 50, 0, 0, SpawnerUID, HIT_SOME) then gMonsters[i].BFGHit();
481 end;
483 function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
484 var
485 find_id, FramesID: DWORD;
486 begin
487 if I < 0 then
488 find_id := FindShot()
489 else
490 begin
491 find_id := I;
492 if Integer(find_id) >= High(Shots) then
493 SetLength(Shots, find_id + 64)
494 end;
496 case ShotType of
497 WEAPON_ROCKETLAUNCHER:
498 begin
499 with Shots[find_id] do
500 begin
501 g_Obj_Init(@Obj);
503 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
504 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
506 Animation := nil;
507 Triggers := nil;
508 ShotType := WEAPON_ROCKETLAUNCHER;
509 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
510 end;
511 end;
513 WEAPON_PLASMA:
514 begin
515 with Shots[find_id] do
516 begin
517 g_Obj_Init(@Obj);
519 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
520 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
522 Triggers := nil;
523 ShotType := WEAPON_PLASMA;
524 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
525 Animation := TAnimation.Create(FramesID, True, 5);
526 end;
527 end;
529 WEAPON_BFG:
530 begin
531 with Shots[find_id] do
532 begin
533 g_Obj_Init(@Obj);
535 Obj.Rect.Width := SHOT_BFG_WIDTH;
536 Obj.Rect.Height := SHOT_BFG_HEIGHT;
538 Triggers := nil;
539 ShotType := WEAPON_BFG;
540 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
541 Animation := TAnimation.Create(FramesID, True, 6);
542 end;
543 end;
545 WEAPON_FLAMETHROWER:
546 begin
547 with Shots[find_id] do
548 begin
549 g_Obj_Init(@Obj);
551 Obj.Rect.Width := SHOT_FLAME_WIDTH;
552 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
554 Triggers := nil;
555 ShotType := WEAPON_FLAMETHROWER;
556 Animation := nil;
557 TextureID := 0;
558 g_Frames_Get(TextureID, 'FRAMES_FLAME');
559 end;
560 end;
562 WEAPON_IMP_FIRE:
563 begin
564 with Shots[find_id] do
565 begin
566 g_Obj_Init(@Obj);
568 Obj.Rect.Width := 16;
569 Obj.Rect.Height := 16;
571 Triggers := nil;
572 ShotType := WEAPON_IMP_FIRE;
573 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
574 Animation := TAnimation.Create(FramesID, True, 4);
575 end;
576 end;
578 WEAPON_CACO_FIRE:
579 begin
580 with Shots[find_id] do
581 begin
582 g_Obj_Init(@Obj);
584 Obj.Rect.Width := 16;
585 Obj.Rect.Height := 16;
587 Triggers := nil;
588 ShotType := WEAPON_CACO_FIRE;
589 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
590 Animation := TAnimation.Create(FramesID, True, 4);
591 end;
592 end;
594 WEAPON_MANCUB_FIRE:
595 begin
596 with Shots[find_id] do
597 begin
598 g_Obj_Init(@Obj);
600 Obj.Rect.Width := 32;
601 Obj.Rect.Height := 32;
603 Triggers := nil;
604 ShotType := WEAPON_MANCUB_FIRE;
605 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
606 Animation := TAnimation.Create(FramesID, True, 4);
607 end;
608 end;
610 WEAPON_BARON_FIRE:
611 begin
612 with Shots[find_id] do
613 begin
614 g_Obj_Init(@Obj);
616 Obj.Rect.Width := 32;
617 Obj.Rect.Height := 16;
619 Triggers := nil;
620 ShotType := WEAPON_BARON_FIRE;
621 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
622 Animation := TAnimation.Create(FramesID, True, 4);
623 end;
624 end;
626 WEAPON_BSP_FIRE:
627 begin
628 with Shots[find_id] do
629 begin
630 g_Obj_Init(@Obj);
632 Obj.Rect.Width := 16;
633 Obj.Rect.Height := 16;
635 Triggers := nil;
636 ShotType := WEAPON_BSP_FIRE;
637 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
638 Animation := TAnimation.Create(FramesID, True, 4);
639 end;
640 end;
642 WEAPON_SKEL_FIRE:
643 begin
644 with Shots[find_id] do
645 begin
646 g_Obj_Init(@Obj);
648 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
649 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
651 Triggers := nil;
652 ShotType := WEAPON_SKEL_FIRE;
653 target := TargetUID;
654 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
655 Animation := TAnimation.Create(FramesID, True, 5);
656 end;
657 end;
658 end;
660 Shots[find_id].Obj.X := X;
661 Shots[find_id].Obj.Y := Y;
662 Shots[find_id].Obj.Vel.X := XV;
663 Shots[find_id].Obj.Vel.Y := YV;
664 Shots[find_id].Obj.Accel.X := 0;
665 Shots[find_id].Obj.Accel.Y := 0;
666 Shots[find_id].SpawnerUID := Spawner;
667 if (ShotType = WEAPON_FLAMETHROWER) and (XV = 0) and (YV = 0) then
668 Shots[find_id].Stopped := 255
669 else
670 Shots[find_id].Stopped := 0;
671 Result := find_id;
672 end;
674 procedure throw(i, x, y, xd, yd, s: Integer);
675 var
676 a: Integer;
677 begin
678 yd := yd - y;
679 xd := xd - x;
681 a := Max(Abs(xd), Abs(yd));
682 if a = 0 then
683 a := 1;
685 Shots[i].Obj.X := x;
686 Shots[i].Obj.Y := y;
687 Shots[i].Obj.Vel.X := (xd*s) div a;
688 Shots[i].Obj.Vel.Y := (yd*s) div a;
689 Shots[i].Obj.Accel.X := 0;
690 Shots[i].Obj.Accel.Y := 0;
691 Shots[i].Stopped := 0;
692 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BFG] then
693 Shots[i].Timeout := 900 // ~25 sec
694 else
695 begin
696 if Shots[i].ShotType = WEAPON_FLAMETHROWER then
697 Shots[i].Timeout := SHOT_FLAME_LIFETIME
698 else
699 Shots[i].Timeout := 550; // ~15 sec
700 end;
701 end;
703 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
704 var
705 i, h: Integer;
707 function PlayerHit(Team: Byte = 0): Boolean;
708 var
709 i: Integer;
710 ChkTeam: Boolean;
711 p: TPlayer;
712 begin
713 Result := False;
714 h := High(gPlayers);
716 if h <> -1 then
717 for i := 0 to h do
718 if (gPlayers[i] <> nil) and gPlayers[i].Live and g_Obj_Collide(obj, @gPlayers[i].Obj) then
719 begin
720 ChkTeam := True;
721 if (Team > 0) and (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
722 begin
723 p := g_Player_Get(SpawnerUID);
724 if p <> nil then
725 ChkTeam := (p.Team = gPlayers[i].Team) xor (Team = 2);
726 end;
727 if ChkTeam then
728 if HitPlayer(gPlayers[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
729 begin
730 if t <> HIT_FLAME then
731 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
732 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
733 if t = HIT_BFG then
734 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
735 Result := True;
736 break;
737 end;
738 end;
739 end;
740 function MonsterHit(): Boolean;
741 var
742 i: Integer;
743 begin
744 Result := False;
745 h := High(gMonsters);
747 if h <> -1 then
748 for i := 0 to h do
749 if (gMonsters[i] <> nil) and gMonsters[i].Live and g_Obj_Collide(obj, @gMonsters[i].Obj) then
750 if HitMonster(gMonsters[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
751 begin
752 if t <> HIT_FLAME then
753 gMonsters[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
754 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
755 Result := True;
756 break;
757 end;
758 end;
759 begin
760 Result := 0;
762 if HitCorpses then
763 begin
764 h := High(gCorpses);
766 if gAdvCorpses and (h <> -1) then
767 for i := 0 to h do
768 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
769 g_Obj_Collide(obj, @gCorpses[i].Obj) then
770 begin
771 // Ðàñïèëèâàåì òðóï:
772 gCorpses[i].Damage(d, (obj^.Vel.X+obj^.Accel.X) div 4,
773 (obj^.Vel.Y+obj^.Accel.Y) div 4);
774 Result := 1;
775 end;
776 end;
778 case gGameSettings.GameMode of
779 // Êàìïàíèÿ:
780 GM_COOP, GM_SINGLE:
781 begin
782 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
783 if MonsterHit() then
784 begin
785 Result := 2;
786 Exit;
787 end;
789 if PlayerHit() then
790 begin
791 Result := 1;
792 Exit;
793 end;
794 end;
796 // Äåçìàò÷:
797 GM_DM:
798 begin
799 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
800 if PlayerHit() then
801 begin
802 Result := 1;
803 Exit;
804 end;
806 if MonsterHit() then
807 begin
808 Result := 2;
809 Exit;
810 end;
811 end;
813 // Êîìàíäíûå:
814 GM_TDM, GM_CTF:
815 begin
816 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
817 if PlayerHit(2) then
818 begin
819 Result := 1;
820 Exit;
821 end;
823 // Ïîòîì ìîíñòðîâ
824 if MonsterHit() then
825 begin
826 Result := 2;
827 Exit;
828 end;
830 // È â êîíöå ñâîèõ èãðîêîâ
831 if PlayerHit(1) then
832 begin
833 Result := 1;
834 Exit;
835 end;
836 end;
838 end;
839 end;
841 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
842 begin
843 Result := False;
845 case g_GetUIDType(UID) of
846 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
847 UID_MONSTER: Result := HitMonster(g_Monsters_Get(UID), d, 0, 0, SpawnerUID, t);
848 else Exit;
849 end;
850 end;
852 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
853 var
854 i, h, r, dx, dy, m, mm: Integer;
855 _angle: SmallInt;
856 begin
857 Result := False;
859 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
861 r := rad*rad;
863 h := High(gPlayers);
865 if h <> -1 then
866 for i := 0 to h do
867 if (gPlayers[i] <> nil) and gPlayers[i].Live then
868 with gPlayers[i] do
869 begin
870 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
871 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
873 if dx > 1000 then dx := 1000;
874 if dy > 1000 then dy := 1000;
876 if dx*dx+dy*dy < r then
877 begin
878 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
879 // PLAYER_RECT.Width, PLAYER_RECT.Height);
881 mm := Max(abs(dx), abs(dy));
882 if mm = 0 then mm := 1;
884 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
885 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
886 end;
887 end;
889 h := High(gMonsters);
891 if h <> -1 then
892 for i := 0 to h do
893 if gMonsters[i] <> nil then
894 with gMonsters[i] do
895 begin
896 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
897 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
899 if dx > 1000 then dx := 1000;
900 if dy > 1000 then dy := 1000;
902 if dx*dx+dy*dy < r then
903 begin
904 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
905 // Obj.Rect.Width, Obj.Rect.Height);
907 mm := Max(abs(dx), abs(dy));
908 if mm = 0 then mm := 1;
910 if gMonsters[i].Live then
911 HitMonster(gMonsters[i], ((gMonsters[i].Obj.Rect.Width div 4)*10*(rad-mm)) div rad,
912 0, 0, SpawnerUID, HIT_ROCKET);
914 gMonsters[i].Push((dx*7) div mm, (dy*7) div mm);
915 end;
916 end;
918 h := High(gCorpses);
920 if gAdvCorpses and (h <> -1) then
921 for i := 0 to h do
922 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
923 with gCorpses[i] do
924 begin
925 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
926 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
928 if dx > 1000 then dx := 1000;
929 if dy > 1000 then dy := 1000;
931 if dx*dx+dy*dy < r then
932 begin
933 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
934 Obj.Rect.Width, Obj.Rect.Height);
936 mm := Max(abs(dx), abs(dy));
937 if mm = 0 then mm := 1;
939 Damage(Round(100*(rad-m)/rad), (dx*10) div mm, (dy*10) div mm);
940 end;
941 end;
943 h := High(gGibs);
945 if gAdvGibs and (h <> -1) then
946 for i := 0 to h do
947 if gGibs[i].Live then
948 with gGibs[i] do
949 begin
950 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
951 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
953 if dx > 1000 then dx := 1000;
954 if dy > 1000 then dy := 1000;
956 if dx*dx+dy*dy < r then
957 begin
958 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
959 Obj.Rect.Width, Obj.Rect.Height);
960 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
961 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
963 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
964 end;
965 end;
966 end;
968 procedure g_Weapon_Init();
969 begin
970 CreateWaterMap();
971 end;
973 procedure g_Weapon_Free();
974 var
975 i: Integer;
976 begin
977 if Shots <> nil then
978 begin
979 for i := 0 to High(Shots) do
980 if Shots[i].ShotType <> 0 then
981 Shots[i].Animation.Free();
983 Shots := nil;
984 end;
986 WaterMap := nil;
987 end;
989 procedure g_Weapon_LoadData();
990 begin
991 e_WriteLog('Loading weapons data...', MSG_NOTIFY);
993 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
994 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
995 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
996 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
997 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
998 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
999 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
1006 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1008 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1010 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1011 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1012 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1013 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1014 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1015 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1016 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1017 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1018 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1019 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1020 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1021 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1022 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1023 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1024 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1026 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1027 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1028 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1029 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1030 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1031 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1032 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1033 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1034 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1035 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1036 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1037 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1038 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1039 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1040 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1041 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1042 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1043 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1044 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1045 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1046 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1048 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1049 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1050 end;
1052 procedure g_Weapon_FreeData();
1053 begin
1054 e_WriteLog('Releasing weapons data...', MSG_NOTIFY);
1056 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1057 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1058 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1059 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1060 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1061 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1062 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1063 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1064 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1065 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1066 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1067 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1068 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1069 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1070 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1071 g_Sound_Delete('SOUND_FIRE');
1072 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1073 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1074 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1075 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1076 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1077 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1078 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1079 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1080 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1081 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1082 g_Sound_Delete('SOUND_PLAYER_JETON');
1083 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1084 g_Sound_Delete('SOUND_PLAYER_CASING1');
1085 g_Sound_Delete('SOUND_PLAYER_CASING2');
1086 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1087 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1089 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1090 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1091 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1092 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1093 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1094 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1095 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1096 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1097 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1098 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1099 g_Frames_DeleteByName('FRAMES_BFGHIT');
1100 g_Frames_DeleteByName('FRAMES_FIRE');
1101 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1102 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1103 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1104 g_Frames_DeleteByName('FRAMES_SMOKE');
1105 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1106 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1107 end;
1109 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1110 var
1111 a: Integer;
1112 x2, y2: Integer;
1113 dx, dy: Integer;
1114 xe, ye: Integer;
1115 xi, yi: Integer;
1116 s, c: Extended;
1117 //vx, vy: Integer;
1118 xx, yy, d: Integer;
1120 i: Integer;
1121 t1, _collide: Boolean;
1122 w, h: Word;
1123 begin
1124 a := GetAngle(x, y, xd, yd)+180;
1126 SinCos(DegToRad(-a), s, c);
1128 if Abs(s) < 0.01 then s := 0;
1129 if Abs(c) < 0.01 then c := 0;
1131 x2 := x+Round(c*gMapInfo.Width);
1132 y2 := y+Round(s*gMapInfo.Width);
1134 t1 := gWalls <> nil;
1135 _collide := False;
1136 w := gMapInfo.Width;
1137 h := gMapInfo.Height;
1139 xe := 0;
1140 ye := 0;
1141 dx := x2-x;
1142 dy := y2-y;
1144 if (xd = 0) and (yd = 0) then Exit;
1146 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1147 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1149 dx := Abs(dx);
1150 dy := Abs(dy);
1152 if dx > dy then d := dx else d := dy;
1154 //blood vel, for Monster.Damage()
1155 //vx := (dx*10 div d)*xi;
1156 //vy := (dy*10 div d)*yi;
1158 xx := x;
1159 yy := y;
1161 for i := 1 to d do
1162 begin
1163 xe := xe+dx;
1164 ye := ye+dy;
1166 if xe > d then
1167 begin
1168 xe := xe-d;
1169 xx := xx+xi;
1170 end;
1172 if ye > d then
1173 begin
1174 ye := ye-d;
1175 yy := yy+yi;
1176 end;
1178 if (yy > h) or (yy < 0) then Break;
1179 if (xx > w) or (xx < 0) then Break;
1181 if t1 then
1182 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1183 begin
1184 _collide := True;
1185 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1186 if g_Game_IsServer and g_Game_IsNet then
1187 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1188 end;
1190 if not _collide then
1191 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1193 if _collide then
1194 Break;
1195 end;
1197 if CheckTrigger and g_Game_IsServer then
1198 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1199 end;
1201 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1202 var
1203 obj: TObj;
1204 begin
1205 obj.X := X;
1206 obj.Y := Y;
1207 obj.rect.X := 0;
1208 obj.rect.Y := 0;
1209 obj.rect.Width := 39;
1210 obj.rect.Height := 52;
1211 obj.Vel.X := 0;
1212 obj.Vel.Y := 0;
1213 obj.Accel.X := 0;
1214 obj.Accel.Y := 0;
1216 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1217 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1218 else
1219 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1220 end;
1222 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1223 var
1224 obj: TObj;
1225 begin
1226 obj.X := X;
1227 obj.Y := Y;
1228 obj.rect.X := 0;
1229 obj.rect.Y := 0;
1230 obj.rect.Width := 32;
1231 obj.rect.Height := 52;
1232 obj.Vel.X := 0;
1233 obj.Vel.Y := 0;
1234 obj.Accel.X := 0;
1235 obj.Accel.Y := 0;
1237 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1238 end;
1240 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1241 Silent: Boolean = False);
1242 var
1243 find_id: DWORD;
1244 dx, dy: Integer;
1245 begin
1246 if WID < 0 then
1247 find_id := FindShot()
1248 else
1249 begin
1250 find_id := WID;
1251 if Integer(find_id) >= High(Shots) then
1252 SetLength(Shots, find_id + 64)
1253 end;
1255 with Shots[find_id] do
1256 begin
1257 g_Obj_Init(@Obj);
1259 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1260 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1262 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1263 dy := -(Obj.Rect.Height div 2);
1265 ShotType := WEAPON_ROCKETLAUNCHER;
1266 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1268 Animation := nil;
1269 triggers := nil;
1270 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1271 end;
1273 Shots[find_id].SpawnerUID := SpawnerUID;
1275 if not Silent then
1276 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1277 end;
1279 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1280 WID: Integer = -1; Silent: Boolean = False);
1281 var
1282 find_id, FramesID: DWORD;
1283 dx, dy: Integer;
1284 begin
1285 if WID < 0 then
1286 find_id := FindShot()
1287 else
1288 begin
1289 find_id := WID;
1290 if Integer(find_id) >= High(Shots) then
1291 SetLength(Shots, find_id + 64)
1292 end;
1294 with Shots[find_id] do
1295 begin
1296 g_Obj_Init(@Obj);
1298 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1299 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1301 dx := -(Obj.Rect.Width div 2);
1302 dy := -(Obj.Rect.Height div 2);
1304 ShotType := WEAPON_SKEL_FIRE;
1305 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1307 triggers := nil;
1308 target := TargetUID;
1309 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1310 Animation := TAnimation.Create(FramesID, True, 5);
1311 end;
1313 Shots[find_id].SpawnerUID := SpawnerUID;
1315 if not Silent then
1316 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1317 end;
1319 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1320 Silent: Boolean = False);
1321 var
1322 find_id, FramesID: DWORD;
1323 dx, dy: Integer;
1324 begin
1325 if WID < 0 then
1326 find_id := FindShot()
1327 else
1328 begin
1329 find_id := WID;
1330 if Integer(find_id) >= High(Shots) then
1331 SetLength(Shots, find_id + 64);
1332 end;
1334 with Shots[find_id] do
1335 begin
1336 g_Obj_Init(@Obj);
1338 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1339 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1341 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1342 dy := -(Obj.Rect.Height div 2);
1344 ShotType := WEAPON_PLASMA;
1345 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1347 triggers := nil;
1348 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1349 Animation := TAnimation.Create(FramesID, True, 5);
1350 end;
1352 Shots[find_id].SpawnerUID := SpawnerUID;
1354 if not Silent then
1355 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1356 end;
1358 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1359 Silent: Boolean = False);
1360 var
1361 find_id: DWORD;
1362 dx, dy: Integer;
1363 begin
1364 if WID < 0 then
1365 find_id := FindShot()
1366 else
1367 begin
1368 find_id := WID;
1369 if Integer(find_id) >= High(Shots) then
1370 SetLength(Shots, find_id + 64);
1371 end;
1373 with Shots[find_id] do
1374 begin
1375 g_Obj_Init(@Obj);
1377 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1378 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1380 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1381 dy := -(Obj.Rect.Height div 2);
1383 ShotType := WEAPON_FLAMETHROWER;
1384 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1386 triggers := nil;
1387 Animation := nil;
1388 TextureID := 0;
1389 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1390 end;
1392 Shots[find_id].SpawnerUID := SpawnerUID;
1394 // if not Silent then
1395 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1396 end;
1398 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1399 Silent: Boolean = False);
1400 var
1401 find_id, FramesID: DWORD;
1402 dx, dy: Integer;
1403 begin
1404 if WID < 0 then
1405 find_id := FindShot()
1406 else
1407 begin
1408 find_id := WID;
1409 if Integer(find_id) >= High(Shots) then
1410 SetLength(Shots, find_id + 64)
1411 end;
1413 with Shots[find_id] do
1414 begin
1415 g_Obj_Init(@Obj);
1417 Obj.Rect.Width := 16;
1418 Obj.Rect.Height := 16;
1420 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1421 dy := -(Obj.Rect.Height div 2);
1423 ShotType := WEAPON_IMP_FIRE;
1424 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1426 triggers := nil;
1427 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1428 Animation := TAnimation.Create(FramesID, True, 4);
1429 end;
1431 Shots[find_id].SpawnerUID := SpawnerUID;
1433 if not Silent then
1434 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1435 end;
1437 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1438 Silent: Boolean = False);
1439 var
1440 find_id, FramesID: DWORD;
1441 dx, dy: Integer;
1442 begin
1443 if WID < 0 then
1444 find_id := FindShot()
1445 else
1446 begin
1447 find_id := WID;
1448 if Integer(find_id) >= High(Shots) then
1449 SetLength(Shots, find_id + 64)
1450 end;
1452 with Shots[find_id] do
1453 begin
1454 g_Obj_Init(@Obj);
1456 Obj.Rect.Width := 16;
1457 Obj.Rect.Height := 16;
1459 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1460 dy := -(Obj.Rect.Height div 2);
1462 ShotType := WEAPON_CACO_FIRE;
1463 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1465 triggers := nil;
1466 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1467 Animation := TAnimation.Create(FramesID, True, 4);
1468 end;
1470 Shots[find_id].SpawnerUID := SpawnerUID;
1472 if not Silent then
1473 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1474 end;
1476 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1477 Silent: Boolean = False);
1478 var
1479 find_id, FramesID: DWORD;
1480 dx, dy: Integer;
1481 begin
1482 if WID < 0 then
1483 find_id := FindShot()
1484 else
1485 begin
1486 find_id := WID;
1487 if Integer(find_id) >= High(Shots) then
1488 SetLength(Shots, find_id + 64)
1489 end;
1491 with Shots[find_id] do
1492 begin
1493 g_Obj_Init(@Obj);
1495 Obj.Rect.Width := 32;
1496 Obj.Rect.Height := 16;
1498 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1499 dy := -(Obj.Rect.Height div 2);
1501 ShotType := WEAPON_BARON_FIRE;
1502 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1504 triggers := nil;
1505 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1506 Animation := TAnimation.Create(FramesID, True, 4);
1507 end;
1509 Shots[find_id].SpawnerUID := SpawnerUID;
1511 if not Silent then
1512 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1513 end;
1515 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1516 Silent: Boolean = False);
1517 var
1518 find_id, FramesID: DWORD;
1519 dx, dy: Integer;
1520 begin
1521 if WID < 0 then
1522 find_id := FindShot()
1523 else
1524 begin
1525 find_id := WID;
1526 if Integer(find_id) >= High(Shots) then
1527 SetLength(Shots, find_id + 64)
1528 end;
1530 with Shots[find_id] do
1531 begin
1532 g_Obj_Init(@Obj);
1534 Obj.Rect.Width := 16;
1535 Obj.Rect.Height := 16;
1537 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1538 dy := -(Obj.Rect.Height div 2);
1540 ShotType := WEAPON_BSP_FIRE;
1541 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1543 triggers := nil;
1545 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1546 Animation := TAnimation.Create(FramesID, True, 4);
1547 end;
1549 Shots[find_id].SpawnerUID := SpawnerUID;
1551 if not Silent then
1552 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1553 end;
1555 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1556 Silent: Boolean = False);
1557 var
1558 find_id, FramesID: DWORD;
1559 dx, dy: Integer;
1560 begin
1561 if WID < 0 then
1562 find_id := FindShot()
1563 else
1564 begin
1565 find_id := WID;
1566 if Integer(find_id) >= High(Shots) then
1567 SetLength(Shots, find_id + 64)
1568 end;
1570 with Shots[find_id] do
1571 begin
1572 g_Obj_Init(@Obj);
1574 Obj.Rect.Width := 32;
1575 Obj.Rect.Height := 32;
1577 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1578 dy := -(Obj.Rect.Height div 2);
1580 ShotType := WEAPON_MANCUB_FIRE;
1581 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1583 triggers := nil;
1585 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1586 Animation := TAnimation.Create(FramesID, True, 4);
1587 end;
1589 Shots[find_id].SpawnerUID := SpawnerUID;
1591 if not Silent then
1592 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1593 end;
1595 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1596 Silent: Boolean = False);
1597 var
1598 find_id, FramesID: DWORD;
1599 dx, dy: Integer;
1600 begin
1601 if WID < 0 then
1602 find_id := FindShot()
1603 else
1604 begin
1605 find_id := WID;
1606 if Integer(find_id) >= High(Shots) then
1607 SetLength(Shots, find_id + 64)
1608 end;
1610 with Shots[find_id] do
1611 begin
1612 g_Obj_Init(@Obj);
1614 Obj.Rect.Width := SHOT_BFG_WIDTH;
1615 Obj.Rect.Height := SHOT_BFG_HEIGHT;
1617 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1618 dy := -(Obj.Rect.Height div 2);
1620 ShotType := WEAPON_BFG;
1621 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1623 triggers := nil;
1624 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
1625 Animation := TAnimation.Create(FramesID, True, 6);
1626 end;
1628 Shots[find_id].SpawnerUID := SpawnerUID;
1630 if not Silent then
1631 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
1632 end;
1634 procedure g_Weapon_bfghit(x, y: Integer);
1635 var
1636 ID: DWORD;
1637 Anim: TAnimation;
1638 begin
1639 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
1640 begin
1641 Anim := TAnimation.Create(ID, False, 4);
1642 g_GFX_OnceAnim(x-32, y-32, Anim);
1643 Anim.Free();
1644 end;
1645 end;
1647 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
1648 Silent: Boolean = False);
1649 begin
1650 if not Silent then
1651 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
1653 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1654 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
1655 begin
1656 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
1657 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1658 end;
1659 end;
1661 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1662 Silent: Boolean = False);
1663 begin
1664 if not Silent then
1665 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
1667 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1668 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
1669 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1670 begin
1671 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
1672 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1673 end;
1674 end;
1676 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1677 Silent: Boolean = False);
1678 var
1679 i, j: Integer;
1680 begin
1681 if not Silent then
1682 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
1684 for i := 0 to 9 do
1685 begin
1686 j := Random(17)-8; // -8 .. 8
1687 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
1688 end;
1689 end;
1691 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1692 Silent: Boolean = False);
1693 var
1694 a, i, j: Integer;
1695 begin
1696 if not Silent then
1697 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
1699 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
1700 for i := 0 to a do
1701 begin
1702 j := Random(41)-20; // -20 .. 20
1703 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
1704 end;
1705 end;
1707 procedure g_Weapon_Update();
1708 var
1709 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
1710 _id: DWORD;
1711 Anim: TAnimation;
1712 t: DWArray;
1713 st: Word;
1714 s: String;
1715 o: TObj;
1716 spl: Boolean;
1717 Loud: Boolean;
1718 tcx, tcy: Integer;
1719 begin
1720 if Shots = nil then
1721 Exit;
1723 for i := 0 to High(Shots) do
1724 begin
1725 if Shots[i].ShotType = 0 then
1726 Continue;
1728 Loud := True;
1730 with Shots[i] do
1731 begin
1732 Timeout := Timeout - 1;
1733 oldvx := Obj.Vel.X;
1734 oldvy := Obj.Vel.Y;
1735 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1736 if (Stopped = 0) and g_Game_IsServer then
1737 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
1738 SpawnerUID, ACTIVATE_SHOT, triggers)
1739 else
1740 t := nil;
1742 if t <> nil then
1743 begin
1744 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1745 if triggers = nil then
1746 triggers := t
1747 else
1748 begin
1749 h := High(t);
1751 for a := 0 to h do
1752 if not InDWArray(t[a], triggers) then
1753 begin
1754 SetLength(triggers, Length(triggers)+1);
1755 triggers[High(triggers)] := t[a];
1756 end;
1757 end;
1758 end;
1760 // Àíèìàöèÿ ñíàðÿäà:
1761 if Animation <> nil then
1762 Animation.Update();
1764 // Äâèæåíèå:
1765 spl := (ShotType <> WEAPON_PLASMA) and
1766 (ShotType <> WEAPON_BFG) and
1767 (ShotType <> WEAPON_BSP_FIRE) and
1768 (ShotType <> WEAPON_FLAMETHROWER);
1770 if Stopped = 0 then
1771 st := g_Obj_Move(@Obj, False, spl)
1772 else
1773 st := 0;
1775 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
1776 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
1777 begin
1778 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1779 ShotType := 0;
1780 Animation.Free();
1781 Continue;
1782 end;
1784 cx := Obj.X + (Obj.Rect.Width div 2);
1785 cy := Obj.Y + (Obj.Rect.Height div 2);
1787 case ShotType of
1788 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1789 begin
1790 // Âûëåòåëà èç âîäû:
1791 if WordBool(st and MOVE_HITAIR) then
1792 g_Obj_SetSpeed(@Obj, 12);
1794 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1795 if WordBool(st and MOVE_INWATER) then
1796 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
1797 Obj.Y+(Obj.Rect.Height div 2),
1798 1+Random(3), 16, 16)
1799 else
1800 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1801 begin
1802 Anim := TAnimation.Create(_id, False, 3);
1803 Anim.Alpha := 150;
1804 g_GFX_OnceAnim(Obj.X-14+Random(9),
1805 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
1806 Anim, ONCEANIM_SMOKE);
1807 Anim.Free();
1808 end;
1810 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1811 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1812 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
1813 (Timeout < 1) then
1814 begin
1815 Obj.Vel.X := 0;
1816 Obj.Vel.Y := 0;
1818 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
1820 if ShotType = WEAPON_SKEL_FIRE then
1821 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1822 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
1823 begin
1824 Anim := TAnimation.Create(TextureID, False, 8);
1825 Anim.Blending := False;
1826 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
1827 g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
1828 Anim.Free();
1829 end;
1830 end
1831 else
1832 begin // Âçðûâ Ðàêåòû
1833 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
1834 begin
1835 Anim := TAnimation.Create(TextureID, False, 6);
1836 Anim.Blending := False;
1837 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1838 g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
1839 Anim.Free();
1840 end;
1841 end;
1843 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
1845 ShotType := 0;
1846 end;
1848 if ShotType = WEAPON_SKEL_FIRE then
1849 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1850 if GetPos(target, @o) then
1851 throw(i, Obj.X, Obj.Y,
1852 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
1853 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
1854 12);
1855 end;
1856 end;
1858 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1859 begin
1860 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1861 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1862 begin
1863 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
1864 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
1865 ShotType := 0;
1866 Continue;
1867 end;
1869 // Âåëè÷èíà óðîíà:
1870 if (ShotType = WEAPON_PLASMA) and
1871 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1872 a := 10
1873 else
1874 a := 5;
1876 if ShotType = WEAPON_BSP_FIRE then
1877 a := 10;
1879 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1880 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1881 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
1882 (Timeout < 1) then
1883 begin
1884 if ShotType = WEAPON_PLASMA then
1885 s := 'FRAMES_EXPLODE_PLASMA'
1886 else
1887 s := 'FRAMES_EXPLODE_BSPFIRE';
1889 // Âçðûâ Ïëàçìû:
1890 if g_Frames_Get(TextureID, s) then
1891 begin
1892 Anim := TAnimation.Create(TextureID, False, 3);
1893 Anim.Blending := False;
1894 g_GFX_OnceAnim(cx-16, cy-16, Anim);
1895 Anim.Free();
1896 g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
1897 end;
1899 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
1901 ShotType := 0;
1902 end;
1903 end;
1905 WEAPON_FLAMETHROWER: // Îãíåìåò
1906 begin
1907 // Ñî âðåìåíåì óìèðàåò
1908 if (Timeout < 1) then
1909 begin
1910 ShotType := 0;
1911 Continue;
1912 end;
1913 // Ïîä âîäîé òîæå
1914 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
1915 begin
1916 if WordBool(st and MOVE_HITWATER) then
1917 begin
1918 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1919 begin
1920 Anim := TAnimation.Create(_id, False, 3);
1921 Anim.Alpha := 0;
1922 tcx := Random(8);
1923 tcy := Random(8);
1924 g_GFX_OnceAnim(cx-4+tcx-(Anim.Width div 2),
1925 cy-4+tcy-(Anim.Height div 2),
1926 Anim, ONCEANIM_SMOKE);
1927 Anim.Free();
1928 end;
1929 end
1930 else
1931 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
1932 ShotType := 0;
1933 Continue;
1934 end;
1936 // Ãðàâèòàöèÿ
1937 if Stopped = 0 then
1938 Obj.Accel.Y := Obj.Accel.Y + 1;
1939 // Ïîïàëè â ñòåíó èëè â âîäó:
1940 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
1941 begin
1942 // Ïðèëèïàåì:
1943 Obj.Vel.X := 0;
1944 Obj.Vel.Y := 0;
1945 Obj.Accel.Y := 0;
1946 if WordBool(st and MOVE_HITWALL) then
1947 Stopped := MOVE_HITWALL
1948 else if WordBool(st and MOVE_HITLAND) then
1949 Stopped := MOVE_HITLAND
1950 else if WordBool(st and MOVE_HITCEIL) then
1951 Stopped := MOVE_HITCEIL;
1952 end;
1954 a := IfThen(Stopped = 0, 3, 1);
1955 // Åñëè â êîãî-òî ïîïàëè
1956 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
1957 begin
1958 // HIT_FLAME ñàì ïîäîææåò
1959 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1960 if Stopped = 0 then
1961 ShotType := 0;
1962 end;
1964 if Stopped = 0 then
1965 tf := 2
1966 else
1967 tf := 3;
1969 if (gTime mod tf = 0) then
1970 begin
1971 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
1972 Anim.Alpha := 0;
1973 case Stopped of
1974 MOVE_HITWALL: begin tcx := cx-4+Random(8); tcy := cy-12+Random(24); end;
1975 MOVE_HITLAND: begin tcx := cx-12+Random(24); tcy := cy-10+Random(8); end;
1976 MOVE_HITCEIL: begin tcx := cx-12+Random(24); tcy := cy+6+Random(8); end;
1977 else begin tcx := cx-4+Random(8); tcy := cy-4+Random(8); end;
1978 end;
1979 g_GFX_OnceAnim(tcx-(Anim.Width div 2), tcy-(Anim.Height div 2), Anim, ONCEANIM_SMOKE);
1980 Anim.Free();
1981 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
1982 end;
1983 end;
1985 WEAPON_BFG: // BFG
1986 begin
1987 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1988 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1989 begin
1990 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
1991 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
1992 ShotType := 0;
1993 Continue;
1994 end;
1996 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1997 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1998 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
1999 (Timeout < 1) then
2000 begin
2001 // Ëó÷è BFG:
2002 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
2004 // Âçðûâ BFG:
2005 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
2006 begin
2007 Anim := TAnimation.Create(TextureID, False, 6);
2008 Anim.Blending := False;
2009 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2010 Anim.Free();
2011 g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
2012 end;
2014 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2016 ShotType := 0;
2017 end;
2018 end;
2020 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2021 begin
2022 // Âûëåòåë èç âîäû:
2023 if WordBool(st and MOVE_HITAIR) then
2024 g_Obj_SetSpeed(@Obj, 16);
2026 // Âåëè÷èíà óðîíà:
2027 if ShotType = WEAPON_IMP_FIRE then
2028 a := 5
2029 else
2030 if ShotType = WEAPON_CACO_FIRE then
2031 a := 20
2032 else
2033 a := 40;
2035 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2036 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2037 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2038 (Timeout < 1) then
2039 begin
2040 if ShotType = WEAPON_IMP_FIRE then
2041 s := 'FRAMES_EXPLODE_IMPFIRE'
2042 else
2043 if ShotType = WEAPON_CACO_FIRE then
2044 s := 'FRAMES_EXPLODE_CACOFIRE'
2045 else
2046 s := 'FRAMES_EXPLODE_BARONFIRE';
2048 // Âçðûâ:
2049 if g_Frames_Get(TextureID, s) then
2050 begin
2051 Anim := TAnimation.Create(TextureID, False, 6);
2052 Anim.Blending := False;
2053 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2054 Anim.Free();
2055 end;
2057 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2059 ShotType := 0;
2060 end;
2061 end;
2063 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2064 begin
2065 // Âûëåòåë èç âîäû:
2066 if WordBool(st and MOVE_HITAIR) then
2067 g_Obj_SetSpeed(@Obj, 16);
2069 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2070 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2071 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2072 (Timeout < 1) then
2073 begin
2074 // Âçðûâ:
2075 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2076 begin
2077 Anim := TAnimation.Create(TextureID, False, 6);
2078 Anim.Blending := False;
2079 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2080 Anim.Free();
2081 end;
2083 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2085 ShotType := 0;
2086 end;
2087 end;
2088 end; // case ShotType of...
2090 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2091 if (ShotType = 0) then
2092 begin
2093 if gGameSettings.GameType = GT_SERVER then
2094 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2095 if Animation <> nil then
2096 begin
2097 Animation.Free();
2098 Animation := nil;
2099 end;
2100 end
2101 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2102 if gGameSettings.GameType = GT_SERVER then
2103 MH_SEND_UpdateShot(i);
2104 end;
2105 end;
2106 end;
2108 procedure g_Weapon_Draw();
2109 var
2110 i: Integer;
2111 a: SmallInt;
2112 p: TPoint;
2113 begin
2114 if Shots = nil then
2115 Exit;
2117 for i := 0 to High(Shots) do
2118 if Shots[i].ShotType <> 0 then
2119 with Shots[i] do
2120 begin
2121 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2122 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2123 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2124 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2125 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2126 else
2127 a := 0;
2129 p.X := Obj.Rect.Width div 2;
2130 p.Y := Obj.Rect.Height div 2;
2132 if Animation <> nil then
2133 begin
2134 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2135 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2136 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2137 Animation.DrawEx(Obj.X, Obj.Y, M_NONE, p, a)
2138 else
2139 Animation.Draw(Obj.X, Obj.Y, M_NONE);
2140 end
2141 else if TextureID <> 0 then
2142 begin
2143 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2144 e_DrawAdv(TextureID, Obj.X, Obj.Y, 0, True, False, a, @p, M_NONE)
2145 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2146 e_Draw(TextureID, Obj.X, Obj.Y, 0, True, False);
2147 end;
2149 if g_debug_Frames then
2150 begin
2151 e_DrawQuad(Obj.X+Obj.Rect.X,
2152 Obj.Y+Obj.Rect.Y,
2153 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2154 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2155 0, 255, 0);
2156 end;
2157 end;
2158 end;
2160 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2161 var
2162 a: Integer;
2163 begin
2164 Result := False;
2166 if Shots = nil then
2167 Exit;
2169 for a := 0 to High(Shots) do
2170 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2171 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2172 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2173 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2174 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2175 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2176 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2177 begin
2178 Result := True;
2179 Exit;
2180 end;
2181 end;
2183 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
2184 var
2185 count, i, j: Integer;
2186 dw: DWORD;
2187 begin
2188 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2189 count := 0;
2190 if Shots <> nil then
2191 for i := 0 to High(Shots) do
2192 if Shots[i].ShotType <> 0 then
2193 count := count + 1;
2195 Mem := TBinMemoryWriter.Create((count+1) * 80);
2197 // Êîëè÷åñòâî ñíàðÿäîâ:
2198 Mem.WriteInt(count);
2200 if count = 0 then
2201 Exit;
2203 for i := 0 to High(Shots) do
2204 if Shots[i].ShotType <> 0 then
2205 begin
2206 // Ñèãíàòóðà ñíàðÿäà:
2207 dw := SHOT_SIGNATURE; // 'SHOT'
2208 Mem.WriteDWORD(dw);
2209 // Òèï ñíàðÿäà:
2210 Mem.WriteByte(Shots[i].ShotType);
2211 // Öåëü:
2212 Mem.WriteWord(Shots[i].Target);
2213 // UID ñòðåëÿâøåãî:
2214 Mem.WriteWord(Shots[i].SpawnerUID);
2215 // Ðàçìåð ïîëÿ Triggers:
2216 dw := Length(Shots[i].Triggers);
2217 Mem.WriteDWORD(dw);
2218 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2219 for j := 0 to Integer(dw)-1 do
2220 Mem.WriteDWORD(Shots[i].Triggers[j]);
2221 // Îáúåêò ñíàðÿäà:
2222 Obj_SaveState(@Shots[i].Obj, Mem);
2223 // Êîñòûëèíà åáàíàÿ:
2224 Mem.WriteByte(Shots[i].Stopped);
2225 end;
2226 end;
2228 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
2229 var
2230 count, i, j: Integer;
2231 dw: DWORD;
2232 begin
2233 if Mem = nil then
2234 Exit;
2236 // Êîëè÷åñòâî ñíàðÿäîâ:
2237 Mem.ReadInt(count);
2239 SetLength(Shots, count);
2241 if count = 0 then
2242 Exit;
2244 for i := 0 to count-1 do
2245 begin
2246 // Ñèãíàòóðà ñíàðÿäà:
2247 Mem.ReadDWORD(dw);
2248 if dw <> SHOT_SIGNATURE then // 'SHOT'
2249 begin
2250 raise EBinSizeError.Create('g_Weapons_LoadState: Wrong Shot Signature');
2251 end;
2252 // Òèï ñíàðÿäà:
2253 Mem.ReadByte(Shots[i].ShotType);
2254 // Öåëü:
2255 Mem.ReadWord(Shots[i].Target);
2256 // UID ñòðåëÿâøåãî:
2257 Mem.ReadWord(Shots[i].SpawnerUID);
2258 // Ðàçìåð ïîëÿ Triggers:
2259 Mem.ReadDWORD(dw);
2260 SetLength(Shots[i].Triggers, dw);
2261 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2262 for j := 0 to Integer(dw)-1 do
2263 Mem.ReadDWORD(Shots[i].Triggers[j]);
2264 // Îáúåêò ïðåäìåòà:
2265 Obj_LoadState(@Shots[i].Obj, Mem);
2266 // Êîñòûëèíà åáàíàÿ:
2267 Mem.ReadByte(Shots[i].Stopped);
2269 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2270 Shots[i].TextureID := DWORD(-1);
2271 Shots[i].Animation := nil;
2273 case Shots[i].ShotType of
2274 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2275 begin
2276 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2277 end;
2278 WEAPON_PLASMA:
2279 begin
2280 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2281 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2282 end;
2283 WEAPON_BFG:
2284 begin
2285 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2286 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2287 end;
2288 WEAPON_IMP_FIRE:
2289 begin
2290 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2291 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2292 end;
2293 WEAPON_BSP_FIRE:
2294 begin
2295 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2296 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2297 end;
2298 WEAPON_CACO_FIRE:
2299 begin
2300 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2301 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2302 end;
2303 WEAPON_BARON_FIRE:
2304 begin
2305 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2306 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2307 end;
2308 WEAPON_MANCUB_FIRE:
2309 begin
2310 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2311 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2312 end;
2313 end;
2314 end;
2315 end;
2317 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2318 var
2319 cx, cy: Integer;
2320 Anim: TAnimation;
2321 s: string;
2322 begin
2323 if Shots = nil then
2324 Exit;
2325 if (I > High(Shots)) or (I < 0) then Exit;
2327 with Shots[I] do
2328 begin
2329 if ShotType = 0 then Exit;
2330 Obj.X := X;
2331 Obj.Y := Y;
2332 cx := Obj.X + (Obj.Rect.Width div 2);
2333 cy := Obj.Y + (Obj.Rect.Height div 2);
2335 case ShotType of
2336 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2337 begin
2338 if Loud then
2339 begin
2340 if ShotType = WEAPON_SKEL_FIRE then
2341 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2342 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2343 begin
2344 Anim := TAnimation.Create(TextureID, False, 8);
2345 Anim.Blending := False;
2346 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2347 Anim.Free();
2348 end;
2349 end
2350 else
2351 begin // Âçðûâ Ðàêåòû
2352 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2353 begin
2354 Anim := TAnimation.Create(TextureID, False, 6);
2355 Anim.Blending := False;
2356 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2357 Anim.Free();
2358 end;
2359 end;
2360 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2361 end;
2362 end;
2364 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2365 begin
2366 if ShotType = WEAPON_PLASMA then
2367 s := 'FRAMES_EXPLODE_PLASMA'
2368 else
2369 s := 'FRAMES_EXPLODE_BSPFIRE';
2371 if g_Frames_Get(TextureID, s) and loud then
2372 begin
2373 Anim := TAnimation.Create(TextureID, False, 3);
2374 Anim.Blending := False;
2375 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2376 Anim.Free();
2378 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2379 end;
2380 end;
2382 WEAPON_BFG: // BFG
2383 begin
2384 // Âçðûâ BFG:
2385 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2386 begin
2387 Anim := TAnimation.Create(TextureID, False, 6);
2388 Anim.Blending := False;
2389 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2390 Anim.Free();
2392 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2393 end;
2394 end;
2396 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2397 begin
2398 if ShotType = WEAPON_IMP_FIRE then
2399 s := 'FRAMES_EXPLODE_IMPFIRE'
2400 else
2401 if ShotType = WEAPON_CACO_FIRE then
2402 s := 'FRAMES_EXPLODE_CACOFIRE'
2403 else
2404 s := 'FRAMES_EXPLODE_BARONFIRE';
2406 if g_Frames_Get(TextureID, s) and Loud then
2407 begin
2408 Anim := TAnimation.Create(TextureID, False, 6);
2409 Anim.Blending := False;
2410 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2411 Anim.Free();
2413 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2414 end;
2415 end;
2417 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2418 begin
2419 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2420 begin
2421 Anim := TAnimation.Create(TextureID, False, 6);
2422 Anim.Blending := False;
2423 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2424 Anim.Free();
2426 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2427 end;
2428 end;
2429 end; // case ShotType of...
2431 ShotType := 0;
2432 Animation.Free();
2433 end;
2434 end;
2437 procedure g_Weapon_AddDynLights();
2438 var
2439 i: Integer;
2440 begin
2441 if Shots = nil then Exit;
2442 for i := 0 to High(Shots) do
2443 begin
2444 if Shots[i].ShotType = 0 then continue;
2445 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2446 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2447 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2448 (Shots[i].ShotType = WEAPON_SKEL_FIRE) or
2449 (Shots[i].ShotType = WEAPON_IMP_FIRE) or
2450 (Shots[i].ShotType = WEAPON_CACO_FIRE) or
2451 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2452 (Shots[i].ShotType = WEAPON_BSP_FIRE) or
2453 (Shots[i].ShotType = WEAPON_PLASMA) or
2454 (Shots[i].ShotType = WEAPON_BFG) or
2455 (Shots[i].ShotType = WEAPON_FLAMETHROWER) or
2456 false then
2457 begin
2458 if (Shots[i].ShotType = WEAPON_PLASMA) then
2459 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)
2460 else if (Shots[i].ShotType = WEAPON_BFG) then
2461 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)
2462 else if (Shots[i].ShotType = WEAPON_FLAMETHROWER) then
2463 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)
2464 else
2465 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);
2466 end;
2467 end;
2468 end;
2470 end.