summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 458ad9b)
raw | patch | inline | side by side (parent: 458ad9b)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 11 Mar 2020 20:37:32 +0000 (23:37 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 11 Mar 2020 20:37:32 +0000 (23:37 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index e3d9b7bb2bed0c13288230a0e9be989c17656068..981082d949b8aa4b5766dc98757319001b108dda 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
e_input, e_log, g_console, g_items, g_map, g_panel,
g_playermodel, g_gfx, g_options, Math,
g_triggers, g_monsters, e_sound, CONFIG,
- g_language, g_net, g_main,
+ g_language, g_net, g_main, g_phys,
ENet, e_msg, g_netmsg, g_netmaster,
sfs, wadreader, g_system;
procedure DrawPlayer(p: TPlayer);
var
px, py, a, b, c, d, i, fX, fY: Integer;
+ camObj: TObj;
//R: TRect;
begin
if (p = nil) or (p.FDummy) then
glPushMatrix();
- p.Obj.lerp(gLerpFactor, fX, fY);
+ camObj := p.getCameraObj();
+ camObj.lerp(gLerpFactor, fX, fY);
px := fX + PLAYER_RECT_CX;
- py := fY + PLAYER_RECT_CY+nlerp(p.SlopeOld, p.Obj.slopeUpLeft, gLerpFactor);
+ py := fY + PLAYER_RECT_CY+nlerp(p.SlopeOld, camObj.slopeUpLeft, gLerpFactor);
if (g_dbg_scale = 1.0) and (not g_dbg_ignore_bounds) then
begin
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 8f84ed9d7328db4c512b6834993235cefa6e7e66..85b8e1537ad9024686d09be58f5ad61914968249 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure doDamage (v: Integer);
- function followCorpse(): Boolean;
+ function refreshCorpse(): Boolean;
public
FDamageBuffer: Integer;
FSpawnInvul: Integer;
FHandicap: Integer;
FWaitForFirstSpawn: Boolean; // set to `true` in server, used to spawn a player on first full state request
+ FCorpse: Integer;
// debug: viewport offset
viewPortX, viewPortY, viewPortW, viewPortH: Integer;
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
+ function getCameraObj(): TObj;
+
public
property Vel: TPoint2i read FObj.Vel;
property Obj: TObj read FObj;
function g_Player_GetCount(): Byte;
function g_Player_GetStats(): TPlayerStatArray;
function g_Player_ValidName(Name: String): Boolean;
-procedure g_Player_CreateCorpse(Player: TPlayer);
+function g_Player_CreateCorpse(Player: TPlayer): Integer;
procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: String; fColor: TRGB);
procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
procedure g_Player_UpdatePhysicalObjects();
end;
end;
-procedure g_Player_CreateCorpse(Player: TPlayer);
+function g_Player_CreateCorpse(Player: TPlayer): Integer;
var
i: Integer;
find_id: DWORD;
ok: Boolean;
begin
+ Result := -1;
+
if Player.alive then
Exit;
// Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- if gCorpses[i].FPlayerUID = Player.FUID then
- gCorpses[i].FPlayerUID := 0;
+ i := Player.FCorpse;
+ if (i >= 0) and (i < Length(gCorpses)) then
+ begin
+ if (gCorpses[i] <> nil) and (gCorpses[i].FPlayerUID = Player.FUID) then
+ gCorpses[i].FPlayerUID := 0;
+ end;
if Player.FObj.Y >= gMapInfo.Height+128 then
Exit;
gCorpses[find_id].FObj.Vel := FObj.Vel;
gCorpses[find_id].FObj.Accel := FObj.Accel;
gCorpses[find_id].FPlayerUID := FUID;
+
+ Result := find_id;
end
else
g_Player_CreateGibs(FObj.X + PLAYER_RECT_CX,
FFirePainTime := 0;
FFireAttacker := 0;
FHandicap := 100;
+ FCorpse := -1;
FActualModelName := 'doomer';
DropFlag(KillType = K_FALLKILL);
end;
- g_Player_CreateCorpse(Self);
+ FCorpse := g_Player_CreateCorpse(Self);
if Srv and (gGameSettings.MaxLives > 0) and FNoRespawn and
(gLMSRespawn = LMS_RESPAWN_NONE) then
FDeath := 0;
FSecrets := 0;
FSpawnInvul := 0;
+ FCorpse := -1;
FReady := False;
if FNoRespawn then
begin
FPain := 0;
FLastHit := 0;
FSpawnInvul := 0;
+ FCorpse := -1;
if not g_Game_IsServer then
Exit;
FPhysics := False;
FWantsInGame := False;
FSpawned := False;
+ FCorpse := -1;
if FNoRespawn then
begin
Result := 1;
end;
-function TPlayer.followCorpse(): Boolean;
+function TPlayer.refreshCorpse(): Boolean;
var
i: Integer;
begin
Result := False;
+ FCorpse := -1;
if FAlive or FSpectator then
Exit;
if (gCorpses = nil) or (Length(gCorpses) = 0) then
if gCorpses[i].FPlayerUID = FUID then
begin
Result := True;
- FObj.X := gCorpses[i].FObj.X;
- FObj.Y := gCorpses[i].FObj.Y;
- FObj.Vel.X := gCorpses[i].FObj.Vel.X;
- FObj.Vel.Y := gCorpses[i].FObj.Vel.Y;
- FObj.Accel.X := gCorpses[i].FObj.Accel.X;
- FObj.Accel.Y := gCorpses[i].FObj.Accel.Y;
+ FCorpse := i;
break;
end;
end;
+function TPlayer.getCameraObj(): TObj;
+begin
+ if (not FAlive) and (not FSpectator) and
+ (FCorpse >= 0) and (FCorpse < Length(gCorpses)) and
+ (gCorpses[FCorpse] <> nil) and (gCorpses[FCorpse].FPlayerUID = FUID) then
+ begin
+ gCorpses[FCorpse].FObj.slopeUpLeft := FObj.slopeUpLeft;
+ Result := gCorpses[FCorpse].FObj;
+ end
+ else
+ begin
+ Result := FObj;
+ end;
+end;
+
procedure TPlayer.PreUpdate();
begin
FSlopeOld := FObj.slopeUpLeft;
if FPhysics then
begin
- if not followCorpse() then
- g_Obj_Move(@FObj, True, True, True);
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end;
if FPhysics then
begin
- if not followCorpse() then
- g_Obj_Move(@FObj, True, True, True);
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end
else