-
Автор темы
- #1
Ребят, нужна помощь. В кратце: взял исходник ZamanWare и увидел что там не рабочий AutoWall.
Сел фиксить всё это и заодно немного перестроить логику RageBot.
Крашит игру с момента сканирования: FindTarget.
Не могу понять почему...
Кто знает - помогите, если не трудно
Сел фиксить всё это и заодно немного перестроить логику RageBot.
Код:
#include "../Cheat.h"
// lazy
float m_bestfov = 360.0f;
float m_bestdist = 8192.f;
float m_bestthreat = 0.f;
float m_bestPreviosDamage = 0.f;
float m_CurrentDamage = 0.f;
float m_bestEntDamage = 0.f;
Vector m_besthitbox = Vector( 0, 0, 0 );
Vector m_entityCheckHitbox = Vector(0, 0, 0);
Vector m_entityCheckHitboxBones = Vector(0, 0, 0);
Vector m_bestFoundedHitBox = Vector(0, 0, 0);
CBaseEntity* m_bestent = nullptr;
bool m_target = false;
bool DoAim = false;
int noRetarget = -1;
QAngle AimStepLastAngle;
std::unordered_map<int, std::vector<const char*>> hitboxes = {
{ HITBOX_HEAD, { "head_0" } },
{ HITBOX_NECK, { "neck_0" } },
{ HITBOX_PELVIS, { "pelvis" } },
{ HITBOX_SPINE, { "spine_0", "spine_1", "spine_2", "spine_3" } },
{ HITBOX_LEGS, { "leg_upper_L", "leg_upper_R", "leg_lower_L", "leg_lower_R", "ankle_L", "ankle_R" } },
{ HITBOX_ARMS, { "hand_L", "hand_R", "arm_upper_L", "arm_lower_L", "arm_upper_R", "arm_lower_R" } },
};
void CRageBot::Run()
{
if (!G::LocalPlayer->GetAlive() || !I::Engine->IsConnected())
return;
QAngle oldAngle;
I::Engine->GetViewAngles(oldAngle);
oldForward = G::UserCmd->forwardmove;
oldSideMove = G::UserCmd->sidemove;
G::BestTarget = -1;
if( !G::LocalPlayer->GetWeapon()->IsGun() || G::LocalPlayer->GetWeapon()->IsEmpty() )
return;
if (G::BestTarget != -1 && AutoWall->GetDamage(m_besthitbox) < MenuSettings.Ragebot.AutoWallDmg)
{
DropTarget();
}
if( G::BestTarget == -1 )
FindTarget();
if( MenuSettings.Ragebot.Hold && !G::PressedKeys[ MenuSettings.Ragebot.HoldKey ] )
return;
if( G::BestTarget != -1 && !G::LocalPlayer->GetWeapon()->IsReloading() && m_target )
GoToTarget();
if (G::BestTarget != -1 && MenuSettings.Ragebot.AutoWall && m_target)
{
//Autowall();
}
M::CorrectMovement(oldAngle, G::UserCmd, oldForward, oldSideMove);
}
// -> Функция не используется, пропускайте.
bool CRageBot::Autowall()
{
/*
float best_damage = 0.0f;
float autowall_damage = 0.0f;
int playerTarget = -1;
for (int i = 0; i <= I::Globals->maxClients; i++)
{
if (!EntityIsValid(i))
continue;
CBaseEntity* Entity = I::ClientEntList->GetClientEntity(i);
Vector vect = Entity->GetBonePosition(MenuSettings.Ragebot.Hitbox);
autowall_damage = AutoWall->GetDamage(vect);
if (autowall_damage >= MenuSettings.Ragebot.AutoWallDmg)
{
if (autowall_damage > best_damage)
{
best_damage = autowall_damage;
playerTarget = i;
float damage = MenuSettings.Ragebot.AutoWallDmg;
Bone bone;
GetBestBone(Entity, damage, bone);
m_besthitbox = Entity->GetBonePosition(bone);
G::UserCmd->buttons |= IN_ATTACK;
}
return true;
}
else
{
DropTarget();
return false;
}
if (Entity->m_visible == true || best_damage >= MenuSettings.Ragebot.AutoWallDmg)
{
float damage = MenuSettings.Ragebot.AutoWallDmg;
Bone bone;
GetBestBone(Entity, damage, bone);
m_besthitbox = Entity->GetBonePosition(bone);
bool auto_shoot = false;
bool can_shoot = true;
bool reloading = false;
auto weapon = G::LocalPlayer->GetWeapon();
float server_time = G::LocalPlayer->GetTickBase() * I::Globals->interval_per_tick;
float next_shot = weapon->GetNextPrimaryAttack() - server_time;
if (next_shot > 0)
can_shoot = false;
QAngle aim_angle = M::CalcAngle(G::LocalPlayer->GetEyePosition(), m_besthitbox);
aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
if (can_shoot)
{
if (MenuSettings.Ragebot.Aimstep)
{
auto_shoot = AimStep(aim_angle);
G::UserCmd->viewangles = aim_angle;
G::UserCmd->buttons |= IN_ATTACK;
}
else
{
auto_shoot = true;
G::UserCmd->viewangles = aim_angle;
G::UserCmd->buttons |= IN_ATTACK;
}
}
}
}
if (m_target)
{
float dmgSec = AutoWall->GetDamage(m_besthitbox);
if (dmgSec >= 0.15f || dmgSec >= 1.0f)
{
G::UserCmd->buttons |= IN_ATTACK;
return true;
}
}
*/
if (MenuSettings.Ragebot.AutoCrouch && G::BestTarget && m_target)
{
G::UserCmd->buttons |= IN_DUCK;
}
auto weapon = G::LocalPlayer->GetWeapon();
if (weapon->IsSniper() && G::BestTarget && m_target)
{
if (!G::LocalPlayer->IsScoped())
{
G::UserCmd->buttons |= IN_ZOOM;
}
}
return false;
}
void CRageBot::GetBestBone(CBaseEntity* entity, float& best_damage, Bone& best_bone)
{
best_bone = BONE_HEAD;
for (std::unordered_map<int, std::vector<const char*>>::iterator it = hitboxes.begin(); it != hitboxes.end(); it++)
{
std::vector<const char*> hitboxList = hitboxes[it->first];
for (std::vector<const char*>::iterator it2 = hitboxList.begin(); it2 != hitboxList.end(); it2++)
{
Bone bone = (Bone)entity->GetBoneByName( *it2 );
Vector vec_bone = entity->GetBonePosition(bone);
float damage = AutoWall->GetDamage(vec_bone);
if (damage > best_damage)
{
best_damage = damage;
best_bone = bone;
}
}
}
}
// может являться причиной вылета, но сомневаюсь.
void CRageBot::DropTarget()
{
if (G::BestTarget != -1 || m_target)
{
if (AutoWall->GetDamage(m_besthitbox) <= MenuSettings.Ragebot.AutoWallDmg)
{
CBaseEntity* Entity = I::ClientEntList->GetClientEntity(G::BestTarget);
noRetarget = Entity->GetIndex();
G::BestTarget = -1;
m_target = false;
m_bestent = nullptr;
m_besthitbox = Vector(0, 0, 0);
}
}
}
// на 50-60% является причиной вылета
Vector CRageBot::GetEntityBestHitbox(int i)
{
CBaseEntity* Entity = I::ClientEntList->GetClientEntity(i);
float damage = MenuSettings.Ragebot.AutoWallDmg;
Bone bone;
GetBestBone(Entity, damage, bone);
m_entityCheckHitbox = Entity->GetBonePosition(MenuSettings.Ragebot.Hitbox);
m_entityCheckHitboxBones = Entity->GetBonePosition(bone);
if (m_bestPreviosDamage == 0.f)
{
if (AutoWall->GetDamage(m_entityCheckHitbox) > MenuSettings.Ragebot.AutoWallDmg || AutoWall->GetDamage(m_entityCheckHitboxBones) > MenuSettings.Ragebot.AutoWallDmg)
{
if (m_bestPreviosDamage = AutoWall->GetDamage(m_entityCheckHitbox) > AutoWall->GetDamage(m_entityCheckHitboxBones))
{
DoAim = false;
m_besthitbox = m_entityCheckHitbox;
m_bestent = Entity;
return m_entityCheckHitbox;
}
else if (m_bestPreviosDamage = AutoWall->GetDamage(m_entityCheckHitboxBones) > AutoWall->GetDamage(m_entityCheckHitbox))
{
DoAim = false;
m_besthitbox = m_entityCheckHitboxBones;
m_bestent = Entity;
return m_entityCheckHitboxBones;
}
else
{
DoAim = false;
m_besthitbox = Vector(0, 0, 0);
return Vector(0, 0, 0);
}
}
}
else
{
if (AutoWall->GetDamage(m_entityCheckHitbox) > MenuSettings.Ragebot.AutoWallDmg || AutoWall->GetDamage(m_entityCheckHitboxBones) > MenuSettings.Ragebot.AutoWallDmg)
{
if (m_CurrentDamage = AutoWall->GetDamage(m_entityCheckHitbox) > AutoWall->GetDamage(m_entityCheckHitboxBones))
{
if (m_CurrentDamage > m_bestPreviosDamage)
{
DoAim = false;
m_besthitbox = m_entityCheckHitbox;
m_bestent = Entity;
m_bestPreviosDamage = m_CurrentDamage;
return m_entityCheckHitbox;
}
else
{
return m_besthitbox;
}
}
else if (m_CurrentDamage = AutoWall->GetDamage(m_entityCheckHitboxBones) > AutoWall->GetDamage(m_entityCheckHitbox))
{
if (m_CurrentDamage > m_bestPreviosDamage)
{
DoAim = false;
m_besthitbox = m_entityCheckHitboxBones;
m_bestent = Entity;
m_bestPreviosDamage = m_CurrentDamage;
return m_entityCheckHitboxBones;
}
else
{
return m_besthitbox;
}
}
else
{
DoAim = false;
m_besthitbox = Vector(0, 0, 0);
return Vector(0, 0, 0);
}
}
}
}
// Именно здесь, когда только-только появляются Entity нужных игроков, игра крашится
void CRageBot::FindTarget()
{
m_bestfov = MenuSettings.Ragebot.FOV;
m_bestdist = 8192.f;
m_bestthreat = 0.f;
m_besthitbox = Vector(0, 0, 0);
m_target = false;
m_bestent = nullptr;
for (int i = 0; i <= I::Globals->maxClients; i++)
{
if (!EntityIsValid(i))
{
continue;
} // это проходит без краша, так как не сканирует союзников. Здесь не крашит.
// отсюда начинается краш
m_bestFoundedHitBox = GetEntityBestHitbox(i);
if (m_bestFoundedHitBox == Vector(0, 0, 0))
{
continue;
}
//CBaseEntity* Entity = I::ClientEntList->GetClientEntity(i);
// Vector hitbox = Entity->GetBonePosition(MenuSettings.Ragebot.Hitbox);
QAngle viewAngles;
I::Engine->GetViewAngles(viewAngles);
float fov = M::GetFov(viewAngles, M::CalcAngle(G::LocalPlayer->GetEyePosition(), m_besthitbox));
if (fov < m_bestfov)
{
G::BestTarget = i;
if (MenuSettings.Ragebot.HitScanAll)
{
m_target = true;
}
else if (!MenuSettings.Ragebot.HitScanAll)
{
m_target = true;
}
else
{
m_bestfov = fov;
m_target = true;
}
}
}
}
void CRageBot::GoToTarget()
{
bool auto_shoot = false;
bool can_shoot = true;
bool reloading = false;
auto weapon = G::LocalPlayer->GetWeapon();
float server_time = G::LocalPlayer->GetTickBase() * I::Globals->interval_per_tick;
float next_shot = weapon->GetNextPrimaryAttack() - server_time;
if( next_shot > 0)
can_shoot = false;
QAngle aim_angle = M::CalcAngle( G::LocalPlayer->GetEyePosition(), m_besthitbox );
aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
if ( can_shoot )
{
if ( MenuSettings.Ragebot.Aimstep )
{
auto_shoot = AimStep( aim_angle );
//if ( auto_shoot )
//aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
G::UserCmd->viewangles = aim_angle;
}
else
{
auto_shoot = true;
//aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
G::UserCmd->viewangles = aim_angle;
}
}
if (!MenuSettings.Ragebot.Silent && MenuSettings.Ragebot.Enabled)
I::Engine->SetViewAngles(G::UserCmd->viewangles);
if( MenuSettings.Ragebot.AutoStop )
{
oldForward = 0;
oldSideMove = 0;
G::UserCmd->upmove = 0;
}
if( MenuSettings.Ragebot.AutoCrouch )
G::UserCmd->buttons |= IN_DUCK;
if (MenuSettings.Ragebot.AutoFire && (!MenuSettings.Ragebot.HitChance || G::LocalPlayer->GetWeapon()->ChanceToHit(MenuSettings.Ragebot.HitChanceAmt)) && m_target)
{
G::UserCmd->buttons |= IN_ATTACK;
}
if (weapon->IsSniper())
{
if (!G::LocalPlayer->IsScoped())
{
G::UserCmd->buttons &= ~IN_ATTACK;
G::UserCmd->buttons |= IN_ZOOM;
}
}
}
bool CRageBot::AimStep( QAngle& angle )
{
if ( !G::Aimbotting )
AimStepLastAngle = G::UserCmd->viewangles;
float fov = M::GetFov(AimStepLastAngle, angle);
G::Aimbotting = fov > MenuSettings.Ragebot.AimstepAmount;
if (!G::Aimbotting)
return true;
QAngle AimStepDelta = AimStepLastAngle - angle;
if (AimStepDelta.y < 0)
AimStepLastAngle.y += MenuSettings.Ragebot.AimstepAmount;
else
AimStepLastAngle.y -= MenuSettings.Ragebot.AimstepAmount;
AimStepLastAngle.x = angle.x;
angle = AimStepLastAngle;
return false;
}
bool CRageBot::GetHitbox( CBaseEntity* target, Hitbox* hitbox )
{
matrix3x4a_t matrix[ MAXSTUDIOBONES ];
if( !target->SetupBones( matrix, MAXSTUDIOBONES, BONE_USED_BY_HITBOX, 0 ) )
return false;
studiohdr_t *hdr = I::ModelInfo->GetStudioModel( target->GetModel() );
if( !hdr )
return false;
mstudiohitboxset_t *hitboxSet = hdr->pHitboxSet( target->GetHitboxSet() );
mstudiobbox_t *untransformedBox = hitboxSet->pHitbox( hitbox->hitbox );
Vector bbmin = untransformedBox->bbmin;
Vector bbmax = untransformedBox->bbmax;
if( untransformedBox->radius != -1.f )
{
bbmin -= Vector( untransformedBox->radius, untransformedBox->radius, untransformedBox->radius );
bbmax += Vector( untransformedBox->radius, untransformedBox->radius, untransformedBox->radius );
}
Vector points[] = { ( ( bbmin + bbmax ) * .5f ),
Vector( bbmin.x, bbmin.y, bbmin.z ),
Vector( bbmin.x, bbmax.y, bbmin.z ),
Vector( bbmax.x, bbmax.y, bbmin.z ),
Vector( bbmax.x, bbmin.y, bbmin.z ),
Vector( bbmax.x, bbmax.y, bbmax.z ),
Vector( bbmin.x, bbmax.y, bbmax.z ),
Vector( bbmin.x, bbmin.y, bbmax.z ),
Vector( bbmax.x, bbmin.y, bbmax.z ) };
for( int index = 0; index <= 8; ++index )
{
if( index != 0 )
points[ index ] = ( ( ( ( points[ index ] + points[ 0 ] ) * .5f ) + points[ index ] ) * .5f );
M::VectorTransform( points[ index ], matrix[ untransformedBox->bone ], hitbox->points[ index ] );
}
return true;
}
bool CRageBot::GetBestPoint( CBaseEntity* target, Hitbox* hitbox, BestPoint *point )
{
Vector center = hitbox->points[ 0 ];
if( hitbox->hitbox == HITBOX_HEAD )
{
Vector high = ( ( hitbox->points[ 3 ] + hitbox->points[ 5 ] ) * .5f );
float pitch = target->GetEyeAngles().x;
if( ( pitch > 0.f ) && ( pitch <= 89.f ) )
{
Vector height = ( ( ( high - hitbox->points[ 0 ] ) / 3 ) * 4 );
Vector new_height = ( hitbox->points[ 0 ] + ( height * ( pitch / 89.f ) ) );
hitbox->points[ 0 ] = new_height;
point->flags |= FL_HIGH;
}
else if( ( pitch < 292.5f ) && ( pitch >= 271.f ) )
{
hitbox->points[ 0 ] -= Vector( 0.f, 0.f, 1.f );
point->flags |= FL_LOW;
}
}
for( int index = 0; index <= 8; ++index )
{
int temp_damage = AutoWall->GetDamage( hitbox->points[ index ] );
if( ( point->dmg < temp_damage ) )
{
point->dmg = temp_damage;
point->point = hitbox->points[ index ];
point->index = index;
}
}
return ( point->dmg > MenuSettings.Ragebot.AutoWallDmg );
}
// goes through the above hitboxes and selects the best point on the target that will deal the most damage
bool CRageBot::BestAimPointAll( CBaseEntity* target, Vector& hitbox )
{
/*BestPoint aim_point;
for( int i = 0; i < 7; i++ )
{
Hitbox hitbox( hitboxes[ i ] );
GetHitbox( target, &hitbox );
if( !GetBestPoint( target, &hitbox, &aim_point ) )
continue;
}
if( aim_point.dmg > MenuSettings.Ragebot.AutoWallDmg )
{
hitbox = aim_point.point;
return true;
}
return false;*/
return true;
}
// checks multiple points inside the selected hitbox and picks the best point which will deal the most damage
bool CRageBot::BestAimPointHitbox( CBaseEntity* target, Vector& hitbox )
{
BestPoint aim_point;
int hitboxnum = 0;
switch( MenuSettings.Ragebot.Hitbox )
{
case 0:
hitboxnum = 3;
break;
case 1:
hitboxnum = 6;
break;
case 2:
case 3:
hitboxnum = 4;
break;
case 4:
hitboxnum = 7;
break;
case 5:
hitboxnum = 1;
break;
case 6:
hitboxnum = 0;
break;
default:
hitboxnum = 0;
break;
}
Hitbox hitboxx( hitboxnum );
GetHitbox( target, &hitboxx );
if( !GetBestPoint( target, &hitboxx, &aim_point ) )
return false;
if( MenuSettings.Ragebot.AutoWall && aim_point.dmg > MenuSettings.Ragebot.AutoWallDmg )
{
hitbox = aim_point.point;
return true;
}
else if (!MenuSettings.Ragebot.AutoWall && aim_point.dmg >= 0.25f)
{
hitbox = aim_point.point;
return true;
}
return false;
}
bool CRageBot::EntityIsValid( int i )
{
CBaseEntity* Entity = I::ClientEntList->GetClientEntity( i );
if( !Entity )
return false;
if( Entity == G::LocalPlayer )
return false;
if( !MenuSettings.Ragebot.FriendlyFire )
{
if( Entity->GetTeam() == G::LocalPlayer->GetTeam() )
return false;
}
if( Entity->GetDormant() )
return false;
if( Entity->GetImmune() )
return false;
if( Entity->GetHealth() <= 0 )
return false;
/*if( !MenuSettings.Ragebot.HitScanAll)
{
if( MenuSettings.Ragebot.AutoWallDmg > AutoWall->GetDamage( Entity->GetBonePosition( MenuSettings.Ragebot.Hitbox ) ) )
return false;
}
*/
return true;
}
Код:
#include "../Cheat.h"
// lazy
float m_bestfov = 360.0f;
float m_bestdist = 8192.f;
float m_bestthreat = 0.f;
Vector m_besthitbox = Vector( 0, 0, 0 );
CBaseEntity* m_bestent = nullptr;
bool m_target = false;
QAngle AimStepLastAngle;
std::unordered_map<int, std::vector<const char*>> hitboxes = {
{ HITBOX_HEAD, { "head_0" } },
{ HITBOX_NECK, { "neck_0" } },
{ HITBOX_PELVIS, { "pelvis" } },
{ HITBOX_SPINE, { "spine_0", "spine_1", "spine_2", "spine_3" } },
{ HITBOX_LEGS, { "leg_upper_L", "leg_upper_R", "leg_lower_L", "leg_lower_R", "ankle_L", "ankle_R" } },
{ HITBOX_ARMS, { "hand_L", "hand_R", "arm_upper_L", "arm_lower_L", "arm_upper_R", "arm_lower_R" } },
};
void CRageBot::Run()
{
if (!G::LocalPlayer->GetAlive() || !I::Engine->IsConnected())
return;
QAngle oldAngle;
I::Engine->GetViewAngles(oldAngle);
oldForward = G::UserCmd->forwardmove;
oldSideMove = G::UserCmd->sidemove;
G::BestTarget = -1;
if( !G::LocalPlayer->GetWeapon()->IsGun() || G::LocalPlayer->GetWeapon()->IsEmpty() )
return;
if( G::BestTarget == -1 )
FindTarget();
if( MenuSettings.Ragebot.Hold && !G::PressedKeys[ MenuSettings.Ragebot.HoldKey ] )
return;
if( G::BestTarget != -1 && !G::LocalPlayer->GetWeapon()->IsReloading() && m_target )
GoToTarget();
M::CorrectMovement(oldAngle, G::UserCmd, oldForward, oldSideMove);
}
void CRageBot::GetBestBone(CBaseEntity* entity, float& best_damage, Bone& best_bone)
{
best_bone = BONE_HEAD;
for (std::unordered_map<int, std::vector<const char*>>::iterator it = hitboxes.begin(); it != hitboxes.end(); it++)
{
std::vector<const char*> hitboxList = hitboxes[it->first];
for (std::vector<const char*>::iterator it2 = hitboxList.begin(); it2 != hitboxList.end(); it2++)
{
Bone bone = (Bone)entity->GetBoneByName( *it2 );
Vector vec_bone = entity->GetBonePosition(bone);
float damage = AutoWall->GetDamage(vec_bone);
if (damage > best_damage)
{
best_damage = damage;
best_bone = bone;
}
}
}
}
void CRageBot::FindTarget()
{
m_bestfov = MenuSettings.Ragebot.FOV;
m_bestdist = 8192.f;
m_bestthreat = 0.f;
m_besthitbox = Vector(0, 0, 0);
m_target = false;
m_bestent = nullptr;
for (int i = 0; i <= I::Globals->maxClients; i++)
{
if (!EntityIsValid(i))
continue;
CBaseEntity* Entity = I::ClientEntList->GetClientEntity(i);
Vector hitbox = Entity->GetBonePosition(MenuSettings.Ragebot.Hitbox);
QAngle viewAngles;
I::Engine->GetViewAngles(viewAngles);
float fov = M::GetFov(viewAngles, M::CalcAngle(G::LocalPlayer->GetEyePosition(), hitbox));
if (fov < m_bestfov)
{
G::BestTarget = i;
if (MenuSettings.Ragebot.HitScanAll)
{
//if( BestAimPointAll( Entity, m_besthitbox ) )
// m_target = true;
float damage = 0.0f;
Bone bone;
GetBestBone(Entity, damage, bone);
if (damage >= MenuSettings.Ragebot.AutoWallDmg)
{
m_bestent = Entity;
m_besthitbox = Entity->GetBonePosition(bone);
m_target = true;
}
}
else if (!MenuSettings.Ragebot.HitScanAll)
{
if (BestAimPointHitbox(Entity, m_besthitbox))
m_target = true;
}
else
{
m_bestent = Entity;
m_bestfov = fov;
m_besthitbox = hitbox;
m_target = true;
}
}
}
}
void CRageBot::GoToTarget()
{
bool auto_shoot = false;
bool can_shoot = true;
bool reloading = false;
auto weapon = G::LocalPlayer->GetWeapon();
float server_time = G::LocalPlayer->GetTickBase() * I::Globals->interval_per_tick;
float next_shot = weapon->GetNextPrimaryAttack() - server_time;
if( next_shot > 0)
can_shoot = false;
QAngle aim_angle = M::CalcAngle( G::LocalPlayer->GetEyePosition(), m_besthitbox );
aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
if ( can_shoot )
{
if ( MenuSettings.Ragebot.Aimstep )
{
auto_shoot = AimStep( aim_angle );
//if ( auto_shoot )
//aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
G::UserCmd->viewangles = aim_angle;
}
else
{
auto_shoot = true;
//aim_angle -= G::LocalPlayer->GetPunch() * 2.f;
G::UserCmd->viewangles = aim_angle;
}
}
if (!MenuSettings.Ragebot.Silent && MenuSettings.Ragebot.Enabled)
I::Engine->SetViewAngles(G::UserCmd->viewangles);
if( MenuSettings.Ragebot.AutoStop )
{
oldForward = 0;
oldSideMove = 0;
G::UserCmd->upmove = 0;
}
if( MenuSettings.Ragebot.AutoCrouch )
G::UserCmd->buttons |= IN_DUCK;
if( auto_shoot && can_shoot && MenuSettings.Ragebot.AutoFire && ( !MenuSettings.Ragebot.HitChance || G::LocalPlayer->GetWeapon()->ChanceToHit(MenuSettings.Ragebot.HitChanceAmt)))
G::UserCmd->buttons |= IN_ATTACK;
if (weapon->IsSniper())
{
if (!G::LocalPlayer->IsScoped())
{
G::UserCmd->buttons &= ~IN_ATTACK;
G::UserCmd->buttons |= IN_ZOOM;
}
}
}
bool CRageBot::AimStep( QAngle& angle )
{
if ( !G::Aimbotting )
AimStepLastAngle = G::UserCmd->viewangles;
float fov = M::GetFov(AimStepLastAngle, angle);
G::Aimbotting = fov > MenuSettings.Ragebot.AimstepAmount;
if (!G::Aimbotting)
return true;
QAngle AimStepDelta = AimStepLastAngle - angle;
if (AimStepDelta.y < 0)
AimStepLastAngle.y += MenuSettings.Ragebot.AimstepAmount;
else
AimStepLastAngle.y -= MenuSettings.Ragebot.AimstepAmount;
AimStepLastAngle.x = angle.x;
angle = AimStepLastAngle;
return false;
}
bool CRageBot::GetHitbox( CBaseEntity* target, Hitbox* hitbox )
{
matrix3x4a_t matrix[ MAXSTUDIOBONES ];
if( !target->SetupBones( matrix, MAXSTUDIOBONES, BONE_USED_BY_HITBOX, 0 ) )
return false;
studiohdr_t *hdr = I::ModelInfo->GetStudioModel( target->GetModel() );
if( !hdr )
return false;
mstudiohitboxset_t *hitboxSet = hdr->pHitboxSet( target->GetHitboxSet() );
mstudiobbox_t *untransformedBox = hitboxSet->pHitbox( hitbox->hitbox );
Vector bbmin = untransformedBox->bbmin;
Vector bbmax = untransformedBox->bbmax;
if( untransformedBox->radius != -1.f )
{
bbmin -= Vector( untransformedBox->radius, untransformedBox->radius, untransformedBox->radius );
bbmax += Vector( untransformedBox->radius, untransformedBox->radius, untransformedBox->radius );
}
Vector points[] = { ( ( bbmin + bbmax ) * .5f ),
Vector( bbmin.x, bbmin.y, bbmin.z ),
Vector( bbmin.x, bbmax.y, bbmin.z ),
Vector( bbmax.x, bbmax.y, bbmin.z ),
Vector( bbmax.x, bbmin.y, bbmin.z ),
Vector( bbmax.x, bbmax.y, bbmax.z ),
Vector( bbmin.x, bbmax.y, bbmax.z ),
Vector( bbmin.x, bbmin.y, bbmax.z ),
Vector( bbmax.x, bbmin.y, bbmax.z ) };
for( int index = 0; index <= 8; ++index )
{
if( index != 0 )
points[ index ] = ( ( ( ( points[ index ] + points[ 0 ] ) * .5f ) + points[ index ] ) * .5f );
M::VectorTransform( points[ index ], matrix[ untransformedBox->bone ], hitbox->points[ index ] );
}
return true;
}
bool CRageBot::GetBestPoint( CBaseEntity* target, Hitbox* hitbox, BestPoint *point )
{
Vector center = hitbox->points[ 0 ];
if( hitbox->hitbox == HITBOX_HEAD )
{
Vector high = ( ( hitbox->points[ 3 ] + hitbox->points[ 5 ] ) * .5f );
float pitch = target->GetEyeAngles().x;
if( ( pitch > 0.f ) && ( pitch <= 89.f ) )
{
Vector height = ( ( ( high - hitbox->points[ 0 ] ) / 3 ) * 4 );
Vector new_height = ( hitbox->points[ 0 ] + ( height * ( pitch / 89.f ) ) );
hitbox->points[ 0 ] = new_height;
point->flags |= FL_HIGH;
}
else if( ( pitch < 292.5f ) && ( pitch >= 271.f ) )
{
hitbox->points[ 0 ] -= Vector( 0.f, 0.f, 1.f );
point->flags |= FL_LOW;
}
}
for( int index = 0; index <= 8; ++index )
{
int temp_damage = AutoWall->GetDamage( hitbox->points[ index ] );
if( ( point->dmg < temp_damage ) )
{
point->dmg = temp_damage;
point->point = hitbox->points[ index ];
point->index = index;
}
}
return ( point->dmg > MenuSettings.Ragebot.AutoWallDmg );
}
// goes through the above hitboxes and selects the best point on the target that will deal the most damage
bool CRageBot::BestAimPointAll( CBaseEntity* target, Vector& hitbox )
{
/*BestPoint aim_point;
for( int i = 0; i < 7; i++ )
{
Hitbox hitbox( hitboxes[ i ] );
GetHitbox( target, &hitbox );
if( !GetBestPoint( target, &hitbox, &aim_point ) )
continue;
}
if( aim_point.dmg > MenuSettings.Ragebot.AutoWallDmg )
{
hitbox = aim_point.point;
return true;
}
return false;*/
return true;
}
// checks multiple points inside the selected hitbox and picks the best point which will deal the most damage
bool CRageBot::BestAimPointHitbox( CBaseEntity* target, Vector& hitbox )
{
BestPoint aim_point;
int hitboxnum = 0;
switch( MenuSettings.Ragebot.Hitbox )
{
case 0:
hitboxnum = 3;
break;
case 1:
hitboxnum = 6;
break;
case 2:
case 3:
hitboxnum = 4;
break;
case 4:
hitboxnum = 7;
break;
case 5:
hitboxnum = 1;
break;
case 6:
hitboxnum = 0;
break;
default:
hitboxnum = 0;
break;
}
Hitbox hitboxx( hitboxnum );
GetHitbox( target, &hitboxx );
if( !GetBestPoint( target, &hitboxx, &aim_point ) )
return false;
if( aim_point.dmg > MenuSettings.Ragebot.AutoWallDmg )
{
hitbox = aim_point.point;
return true;
}
return false;
}
bool CRageBot::EntityIsValid( int i )
{
CBaseEntity* Entity = I::ClientEntList->GetClientEntity( i );
if( !Entity )
return false;
if( Entity == G::LocalPlayer )
return false;
if( !MenuSettings.Ragebot.FriendlyFire )
{
if( Entity->GetTeam() == G::LocalPlayer->GetTeam() )
return false;
}
if( Entity->GetDormant() )
return false;
if( Entity->GetImmune() )
return false;
if( Entity->GetHealth() <= 0 )
return false;
if( !MenuSettings.Ragebot.HitScanAll)
{
if( MenuSettings.Ragebot.AutoWallDmg > AutoWall->GetDamage( Entity->GetBonePosition( MenuSettings.Ragebot.Hitbox ) ) )
return false;
}
return true;
}
Не могу понять почему...
Кто знает - помогите, если не трудно
Последнее редактирование: