predicted chainsaw state 2/2

unfortunately there's no reliable way due to *::Deploy not being called in certain scenarios but that should serve as good foundation for later improvement.

minor precision loss possibly due to addition being replaced with multiplication (ie. cycle + rate * interval -> ticks * rate * interval)
This commit is contained in:
explorer 2025-01-02 21:10:02 +03:00
parent f5fb3e4d30
commit 519d56c138
3 changed files with 31 additions and 73 deletions

View File

@ -223,18 +223,17 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
}
};
static __int32 Accumulative_Correction; //rem: deviation from clock-corrected tick (not "accumulative correction")
static __int32 Accumulative_Correction;
//rem: extra commands queued with no clock correction applied due to m_PacketDrop induced negation (not "absolute speed")
auto Absolute_Speed = [&]() -> void
auto Disable_Clock_Correction = [&](__int32 Queue) -> void
{
if (Interface_Extra_Commands_Action.Integer > 0)
if (Queue > 0)
{
if (Extended_Command == Initial_Extended_Command)
{
Extended_Command->Extra_Commands = 0;
Extra_Commands = max((__int32)(0.06f / Global_Variables->Interval_Per_Tick + 0.5f), Interface_Extra_Commands_Action.Integer);
Extra_Commands = max((__int32)(0.06f / Global_Variables->Interval_Per_Tick + 0.5f), Queue);
}
else
{
@ -274,7 +273,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
{
Command->Buttons |= Is_Jockey_Victim * 2;
Absolute_Speed();
Disable_Clock_Correction(Interface_Extra_Commands_Action.Integer);
}
}
else
@ -306,7 +305,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
{
if (Action + Reviving != 0)
{
Absolute_Speed();
Disable_Clock_Correction(Interface_Extra_Commands_Action.Integer);
}
}
@ -354,14 +353,11 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
if ((Weapon_Identifier == 105) + (Weapon_Identifier == 121) == 0)
{
if ((129 * (Weapon_Identifier != 120) - Weapon_Identifier ^ Weapon_Identifier - 106) >= 0)
{
using Is_Grenade_Type = __int8(__thiscall**)(void* Weapon);
static std::unordered_set<__int32> Grenades = { 106, 118, 129 };
if ((*Is_Grenade_Type(*(unsigned __int32*)Weapon + 1308))(Weapon) == 1)
{
Cancelable_Shove = min((*(__int16*)((unsigned __int32)Weapon + 3304) == 0) + (*(float*)((unsigned __int32)Weapon + 3308) == 0.f), Cancelable_Shove);
}
if (Grenades.contains(Weapon_Identifier) == 1)
{
Cancelable_Shove = min((*(__int16*)((unsigned __int32)Weapon + 3304) == 0) + (*(float*)((unsigned __int32)Weapon + 3308) == 0.f), Cancelable_Shove);
}
}
else
@ -392,13 +388,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
if (Weapon_Identifier == 39)
{
void* Animation_Overlay = *(void**)((unsigned __int32)Weapon + 3408);
if (Animation_Overlay != nullptr) //1 tick behind. required until "weapon prediction" (misnomer) is implemented
{
Can_Attack = *(float*)(*(unsigned __int32*)((unsigned __int32)Animation_Overlay + 2392) + 28) > 0.95f;
}
Can_Attack = (min(Chainsaw_Cycles * 0.46153846f * Global_Variables->Interval_Per_Tick, 1.f) > 0.95f) * (In_Shove ^ 1);
}
else
{

View File

@ -9,32 +9,7 @@ __int32 Get_Identifier(void* Entity, __int8 Raw, __int8 Equipment)
return Identifier;
}
static std::unordered_set<__int32> Targets =
{
0,
13,
99,
232,
263,
264,
265,
270,
272,
275,
276,
277
};
static std::unordered_set<__int32> Targets = { 0, 13, 99, 232, 263, 264, 265, 270, 272, 275, 276, 277 };
if (Targets.contains(Identifier) == 1)
{
@ -93,20 +68,7 @@ __int32 Get_Identifier(void* Entity, __int8 Raw, __int8 Equipment)
{
if (Equipment == 1)
{
static std::unordered_set<__int32> Equipment_List =
{
73,
105,
109,
121,
256,
260
};
static std::unordered_set<__int32> Equipment_List = { 73, 105, 109, 121, 256, 260 };
if (Equipment_List.contains(Identifier) == 1)
{
@ -144,12 +106,7 @@ void* Original_Estimate_Velocity_Caller;
void __thiscall Redirected_Estimate_Velocity(void* Entity, float* Velocity)
{
static std::unordered_set<__int32> Invalids =
{
264,
277
};
static std::unordered_set<__int32> Invalids = { 264, 277 };
if (Invalids.contains(Get_Identifier(Entity, 1, 0)) == 1)
{
@ -161,10 +118,6 @@ void __thiscall Redirected_Estimate_Velocity(void* Entity, float* Velocity)
Calculate_Velocity_Type((unsigned __int32)Client_Module + 290704)(Entity);
Velocity[0] = *(float*)((unsigned __int32)Entity + 136);
Velocity[1] = *(float*)((unsigned __int32)Entity + 140);
Velocity[2] = *(float*)((unsigned __int32)Entity + 144);
Byte_Manager::Copy_Bytes(1, Velocity, sizeof(float[3]), (float*)((unsigned __int32)Entity + 136));
}
}

View File

@ -1,12 +1,16 @@
__int32 Extra_Commands;
__int32 Chainsaw_Cycles;
void* Original_Move_Caller;
void Redirected_Move(float Unknown_Parameter, __int8 Final)
{
void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712);
using Run_Prediction_Type = void(__cdecl*)();
if (*(void**)((unsigned __int32)Client_Module + 7498712) != nullptr)
if (Local_Player != nullptr)
{
Redirected_Read_Packets(Final);
@ -37,6 +41,17 @@ void Redirected_Move(float Unknown_Parameter, __int8 Final)
Run_Prediction_Type((unsigned __int32)Engine_Module + 527776)();
if (Local_Player != nullptr)
{
Chainsaw_Cycles += 1 + (Chainsaw_Cycles == 0);
static float Deploy_Time;
Chainsaw_Cycles *= *(float*)((unsigned __int32)Local_Player + 3872) == Deploy_Time;
Deploy_Time = *(float*)((unsigned __int32)Local_Player + 3872);
}
if (Extra_Commands > 0)
{
Extra_Commands -= 1;