Storm/Perform_Trace.hpp

335 lines
8.3 KiB
C++
Raw Normal View History

2024-04-04 03:17:09 +08:00
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;
2024-04-04 03:17:09 +08:00
float Vector_Normalize(float* Vector)
{
using Vector_Normalize_Type = float(__thiscall*)(float* Vector);
2024-10-07 03:45:39 +08:00
return Vector_Normalize_Type((unsigned __int32)Client_Module + 3536176)(Vector);
2024-04-04 03:17:09 +08:00
};
void Angle_Vectors(float* Angles, float* Forward, float* Right, float* Up)
{
using Angle_Vectors_Type = void(__cdecl*)(float* Angles, float* Forward, float* Right, float* Up);
2024-10-07 03:45:39 +08:00
Angle_Vectors_Type((unsigned __int32)Client_Module + 3539376)(Angles, Forward, Right, Up);
2024-04-04 03:17:09 +08:00
};
void __thiscall Perform_Trace(void* Stack)
{
void* Entity = *(void**)((unsigned __int32)Stack + 312);
2024-10-15 07:38:32 +08:00
__int32 Identifier = Get_Identifier(Entity, 0, 0);
2024-10-07 03:45:39 +08:00
if (Interface_Penetrate_Teammates.Integer == 0)
{
2024-10-15 07:38:32 +08:00
if (Identifier == 232)
2024-10-07 03:45:39 +08:00
{
void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712);
if (*(__int32*)((unsigned __int32)Entity + 228) == *(__int32*)((unsigned __int32)Local_Player + 228))
{
return;
2024-10-07 03:45:39 +08:00
}
}
}
if (Entity == Perform_Trace_Target)
2024-04-04 03:17:09 +08:00
{
2024-10-09 12:00:21 +08:00
__int32 Group = *(__int32*)((unsigned __int32)Stack + 304);
if (Interface_Aim_Intersection.Integer == 0)
{
2024-10-09 12:00:21 +08:00
if (Group != 1)
{
return;
}
}
2024-04-04 03:17:09 +08:00
void* Trace_Information = *(void**)((unsigned __int32)Stack + 36);
void* Weapon_Data = *(void**)((unsigned __int32)Trace_Information + 4);
2024-10-09 12:00:21 +08:00
float* End = (float*)((unsigned __int32)Stack + 248);
2024-10-09 12:00:21 +08:00
__int32 Upgrade_Type = (*(__int32*)((unsigned __int32)Trace_Information + 36) & 255) % 5;
2024-10-09 12:00:21 +08:00
__int32 Gender = *(__int32*)((unsigned __int32)Entity + 52);
2024-10-09 12:00:21 +08:00
auto Compute_Damage = [&]() -> void
{
if (Interface_Penetration_Damage.Integer == 0)
2024-10-09 12:00:21 +08:00
{
Perform_Trace_Damage = 1;
2024-10-09 12:00:21 +08:00
}
else
{
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 Damage;
static void* Calculate_Damage = (void*)((unsigned __int32)GetModuleHandleW(L"server.dll") + 3950416);
{
asm("movl %0, %%esi" : : "m"(Weapon_Data) : "esi");
asm("subl $16, %esp");
asm("movss %0, %%xmm0" : : "m"(Distance) : "esp");
asm("movdqu %xmm0, (%esp)");
2024-10-13 10:42:41 +08:00
asm("calll *%0" : : "m"(Calculate_Damage) : "eax", "ecx", "edx");
asm("movd %%xmm0, %0" : "=m"(Damage));
asm("addl $16, %esp");
2024-10-13 10:42:41 +08:00
}
__int32 Bullet_Type = *(__int32*)((unsigned __int32)Weapon_Data + 2128);
__int8 Is_Shotgun = (Bullet_Type ^ 12) % 7 == 4;
if (Upgrade_Type * Is_Shotgun == 1)
{
Damage *= *(__int32*)((unsigned __int32)Weapon_Data + 2520);
}
auto Apply_Difficulty_Scaling = [&]() -> void
{
using Get_Difficulty_Type = __int32(__cdecl*)();
float Multipliers[3] = { 0.8f, 0.7f, 0.6f };
Damage *= Multipliers[Get_Difficulty_Type((unsigned __int32)Client_Module + 2650448)()];
};
2024-10-13 10:42:41 +08:00
char* Mode = *(char**)((unsigned __int32)Client_Module + 8145092);
2024-10-13 10:42:41 +08:00
__int8 Realism = Mode[0] == 'r';
auto Apply_Shotgun_Scaling = [&]() -> void
2024-10-09 12:00:21 +08:00
{
if (Is_Shotgun == 1)
2024-10-09 12:00:21 +08:00
{
2024-10-14 09:52:51 +08:00
__int8 Hardcore = Realism;
2024-10-13 10:42:41 +08:00
if (__builtin_strlen(Mode) > 8)
{
2024-10-14 09:52:51 +08:00
Hardcore = (Mode[8] == '8') + (Mode[9] == '2');
2024-10-13 10:42:41 +08:00
}
2024-10-14 09:52:51 +08:00
if (Hardcore == 0)
2024-10-13 10:42:41 +08:00
{
using Get_Bounds_Type = void(__thiscall*)(void* Collision, float* Start, float* Bounds);
2024-10-13 10:42:41 +08:00
void* Local_Player = *(void**)Trace_Information;
2024-10-13 10:42:41 +08:00
float Bounds[3];
Get_Bounds_Type((unsigned __int32)Client_Module + 878528)((void*)((unsigned __int32)Entity + 540), Get_Center(Local_Player), Bounds);
2024-10-13 10:42:41 +08:00
using Calculate_Distance_Type = float(__thiscall*)(void* Collision, float* Bounds);
float Distance = Calculate_Distance_Type((unsigned __int32)Client_Module + 878608)((void*)((unsigned __int32)Local_Player + 540), Bounds);
if (Distance < 100)
{
2024-10-15 06:32:36 +08:00
Damage += 4.f * Damage * __builtin_powf(1.f - Distance / 100.f, 2);
2024-10-13 10:42:41 +08:00
}
}
2024-10-09 12:00:21 +08:00
}
};
if (Identifier == 277)
{
if (Group != 1)
2024-10-09 12:00:21 +08:00
{
Apply_Difficulty_Scaling();
}
Apply_Shotgun_Scaling();
2024-10-09 12:00:21 +08:00
}
else
2024-10-09 12:00:21 +08:00
{
if (Identifier == 264)
2024-10-09 12:00:21 +08:00
{
2024-10-13 10:42:41 +08:00
if ((Upgrade_Type == 1) + (Bullet_Type == 6))
2024-10-09 12:00:21 +08:00
{
Damage = __builtin_inff();
}
else
{
2024-10-13 10:42:41 +08:00
Apply_Shotgun_Scaling();
2024-10-13 10:42:41 +08:00
__int8 Is_Sniper_Rifle = (Bullet_Type - 8) > 0;
2024-10-13 10:42:41 +08:00
if (Group == 1)
{
if (Gender == 14)
{
2024-10-13 10:42:41 +08:00
auto Is_Neutral = [&]() -> __int8
{
2024-10-13 10:42:41 +08:00
__int32 Sequence_Activity = *(__int32*)((unsigned __int32)Entity + 4688);
2024-10-13 10:42:41 +08:00
unsigned __int32 Absolute_Sequence_Activity = Sequence_Activity - 563;
2024-10-13 10:42:41 +08:00
if (Absolute_Sequence_Activity <= 29)
{
2024-10-13 10:42:41 +08:00
return (536870929 & (1 << (Absolute_Sequence_Activity & 31))) != 0;
}
2024-10-13 10:42:41 +08:00
return (Sequence_Activity == 600) + (Sequence_Activity == 648);
};
if (Is_Neutral() == 1)
{
2024-10-13 10:42:41 +08:00
Damage = __builtin_inff();
}
}
else
2024-10-09 12:00:21 +08:00
{
2024-10-13 10:42:41 +08:00
if (Gender != 17)
{
Damage = __builtin_inff();
}
2024-10-13 10:42:41 +08:00
}
}
else
{
if (Group * (Gender != 14) * (Gender != 17) * Is_Shotgun == 3)
{
Damage = __builtin_inff();
}
else
{
Apply_Difficulty_Scaling();
2024-10-13 10:42:41 +08:00
if ((Bullet_Type == 2) + Is_Sniper_Rifle != 0)
{
if (Gender == 14)
{
2024-10-13 10:42:41 +08:00
if (Is_Sniper_Rifle * Realism == 0)
{
Damage = 450;
}
}
else
{
2024-10-13 10:42:41 +08:00
Damage = __builtin_inff();
}
}
2024-10-09 12:00:21 +08:00
}
}
}
}
else
{
if (Identifier != 13)
{
if (Identifier + Bullet_Type == 284)
{
Damage *= 0.85f;
}
2024-10-13 10:42:41 +08:00
if ((Identifier != 276) + (Upgrade_Type != 1) == 2)
{
2024-10-13 10:42:41 +08:00
float Multipliers[8] = { 1.f, 4.f, 1.f, 1.25f, 1.f, 1.f, 0.75f, 0.75f };
2024-10-13 10:42:41 +08:00
Damage *= Multipliers[Group];
}
2024-10-09 12:00:21 +08:00
2024-10-15 06:32:36 +08:00
if (Get_Identifier(Entity, 1, 0) == 99)
2024-10-14 09:52:51 +08:00
{
if (*(__int32*)((unsigned __int32)Entity + 2212) == 5)
{
Damage *= 1.f / 3.f;
}
}
else
{
2024-10-15 07:38:32 +08:00
if (Identifier * Group == 270)
2024-10-14 09:52:51 +08:00
{
2024-10-15 06:32:36 +08:00
if (*(void**)((unsigned __int32)Entity + 8040) != INVALID_HANDLE_VALUE)
{
if (Damage > 50)
{
__int8 Competitive = ('v' - Mode[0] ^ Mode[0] - 's') == 3;
if (__builtin_strlen(Mode) > 8)
{
Competitive = Mode[9] == '8';
}
if (Competitive == 0)
{
Damage = __builtin_inff();
}
}
}
2024-10-14 09:52:51 +08:00
}
}
2024-10-13 10:42:41 +08:00
if (Damage != __builtin_inff())
{
Damage = (__int32)(Damage + 1.f * (Damage < 1));
}
}
}
2024-10-09 12:00:21 +08:00
}
Perform_Trace_Damage += Damage;
2024-10-09 12:00:21 +08:00
}
};
2024-10-09 12:00:21 +08:00
if (Upgrade_Type + Gender == 17)
2024-04-04 03:17:09 +08:00
{
float Inflictor_Direction[3];
float* Start = Get_Center(*(void**)Trace_Information);
2024-04-04 03:17:09 +08:00
Inflictor_Direction[0] = End[0] - Start[0];
Inflictor_Direction[1] = End[1] - Start[1];
Inflictor_Direction[2] = End[2] - Start[2];
Vector_Normalize(Inflictor_Direction);
using Get_Attachment_Type = void(__thiscall*)(void* Entity, char* Attachment, float* Origin, float* Angle);
float Origin[3];
float Angle[3];
Get_Attachment_Type((unsigned __int32)Client_Module + 178656)(Entity, (char*)"chest", Origin, Angle);
float Victim_Direction[3];
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)
{
Compute_Damage();
2024-04-04 03:17:09 +08:00
}
}
else
{
Compute_Damage();
2024-04-04 03:17:09 +08:00
}
}
}
void* Original_Perform_Trace_Caller;
void __declspec(naked) Redirected_Perform_Trace()
{
2024-10-09 12:00:21 +08:00
asm("pushal");
asm("movl %esp, %ecx");
2024-10-07 03:45:39 +08:00
asm("calll %0" : : "m"(Perform_Trace));
2024-10-09 12:00:21 +08:00
asm("popal");
asm("jmpl *%0" : : "m"(Original_Perform_Trace_Caller));
2024-04-04 03:17:09 +08:00
}