Skip to content

Commit

Permalink
autosave lock player in place (I hope Jesus will be happy now)
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed Sep 10, 2023
1 parent 112c0ae commit 2044021
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion DXRModules/DeusEx/Classes/DXRAutosave.uc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var config float save_delay;
var transient float save_timer;
var transient int autosave_combat;

var vector player_pos;
var rotator player_rot;
var bool set_player_pos;

const Disabled = 0;
const FirstEntry = 1;
const EveryEntry = 2;
Expand Down Expand Up @@ -55,8 +59,13 @@ function NeedSave()
bNeedSave = true;
save_timer = save_delay;
Enable('Tick');
if(autosave_combat>0 || !PawnIsInCombat(player()))
if(autosave_combat>0 || !PawnIsInCombat(player())) {
autosave_combat = 1;// we're all in on this autosave because of the player rotation
player_pos = player().Location;
player_rot = player().ViewRotation;
set_player_pos = true;
SetGameSpeed(0);
}
}

function SetGameSpeed(float s)
Expand All @@ -78,11 +87,20 @@ function SetGameSpeed(float s)
}
}

function FixPos()
{
if(set_player_pos) {
player().SetLocation(player_pos);
player().ViewRotation = player_rot;
}
}

function Tick(float delta)
{
delta /= Level.Game.GameSpeed;
delta = FClamp(delta, 0.01, 0.05);// a single slow frame should not expire the timer by itself
save_timer -= delta;
FixPos();
if(bNeedSave) {
if(save_timer <= 0) {
doAutosave();
Expand Down

0 comments on commit 2044021

Please sign in to comment.