From 2dc81b9839730ed9dd5c23364ca279c1b9706ac0 Mon Sep 17 00:00:00 2001 From: explorer Date: Fri, 1 Nov 2024 16:43:34 +0300 Subject: [PATCH] adjust special infected shotgun scaling also explicitly specifying value type seems to be good practice to prevent unintended fraction down-rounding (just what've happened in paint.hpp with color 128 -> 127) also remove scope check i've competely forgot about in draw_crosshair.hpp --- Copy_Command.hpp | 36 +++++++-------- Draw_Crosshair.hpp | 105 +++++++++++++++++++++---------------------- Finish_Move.hpp | 4 +- Paint.hpp | 18 ++++---- Perform_Trace.hpp | 25 +++++------ Process_Movement.hpp | 2 +- 6 files changed, 92 insertions(+), 98 deletions(-) diff --git a/Copy_Command.hpp b/Copy_Command.hpp index e455b5e..ba2b722 100644 --- a/Copy_Command.hpp +++ b/Copy_Command.hpp @@ -90,23 +90,23 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu Command->Buttons &= ~(*(__int32*)((unsigned __int32)Local_Player + 5028) & 2); } - float Difference = __builtin_remainderf(Move_Angles[1] - Previous_Move_Angle_Y, 360); + float Difference = __builtin_remainderf(Move_Angles[1] - Previous_Move_Angle_Y, 360.f); Previous_Move_Angle_Y = Move_Angles[1]; float* Velocity = (float*)((unsigned __int32)Local_Player + 256); - if (__builtin_fabsf(Difference) < __builtin_atan2f(30, __builtin_hypotf(Velocity[0], Velocity[1])) * 180 / 3.1415927f) + if (__builtin_fabsf(Difference) < __builtin_atan2f(30, __builtin_hypotf(Velocity[0], Velocity[1])) * 180.f / 3.1415927f) { - float Strafe_Angle = __builtin_remainderf(Move_Angles[1] - __builtin_atan2f(Velocity[1], Velocity[0]) * 180 / 3.1415927f, 360); + float Strafe_Angle = __builtin_remainderf(Move_Angles[1] - __builtin_atan2f(Velocity[1], Velocity[0]) * 180.f / 3.1415927f, 360.f); if (__builtin_signbitf(Strafe_Angle) == 0) { - Command->Move[1] = -400; + Command->Move[1] = -400.f; } else { - Command->Move[1] = 400; + Command->Move[1] = 400.f; } Move_Angles[1] -= Strafe_Angle; @@ -115,11 +115,11 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { if (__builtin_signbitf(Difference) == 0) { - Command->Move[1] = -400; + Command->Move[1] = -400.f; } else { - Command->Move[1] = 400; + Command->Move[1] = 400.f; } } } @@ -230,7 +230,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu } else { - 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) + if ((*(float*)((unsigned __int32)Local_Player + 4604) + 800.f * Global_Variables->Interval_Per_Tick >= 560.f) + *(__int8*)((unsigned __int32)Local_Player + 8068) + *(__int8*)((unsigned __int32)Local_Player + 9708) != 0) { Sequence_Shift(2); } @@ -317,7 +317,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu (__int8)(Identifier == 270 ? *(void**)((unsigned __int32)Entity + 8040) == *(void**)((unsigned __int32)Local_Player + 376) : 0), - __builtin_powf(Local_Player_Origin[0] - Entity_Origin[0], 2) + __builtin_powf(Local_Player_Origin[1] - Entity_Origin[1], 2) + __builtin_powf(Local_Player_Origin[2] - Entity_Origin[2], 2), + __builtin_powf(Local_Player_Origin[0] - Entity_Origin[0], 2.f) + __builtin_powf(Local_Player_Origin[1] - Entity_Origin[1], 2.f) + __builtin_powf(Local_Player_Origin[2] - Entity_Origin[2], 2.f), (__int32)(Time / Global_Variables->Interval_Per_Tick + 0.5f) }; @@ -326,7 +326,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { if (Identifier == 277) { - if (*(float*)((unsigned __int32)Entity + 4844) == 1) + if (*(float*)((unsigned __int32)Entity + 4844) == 1.f) { Sorted_Target_List.push_back(Target); } @@ -441,7 +441,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu Vector_Normalize(Direction); - *(float*)((unsigned __int32)Weapon + 2724) = 75; + *(float*)((unsigned __int32)Weapon + 2724) = 75.f; *(__int32*)((unsigned __int32)Weapon + 3248) = 0; @@ -459,19 +459,19 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { Command->Tick_Number = Target->Tick_Number; - Command->Angles[0] = __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180 / 3.1415927f; + Command->Angles[0] = __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180.f / 3.1415927f; - Command->Angles[1] = __builtin_atan2f(Direction[1], Direction[0]) * 180 / 3.1415927f; + Command->Angles[1] = __builtin_atan2f(Direction[1], Direction[0]) * 180.f / 3.1415927f; if (Cancelable_Shove == 1) { float Shove_Multiplier = min((Global_Variables->Current_Time - *(float*)((unsigned __int32)Weapon + 2704) + *(float*)((unsigned __int32)Weapon + 2700)) / *(float*)((unsigned __int32)Weapon + 2700), 1.f); - Command->Angles[1] += -45 * Shove_Multiplier + 45 * (1 - Shove_Multiplier); + Command->Angles[1] += -45.f * Shove_Multiplier + 45.f * (1.f - Shove_Multiplier); } else { - Command->Angles[1] += 45; + Command->Angles[1] += 45.f; } Command->Buttons |= 2048; @@ -685,9 +685,9 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu float Angles[3] = { - __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180 / 3.1415927f, + __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180.f / 3.1415927f, - __builtin_atan2f(Direction[1], Direction[0]) * 180 / 3.1415927f, + __builtin_atan2f(Direction[1], Direction[0]) * 180.f / 3.1415927f, 0 }; @@ -722,7 +722,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu { if (Shove_Target != nullptr) { - *(float*)((unsigned __int32)Shove_Target->Self + 16) = 0; + *(float*)((unsigned __int32)Shove_Target->Self + 16) = 0.f; if (Aim_Target != nullptr) { diff --git a/Draw_Crosshair.hpp b/Draw_Crosshair.hpp index 7d0b18d..d79d809 100755 --- a/Draw_Crosshair.hpp +++ b/Draw_Crosshair.hpp @@ -1,64 +1,61 @@ void Redirected_Draw_Crosshair() { - if ((*(__int32*)(*(unsigned __int32*)((unsigned __int32)Client_Module + 7498712) + 5008) | 55) == 55) + static float Rotation_Angle; + + auto Draw_Storm = [&](__int32 X, __int32 Y, __int32 Additional_Rotation_Angle) { - static float Rotation_Angle; + using Set_Color_Type = void(__thiscall**)(void* Surface, unsigned __int8 Red, unsigned __int8 Green, unsigned __int8 Blue, unsigned __int8 Alpha); - auto Draw_Storm = [&](__int32 X, __int32 Y, __int32 Additional_Rotation_Angle) + void* Surface = *(void**)((unsigned __int32)Client_Module + 8960244); + + (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, 0, 0, 0, 255); + + using Draw_Circle_Type = void(__thiscall**)(void* Surface, __int32 X, __int32 Y, __int32 Radius, __int32 Segments); + + X += Interface_Storm_Rotation_Radius.Integer * __builtin_cosf(__builtin_remainderf(Rotation_Angle + Additional_Rotation_Angle, 360.f) * 3.1415927f / 180.f); + + Y += Interface_Storm_Rotation_Radius.Integer * __builtin_sinf(__builtin_remainderf(Rotation_Angle + Additional_Rotation_Angle, 360.f) * 3.1415927f / 180.f); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + + (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, 0, 128, 255, 255); + + (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); + }; + + __int32 Storm_Number = 0; + + using Get_Screen_Size_Type = __int32(__cdecl*)(); + + __int32 Screen_Width = Get_Screen_Size_Type((unsigned __int32)Client_Module + 738576)() / 2; + + __int32 Screen_Height = Get_Screen_Size_Type((unsigned __int32)Client_Module + 738544)() / 2; + + Draw_Storm_Label: + { + if (Storm_Number < Interface_Storm_Iterations.Integer) { - using Set_Color_Type = void(__thiscall**)(void* Surface, unsigned __int8 Red, unsigned __int8 Green, unsigned __int8 Blue, unsigned __int8 Alpha); + Draw_Storm(Screen_Width, Screen_Height, Storm_Number * 360 / Interface_Storm_Iterations.Integer); - void* Surface = *(void**)((unsigned __int32)Client_Module + 8960244); + Storm_Number += 1; - (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, 0, 0, 0, 255); - - using Draw_Circle_Type = void(__thiscall**)(void* Surface, __int32 X, __int32 Y, __int32 Radius, __int32 Segments); - - X += Interface_Storm_Rotation_Radius.Integer * __builtin_cosf(__builtin_remainderf(Rotation_Angle + Additional_Rotation_Angle, 360) * 3.1415927f / 180); - - Y += Interface_Storm_Rotation_Radius.Integer * __builtin_sinf(__builtin_remainderf(Rotation_Angle + Additional_Rotation_Angle, 360) * 3.1415927f / 180); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y - 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X - 1, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X + 1, Y + 1, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - - (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, 0, 128, 255, 255); - - (*Draw_Circle_Type(*(unsigned __int32*)Surface + 384))(Surface, X, Y, Interface_Storm_Radius.Integer, Interface_Storm_Segments.Integer); - }; - - __int32 Storm_Number = 0; - - using Get_Screen_Size_Type = __int32(__cdecl*)(); - - __int32 Screen_Width = Get_Screen_Size_Type((unsigned __int32)Client_Module + 738576)() / 2; - - __int32 Screen_Height = Get_Screen_Size_Type((unsigned __int32)Client_Module + 738544)() / 2; - - Draw_Storm_Label: - { - if (Storm_Number < Interface_Storm_Iterations.Integer) - { - Draw_Storm(Screen_Width, Screen_Height, Storm_Number * 360 / Interface_Storm_Iterations.Integer); - - Storm_Number += 1; - - goto Draw_Storm_Label; - } + goto Draw_Storm_Label; } - - Rotation_Angle = __builtin_remainderf(Rotation_Angle + (*(Global_Variables_Structure**)((unsigned __int32)Client_Module + 7096744))->Frame_Time * Interface_Storm_Speed.Integer, 360); } + + Rotation_Angle = __builtin_remainderf(Rotation_Angle + (*(Global_Variables_Structure**)((unsigned __int32)Client_Module + 7096744))->Frame_Time * Interface_Storm_Speed.Integer, 360.f); } \ No newline at end of file diff --git a/Finish_Move.hpp b/Finish_Move.hpp index 1d832a1..8289a2e 100755 --- a/Finish_Move.hpp +++ b/Finish_Move.hpp @@ -4,9 +4,9 @@ void __thiscall Redirected_Finish_Move(void* Unknown_Parameter_1, void* Player, { float X = *(float*)((unsigned __int32)Move_Data + 76); - if (X > 180) + if (X > 180.f) { - X -= 360; + X -= 360.f; } *(float*)((unsigned __int32)Move_Data + 76) = std::clamp(X, -90.f, 90.f); diff --git a/Paint.hpp b/Paint.hpp index dc0eaf9..df334bc 100755 --- a/Paint.hpp +++ b/Paint.hpp @@ -36,7 +36,7 @@ void __thiscall Redirected_Paint(void* Panel) 0, - __builtin_powf(Local_Player_Origin[0] - Entity_Origin[0], 2) + __builtin_powf(Local_Player_Origin[1] - Entity_Origin[1], 2) + __builtin_powf(Local_Player_Origin[2] - Entity_Origin[2], 2) + __builtin_powf(Local_Player_Origin[0] - Entity_Origin[0], 2.f) + __builtin_powf(Local_Player_Origin[1] - Entity_Origin[1], 2.f) + __builtin_powf(Local_Player_Origin[2] - Entity_Origin[2], 2.f) }; if (Identifier >= 0) @@ -145,9 +145,9 @@ void __thiscall Redirected_Paint(void* Panel) __int32 Screen_Height = Get_Screen_Size_Type((unsigned __int32)Client_Module + 738544)(); - Screen[0] = Screen[0] / 2 * Screen_Width + Screen_Width / 2; + Screen[0] = Screen[0] / 2.f * Screen_Width + Screen_Width / 2.f; - Screen[1] = -Screen[1] / 2 * Screen_Height + Screen_Height / 2; + Screen[1] = -Screen[1] / 2.f * Screen_Height + Screen_Height / 2.f; Bounds[0] = min(Bounds[0], Screen[0]); @@ -176,15 +176,15 @@ void __thiscall Redirected_Paint(void* Panel) } } - Bounds[0] -= 2; + Bounds[0] -= 2.f; - Bounds[1] += 2; + Bounds[1] += 2.f; - Bounds[2] -= 2; + Bounds[2] -= 2.f; - Bounds[3] += 2; + Bounds[3] += 2.f; - return (Bounds[1] != 2) * (Bounds[3] != 2); + return (Bounds[1] != 2.f) * (Bounds[3] != 2.f); } return 0; @@ -270,7 +270,7 @@ void __thiscall Redirected_Paint(void* Panel) if (Ghost == 0) { - (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, (__int32)(Paint_Data->Color[0] / 2 + 0.5f), (__int32)(Paint_Data->Color[1] / 2 + 0.5f), (__int32)(Paint_Data->Color[2] / 2 + 0.5f), 128); + (*Set_Color_Type(*(unsigned __int32*)Surface + 44))(Surface, (__int32)(Paint_Data->Color[0] / 2.f + 0.5f), (__int32)(Paint_Data->Color[1] / 2.f + 0.5f), (__int32)(Paint_Data->Color[2] / 2.f + 0.5f), 128); } else { diff --git a/Perform_Trace.hpp b/Perform_Trace.hpp index 1b61d61..cab4352 100755 --- a/Perform_Trace.hpp +++ b/Perform_Trace.hpp @@ -74,7 +74,7 @@ void __thiscall Perform_Trace(void* Stack) { float* Start = (float*)((unsigned __int32)Stack + 236); - float Distance = __builtin_sqrtf(__builtin_powf(End[0] - Start[0], 2) + __builtin_powf(End[1] - Start[1], 2) + __builtin_powf(End[2] - Start[2], 2)); + float Distance = __builtin_sqrtf(__builtin_powf(End[0] - Start[0], 2.f) + __builtin_powf(End[1] - Start[1], 2.f) + __builtin_powf(End[2] - Start[2], 2.f)); float Damage; @@ -138,20 +138,15 @@ void __thiscall Perform_Trace(void* Stack) if (Distance < 100) { - Damage += 4.f * Damage * __builtin_powf(1.f - Distance / 100.f, 2); + Damage += 4.f * Damage * __builtin_powf(1.f - Distance / 100.f, 2.f); } } } }; - if (Identifier == 277) + if (Identifier == 13) { - if (Group != 1) - { - Apply_Difficulty_Scaling(); - } - - Apply_Shotgun_Scaling(); + Damage *= *(float*)((unsigned __int32)Entity + 336) - *(float*)((unsigned __int32)Entity + 472) >= 0.5f; } else { @@ -228,12 +223,14 @@ void __thiscall Perform_Trace(void* Stack) } else { - if (Identifier == 13) + if (Identifier == 277) { - if (*(float*)((unsigned __int32)Entity + 336) - *(float*)((unsigned __int32)Entity + 472) < 0.5f) + if (Group != 1) { - Damage = 0; + Apply_Difficulty_Scaling(); } + + Apply_Shotgun_Scaling(); } else { @@ -246,7 +243,7 @@ void __thiscall Perform_Trace(void* Stack) { static float Multipliers[8] = { 1.f, 4.f, 1.f, 1.25f, 1.f, 1.f, 0.75f, 0.75f }; - Damage *= Multipliers[Group]; + Damage *= min(4.f - 2.75f * Is_Shotgun, Multipliers[Group]); } if (Get_Identifier(Entity, 1, 0) == 99) @@ -318,7 +315,7 @@ void __thiscall Perform_Trace(void* Stack) Angle_Vectors(Angle, Victim_Direction, nullptr, nullptr); - if (Inflictor_Direction[0] * Victim_Direction[0] + Inflictor_Direction[1] * Victim_Direction[1] + Inflictor_Direction[2] * Victim_Direction[2] >= 0) + if (Inflictor_Direction[0] * Victim_Direction[0] + Inflictor_Direction[1] * Victim_Direction[1] + Inflictor_Direction[2] * Victim_Direction[2] >= 0.f) { Compute_Damage(); } diff --git a/Process_Movement.hpp b/Process_Movement.hpp index f92b734..f52bf3c 100644 --- a/Process_Movement.hpp +++ b/Process_Movement.hpp @@ -8,7 +8,7 @@ void __thiscall Redirected_Process_Movement(void* Unknown_Parameter, void* Playe *(__int32*)((unsigned __int32)Move_Data + 36) |= 4 * *(__int8*)((unsigned __int32)Player + 4636); - *(double*)((unsigned __int32)Move_Data + 44) = 0; + *(double*)((unsigned __int32)Move_Data + 44) = 0.; } (decltype(&Redirected_Process_Movement)(Original_Process_Movement_Caller))(Unknown_Parameter, Player, Move_Data);