summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44bf4b6)
raw | patch | inline | side by side (parent: 44bf4b6)
author | Stas'M <x86corez@gmail.com> | |
Mon, 24 Sep 2018 12:34:59 +0000 (15:34 +0300) | ||
committer | Stas'M <x86corez@gmail.com> | |
Mon, 24 Sep 2018 12:36:19 +0000 (15:36 +0300) |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 1a10f7b8ebba0a78fa964b8100dca3bd6fe3d191..6cc70f53c4a8c1fd232eb57d68721f364fae4214 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure doDamage (v: Integer);
+ function followCorpse(): Boolean;
+
public
FDamageBuffer: Integer;
PGib = ^TGib;
TGib = record
- alive: Boolean;
+ alive: Boolean;
ID: DWORD;
MaskID: DWORD;
RAngle: Integer;
FDamage: Byte;
FColor: TRGB;
FObj: TObj;
+ FPlayerUID: Word;
FAnimation: TAnimation;
FAnimationMask: TAnimation;
gCorpses[find_id].FColor := FModel.Color;
gCorpses[find_id].FObj.Vel := FObj.Vel;
gCorpses[find_id].FObj.Accel := FObj.Accel;
+ gCorpses[find_id].FPlayerUID := FUID;
end
else
g_Player_CreateGibs(FObj.X + PLAYER_RECT_CX,
Result := 1;
end;
+function TPlayer.followCorpse(): Boolean;
+var
+ i: Integer;
+begin
+ Result := False;
+ if FAlive or FSpectator then
+ Exit;
+ if (gCorpses = nil) or (Length(gCorpses) = 0) then
+ Exit;
+ if gCorpses <> nil then
+ for i := 0 to High(gCorpses) do
+ if gCorpses[i] <> nil 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;
+ break;
+ end;
+end;
+
procedure TPlayer.Update();
var
b: Byte;
if FPhysics then
begin
- g_Obj_Move(@FObj, True, True, True);
+ if not followCorpse() then
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end;
if FPhysics then
begin
- g_Obj_Move(@FObj, True, True, True);
+ if not followCorpse() then
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end
else
utils.writeInt(st, Byte(FColor.B));
// Îáúåêò òðóïà
Obj_SaveState(st, @FObj);
+ utils.writeInt(st, Word(FPlayerUID));
// Åñòü ëè àíèìàöèÿ
anim := (FAnimation <> nil);
utils.writeBool(st, anim);
FColor.B := utils.readByte(st);
// Îáúåêò òðóïà
Obj_LoadState(@FObj, st);
+ FPlayerUID := utils.readWord(st);
// Åñòü ëè àíèìàöèÿ
anim := utils.readBool(st);
// Åñëè åñòü - çàãðóæàåì