2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
int SlowMotion::Delay = 0;
|
|
|
|
|
2021-08-15 20:01:21 -04:00
|
|
|
void SlowMotion::ApplySlowMotion(int timePassed)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
|
|
|
if (SlowMotion::Delay <= 0)
|
|
|
|
{
|
2021-08-15 20:01:21 -04:00
|
|
|
Utils::Hook::Call<void(int)>(0x60B2D0)(timePassed);
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
else
|
2021-08-15 20:01:21 -04:00
|
|
|
{
|
2017-01-19 16:23:59 -05:00
|
|
|
SlowMotion::Delay -= timePassed;
|
2021-08-15 20:01:21 -04:00
|
|
|
}
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
2021-08-15 20:01:21 -04:00
|
|
|
|
|
|
|
__declspec(naked) void SlowMotion::ApplySlowMotionStub()
|
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
pushad
|
|
|
|
|
2021-08-19 11:28:22 -04:00
|
|
|
push [esp + 24h]
|
2021-08-15 20:01:21 -04:00
|
|
|
call SlowMotion::ApplySlowMotion
|
2021-08-19 05:45:40 -04:00
|
|
|
add esp, 4h
|
2021-08-15 20:01:21 -04:00
|
|
|
|
|
|
|
popad
|
|
|
|
|
|
|
|
retn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
void SlowMotion::SetSlowMotion()
|
|
|
|
{
|
|
|
|
int duration = 1000;
|
|
|
|
float start = Game::Scr_GetFloat(0);
|
|
|
|
float end = 1.0f;
|
|
|
|
|
2021-11-13 08:22:06 -05:00
|
|
|
if (Game::Scr_GetNumParam() >= 2u)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
|
|
|
end = Game::Scr_GetFloat(1);
|
|
|
|
}
|
|
|
|
|
2021-11-13 08:22:06 -05:00
|
|
|
if (Game::Scr_GetNumParam() >= 3u)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
|
|
|
duration = static_cast<int>(Game::Scr_GetFloat(2) * 1000.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int delay = 0;
|
|
|
|
|
|
|
|
if (start > end)
|
|
|
|
{
|
|
|
|
if (duration < 150)
|
|
|
|
{
|
|
|
|
delay = duration;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delay = 150;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
duration = duration - delay;
|
|
|
|
|
|
|
|
Game::Com_SetSlowMotion(start, end, duration);
|
|
|
|
SlowMotion::Delay = delay;
|
|
|
|
|
|
|
|
// set snapshot num to 1 behind (T6 does this, why shouldn't we?)
|
|
|
|
for (int i = 0; i < *Game::svs_numclients; ++i)
|
|
|
|
{
|
2017-02-10 02:24:23 -05:00
|
|
|
Game::svs_clients[i].snapNum = *reinterpret_cast<DWORD*>(0x31D9384) - 1;
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-02 08:41:31 -04:00
|
|
|
void SlowMotion::DrawConnectionInterruptedStub(int /*a1*/)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2021-08-15 20:01:21 -04:00
|
|
|
// if (!*reinterpret_cast<bool*>(0x1AD8ED0) && !*reinterpret_cast<bool*>(0x1AD8EEC) && !*reinterpret_cast<int*>(0x1AD78F8))
|
|
|
|
// {
|
|
|
|
// Utils::Hook::Call<void(int)>(0x454A70)(a1);
|
|
|
|
// }
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
2017-06-29 17:03:57 -04:00
|
|
|
|
|
|
|
SlowMotion::SlowMotion()
|
|
|
|
{
|
|
|
|
SlowMotion::Delay = 0;
|
|
|
|
Utils::Hook(0x5F5FF2, SlowMotion::SetSlowMotion, HOOK_JUMP).install()->quick();
|
|
|
|
Utils::Hook(0x60B38A, SlowMotion::ApplySlowMotionStub, HOOK_CALL).install()->quick();
|
|
|
|
|
|
|
|
Utils::Hook(0x4A54ED, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick();
|
|
|
|
Utils::Hook(0x4A54FB, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick();
|
|
|
|
}
|
2021-08-14 18:10:42 -04:00
|
|
|
}
|