diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas
index 44cef05922d1b9b9303e8e4156271538b210faf4..8fdde869c0bcda1b9a175a3805bc0c2bc528be53 100644 (file)
--- a/src/game/g_weapons.pas
+++ b/src/game/g_weapons.pas
uses
SysUtils, Classes, mempool,
- g_textures, g_basic, g_phys, xprofiler;
+ g_basic, g_phys, xprofiler;
type
SpawnerUID: Word;
Triggers: DWArray;
Obj: TObj;
- Animation: TAnimationState;
+ time: LongWord;
Timeout: DWORD;
Stopped: Byte;
WEAPON_BARON_FIRE = 24;
WEAPON_MANCUB_FIRE = 25;
WEAPON_SKEL_FIRE = 26;
+ WEAPON_LAST = WEAPON_SKEL_FIRE;
WP_FIRST = WEAPON_KASTET;
WP_LAST = WEAPON_FLAMETHROWER;
{$IFDEF ENABLE_GIBS}
g_gibs,
{$ENDIF}
+ {$IFDEF ENABLE_CORPSES}
+ g_corpses,
+ {$ENDIF}
Math, g_map, g_player, g_sound, g_panel,
g_console, g_options, g_game,
g_triggers, MAPDEF, e_log, g_monsters, g_saveload,
begin
//g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255);
- h := High(gCorpses);
-
- if gAdvCorpses and (h <> -1) then
- for i := 0 to h do
- if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
- with gCorpses[i] do
- if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
- Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
- g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
- Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
+ {$IFDEF ENABLE_CORPSES}
+ h := High(gCorpses);
+ if gAdvCorpses and (h <> -1) then
+ begin
+ for i := 0 to h do
+ begin
+ if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
+ begin
+ with gCorpses[i] do
begin
- Damage(50, SpawnerUID, 0, 0);
- g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
- Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2));
+ if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
+ Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and
+ g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2),
+ Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then
+ begin
+ Damage(50, SpawnerUID, 0, 0);
+ g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2));
+ end;
end;
+ end;
+ end;
+ end;
+ {$ENDIF}
st := TEAM_NONE;
pl := g_Player_Get(SpawnerUID);
SetLength(Shots, find_id + 64)
end;
+ shots[find_id].time := gTime;
+
case ShotType of
WEAPON_ROCKETLAUNCHER:
begin
Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH;
Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT;
- Animation := nil;
Triggers := nil;
ShotType := WEAPON_ROCKETLAUNCHER;
end;
Triggers := nil;
ShotType := WEAPON_PLASMA;
- Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BFG;
- Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_FLAMETHROWER;
- // Animation := TAnimationState.Create(True, 6, 0); // drawed as gfx
end;
end;
Triggers := nil;
ShotType := WEAPON_IMP_FIRE;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_CACO_FIRE;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_MANCUB_FIRE;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BARON_FIRE;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BSP_FIRE;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_SKEL_FIRE;
target := TargetUID;
- Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
end;
end;
end;
function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte;
-var
- i, h: Integer;
+ {$IFDEF ENABLE_CORPSES}
+ var i: Integer;
+ {$ENDIF}
+ var h: Integer;
function PlayerHit(Team: Byte = 0): Boolean;
var
begin
Result := 0;
- if HitCorpses then
- begin
- h := High(gCorpses);
-
- if gAdvCorpses and (h <> -1) then
- for i := 0 to h do
- if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
- g_Obj_Collide(obj, @gCorpses[i].Obj) then
+ {$IFDEF ENABLE_CORPSES}
+ if HitCorpses then
+ begin
+ h := High(gCorpses);
+ if gAdvCorpses and (h <> -1) then
+ begin
+ for i := 0 to h do
begin
- // Ðàñïèëèâàåì òðóï:
- gCorpses[i].Damage(d, SpawnerUID, (obj^.Vel.X+obj^.Accel.X) div 4,
- (obj^.Vel.Y+obj^.Accel.Y) div 4);
- Result := 1;
+ if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and
+ g_Obj_Collide(obj, @gCorpses[i].Obj) then
+ begin
+ // Ðàñïèëèâàåì òðóï:
+ gCorpses[i].Damage(d, SpawnerUID, (obj^.Vel.X+obj^.Accel.X) div 4,
+ (obj^.Vel.Y+obj^.Accel.Y) div 4);
+ Result := 1;
+ end;
end;
- end;
+ end;
+ end;
+ {$ENDIF}
case gGameSettings.GameMode of
// Êàìïàíèÿ:
end;
end;
- var i, h, dx, dy, m, mm: Integer;
+ var i, h, dx, dy, mm: Integer;
{$IFDEF ENABLE_GIBS}
var _angle: SmallInt;
{$ENDIF}
+ {$IF DEFINED(ENABLE_GIBS) OR DEFINED(ENABLE_CORPSES)}
+ var m: Integer;
+ {$ENDIF}
begin
result := false;
//g_Mons_ForEach(monsExCheck);
g_Mons_ForEachAt(X-(rad+32), Y-(rad+32), (rad+32)*2, (rad+32)*2, monsExCheck);
- h := High(gCorpses);
-
- if gAdvCorpses and (h <> -1) then
- for i := 0 to h do
- if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
- with gCorpses[i] do
+ {$IFDEF ENABLE_CORPSES}
+ h := High(gCorpses);
+ if gAdvCorpses and (h <> -1) then
+ begin
+ for i := 0 to h do
+ begin
+ if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then
begin
- dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
- dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
-
- if dx > 1000 then dx := 1000;
- if dy > 1000 then dy := 1000;
-
- if dx*dx+dy*dy < r then
+ with gCorpses[i] do
begin
- m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y,
- Obj.Rect.Width, Obj.Rect.Height);
-
- mm := Max(abs(dx), abs(dy));
- if mm = 0 then mm := 1;
-
- Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm);
+ dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X;
+ dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y;
+ if dx > 1000 then dx := 1000;
+ if dy > 1000 then dy := 1000;
+ if dx*dx+dy*dy < r then
+ begin
+ m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height);
+ mm := Max(abs(dx), abs(dy));
+ if mm = 0 then
+ mm := 1;
+ Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm);
+ end;
end;
end;
+ end;
+ end;
+ {$ENDIF}
{$IFDEF ENABLE_GIBS}
h := High(gGibs);
end;
procedure g_Weapon_Free();
-var
- i: Integer;
begin
- if Shots <> nil then
- begin
- for i := 0 to High(Shots) do
- if Shots[i].ShotType <> 0 then
- Shots[i].Animation.Free();
-
- Shots := nil;
- end;
-
+ Shots := nil;
WaterMap := nil;
end;
ShotType := WEAPON_ROCKETLAUNCHER;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12);
- Animation := nil;
triggers := nil;
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
triggers := nil;
target := TargetUID;
- Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := nil;
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
-
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
-
- Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
+ time := gTime;
end;
Shots[find_id].SpawnerUID := SpawnerUID;
end;
end;
- // Àíèìàöèÿ ñíàðÿäà:
- if Animation <> nil then
- Animation.Update();
-
// Äâèæåíèå:
spl := (ShotType <> WEAPON_PLASMA) and
(ShotType <> WEAPON_BFG) and
begin
// Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë.
ShotType := 0;
- Animation.Free();
+ time := 0;
Continue;
end;
begin
if gGameSettings.GameType = GT_SERVER then
MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud);
- if Animation <> nil then
- begin
- Animation.Free();
- Animation := nil;
- end;
+ time := 0;
end
else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then
if gGameSettings.GameType = GT_SERVER then
// Êîñòûëèíà åáàíàÿ
Shots[i].Stopped := utils.readByte(st);
- // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
- Shots[i].Animation := nil;
-
- case Shots[i].ShotType of
- WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
- begin
- end;
- WEAPON_PLASMA:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
- end;
- WEAPON_BFG:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
- end;
- WEAPON_IMP_FIRE:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
- end;
- WEAPON_BSP_FIRE:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
- end;
- WEAPON_CACO_FIRE:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
- end;
- WEAPON_BARON_FIRE:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
- end;
- WEAPON_MANCUB_FIRE:
- begin
- Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
- end;
- end;
+ Shots[i].time := gTime; // TODO save time?
end;
end;
end; // case ShotType of...
ShotType := 0;
- Animation.Free();
end;
end;