From 924e32b297fa11d0f8c5a2c6630e9bc1de60823a Mon Sep 17 00:00:00 2001 From: explorer Date: Mon, 21 Oct 2024 06:13:28 +0300 Subject: [PATCH] some progress on prediction redesignment --- Copy_Command.hpp | 56 ++++++++++++++++++++-------------- Entry_Point.cpp | 3 ++ Extended_Interface.hpp | 2 +- Item_Post_Frame.hpp | 2 +- Move.hpp | 19 +++++++----- Perform_Trace.hpp | 19 +++++++----- Post_Network_Data_Received.hpp | 19 +++--------- Process_Movement.hpp | 27 +++------------- Run_Command.hpp | 13 +++++++- Send_Move.hpp | 2 +- 10 files changed, 84 insertions(+), 78 deletions(-) diff --git a/Copy_Command.hpp b/Copy_Command.hpp index 35e2c3d..05fa07e 100644 --- a/Copy_Command.hpp +++ b/Copy_Command.hpp @@ -39,6 +39,8 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu Extended_Command->Extra_Commands = 0; + Extended_Command->Sequence_Shift = 0; + Global_Variables_Structure* Global_Variables = *(Global_Variables_Structure**)((unsigned __int32)Client_Module + 7096744); void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712); @@ -57,8 +59,6 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu } } - *(__int32*)((unsigned __int32)Local_Player + 20) = 0; - if (*(__int8*)((unsigned __int32)Local_Player + 327) == 0) { float Move_Angles[3] = @@ -177,19 +177,24 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu auto Sequence_Shift = [&](__int32 Reserve) { - if (Extra_Commands < 1) + if (Extra_Commands < 1) //td: should work on it { __int32 Sequence_Shift = (*(__int32*)((unsigned __int32)Local_Player + 5324) + ~-150) / 150 * 150 + (Reserve * 150); if (Sequence_Shift > 0) { *(__int32*)((unsigned __int32)Network_Channel + 8) += Sequence_Shift; + + Extended_Command->Sequence_Shift = Sequence_Shift; } } - - *(__int32*)((unsigned __int32)Local_Player + 20) = 1 + (Reserve > 0); }; + if (GetKeyState(VK_INSERT) < 0) + { + Sequence_Shift(2); + } + if (*(__int32*)((unsigned __int32)Local_Player + 228) == 3) { if (*(__int8*)((unsigned __int32)Local_Player + 7322) == 1) @@ -203,7 +208,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { if (*(void**)((unsigned __int32)Local_Player + 10008) != INVALID_HANDLE_VALUE) { - Sequence_Shift(150); + Sequence_Shift(2); } } } @@ -211,27 +216,34 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { if ((*(float*)((unsigned __int32)Local_Player + 4604) + 800 * Global_Variables->Interval_Per_Tick >= 560) + *(__int8*)((unsigned __int32)Local_Player + 8068) + *(__int8*)((unsigned __int32)Local_Player + 9708) != 0) { - Command->Buttons &= ~10241; - - Sequence_Shift(150); + Sequence_Shift(2); } else { - void* Prediction = (void*)((unsigned __int32)Client_Module + 8072728); + //will be used later for reprediction + auto Predict = [&]() -> void + { + Run_Prediction(); + { + void* Prediction = (void*)((unsigned __int32)Client_Module + 8072728); - *(__int8*)((unsigned __int32)Prediction + 8) = 1; + *(__int8*)((unsigned __int32)Prediction + 8) = 1; - *(__int8*)((unsigned __int32)Prediction + 24) = 0; + *(__int8*)((unsigned __int32)Prediction + 24) = 0; - using Set_Host_Type = void(__thiscall*)(void* Move_Helper, void* Player); + using Set_Host_Type = void(__thiscall*)(void* Move_Helper, void* Player); - Set_Host_Type((unsigned __int32)Client_Module + 1331184)((void*)((unsigned __int32)Client_Module + 7174888), Local_Player); + Set_Host_Type((unsigned __int32)Client_Module + 1331184)((void*)((unsigned __int32)Client_Module + 7174888), Local_Player); - Redirected_Run_Command(Prediction, Local_Player, Command, (void*)((unsigned __int32)Client_Module + 7174888)); + Redirected_Run_Command(Prediction, Local_Player, Command, (void*)((unsigned __int32)Client_Module + 7174888)); - Set_Host_Type((unsigned __int32)Client_Module + 1331184)((void*)((unsigned __int32)Client_Module + 7174888), nullptr); + Set_Host_Type((unsigned __int32)Client_Module + 1331184)((void*)((unsigned __int32)Client_Module + 7174888), nullptr); - *(__int8*)((unsigned __int32)Prediction + 8) = 0; + *(__int8*)((unsigned __int32)Prediction + 8) = 0; + } + }; + + Predict(); __int32 Block_Buttons = 2049; @@ -358,7 +370,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu __int8 Reloading = *(__int8*)((unsigned __int32)Weapon + 2493); - __int8 Healing = *(__int32*)((unsigned __int32)Local_Player + 7080) == 1; + __int32 Action = *(__int32*)((unsigned __int32)Local_Player + 7080); __int8 Reviving = *(void**)((unsigned __int32)Local_Player + 8076) != INVALID_HANDLE_VALUE; @@ -384,7 +396,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu __int8 Forced = 0; - if ((Is_Melee + Reloading) * (Healing + Reviving ^ 1) != 0) + if ((Is_Melee + Reloading) * (Action + Reviving ^ 1) != 0) { if ((Target->Identifier ^ 72) % 348 >= 72) { @@ -410,9 +422,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { using Perform_Shove_Trace = __int8(__thiscall*)(void* Weapon, float* Direction); - using Get_Center_Type = float*(__thiscall*)(void* Entity); - - float* Target_Origin = Get_Center_Type((unsigned __int32)Client_Module + 114400)(Target->Self); + float* Target_Origin = Get_Center(Target->Self); float Direction[3] = { @@ -439,7 +449,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu if (Perform_Trace_Damage == 1) { - if (Healing == 0) + if (Action == 0) { Command->Tick_Number = Target->Tick_Number; diff --git a/Entry_Point.cpp b/Entry_Point.cpp index ff4901a..6eb385c 100755 --- a/Entry_Point.cpp +++ b/Entry_Point.cpp @@ -291,6 +291,9 @@ __int32 __stdcall DllMain(HMODULE This_Module, unsigned __int32 Call_Reason, voi Byte_Manager::Set_Bytes(1, (void*)((unsigned __int32)Client_Module + 2655546), 1, 216); *(void**)((unsigned __int32)Client_Module + 8115120) = (void*)((unsigned __int32)Client_Module + 955708); + + //rem: there is annoying "power bounce" effect (extremely noticeable with broken lerp) + //actually it's m_duckUntilOnGround } _putws(L"[ + ] Paint"); diff --git a/Extended_Interface.hpp b/Extended_Interface.hpp index 9915dc9..d0f6341 100755 --- a/Extended_Interface.hpp +++ b/Extended_Interface.hpp @@ -62,7 +62,7 @@ void Implement_Extended_Interface() Create_Console_Interface(Pointer_Name(Interface_Aim_Intersection), (char*)"1", nullptr); - Create_Console_Interface(Pointer_Name(Interface_Penetration_Damage), (char*)"20", nullptr); + Create_Console_Interface(Pointer_Name(Interface_Penetration_Damage), (char*)"12", nullptr); Create_Console_Interface(Pointer_Name(Interface_Equipment_Distance), (char*)"2048", nullptr); diff --git a/Item_Post_Frame.hpp b/Item_Post_Frame.hpp index 61e2922..365e8be 100755 --- a/Item_Post_Frame.hpp +++ b/Item_Post_Frame.hpp @@ -2,7 +2,7 @@ void* Original_Item_Post_Frame_Caller; void __thiscall Redirected_Item_Post_Frame(void* Player) { - if (*(void**)((unsigned __int32)__builtin_frame_address(0) + 60) == (void*)((unsigned __int32)Client_Module + 423107)) + if (*(void**)((unsigned __int32)__builtin_frame_address(0) + 88) == (void*)((unsigned __int32)Client_Module + 423107)) { (decltype(&Redirected_Item_Post_Frame)(Original_Item_Post_Frame_Caller))(Player); } diff --git a/Move.hpp b/Move.hpp index 621c3a9..a552f96 100644 --- a/Move.hpp +++ b/Move.hpp @@ -1,16 +1,21 @@ -void* Original_Move_Caller; - -__int32 Extra_Commands; - -void Redirected_Move(float Unknown_Parameter, __int8 Final) +void Run_Prediction() { using Run_Prediction_Type = void(__cdecl*)(); + Run_Prediction_Type((unsigned __int32)Engine_Module + 527776)(); +} + +__int32 Extra_Commands; + +void* Original_Move_Caller; + +void Redirected_Move(float Unknown_Parameter, __int8 Final) +{ if (*(void**)((unsigned __int32)Client_Module + 7498712) != nullptr) { Redirected_Read_Packets(Final); - Run_Prediction_Type((unsigned __int32)Engine_Module + 527776)(); + Run_Prediction(); using Update_Animations_Type = void(__cdecl*)(); @@ -35,7 +40,7 @@ void Redirected_Move(float Unknown_Parameter, __int8 Final) { (decltype(&Redirected_Move)(Original_Move_Caller))(Unknown_Parameter, Final); - Run_Prediction_Type((unsigned __int32)Engine_Module + 527776)(); + Run_Prediction(); if (Extra_Commands > 0) { diff --git a/Perform_Trace.hpp b/Perform_Trace.hpp index 3dd2991..1be6572 100755 --- a/Perform_Trace.hpp +++ b/Perform_Trace.hpp @@ -1,5 +1,14 @@ void* Perform_Trace_Target; +float* Get_Center(void* Entity) +{ + using Get_Center_Type = float*(__thiscall*)(void* Entity); + + return Get_Center_Type((unsigned __int32)Client_Module + 114400)(Entity); +} + +float Perform_Trace_Damage; + float Vector_Normalize(float* Vector) { using Vector_Normalize_Type = float(__thiscall*)(float* Vector); @@ -14,8 +23,6 @@ void Angle_Vectors(float* Angles, float* Forward, float* Right, float* Up) Angle_Vectors_Type((unsigned __int32)Client_Module + 3539376)(Angles, Forward, Right, Up); }; -float Perform_Trace_Damage; - void __thiscall Perform_Trace(void* Stack) { void* Entity = *(void**)((unsigned __int32)Stack + 312); @@ -119,13 +126,11 @@ void __thiscall Perform_Trace(void* Stack) { using Get_Bounds_Type = void(__thiscall*)(void* Collision, float* Start, float* Bounds); - using Get_Center_Type = float* (__thiscall*)(void* Entity); - void* Local_Player = *(void**)Trace_Information; float Bounds[3]; - Get_Bounds_Type((unsigned __int32)Client_Module + 878528)((void*)((unsigned __int32)Entity + 540), Get_Center_Type((unsigned __int32)Client_Module + 114400)(Local_Player), Bounds); + Get_Bounds_Type((unsigned __int32)Client_Module + 878528)((void*)((unsigned __int32)Entity + 540), Get_Center(Local_Player), Bounds); using Calculate_Distance_Type = float(__thiscall*)(void* Collision, float* Bounds); @@ -284,9 +289,7 @@ void __thiscall Perform_Trace(void* Stack) { float Inflictor_Direction[3]; - using Get_Center_Type = float*(__thiscall*)(void* Entity); - - float* Start = Get_Center_Type((unsigned __int32)Client_Module + 114400)(*(void**)Trace_Information); + float* Start = Get_Center(*(void**)Trace_Information); Inflictor_Direction[0] = End[0] - Start[0]; diff --git a/Post_Network_Data_Received.hpp b/Post_Network_Data_Received.hpp index e3a90f7..349a103 100755 --- a/Post_Network_Data_Received.hpp +++ b/Post_Network_Data_Received.hpp @@ -41,24 +41,13 @@ Prediction_Copy_Structure Predicton_Copy; void Predicton_Copy_Compare(void* Unknown_Parameter_1, void* Unknown_Parameter_2, void* Unknown_Parameter_3, void* Unknown_Parameter_4, void* Unknown_Parameter_5, void* Unknown_Parameter_6, __int8 Within_Tolerance, void* Unknown_Parameter_7) { - Prediction_Field_Structure* Field = *(Prediction_Field_Structure**)((unsigned __int32)__builtin_frame_address(0) + 60); - - if (Field->Flat_Offset[0] == 5324) - { - if (*(__int32*)((unsigned __int32)Predicton_Copy.Destination + 20) != 0) - { - goto Copy_Label; - } - } - if (Within_Tolerance == 1) { + Prediction_Field_Structure* Field = *(Prediction_Field_Structure**)((unsigned __int32)__builtin_frame_address(0) + 60); + if ((256 - Field->Flat_Offset[0] ^ Field->Flat_Offset[0] - 244) != 12) { - Copy_Label: - { - Byte_Manager::Copy_Bytes(0, (void*)((unsigned __int32)Predicton_Copy.Destination + Field->Flat_Offset[0]), Field->Bytes, (void*)((unsigned __int32)Predicton_Copy.Source + Field->Flat_Offset[1])); - } + Byte_Manager::Copy_Bytes(0, (void*)((unsigned __int32)Predicton_Copy.Destination + Field->Flat_Offset[0]), Field->Bytes, (void*)((unsigned __int32)Predicton_Copy.Source + Field->Flat_Offset[1])); } } } @@ -91,6 +80,8 @@ void __thiscall Redirected_Post_Network_Data_Received(void* Unknown_Parameter, _ using Transfer_Data_Type = __int32(__thiscall*)(Prediction_Copy_Structure* Prediction_Copy, void* Unknown_Parameter, __int32 Entity_Number, Prediction_Descriptor_Structure* Descriptor); Transfer_Data_Type((unsigned __int32)Client_Module + 1573744)(&Predicton_Copy, nullptr, -1, (Prediction_Descriptor_Structure*)((unsigned __int32)Client_Module + 7236480)); + + *(__int32*)((unsigned __int32)Local_Player + 5324) += Commands_Acknowledged - Commands_Acknowledged % 150; } (decltype(&Redirected_Post_Network_Data_Received)(Original_Post_Network_Data_Received_Caller))(Unknown_Parameter, Commands_Acknowledged); diff --git a/Process_Movement.hpp b/Process_Movement.hpp index 10dceda..bc7ca5d 100644 --- a/Process_Movement.hpp +++ b/Process_Movement.hpp @@ -2,31 +2,14 @@ void* Original_Process_Movement_Caller; void __thiscall Redirected_Process_Movement(void* Unknown_Parameter, void* Player, void* Move_Data) { - __int32 Stunned = *(__int32*)((unsigned __int32)Player + 20); - - if (Stunned == 2) + if (*(__int32*)((unsigned __int32)Player + 5324) < 0) { - Global_Variables_Structure* Global_Variables = *(Global_Variables_Structure**)((unsigned __int32)Client_Module + 7096744); - - Global_Variables->Current_Time *= -1; - *(__int32*)((unsigned __int32)Move_Data + 36) &= ~1564; - if (*(__int8*)((unsigned __int32)Player + 4636) == 1) - { - *(__int32*)((unsigned __int32)Move_Data + 36) |= 4; - } + *(__int32*)((unsigned __int32)Move_Data + 36) |= 4 * *(__int8*)((unsigned __int32)Player + 4636); - *(float*)((unsigned __int32)Move_Data + 44) = 0; - - *(float*)((unsigned __int32)Move_Data + 48) = 0; - - (decltype(&Redirected_Process_Movement)(Original_Process_Movement_Caller))(Unknown_Parameter, Player, Move_Data); - - Global_Variables->Current_Time *= -1; - } - else - { - (decltype(&Redirected_Process_Movement)(Original_Process_Movement_Caller))(Unknown_Parameter, Player, Move_Data); + *(double*)((unsigned __int32)Move_Data + 44) = 0; } + + (decltype(&Redirected_Process_Movement)(Original_Process_Movement_Caller))(Unknown_Parameter, Player, Move_Data); } \ No newline at end of file diff --git a/Run_Command.hpp b/Run_Command.hpp index d91b72d..61c9bf1 100644 --- a/Run_Command.hpp +++ b/Run_Command.hpp @@ -22,6 +22,8 @@ struct Command_Structure struct Extended_Command_Structure { __int32 Extra_Commands; + + __int32 Sequence_Shift; }; Extended_Command_Structure Extended_Commands[150]; @@ -32,7 +34,16 @@ void __thiscall Redirected_Run_Command(void* Prediction, void* Player, Command_S { Extended_Command_Structure* Extended_Command = &Extended_Commands[Command->Frame_Number]; - *(__int32*)((unsigned __int32)Player + 5324) -= Extended_Command->Extra_Commands; + *(__int32*)((unsigned __int32)Player + 5324) -= Extended_Command->Extra_Commands + Extended_Command->Sequence_Shift; (decltype(&Redirected_Run_Command)(Original_Run_Command_Caller))(Prediction, Player, Command, Unknown_Parameter); + + if (__builtin_return_address(0) == (void*)((unsigned __int32)Client_Module + 423107)) + { + *(__int32*)((unsigned __int32)Player + 5324) += Extended_Command->Sequence_Shift; + + Global_Variables_Structure* Global_Variables = *(Global_Variables_Structure**)((unsigned __int32)Client_Module + 7096744); + + Global_Variables->Current_Time = (*(__int32*)((unsigned __int32)Player + 5324) - 1) * Global_Variables->Interval_Per_Tick; + } } \ No newline at end of file diff --git a/Send_Move.hpp b/Send_Move.hpp index b1e99a6..3c78d08 100644 --- a/Send_Move.hpp +++ b/Send_Move.hpp @@ -62,7 +62,7 @@ void Redirected_Send_Move() void* Network_Channel = *(void**)(*(unsigned __int32*)((unsigned __int32)Engine_Module + 4352236) + 24); - *(__int32*)((unsigned __int32)Network_Channel + 28) -= Extra_Commands_Queue; + *(__int32*)((unsigned __int32)Network_Channel + 28) -= Extra_Commands_Queue; //td: should do same thing i'm doing in v34 instead using Send_Network_Message_Type = void(__thiscall**)(void* Network_Channel, void* Message, void* Unknown_Parameter_1, void* Unknown_Parameter_2);