DEADSOFTWARE

slightly altered flame behavior
[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 = 360;
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();
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();
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 Stopped := 0;
557 end;
558 end;
560 WEAPON_IMP_FIRE:
561 begin
562 with Shots[find_id] do
563 begin
564 g_Obj_Init(@Obj);
566 Obj.Rect.Width := 16;
567 Obj.Rect.Height := 16;
569 Triggers := nil;
570 ShotType := WEAPON_IMP_FIRE;
571 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
572 Animation := TAnimation.Create(FramesID, True, 4);
573 end;
574 end;
576 WEAPON_CACO_FIRE:
577 begin
578 with Shots[find_id] do
579 begin
580 g_Obj_Init(@Obj);
582 Obj.Rect.Width := 16;
583 Obj.Rect.Height := 16;
585 Triggers := nil;
586 ShotType := WEAPON_CACO_FIRE;
587 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
588 Animation := TAnimation.Create(FramesID, True, 4);
589 end;
590 end;
592 WEAPON_MANCUB_FIRE:
593 begin
594 with Shots[find_id] do
595 begin
596 g_Obj_Init(@Obj);
598 Obj.Rect.Width := 32;
599 Obj.Rect.Height := 32;
601 Triggers := nil;
602 ShotType := WEAPON_MANCUB_FIRE;
603 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
604 Animation := TAnimation.Create(FramesID, True, 4);
605 end;
606 end;
608 WEAPON_BARON_FIRE:
609 begin
610 with Shots[find_id] do
611 begin
612 g_Obj_Init(@Obj);
614 Obj.Rect.Width := 32;
615 Obj.Rect.Height := 16;
617 Triggers := nil;
618 ShotType := WEAPON_BARON_FIRE;
619 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
620 Animation := TAnimation.Create(FramesID, True, 4);
621 end;
622 end;
624 WEAPON_BSP_FIRE:
625 begin
626 with Shots[find_id] do
627 begin
628 g_Obj_Init(@Obj);
630 Obj.Rect.Width := 16;
631 Obj.Rect.Height := 16;
633 Triggers := nil;
634 ShotType := WEAPON_BSP_FIRE;
635 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
636 Animation := TAnimation.Create(FramesID, True, 4);
637 end;
638 end;
640 WEAPON_SKEL_FIRE:
641 begin
642 with Shots[find_id] do
643 begin
644 g_Obj_Init(@Obj);
646 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
647 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
649 Triggers := nil;
650 ShotType := WEAPON_SKEL_FIRE;
651 target := TargetUID;
652 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
653 Animation := TAnimation.Create(FramesID, True, 5);
654 end;
655 end;
656 end;
658 Shots[find_id].Obj.X := X;
659 Shots[find_id].Obj.Y := Y;
660 Shots[find_id].Obj.Vel.X := XV;
661 Shots[find_id].Obj.Vel.Y := YV;
662 Shots[find_id].Obj.Accel.X := 0;
663 Shots[find_id].Obj.Accel.Y := 0;
664 Shots[find_id].SpawnerUID := Spawner;
665 Result := find_id;
666 end;
668 procedure throw(i, x, y, xd, yd, s: Integer);
669 var
670 a: Integer;
671 begin
672 yd := yd - y;
673 xd := xd - x;
675 a := Max(Abs(xd), Abs(yd));
676 if a = 0 then
677 a := 1;
679 Shots[i].Obj.X := x;
680 Shots[i].Obj.Y := y;
681 Shots[i].Obj.Vel.X := (xd*s) div a;
682 Shots[i].Obj.Vel.Y := (yd*s) div a;
683 Shots[i].Obj.Accel.X := 0;
684 Shots[i].Obj.Accel.Y := 0;
685 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BFG] then
686 Shots[i].Timeout := 900 // ~25 sec
687 else if Shots[i].ShotType = WEAPON_FLAMETHROWER then
688 Shots[i].Timeout := SHOT_FLAME_LIFETIME
689 else
690 Shots[i].Timeout := 550 // ~15 sec
691 end;
693 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
694 var
695 i, h: Integer;
697 function PlayerHit(Team: Byte = 0): Boolean;
698 var
699 i: Integer;
700 ChkTeam: Boolean;
701 p: TPlayer;
702 begin
703 Result := False;
704 h := High(gPlayers);
706 if h <> -1 then
707 for i := 0 to h do
708 if (gPlayers[i] <> nil) and gPlayers[i].Live and g_Obj_Collide(obj, @gPlayers[i].Obj) then
709 begin
710 ChkTeam := True;
711 if (Team > 0) and (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
712 begin
713 p := g_Player_Get(SpawnerUID);
714 if p <> nil then
715 ChkTeam := (p.Team = gPlayers[i].Team) xor (Team = 2);
716 end;
717 if ChkTeam then
718 if HitPlayer(gPlayers[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
719 begin
720 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
721 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
722 if t = HIT_BFG then
723 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
724 Result := True;
725 break;
726 end;
727 end;
728 end;
729 function MonsterHit(): Boolean;
730 var
731 i: Integer;
732 begin
733 Result := False;
734 h := High(gMonsters);
736 if h <> -1 then
737 for i := 0 to h do
738 if (gMonsters[i] <> nil) and gMonsters[i].Live and g_Obj_Collide(obj, @gMonsters[i].Obj) then
739 if HitMonster(gMonsters[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
740 begin
741 gMonsters[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
742 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
743 Result := True;
744 break;
745 end;
746 end;
747 begin
748 Result := 0;
750 if HitCorpses then
751 begin
752 h := High(gCorpses);
754 if gAdvCorpses and (h <> -1) then
755 for i := 0 to h do
756 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
757 g_Obj_Collide(obj, @gCorpses[i].Obj) then
758 begin
759 // Ðàñïèëèâàåì òðóï:
760 gCorpses[i].Damage(d, (obj^.Vel.X+obj^.Accel.X) div 4,
761 (obj^.Vel.Y+obj^.Accel.Y) div 4);
762 Result := 1;
763 end;
764 end;
766 case gGameSettings.GameMode of
767 // Êàìïàíèÿ:
768 GM_COOP, GM_SINGLE:
769 begin
770 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
771 if MonsterHit() then
772 begin
773 Result := 2;
774 Exit;
775 end;
777 if PlayerHit() then
778 begin
779 Result := 1;
780 Exit;
781 end;
782 end;
784 // Äåçìàò÷:
785 GM_DM:
786 begin
787 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
788 if PlayerHit() then
789 begin
790 Result := 1;
791 Exit;
792 end;
794 if MonsterHit() then
795 begin
796 Result := 2;
797 Exit;
798 end;
799 end;
801 // Êîìàíäíûå:
802 GM_TDM, GM_CTF:
803 begin
804 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
805 if PlayerHit(2) then
806 begin
807 Result := 1;
808 Exit;
809 end;
811 // Ïîòîì ìîíñòðîâ
812 if MonsterHit() then
813 begin
814 Result := 2;
815 Exit;
816 end;
818 // È â êîíöå ñâîèõ èãðîêîâ
819 if PlayerHit(1) then
820 begin
821 Result := 1;
822 Exit;
823 end;
824 end;
826 end;
827 end;
829 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
830 begin
831 Result := False;
833 case g_GetUIDType(UID) of
834 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
835 UID_MONSTER: Result := HitMonster(g_Monsters_Get(UID), d, 0, 0, SpawnerUID, t);
836 else Exit;
837 end;
838 end;
840 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
841 var
842 i, h, r, dx, dy, m, mm: Integer;
843 _angle: SmallInt;
844 begin
845 Result := False;
847 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
849 r := rad*rad;
851 h := High(gPlayers);
853 if h <> -1 then
854 for i := 0 to h do
855 if (gPlayers[i] <> nil) and gPlayers[i].Live then
856 with gPlayers[i] do
857 begin
858 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
859 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
861 if dx > 1000 then dx := 1000;
862 if dy > 1000 then dy := 1000;
864 if dx*dx+dy*dy < r then
865 begin
866 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
867 // PLAYER_RECT.Width, PLAYER_RECT.Height);
869 mm := Max(abs(dx), abs(dy));
870 if mm = 0 then mm := 1;
872 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
873 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
874 end;
875 end;
877 h := High(gMonsters);
879 if h <> -1 then
880 for i := 0 to h do
881 if gMonsters[i] <> nil then
882 with gMonsters[i] do
883 begin
884 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
885 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
887 if dx > 1000 then dx := 1000;
888 if dy > 1000 then dy := 1000;
890 if dx*dx+dy*dy < r then
891 begin
892 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
893 // Obj.Rect.Width, Obj.Rect.Height);
895 mm := Max(abs(dx), abs(dy));
896 if mm = 0 then mm := 1;
898 if gMonsters[i].Live then
899 HitMonster(gMonsters[i], ((gMonsters[i].Obj.Rect.Width div 4)*10*(rad-mm)) div rad,
900 0, 0, SpawnerUID, HIT_ROCKET);
902 gMonsters[i].Push((dx*7) div mm, (dy*7) div mm);
903 end;
904 end;
906 h := High(gCorpses);
908 if gAdvCorpses and (h <> -1) then
909 for i := 0 to h do
910 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
911 with gCorpses[i] do
912 begin
913 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
914 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
916 if dx > 1000 then dx := 1000;
917 if dy > 1000 then dy := 1000;
919 if dx*dx+dy*dy < r then
920 begin
921 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
922 Obj.Rect.Width, Obj.Rect.Height);
924 mm := Max(abs(dx), abs(dy));
925 if mm = 0 then mm := 1;
927 Damage(Round(100*(rad-m)/rad), (dx*10) div mm, (dy*10) div mm);
928 end;
929 end;
931 h := High(gGibs);
933 if gAdvGibs and (h <> -1) then
934 for i := 0 to h do
935 if gGibs[i].Live then
936 with gGibs[i] do
937 begin
938 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
939 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
941 if dx > 1000 then dx := 1000;
942 if dy > 1000 then dy := 1000;
944 if dx*dx+dy*dy < r then
945 begin
946 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
947 Obj.Rect.Width, Obj.Rect.Height);
948 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
949 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
951 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
952 end;
953 end;
954 end;
956 procedure g_Weapon_Init();
957 begin
958 CreateWaterMap();
959 end;
961 procedure g_Weapon_Free();
962 var
963 i: Integer;
964 begin
965 if Shots <> nil then
966 begin
967 for i := 0 to High(Shots) do
968 if Shots[i].ShotType <> 0 then
969 Shots[i].Animation.Free();
971 Shots := nil;
972 end;
974 WaterMap := nil;
975 end;
977 procedure g_Weapon_LoadData();
978 begin
979 e_WriteLog('Loading weapons data...', MSG_NOTIFY);
981 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
982 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
983 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
984 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
985 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
986 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
987 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
988 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
989 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
990 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
991 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
992 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
993 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
994 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
995 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
996 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
997 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
998 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
999 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1004 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1006 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1007 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1008 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1009 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1010 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1011 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1012 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1014 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1015 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1016 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1017 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1018 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1019 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1020 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1021 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1022 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1023 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1024 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1025 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1026 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1027 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1028 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1029 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1030 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1031 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1032 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1033 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1034 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1036 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1037 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1038 end;
1040 procedure g_Weapon_FreeData();
1041 begin
1042 e_WriteLog('Releasing weapons data...', MSG_NOTIFY);
1044 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1045 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1046 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1047 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1048 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1049 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1050 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1051 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1052 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1053 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1054 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1055 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1056 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1057 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1058 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1059 g_Sound_Delete('SOUND_FIRE');
1060 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1061 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1062 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1063 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1064 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1065 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1066 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1067 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1068 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1069 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1070 g_Sound_Delete('SOUND_PLAYER_JETON');
1071 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1072 g_Sound_Delete('SOUND_PLAYER_CASING1');
1073 g_Sound_Delete('SOUND_PLAYER_CASING2');
1074 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1075 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1077 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1078 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1079 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1080 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1081 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1082 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1083 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1084 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1085 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1086 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1087 g_Frames_DeleteByName('FRAMES_BFGHIT');
1088 g_Frames_DeleteByName('FRAMES_FIRE');
1089 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1090 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1091 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1092 g_Frames_DeleteByName('FRAMES_SMOKE');
1093 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1094 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1095 end;
1097 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1098 var
1099 a: Integer;
1100 x2, y2: Integer;
1101 dx, dy: Integer;
1102 xe, ye: Integer;
1103 xi, yi: Integer;
1104 s, c: Extended;
1105 //vx, vy: Integer;
1106 xx, yy, d: Integer;
1108 i: Integer;
1109 t1, _collide: Boolean;
1110 w, h: Word;
1111 begin
1112 a := GetAngle(x, y, xd, yd)+180;
1114 SinCos(DegToRad(-a), s, c);
1116 if Abs(s) < 0.01 then s := 0;
1117 if Abs(c) < 0.01 then c := 0;
1119 x2 := x+Round(c*gMapInfo.Width);
1120 y2 := y+Round(s*gMapInfo.Width);
1122 t1 := gWalls <> nil;
1123 _collide := False;
1124 w := gMapInfo.Width;
1125 h := gMapInfo.Height;
1127 xe := 0;
1128 ye := 0;
1129 dx := x2-x;
1130 dy := y2-y;
1132 if (xd = 0) and (yd = 0) then Exit;
1134 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1135 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1137 dx := Abs(dx);
1138 dy := Abs(dy);
1140 if dx > dy then d := dx else d := dy;
1142 //blood vel, for Monster.Damage()
1143 //vx := (dx*10 div d)*xi;
1144 //vy := (dy*10 div d)*yi;
1146 xx := x;
1147 yy := y;
1149 for i := 1 to d do
1150 begin
1151 xe := xe+dx;
1152 ye := ye+dy;
1154 if xe > d then
1155 begin
1156 xe := xe-d;
1157 xx := xx+xi;
1158 end;
1160 if ye > d then
1161 begin
1162 ye := ye-d;
1163 yy := yy+yi;
1164 end;
1166 if (yy > h) or (yy < 0) then Break;
1167 if (xx > w) or (xx < 0) then Break;
1169 if t1 then
1170 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1171 begin
1172 _collide := True;
1173 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1174 if g_Game_IsServer and g_Game_IsNet then
1175 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1176 end;
1178 if not _collide then
1179 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1181 if _collide then
1182 Break;
1183 end;
1185 if CheckTrigger and g_Game_IsServer then
1186 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1187 end;
1189 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1190 var
1191 obj: TObj;
1192 begin
1193 obj.X := X;
1194 obj.Y := Y;
1195 obj.rect.X := 0;
1196 obj.rect.Y := 0;
1197 obj.rect.Width := 39;
1198 obj.rect.Height := 52;
1199 obj.Vel.X := 0;
1200 obj.Vel.Y := 0;
1201 obj.Accel.X := 0;
1202 obj.Accel.Y := 0;
1204 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1205 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1206 else
1207 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1208 end;
1210 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1211 var
1212 obj: TObj;
1213 begin
1214 obj.X := X;
1215 obj.Y := Y;
1216 obj.rect.X := 0;
1217 obj.rect.Y := 0;
1218 obj.rect.Width := 32;
1219 obj.rect.Height := 52;
1220 obj.Vel.X := 0;
1221 obj.Vel.Y := 0;
1222 obj.Accel.X := 0;
1223 obj.Accel.Y := 0;
1225 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1226 end;
1228 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1229 Silent: Boolean = False);
1230 var
1231 find_id: DWORD;
1232 dx, dy: Integer;
1233 begin
1234 if WID < 0 then
1235 find_id := FindShot()
1236 else
1237 begin
1238 find_id := WID;
1239 if Integer(find_id) >= High(Shots) then
1240 SetLength(Shots, find_id + 64)
1241 end;
1243 with Shots[find_id] do
1244 begin
1245 g_Obj_Init(@Obj);
1247 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1248 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1250 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1251 dy := -(Obj.Rect.Height div 2);
1252 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1254 Animation := nil;
1255 triggers := nil;
1256 ShotType := WEAPON_ROCKETLAUNCHER;
1257 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1258 end;
1260 Shots[find_id].SpawnerUID := SpawnerUID;
1262 if not Silent then
1263 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1264 end;
1266 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1267 WID: Integer = -1; Silent: Boolean = False);
1268 var
1269 find_id, FramesID: DWORD;
1270 dx, dy: Integer;
1271 begin
1272 if WID < 0 then
1273 find_id := FindShot()
1274 else
1275 begin
1276 find_id := WID;
1277 if Integer(find_id) >= High(Shots) then
1278 SetLength(Shots, find_id + 64)
1279 end;
1281 with Shots[find_id] do
1282 begin
1283 g_Obj_Init(@Obj);
1285 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1286 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1288 dx := -(Obj.Rect.Width div 2);
1289 dy := -(Obj.Rect.Height div 2);
1290 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1292 triggers := nil;
1293 ShotType := WEAPON_SKEL_FIRE;
1294 target := TargetUID;
1295 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1296 Animation := TAnimation.Create(FramesID, True, 5);
1297 end;
1299 Shots[find_id].SpawnerUID := SpawnerUID;
1301 if not Silent then
1302 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1303 end;
1305 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1306 Silent: Boolean = False);
1307 var
1308 find_id, FramesID: DWORD;
1309 dx, dy: Integer;
1310 begin
1311 if WID < 0 then
1312 find_id := FindShot()
1313 else
1314 begin
1315 find_id := WID;
1316 if Integer(find_id) >= High(Shots) then
1317 SetLength(Shots, find_id + 64);
1318 end;
1320 with Shots[find_id] do
1321 begin
1322 g_Obj_Init(@Obj);
1324 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1325 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1327 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1328 dy := -(Obj.Rect.Height div 2);
1329 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1331 triggers := nil;
1332 ShotType := WEAPON_PLASMA;
1333 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1334 Animation := TAnimation.Create(FramesID, True, 5);
1335 end;
1337 Shots[find_id].SpawnerUID := SpawnerUID;
1339 if not Silent then
1340 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1341 end;
1343 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1344 Silent: Boolean = False);
1345 var
1346 find_id, FramesID: DWORD;
1347 dx, dy: Integer;
1348 begin
1349 if WID < 0 then
1350 find_id := FindShot()
1351 else
1352 begin
1353 find_id := WID;
1354 if Integer(find_id) >= High(Shots) then
1355 SetLength(Shots, find_id + 64);
1356 end;
1358 with Shots[find_id] do
1359 begin
1360 g_Obj_Init(@Obj);
1362 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1363 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1365 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1366 dy := -(Obj.Rect.Height div 2);
1367 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1369 triggers := nil;
1370 ShotType := WEAPON_FLAMETHROWER;
1371 Animation := nil;
1372 TextureID := 0;
1373 Stopped := 0;
1374 end;
1376 Shots[find_id].SpawnerUID := SpawnerUID;
1378 // if not Silent then
1379 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1380 end;
1382 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1383 Silent: Boolean = False);
1384 var
1385 find_id, FramesID: DWORD;
1386 dx, dy: Integer;
1387 begin
1388 if WID < 0 then
1389 find_id := FindShot()
1390 else
1391 begin
1392 find_id := WID;
1393 if Integer(find_id) >= High(Shots) then
1394 SetLength(Shots, find_id + 64)
1395 end;
1397 with Shots[find_id] do
1398 begin
1399 g_Obj_Init(@Obj);
1401 Obj.Rect.Width := 16;
1402 Obj.Rect.Height := 16;
1404 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1405 dy := -(Obj.Rect.Height div 2);
1406 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1408 triggers := nil;
1409 ShotType := WEAPON_IMP_FIRE;
1410 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1411 Animation := TAnimation.Create(FramesID, True, 4);
1412 end;
1414 Shots[find_id].SpawnerUID := SpawnerUID;
1416 if not Silent then
1417 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1418 end;
1420 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1421 Silent: Boolean = False);
1422 var
1423 find_id, FramesID: DWORD;
1424 dx, dy: Integer;
1425 begin
1426 if WID < 0 then
1427 find_id := FindShot()
1428 else
1429 begin
1430 find_id := WID;
1431 if Integer(find_id) >= High(Shots) then
1432 SetLength(Shots, find_id + 64)
1433 end;
1435 with Shots[find_id] do
1436 begin
1437 g_Obj_Init(@Obj);
1439 Obj.Rect.Width := 16;
1440 Obj.Rect.Height := 16;
1442 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1443 dy := -(Obj.Rect.Height div 2);
1444 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1446 triggers := nil;
1447 ShotType := WEAPON_CACO_FIRE;
1448 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1449 Animation := TAnimation.Create(FramesID, True, 4);
1450 end;
1452 Shots[find_id].SpawnerUID := SpawnerUID;
1454 if not Silent then
1455 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1456 end;
1458 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1459 Silent: Boolean = False);
1460 var
1461 find_id, FramesID: DWORD;
1462 dx, dy: Integer;
1463 begin
1464 if WID < 0 then
1465 find_id := FindShot()
1466 else
1467 begin
1468 find_id := WID;
1469 if Integer(find_id) >= High(Shots) then
1470 SetLength(Shots, find_id + 64)
1471 end;
1473 with Shots[find_id] do
1474 begin
1475 g_Obj_Init(@Obj);
1477 Obj.Rect.Width := 32;
1478 Obj.Rect.Height := 16;
1480 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1481 dy := -(Obj.Rect.Height div 2);
1482 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1484 triggers := nil;
1485 ShotType := WEAPON_BARON_FIRE;
1486 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1487 Animation := TAnimation.Create(FramesID, True, 4);
1488 end;
1490 Shots[find_id].SpawnerUID := SpawnerUID;
1492 if not Silent then
1493 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1494 end;
1496 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1497 Silent: Boolean = False);
1498 var
1499 find_id, FramesID: DWORD;
1500 dx, dy: Integer;
1501 begin
1502 if WID < 0 then
1503 find_id := FindShot()
1504 else
1505 begin
1506 find_id := WID;
1507 if Integer(find_id) >= High(Shots) then
1508 SetLength(Shots, find_id + 64)
1509 end;
1511 with Shots[find_id] do
1512 begin
1513 g_Obj_Init(@Obj);
1515 Obj.Rect.Width := 16;
1516 Obj.Rect.Height := 16;
1518 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1519 dy := -(Obj.Rect.Height div 2);
1520 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1522 triggers := nil;
1523 ShotType := WEAPON_BSP_FIRE;
1524 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1525 Animation := TAnimation.Create(FramesID, True, 4);
1526 end;
1528 Shots[find_id].SpawnerUID := SpawnerUID;
1530 if not Silent then
1531 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1532 end;
1534 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1535 Silent: Boolean = False);
1536 var
1537 find_id, FramesID: DWORD;
1538 dx, dy: Integer;
1539 begin
1540 if WID < 0 then
1541 find_id := FindShot()
1542 else
1543 begin
1544 find_id := WID;
1545 if Integer(find_id) >= High(Shots) then
1546 SetLength(Shots, find_id + 64)
1547 end;
1549 with Shots[find_id] do
1550 begin
1551 g_Obj_Init(@Obj);
1553 Obj.Rect.Width := 32;
1554 Obj.Rect.Height := 32;
1556 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1557 dy := -(Obj.Rect.Height div 2);
1558 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1560 triggers := nil;
1561 ShotType := WEAPON_MANCUB_FIRE;
1562 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1563 Animation := TAnimation.Create(FramesID, True, 4);
1564 end;
1566 Shots[find_id].SpawnerUID := SpawnerUID;
1568 if not Silent then
1569 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1570 end;
1572 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1573 Silent: Boolean = False);
1574 var
1575 find_id, FramesID: DWORD;
1576 dx, dy: Integer;
1577 begin
1578 if WID < 0 then
1579 find_id := FindShot()
1580 else
1581 begin
1582 find_id := WID;
1583 if Integer(find_id) >= High(Shots) then
1584 SetLength(Shots, find_id + 64)
1585 end;
1587 with Shots[find_id] do
1588 begin
1589 g_Obj_Init(@Obj);
1591 Obj.Rect.Width := SHOT_BFG_WIDTH;
1592 Obj.Rect.Height := SHOT_BFG_HEIGHT;
1594 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1595 dy := -(Obj.Rect.Height div 2);
1596 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1598 triggers := nil;
1599 ShotType := WEAPON_BFG;
1600 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
1601 Animation := TAnimation.Create(FramesID, True, 6);
1602 end;
1604 Shots[find_id].SpawnerUID := SpawnerUID;
1606 if not Silent then
1607 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
1608 end;
1610 procedure g_Weapon_bfghit(x, y: Integer);
1611 var
1612 ID: DWORD;
1613 Anim: TAnimation;
1614 begin
1615 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
1616 begin
1617 Anim := TAnimation.Create(ID, False, 4);
1618 g_GFX_OnceAnim(x-32, y-32, Anim);
1619 Anim.Free();
1620 end;
1621 end;
1623 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
1624 Silent: Boolean = False);
1625 begin
1626 if not Silent then
1627 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
1629 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1630 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
1631 begin
1632 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
1633 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1634 end;
1635 end;
1637 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1638 Silent: Boolean = False);
1639 begin
1640 if not Silent then
1641 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
1643 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1644 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
1645 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1646 begin
1647 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
1648 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1649 end;
1650 end;
1652 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1653 Silent: Boolean = False);
1654 var
1655 i, j: Integer;
1656 begin
1657 if not Silent then
1658 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
1660 for i := 0 to 9 do
1661 begin
1662 j := Random(17)-8; // -8 .. 8
1663 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
1664 end;
1665 end;
1667 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1668 Silent: Boolean = False);
1669 var
1670 a, i, j: Integer;
1671 begin
1672 if not Silent then
1673 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
1675 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
1676 for i := 0 to a do
1677 begin
1678 j := Random(41)-20; // -20 .. 20
1679 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
1680 end;
1681 end;
1683 procedure g_Weapon_Update();
1684 var
1685 i, a, h, cx, cy, oldvx, oldvy: Integer;
1686 _id: DWORD;
1687 Anim: TAnimation;
1688 t: DWArray;
1689 st: Word;
1690 s: String;
1691 o: TObj;
1692 spl: Boolean;
1693 Loud: Boolean;
1694 begin
1695 if Shots = nil then
1696 Exit;
1698 for i := 0 to High(Shots) do
1699 begin
1700 if Shots[i].ShotType = 0 then
1701 Continue;
1703 Loud := True;
1705 with Shots[i] do
1706 begin
1707 Timeout := Timeout - 1;
1708 oldvx := Obj.Vel.X;
1709 oldvy := Obj.Vel.Y;
1710 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1711 if g_Game_IsServer then
1712 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
1713 SpawnerUID, ACTIVATE_SHOT, triggers)
1714 else
1715 t := nil;
1717 if t <> nil then
1718 begin
1719 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1720 if triggers = nil then
1721 triggers := t
1722 else
1723 begin
1724 h := High(t);
1726 for a := 0 to h do
1727 if not InDWArray(t[a], triggers) then
1728 begin
1729 SetLength(triggers, Length(triggers)+1);
1730 triggers[High(triggers)] := t[a];
1731 end;
1732 end;
1733 end;
1735 // Àíèìàöèÿ ñíàðÿäà:
1736 if Animation <> nil then
1737 Animation.Update();
1739 // Äâèæåíèå:
1740 spl := (ShotType <> WEAPON_PLASMA) and
1741 (ShotType <> WEAPON_BFG) and
1742 (ShotType <> WEAPON_BSP_FIRE) and
1743 (ShotType <> WEAPON_FLAMETHROWER);
1745 st := g_Obj_Move(@Obj, False, spl);
1747 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
1748 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
1749 begin
1750 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1751 ShotType := 0;
1752 Animation.Free();
1753 Continue;
1754 end;
1756 cx := Obj.X + (Obj.Rect.Width div 2);
1757 cy := Obj.Y + (Obj.Rect.Height div 2);
1759 case ShotType of
1760 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1761 begin
1762 // Âûëåòåëà èç âîäû:
1763 if WordBool(st and MOVE_HITAIR) then
1764 g_Obj_SetSpeed(@Obj, 12);
1766 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1767 if WordBool(st and MOVE_INWATER) then
1768 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
1769 Obj.Y+(Obj.Rect.Height div 2),
1770 1+Random(3), 16, 16)
1771 else
1772 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1773 begin
1774 Anim := TAnimation.Create(_id, False, 3);
1775 Anim.Alpha := 150;
1776 g_GFX_OnceAnim(Obj.X-14+Random(9),
1777 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
1778 Anim, ONCEANIM_SMOKE);
1779 Anim.Free();
1780 end;
1782 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1783 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1784 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
1785 (Timeout < 1) then
1786 begin
1787 Obj.Vel.X := 0;
1788 Obj.Vel.Y := 0;
1790 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
1792 if ShotType = WEAPON_SKEL_FIRE then
1793 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1794 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
1795 begin
1796 Anim := TAnimation.Create(TextureID, False, 8);
1797 Anim.Blending := False;
1798 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
1799 Anim.Free();
1800 end;
1801 end
1802 else
1803 begin // Âçðûâ Ðàêåòû
1804 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
1805 begin
1806 Anim := TAnimation.Create(TextureID, False, 6);
1807 Anim.Blending := False;
1808 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1809 Anim.Free();
1810 end;
1811 end;
1813 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
1815 ShotType := 0;
1816 end;
1818 if ShotType = WEAPON_SKEL_FIRE then
1819 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1820 if GetPos(target, @o) then
1821 throw(i, Obj.X, Obj.Y,
1822 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
1823 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
1824 12);
1825 end;
1826 end;
1828 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1829 begin
1830 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1831 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1832 begin
1833 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
1834 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
1835 ShotType := 0;
1836 Continue;
1837 end;
1839 // Âåëè÷èíà óðîíà:
1840 if (ShotType = WEAPON_PLASMA) and
1841 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1842 a := 10
1843 else
1844 a := 5;
1846 if ShotType = WEAPON_BSP_FIRE then
1847 a := 10;
1849 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1850 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1851 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
1852 (Timeout < 1) then
1853 begin
1854 if ShotType = WEAPON_PLASMA then
1855 s := 'FRAMES_EXPLODE_PLASMA'
1856 else
1857 s := 'FRAMES_EXPLODE_BSPFIRE';
1859 // Âçðûâ Ïëàçìû:
1860 if g_Frames_Get(TextureID, s) then
1861 begin
1862 Anim := TAnimation.Create(TextureID, False, 3);
1863 Anim.Blending := False;
1864 g_GFX_OnceAnim(cx-16, cy-16, Anim);
1865 Anim.Free();
1866 end;
1868 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
1870 ShotType := 0;
1871 end;
1872 end;
1874 WEAPON_FLAMETHROWER: // Îãíåìåò
1875 begin
1876 // Ñî âðåìåíåì óìèðàåò
1877 if (Timeout < 1) then
1878 begin
1879 ShotType := 0;
1880 Continue;
1881 end;
1882 // Ïîä âîäîé òîæå
1883 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
1884 begin
1885 if WordBool(st and MOVE_HITWATER) then
1886 begin
1887 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1888 begin
1889 Anim := TAnimation.Create(_id, False, 3);
1890 Anim.Alpha := 0;
1891 g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1892 cy-4+Random(8)-(Anim.Height div 2),
1893 Anim, ONCEANIM_SMOKE);
1894 Anim.Free();
1895 end;
1896 end
1897 else
1898 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
1899 ShotType := 0;
1900 Continue;
1901 end;
1903 // Ãðàâèòàöèÿ
1904 if Stopped = 0 then
1905 Obj.Accel.Y := Obj.Accel.Y + 1;
1906 // Ïîïàëè â ñòåíó èëè â âîäó:
1907 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
1908 begin
1909 // Ïðèëèïàåì:
1910 Obj.Vel.X := 0;
1911 Obj.Vel.Y := 0;
1912 Obj.Accel.Y := 0;
1913 if WordBool(st and MOVE_HITWALL) then
1914 Stopped := MOVE_HITWALL
1915 else if WordBool(st and MOVE_HITLAND) then
1916 Stopped := MOVE_HITLAND
1917 else if WordBool(st and MOVE_HITCEIL) then
1918 Stopped := MOVE_HITCEIL;
1919 end;
1921 a := IfThen(Stopped = 0, 5, 1);
1922 // Åñëè â êîãî-òî ïîïàëè
1923 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
1924 begin
1925 // HIT_FLAME ñàì ïîäîææåò
1926 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1927 if Stopped = 0 then
1928 ShotType := 0;
1929 end;
1931 if g_Frames_Get(_id, 'FRAMES_FLAME') then
1932 begin
1933 Anim := TAnimation.Create(_id, False, 2 + Random(2));
1934 Anim.Alpha := 0;
1935 case Stopped of
1936 0: g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1937 cy-4+Random(8)-(Anim.Height div 2),
1938 Anim, ONCEANIM_SMOKE);
1939 MOVE_HITWALL: g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1940 cy-12+Random(24)-(Anim.Height div 2),
1941 Anim, ONCEANIM_SMOKE);
1942 MOVE_HITLAND: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1943 cy-10+Random(8)-(Anim.Height div 2),
1944 Anim, ONCEANIM_SMOKE);
1945 MOVE_HITCEIL: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1946 cy+6+Random(8)-(Anim.Height div 2),
1947 Anim, ONCEANIM_SMOKE);
1948 end;
1949 Anim.Free();
1950 end;
1951 end;
1953 WEAPON_BFG: // BFG
1954 begin
1955 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1956 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1957 begin
1958 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
1959 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
1960 ShotType := 0;
1961 Continue;
1962 end;
1964 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1965 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1966 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
1967 (Timeout < 1) then
1968 begin
1969 // Ëó÷è BFG:
1970 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
1972 // Âçðûâ BFG:
1973 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
1974 begin
1975 Anim := TAnimation.Create(TextureID, False, 6);
1976 Anim.Blending := False;
1977 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1978 Anim.Free();
1979 end;
1981 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
1983 ShotType := 0;
1984 end;
1985 end;
1987 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
1988 begin
1989 // Âûëåòåë èç âîäû:
1990 if WordBool(st and MOVE_HITAIR) then
1991 g_Obj_SetSpeed(@Obj, 16);
1993 // Âåëè÷èíà óðîíà:
1994 if ShotType = WEAPON_IMP_FIRE then
1995 a := 5
1996 else
1997 if ShotType = WEAPON_CACO_FIRE then
1998 a := 20
1999 else
2000 a := 40;
2002 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2003 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2004 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2005 (Timeout < 1) then
2006 begin
2007 if ShotType = WEAPON_IMP_FIRE then
2008 s := 'FRAMES_EXPLODE_IMPFIRE'
2009 else
2010 if ShotType = WEAPON_CACO_FIRE then
2011 s := 'FRAMES_EXPLODE_CACOFIRE'
2012 else
2013 s := 'FRAMES_EXPLODE_BARONFIRE';
2015 // Âçðûâ:
2016 if g_Frames_Get(TextureID, s) then
2017 begin
2018 Anim := TAnimation.Create(TextureID, False, 6);
2019 Anim.Blending := False;
2020 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2021 Anim.Free();
2022 end;
2024 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2026 ShotType := 0;
2027 end;
2028 end;
2030 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2031 begin
2032 // Âûëåòåë èç âîäû:
2033 if WordBool(st and MOVE_HITAIR) then
2034 g_Obj_SetSpeed(@Obj, 16);
2036 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2037 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2038 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2039 (Timeout < 1) then
2040 begin
2041 // Âçðûâ:
2042 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2043 begin
2044 Anim := TAnimation.Create(TextureID, False, 6);
2045 Anim.Blending := False;
2046 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2047 Anim.Free();
2048 end;
2050 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2052 ShotType := 0;
2053 end;
2054 end;
2055 end; // case ShotType of...
2057 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2058 if (ShotType = 0) then
2059 begin
2060 if gGameSettings.GameType = GT_SERVER then
2061 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2062 if Animation <> nil then
2063 begin
2064 Animation.Free();
2065 Animation := nil;
2066 end;
2067 end
2068 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2069 if gGameSettings.GameType = GT_SERVER then
2070 MH_SEND_UpdateShot(i);
2071 end;
2072 end;
2073 end;
2075 procedure g_Weapon_Draw();
2076 var
2077 i: Integer;
2078 a: SmallInt;
2079 p: TPoint;
2080 begin
2081 if Shots = nil then
2082 Exit;
2084 for i := 0 to High(Shots) do
2085 if Shots[i].ShotType <> 0 then
2086 with Shots[i] do
2087 begin
2088 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2089 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2090 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2091 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2092 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2093 else
2094 a := 0;
2096 p.X := Obj.Rect.Width div 2;
2097 p.Y := Obj.Rect.Height div 2;
2099 if Animation <> nil then
2100 begin
2101 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2102 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2103 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2104 Animation.DrawEx(Obj.X, Obj.Y, M_NONE, p, a)
2105 else
2106 Animation.Draw(Obj.X, Obj.Y, M_NONE);
2107 end
2108 else if TextureID <> 0 then
2109 begin
2110 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2111 e_DrawAdv(TextureID, Obj.X, Obj.Y, 0, True, False, a, @p, M_NONE)
2112 else
2113 e_Draw(TextureID, Obj.X, Obj.Y, 0, True, False);
2114 end;
2116 if g_debug_Frames then
2117 begin
2118 e_DrawQuad(Obj.X+Obj.Rect.X,
2119 Obj.Y+Obj.Rect.Y,
2120 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2121 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2122 0, 255, 0);
2123 end;
2124 end;
2125 end;
2127 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2128 var
2129 a: Integer;
2130 begin
2131 Result := False;
2133 if Shots = nil then
2134 Exit;
2136 for a := 0 to High(Shots) do
2137 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2138 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2139 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2140 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2141 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2142 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2143 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2144 begin
2145 Result := True;
2146 Exit;
2147 end;
2148 end;
2150 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
2151 var
2152 count, i, j: Integer;
2153 dw: DWORD;
2154 begin
2155 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2156 count := 0;
2157 if Shots <> nil then
2158 for i := 0 to High(Shots) do
2159 if Shots[i].ShotType <> 0 then
2160 count := count + 1;
2162 Mem := TBinMemoryWriter.Create((count+1) * 80);
2164 // Êîëè÷åñòâî ñíàðÿäîâ:
2165 Mem.WriteInt(count);
2167 if count = 0 then
2168 Exit;
2170 for i := 0 to High(Shots) do
2171 if Shots[i].ShotType <> 0 then
2172 begin
2173 // Ñèãíàòóðà ñíàðÿäà:
2174 dw := SHOT_SIGNATURE; // 'SHOT'
2175 Mem.WriteDWORD(dw);
2176 // Òèï ñíàðÿäà:
2177 Mem.WriteByte(Shots[i].ShotType);
2178 // Öåëü:
2179 Mem.WriteWord(Shots[i].Target);
2180 // UID ñòðåëÿâøåãî:
2181 Mem.WriteWord(Shots[i].SpawnerUID);
2182 // Ðàçìåð ïîëÿ Triggers:
2183 dw := Length(Shots[i].Triggers);
2184 Mem.WriteDWORD(dw);
2185 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2186 for j := 0 to Integer(dw)-1 do
2187 Mem.WriteDWORD(Shots[i].Triggers[j]);
2188 // Îáúåêò ñíàðÿäà:
2189 Obj_SaveState(@Shots[i].Obj, Mem);
2190 // Êîñòûëèíà åáàíàÿ:
2191 Mem.WriteByte(Shots[i].Stopped);
2192 end;
2193 end;
2195 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
2196 var
2197 count, i, j: Integer;
2198 dw: DWORD;
2199 begin
2200 if Mem = nil then
2201 Exit;
2203 // Êîëè÷åñòâî ñíàðÿäîâ:
2204 Mem.ReadInt(count);
2206 SetLength(Shots, count);
2208 if count = 0 then
2209 Exit;
2211 for i := 0 to count-1 do
2212 begin
2213 // Ñèãíàòóðà ñíàðÿäà:
2214 Mem.ReadDWORD(dw);
2215 if dw <> SHOT_SIGNATURE then // 'SHOT'
2216 begin
2217 raise EBinSizeError.Create('g_Weapons_LoadState: Wrong Shot Signature');
2218 end;
2219 // Òèï ñíàðÿäà:
2220 Mem.ReadByte(Shots[i].ShotType);
2221 // Öåëü:
2222 Mem.ReadWord(Shots[i].Target);
2223 // UID ñòðåëÿâøåãî:
2224 Mem.ReadWord(Shots[i].SpawnerUID);
2225 // Ðàçìåð ïîëÿ Triggers:
2226 Mem.ReadDWORD(dw);
2227 SetLength(Shots[i].Triggers, dw);
2228 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2229 for j := 0 to Integer(dw)-1 do
2230 Mem.ReadDWORD(Shots[i].Triggers[j]);
2231 // Îáúåêò ïðåäìåòà:
2232 Obj_LoadState(@Shots[i].Obj, Mem);
2233 // Êîñòûëèíà åáàíàÿ:
2234 Mem.ReadByte(Shots[i].Stopped);
2236 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2237 Shots[i].TextureID := DWORD(-1);
2238 Shots[i].Animation := nil;
2240 case Shots[i].ShotType of
2241 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2242 begin
2243 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2244 end;
2245 WEAPON_PLASMA:
2246 begin
2247 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2248 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2249 end;
2250 WEAPON_BFG:
2251 begin
2252 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2253 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2254 end;
2255 WEAPON_IMP_FIRE:
2256 begin
2257 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2258 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2259 end;
2260 WEAPON_BSP_FIRE:
2261 begin
2262 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2263 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2264 end;
2265 WEAPON_CACO_FIRE:
2266 begin
2267 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2268 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2269 end;
2270 WEAPON_BARON_FIRE:
2271 begin
2272 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2273 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2274 end;
2275 WEAPON_MANCUB_FIRE:
2276 begin
2277 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2278 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2279 end;
2280 end;
2281 end;
2282 end;
2284 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2285 var
2286 cx, cy: Integer;
2287 Anim: TAnimation;
2288 s: string;
2289 begin
2290 if Shots = nil then
2291 Exit;
2292 if (I > High(Shots)) or (I < 0) then Exit;
2294 with Shots[I] do
2295 begin
2296 if ShotType = 0 then Exit;
2297 Obj.X := X;
2298 Obj.Y := Y;
2299 cx := Obj.X + (Obj.Rect.Width div 2);
2300 cy := Obj.Y + (Obj.Rect.Height div 2);
2302 case ShotType of
2303 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2304 begin
2305 if Loud then
2306 begin
2307 if ShotType = WEAPON_SKEL_FIRE then
2308 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2309 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2310 begin
2311 Anim := TAnimation.Create(TextureID, False, 8);
2312 Anim.Blending := False;
2313 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2314 Anim.Free();
2315 end;
2316 end
2317 else
2318 begin // Âçðûâ Ðàêåòû
2319 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2320 begin
2321 Anim := TAnimation.Create(TextureID, False, 6);
2322 Anim.Blending := False;
2323 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2324 Anim.Free();
2325 end;
2326 end;
2327 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2328 end;
2329 end;
2331 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2332 begin
2333 if ShotType = WEAPON_PLASMA then
2334 s := 'FRAMES_EXPLODE_PLASMA'
2335 else
2336 s := 'FRAMES_EXPLODE_BSPFIRE';
2338 if g_Frames_Get(TextureID, s) and loud then
2339 begin
2340 Anim := TAnimation.Create(TextureID, False, 3);
2341 Anim.Blending := False;
2342 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2343 Anim.Free();
2345 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2346 end;
2347 end;
2349 WEAPON_BFG: // BFG
2350 begin
2351 // Âçðûâ BFG:
2352 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2353 begin
2354 Anim := TAnimation.Create(TextureID, False, 6);
2355 Anim.Blending := False;
2356 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2357 Anim.Free();
2359 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2360 end;
2361 end;
2363 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2364 begin
2365 if ShotType = WEAPON_IMP_FIRE then
2366 s := 'FRAMES_EXPLODE_IMPFIRE'
2367 else
2368 if ShotType = WEAPON_CACO_FIRE then
2369 s := 'FRAMES_EXPLODE_CACOFIRE'
2370 else
2371 s := 'FRAMES_EXPLODE_BARONFIRE';
2373 if g_Frames_Get(TextureID, s) and Loud then
2374 begin
2375 Anim := TAnimation.Create(TextureID, False, 6);
2376 Anim.Blending := False;
2377 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2378 Anim.Free();
2380 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2381 end;
2382 end;
2384 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2385 begin
2386 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2387 begin
2388 Anim := TAnimation.Create(TextureID, False, 6);
2389 Anim.Blending := False;
2390 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2391 Anim.Free();
2393 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2394 end;
2395 end;
2396 end; // case ShotType of...
2398 ShotType := 0;
2399 Animation.Free();
2400 end;
2401 end;
2403 end.