Garry's Mod Leaks
[Source] SlowMotion
Submitted by lorena, 28-05-2019, 12:42 PM, Thread ID: 131711
Thread Closed
Hello everyone im show you the way how you can achieve SlowMotion effect by abusing CBasePlayer:hysicsSimulate function.
you can notice when player lags out he still move in one direction - this are happens due to lines 156-159 and this can be useful to achieve this effect. So you can make server don't process your user commands until this check are passed.
This can be achived by two ways: by not sending CLC_Move <0.5 sec or sending only m_nBackupCommands in CLC_Move message <0.5 sec (also when checks are passed you can achive 0.5 sec tickbase shift and keep moving normaly because when you not sending new commands , backup commands are override m_LastCmd)
here is implementation:
m_nChokedPackets should be zero because this will cause m_LastCmd\m_nBackupCommands to be processed.
already notice this can be used to make fakelag more than 15 ticks by suppresing messages to be sending and afterwards sending multiple CLC_Move messages to be processed (this method is not reliable due to here is not garanti that thouse messages will be processed in one server frame).
the scale of slow motion are correlated with server tickrate - than more tickrate ->less tick interval -> less movement per tick.
you can notice when player lags out he still move in one direction - this are happens due to lines 156-159 and this can be useful to achieve this effect. So you can make server don't process your user commands until this check are passed.
This can be achived by two ways: by not sending CLC_Move <0.5 sec or sending only m_nBackupCommands in CLC_Move message <0.5 sec (also when checks are passed you can achive 0.5 sec tickbase shift and keep moving normaly because when you not sending new commands , backup commands are override m_LastCmd)
here is implementation:
Code:
void CL_SendMove_backup_move(void)
{
byte data[MAX_CMD_BUFFER];
int nextcommandnr = g_pClientState->lastoutgoingcommand + g_pClientState->chokedcommands + 1;
// send the client update packet
CLC_Move moveMsg;
moveMsg.m_DataOut.StartWriting(data, sizeof(data));
// Determine number of backup commands to send along
int cl_cmdbackup = 2;
moveMsg.m_nBackupCommands = clamp(cl_cmdbackup, 0, MAX_BACKUP_COMMANDS);
// How many real new commands have queued up
moveMsg.m_nNewCommands = 0;
moveMsg.m_nNewCommands = clamp(moveMsg.m_nNewCommands, 0, MAX_NEW_COMMANDS);
int numcmds = moveMsg.m_nNewCommands + moveMsg.m_nBackupCommands;
int from = -1;// first command is deltaed against zeros
bool bOK = true;
for (int to = nextcommandnr - numcmds + 1; to <= nextcommandnr; to++)
{
bool isnewcmd = to >= (nextcommandnr - moveMsg.m_nNewCommands + 1);
// first valid command number is 1
bOK = bOK && WriteUsercmdDeltaToBuffer(&moveMsg.m_DataOut, from, to, nextcommandnr, isnewcmd);//23
from = to;
}
if (bOK)
{
moveMsg.m_nLength = moveMsg.m_DataOut.GetNumBitsWritten();
// only write message if all usercmds were written correctly, otherwise parsing would fail
o_SendNetMsg(g_pEngine->GetNetChannelInfo(), NULL, moveMsg, false, false);
}
}
bool __fastcall hkSendNetMsg(CNetChan* netchan, void*edx, INetMessage &msg, bool bForceReliable, bool bVoice)
{
if (strcmp("clc_Move", msg.GetName()) == 0) {
if (Engine::Var::Instance().Slow_Motion.Get()) {
static int SlowMoCount = 0;
if (GUI::KeyPressed(Engine::Var::Instance().Slow_Motion_Key.Get()) ) {
if (SlowMoCount < TIME_TO_TICKS(Engine::Var::Instance().Slow_Motion_Scale.Get())) {
CL_SendMove_backup_move();
SlowMoCount++;
}
else {
SlowMoCount = 0;
CL_SendMove();
}
}
else {
SlowMoCount = 0;
CL_SendMove();
}
}
else {
CL_SendMove();
}
return true;
}
return o_SendNetMsg(netchan, edx, msg, bForceReliable, bVoice);
}
m_nChokedPackets should be zero because this will cause m_LastCmd\m_nBackupCommands to be processed.
already notice this can be used to make fakelag more than 15 ticks by suppresing messages to be sending and afterwards sending multiple CLC_Move messages to be processed (this method is not reliable due to here is not garanti that thouse messages will be processed in one server frame).
the scale of slow motion are correlated with server tickrate - than more tickrate ->less tick interval -> less movement per tick.
Users browsing this thread: 1 Guest(s)