DEADSOFTWARE

b5e46d11e930755b647728f1c8f9eae179555c98
[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 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 if (ShotType = WEAPON_FLAMETHROWER) and (XV = 0) and (YV = 0) then
666 Shots[find_id].Stopped := 255
667 else
668 Shots[find_id].Stopped := 0;
669 Result := find_id;
670 end;
672 procedure throw(i, x, y, xd, yd, s: Integer);
673 var
674 a: Integer;
675 begin
676 yd := yd - y;
677 xd := xd - x;
679 a := Max(Abs(xd), Abs(yd));
680 if a = 0 then
681 a := 1;
683 Shots[i].Obj.X := x;
684 Shots[i].Obj.Y := y;
685 Shots[i].Obj.Vel.X := (xd*s) div a;
686 Shots[i].Obj.Vel.Y := (yd*s) div a;
687 Shots[i].Obj.Accel.X := 0;
688 Shots[i].Obj.Accel.Y := 0;
689 Shots[i].Stopped := 0;
690 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BFG] then
691 Shots[i].Timeout := 900 // ~25 sec
692 else
693 begin
694 if Shots[i].ShotType = WEAPON_FLAMETHROWER then
695 Shots[i].Timeout := SHOT_FLAME_LIFETIME
696 else
697 Shots[i].Timeout := 550; // ~15 sec
698 end;
699 end;
701 function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
702 var
703 i, h: Integer;
705 function PlayerHit(Team: Byte = 0): Boolean;
706 var
707 i: Integer;
708 ChkTeam: Boolean;
709 p: TPlayer;
710 begin
711 Result := False;
712 h := High(gPlayers);
714 if h <> -1 then
715 for i := 0 to h do
716 if (gPlayers[i] <> nil) and gPlayers[i].Live and g_Obj_Collide(obj, @gPlayers[i].Obj) then
717 begin
718 ChkTeam := True;
719 if (Team > 0) and (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
720 begin
721 p := g_Player_Get(SpawnerUID);
722 if p <> nil then
723 ChkTeam := (p.Team = gPlayers[i].Team) xor (Team = 2);
724 end;
725 if ChkTeam then
726 if HitPlayer(gPlayers[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
727 begin
728 gPlayers[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
729 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
730 if t = HIT_BFG then
731 g_Game_DelayEvent(DE_BFGHIT, 1000, SpawnerUID);
732 Result := True;
733 break;
734 end;
735 end;
736 end;
737 function MonsterHit(): Boolean;
738 var
739 i: Integer;
740 begin
741 Result := False;
742 h := High(gMonsters);
744 if h <> -1 then
745 for i := 0 to h do
746 if (gMonsters[i] <> nil) and gMonsters[i].Live and g_Obj_Collide(obj, @gMonsters[i].Obj) then
747 if HitMonster(gMonsters[i], d, obj^.Vel.X, obj^.Vel.Y, SpawnerUID, t) then
748 begin
749 gMonsters[i].Push((obj^.Vel.X+obj^.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4,
750 (obj^.Vel.Y+obj^.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4);
751 Result := True;
752 break;
753 end;
754 end;
755 begin
756 Result := 0;
758 if HitCorpses then
759 begin
760 h := High(gCorpses);
762 if gAdvCorpses and (h <> -1) then
763 for i := 0 to h do
764 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
765 g_Obj_Collide(obj, @gCorpses[i].Obj) then
766 begin
767 // Ðàñïèëèâàåì òðóï:
768 gCorpses[i].Damage(d, (obj^.Vel.X+obj^.Accel.X) div 4,
769 (obj^.Vel.Y+obj^.Accel.Y) div 4);
770 Result := 1;
771 end;
772 end;
774 case gGameSettings.GameMode of
775 // Êàìïàíèÿ:
776 GM_COOP, GM_SINGLE:
777 begin
778 // Ñíà÷àëà áü¸ì ìîíñòðîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü èãðîêîâ
779 if MonsterHit() then
780 begin
781 Result := 2;
782 Exit;
783 end;
785 if PlayerHit() then
786 begin
787 Result := 1;
788 Exit;
789 end;
790 end;
792 // Äåçìàò÷:
793 GM_DM:
794 begin
795 // Ñíà÷àëà áü¸ì èãðîêîâ, åñëè åñòü, ïîòîì ïûòàåìñÿ áèòü ìîíñòðîâ
796 if PlayerHit() then
797 begin
798 Result := 1;
799 Exit;
800 end;
802 if MonsterHit() then
803 begin
804 Result := 2;
805 Exit;
806 end;
807 end;
809 // Êîìàíäíûå:
810 GM_TDM, GM_CTF:
811 begin
812 // Ñíà÷àëà áü¸ì èãðîêîâ êîìàíäû ñîïåðíèêà
813 if PlayerHit(2) then
814 begin
815 Result := 1;
816 Exit;
817 end;
819 // Ïîòîì ìîíñòðîâ
820 if MonsterHit() then
821 begin
822 Result := 2;
823 Exit;
824 end;
826 // È â êîíöå ñâîèõ èãðîêîâ
827 if PlayerHit(1) then
828 begin
829 Result := 1;
830 Exit;
831 end;
832 end;
834 end;
835 end;
837 function g_Weapon_HitUID(UID: Word; d: Integer; SpawnerUID: Word; t: Byte): Boolean;
838 begin
839 Result := False;
841 case g_GetUIDType(UID) of
842 UID_PLAYER: Result := HitPlayer(g_Player_Get(UID), d, 0, 0, SpawnerUID, t);
843 UID_MONSTER: Result := HitMonster(g_Monsters_Get(UID), d, 0, 0, SpawnerUID, t);
844 else Exit;
845 end;
846 end;
848 function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolean;
849 var
850 i, h, r, dx, dy, m, mm: Integer;
851 _angle: SmallInt;
852 begin
853 Result := False;
855 g_Triggers_PressC(X, Y, rad, SpawnerUID, ACTIVATE_SHOT);
857 r := rad*rad;
859 h := High(gPlayers);
861 if h <> -1 then
862 for i := 0 to h do
863 if (gPlayers[i] <> nil) and gPlayers[i].Live then
864 with gPlayers[i] do
865 begin
866 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
867 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
869 if dx > 1000 then dx := 1000;
870 if dy > 1000 then dy := 1000;
872 if dx*dx+dy*dy < r then
873 begin
874 //m := PointToRect(X, Y, GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y,
875 // PLAYER_RECT.Width, PLAYER_RECT.Height);
877 mm := Max(abs(dx), abs(dy));
878 if mm = 0 then mm := 1;
880 HitPlayer(gPlayers[i], (100*(rad-mm)) div rad, (dx*10) div mm, (dy*10) div mm, SpawnerUID, HIT_ROCKET);
881 gPlayers[i].Push((dx*7) div mm, (dy*7) div mm);
882 end;
883 end;
885 h := High(gMonsters);
887 if h <> -1 then
888 for i := 0 to h do
889 if gMonsters[i] <> nil then
890 with gMonsters[i] do
891 begin
892 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
893 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
895 if dx > 1000 then dx := 1000;
896 if dy > 1000 then dy := 1000;
898 if dx*dx+dy*dy < r then
899 begin
900 //m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
901 // Obj.Rect.Width, Obj.Rect.Height);
903 mm := Max(abs(dx), abs(dy));
904 if mm = 0 then mm := 1;
906 if gMonsters[i].Live then
907 HitMonster(gMonsters[i], ((gMonsters[i].Obj.Rect.Width div 4)*10*(rad-mm)) div rad,
908 0, 0, SpawnerUID, HIT_ROCKET);
910 gMonsters[i].Push((dx*7) div mm, (dy*7) div mm);
911 end;
912 end;
914 h := High(gCorpses);
916 if gAdvCorpses and (h <> -1) then
917 for i := 0 to h do
918 if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
919 with gCorpses[i] do
920 begin
921 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
922 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
924 if dx > 1000 then dx := 1000;
925 if dy > 1000 then dy := 1000;
927 if dx*dx+dy*dy < r then
928 begin
929 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
930 Obj.Rect.Width, Obj.Rect.Height);
932 mm := Max(abs(dx), abs(dy));
933 if mm = 0 then mm := 1;
935 Damage(Round(100*(rad-m)/rad), (dx*10) div mm, (dy*10) div mm);
936 end;
937 end;
939 h := High(gGibs);
941 if gAdvGibs and (h <> -1) then
942 for i := 0 to h do
943 if gGibs[i].Live then
944 with gGibs[i] do
945 begin
946 dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
947 dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
949 if dx > 1000 then dx := 1000;
950 if dy > 1000 then dy := 1000;
952 if dx*dx+dy*dy < r then
953 begin
954 m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
955 Obj.Rect.Width, Obj.Rect.Height);
956 _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
957 Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y);
959 g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle);
960 end;
961 end;
962 end;
964 procedure g_Weapon_Init();
965 begin
966 CreateWaterMap();
967 end;
969 procedure g_Weapon_Free();
970 var
971 i: Integer;
972 begin
973 if Shots <> nil then
974 begin
975 for i := 0 to High(Shots) do
976 if Shots[i].ShotType <> 0 then
977 Shots[i].Animation.Free();
979 Shots := nil;
980 end;
982 WaterMap := nil;
983 end;
985 procedure g_Weapon_LoadData();
986 begin
987 e_WriteLog('Loading weapons data...', MSG_NOTIFY);
989 g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH');
990 g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH');
991 g_Sound_CreateWADEx('SOUND_WEAPON_HITBERSERK', GameWAD+':SOUNDS\HITBERSERK');
992 g_Sound_CreateWADEx('SOUND_WEAPON_MISSBERSERK', GameWAD+':SOUNDS\MISSBERSERK');
993 g_Sound_CreateWADEx('SOUND_WEAPON_SELECTSAW', GameWAD+':SOUNDS\SELECTSAW');
994 g_Sound_CreateWADEx('SOUND_WEAPON_IDLESAW', GameWAD+':SOUNDS\IDLESAW');
995 g_Sound_CreateWADEx('SOUND_WEAPON_HITSAW', GameWAD+':SOUNDS\HITSAW');
996 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN2', GameWAD+':SOUNDS\FIRESHOTGUN2');
997 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESHOTGUN', GameWAD+':SOUNDS\FIRESHOTGUN');
998 g_Sound_CreateWADEx('SOUND_WEAPON_FIRESAW', GameWAD+':SOUNDS\FIRESAW');
999 g_Sound_CreateWADEx('SOUND_WEAPON_FIREROCKET', GameWAD+':SOUNDS\FIREROCKET');
1000 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPLASMA', GameWAD+':SOUNDS\FIREPLASMA');
1001 g_Sound_CreateWADEx('SOUND_WEAPON_FIREPISTOL', GameWAD+':SOUNDS\FIREPISTOL');
1002 g_Sound_CreateWADEx('SOUND_WEAPON_FIRECGUN', GameWAD+':SOUNDS\FIRECGUN');
1003 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBFG', GameWAD+':SOUNDS\FIREBFG');
1004 g_Sound_CreateWADEx('SOUND_FIRE', GameWAD+':SOUNDS\FIRE');
1005 g_Sound_CreateWADEx('SOUND_WEAPON_STARTFIREBFG', GameWAD+':SOUNDS\STARTFIREBFG');
1006 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEROCKET', GameWAD+':SOUNDS\EXPLODEROCKET');
1007 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBFG', GameWAD+':SOUNDS\EXPLODEBFG');
1008 g_Sound_CreateWADEx('SOUND_WEAPON_BFGWATER', GameWAD+':SOUNDS\BFGWATER');
1009 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEPLASMA', GameWAD+':SOUNDS\EXPLODEPLASMA');
1010 g_Sound_CreateWADEx('SOUND_WEAPON_PLASMAWATER', GameWAD+':SOUNDS\PLASMAWATER');
1011 g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL');
1012 g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL');
1013 g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV');
1014 g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK');
1015 g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK');
1016 g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK');
1017 g_Sound_CreateWADEx('SOUND_PLAYER_CASING1', GameWAD+':SOUNDS\CASING1');
1018 g_Sound_CreateWADEx('SOUND_PLAYER_CASING2', GameWAD+':SOUNDS\CASING2');
1019 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
1020 g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
1022 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
1023 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
1024 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
1025 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
1026 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
1027 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
1028 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
1029 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
1030 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
1031 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
1032 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
1033 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
1034 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
1035 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
1036 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
1037 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
1038 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
1039 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
1040 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
1041 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
1042 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
1044 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
1045 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
1046 end;
1048 procedure g_Weapon_FreeData();
1049 begin
1050 e_WriteLog('Releasing weapons data...', MSG_NOTIFY);
1052 g_Sound_Delete('SOUND_WEAPON_HITPUNCH');
1053 g_Sound_Delete('SOUND_WEAPON_MISSPUNCH');
1054 g_Sound_Delete('SOUND_WEAPON_HITBERSERK');
1055 g_Sound_Delete('SOUND_WEAPON_MISSBERSERK');
1056 g_Sound_Delete('SOUND_WEAPON_SELECTSAW');
1057 g_Sound_Delete('SOUND_WEAPON_IDLESAW');
1058 g_Sound_Delete('SOUND_WEAPON_HITSAW');
1059 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN2');
1060 g_Sound_Delete('SOUND_WEAPON_FIRESHOTGUN');
1061 g_Sound_Delete('SOUND_WEAPON_FIRESAW');
1062 g_Sound_Delete('SOUND_WEAPON_FIREROCKET');
1063 g_Sound_Delete('SOUND_WEAPON_FIREPLASMA');
1064 g_Sound_Delete('SOUND_WEAPON_FIREPISTOL');
1065 g_Sound_Delete('SOUND_WEAPON_FIRECGUN');
1066 g_Sound_Delete('SOUND_WEAPON_FIREBFG');
1067 g_Sound_Delete('SOUND_FIRE');
1068 g_Sound_Delete('SOUND_WEAPON_STARTFIREBFG');
1069 g_Sound_Delete('SOUND_WEAPON_EXPLODEROCKET');
1070 g_Sound_Delete('SOUND_WEAPON_EXPLODEBFG');
1071 g_Sound_Delete('SOUND_WEAPON_BFGWATER');
1072 g_Sound_Delete('SOUND_WEAPON_EXPLODEPLASMA');
1073 g_Sound_Delete('SOUND_WEAPON_PLASMAWATER');
1074 g_Sound_Delete('SOUND_WEAPON_FIREBALL');
1075 g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL');
1076 g_Sound_Delete('SOUND_WEAPON_FIREREV');
1077 g_Sound_Delete('SOUND_PLAYER_JETFLY');
1078 g_Sound_Delete('SOUND_PLAYER_JETON');
1079 g_Sound_Delete('SOUND_PLAYER_JETOFF');
1080 g_Sound_Delete('SOUND_PLAYER_CASING1');
1081 g_Sound_Delete('SOUND_PLAYER_CASING2');
1082 g_Sound_Delete('SOUND_PLAYER_SHELL1');
1083 g_Sound_Delete('SOUND_PLAYER_SHELL2');
1085 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
1086 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
1087 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
1088 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
1089 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
1090 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
1091 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
1092 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
1093 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
1094 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
1095 g_Frames_DeleteByName('FRAMES_BFGHIT');
1096 g_Frames_DeleteByName('FRAMES_FIRE');
1097 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
1098 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
1099 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
1100 g_Frames_DeleteByName('FRAMES_SMOKE');
1101 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
1102 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
1103 end;
1105 procedure g_Weapon_gun(x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
1106 var
1107 a: Integer;
1108 x2, y2: Integer;
1109 dx, dy: Integer;
1110 xe, ye: Integer;
1111 xi, yi: Integer;
1112 s, c: Extended;
1113 //vx, vy: Integer;
1114 xx, yy, d: Integer;
1116 i: Integer;
1117 t1, _collide: Boolean;
1118 w, h: Word;
1119 begin
1120 a := GetAngle(x, y, xd, yd)+180;
1122 SinCos(DegToRad(-a), s, c);
1124 if Abs(s) < 0.01 then s := 0;
1125 if Abs(c) < 0.01 then c := 0;
1127 x2 := x+Round(c*gMapInfo.Width);
1128 y2 := y+Round(s*gMapInfo.Width);
1130 t1 := gWalls <> nil;
1131 _collide := False;
1132 w := gMapInfo.Width;
1133 h := gMapInfo.Height;
1135 xe := 0;
1136 ye := 0;
1137 dx := x2-x;
1138 dy := y2-y;
1140 if (xd = 0) and (yd = 0) then Exit;
1142 if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
1143 if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
1145 dx := Abs(dx);
1146 dy := Abs(dy);
1148 if dx > dy then d := dx else d := dy;
1150 //blood vel, for Monster.Damage()
1151 //vx := (dx*10 div d)*xi;
1152 //vy := (dy*10 div d)*yi;
1154 xx := x;
1155 yy := y;
1157 for i := 1 to d do
1158 begin
1159 xe := xe+dx;
1160 ye := ye+dy;
1162 if xe > d then
1163 begin
1164 xe := xe-d;
1165 xx := xx+xi;
1166 end;
1168 if ye > d then
1169 begin
1170 ye := ye-d;
1171 yy := yy+yi;
1172 end;
1174 if (yy > h) or (yy < 0) then Break;
1175 if (xx > w) or (xx < 0) then Break;
1177 if t1 then
1178 if ByteBool(gCollideMap[yy, xx] and MARK_BLOCKED) then
1179 begin
1180 _collide := True;
1181 g_GFX_Spark(xx-xi, yy-yi, 2+Random(2), 180+a, 0, 0);
1182 if g_Game_IsServer and g_Game_IsNet then
1183 MH_SEND_Effect(xx-xi, yy-yi, 180+a, NET_GFX_SPARK);
1184 end;
1186 if not _collide then
1187 _collide := GunHit(xx, yy, xi*v, yi*v, dmg, SpawnerUID, v <> 0) <> 0;
1189 if _collide then
1190 Break;
1191 end;
1193 if CheckTrigger and g_Game_IsServer then
1194 g_Triggers_PressL(X, Y, xx-xi, yy-yi, SpawnerUID, ACTIVATE_SHOT);
1195 end;
1197 procedure g_Weapon_punch(x, y: Integer; d, SpawnerUID: Word);
1198 var
1199 obj: TObj;
1200 begin
1201 obj.X := X;
1202 obj.Y := Y;
1203 obj.rect.X := 0;
1204 obj.rect.Y := 0;
1205 obj.rect.Width := 39;
1206 obj.rect.Height := 52;
1207 obj.Vel.X := 0;
1208 obj.Vel.Y := 0;
1209 obj.Accel.X := 0;
1210 obj.Accel.Y := 0;
1212 if g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME) <> 0 then
1213 g_Sound_PlayExAt('SOUND_WEAPON_HITPUNCH', x, y)
1214 else
1215 g_Sound_PlayExAt('SOUND_WEAPON_MISSPUNCH', x, y);
1216 end;
1218 function g_Weapon_chainsaw(x, y: Integer; d, SpawnerUID: Word): Integer;
1219 var
1220 obj: TObj;
1221 begin
1222 obj.X := X;
1223 obj.Y := Y;
1224 obj.rect.X := 0;
1225 obj.rect.Y := 0;
1226 obj.rect.Width := 32;
1227 obj.rect.Height := 52;
1228 obj.Vel.X := 0;
1229 obj.Vel.Y := 0;
1230 obj.Accel.X := 0;
1231 obj.Accel.Y := 0;
1233 Result := g_Weapon_Hit(@obj, d, SpawnerUID, HIT_SOME);
1234 end;
1236 procedure g_Weapon_rocket(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1237 Silent: Boolean = False);
1238 var
1239 find_id: DWORD;
1240 dx, dy: Integer;
1241 begin
1242 if WID < 0 then
1243 find_id := FindShot()
1244 else
1245 begin
1246 find_id := WID;
1247 if Integer(find_id) >= High(Shots) then
1248 SetLength(Shots, find_id + 64)
1249 end;
1251 with Shots[find_id] do
1252 begin
1253 g_Obj_Init(@Obj);
1255 Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
1256 Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
1258 dx := IfThen(xd > x, -Obj.Rect.Width, 0);
1259 dy := -(Obj.Rect.Height div 2);
1261 ShotType := WEAPON_ROCKETLAUNCHER;
1262 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1264 Animation := nil;
1265 triggers := nil;
1266 g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
1267 end;
1269 Shots[find_id].SpawnerUID := SpawnerUID;
1271 if not Silent then
1272 g_Sound_PlayExAt('SOUND_WEAPON_FIREROCKET', x, y);
1273 end;
1275 procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
1276 WID: Integer = -1; Silent: Boolean = False);
1277 var
1278 find_id, FramesID: DWORD;
1279 dx, dy: Integer;
1280 begin
1281 if WID < 0 then
1282 find_id := FindShot()
1283 else
1284 begin
1285 find_id := WID;
1286 if Integer(find_id) >= High(Shots) then
1287 SetLength(Shots, find_id + 64)
1288 end;
1290 with Shots[find_id] do
1291 begin
1292 g_Obj_Init(@Obj);
1294 Obj.Rect.Width := SHOT_SKELFIRE_WIDTH;
1295 Obj.Rect.Height := SHOT_SKELFIRE_HEIGHT;
1297 dx := -(Obj.Rect.Width div 2);
1298 dy := -(Obj.Rect.Height div 2);
1300 ShotType := WEAPON_SKEL_FIRE;
1301 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
1303 triggers := nil;
1304 target := TargetUID;
1305 g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
1306 Animation := TAnimation.Create(FramesID, True, 5);
1307 end;
1309 Shots[find_id].SpawnerUID := SpawnerUID;
1311 if not Silent then
1312 g_Sound_PlayExAt('SOUND_WEAPON_FIREREV', x, y);
1313 end;
1315 procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1316 Silent: Boolean = False);
1317 var
1318 find_id, FramesID: DWORD;
1319 dx, dy: Integer;
1320 begin
1321 if WID < 0 then
1322 find_id := FindShot()
1323 else
1324 begin
1325 find_id := WID;
1326 if Integer(find_id) >= High(Shots) then
1327 SetLength(Shots, find_id + 64);
1328 end;
1330 with Shots[find_id] do
1331 begin
1332 g_Obj_Init(@Obj);
1334 Obj.Rect.Width := SHOT_PLASMA_WIDTH;
1335 Obj.Rect.Height := SHOT_PLASMA_HEIGHT;
1337 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1338 dy := -(Obj.Rect.Height div 2);
1340 ShotType := WEAPON_PLASMA;
1341 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1343 triggers := nil;
1344 g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
1345 Animation := TAnimation.Create(FramesID, True, 5);
1346 end;
1348 Shots[find_id].SpawnerUID := SpawnerUID;
1350 if not Silent then
1351 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1352 end;
1354 procedure g_Weapon_flame(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1355 Silent: Boolean = False);
1356 var
1357 find_id, FramesID: DWORD;
1358 dx, dy: Integer;
1359 begin
1360 if WID < 0 then
1361 find_id := FindShot()
1362 else
1363 begin
1364 find_id := WID;
1365 if Integer(find_id) >= High(Shots) then
1366 SetLength(Shots, find_id + 64);
1367 end;
1369 with Shots[find_id] do
1370 begin
1371 g_Obj_Init(@Obj);
1373 Obj.Rect.Width := SHOT_FLAME_WIDTH;
1374 Obj.Rect.Height := SHOT_FLAME_HEIGHT;
1376 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1377 dy := -(Obj.Rect.Height div 2);
1379 ShotType := WEAPON_FLAMETHROWER;
1380 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1382 triggers := nil;
1383 Animation := nil;
1384 TextureID := 0;
1385 g_Frames_Get(TextureID, 'FRAMES_FLAME');
1386 end;
1388 Shots[find_id].SpawnerUID := SpawnerUID;
1390 // if not Silent then
1391 // g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1392 end;
1394 procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1395 Silent: Boolean = False);
1396 var
1397 find_id, FramesID: DWORD;
1398 dx, dy: Integer;
1399 begin
1400 if WID < 0 then
1401 find_id := FindShot()
1402 else
1403 begin
1404 find_id := WID;
1405 if Integer(find_id) >= High(Shots) then
1406 SetLength(Shots, find_id + 64)
1407 end;
1409 with Shots[find_id] do
1410 begin
1411 g_Obj_Init(@Obj);
1413 Obj.Rect.Width := 16;
1414 Obj.Rect.Height := 16;
1416 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1417 dy := -(Obj.Rect.Height div 2);
1419 ShotType := WEAPON_IMP_FIRE;
1420 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1422 triggers := nil;
1423 g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
1424 Animation := TAnimation.Create(FramesID, True, 4);
1425 end;
1427 Shots[find_id].SpawnerUID := SpawnerUID;
1429 if not Silent then
1430 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1431 end;
1433 procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1434 Silent: Boolean = False);
1435 var
1436 find_id, FramesID: DWORD;
1437 dx, dy: Integer;
1438 begin
1439 if WID < 0 then
1440 find_id := FindShot()
1441 else
1442 begin
1443 find_id := WID;
1444 if Integer(find_id) >= High(Shots) then
1445 SetLength(Shots, find_id + 64)
1446 end;
1448 with Shots[find_id] do
1449 begin
1450 g_Obj_Init(@Obj);
1452 Obj.Rect.Width := 16;
1453 Obj.Rect.Height := 16;
1455 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1456 dy := -(Obj.Rect.Height div 2);
1458 ShotType := WEAPON_CACO_FIRE;
1459 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1461 triggers := nil;
1462 g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
1463 Animation := TAnimation.Create(FramesID, True, 4);
1464 end;
1466 Shots[find_id].SpawnerUID := SpawnerUID;
1468 if not Silent then
1469 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1470 end;
1472 procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1473 Silent: Boolean = False);
1474 var
1475 find_id, FramesID: DWORD;
1476 dx, dy: Integer;
1477 begin
1478 if WID < 0 then
1479 find_id := FindShot()
1480 else
1481 begin
1482 find_id := WID;
1483 if Integer(find_id) >= High(Shots) then
1484 SetLength(Shots, find_id + 64)
1485 end;
1487 with Shots[find_id] do
1488 begin
1489 g_Obj_Init(@Obj);
1491 Obj.Rect.Width := 32;
1492 Obj.Rect.Height := 16;
1494 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1495 dy := -(Obj.Rect.Height div 2);
1497 ShotType := WEAPON_BARON_FIRE;
1498 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1500 triggers := nil;
1501 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
1502 Animation := TAnimation.Create(FramesID, True, 4);
1503 end;
1505 Shots[find_id].SpawnerUID := SpawnerUID;
1507 if not Silent then
1508 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1509 end;
1511 procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1512 Silent: Boolean = False);
1513 var
1514 find_id, FramesID: DWORD;
1515 dx, dy: Integer;
1516 begin
1517 if WID < 0 then
1518 find_id := FindShot()
1519 else
1520 begin
1521 find_id := WID;
1522 if Integer(find_id) >= High(Shots) then
1523 SetLength(Shots, find_id + 64)
1524 end;
1526 with Shots[find_id] do
1527 begin
1528 g_Obj_Init(@Obj);
1530 Obj.Rect.Width := 16;
1531 Obj.Rect.Height := 16;
1533 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1534 dy := -(Obj.Rect.Height div 2);
1536 ShotType := WEAPON_BSP_FIRE;
1537 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1539 triggers := nil;
1541 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
1542 Animation := TAnimation.Create(FramesID, True, 4);
1543 end;
1545 Shots[find_id].SpawnerUID := SpawnerUID;
1547 if not Silent then
1548 g_Sound_PlayExAt('SOUND_WEAPON_FIREPLASMA', x, y);
1549 end;
1551 procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1552 Silent: Boolean = False);
1553 var
1554 find_id, FramesID: DWORD;
1555 dx, dy: Integer;
1556 begin
1557 if WID < 0 then
1558 find_id := FindShot()
1559 else
1560 begin
1561 find_id := WID;
1562 if Integer(find_id) >= High(Shots) then
1563 SetLength(Shots, find_id + 64)
1564 end;
1566 with Shots[find_id] do
1567 begin
1568 g_Obj_Init(@Obj);
1570 Obj.Rect.Width := 32;
1571 Obj.Rect.Height := 32;
1573 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1574 dy := -(Obj.Rect.Height div 2);
1576 ShotType := WEAPON_MANCUB_FIRE;
1577 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1579 triggers := nil;
1581 g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
1582 Animation := TAnimation.Create(FramesID, True, 4);
1583 end;
1585 Shots[find_id].SpawnerUID := SpawnerUID;
1587 if not Silent then
1588 g_Sound_PlayExAt('SOUND_WEAPON_FIREBALL', x, y);
1589 end;
1591 procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
1592 Silent: Boolean = False);
1593 var
1594 find_id, FramesID: DWORD;
1595 dx, dy: Integer;
1596 begin
1597 if WID < 0 then
1598 find_id := FindShot()
1599 else
1600 begin
1601 find_id := WID;
1602 if Integer(find_id) >= High(Shots) then
1603 SetLength(Shots, find_id + 64)
1604 end;
1606 with Shots[find_id] do
1607 begin
1608 g_Obj_Init(@Obj);
1610 Obj.Rect.Width := SHOT_BFG_WIDTH;
1611 Obj.Rect.Height := SHOT_BFG_HEIGHT;
1613 dx := IfThen(xd>x, -Obj.Rect.Width, 0);
1614 dy := -(Obj.Rect.Height div 2);
1616 ShotType := WEAPON_BFG;
1617 throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
1619 triggers := nil;
1620 g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
1621 Animation := TAnimation.Create(FramesID, True, 6);
1622 end;
1624 Shots[find_id].SpawnerUID := SpawnerUID;
1626 if not Silent then
1627 g_Sound_PlayExAt('SOUND_WEAPON_FIREBFG', x, y);
1628 end;
1630 procedure g_Weapon_bfghit(x, y: Integer);
1631 var
1632 ID: DWORD;
1633 Anim: TAnimation;
1634 begin
1635 if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
1636 begin
1637 Anim := TAnimation.Create(ID, False, 4);
1638 g_GFX_OnceAnim(x-32, y-32, Anim);
1639 Anim.Free();
1640 end;
1641 end;
1643 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
1644 Silent: Boolean = False);
1645 begin
1646 if not Silent then
1647 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', x, y);
1649 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1650 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
1651 begin
1652 g_Weapon_gun(x, y+1, xd, yd+1, 1, 3, SpawnerUID, False);
1653 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1654 end;
1655 end;
1657 procedure g_Weapon_mgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1658 Silent: Boolean = False);
1659 begin
1660 if not Silent then
1661 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', x, y);
1663 g_Weapon_gun(x, y, xd, yd, 1, 3, SpawnerUID, True);
1664 if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
1665 (g_GetUIDType(SpawnerUID) = UID_PLAYER) then
1666 begin
1667 g_Weapon_gun(x, y+1, xd, yd+1, 1, 2, SpawnerUID, False);
1668 g_Weapon_gun(x, y-1, xd, yd-1, 1, 2, SpawnerUID, False);
1669 end;
1670 end;
1672 procedure g_Weapon_shotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1673 Silent: Boolean = False);
1674 var
1675 i, j: Integer;
1676 begin
1677 if not Silent then
1678 if gSoundEffectsDF then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', x, y);
1680 for i := 0 to 9 do
1681 begin
1682 j := Random(17)-8; // -8 .. 8
1683 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 2 <> 0, 1, 0), 3, SpawnerUID, i=0);
1684 end;
1685 end;
1687 procedure g_Weapon_dshotgun(x, y, xd, yd: Integer; SpawnerUID: Word;
1688 Silent: Boolean = False);
1689 var
1690 a, i, j: Integer;
1691 begin
1692 if not Silent then
1693 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', x, y);
1695 if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then a := 25 else a := 20;
1696 for i := 0 to a do
1697 begin
1698 j := Random(41)-20; // -20 .. 20
1699 g_Weapon_gun(x, y+j, xd, yd+j, IfThen(i mod 3 <> 0, 0, 1), 3, SpawnerUID, i=0);
1700 end;
1701 end;
1703 procedure g_Weapon_Update();
1704 var
1705 i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
1706 _id: DWORD;
1707 Anim: TAnimation;
1708 t: DWArray;
1709 st: Word;
1710 s: String;
1711 o: TObj;
1712 spl: Boolean;
1713 Loud: Boolean;
1714 begin
1715 if Shots = nil then
1716 Exit;
1718 for i := 0 to High(Shots) do
1719 begin
1720 if Shots[i].ShotType = 0 then
1721 Continue;
1723 Loud := True;
1725 with Shots[i] do
1726 begin
1727 Timeout := Timeout - 1;
1728 oldvx := Obj.Vel.X;
1729 oldvy := Obj.Vel.Y;
1730 // Àêòèâèðîâàòü òðèããåðû ïî ïóòè (êðîìå óæå àêòèâèðîâàííûõ):
1731 if (Stopped = 0) and g_Game_IsServer then
1732 t := g_Triggers_PressR(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height,
1733 SpawnerUID, ACTIVATE_SHOT, triggers)
1734 else
1735 t := nil;
1737 if t <> nil then
1738 begin
1739 // Ïîïîëíÿåì ñïèñîê àêòèâèðîâàííûõ òðèããåðîâ:
1740 if triggers = nil then
1741 triggers := t
1742 else
1743 begin
1744 h := High(t);
1746 for a := 0 to h do
1747 if not InDWArray(t[a], triggers) then
1748 begin
1749 SetLength(triggers, Length(triggers)+1);
1750 triggers[High(triggers)] := t[a];
1751 end;
1752 end;
1753 end;
1755 // Àíèìàöèÿ ñíàðÿäà:
1756 if Animation <> nil then
1757 Animation.Update();
1759 // Äâèæåíèå:
1760 spl := (ShotType <> WEAPON_PLASMA) and
1761 (ShotType <> WEAPON_BFG) and
1762 (ShotType <> WEAPON_BSP_FIRE) and
1763 (ShotType <> WEAPON_FLAMETHROWER);
1765 if Stopped = 0 then
1766 st := g_Obj_Move(@Obj, False, spl)
1767 else
1768 st := 0;
1770 if WordBool(st and MOVE_FALLOUT) or (Obj.X < -1000) or
1771 (Obj.X > gMapInfo.Width+1000) or (Obj.Y < -1000) then
1772 begin
1773 // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
1774 ShotType := 0;
1775 Animation.Free();
1776 Continue;
1777 end;
1779 cx := Obj.X + (Obj.Rect.Width div 2);
1780 cy := Obj.Y + (Obj.Rect.Height div 2);
1782 case ShotType of
1783 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
1784 begin
1785 // Âûëåòåëà èç âîäû:
1786 if WordBool(st and MOVE_HITAIR) then
1787 g_Obj_SetSpeed(@Obj, 12);
1789 // Â âîäå øëåéô - ïóçûðè, â âîçäóõå øëåéô - äûì:
1790 if WordBool(st and MOVE_INWATER) then
1791 g_GFX_Bubbles(Obj.X+(Obj.Rect.Width div 2),
1792 Obj.Y+(Obj.Rect.Height div 2),
1793 1+Random(3), 16, 16)
1794 else
1795 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1796 begin
1797 Anim := TAnimation.Create(_id, False, 3);
1798 Anim.Alpha := 150;
1799 g_GFX_OnceAnim(Obj.X-14+Random(9),
1800 Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
1801 Anim, ONCEANIM_SMOKE);
1802 Anim.Free();
1803 end;
1805 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1806 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1807 (g_Weapon_Hit(@Obj, 10, SpawnerUID, HIT_SOME, False) <> 0) or
1808 (Timeout < 1) then
1809 begin
1810 Obj.Vel.X := 0;
1811 Obj.Vel.Y := 0;
1813 g_Weapon_Explode(cx, cy, 60, SpawnerUID);
1815 if ShotType = WEAPON_SKEL_FIRE then
1816 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
1817 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
1818 begin
1819 Anim := TAnimation.Create(TextureID, False, 8);
1820 Anim.Blending := False;
1821 g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
1822 Anim.Free();
1823 end;
1824 end
1825 else
1826 begin // Âçðûâ Ðàêåòû
1827 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
1828 begin
1829 Anim := TAnimation.Create(TextureID, False, 6);
1830 Anim.Blending := False;
1831 g_GFX_OnceAnim(cx-64, cy-64, Anim);
1832 Anim.Free();
1833 end;
1834 end;
1836 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
1838 ShotType := 0;
1839 end;
1841 if ShotType = WEAPON_SKEL_FIRE then
1842 begin // Ñàìîíàâîäêà ñíàðÿäà Ñêåëåòà:
1843 if GetPos(target, @o) then
1844 throw(i, Obj.X, Obj.Y,
1845 o.X+o.Rect.X+(o.Rect.Width div 2)+o.Vel.X+o.Accel.X,
1846 o.Y+o.Rect.Y+(o.Rect.Height div 2)+o.Vel.Y+o.Accel.Y,
1847 12);
1848 end;
1849 end;
1851 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
1852 begin
1853 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1854 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1855 begin
1856 g_Sound_PlayExAt('SOUND_WEAPON_PLASMAWATER', Obj.X, Obj.Y);
1857 if g_Game_IsServer then CheckTrap(i, 10, HIT_ELECTRO);
1858 ShotType := 0;
1859 Continue;
1860 end;
1862 // Âåëè÷èíà óðîíà:
1863 if (ShotType = WEAPON_PLASMA) and
1864 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1865 a := 10
1866 else
1867 a := 5;
1869 if ShotType = WEAPON_BSP_FIRE then
1870 a := 10;
1872 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1873 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1874 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME, False) <> 0) or
1875 (Timeout < 1) then
1876 begin
1877 if ShotType = WEAPON_PLASMA then
1878 s := 'FRAMES_EXPLODE_PLASMA'
1879 else
1880 s := 'FRAMES_EXPLODE_BSPFIRE';
1882 // Âçðûâ Ïëàçìû:
1883 if g_Frames_Get(TextureID, s) then
1884 begin
1885 Anim := TAnimation.Create(TextureID, False, 3);
1886 Anim.Blending := False;
1887 g_GFX_OnceAnim(cx-16, cy-16, Anim);
1888 Anim.Free();
1889 end;
1891 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
1893 ShotType := 0;
1894 end;
1895 end;
1897 WEAPON_FLAMETHROWER: // Îãíåìåò
1898 begin
1899 // Ñî âðåìåíåì óìèðàåò
1900 if (Timeout < 1) then
1901 begin
1902 ShotType := 0;
1903 Continue;
1904 end;
1905 // Ïîä âîäîé òîæå
1906 if WordBool(st and (MOVE_HITWATER or MOVE_INWATER)) then
1907 begin
1908 if WordBool(st and MOVE_HITWATER) then
1909 begin
1910 if g_Frames_Get(_id, 'FRAMES_SMOKE') then
1911 begin
1912 Anim := TAnimation.Create(_id, False, 3);
1913 Anim.Alpha := 0;
1914 g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1915 cy-4+Random(8)-(Anim.Height div 2),
1916 Anim, ONCEANIM_SMOKE);
1917 Anim.Free();
1918 end;
1919 end
1920 else
1921 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
1922 ShotType := 0;
1923 Continue;
1924 end;
1926 // Ãðàâèòàöèÿ
1927 if Stopped = 0 then
1928 Obj.Accel.Y := Obj.Accel.Y + 1;
1929 // Ïîïàëè â ñòåíó èëè â âîäó:
1930 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL or MOVE_HITWATER)) then
1931 begin
1932 // Ïðèëèïàåì:
1933 Obj.Vel.X := 0;
1934 Obj.Vel.Y := 0;
1935 Obj.Accel.Y := 0;
1936 if WordBool(st and MOVE_HITWALL) then
1937 Stopped := MOVE_HITWALL
1938 else if WordBool(st and MOVE_HITLAND) then
1939 Stopped := MOVE_HITLAND
1940 else if WordBool(st and MOVE_HITCEIL) then
1941 Stopped := MOVE_HITCEIL;
1942 end;
1944 a := IfThen(Stopped = 0, 3, 1);
1945 // Åñëè â êîãî-òî ïîïàëè
1946 if g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_FLAME, False) <> 0 then
1947 begin
1948 // HIT_FLAME ñàì ïîäîææåò
1949 // Åñëè â ïîëåòå ïîïàëè, èñ÷åçàåì
1950 if Stopped = 0 then
1951 ShotType := 0;
1952 end;
1954 if Stopped = 0 then
1955 tf := 2
1956 else
1957 tf := 3;
1959 if (gTime mod tf = 0) then
1960 begin
1961 Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
1962 Anim.Alpha := 0;
1963 case Stopped of
1964 MOVE_HITWALL: g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1965 cy-12+Random(24)-(Anim.Height div 2),
1966 Anim, ONCEANIM_SMOKE);
1967 MOVE_HITLAND: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1968 cy-10+Random(8)-(Anim.Height div 2),
1969 Anim, ONCEANIM_SMOKE);
1970 MOVE_HITCEIL: g_GFX_OnceAnim(cx-12+Random(24)-(Anim.Width div 2),
1971 cy+6+Random(8)-(Anim.Height div 2),
1972 Anim, ONCEANIM_SMOKE);
1973 else g_GFX_OnceAnim(cx-4+Random(8)-(Anim.Width div 2),
1974 cy-4+Random(8)-(Anim.Height div 2),
1975 Anim, ONCEANIM_SMOKE);
1976 end;
1977 Anim.Free();
1978 end;
1979 end;
1981 WEAPON_BFG: // BFG
1982 begin
1983 // Ïîïàëà â âîäó - ýëåêòðîøîê ïî âîäå:
1984 if WordBool(st and (MOVE_INWATER or MOVE_HITWATER)) then
1985 begin
1986 g_Sound_PlayExAt('SOUND_WEAPON_BFGWATER', Obj.X, Obj.Y);
1987 if g_Game_IsServer then CheckTrap(i, 1000, HIT_ELECTRO);
1988 ShotType := 0;
1989 Continue;
1990 end;
1992 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
1993 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
1994 (g_Weapon_Hit(@Obj, SHOT_BFG_DAMAGE, SpawnerUID, HIT_BFG, False) <> 0) or
1995 (Timeout < 1) then
1996 begin
1997 // Ëó÷è BFG:
1998 if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
2000 // Âçðûâ BFG:
2001 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
2002 begin
2003 Anim := TAnimation.Create(TextureID, False, 6);
2004 Anim.Blending := False;
2005 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2006 Anim.Free();
2007 end;
2009 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2011 ShotType := 0;
2012 end;
2013 end;
2015 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2016 begin
2017 // Âûëåòåë èç âîäû:
2018 if WordBool(st and MOVE_HITAIR) then
2019 g_Obj_SetSpeed(@Obj, 16);
2021 // Âåëè÷èíà óðîíà:
2022 if ShotType = WEAPON_IMP_FIRE then
2023 a := 5
2024 else
2025 if ShotType = WEAPON_CACO_FIRE then
2026 a := 20
2027 else
2028 a := 40;
2030 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2031 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2032 (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
2033 (Timeout < 1) then
2034 begin
2035 if ShotType = WEAPON_IMP_FIRE then
2036 s := 'FRAMES_EXPLODE_IMPFIRE'
2037 else
2038 if ShotType = WEAPON_CACO_FIRE then
2039 s := 'FRAMES_EXPLODE_CACOFIRE'
2040 else
2041 s := 'FRAMES_EXPLODE_BARONFIRE';
2043 // Âçðûâ:
2044 if g_Frames_Get(TextureID, s) then
2045 begin
2046 Anim := TAnimation.Create(TextureID, False, 6);
2047 Anim.Blending := False;
2048 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2049 Anim.Free();
2050 end;
2052 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2054 ShotType := 0;
2055 end;
2056 end;
2058 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2059 begin
2060 // Âûëåòåë èç âîäû:
2061 if WordBool(st and MOVE_HITAIR) then
2062 g_Obj_SetSpeed(@Obj, 16);
2064 // Ïîïàëè â êîãî-òî èëè â ñòåíó:
2065 if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
2066 (g_Weapon_Hit(@Obj, 40, SpawnerUID, HIT_SOME, False) <> 0) or
2067 (Timeout < 1) then
2068 begin
2069 // Âçðûâ:
2070 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2071 begin
2072 Anim := TAnimation.Create(TextureID, False, 6);
2073 Anim.Blending := False;
2074 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2075 Anim.Free();
2076 end;
2078 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2080 ShotType := 0;
2081 end;
2082 end;
2083 end; // case ShotType of...
2085 // Åñëè ñíàðÿäà óæå íåò, óäàëÿåì àíèìàöèþ:
2086 if (ShotType = 0) then
2087 begin
2088 if gGameSettings.GameType = GT_SERVER then
2089 MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
2090 if Animation <> nil then
2091 begin
2092 Animation.Free();
2093 Animation := nil;
2094 end;
2095 end
2096 else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
2097 if gGameSettings.GameType = GT_SERVER then
2098 MH_SEND_UpdateShot(i);
2099 end;
2100 end;
2101 end;
2103 procedure g_Weapon_Draw();
2104 var
2105 i: Integer;
2106 a: SmallInt;
2107 p: TPoint;
2108 begin
2109 if Shots = nil then
2110 Exit;
2112 for i := 0 to High(Shots) do
2113 if Shots[i].ShotType <> 0 then
2114 with Shots[i] do
2115 begin
2116 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or
2117 (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2118 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2119 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2120 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
2121 else
2122 a := 0;
2124 p.X := Obj.Rect.Width div 2;
2125 p.Y := Obj.Rect.Height div 2;
2127 if Animation <> nil then
2128 begin
2129 if (Shots[i].ShotType = WEAPON_BARON_FIRE) or
2130 (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or
2131 (Shots[i].ShotType = WEAPON_SKEL_FIRE) then
2132 Animation.DrawEx(Obj.X, Obj.Y, M_NONE, p, a)
2133 else
2134 Animation.Draw(Obj.X, Obj.Y, M_NONE);
2135 end
2136 else if TextureID <> 0 then
2137 begin
2138 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
2139 e_DrawAdv(TextureID, Obj.X, Obj.Y, 0, True, False, a, @p, M_NONE)
2140 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
2141 e_Draw(TextureID, Obj.X, Obj.Y, 0, True, False);
2142 end;
2144 if g_debug_Frames then
2145 begin
2146 e_DrawQuad(Obj.X+Obj.Rect.X,
2147 Obj.Y+Obj.Rect.Y,
2148 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
2149 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
2150 0, 255, 0);
2151 end;
2152 end;
2153 end;
2155 function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean;
2156 var
2157 a: Integer;
2158 begin
2159 Result := False;
2161 if Shots = nil then
2162 Exit;
2164 for a := 0 to High(Shots) do
2165 if (Shots[a].ShotType <> 0) and (Shots[a].SpawnerUID <> UID) then
2166 if ((Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X > 0) and (Shots[a].Obj.X < X)) or
2167 (Shots[a].Obj.Vel.Y = 0) and (Shots[a].Obj.Vel.X < 0) and (Shots[a].Obj.X > X) then
2168 if (Abs(X-Shots[a].Obj.X) < Abs(Shots[a].Obj.Vel.X*Time)) and
2169 g_Collide(X, Y, Width, Height, X, Shots[a].Obj.Y,
2170 Shots[a].Obj.Rect.Width, Shots[a].Obj.Rect.Height) and
2171 g_TraceVector(X, Y, Shots[a].Obj.X, Shots[a].Obj.Y) then
2172 begin
2173 Result := True;
2174 Exit;
2175 end;
2176 end;
2178 procedure g_Weapon_SaveState(var Mem: TBinMemoryWriter);
2179 var
2180 count, i, j: Integer;
2181 dw: DWORD;
2182 begin
2183 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ñíàðÿäîâ:
2184 count := 0;
2185 if Shots <> nil then
2186 for i := 0 to High(Shots) do
2187 if Shots[i].ShotType <> 0 then
2188 count := count + 1;
2190 Mem := TBinMemoryWriter.Create((count+1) * 80);
2192 // Êîëè÷åñòâî ñíàðÿäîâ:
2193 Mem.WriteInt(count);
2195 if count = 0 then
2196 Exit;
2198 for i := 0 to High(Shots) do
2199 if Shots[i].ShotType <> 0 then
2200 begin
2201 // Ñèãíàòóðà ñíàðÿäà:
2202 dw := SHOT_SIGNATURE; // 'SHOT'
2203 Mem.WriteDWORD(dw);
2204 // Òèï ñíàðÿäà:
2205 Mem.WriteByte(Shots[i].ShotType);
2206 // Öåëü:
2207 Mem.WriteWord(Shots[i].Target);
2208 // UID ñòðåëÿâøåãî:
2209 Mem.WriteWord(Shots[i].SpawnerUID);
2210 // Ðàçìåð ïîëÿ Triggers:
2211 dw := Length(Shots[i].Triggers);
2212 Mem.WriteDWORD(dw);
2213 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2214 for j := 0 to Integer(dw)-1 do
2215 Mem.WriteDWORD(Shots[i].Triggers[j]);
2216 // Îáúåêò ñíàðÿäà:
2217 Obj_SaveState(@Shots[i].Obj, Mem);
2218 // Êîñòûëèíà åáàíàÿ:
2219 Mem.WriteByte(Shots[i].Stopped);
2220 end;
2221 end;
2223 procedure g_Weapon_LoadState(var Mem: TBinMemoryReader);
2224 var
2225 count, i, j: Integer;
2226 dw: DWORD;
2227 begin
2228 if Mem = nil then
2229 Exit;
2231 // Êîëè÷åñòâî ñíàðÿäîâ:
2232 Mem.ReadInt(count);
2234 SetLength(Shots, count);
2236 if count = 0 then
2237 Exit;
2239 for i := 0 to count-1 do
2240 begin
2241 // Ñèãíàòóðà ñíàðÿäà:
2242 Mem.ReadDWORD(dw);
2243 if dw <> SHOT_SIGNATURE then // 'SHOT'
2244 begin
2245 raise EBinSizeError.Create('g_Weapons_LoadState: Wrong Shot Signature');
2246 end;
2247 // Òèï ñíàðÿäà:
2248 Mem.ReadByte(Shots[i].ShotType);
2249 // Öåëü:
2250 Mem.ReadWord(Shots[i].Target);
2251 // UID ñòðåëÿâøåãî:
2252 Mem.ReadWord(Shots[i].SpawnerUID);
2253 // Ðàçìåð ïîëÿ Triggers:
2254 Mem.ReadDWORD(dw);
2255 SetLength(Shots[i].Triggers, dw);
2256 // Òðèããåðû, àêòèâèðîâàííûå âûñòðåëîì:
2257 for j := 0 to Integer(dw)-1 do
2258 Mem.ReadDWORD(Shots[i].Triggers[j]);
2259 // Îáúåêò ïðåäìåòà:
2260 Obj_LoadState(@Shots[i].Obj, Mem);
2261 // Êîñòûëèíà åáàíàÿ:
2262 Mem.ReadByte(Shots[i].Stopped);
2264 // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè:
2265 Shots[i].TextureID := DWORD(-1);
2266 Shots[i].Animation := nil;
2268 case Shots[i].ShotType of
2269 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
2270 begin
2271 g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
2272 end;
2273 WEAPON_PLASMA:
2274 begin
2275 g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
2276 Shots[i].Animation := TAnimation.Create(dw, True, 5);
2277 end;
2278 WEAPON_BFG:
2279 begin
2280 g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
2281 Shots[i].Animation := TAnimation.Create(dw, True, 6);
2282 end;
2283 WEAPON_IMP_FIRE:
2284 begin
2285 g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
2286 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2287 end;
2288 WEAPON_BSP_FIRE:
2289 begin
2290 g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
2291 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2292 end;
2293 WEAPON_CACO_FIRE:
2294 begin
2295 g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
2296 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2297 end;
2298 WEAPON_BARON_FIRE:
2299 begin
2300 g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
2301 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2302 end;
2303 WEAPON_MANCUB_FIRE:
2304 begin
2305 g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
2306 Shots[i].Animation := TAnimation.Create(dw, True, 4);
2307 end;
2308 end;
2309 end;
2310 end;
2312 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
2313 var
2314 cx, cy: Integer;
2315 Anim: TAnimation;
2316 s: string;
2317 begin
2318 if Shots = nil then
2319 Exit;
2320 if (I > High(Shots)) or (I < 0) then Exit;
2322 with Shots[I] do
2323 begin
2324 if ShotType = 0 then Exit;
2325 Obj.X := X;
2326 Obj.Y := Y;
2327 cx := Obj.X + (Obj.Rect.Width div 2);
2328 cy := Obj.Y + (Obj.Rect.Height div 2);
2330 case ShotType of
2331 WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
2332 begin
2333 if Loud then
2334 begin
2335 if ShotType = WEAPON_SKEL_FIRE then
2336 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
2337 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
2338 begin
2339 Anim := TAnimation.Create(TextureID, False, 8);
2340 Anim.Blending := False;
2341 g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
2342 Anim.Free();
2343 end;
2344 end
2345 else
2346 begin // Âçðûâ Ðàêåòû
2347 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
2348 begin
2349 Anim := TAnimation.Create(TextureID, False, 6);
2350 Anim.Blending := False;
2351 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2352 Anim.Free();
2353 end;
2354 end;
2355 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
2356 end;
2357 end;
2359 WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
2360 begin
2361 if ShotType = WEAPON_PLASMA then
2362 s := 'FRAMES_EXPLODE_PLASMA'
2363 else
2364 s := 'FRAMES_EXPLODE_BSPFIRE';
2366 if g_Frames_Get(TextureID, s) and loud then
2367 begin
2368 Anim := TAnimation.Create(TextureID, False, 3);
2369 Anim.Blending := False;
2370 g_GFX_OnceAnim(cx-16, cy-16, Anim);
2371 Anim.Free();
2373 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
2374 end;
2375 end;
2377 WEAPON_BFG: // BFG
2378 begin
2379 // Âçðûâ BFG:
2380 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
2381 begin
2382 Anim := TAnimation.Create(TextureID, False, 6);
2383 Anim.Blending := False;
2384 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2385 Anim.Free();
2387 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
2388 end;
2389 end;
2391 WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
2392 begin
2393 if ShotType = WEAPON_IMP_FIRE then
2394 s := 'FRAMES_EXPLODE_IMPFIRE'
2395 else
2396 if ShotType = WEAPON_CACO_FIRE then
2397 s := 'FRAMES_EXPLODE_CACOFIRE'
2398 else
2399 s := 'FRAMES_EXPLODE_BARONFIRE';
2401 if g_Frames_Get(TextureID, s) and Loud then
2402 begin
2403 Anim := TAnimation.Create(TextureID, False, 6);
2404 Anim.Blending := False;
2405 g_GFX_OnceAnim(cx-32, cy-32, Anim);
2406 Anim.Free();
2408 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2409 end;
2410 end;
2412 WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
2413 begin
2414 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
2415 begin
2416 Anim := TAnimation.Create(TextureID, False, 6);
2417 Anim.Blending := False;
2418 g_GFX_OnceAnim(cx-64, cy-64, Anim);
2419 Anim.Free();
2421 g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
2422 end;
2423 end;
2424 end; // case ShotType of...
2426 ShotType := 0;
2427 Animation.Free();
2428 end;
2429 end;
2431 end.