2024-04-04 03:17:09 +08:00
|
|
|
void* Perform_Trace_Target;
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
float Perform_Trace_Damage;
|
|
|
|
|
2024-04-04 03:17:09 +08:00
|
|
|
void __thiscall Perform_Trace(void* Stack)
|
|
|
|
{
|
|
|
|
void* Entity = *(void**)((unsigned __int32)Stack + 312);
|
|
|
|
|
2024-10-07 03:45:39 +08:00
|
|
|
if (Interface_Penetrate_Teammates.Integer == 0)
|
|
|
|
{
|
|
|
|
if (Get_Identifier(Entity, 0, 0) == 232)
|
|
|
|
{
|
|
|
|
void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712);
|
|
|
|
|
|
|
|
if (*(__int32*)((unsigned __int32)Entity + 228) == *(__int32*)((unsigned __int32)Local_Player + 228))
|
|
|
|
{
|
2024-10-08 09:41:25 +08:00
|
|
|
return;
|
2024-10-07 03:45:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-12 10:19:00 +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);
|
|
|
|
|
2024-10-08 09:41:25 +08:00
|
|
|
if (Interface_Aim_Intersection.Integer == 0)
|
|
|
|
{
|
2024-10-09 12:00:21 +08:00
|
|
|
if (Group != 1)
|
2024-10-08 09:41:25 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-04 03:17:09 +08:00
|
|
|
void* Trace_Information = *(void**)((unsigned __int32)Stack + 36);
|
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
void* Weapon_Data = *(void**)((unsigned __int32)Trace_Information + 4);
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
float* End = (float*)((unsigned __int32)Stack + 248);
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
__int32 Upgrade_Type = (*(__int32*)((unsigned __int32)Trace_Information + 36) & 255) % 5;
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
__int32 Gender = *(__int32*)((unsigned __int32)Entity + 52);
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
auto Compute_Damage = [&]() -> void
|
|
|
|
{
|
|
|
|
if (Interface_Penetration_Damage.Integer == 0)
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
Perform_Trace_Damage = 1;
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
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");
|
2024-10-12 10:19:00 +08:00
|
|
|
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);
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__int32 Identifier = Get_Identifier(Entity, 1, 0);
|
|
|
|
|
|
|
|
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-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
__int8 Realism = Mode[0] == 'r';
|
2024-10-12 10:19:00 +08:00
|
|
|
|
|
|
|
auto Apply_Shotgun_Scaling = [&]() -> void
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
if (Is_Shotgun == 1)
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
__int8 Casual_Mode = 1;
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
char* Mode = *(char**)((unsigned __int32)Client_Module + 8145092);
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
if (__builtin_strlen(Mode) > 8)
|
|
|
|
{
|
|
|
|
Casual_Mode = (Mode[8] != '8') + (Mode[9] != '2');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Casual_Mode += Realism ^ 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Casual_Mode == 2)
|
|
|
|
{
|
|
|
|
using Get_Bounds_Type = void(__thiscall*)(void* Collision, float* Start, float* Bounds);
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
using Get_Center_Type = float* (__thiscall*)(void* Entity);
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
void* Local_Player = *(void**)Trace_Information;
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
float Bounds[3];
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
Get_Bounds_Type((unsigned __int32)Client_Module + 878528)((void*)((unsigned __int32)Entity + 540), Get_Center_Type((unsigned __int32)Client_Module + 114400)(Local_Player), Bounds);
|
2024-10-12 10:19:00 +08:00
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
Damage += (4.f * Damage) * __builtin_powf(1.f - Distance / 100.f, 2);
|
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
if (Identifier == 277)
|
|
|
|
{
|
|
|
|
if (Group != 1)
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
|
|
|
Apply_Difficulty_Scaling();
|
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
|
|
|
|
Apply_Shotgun_Scaling();
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
else
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
2024-10-12 10:19:00 +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
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
Damage = __builtin_inff();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
Apply_Shotgun_Scaling();
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
__int8 Is_Sniper_Rifle = (Bullet_Type - 8) > 0;
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
if (Group == 1)
|
|
|
|
{
|
|
|
|
if (Gender == 14)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
auto Is_Neutral = [&]() -> __int8
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
__int32 Sequence_Activity = *(__int32*)((unsigned __int32)Entity + 4688);
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
unsigned __int32 Absolute_Sequence_Activity = Sequence_Activity - 563;
|
2024-10-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
if (Absolute_Sequence_Activity <= 29)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
return (536870929 & (1 << (Absolute_Sequence_Activity & 31))) != 0;
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
2024-10-13 10:42:41 +08:00
|
|
|
|
|
|
|
return (Sequence_Activity == 600) + (Sequence_Activity == 648);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (Is_Neutral() == 1)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
Damage = __builtin_inff();
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2024-10-09 12:00:21 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
if (Gender != 17)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
|
|
|
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-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
if ((Bullet_Type == 2) + Is_Sniper_Rifle != 0)
|
|
|
|
{
|
|
|
|
if (Gender == 14)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
if (Is_Sniper_Rifle * Realism == 0)
|
2024-10-12 10:19:00 +08:00
|
|
|
{
|
|
|
|
Damage = 450;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-10-13 10:42:41 +08:00
|
|
|
Damage = __builtin_inff();
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-10-12 10:19:00 +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-12 10:19:00 +08:00
|
|
|
{
|
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-12 10:19:00 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
Damage *= Multipliers[Group];
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-13 10:42:41 +08:00
|
|
|
//CTerrorPlayer::OnTakeDamage
|
|
|
|
//"AI controlled Chargers take 66% less damage while charging." (CTerrorPlayer::IsCustomAbilityActive)
|
|
|
|
|
|
|
|
if (Damage != __builtin_inff())
|
|
|
|
{
|
|
|
|
Damage = (__int32)(Damage + 1.f * (Damage < 1));
|
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
Perform_Trace_Damage += Damage;
|
2024-10-09 12:00:21 +08:00
|
|
|
}
|
2024-10-12 10:19:00 +08:00
|
|
|
};
|
2024-10-09 12:00:21 +08:00
|
|
|
|
2024-10-12 10:19:00 +08:00
|
|
|
if (Upgrade_Type + Gender == 17)
|
2024-04-04 03:17:09 +08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
Compute_Damage();
|
2024-04-04 03:17:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-10-12 10:19:00 +08:00
|
|
|
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
|
|
|
}
|