DEADSOFTWARE

22fc69dd520dd148c7206a2d803607342fc22251
[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 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
731 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
732 if t = HIT_BFG then
733 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
734 Result := True;
735 break;
736 end;
737 end;
738 end;
739 function MonsterHit(): Boolean;
740 var
741 i: Integer;
742 begin
743 Result := False;
744 h := High(gMonsters);
746 if h <> -1 then
747 for i := 0 to h do
748 if (gMonsters[i] <> nil) and gMonsters[i].Live and g_Obj_Collide(obj, @gMonsters[i].Obj) then
749 if HitMonster(gMonsters[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
750 begin
751 gMonsters[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
752 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
753 Result := True;
754 break;
755 end;
756 end;
757 begin
758 Result := 0;
760 if HitCorpses then
761 begin
762 h := High(gCorpses);
764 if gAdvCorpses and (h <> -1) then
765 for i := 0 to h do
766 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
767 g_Obj_Collide(obj, @gCorpses[i].Obj) then
768 begin
769 // Ðàñïèëèâàåì òðóï:
770 gCorpses[i].Damage(d, (obj^.Vel.X+obj^.Accel.X) div 4,
771 (obj^.Vel.Y+obj^.Accel.Y) div 4);
772 Result := 1;
773 end;
774 end;
776 case gGameSettings.GameMode of
777 // Êàìïàíèÿ:
778 GM_COOP, GM_SINGLE:
779 begin
780 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
781 if MonsterHit() then
782 begin
783 Result := 2;
784 Exit;
785 end;
787 if PlayerHit() then
788 begin
789 Result := 1;
790 Exit;
791 end;
792 end;
794 // Äåçìàò÷:
795 GM_DM:
796 begin
797 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
798 if PlayerHit() then
799 begin
800 Result := 1;
801 Exit;
802 end;
804 if MonsterHit() then
805 begin
806 Result := 2;
807 Exit;
808 end;
809 end;
811 // Êîìàíäíûå:
812 GM_TDM, GM_CTF:
813 begin
814 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
815 if PlayerHit(2) then
816 begin
817 Result := 1;
818 Exit;
819 end;
821 // Ïîòîì ìîíñòðîâ
822 if MonsterHit() then
823 begin
824 Result := 2;
825 Exit;
826 end;
828 // È â êîíöå ñâîèõ èãðîêîâ
829 if PlayerHit(1) then
830 begin
831 Result := 1;
832 Exit;
833 end;
834 end;
836 end;
837 end;
839 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
840 begin
841 Result := False;
843 case g_GetUIDType(UID) of
844 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
845 UID_MONSTER: Result := HitMonster(g_Monsters_Get(UID), d, 0, 0, SpawnerUID, t);
846 else Exit;
847 end;
848 end;
850 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
851 var
852 i, h, r, dx, dy, m, mm: Integer;
853 _angle: SmallInt;
854 begin
855 Result := False;
857 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
859 r := rad*rad;
861 h := High(gPlayers);
863 if h <> -1 then
864 for i := 0 to h do
865 if (gPlayers[i] <> nil) and gPlayers[i].Live then
866 with gPlayers[i] do
867 begin
868 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
869 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
871 if dx > 1000 then dx := 1000;
872 if dy > 1000 then dy := 1000;
874 if dx*dx+dy*dy < r then
875 begin
876 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
877 // PLAYER_RECT.Width, PLAYER_RECT.Height);
879 mm := Max(abs(dx), abs(dy));
880 if mm = 0 then mm := 1;
882 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
883 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
884 end;
885 end;
887 h := High(gMonsters);
889 if h <> -1 then
890 for i := 0 to h do
891 if gMonsters[i] <> nil then
892 with gMonsters[i] do
893 begin
894 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
895 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
897 if dx > 1000 then dx := 1000;
898 if dy > 1000 then dy := 1000;
900 if dx*dx+dy*dy < r then
901 begin
902 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
903 // Obj.Rect.Width, Obj.Rect.Height);
905 mm := Max(abs(dx), abs(dy));
906 if mm = 0 then mm := 1;
908 if gMonsters[i].Live then
909 HitMonster(gMonsters[i], ((gMonsters[i].Obj.Rect.Width div 4)*10*(rad-mm)) div rad,
910 0, 0, SpawnerUID, HIT_ROCKET);
912 gMonsters[i].Push((dx*7) div mm, (dy*7) div mm);
913 end;
914 end;
916 h := High(gCorpses);
918 if gAdvCorpses and (h <> -1) then
919 for i := 0 to h do
920 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
921 with gCorpses[i] do
922 begin
923 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
924 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
926 if dx > 1000 then dx := 1000;
927 if dy > 1000 then dy := 1000;
929 if dx*dx+dy*dy < r then
930 begin
931 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
932 Obj.Rect.Width, Obj.Rect.Height);
934 mm := Max(abs(dx), abs(dy));
935 if mm = 0 then mm := 1;
937 Damage(Round(100*(rad-m)/rad), (dx*10) div mm, (dy*10) div mm);
938 end;
939 end;
941 h := High(gGibs);
943 if gAdvGibs and (h <> -1) then
944 for i := 0 to h do
945 if gGibs[i].Live then
946 with gGibs[i] do
947 begin
948 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
949 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
951 if dx > 1000 then dx := 1000;
952 if dy > 1000 then dy := 1000;
954 if dx*dx+dy*dy < r then
955 begin
956 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
957 Obj.Rect.Width, Obj.Rect.Height);
958 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
959 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
961 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
962 end;
963 end;
964 end;
966 procedure g_Weapon_Init();
967 begin
968 CreateWaterMap();
969 end;
971 procedure g_Weapon_Free();
972 var
973 i: Integer;
974 begin
975 if Shots <> nil then
976 begin
977 for i := 0 to High(Shots) do
978 if Shots[i].ShotType <> 0 then
979 Shots[i].Animation.Free();
981 Shots := nil;
982 end;
984 WaterMap := nil;
985 end;
987 procedure g_Weapon_LoadData();
988 begin
989 e_WriteLog('Loading weapons data...', MSG_NOTIFY);
991 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
992 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
993 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
994 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
995 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
996 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
997 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
998 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
999 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1006 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1008 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1010 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1011 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1012 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1013 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1014 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1015 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1016 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1017 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1018 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1019 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1020 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1021 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1022 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1024 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1025 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1026 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1027 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1028 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1029 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1030 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1031 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1032 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1033 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1034 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1035 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1036 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1037 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1038 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1039 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1040 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1041 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1042 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1043 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1044 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1046 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1047 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1048 end;
1050 procedure g_Weapon_FreeData();
1051 begin
1052 e_WriteLog('Releasing weapons data...', MSG_NOTIFY);
1054 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1055 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1056 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1057 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1058 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1059 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1060 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1061 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1062 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1063 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1064 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1065 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1066 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1067 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1068 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1069 g_Sound_Delete('SOUND_FIRE');
1070 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1071 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1072 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1073 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1074 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1075 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1076 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1077 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1078 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1079 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1080 g_Sound_Delete('SOUND_PLAYER_JETON');
1081 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1082 g_Sound_Delete('SOUND_PLAYER_CASING1');
1083 g_Sound_Delete('SOUND_PLAYER_CASING2');
1084 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1085 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1087 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1088 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1089 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1090 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1091 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1092 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1093 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1094 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1095 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1096 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1097 g_Frames_DeleteByName('FRAMES_BFGHIT');
1098 g_Frames_DeleteByName('FRAMES_FIRE');
1099 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1100 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1101 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1102 g_Frames_DeleteByName('FRAMES_SMOKE');
1103 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1104 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1105 end;
1107 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1108 var
1109 a: Integer;
1110 x2, y2: Integer;
1111 dx, dy: Integer;
1112 xe, ye: Integer;
1113 xi, yi: Integer;
1114 s, c: Extended;
1115 //vx, vy: Integer;
1116 xx, yy, d: Integer;
1118 i: Integer;
1119 t1, _collide: Boolean;
1120 w, h: Word;
1121 begin
1122 a := GetAngle(x, y, xd, yd)+180;
1124 SinCos(DegToRad(-a), s, c);
1126 if Abs(s) < 0.01 then s := 0;
1127 if Abs(c) < 0.01 then c := 0;
1129 x2 := x+Round(c*gMapInfo.Width);
1130 y2 := y+Round(s*gMapInfo.Width);
1132 t1 := gWalls <> nil;
1133 _collide := False;
1134 w := gMapInfo.Width;
1135 h := gMapInfo.Height;
1137 xe := 0;
1138 ye := 0;
1139 dx := x2-x;
1140 dy := y2-y;
1142 if (xd = 0) and (yd = 0) then Exit;
1144 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1145 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1147 dx := Abs(dx);
1148 dy := Abs(dy);
1150 if dx > dy then d := dx else d := dy;
1152 //blood vel, for Monster.Damage()
1153 //vx := (dx*10 div d)*xi;
1154 //vy := (dy*10 div d)*yi;
1156 xx := x;
1157 yy := y;
1159 for i := 1 to d do
1160 begin
1161 xe := xe+dx;
1162 ye := ye+dy;
1164 if xe > d then
1165 begin
1166 xe := xe-d;
1167 xx := xx+xi;
1168 end;
1170 if ye > d then
1171 begin
1172 ye := ye-d;
1173 yy := yy+yi;
1174 end;
1176 if (yy > h) or (yy < 0) then Break;
1177 if (xx > w) or (xx < 0) then Break;
1179 if t1 then
1180 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1181 begin
1182 _collide := True;
1183 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1184 if g_Game_IsServer and g_Game_IsNet then
1185 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1186 end;
1188 if not _collide then
1189 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1191 if _collide then
1192 Break;
1193 end;
1195 if CheckTrigger and g_Game_IsServer then
1196 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1197 end;
1199 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1200 var
1201 obj: TObj;
1202 begin
1203 obj.X := X;
1204 obj.Y := Y;
1205 obj.rect.X := 0;
1206 obj.rect.Y := 0;
1207 obj.rect.Width := 39;
1208 obj.rect.Height := 52;
1209 obj.Vel.X := 0;
1210 obj.Vel.Y := 0;
1211 obj.Accel.X := 0;
1212 obj.Accel.Y := 0;
1214 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1215 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1216 else
1217 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1218 end;
1220 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1221 var
1222 obj: TObj;
1223 begin
1224 obj.X := X;
1225 obj.Y := Y;
1226 obj.rect.X := 0;
1227 obj.rect.Y := 0;
1228 obj.rect.Width := 32;
1229 obj.rect.Height := 52;
1230 obj.Vel.X := 0;
1231 obj.Vel.Y := 0;
1232 obj.Accel.X := 0;
1233 obj.Accel.Y := 0;
1235 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1236 end;
1238 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1239 Silent: Boolean = False);
1240 var
1241 find_id: DWORD;
1242 dx, dy: Integer;
1243 begin
1244 if WID < 0 then
1245 find_id := FindShot()
1246 else
1247 begin
1248 find_id := WID;
1249 if Integer(find_id) >= High(Shots) then
1250 SetLength(Shots, find_id + 64)
1251 end;
1253 with Shots[find_id] do
1254 begin
1255 g_Obj_Init(@Obj);
1257 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1258 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1260 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1261 dy := -(Obj.Rect.Height div 2);
1263 ShotType := WEAPON_ROCKETLAUNCHER;
1264 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1266 Animation := nil;
1267 triggers := nil;
1268 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1269 end;
1271 Shots[find_id].SpawnerUID := SpawnerUID;
1273 if not Silent then
1274 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1275 end;
1277 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1278 WID: Integer = -1; Silent: Boolean = False);
1279 var
1280 find_id, FramesID: DWORD;
1281 dx, dy: Integer;
1282 begin
1283 if WID < 0 then
1284 find_id := FindShot()
1285 else
1286 begin
1287 find_id := WID;
1288 if Integer(find_id) >= High(Shots) then
1289 SetLength(Shots, find_id + 64)
1290 end;
1292 with Shots[find_id] do
1293 begin
1294 g_Obj_Init(@Obj);
1296 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1297 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1299 dx := -(Obj.Rect.Width div 2);
1300 dy := -(Obj.Rect.Height div 2);
1302 ShotType := WEAPON_SKEL_FIRE;
1303 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1305 triggers := nil;
1306 target := TargetUID;
1307 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1308 Animation := TAnimation.Create(FramesID, True, 5);
1309 end;
1311 Shots[find_id].SpawnerUID := SpawnerUID;
1313 if not Silent then
1314 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1315 end;
1317 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1318 Silent: Boolean = False);
1319 var
1320 find_id, FramesID: DWORD;
1321 dx, dy: Integer;
1322 begin
1323 if WID < 0 then
1324 find_id := FindShot()
1325 else
1326 begin
1327 find_id := WID;
1328 if Integer(find_id) >= High(Shots) then
1329 SetLength(Shots, find_id + 64);
1330 end;
1332 with Shots[find_id] do
1333 begin
1334 g_Obj_Init(@Obj);
1336 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1337 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1339 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1340 dy := -(Obj.Rect.Height div 2);
1342 ShotType := WEAPON_PLASMA;
1343 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1345 triggers := nil;
1346 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1347 Animation := TAnimation.Create(FramesID, True, 5);
1348 end;
1350 Shots[find_id].SpawnerUID := SpawnerUID;
1352 if not Silent then
1353 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1354 end;
1356 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1357 Silent: Boolean = False);
1358 var
1359 find_id: DWORD;
1360 dx, dy: Integer;
1361 begin
1362 if WID < 0 then
1363 find_id := FindShot()
1364 else
1365 begin
1366 find_id := WID;
1367 if Integer(find_id) >= High(Shots) then
1368 SetLength(Shots, find_id + 64);
1369 end;
1371 with Shots[find_id] do
1372 begin
1373 g_Obj_Init(@Obj);
1375 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1376 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1378 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1379 dy := -(Obj.Rect.Height div 2);
1381 ShotType := WEAPON_FLAMETHROWER;
1382 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1384 triggers := nil;
1385 Animation := nil;
1386 TextureID := 0;
1387 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1388 end;
1390 Shots[find_id].SpawnerUID := SpawnerUID;
1392 // if not Silent then
1393 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1394 end;
1396 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1397 Silent: Boolean = False);
1398 var
1399 find_id, FramesID: DWORD;
1400 dx, dy: Integer;
1401 begin
1402 if WID < 0 then
1403 find_id := FindShot()
1404 else
1405 begin
1406 find_id := WID;
1407 if Integer(find_id) >= High(Shots) then
1408 SetLength(Shots, find_id + 64)
1409 end;
1411 with Shots[find_id] do
1412 begin
1413 g_Obj_Init(@Obj);
1415 Obj.Rect.Width := 16;
1416 Obj.Rect.Height := 16;
1418 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1419 dy := -(Obj.Rect.Height div 2);
1421 ShotType := WEAPON_IMP_FIRE;
1422 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1424 triggers := nil;
1425 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1426 Animation := TAnimation.Create(FramesID, True, 4);
1427 end;
1429 Shots[find_id].SpawnerUID := SpawnerUID;
1431 if not Silent then
1432 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1433 end;
1435 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1436 Silent: Boolean = False);
1437 var
1438 find_id, FramesID: DWORD;
1439 dx, dy: Integer;
1440 begin
1441 if WID < 0 then
1442 find_id := FindShot()
1443 else
1444 begin
1445 find_id := WID;
1446 if Integer(find_id) >= High(Shots) then
1447 SetLength(Shots, find_id + 64)
1448 end;
1450 with Shots[find_id] do
1451 begin
1452 g_Obj_Init(@Obj);
1454 Obj.Rect.Width := 16;
1455 Obj.Rect.Height := 16;
1457 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1458 dy := -(Obj.Rect.Height div 2);
1460 ShotType := WEAPON_CACO_FIRE;
1461 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1463 triggers := nil;
1464 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1465 Animation := TAnimation.Create(FramesID, True, 4);
1466 end;
1468 Shots[find_id].SpawnerUID := SpawnerUID;
1470 if not Silent then
1471 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1472 end;
1474 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1475 Silent: Boolean = False);
1476 var
1477 find_id, FramesID: DWORD;
1478 dx, dy: Integer;
1479 begin
1480 if WID < 0 then
1481 find_id := FindShot()
1482 else
1483 begin
1484 find_id := WID;
1485 if Integer(find_id) >= High(Shots) then
1486 SetLength(Shots, find_id + 64)
1487 end;
1489 with Shots[find_id] do
1490 begin
1491 g_Obj_Init(@Obj);
1493 Obj.Rect.Width := 32;
1494 Obj.Rect.Height := 16;
1496 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1497 dy := -(Obj.Rect.Height div 2);
1499 ShotType := WEAPON_BARON_FIRE;
1500 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1502 triggers := nil;
1503 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1504 Animation := TAnimation.Create(FramesID, True, 4);
1505 end;
1507 Shots[find_id].SpawnerUID := SpawnerUID;
1509 if not Silent then
1510 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1511 end;
1513 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1514 Silent: Boolean = False);
1515 var
1516 find_id, FramesID: DWORD;
1517 dx, dy: Integer;
1518 begin
1519 if WID < 0 then
1520 find_id := FindShot()
1521 else
1522 begin
1523 find_id := WID;
1524 if Integer(find_id) >= High(Shots) then
1525 SetLength(Shots, find_id + 64)
1526 end;
1528 with Shots[find_id] do
1529 begin
1530 g_Obj_Init(@Obj);
1532 Obj.Rect.Width := 16;
1533 Obj.Rect.Height := 16;
1535 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1536 dy := -(Obj.Rect.Height div 2);
1538 ShotType := WEAPON_BSP_FIRE;
1539 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1541 triggers := nil;
1543 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1544 Animation := TAnimation.Create(FramesID, True, 4);
1545 end;
1547 Shots[find_id].SpawnerUID := SpawnerUID;
1549 if not Silent then
1550 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1551 end;
1553 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1554 Silent: Boolean = False);
1555 var
1556 find_id, FramesID: DWORD;
1557 dx, dy: Integer;
1558 begin
1559 if WID < 0 then
1560 find_id := FindShot()
1561 else
1562 begin
1563 find_id := WID;
1564 if Integer(find_id) >= High(Shots) then
1565 SetLength(Shots, find_id + 64)
1566 end;
1568 with Shots[find_id] do
1569 begin
1570 g_Obj_Init(@Obj);
1572 Obj.Rect.Width := 32;
1573 Obj.Rect.Height := 32;
1575 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1576 dy := -(Obj.Rect.Height div 2);
1578 ShotType := WEAPON_MANCUB_FIRE;
1579 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1581 triggers := nil;
1583 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1584 Animation := TAnimation.Create(FramesID, True, 4);
1585 end;
1587 Shots[find_id].SpawnerUID := SpawnerUID;
1589 if not Silent then
1590 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1591 end;
1593 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1594 Silent: Boolean = False);
1595 var
1596 find_id, FramesID: DWORD;
1597 dx, dy: Integer;
1598 begin
1599 if WID < 0 then
1600 find_id := FindShot()
1601 else
1602 begin
1603 find_id := WID;
1604 if Integer(find_id) >= High(Shots) then
1605 SetLength(Shots, find_id + 64)
1606 end;
1608 with Shots[find_id] do
1609 begin
1610 g_Obj_Init(@Obj);
1612 Obj.Rect.Width := SHOT_BFG_WIDTH;
1613 Obj.Rect.Height := SHOT_BFG_HEIGHT;
1615 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1616 dy := -(Obj.Rect.Height div 2);
1618 ShotType := WEAPON_BFG;
1619 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1621 triggers := nil;
1622 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
1623 Animation := TAnimation.Create(FramesID, True, 6);
1624 end;
1626 Shots[find_id].SpawnerUID := SpawnerUID;
1628 if not Silent then
1629 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
1630 end;
1632 procedure g_Weapon_bfghit(x, y: Integer);
1633 var
1634 ID: DWORD;
1635 Anim: TAnimation;
1636 begin
1637 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
1638 begin
1639 Anim := TAnimation.Create(ID, False, 4);
1640 g_GFX_OnceAnim(x-32, y-32, Anim);
1641 Anim.Free();
1642 end;
1643 end;
1645 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
1646 Silent: Boolean = False);
1647 begin
1648 if not Silent then
1649 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
1651 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1652 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
1653 begin
1654 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
1655 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1656 end;
1657 end;
1659 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1660 Silent: Boolean = False);
1661 begin
1662 if not Silent then
1663 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
1665 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1666 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
1667 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1668 begin
1669 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
1670 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1671 end;
1672 end;
1674 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1675 Silent: Boolean = False);
1676 var
1677 i, j: Integer;
1678 begin
1679 if not Silent then
1680 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
1682 for i := 0 to 9 do
1683 begin
1684 j := Random(17)-8; // -8 .. 8
1685 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
1686 end;
1687 end;
1689 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1690 Silent: Boolean = False);
1691 var
1692 a, i, j: Integer;
1693 begin
1694 if not Silent then
1695 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
1697 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
1698 for i := 0 to a do
1699 begin
1700 j := Random(41)-20; // -20 .. 20
1701 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
1702 end;
1703 end;
1705 procedure g_Weapon_Update();
1706 var
1707 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
1708 _id: DWORD;
1709 Anim: TAnimation;
1710 t: DWArray;
1711 st: Word;
1712 s: String;
1713 o: TObj;
1714 spl: Boolean;
1715 Loud: Boolean;
1716 tcx, tcy: Integer;
1717 begin
1718 if Shots = nil then
1719 Exit;
1721 for i := 0 to High(Shots) do
1722 begin
1723 if Shots[i].ShotType = 0 then
1724 Continue;
1726 Loud := True;
1728 with Shots[i] do
1729 begin
1730 Timeout := Timeout - 1;
1731 oldvx := Obj.Vel.X;
1732 oldvy := Obj.Vel.Y;
1733 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1734 if (Stopped = 0) and g_Game_IsServer then
1735 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
1736 SpawnerUID, ACTIVATE_SHOT, triggers)
1737 else
1738 t := nil;
1740 if t <> nil then
1741 begin
1742 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1743 if triggers = nil then
1744 triggers := t
1745 else
1746 begin
1747 h := High(t);
1749 for a := 0 to h do
1750 if not InDWArray(t[a], triggers) then
1751 begin
1752 SetLength(triggers, Length(triggers)+1);
1753 triggers[High(triggers)] := t[a];
1754 end;
1755 end;
1756 end;
1758 // Àíèìàöèÿ ñíàðÿäà:
1759 if Animation <> nil then
1760 Animation.Update();
1762 // Äâèæåíèå:
1763 spl := (ShotType <> WEAPON_PLASMA) and
1764 (ShotType <> WEAPON_BFG) and
1765 (ShotType <> WEAPON_BSP_FIRE) and
1766 (ShotType <> WEAPON_FLAMETHROWER);
1768 if Stopped = 0 then
1769 st := g_Obj_Move(@Obj, False, spl)
1770 else
1771 st := 0;
1773 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
1774 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
1775 begin
1776 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1777 ShotType := 0;
1778 Animation.Free();
1779 Continue;
1780 end;
1782 cx := Obj.X + (Obj.Rect.Width div 2);
1783 cy := Obj.Y + (Obj.Rect.Height div 2);
1785 case ShotType of
1786 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1787 begin
1788 // Âûëåòåëà èç âîäû:
1789 if WordBool(st and MOVE_HITAIR) then
1790 g_Obj_SetSpeed(@Obj, 12);
1792 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1793 if WordBool(st and MOVE_INWATER) then
1794 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
1795 Obj.Y+(Obj.Rect.Height div 2),
1796 1+Random(3), 16, 16)
1797 else
1798 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1799 begin
1800 Anim := TAnimation.Create(_id, False, 3);
1801 Anim.Alpha := 150;
1802 g_GFX_OnceAnim(Obj.X-14+Random(9),
1803 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
1804 Anim, ONCEANIM_SMOKE);
1805 Anim.Free();
1806 end;
1808 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1809 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1810 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
1811 (Timeout < 1) then
1812 begin
1813 Obj.Vel.X := 0;
1814 Obj.Vel.Y := 0;
1816 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
1818 if ShotType = WEAPON_SKEL_FIRE then
1819 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1820 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
1821 begin
1822 Anim := TAnimation.Create(TextureID, False, 8);
1823 Anim.Blending := False;
1824 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
1825 g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
1826 Anim.Free();
1827 end;
1828 end
1829 else
1830 begin // Âçðûâ Ðàêåòû
1831 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
1832 begin
1833 Anim := TAnimation.Create(TextureID, False, 6);
1834 Anim.Blending := False;
1835 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1836 g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
1837 Anim.Free();
1838 end;
1839 end;
1841 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
1843 ShotType := 0;
1844 end;
1846 if ShotType = WEAPON_SKEL_FIRE then
1847 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1848 if GetPos(target, @o) then
1849 throw(i, Obj.X, Obj.Y,
1850 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
1851 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
1852 12);
1853 end;
1854 end;
1856 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1857 begin
1858 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1859 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1860 begin
1861 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
1862 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
1863 ShotType := 0;
1864 Continue;
1865 end;
1867 // Âåëè÷èíà óðîíà:
1868 if (ShotType = WEAPON_PLASMA) and
1869 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1870 a := 10
1871 else
1872 a := 5;
1874 if ShotType = WEAPON_BSP_FIRE then
1875 a := 10;
1877 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1878 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1879 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
1880 (Timeout < 1) then
1881 begin
1882 if ShotType = WEAPON_PLASMA then
1883 s := 'FRAMES_EXPLODE_PLASMA'
1884 else
1885 s := 'FRAMES_EXPLODE_BSPFIRE';
1887 // Âçðûâ Ïëàçìû:
1888 if g_Frames_Get(TextureID, s) then
1889 begin
1890 Anim := TAnimation.Create(TextureID, False, 3);
1891 Anim.Blending := False;
1892 g_GFX_OnceAnim(cx-16, cy-16, Anim);
1893 Anim.Free();
1894 g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
1895 end;
1897 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
1899 ShotType := 0;
1900 end;
1901 end;
1903 WEAPON_FLAMETHROWER: // Îãíåìåò
1904 begin
1905 // Ñî âðåìåíåì óìèðàåò
1906 if (Timeout < 1) then
1907 begin
1908 ShotType := 0;
1909 Continue;
1910 end;
1911 // Ïîä âîäîé òîæå
1912 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
1913 begin
1914 if WordBool(st and MOVE_HITWATER) then
1915 begin
1916 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1917 begin
1918 Anim := TAnimation.Create(_id, False, 3);
1919 Anim.Alpha := 0;
1920 tcx := Random(8);
1921 tcy := Random(8);
1922 g_GFX_OnceAnim(cx-4+tcx-(Anim.Width div 2),
1923 cy-4+tcy-(Anim.Height div 2),
1924 Anim, ONCEANIM_SMOKE);
1925 Anim.Free();
1926 end;
1927 end
1928 else
1929 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
1930 ShotType := 0;
1931 Continue;
1932 end;
1934 // Ãðàâèòàöèÿ
1935 if Stopped = 0 then
1936 Obj.Accel.Y := Obj.Accel.Y + 1;
1937 // Ïîïàëè â ñòåíó èëè â âîäó:
1938 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
1939 begin
1940 // Ïðèëèïàåì:
1941 Obj.Vel.X := 0;
1942 Obj.Vel.Y := 0;
1943 Obj.Accel.Y := 0;
1944 if WordBool(st and MOVE_HITWALL) then
1945 Stopped := MOVE_HITWALL
1946 else if WordBool(st and MOVE_HITLAND) then
1947 Stopped := MOVE_HITLAND
1948 else if WordBool(st and MOVE_HITCEIL) then
1949 Stopped := MOVE_HITCEIL;
1950 end;
1952 a := IfThen(Stopped = 0, 3, 1);
1953 // Åñëè â êîãî-òî ïîïàëè
1954 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
1955 begin
1956 // HIT_FLAME ñàì ïîäîææåò
1957 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1958 if Stopped = 0 then
1959 ShotType := 0;
1960 end;
1962 if Stopped = 0 then
1963 tf := 2
1964 else
1965 tf := 3;
1967 if (gTime mod tf = 0) then
1968 begin
1969 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
1970 Anim.Alpha := 0;
1971 case Stopped of
1972 MOVE_HITWALL: begin tcx := cx-4+Random(8); tcy := cy-12+Random(24); end;
1973 MOVE_HITLAND: begin tcx := cx-12+Random(24); tcy := cy-10+Random(8); end;
1974 MOVE_HITCEIL: begin tcx := cx-12+Random(24); tcy := cy+6+Random(8); end;
1975 else begin tcx := cx-4+Random(8); tcy := cy-4+Random(8); end;
1976 end;
1977 g_GFX_OnceAnim(tcx-(Anim.Width div 2), tcy-(Anim.Height div 2), Anim, ONCEANIM_SMOKE);
1978 Anim.Free();
1979 //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
1980 end;
1981 end;
1983 WEAPON_BFG: // BFG
1984 begin
1985 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1986 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1987 begin
1988 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
1989 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
1990 ShotType := 0;
1991 Continue;
1992 end;
1994 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1995 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1996 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
1997 (Timeout < 1) then
1998 begin
1999 // Ëó÷è BFG:
2000 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
2002 // Âçðûâ BFG:
2003 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
2004 begin
2005 Anim := TAnimation.Create(TextureID, False, 6);
2006 Anim.Blending := False;
2007 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2008 Anim.Free();
2009 g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
2010 end;
2012 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2014 ShotType := 0;
2015 end;
2016 end;
2018 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2019 begin
2020 // Âûëåòåë èç âîäû:
2021 if WordBool(st and MOVE_HITAIR) then
2022 g_Obj_SetSpeed(@Obj, 16);
2024 // Âåëè÷èíà óðîíà:
2025 if ShotType = WEAPON_IMP_FIRE then
2026 a := 5
2027 else
2028 if ShotType = WEAPON_CACO_FIRE then
2029 a := 20
2030 else
2031 a := 40;
2033 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2034 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2035 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2036 (Timeout < 1) then
2037 begin
2038 if ShotType = WEAPON_IMP_FIRE then
2039 s := 'FRAMES_EXPLODE_IMPFIRE'
2040 else
2041 if ShotType = WEAPON_CACO_FIRE then
2042 s := 'FRAMES_EXPLODE_CACOFIRE'
2043 else
2044 s := 'FRAMES_EXPLODE_BARONFIRE';
2046 // Âçðûâ:
2047 if g_Frames_Get(TextureID, s) then
2048 begin
2049 Anim := TAnimation.Create(TextureID, False, 6);
2050 Anim.Blending := False;
2051 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2052 Anim.Free();
2053 end;
2055 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2057 ShotType := 0;
2058 end;
2059 end;
2061 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2062 begin
2063 // Âûëåòåë èç âîäû:
2064 if WordBool(st and MOVE_HITAIR) then
2065 g_Obj_SetSpeed(@Obj, 16);
2067 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2068 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2069 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2070 (Timeout < 1) then
2071 begin
2072 // Âçðûâ:
2073 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2074 begin
2075 Anim := TAnimation.Create(TextureID, False, 6);
2076 Anim.Blending := False;
2077 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2078 Anim.Free();
2079 end;
2081 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2083 ShotType := 0;
2084 end;
2085 end;
2086 end; // case ShotType of...
2088 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2089 if (ShotType = 0) then
2090 begin
2091 if gGameSettings.GameType = GT_SERVER then
2092 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2093 if Animation <> nil then
2094 begin
2095 Animation.Free();
2096 Animation := nil;
2097 end;
2098 end
2099 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2100 if gGameSettings.GameType = GT_SERVER then
2101 MH_SEND_UpdateShot(i);
2102 end;
2103 end;
2104 end;
2106 procedure g_Weapon_Draw();
2107 var
2108 i: Integer;
2109 a: SmallInt;
2110 p: TPoint;
2111 begin
2112 if Shots = nil then
2113 Exit;
2115 for i := 0 to High(Shots) do
2116 if Shots[i].ShotType <> 0 then
2117 with Shots[i] do
2118 begin
2119 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2120 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2121 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2122 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2123 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2124 else
2125 a := 0;
2127 p.X := Obj.Rect.Width div 2;
2128 p.Y := Obj.Rect.Height div 2;
2130 if Animation <> nil then
2131 begin
2132 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2133 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2134 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2135 Animation.DrawEx(Obj.X, Obj.Y, M_NONE, p, a)
2136 else
2137 Animation.Draw(Obj.X, Obj.Y, M_NONE);
2138 end
2139 else if TextureID <> 0 then
2140 begin
2141 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2142 e_DrawAdv(TextureID, Obj.X, Obj.Y, 0, True, False, a, @p, M_NONE)
2143 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2144 e_Draw(TextureID, Obj.X, Obj.Y, 0, True, False);
2145 end;
2147 if g_debug_Frames then
2148 begin
2149 e_DrawQuad(Obj.X+Obj.Rect.X,
2150 Obj.Y+Obj.Rect.Y,
2151 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2152 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2153 0, 255, 0);
2154 end;
2155 end;
2156 end;
2158 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2159 var
2160 a: Integer;
2161 begin
2162 Result := False;
2164 if Shots = nil then
2165 Exit;
2167 for a := 0 to High(Shots) do
2168 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2169 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2170 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2171 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2172 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2173 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2174 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2175 begin
2176 Result := True;
2177 Exit;
2178 end;
2179 end;
2181 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
2182 var
2183 count, i, j: Integer;
2184 dw: DWORD;
2185 begin
2186 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2187 count := 0;
2188 if Shots <> nil then
2189 for i := 0 to High(Shots) do
2190 if Shots[i].ShotType <> 0 then
2191 count := count + 1;
2193 Mem := TBinMemoryWriter.Create((count+1) * 80);
2195 // Êîëè÷åñòâî ñíàðÿäîâ:
2196 Mem.WriteInt(count);
2198 if count = 0 then
2199 Exit;
2201 for i := 0 to High(Shots) do
2202 if Shots[i].ShotType <> 0 then
2203 begin
2204 // Ñèãíàòóðà ñíàðÿäà:
2205 dw := SHOT_SIGNATURE; // 'SHOT'
2206 Mem.WriteDWORD(dw);
2207 // Òèï ñíàðÿäà:
2208 Mem.WriteByte(Shots[i].ShotType);
2209 // Öåëü:
2210 Mem.WriteWord(Shots[i].Target);
2211 // UID ñòðåëÿâøåãî:
2212 Mem.WriteWord(Shots[i].SpawnerUID);
2213 // Ðàçìåð ïîëÿ Triggers:
2214 dw := Length(Shots[i].Triggers);
2215 Mem.WriteDWORD(dw);
2216 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2217 for j := 0 to Integer(dw)-1 do
2218 Mem.WriteDWORD(Shots[i].Triggers[j]);
2219 // Îáúåêò ñíàðÿäà:
2220 Obj_SaveState(@Shots[i].Obj, Mem);
2221 // Êîñòûëèíà åáàíàÿ:
2222 Mem.WriteByte(Shots[i].Stopped);
2223 end;
2224 end;
2226 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
2227 var
2228 count, i, j: Integer;
2229 dw: DWORD;
2230 begin
2231 if Mem = nil then
2232 Exit;
2234 // Êîëè÷åñòâî ñíàðÿäîâ:
2235 Mem.ReadInt(count);
2237 SetLength(Shots, count);
2239 if count = 0 then
2240 Exit;
2242 for i := 0 to count-1 do
2243 begin
2244 // Ñèãíàòóðà ñíàðÿäà:
2245 Mem.ReadDWORD(dw);
2246 if dw <> SHOT_SIGNATURE then // 'SHOT'
2247 begin
2248 raise EBinSizeError.Create('g_Weapons_LoadState: Wrong Shot Signature');
2249 end;
2250 // Òèï ñíàðÿäà:
2251 Mem.ReadByte(Shots[i].ShotType);
2252 // Öåëü:
2253 Mem.ReadWord(Shots[i].Target);
2254 // UID ñòðåëÿâøåãî:
2255 Mem.ReadWord(Shots[i].SpawnerUID);
2256 // Ðàçìåð ïîëÿ Triggers:
2257 Mem.ReadDWORD(dw);
2258 SetLength(Shots[i].Triggers, dw);
2259 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2260 for j := 0 to Integer(dw)-1 do
2261 Mem.ReadDWORD(Shots[i].Triggers[j]);
2262 // Îáúåêò ïðåäìåòà:
2263 Obj_LoadState(@Shots[i].Obj, Mem);
2264 // Êîñòûëèíà åáàíàÿ:
2265 Mem.ReadByte(Shots[i].Stopped);
2267 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2268 Shots[i].TextureID := DWORD(-1);
2269 Shots[i].Animation := nil;
2271 case Shots[i].ShotType of
2272 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2273 begin
2274 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2275 end;
2276 WEAPON_PLASMA:
2277 begin
2278 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2279 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2280 end;
2281 WEAPON_BFG:
2282 begin
2283 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2284 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2285 end;
2286 WEAPON_IMP_FIRE:
2287 begin
2288 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2289 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2290 end;
2291 WEAPON_BSP_FIRE:
2292 begin
2293 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2294 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2295 end;
2296 WEAPON_CACO_FIRE:
2297 begin
2298 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2299 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2300 end;
2301 WEAPON_BARON_FIRE:
2302 begin
2303 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2304 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2305 end;
2306 WEAPON_MANCUB_FIRE:
2307 begin
2308 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2309 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2310 end;
2311 end;
2312 end;
2313 end;
2315 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2316 var
2317 cx, cy: Integer;
2318 Anim: TAnimation;
2319 s: string;
2320 begin
2321 if Shots = nil then
2322 Exit;
2323 if (I > High(Shots)) or (I < 0) then Exit;
2325 with Shots[I] do
2326 begin
2327 if ShotType = 0 then Exit;
2328 Obj.X := X;
2329 Obj.Y := Y;
2330 cx := Obj.X + (Obj.Rect.Width div 2);
2331 cy := Obj.Y + (Obj.Rect.Height div 2);
2333 case ShotType of
2334 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2335 begin
2336 if Loud then
2337 begin
2338 if ShotType = WEAPON_SKEL_FIRE then
2339 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2340 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2341 begin
2342 Anim := TAnimation.Create(TextureID, False, 8);
2343 Anim.Blending := False;
2344 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2345 Anim.Free();
2346 end;
2347 end
2348 else
2349 begin // Âçðûâ Ðàêåòû
2350 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2351 begin
2352 Anim := TAnimation.Create(TextureID, False, 6);
2353 Anim.Blending := False;
2354 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2355 Anim.Free();
2356 end;
2357 end;
2358 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2359 end;
2360 end;
2362 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2363 begin
2364 if ShotType = WEAPON_PLASMA then
2365 s := 'FRAMES_EXPLODE_PLASMA'
2366 else
2367 s := 'FRAMES_EXPLODE_BSPFIRE';
2369 if g_Frames_Get(TextureID, s) and loud then
2370 begin
2371 Anim := TAnimation.Create(TextureID, False, 3);
2372 Anim.Blending := False;
2373 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2374 Anim.Free();
2376 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2377 end;
2378 end;
2380 WEAPON_BFG: // BFG
2381 begin
2382 // Âçðûâ BFG:
2383 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2384 begin
2385 Anim := TAnimation.Create(TextureID, False, 6);
2386 Anim.Blending := False;
2387 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2388 Anim.Free();
2390 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2391 end;
2392 end;
2394 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2395 begin
2396 if ShotType = WEAPON_IMP_FIRE then
2397 s := 'FRAMES_EXPLODE_IMPFIRE'
2398 else
2399 if ShotType = WEAPON_CACO_FIRE then
2400 s := 'FRAMES_EXPLODE_CACOFIRE'
2401 else
2402 s := 'FRAMES_EXPLODE_BARONFIRE';
2404 if g_Frames_Get(TextureID, s) and Loud then
2405 begin
2406 Anim := TAnimation.Create(TextureID, False, 6);
2407 Anim.Blending := False;
2408 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2409 Anim.Free();
2411 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2412 end;
2413 end;
2415 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2416 begin
2417 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2418 begin
2419 Anim := TAnimation.Create(TextureID, False, 6);
2420 Anim.Blending := False;
2421 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2422 Anim.Free();
2424 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2425 end;
2426 end;
2427 end; // case ShotType of...
2429 ShotType := 0;
2430 Animation.Free();
2431 end;
2432 end;
2435 procedure g_Weapon_AddDynLights();
2436 var
2437 i: Integer;
2438 begin
2439 if Shots = nil then Exit;
2440 for i := 0 to High(Shots) do
2441 begin
2442 if Shots[i].ShotType = 0 then continue;
2443 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2444 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2445 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2446 (Shots[i].ShotType = WEAPON_SKEL_FIRE) or
2447 (Shots[i].ShotType = WEAPON_IMP_FIRE) or
2448 (Shots[i].ShotType = WEAPON_CACO_FIRE) or
2449 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2450 (Shots[i].ShotType = WEAPON_BSP_FIRE) or
2451 (Shots[i].ShotType = WEAPON_PLASMA) or
2452 (Shots[i].ShotType = WEAPON_BFG) or
2453 (Shots[i].ShotType = WEAPON_FLAMETHROWER) or
2454 false then
2455 begin
2456 if (Shots[i].ShotType = WEAPON_PLASMA) then
2457 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)
2458 else if (Shots[i].ShotType = WEAPON_BFG) 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, 1, 0, 0.5)
2460 else if (Shots[i].ShotType = WEAPON_FLAMETHROWER) 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), 42, 1, 0.8, 0, 0.4)
2462 else
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), 128, 1, 0, 0, 0.4);
2464 end;
2465 end;
2466 end;
2468 end.