Skip to content

Commit

Permalink
set forwardmove & sidemove on replay bots because why not
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Sep 16, 2022
1 parent fdbbc11 commit b115726
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/include/shavit/replay-file.inc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum struct frame_cache_t
}

// Can be used to unpack frame_t.mousexy and frame_t.vel
stock void UnpackSignedShorts(int x, int out[2])
stock void UnpackSignedShorts(int x, int[] out)
{
out[0] = ((x & 0xFFFF) ^ 0x8000) - 0x8000;
out[1] = (((x >> 16) & 0xFFFF) ^ 0x8000) - 0x8000;
Expand Down
17 changes: 17 additions & 0 deletions addons/sourcemod/scripting/shavit-replay-playback.sp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ bot_info_t gA_BotInfo_Temp; // cached when creating a bot so we can use an accur
int gI_LastReplayFlags[MAXPLAYERS + 1];
float gF_EyeOffset;
float gF_EyeOffsetDuck;
float gF_MaxMove = 400.0;

// how do i call this
bool gB_HideNameChange = false;
Expand Down Expand Up @@ -379,6 +380,7 @@ public void OnPluginStart()
{
gF_EyeOffset = 64.0;
gF_EyeOffsetDuck = 46.0;
gF_MaxMove = 450.0;
}
case Engine_CSS:
{
Expand Down Expand Up @@ -2644,6 +2646,21 @@ Action ReplayOnPlayerRunCmd(bot_info_t info, int &buttons, int &impulse, float v
}
}

if (info.aCache.iReplayVersion >= 0x06)
{
int ivel[2];
UnpackSignedShorts(aFrame.vel, ivel);
vel[0] = float(ivel[0]);
vel[1] = float(ivel[1]);
}
else
{
if (buttons & IN_FORWARD) vel[0] += gF_MaxMove;
if (buttons & IN_BACK) vel[0] -= gF_MaxMove;
if (buttons & IN_MOVELEFT) vel[1] -= gF_MaxMove;
if (buttons & IN_MOVERIGHT) vel[1] += gF_MaxMove;
}

if (isClient)
{
gI_LastReplayFlags[info.iEnt] = aFrame.flags;
Expand Down

2 comments on commit b115726

@lilac1337
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😈

@rtldg
Copy link
Collaborator Author

@rtldg rtldg commented on b115726 Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😈

Please sign in to comment.