diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 0ee9365f2adbee0cf6183a774a83500781d6ea23..04719fccc88dca671b0e98a9838a388f55d7170f 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
{$INCLUDE ../shared/a_modes.inc}
+{$M+}
unit g_player;
interface
uses
e_graphics, g_playermodel, g_basic, g_textures,
- g_weapons, g_phys, g_sound, g_saveload, MAPSTRUCT,
+ g_weapons, g_phys, g_sound, g_saveload, MAPDEF,
BinEditor, g_panel;
const
FDummy: Boolean;
FFireTime: Integer;
+ // debug: viewport offset
+ viewPortX, viewPortY, viewPortW, viewPortH: Integer;
+
+ function isValidViewPort (): Boolean; inline;
+
constructor Create(); virtual;
destructor Destroy(); override;
procedure Respawn(Silent: Boolean; Force: Boolean = False); virtual;
//WARNING! this does nothing for now, but still call it!
procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
+ procedure getMapBox (out x, y, w, h: Integer); inline;
+
+ public
+ property Vel: TPoint2i read FObj.Vel;
+ property Obj: TObj read FObj;
+
+ published
property Name: String read FName write FName;
property Model: TPlayerModel read FModel;
property Health: Integer read FHealth write FHealth;
property GameVelY: Integer read FObj.Vel.Y write FObj.Vel.Y;
property GameAccelX: Integer read FObj.Accel.X write FObj.Accel.X;
property GameAccelY: Integer read FObj.Accel.Y write FObj.Accel.Y;
- property Vel: TPoint2i read FObj.Vel;
- property Obj: TObj read FObj;
property IncCam: Integer read FIncCam write FIncCam;
property UID: Word read FUID write FUID;
property JustTeleported: Boolean read FJustTeleported write FJustTeleported;
uses
e_log, g_map, g_items, g_console, SysUtils, g_gfx, Math,
- g_options, g_triggers, g_menu, MAPDEF, g_game,
- wadreader, g_main, g_monsters, CONFIG, g_language, g_net, g_netmsg;
+ g_options, g_triggers, g_menu, g_game, g_grid,
+ wadreader, g_main, g_monsters, CONFIG, g_language,
+ g_net, g_netmsg, g_window, GL, g_holmes;
type
TBotProfile = record
ANGLE_LEFTUP = 125;
ANGLE_LEFTDOWN = -145;
PLAYER_HEADRECT: TRectWH = (X:24; Y:12; Width:20; Height:12);
- WEAPONPOINT: Array [TDirection] of TPoint = ((X:16; Y:32), (X:47; Y:32));
+ WEAPONPOINT: Array [TDirection] of TDFPoint = ((X:16; Y:32), (X:47; Y:32));
BOT_MAXJUMP = 84;
BOT_LONGDIST = 300;
BOT_UNSAFEDIST = 128;
procedure g_Player_DrawCorpses();
var
i: Integer;
- a: TPoint;
+ a: TDFPoint;
begin
if gGibs <> nil then
for i := 0 to High(gGibs) do
procedure g_Player_DrawShells();
var
i: Integer;
- a: TPoint;
+ a: TDFPoint;
begin
if gShells <> nil then
for i := 0 to High(gShells) do
{ T P l a y e r : }
+function TPlayer.isValidViewPort (): Boolean; inline; begin result := (viewPortW > 0) and (viewPortH > 0); end;
+
procedure TPlayer.BFGHit();
begin
g_Weapon_BFGHit(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
constructor TPlayer.Create();
begin
+ viewPortX := 0;
+ viewPortY := 0;
+ viewPortW := 0;
+ viewPortH := 0;
+
FIamBot := False;
FDummy := False;
FSpawned := False;
e_GetTextureSize(ID, @w, @h);
if FDirection = D_LEFT then
e_Draw(ID, FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-(w div 2)+4,
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7, 0, True, False)
+ FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7+FObj.slopeUpLeft, 0, True, False)
else
e_Draw(ID, FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-(w div 2)-2,
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7, 0, True, False);
+ FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7+FObj.slopeUpLeft, 0, True, False);
end;
if FMegaRulez[MR_INVIS] > gTime then
else
dr := True;
if dr then
- FModel.Draw(FObj.X, FObj.Y, 200)
+ FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft, 200)
else
- FModel.Draw(FObj.X, FObj.Y);
+ FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft);
end
else
- FModel.Draw(FObj.X, FObj.Y, 254);
+ FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft, 254);
end
else
- FModel.Draw(FObj.X, FObj.Y);
+ FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft);
end;
if g_debug_Frames then
DrawAim();
end;
+
procedure TPlayer.DrawAim();
+ procedure drawCast (sz: Integer; ax0, ay0, ax1, ay1: Integer);
+ var
+ ex, ey: Integer;
+ begin
+ if isValidViewPort and (self = gPlayer1) then
+ begin
+ g_Holmes_plrLaser(ax0, ay0, ax1, ay1);
+ end;
+
+ e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96);
+ if (g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) <> nil) then
+ begin
+ e_DrawLine(sz, ax0, ay0, ex, ey, 0, 255, 0, 96);
+ end
+ else
+ begin
+ e_DrawLine(sz, ax0, ay0, ex, ey, 0, 0, 255, 96);
+ end;
+ end;
+
var
wx, wy, xx, yy: Integer;
angle: SmallInt;
end;
xx := Trunc(Cos(-DegToRad(angle)) * len) + wx;
yy := Trunc(Sin(-DegToRad(angle)) * len) + wy;
+ {$IF DEFINED(D2F_DEBUG)}
+ drawCast(sz, wx, wy, xx, yy);
+ {$ELSE}
e_DrawLine(sz, wx, wy, xx, yy, 255, 0, 0, 96);
+ {$ENDIF}
end;
procedure TPlayer.DrawGUI();
id: DWORD;
begin
id := g_Items_Create(FObj.X, FObj.Y, t, True, False);
- it := g_ItemByIdx(id);
+ it := g_Items_ByIdx(id);
if KillType = K_EXTRAHARDKILL then // -7..+7; -8..0
begin
g_Obj_Push(@it.Obj, (FObj.Vel.X div 2)-7+Random(15),
end
else if g_GetUIDType(SpawnerUID) = UID_MONSTER then
begin // Óáèò ìîíñòðîì
- mon := g_Monsters_Get(SpawnerUID);
+ mon := g_Monsters_ByUID(SpawnerUID);
if mon = nil then
s := '?'
else
DecMin(FPain, 5, 0);
DecMin(FPickup, 1, 0);
- if FLive and (FObj.Y > gMapInfo.Height+128) and AnyServer then
+ if FLive and (FObj.Y > Integer(gMapInfo.Height)+128) and AnyServer then
begin
// Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
FMegaRulez[MR_SUIT] := 0;
if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
end;
+procedure TPlayer.getMapBox (out x, y, w, h: Integer); inline;
+begin
+ x := FObj.X+PLAYER_RECT.X;
+ y := FObj.Y+PLAYER_RECT.Y;
+ w := PLAYER_RECT.Width;
+ h := PLAYER_RECT.Height;
+end;
+
function TPlayer.Collide(X, Y: Integer; Width, Height: Word): Boolean;
begin
Result := g_Collide(FObj.X+PLAYER_RECT.X,
mon: TMonster;
pla, tpla: TPlayer;
vsPlayer, vsMonster, ok: Boolean;
+
+
+ function monsUpdate (mon: TMonster): Boolean;
+ begin
+ result := false; // don't stop
+ if mon.Live and (mon.MonsterType <> MONSTER_BARREL) then
+ begin
+ if not TargetOnScreen(mon.Obj.X+mon.Obj.Rect.X, mon.Obj.Y+mon.Obj.Rect.Y) then exit;
+
+ x2 := mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2);
+ y2 := mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2);
+
+ // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
+ if g_TraceVector(x1, y1, x2, y2) then
+ begin
+ // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
+ SetLength(targets, Length(targets)+1);
+ with targets[High(targets)] do
+ begin
+ UID := mon.UID;
+ X := mon.Obj.X;
+ Y := mon.Obj.Y;
+ cX := x2;
+ cY := y2;
+ Rect := mon.Obj.Rect;
+ Dist := g_PatchLength(x1, y1, x2, y2);
+ Line := (y1+4 < Target.Y + mon.Obj.Rect.Y + mon.Obj.Rect.Height) and
+ (y1-4 > Target.Y + mon.Obj.Rect.Y);
+ Visible := True;
+ IsPlayer := False;
+ end;
+ end;
+ end;
+ end;
+
begin
vsPlayer := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER);
vsMonster := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER);
if (g_GetUIDType(Target.UID) = UID_MONSTER) and
vsMonster then
begin // Ìîíñòð
- mon := g_Monsters_Get(Target.UID);
+ mon := g_Monsters_ByUID(Target.UID);
if mon <> nil then
begin
Target.X := mon.Obj.X;
end;
// Ìîíñòðû:
- if vsMonster and (gMonsters <> nil) then
- for a := 0 to High(gMonsters) do
- if (gMonsters[a] <> nil) and (gMonsters[a].Live) and
- (gMonsters[a].MonsterType <> MONSTER_BARREL) then
- begin
- mon := gMonsters[a];
-
- if not TargetOnScreen(mon.Obj.X + mon.Obj.Rect.X,
- mon.Obj.Y + mon.Obj.Rect.Y) then
- Continue;
-
- x2 := mon.Obj.X + mon.Obj.Rect.X + (mon.Obj.Rect.Width div 2);
- y2 := mon.Obj.Y + mon.Obj.Rect.Y + (mon.Obj.Rect.Height div 2);
-
- // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé:
- if g_TraceVector(x1, y1, x2, y2) then
- begin
- // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
- SetLength(targets, Length(targets)+1);
- with targets[High(targets)] do
- begin
- UID := mon.UID;
- X := mon.Obj.X;
- Y := mon.Obj.Y;
- cX := x2;
- cY := y2;
- Rect := mon.Obj.Rect;
- Dist := g_PatchLength(x1, y1, x2, y2);
- Line := (y1+4 < Target.Y + mon.Obj.Rect.Y + mon.Obj.Rect.Height) and
- (y1-4 > Target.Y + mon.Obj.Rect.Y);
- Visible := True;
- IsPlayer := False;
- end;
- end;
- end;
+ if vsMonster then g_Mons_ForEach(monsUpdate);
end;
// Åñëè åñòü âîçìîæíûå öåëè:
end
else
begin // Öåëü - ìîíñòð
- mon := g_Monsters_Get(Target.UID);
+ mon := g_Monsters_ByUID(Target.UID);
if (mon = nil) or (not mon.Live) then
Target.UID := 0; // òî çàáûòü öåëü
end;
if (g_GetUIDType(FLastSpawnerUID) = UID_MONSTER) and
LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER) then
begin // Ìîíñòð
- mon := g_Monsters_Get(FLastSpawnerUID);
+ mon := g_Monsters_ByUID(FLastSpawnerUID);
ok := not TargetOnScreen(mon.Obj.X + mon.Obj.Rect.X,
mon.Obj.Y + mon.Obj.Rect.Y);
end;