DEADSOFTWARE

2e2521b72f9956912574ac8a2eba69f71fe2ede4
[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 {$MODE DELPHI}
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 const
92 WEAPON_KASTET = 0;
93 WEAPON_SAW = 1;
94 WEAPON_PISTOL = 2;
95 WEAPON_SHOTGUN1 = 3;
96 WEAPON_SHOTGUN2 = 4;
97 WEAPON_CHAINGUN = 5;
98 WEAPON_ROCKETLAUNCHER = 6;
99 WEAPON_PLASMA = 7;
100 WEAPON_BFG = 8;
101 WEAPON_SUPERPULEMET = 9;
102 WEAPON_FLAMETHROWER = 10;
103 WEAPON_ZOMBY_PISTOL = 20;
104 WEAPON_IMP_FIRE = 21;
105 WEAPON_BSP_FIRE = 22;
106 WEAPON_CACO_FIRE = 23;
107 WEAPON_BARON_FIRE = 24;
108 WEAPON_MANCUB_FIRE = 25;
109 WEAPON_SKEL_FIRE = 26;
111 WP_FIRST = WEAPON_KASTET;
112 WP_LAST = WEAPON_FLAMETHROWER;
114 implementation
116 uses
117 Math, g_map, g_player, g_gfx, g_sound, g_main,
118 g_console, SysUtils, g_options, g_game,
119 g_triggers, MAPDEF, e_log, g_monsters, g_saveload,
120 g_language, g_netmsg;
122 type
123 TWaterPanel = record
124 X, Y: Integer;
125 Width, Height: Word;
126 Active: Boolean;
127 end;
129 const
130 SHOT_ROCKETLAUNCHER_WIDTH = 14;
131 SHOT_ROCKETLAUNCHER_HEIGHT = 14;
133 SHOT_SKELFIRE_WIDTH = 14;
134 SHOT_SKELFIRE_HEIGHT = 14;
136 SHOT_PLASMA_WIDTH = 16;
137 SHOT_PLASMA_HEIGHT = 16;
139 SHOT_BFG_WIDTH = 32;
140 SHOT_BFG_HEIGHT = 32;
141 SHOT_BFG_DAMAGE = 100;
142 SHOT_BFG_RADIUS = 256;
144 SHOT_FLAME_WIDTH = 4;
145 SHOT_FLAME_HEIGHT = 4;
146 SHOT_FLAME_LIFETIME = 180;
148 SHOT_SIGNATURE = $544F4853; // 'SHOT'
150 var
151 WaterMap: array of array of DWORD = nil;
153 function FindShot(): DWORD;
154 var
155 i: Integer;
156 begin
157 if Shots <> nil then
158 for i := 0 to High(Shots) do
159 if Shots[i].ShotType = 0 then
160 begin
161 Result := i;
162 LastShotID := Result;
163 Exit;
164 end;
166 if Shots = nil then
167 begin
168 SetLength(Shots, 128);
169 Result := 0;
170 end
171 else
172 begin
173 Result := High(Shots) + 1;
174 SetLength(Shots, Length(Shots) + 128);
175 end;
176 LastShotID := Result;
177 end;
179 procedure CreateWaterMap();
180 var
181 WaterArray: Array of TWaterPanel;
182 a, b, c, m: Integer;
183 ok: Boolean;
184 begin
185 if gWater = nil then
186 Exit;
188 SetLength(WaterArray, Length(gWater));
190 for a := 0 to High(gWater) do
191 begin
192 WaterArray[a].X := gWater[a].X;
193 WaterArray[a].Y := gWater[a].Y;
194 WaterArray[a].Width := gWater[a].Width;
195 WaterArray[a].Height := gWater[a].Height;
196 WaterArray[a].Active := True;
197 end;
199 g_Game_SetLoadingText(_lc[I_LOAD_WATER_MAP], High(WaterArray), False);
201 for a := 0 to High(WaterArray) do
202 if WaterArray[a].Active then
203 begin
204 WaterArray[a].Active := False;
205 m := Length(WaterMap);
206 SetLength(WaterMap, m+1);
207 SetLength(WaterMap[m], 1);
208 WaterMap[m][0] := a;
209 ok := True;
211 while ok do
212 begin
213 ok := False;
214 for b := 0 to High(WaterArray) do
215 if WaterArray[b].Active then
216 for c := 0 to High(WaterMap[m]) do
217 if g_CollideAround(WaterArray[b].X,
218 WaterArray[b].Y,
219 WaterArray[b].Width,
220 WaterArray[b].Height,
221 WaterArray[WaterMap[m][c]].X,
222 WaterArray[WaterMap[m][c]].Y,
223 WaterArray[WaterMap[m][c]].Width,
224 WaterArray[WaterMap[m][c]].Height) then
225 begin
226 WaterArray[b].Active := False;
227 SetLength(WaterMap[m],
228 Length(WaterMap[m])+1);
229 WaterMap[m][High(WaterMap[m])] := b;
230 ok := True;
231 Break;
232 end;
233 end;
235 g_Game_StepLoading();
236 end;
238 WaterArray := nil;
239 end;
241 procedure CheckTrap(ID: DWORD; dm: Integer; t: Byte);
242 var
243 a, b, c, d, i1, i2: Integer;
244 pl, mn: WArray;
245 begin
246 if (gWater = nil) or (WaterMap = nil) then Exit;
248 i1 := -1;
249 i2 := -1;
251 SetLength(pl, 1024);
252 SetLength(mn, 1024);
253 for d := 0 to 1023 do pl[d] := $FFFF;
254 for d := 0 to 1023 do mn[d] := $FFFF;
256 for a := 0 to High(WaterMap) do
257 for b := 0 to High(WaterMap[a]) do
258 begin
259 if not g_Obj_Collide(gWater[WaterMap[a][b]].X, gWater[WaterMap[a][b]].Y,
260 gWater[WaterMap[a][b]].Width, gWater[WaterMap[a][b]].Height,
261 @Shots[ID].Obj) then Continue;
263 for c := 0 to High(WaterMap[a]) do
264 begin
265 if gPlayers <> nil then
266 begin
267 for d := 0 to High(gPlayers) do
268 if (gPlayers[d] <> nil) and (gPlayers[d].Live) then
269 if gPlayers[d].Collide(gWater[WaterMap[a][c]]) then
270 if not InWArray(d, pl) then
271 if i1 < 1023 then
272 begin
273 i1 := i1+1;
274 pl[i1] := d;
275 end;
276 end;
278 if gMonsters <> nil then
279 begin
280 for d := 0 to High(gMonsters) do
281 if (gMonsters[d] <> nil) and (gMonsters[d].Live) then
282 if gMonsters[d].Collide(gWater[WaterMap[a][c]]) then
283 if not InWArray(d, mn) then
284 if i2 < 1023 then
285 begin
286 i2 := i2+1;
287 mn[i2] := d;
288 end;
289 end;
290 end;
292 if i1 <> -1 then
293 for d := 0 to i1 do
294 gPlayers[pl[d]].Damage(dm, Shots[ID].SpawnerUID, 0, 0, t);
296 if i2 <> -1 then
297 for d := 0 to i2 do
298 gMonsters[mn[d]].Damage(dm, 0, 0, Shots[ID].SpawnerUID, t);
299 end;
301 pl := nil;
302 mn := nil;
303 end;
305 function HitMonster(m: TMonster; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
306 var
307 tt, mt: Byte;
308 mon: TMonster;
309 begin
310 Result := False;
312 tt := g_GetUIDType(SpawnerUID);
313 if tt = UID_MONSTER then
314 begin
315 mon := g_Monsters_Get(SpawnerUID);
316 if mon <> nil then
317 mt := g_Monsters_Get(SpawnerUID).MonsterType
318 else
319 mt := 0;
320 end
321 else
322 mt := 0;
324 if m = nil then Exit;
325 if m.UID = SpawnerUID then
326 begin
327 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
328 if (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then
329 Exit;
330 // Êèáåð äåìîí è áî÷êà âîîáùå íå ìîãóò ñåáÿ ðàíèòü:
331 if (m.MonsterType = MONSTER_CYBER) or
332 (m.MonsterType = MONSTER_BARREL) then
333 begin
334 Result := True;
335 Exit;
336 end;
337 end;
339 if tt = UID_MONSTER then
340 begin
341 // Lost_Soul íå ìîæåò ðàíèòü Pain_Elemental'à:
342 if (mt = MONSTER_SOUL) and (m.MonsterType = MONSTER_PAIN) then
343 Exit;
345 // Îáà ìîíñòðà îäíîãî âèäà:
346 if mt = m.MonsterType then
347 case mt of
348 MONSTER_IMP, MONSTER_DEMON, MONSTER_BARON, MONSTER_KNIGHT, MONSTER_CACO,
349 MONSTER_SOUL, MONSTER_MANCUB, MONSTER_SKEL, MONSTER_FISH:
350 Exit; // Ýòè íå áüþò ñâîèõ
351 end;
352 end;
354 if g_Game_IsServer then
355 begin
356 if (t <> HIT_FLAME) or (m.FFireTime = 0) or (vx <> 0) or (vy <> 0) then
357 Result := m.Damage(d, vx, vy, SpawnerUID, t)
358 else
359 Result := True;
360 if t = HIT_FLAME then
361 m.CatchFire(SpawnerUID);
362 end
363 else
364 Result := True;
365 end;
367 function HitPlayer(p: TPlayer; d: Integer; vx, vy: Integer; SpawnerUID: Word; t: Byte): Boolean;
368 begin
369 Result := False;
371 // Ñàì ñåáÿ ìîæåò ðàíèòü òîëüêî ðàêåòîé è òîêîì:
372 if (p.UID = SpawnerUID) and (t <> HIT_ROCKET) and (t <> HIT_ELECTRO) then
373 Exit;
375 if g_Game_IsServer then
376 begin
377 if (t <> HIT_FLAME) or (p.FFireTime = 0) or (vx <> 0) or (vy <> 0) then
378 p.Damage(d, SpawnerUID, vx, vy, t);
379 if (t = HIT_FLAME) then
380 p.CatchFire(SpawnerUID);
381 end;
383 Result := True;
384 end;
386 function GunHit(X, Y: Integer; vx, vy: Integer; dmg: Integer;
387 SpawnerUID: Word; AllowPush: Boolean): Byte;
388 var
389 i, h: Integer;
390 begin
391 Result := 0;
393 h := High(gPlayers);
395 if h <> -1 then
396 for i := 0 to h do
397 if (gPlayers[i] <> nil) and gPlayers[i].Live and gPlayers[i].Collide(X, Y) then
398 if HitPlayer(gPlayers[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
399 begin
400 if AllowPush then gPlayers[i].Push(vx, vy);
401 Result := 1;
402 end;
404 if Result <> 0 then Exit;
406 h := High(gMonsters);
408 if h <> -1 then
409 for i := 0 to h do
410 if (gMonsters[i] <> nil) and gMonsters[i].Live and gMonsters[i].Collide(X, Y) then
411 if HitMonster(gMonsters[i], dmg, vx*10, vy*10-3, SpawnerUID, HIT_SOME) then
412 begin
413 if AllowPush then gMonsters[i].Push(vx, vy);
414 Result := 2;
415 Exit;
416 end;
417 end;
419 procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word);
420 var
421 i, h: Integer;
422 st: Byte;
423 pl: TPlayer;
424 b: Boolean;
425 begin
426 //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
428 h := High(gCorpses);
430 if gAdvCorpses and (h <> -1) then
431 for i := 0 to h do
432 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
433 with gCorpses[i] do
434 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
435 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
436 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
437 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
438 begin
439 Damage(50, 0, 0);
440 g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
441 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2));
442 end;
444 st := TEAM_NONE;
445 pl := g_Player_Get(SpawnerUID);
446 if pl <> nil then
447 st := pl.Team;
449 h := High(gPlayers);
451 if h <> -1 then
452 for i := 0 to h do
453 if (gPlayers[i] <> nil) and (gPlayers[i].Live) and (gPlayers[i].UID <> SpawnerUID) then
454 with gPlayers[i] do
455 if (g_PatchLength(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
456 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) <= SHOT_BFG_RADIUS) and
457 g_TraceVector(X, Y, GameX+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
458 GameY+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)) then
459 begin
460 if (st = TEAM_NONE) or (st <> gPlayers[i].Team) then
461 b := HitPlayer(gPlayers[i], 50, 0, 0, SpawnerUID, HIT_SOME)
462 else
463 b := HitPlayer(gPlayers[i], 25, 0, 0, SpawnerUID, HIT_SOME);
464 if b then
465 gPlayers[i].BFGHit();
466 end;
468 h := High(gMonsters);
470 if h <> -1 then
471 for i := 0 to h do
472 if (gMonsters[i] <> nil) and (gMonsters[i].Live) and (gMonsters[i].UID <> SpawnerUID) then
473 with gMonsters[i] do
474 if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
475 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
476 g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
477 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
478 if HitMonster(gMonsters[i], 50, 0, 0, SpawnerUID, HIT_SOME) then gMonsters[i].BFGHit();
479 end;
481 function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
482 var
483 find_id, FramesID: DWORD;
484 begin
485 if I < 0 then
486 find_id := FindShot()
487 else
488 begin
489 find_id := I;
490 if Integer(find_id) >= High(Shots) then
491 SetLength(Shots, find_id + 64)
492 end;
494 case ShotType of
495 WEAPON_ROCKETLAUNCHER:
496 begin
497 with Shots[find_id] do
498 begin
499 g_Obj_Init(@Obj);
501 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
502 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
504 Animation := nil;
505 Triggers := nil;
506 ShotType := WEAPON_ROCKETLAUNCHER;
507 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
508 end;
509 end;
511 WEAPON_PLASMA:
512 begin
513 with Shots[find_id] do
514 begin
515 g_Obj_Init(@Obj);
517 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
518 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
520 Triggers := nil;
521 ShotType := WEAPON_PLASMA;
522 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
523 Animation := TAnimation.Create(FramesID, True, 5);
524 end;
525 end;
527 WEAPON_BFG:
528 begin
529 with Shots[find_id] do
530 begin
531 g_Obj_Init(@Obj);
533 Obj.Rect.Width := SHOT_BFG_WIDTH;
534 Obj.Rect.Height := SHOT_BFG_HEIGHT;
536 Triggers := nil;
537 ShotType := WEAPON_BFG;
538 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
539 Animation := TAnimation.Create(FramesID, True, 6);
540 end;
541 end;
543 WEAPON_FLAMETHROWER:
544 begin
545 with Shots[find_id] do
546 begin
547 g_Obj_Init(@Obj);
549 Obj.Rect.Width := SHOT_FLAME_WIDTH;
550 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
552 Triggers := nil;
553 ShotType := WEAPON_FLAMETHROWER;
554 Animation := nil;
555 TextureID := 0;
556 g_Frames_Get(TextureID, 'FRAMES_FLAME');
557 Stopped := 0;
558 end;
559 end;
561 WEAPON_IMP_FIRE:
562 begin
563 with Shots[find_id] do
564 begin
565 g_Obj_Init(@Obj);
567 Obj.Rect.Width := 16;
568 Obj.Rect.Height := 16;
570 Triggers := nil;
571 ShotType := WEAPON_IMP_FIRE;
572 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
573 Animation := TAnimation.Create(FramesID, True, 4);
574 end;
575 end;
577 WEAPON_CACO_FIRE:
578 begin
579 with Shots[find_id] do
580 begin
581 g_Obj_Init(@Obj);
583 Obj.Rect.Width := 16;
584 Obj.Rect.Height := 16;
586 Triggers := nil;
587 ShotType := WEAPON_CACO_FIRE;
588 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
589 Animation := TAnimation.Create(FramesID, True, 4);
590 end;
591 end;
593 WEAPON_MANCUB_FIRE:
594 begin
595 with Shots[find_id] do
596 begin
597 g_Obj_Init(@Obj);
599 Obj.Rect.Width := 32;
600 Obj.Rect.Height := 32;
602 Triggers := nil;
603 ShotType := WEAPON_MANCUB_FIRE;
604 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
605 Animation := TAnimation.Create(FramesID, True, 4);
606 end;
607 end;
609 WEAPON_BARON_FIRE:
610 begin
611 with Shots[find_id] do
612 begin
613 g_Obj_Init(@Obj);
615 Obj.Rect.Width := 32;
616 Obj.Rect.Height := 16;
618 Triggers := nil;
619 ShotType := WEAPON_BARON_FIRE;
620 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
621 Animation := TAnimation.Create(FramesID, True, 4);
622 end;
623 end;
625 WEAPON_BSP_FIRE:
626 begin
627 with Shots[find_id] do
628 begin
629 g_Obj_Init(@Obj);
631 Obj.Rect.Width := 16;
632 Obj.Rect.Height := 16;
634 Triggers := nil;
635 ShotType := WEAPON_BSP_FIRE;
636 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
637 Animation := TAnimation.Create(FramesID, True, 4);
638 end;
639 end;
641 WEAPON_SKEL_FIRE:
642 begin
643 with Shots[find_id] do
644 begin
645 g_Obj_Init(@Obj);
647 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
648 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
650 Triggers := nil;
651 ShotType := WEAPON_SKEL_FIRE;
652 target := TargetUID;
653 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
654 Animation := TAnimation.Create(FramesID, True, 5);
655 end;
656 end;
657 end;
659 Shots[find_id].Obj.X := X;
660 Shots[find_id].Obj.Y := Y;
661 Shots[find_id].Obj.Vel.X := XV;
662 Shots[find_id].Obj.Vel.Y := YV;
663 Shots[find_id].Obj.Accel.X := 0;
664 Shots[find_id].Obj.Accel.Y := 0;
665 Shots[find_id].SpawnerUID := Spawner;
666 Result := find_id;
667 end;
669 procedure throw(i, x, y, xd, yd, s: Integer);
670 var
671 a: Integer;
672 begin
673 yd := yd - y;
674 xd := xd - x;
676 a := Max(Abs(xd), Abs(yd));
677 if a = 0 then
678 a := 1;
680 Shots[i].Obj.X := x;
681 Shots[i].Obj.Y := y;
682 Shots[i].Obj.Vel.X := (xd*s) div a;
683 Shots[i].Obj.Vel.Y := (yd*s) div a;
684 Shots[i].Obj.Accel.X := 0;
685 Shots[i].Obj.Accel.Y := 0;
686 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BFG] then
687 Shots[i].Timeout := 900 // ~25 sec
688 else
689 begin
690 if Shots[i].ShotType = WEAPON_FLAMETHROWER then
691 Shots[i].Timeout := SHOT_FLAME_LIFETIME
692 else
693 Shots[i].Timeout := 550; // ~15 sec
694 end;
695 end;
697 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
698 var
699 i, h: Integer;
701 function PlayerHit(Team: Byte = 0): Boolean;
702 var
703 i: Integer;
704 ChkTeam: Boolean;
705 p: TPlayer;
706 begin
707 Result := False;
708 h := High(gPlayers);
710 if h <> -1 then
711 for i := 0 to h do
712 if (gPlayers[i] <> nil) and gPlayers[i].Live and g_Obj_Collide(obj, @gPlayers[i].Obj) then
713 begin
714 ChkTeam := True;
715 if (Team > 0) and (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
716 begin
717 p := g_Player_Get(SpawnerUID);
718 if p <> nil then
719 ChkTeam := (p.Team = gPlayers[i].Team) xor (Team = 2);
720 end;
721 if ChkTeam then
722 if HitPlayer(gPlayers[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
723 begin
724 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
725 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
726 if t = HIT_BFG then
727 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
728 Result := True;
729 break;
730 end;
731 end;
732 end;
733 function MonsterHit(): Boolean;
734 var
735 i: Integer;
736 begin
737 Result := False;
738 h := High(gMonsters);
740 if h <> -1 then
741 for i := 0 to h do
742 if (gMonsters[i] <> nil) and gMonsters[i].Live and g_Obj_Collide(obj, @gMonsters[i].Obj) then
743 if HitMonster(gMonsters[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
744 begin
745 gMonsters[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
746 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
747 Result := True;
748 break;
749 end;
750 end;
751 begin
752 Result := 0;
754 if HitCorpses then
755 begin
756 h := High(gCorpses);
758 if gAdvCorpses and (h <> -1) then
759 for i := 0 to h do
760 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
761 g_Obj_Collide(obj, @gCorpses[i].Obj) then
762 begin
763 // Ðàñïèëèâàåì òðóï:
764 gCorpses[i].Damage(d, (obj^.Vel.X+obj^.Accel.X) div 4,
765 (obj^.Vel.Y+obj^.Accel.Y) div 4);
766 Result := 1;
767 end;
768 end;
770 case gGameSettings.GameMode of
771 // Êàìïàíèÿ:
772 GM_COOP, GM_SINGLE:
773 begin
774 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
775 if MonsterHit() then
776 begin
777 Result := 2;
778 Exit;
779 end;
781 if PlayerHit() then
782 begin
783 Result := 1;
784 Exit;
785 end;
786 end;
788 // Äåçìàò÷:
789 GM_DM:
790 begin
791 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
792 if PlayerHit() then
793 begin
794 Result := 1;
795 Exit;
796 end;
798 if MonsterHit() then
799 begin
800 Result := 2;
801 Exit;
802 end;
803 end;
805 // Êîìàíäíûå:
806 GM_TDM, GM_CTF:
807 begin
808 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
809 if PlayerHit(2) then
810 begin
811 Result := 1;
812 Exit;
813 end;
815 // Ïîòîì ìîíñòðîâ
816 if MonsterHit() then
817 begin
818 Result := 2;
819 Exit;
820 end;
822 // È â êîíöå ñâîèõ èãðîêîâ
823 if PlayerHit(1) then
824 begin
825 Result := 1;
826 Exit;
827 end;
828 end;
830 end;
831 end;
833 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
834 begin
835 Result := False;
837 case g_GetUIDType(UID) of
838 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
839 UID_MONSTER: Result := HitMonster(g_Monsters_Get(UID), d, 0, 0, SpawnerUID, t);
840 else Exit;
841 end;
842 end;
844 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
845 var
846 i, h, r, dx, dy, m, mm: Integer;
847 _angle: SmallInt;
848 begin
849 Result := False;
851 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
853 r := rad*rad;
855 h := High(gPlayers);
857 if h <> -1 then
858 for i := 0 to h do
859 if (gPlayers[i] <> nil) and gPlayers[i].Live then
860 with gPlayers[i] do
861 begin
862 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
863 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
865 if dx > 1000 then dx := 1000;
866 if dy > 1000 then dy := 1000;
868 if dx*dx+dy*dy < r then
869 begin
870 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
871 // PLAYER_RECT.Width, PLAYER_RECT.Height);
873 mm := Max(abs(dx), abs(dy));
874 if mm = 0 then mm := 1;
876 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
877 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
878 end;
879 end;
881 h := High(gMonsters);
883 if h <> -1 then
884 for i := 0 to h do
885 if gMonsters[i] <> nil then
886 with gMonsters[i] do
887 begin
888 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
889 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
891 if dx > 1000 then dx := 1000;
892 if dy > 1000 then dy := 1000;
894 if dx*dx+dy*dy < r then
895 begin
896 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
897 // Obj.Rect.Width, Obj.Rect.Height);
899 mm := Max(abs(dx), abs(dy));
900 if mm = 0 then mm := 1;
902 if gMonsters[i].Live then
903 HitMonster(gMonsters[i], ((gMonsters[i].Obj.Rect.Width div 4)*10*(rad-mm)) div rad,
904 0, 0, SpawnerUID, HIT_ROCKET);
906 gMonsters[i].Push((dx*7) div mm, (dy*7) div mm);
907 end;
908 end;
910 h := High(gCorpses);
912 if gAdvCorpses and (h <> -1) then
913 for i := 0 to h do
914 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
915 with gCorpses[i] do
916 begin
917 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
918 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
920 if dx > 1000 then dx := 1000;
921 if dy > 1000 then dy := 1000;
923 if dx*dx+dy*dy < r then
924 begin
925 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
926 Obj.Rect.Width, Obj.Rect.Height);
928 mm := Max(abs(dx), abs(dy));
929 if mm = 0 then mm := 1;
931 Damage(Round(100*(rad-m)/rad), (dx*10) div mm, (dy*10) div mm);
932 end;
933 end;
935 h := High(gGibs);
937 if gAdvGibs and (h <> -1) then
938 for i := 0 to h do
939 if gGibs[i].Live then
940 with gGibs[i] do
941 begin
942 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
943 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
945 if dx > 1000 then dx := 1000;
946 if dy > 1000 then dy := 1000;
948 if dx*dx+dy*dy < r then
949 begin
950 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
951 Obj.Rect.Width, Obj.Rect.Height);
952 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
953 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
955 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
956 end;
957 end;
958 end;
960 procedure g_Weapon_Init();
961 begin
962 CreateWaterMap();
963 end;
965 procedure g_Weapon_Free();
966 var
967 i: Integer;
968 begin
969 if Shots <> nil then
970 begin
971 for i := 0 to High(Shots) do
972 if Shots[i].ShotType <> 0 then
973 Shots[i].Animation.Free();
975 Shots := nil;
976 end;
978 WaterMap := nil;
979 end;
981 procedure g_Weapon_LoadData();
982 begin
983 e_WriteLog('Loading weapons data...', MSG_NOTIFY);
985 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
986 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
987 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
988 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
989 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
990 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
991 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
992 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
993 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
994 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
995 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
996 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
997 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
998 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
999 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1000 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1006 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1008 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1010 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1011 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1012 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1013 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1014 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1015 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1016 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1018 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1019 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1020 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1021 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1022 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1023 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1024 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1025 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1026 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1027 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1028 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1029 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1030 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1031 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1032 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1033 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1034 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1035 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1036 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1037 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1038 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1040 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1041 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1042 end;
1044 procedure g_Weapon_FreeData();
1045 begin
1046 e_WriteLog('Releasing weapons data...', MSG_NOTIFY);
1048 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1049 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1050 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1051 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1052 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1053 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1054 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1055 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1056 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1057 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1058 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1059 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1060 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1061 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1062 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1063 g_Sound_Delete('SOUND_FIRE');
1064 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1065 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1066 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1067 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1068 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1069 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1070 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1071 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1072 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1073 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1074 g_Sound_Delete('SOUND_PLAYER_JETON');
1075 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1076 g_Sound_Delete('SOUND_PLAYER_CASING1');
1077 g_Sound_Delete('SOUND_PLAYER_CASING2');
1078 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1079 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1081 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1082 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1083 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1084 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1085 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1086 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1087 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1088 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1089 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1090 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1091 g_Frames_DeleteByName('FRAMES_BFGHIT');
1092 g_Frames_DeleteByName('FRAMES_FIRE');
1093 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1094 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1095 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1096 g_Frames_DeleteByName('FRAMES_SMOKE');
1097 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1098 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1099 end;
1101 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1102 var
1103 a: Integer;
1104 x2, y2: Integer;
1105 dx, dy: Integer;
1106 xe, ye: Integer;
1107 xi, yi: Integer;
1108 s, c: Extended;
1109 //vx, vy: Integer;
1110 xx, yy, d: Integer;
1112 i: Integer;
1113 t1, _collide: Boolean;
1114 w, h: Word;
1115 begin
1116 a := GetAngle(x, y, xd, yd)+180;
1118 SinCos(DegToRad(-a), s, c);
1120 if Abs(s) < 0.01 then s := 0;
1121 if Abs(c) < 0.01 then c := 0;
1123 x2 := x+Round(c*gMapInfo.Width);
1124 y2 := y+Round(s*gMapInfo.Width);
1126 t1 := gWalls <> nil;
1127 _collide := False;
1128 w := gMapInfo.Width;
1129 h := gMapInfo.Height;
1131 xe := 0;
1132 ye := 0;
1133 dx := x2-x;
1134 dy := y2-y;
1136 if (xd = 0) and (yd = 0) then Exit;
1138 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1139 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1141 dx := Abs(dx);
1142 dy := Abs(dy);
1144 if dx > dy then d := dx else d := dy;
1146 //blood vel, for Monster.Damage()
1147 //vx := (dx*10 div d)*xi;
1148 //vy := (dy*10 div d)*yi;
1150 xx := x;
1151 yy := y;
1153 for i := 1 to d do
1154 begin
1155 xe := xe+dx;
1156 ye := ye+dy;
1158 if xe > d then
1159 begin
1160 xe := xe-d;
1161 xx := xx+xi;
1162 end;
1164 if ye > d then
1165 begin
1166 ye := ye-d;
1167 yy := yy+yi;
1168 end;
1170 if (yy > h) or (yy < 0) then Break;
1171 if (xx > w) or (xx < 0) then Break;
1173 if t1 then
1174 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1175 begin
1176 _collide := True;
1177 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1178 if g_Game_IsServer and g_Game_IsNet then
1179 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1180 end;
1182 if not _collide then
1183 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1185 if _collide then
1186 Break;
1187 end;
1189 if CheckTrigger and g_Game_IsServer then
1190 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1191 end;
1193 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1194 var
1195 obj: TObj;
1196 begin
1197 obj.X := X;
1198 obj.Y := Y;
1199 obj.rect.X := 0;
1200 obj.rect.Y := 0;
1201 obj.rect.Width := 39;
1202 obj.rect.Height := 52;
1203 obj.Vel.X := 0;
1204 obj.Vel.Y := 0;
1205 obj.Accel.X := 0;
1206 obj.Accel.Y := 0;
1208 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1209 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1210 else
1211 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1212 end;
1214 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1215 var
1216 obj: TObj;
1217 begin
1218 obj.X := X;
1219 obj.Y := Y;
1220 obj.rect.X := 0;
1221 obj.rect.Y := 0;
1222 obj.rect.Width := 32;
1223 obj.rect.Height := 52;
1224 obj.Vel.X := 0;
1225 obj.Vel.Y := 0;
1226 obj.Accel.X := 0;
1227 obj.Accel.Y := 0;
1229 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1230 end;
1232 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1233 Silent: Boolean = False);
1234 var
1235 find_id: DWORD;
1236 dx, dy: Integer;
1237 begin
1238 if WID < 0 then
1239 find_id := FindShot()
1240 else
1241 begin
1242 find_id := WID;
1243 if Integer(find_id) >= High(Shots) then
1244 SetLength(Shots, find_id + 64)
1245 end;
1247 with Shots[find_id] do
1248 begin
1249 g_Obj_Init(@Obj);
1251 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1252 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1254 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1255 dy := -(Obj.Rect.Height div 2);
1257 ShotType := WEAPON_ROCKETLAUNCHER;
1258 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1260 Animation := nil;
1261 triggers := nil;
1262 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1263 end;
1265 Shots[find_id].SpawnerUID := SpawnerUID;
1267 if not Silent then
1268 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1269 end;
1271 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1272 WID: Integer = -1; Silent: Boolean = False);
1273 var
1274 find_id, FramesID: DWORD;
1275 dx, dy: Integer;
1276 begin
1277 if WID < 0 then
1278 find_id := FindShot()
1279 else
1280 begin
1281 find_id := WID;
1282 if Integer(find_id) >= High(Shots) then
1283 SetLength(Shots, find_id + 64)
1284 end;
1286 with Shots[find_id] do
1287 begin
1288 g_Obj_Init(@Obj);
1290 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1291 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1293 dx := -(Obj.Rect.Width div 2);
1294 dy := -(Obj.Rect.Height div 2);
1296 ShotType := WEAPON_SKEL_FIRE;
1297 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1299 triggers := nil;
1300 target := TargetUID;
1301 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1302 Animation := TAnimation.Create(FramesID, True, 5);
1303 end;
1305 Shots[find_id].SpawnerUID := SpawnerUID;
1307 if not Silent then
1308 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1309 end;
1311 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1312 Silent: Boolean = False);
1313 var
1314 find_id, FramesID: DWORD;
1315 dx, dy: Integer;
1316 begin
1317 if WID < 0 then
1318 find_id := FindShot()
1319 else
1320 begin
1321 find_id := WID;
1322 if Integer(find_id) >= High(Shots) then
1323 SetLength(Shots, find_id + 64);
1324 end;
1326 with Shots[find_id] do
1327 begin
1328 g_Obj_Init(@Obj);
1330 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1331 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1333 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1334 dy := -(Obj.Rect.Height div 2);
1336 ShotType := WEAPON_PLASMA;
1337 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1339 triggers := nil;
1340 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1341 Animation := TAnimation.Create(FramesID, True, 5);
1342 end;
1344 Shots[find_id].SpawnerUID := SpawnerUID;
1346 if not Silent then
1347 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1348 end;
1350 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1351 Silent: Boolean = False);
1352 var
1353 find_id, FramesID: DWORD;
1354 dx, dy: Integer;
1355 begin
1356 if WID < 0 then
1357 find_id := FindShot()
1358 else
1359 begin
1360 find_id := WID;
1361 if Integer(find_id) >= High(Shots) then
1362 SetLength(Shots, find_id + 64);
1363 end;
1365 with Shots[find_id] do
1366 begin
1367 g_Obj_Init(@Obj);
1369 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1370 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1372 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1373 dy := -(Obj.Rect.Height div 2);
1375 ShotType := WEAPON_FLAMETHROWER;
1376 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1378 triggers := nil;
1379 Animation := nil;
1380 TextureID := 0;
1381 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1382 Stopped := 0;
1383 end;
1385 Shots[find_id].SpawnerUID := SpawnerUID;
1387 // if not Silent then
1388 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1389 end;
1391 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1392 Silent: Boolean = False);
1393 var
1394 find_id, FramesID: DWORD;
1395 dx, dy: Integer;
1396 begin
1397 if WID < 0 then
1398 find_id := FindShot()
1399 else
1400 begin
1401 find_id := WID;
1402 if Integer(find_id) >= High(Shots) then
1403 SetLength(Shots, find_id + 64)
1404 end;
1406 with Shots[find_id] do
1407 begin
1408 g_Obj_Init(@Obj);
1410 Obj.Rect.Width := 16;
1411 Obj.Rect.Height := 16;
1413 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1414 dy := -(Obj.Rect.Height div 2);
1416 ShotType := WEAPON_IMP_FIRE;
1417 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1419 triggers := nil;
1420 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1421 Animation := TAnimation.Create(FramesID, True, 4);
1422 end;
1424 Shots[find_id].SpawnerUID := SpawnerUID;
1426 if not Silent then
1427 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1428 end;
1430 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1431 Silent: Boolean = False);
1432 var
1433 find_id, FramesID: DWORD;
1434 dx, dy: Integer;
1435 begin
1436 if WID < 0 then
1437 find_id := FindShot()
1438 else
1439 begin
1440 find_id := WID;
1441 if Integer(find_id) >= High(Shots) then
1442 SetLength(Shots, find_id + 64)
1443 end;
1445 with Shots[find_id] do
1446 begin
1447 g_Obj_Init(@Obj);
1449 Obj.Rect.Width := 16;
1450 Obj.Rect.Height := 16;
1452 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1453 dy := -(Obj.Rect.Height div 2);
1455 ShotType := WEAPON_CACO_FIRE;
1456 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1458 triggers := nil;
1459 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1460 Animation := TAnimation.Create(FramesID, True, 4);
1461 end;
1463 Shots[find_id].SpawnerUID := SpawnerUID;
1465 if not Silent then
1466 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1467 end;
1469 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1470 Silent: Boolean = False);
1471 var
1472 find_id, FramesID: DWORD;
1473 dx, dy: Integer;
1474 begin
1475 if WID < 0 then
1476 find_id := FindShot()
1477 else
1478 begin
1479 find_id := WID;
1480 if Integer(find_id) >= High(Shots) then
1481 SetLength(Shots, find_id + 64)
1482 end;
1484 with Shots[find_id] do
1485 begin
1486 g_Obj_Init(@Obj);
1488 Obj.Rect.Width := 32;
1489 Obj.Rect.Height := 16;
1491 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1492 dy := -(Obj.Rect.Height div 2);
1494 ShotType := WEAPON_BARON_FIRE;
1495 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1497 triggers := nil;
1498 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1499 Animation := TAnimation.Create(FramesID, True, 4);
1500 end;
1502 Shots[find_id].SpawnerUID := SpawnerUID;
1504 if not Silent then
1505 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1506 end;
1508 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1509 Silent: Boolean = False);
1510 var
1511 find_id, FramesID: DWORD;
1512 dx, dy: Integer;
1513 begin
1514 if WID < 0 then
1515 find_id := FindShot()
1516 else
1517 begin
1518 find_id := WID;
1519 if Integer(find_id) >= High(Shots) then
1520 SetLength(Shots, find_id + 64)
1521 end;
1523 with Shots[find_id] do
1524 begin
1525 g_Obj_Init(@Obj);
1527 Obj.Rect.Width := 16;
1528 Obj.Rect.Height := 16;
1530 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1531 dy := -(Obj.Rect.Height div 2);
1533 ShotType := WEAPON_BSP_FIRE;
1534 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1536 triggers := nil;
1538 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1539 Animation := TAnimation.Create(FramesID, True, 4);
1540 end;
1542 Shots[find_id].SpawnerUID := SpawnerUID;
1544 if not Silent then
1545 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1546 end;
1548 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1549 Silent: Boolean = False);
1550 var
1551 find_id, FramesID: DWORD;
1552 dx, dy: Integer;
1553 begin
1554 if WID < 0 then
1555 find_id := FindShot()
1556 else
1557 begin
1558 find_id := WID;
1559 if Integer(find_id) >= High(Shots) then
1560 SetLength(Shots, find_id + 64)
1561 end;
1563 with Shots[find_id] do
1564 begin
1565 g_Obj_Init(@Obj);
1567 Obj.Rect.Width := 32;
1568 Obj.Rect.Height := 32;
1570 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1571 dy := -(Obj.Rect.Height div 2);
1573 ShotType := WEAPON_MANCUB_FIRE;
1574 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1576 triggers := nil;
1578 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1579 Animation := TAnimation.Create(FramesID, True, 4);
1580 end;
1582 Shots[find_id].SpawnerUID := SpawnerUID;
1584 if not Silent then
1585 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1586 end;
1588 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1589 Silent: Boolean = False);
1590 var
1591 find_id, FramesID: DWORD;
1592 dx, dy: Integer;
1593 begin
1594 if WID < 0 then
1595 find_id := FindShot()
1596 else
1597 begin
1598 find_id := WID;
1599 if Integer(find_id) >= High(Shots) then
1600 SetLength(Shots, find_id + 64)
1601 end;
1603 with Shots[find_id] do
1604 begin
1605 g_Obj_Init(@Obj);
1607 Obj.Rect.Width := SHOT_BFG_WIDTH;
1608 Obj.Rect.Height := SHOT_BFG_HEIGHT;
1610 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1611 dy := -(Obj.Rect.Height div 2);
1613 ShotType := WEAPON_BFG;
1614 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1616 triggers := nil;
1617 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
1618 Animation := TAnimation.Create(FramesID, True, 6);
1619 end;
1621 Shots[find_id].SpawnerUID := SpawnerUID;
1623 if not Silent then
1624 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
1625 end;
1627 procedure g_Weapon_bfghit(x, y: Integer);
1628 var
1629 ID: DWORD;
1630 Anim: TAnimation;
1631 begin
1632 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
1633 begin
1634 Anim := TAnimation.Create(ID, False, 4);
1635 g_GFX_OnceAnim(x-32, y-32, Anim);
1636 Anim.Free();
1637 end;
1638 end;
1640 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
1641 Silent: Boolean = False);
1642 begin
1643 if not Silent then
1644 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
1646 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1647 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
1648 begin
1649 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
1650 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1651 end;
1652 end;
1654 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1655 Silent: Boolean = False);
1656 begin
1657 if not Silent then
1658 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
1660 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1661 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
1662 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1663 begin
1664 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
1665 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1666 end;
1667 end;
1669 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1670 Silent: Boolean = False);
1671 var
1672 i, j: Integer;
1673 begin
1674 if not Silent then
1675 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
1677 for i := 0 to 9 do
1678 begin
1679 j := Random(17)-8; // -8 .. 8
1680 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
1681 end;
1682 end;
1684 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1685 Silent: Boolean = False);
1686 var
1687 a, i, j: Integer;
1688 begin
1689 if not Silent then
1690 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
1692 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
1693 for i := 0 to a do
1694 begin
1695 j := Random(41)-20; // -20 .. 20
1696 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
1697 end;
1698 end;
1700 procedure g_Weapon_Update();
1701 var
1702 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
1703 _id: DWORD;
1704 Anim: TAnimation;
1705 t: DWArray;
1706 st: Word;
1707 s: String;
1708 o: TObj;
1709 spl: Boolean;
1710 Loud: Boolean;
1711 begin
1712 if Shots = nil then
1713 Exit;
1715 for i := 0 to High(Shots) do
1716 begin
1717 if Shots[i].ShotType = 0 then
1718 Continue;
1720 Loud := True;
1722 with Shots[i] do
1723 begin
1724 Timeout := Timeout - 1;
1725 oldvx := Obj.Vel.X;
1726 oldvy := Obj.Vel.Y;
1727 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1728 if g_Game_IsServer then
1729 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
1730 SpawnerUID, ACTIVATE_SHOT, triggers)
1731 else
1732 t := nil;
1734 if t <> nil then
1735 begin
1736 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1737 if triggers = nil then
1738 triggers := t
1739 else
1740 begin
1741 h := High(t);
1743 for a := 0 to h do
1744 if not InDWArray(t[a], triggers) then
1745 begin
1746 SetLength(triggers, Length(triggers)+1);
1747 triggers[High(triggers)] := t[a];
1748 end;
1749 end;
1750 end;
1752 // Àíèìàöèÿ ñíàðÿäà:
1753 if Animation <> nil then
1754 Animation.Update();
1756 // Äâèæåíèå:
1757 spl := (ShotType <> WEAPON_PLASMA) and
1758 (ShotType <> WEAPON_BFG) and
1759 (ShotType <> WEAPON_BSP_FIRE) and
1760 (ShotType <> WEAPON_FLAMETHROWER);
1762 st := g_Obj_Move(@Obj, False, spl);
1764 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
1765 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
1766 begin
1767 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1768 ShotType := 0;
1769 Animation.Free();
1770 Continue;
1771 end;
1773 cx := Obj.X + (Obj.Rect.Width div 2);
1774 cy := Obj.Y + (Obj.Rect.Height div 2);
1776 case ShotType of
1777 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1778 begin
1779 // Âûëåòåëà èç âîäû:
1780 if WordBool(st and MOVE_HITAIR) then
1781 g_Obj_SetSpeed(@Obj, 12);
1783 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1784 if WordBool(st and MOVE_INWATER) then
1785 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
1786 Obj.Y+(Obj.Rect.Height div 2),
1787 1+Random(3), 16, 16)
1788 else
1789 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1790 begin
1791 Anim := TAnimation.Create(_id, False, 3);
1792 Anim.Alpha := 150;
1793 g_GFX_OnceAnim(Obj.X-14+Random(9),
1794 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
1795 Anim, ONCEANIM_SMOKE);
1796 Anim.Free();
1797 end;
1799 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1800 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1801 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
1802 (Timeout < 1) then
1803 begin
1804 Obj.Vel.X := 0;
1805 Obj.Vel.Y := 0;
1807 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
1809 if ShotType = WEAPON_SKEL_FIRE then
1810 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1811 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
1812 begin
1813 Anim := TAnimation.Create(TextureID, False, 8);
1814 Anim.Blending := False;
1815 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
1816 Anim.Free();
1817 end;
1818 end
1819 else
1820 begin // Âçðûâ Ðàêåòû
1821 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
1822 begin
1823 Anim := TAnimation.Create(TextureID, False, 6);
1824 Anim.Blending := False;
1825 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1826 Anim.Free();
1827 end;
1828 end;
1830 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
1832 ShotType := 0;
1833 end;
1835 if ShotType = WEAPON_SKEL_FIRE then
1836 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1837 if GetPos(target, @o) then
1838 throw(i, Obj.X, Obj.Y,
1839 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
1840 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
1841 12);
1842 end;
1843 end;
1845 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1846 begin
1847 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1848 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1849 begin
1850 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
1851 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
1852 ShotType := 0;
1853 Continue;
1854 end;
1856 // Âåëè÷èíà óðîíà:
1857 if (ShotType = WEAPON_PLASMA) and
1858 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1859 a := 10
1860 else
1861 a := 5;
1863 if ShotType = WEAPON_BSP_FIRE then
1864 a := 10;
1866 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1867 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1868 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
1869 (Timeout < 1) then
1870 begin
1871 if ShotType = WEAPON_PLASMA then
1872 s := 'FRAMES_EXPLODE_PLASMA'
1873 else
1874 s := 'FRAMES_EXPLODE_BSPFIRE';
1876 // Âçðûâ Ïëàçìû:
1877 if g_Frames_Get(TextureID, s) then
1878 begin
1879 Anim := TAnimation.Create(TextureID, False, 3);
1880 Anim.Blending := False;
1881 g_GFX_OnceAnim(cx-16, cy-16, Anim);
1882 Anim.Free();
1883 end;
1885 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
1887 ShotType := 0;
1888 end;
1889 end;
1891 WEAPON_FLAMETHROWER: // Îãíåìåò
1892 begin
1893 // Ñî âðåìåíåì óìèðàåò
1894 if (Timeout < 1) then
1895 begin
1896 ShotType := 0;
1897 Continue;
1898 end;
1899 // Ïîä âîäîé òîæå
1900 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
1901 begin
1902 if WordBool(st and MOVE_HITWATER) then
1903 begin
1904 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1905 begin
1906 Anim := TAnimation.Create(_id, False, 3);
1907 Anim.Alpha := 0;
1908 g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1909 cy-4+Random(8)-(Anim.Height div 2),
1910 Anim, ONCEANIM_SMOKE);
1911 Anim.Free();
1912 end;
1913 end
1914 else
1915 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
1916 ShotType := 0;
1917 Continue;
1918 end;
1920 // Ãðàâèòàöèÿ
1921 if Stopped = 0 then
1922 Obj.Accel.Y := Obj.Accel.Y + 1;
1923 // Ïîïàëè â ñòåíó èëè â âîäó:
1924 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
1925 begin
1926 // Ïðèëèïàåì:
1927 Obj.Vel.X := 0;
1928 Obj.Vel.Y := 0;
1929 Obj.Accel.Y := 0;
1930 if WordBool(st and MOVE_HITWALL) then
1931 Stopped := MOVE_HITWALL
1932 else if WordBool(st and MOVE_HITLAND) then
1933 Stopped := MOVE_HITLAND
1934 else if WordBool(st and MOVE_HITCEIL) then
1935 Stopped := MOVE_HITCEIL;
1936 end;
1938 a := IfThen(Stopped = 0, 3, 1);
1939 // Åñëè â êîãî-òî ïîïàëè
1940 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
1941 begin
1942 // HIT_FLAME ñàì ïîäîææåò
1943 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1944 if Stopped = 0 then
1945 ShotType := 0;
1946 end;
1948 if Stopped = 0 then
1949 tf := 2
1950 else
1951 tf := 3;
1953 if (gTime mod tf = 0) then
1954 begin
1955 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
1956 Anim.Alpha := 0;
1957 case Stopped of
1958 0: g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1959 cy-4+Random(8)-(Anim.Height div 2),
1960 Anim, ONCEANIM_SMOKE);
1961 MOVE_HITWALL: g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1962 cy-12+Random(24)-(Anim.Height div 2),
1963 Anim, ONCEANIM_SMOKE);
1964 MOVE_HITLAND: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1965 cy-10+Random(8)-(Anim.Height div 2),
1966 Anim, ONCEANIM_SMOKE);
1967 MOVE_HITCEIL: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1968 cy+6+Random(8)-(Anim.Height div 2),
1969 Anim, ONCEANIM_SMOKE);
1970 end;
1971 Anim.Free();
1972 end;
1973 end;
1975 WEAPON_BFG: // BFG
1976 begin
1977 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1978 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1979 begin
1980 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
1981 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
1982 ShotType := 0;
1983 Continue;
1984 end;
1986 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1987 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1988 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
1989 (Timeout < 1) then
1990 begin
1991 // Ëó÷è BFG:
1992 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
1994 // Âçðûâ BFG:
1995 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
1996 begin
1997 Anim := TAnimation.Create(TextureID, False, 6);
1998 Anim.Blending := False;
1999 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2000 Anim.Free();
2001 end;
2003 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2005 ShotType := 0;
2006 end;
2007 end;
2009 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2010 begin
2011 // Âûëåòåë èç âîäû:
2012 if WordBool(st and MOVE_HITAIR) then
2013 g_Obj_SetSpeed(@Obj, 16);
2015 // Âåëè÷èíà óðîíà:
2016 if ShotType = WEAPON_IMP_FIRE then
2017 a := 5
2018 else
2019 if ShotType = WEAPON_CACO_FIRE then
2020 a := 20
2021 else
2022 a := 40;
2024 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2025 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2026 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2027 (Timeout < 1) then
2028 begin
2029 if ShotType = WEAPON_IMP_FIRE then
2030 s := 'FRAMES_EXPLODE_IMPFIRE'
2031 else
2032 if ShotType = WEAPON_CACO_FIRE then
2033 s := 'FRAMES_EXPLODE_CACOFIRE'
2034 else
2035 s := 'FRAMES_EXPLODE_BARONFIRE';
2037 // Âçðûâ:
2038 if g_Frames_Get(TextureID, s) then
2039 begin
2040 Anim := TAnimation.Create(TextureID, False, 6);
2041 Anim.Blending := False;
2042 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2043 Anim.Free();
2044 end;
2046 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2048 ShotType := 0;
2049 end;
2050 end;
2052 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2053 begin
2054 // Âûëåòåë èç âîäû:
2055 if WordBool(st and MOVE_HITAIR) then
2056 g_Obj_SetSpeed(@Obj, 16);
2058 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2059 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2060 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2061 (Timeout < 1) then
2062 begin
2063 // Âçðûâ:
2064 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2065 begin
2066 Anim := TAnimation.Create(TextureID, False, 6);
2067 Anim.Blending := False;
2068 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2069 Anim.Free();
2070 end;
2072 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2074 ShotType := 0;
2075 end;
2076 end;
2077 end; // case ShotType of...
2079 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2080 if (ShotType = 0) then
2081 begin
2082 if gGameSettings.GameType = GT_SERVER then
2083 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2084 if Animation <> nil then
2085 begin
2086 Animation.Free();
2087 Animation := nil;
2088 end;
2089 end
2090 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2091 if gGameSettings.GameType = GT_SERVER then
2092 MH_SEND_UpdateShot(i);
2093 end;
2094 end;
2095 end;
2097 procedure g_Weapon_Draw();
2098 var
2099 i: Integer;
2100 a: SmallInt;
2101 p: TPoint;
2102 begin
2103 if Shots = nil then
2104 Exit;
2106 for i := 0 to High(Shots) do
2107 if Shots[i].ShotType <> 0 then
2108 with Shots[i] do
2109 begin
2110 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2111 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2112 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2113 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2114 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2115 else
2116 a := 0;
2118 p.X := Obj.Rect.Width div 2;
2119 p.Y := Obj.Rect.Height div 2;
2121 if Animation <> nil then
2122 begin
2123 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2124 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2125 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2126 Animation.DrawEx(Obj.X, Obj.Y, M_NONE, p, a)
2127 else
2128 Animation.Draw(Obj.X, Obj.Y, M_NONE);
2129 end
2130 else if TextureID <> 0 then
2131 begin
2132 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2133 e_DrawAdv(TextureID, Obj.X, Obj.Y, 0, True, False, a, @p, M_NONE)
2134 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2135 e_Draw(TextureID, Obj.X, Obj.Y, 0, True, False);
2136 end;
2138 if g_debug_Frames then
2139 begin
2140 e_DrawQuad(Obj.X+Obj.Rect.X,
2141 Obj.Y+Obj.Rect.Y,
2142 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2143 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2144 0, 255, 0);
2145 end;
2146 end;
2147 end;
2149 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2150 var
2151 a: Integer;
2152 begin
2153 Result := False;
2155 if Shots = nil then
2156 Exit;
2158 for a := 0 to High(Shots) do
2159 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2160 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2161 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2162 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2163 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2164 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2165 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2166 begin
2167 Result := True;
2168 Exit;
2169 end;
2170 end;
2172 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
2173 var
2174 count, i, j: Integer;
2175 dw: DWORD;
2176 begin
2177 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2178 count := 0;
2179 if Shots <> nil then
2180 for i := 0 to High(Shots) do
2181 if Shots[i].ShotType <> 0 then
2182 count := count + 1;
2184 Mem := TBinMemoryWriter.Create((count+1) * 80);
2186 // Êîëè÷åñòâî ñíàðÿäîâ:
2187 Mem.WriteInt(count);
2189 if count = 0 then
2190 Exit;
2192 for i := 0 to High(Shots) do
2193 if Shots[i].ShotType <> 0 then
2194 begin
2195 // Ñèãíàòóðà ñíàðÿäà:
2196 dw := SHOT_SIGNATURE; // 'SHOT'
2197 Mem.WriteDWORD(dw);
2198 // Òèï ñíàðÿäà:
2199 Mem.WriteByte(Shots[i].ShotType);
2200 // Öåëü:
2201 Mem.WriteWord(Shots[i].Target);
2202 // UID ñòðåëÿâøåãî:
2203 Mem.WriteWord(Shots[i].SpawnerUID);
2204 // Ðàçìåð ïîëÿ Triggers:
2205 dw := Length(Shots[i].Triggers);
2206 Mem.WriteDWORD(dw);
2207 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2208 for j := 0 to Integer(dw)-1 do
2209 Mem.WriteDWORD(Shots[i].Triggers[j]);
2210 // Îáúåêò ñíàðÿäà:
2211 Obj_SaveState(@Shots[i].Obj, Mem);
2212 // Êîñòûëèíà åáàíàÿ:
2213 Mem.WriteByte(Shots[i].Stopped);
2214 end;
2215 end;
2217 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
2218 var
2219 count, i, j: Integer;
2220 dw: DWORD;
2221 begin
2222 if Mem = nil then
2223 Exit;
2225 // Êîëè÷åñòâî ñíàðÿäîâ:
2226 Mem.ReadInt(count);
2228 SetLength(Shots, count);
2230 if count = 0 then
2231 Exit;
2233 for i := 0 to count-1 do
2234 begin
2235 // Ñèãíàòóðà ñíàðÿäà:
2236 Mem.ReadDWORD(dw);
2237 if dw <> SHOT_SIGNATURE then // 'SHOT'
2238 begin
2239 raise EBinSizeError.Create('g_Weapons_LoadState: Wrong Shot Signature');
2240 end;
2241 // Òèï ñíàðÿäà:
2242 Mem.ReadByte(Shots[i].ShotType);
2243 // Öåëü:
2244 Mem.ReadWord(Shots[i].Target);
2245 // UID ñòðåëÿâøåãî:
2246 Mem.ReadWord(Shots[i].SpawnerUID);
2247 // Ðàçìåð ïîëÿ Triggers:
2248 Mem.ReadDWORD(dw);
2249 SetLength(Shots[i].Triggers, dw);
2250 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2251 for j := 0 to Integer(dw)-1 do
2252 Mem.ReadDWORD(Shots[i].Triggers[j]);
2253 // Îáúåêò ïðåäìåòà:
2254 Obj_LoadState(@Shots[i].Obj, Mem);
2255 // Êîñòûëèíà åáàíàÿ:
2256 Mem.ReadByte(Shots[i].Stopped);
2258 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2259 Shots[i].TextureID := DWORD(-1);
2260 Shots[i].Animation := nil;
2262 case Shots[i].ShotType of
2263 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2264 begin
2265 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2266 end;
2267 WEAPON_PLASMA:
2268 begin
2269 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2270 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2271 end;
2272 WEAPON_BFG:
2273 begin
2274 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2275 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2276 end;
2277 WEAPON_IMP_FIRE:
2278 begin
2279 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2280 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2281 end;
2282 WEAPON_BSP_FIRE:
2283 begin
2284 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2285 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2286 end;
2287 WEAPON_CACO_FIRE:
2288 begin
2289 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2290 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2291 end;
2292 WEAPON_BARON_FIRE:
2293 begin
2294 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2295 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2296 end;
2297 WEAPON_MANCUB_FIRE:
2298 begin
2299 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2300 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2301 end;
2302 end;
2303 end;
2304 end;
2306 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2307 var
2308 cx, cy: Integer;
2309 Anim: TAnimation;
2310 s: string;
2311 begin
2312 if Shots = nil then
2313 Exit;
2314 if (I > High(Shots)) or (I < 0) then Exit;
2316 with Shots[I] do
2317 begin
2318 if ShotType = 0 then Exit;
2319 Obj.X := X;
2320 Obj.Y := Y;
2321 cx := Obj.X + (Obj.Rect.Width div 2);
2322 cy := Obj.Y + (Obj.Rect.Height div 2);
2324 case ShotType of
2325 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2326 begin
2327 if Loud then
2328 begin
2329 if ShotType = WEAPON_SKEL_FIRE then
2330 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2331 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2332 begin
2333 Anim := TAnimation.Create(TextureID, False, 8);
2334 Anim.Blending := False;
2335 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2336 Anim.Free();
2337 end;
2338 end
2339 else
2340 begin // Âçðûâ Ðàêåòû
2341 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2342 begin
2343 Anim := TAnimation.Create(TextureID, False, 6);
2344 Anim.Blending := False;
2345 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2346 Anim.Free();
2347 end;
2348 end;
2349 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2350 end;
2351 end;
2353 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2354 begin
2355 if ShotType = WEAPON_PLASMA then
2356 s := 'FRAMES_EXPLODE_PLASMA'
2357 else
2358 s := 'FRAMES_EXPLODE_BSPFIRE';
2360 if g_Frames_Get(TextureID, s) and loud then
2361 begin
2362 Anim := TAnimation.Create(TextureID, False, 3);
2363 Anim.Blending := False;
2364 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2365 Anim.Free();
2367 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2368 end;
2369 end;
2371 WEAPON_BFG: // BFG
2372 begin
2373 // Âçðûâ BFG:
2374 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2375 begin
2376 Anim := TAnimation.Create(TextureID, False, 6);
2377 Anim.Blending := False;
2378 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2379 Anim.Free();
2381 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2382 end;
2383 end;
2385 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2386 begin
2387 if ShotType = WEAPON_IMP_FIRE then
2388 s := 'FRAMES_EXPLODE_IMPFIRE'
2389 else
2390 if ShotType = WEAPON_CACO_FIRE then
2391 s := 'FRAMES_EXPLODE_CACOFIRE'
2392 else
2393 s := 'FRAMES_EXPLODE_BARONFIRE';
2395 if g_Frames_Get(TextureID, s) and Loud then
2396 begin
2397 Anim := TAnimation.Create(TextureID, False, 6);
2398 Anim.Blending := False;
2399 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2400 Anim.Free();
2402 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2403 end;
2404 end;
2406 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2407 begin
2408 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2409 begin
2410 Anim := TAnimation.Create(TextureID, False, 6);
2411 Anim.Blending := False;
2412 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2413 Anim.Free();
2415 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2416 end;
2417 end;
2418 end; // case ShotType of...
2420 ShotType := 0;
2421 Animation.Free();
2422 end;
2423 end;
2425 end.