Fix visual branch (#1673 but changed) (#1680)

Fix some visual issues and update c++/boost

Co-authored-by: Stephen Martin <stephenmartinemail2003@gmail.com>
Co-authored-by: Stephen Martin <93275421+STEVE4git@users.noreply.github.com>
This commit is contained in:
LightCat 2022-07-07 23:26:51 +02:00 committed by GitHub
parent 4ccdbc4f8f
commit e7d6c7797c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 88 additions and 202 deletions

2
.gitmodules vendored
View File

@ -24,4 +24,4 @@
url = https://github.com/nullworks/libnullnexus
[submodule "external/boost-cmake"]
path = external/boost-cmake
url = https://github.com/Orphis/boost-cmake.git
url = https://github.com/STEVE4git/boost-cmake.git

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.20)
set(EnablePrecompiledHeaders 1 CACHE BOOL "Enable Precompiled Headers to reduce compile time")
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
@ -23,7 +23,7 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_BUILD_TYPE_VALUES})
project(cathook VERSION 0.0.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
add_library(cathook SHARED "")
set(GameSpecific 1 CACHE BOOL "Build for specific target game (As opposed to universal, but slower, lib)")
@ -102,13 +102,13 @@ endif()
find_package(Git REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/external")
find_package(SDL2 REQUIRED)
SET (Boost_NO_SYSTEM_PATHS true)
find_package(Boost 1.71.0 EXACT)
find_package(Boost 1.76.0 EXACT)
if (NOT ${Boost_FOUND})
set(BOOST_LIBS_OPTIONAL "" CACHE STRING "Boost libs to be compiled")
add_subdirectory(external/boost-cmake)
SET (BOOST_ROOT ${CMAKE_BINARY_DIR}/_deps/boost-src)
find_package(Boost 1.71.0 EXACT REQUIRED)
find_package(Boost 1.76.0 EXACT)
include_directories(${Boost_INCLUDE_DIRS})
endif()
@ -162,11 +162,11 @@ configure_file(include/config.h.in ${CMAKE_SOURCE_DIR}/include/config.h @ONLY)
configure_file(include/version.h.in ${CMAKE_SOURCE_DIR}/include/version.h @ONLY)
set(CMAKE_CXX_FLAGS "-m32 -march=native -fexceptions -fno-gnu-unique -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-rdynamic -ggdb -Og")
set(CMAKE_CXX_FLAGS_DEBUG "-march=native -rdynamic -ggdb -Og")
if (Internal_Symbolized)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ggdb -fvisibility=hidden -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -ggdb -fvisibility=hidden -fvisibility-inlines-hidden")
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -s -fvisibility=hidden -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -s -fvisibility=hidden -fvisibility-inlines-hidden")
endif()
target_compile_definitions(cathook PRIVATE

4
attach
View File

@ -42,10 +42,6 @@ cp "bin/libcathook.so" "$FILENAME"
echo loading "$FILENAME" to "$proc"
gdbbin="gdb"
if [ -x "./bin/gdb-arch-2021-02" ]; then
gdbbin="./bin/gdb-arch-2021-02"
fi
$gdbbin -n -q -batch \
-ex "attach $proc" \
-ex "echo \033[1mCalling dlopen\033[0m\n" \

View File

@ -34,12 +34,7 @@ FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)"
cp "bin/libcathook.so" "$FILENAME"
echo loading "$FILENAME" to "$proc"
gdbbin="gdb"
if [ -x "./bin/gdb-arch-2021-02" ]; then
gdbbin="./bin/gdb-arch-2021-02"
fi
$gdbbin -n -q -batch \
-ex "attach $proc" \
-ex "echo \033[1mCalling dlopen\033[0m\n" \

View File

@ -45,10 +45,6 @@ sudo cp "bin/libcathook.so" "/lib/i386-linux-gnu/${FILENAME}"
echo loading "$FILENAME" to "$proc"
gdbbin="gdb"
if [ -x "./bin/gdb-arch-2021-02" ]; then
gdbbin="./bin/gdb-arch-2021-02"
fi
$gdbbin -n -q -batch \
-ex "attach $proc" \
-ex "echo \033[1mCalling dlopen\033[0m\n" \

View File

@ -45,6 +45,7 @@
<Option name="Distance (Highest)" value="4"/>
<Option name="Health (Lowest)" value="3"/>
<Option name="Health (Highest)" value="5"/>
<Option name="Fast" value="6"/>
</Select>
</LabeledObject>
<LabeledObject width="fill" label="Target team">
@ -84,14 +85,7 @@
</Select>
</LabeledObject>
<AutoVariable width="fill" target="aimbot.target.max-range" label="Max range" tooltip="Entities further than this distance will not be targeted. Measured in Hammer units."/>
<LabeledObject width="fill" label="Multipoint">
<Select target="aimbot.multipoint">
<Option name="Disabled" value="0"/>
<Option name="Small hitboxes" value="1"/>
<Option name="Medium hitboxes" value="2"/>
<Option name="Big hitboxes" value="3"/>
</Select>
</LabeledObject>
<AutoVariable width="fill" target="aimbot.multipoint" label="Multipoint"/>
<AutoVariable width="fill" target="aimbot.assistance.only" label="Assistance only" tooltip="Aimbot will only activate if your mouse has moved in the last half second."/>
<AutoVariable width="fill" target="aimbot.lock-target" label="Lock target" tooltip="Lock onto a target until they die or leave your FOV."/>
<AutoVariable width="fill" target="aimbot.target.ignore-non-rage" label="Rage only" tooltip="Only target players set to RAGE."/>

@ -1 +1 @@
Subproject commit 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
Subproject commit 402df1a95f40357f9f42431c20bae58ceeb97223

@ -1 +1 @@
Subproject commit ec9aaa1514eef4a9fc7406acc7dd3b0cea05161a
Subproject commit cda1b59ee670df5964e76e4050536e76f91fa644

View File

@ -38,17 +38,16 @@ void Reset();
// Stuff to make storing functions easy
bool isAiming();
CachedEntity *CurrentTarget();
bool ShouldAim();
CachedEntity *RetrieveBestTarget(bool aimkey_state);
bool IsTargetStateGood(CachedEntity *entity);
bool Aim(CachedEntity *entity);
void DoAutoshoot(CachedEntity *target = nullptr);
bool smallBoxChecker(CachedEntity* target_entity);
int notVisibleHitbox(CachedEntity *target, int preferred);
int autoHitbox(CachedEntity* target);
bool hitscanSpecialCases(CachedEntity* target_entity, int weapon_case);
bool projectileSpecialCases(CachedEntity* target_entity, int weapon_case);
int BestHitbox(CachedEntity *target);
bool isHitboxMedium(int hitbox);
int ClosestHitbox(CachedEntity *target);
void DoSlowAim(Vector &inputAngle);
bool UpdateAimkey();

View File

@ -12,7 +12,7 @@ namespace settings
template <> class Variable<float> : public ArithmeticVariable<float>
{
public:
~Variable<float>() override = default;
~Variable() override = default;
VariableType getType() override
{

View File

@ -23,7 +23,7 @@ namespace settings
template <> class Variable<rgba_t> : public VariableBase<rgba_t>
{
public:
~Variable<rgba_t>() override = default;
~Variable() override = default;
VariableType getType() override
{

View File

@ -93,7 +93,7 @@ template <typename T> class Variable
template <typename T> class ArithmeticVariable : public VariableBase<T>
{
public:
~ArithmeticVariable<T>() override = default;
~ArithmeticVariable() override = default;
explicit inline operator T() const
{

View File

@ -165,5 +165,3 @@ case "$OS" in
printf "\033[1;33m\nWarning! Automatic package installation is not supported!\n\033[0m"
;;
esac
# A lot of distro's shipped GDB is broken at this time
mkdir -p ./bin && curl -C - -o ./bin/gdb-arch-2021-02 https://nullworks.gitlab.io/cathook/cathook/gdb && chmod +x ./bin/gdb-arch-2021-02 || true

View File

@ -28,7 +28,7 @@ static settings::Int aimkey_mode{ "aimbot.aimkey.mode", "1" };
static settings::Boolean autoshoot{ "aimbot.autoshoot", "1" };
static settings::Boolean autoreload{ "aimbot.autoshoot.activate-heatmaker", "false" };
static settings::Boolean autoshoot_disguised{ "aimbot.autoshoot-disguised", "1" };
static settings::Int multipoint{ "aimbot.multipoint", "0" };
static settings::Boolean multipoint{ "aimbot.multipoint", "0" };
static settings::Int hitbox_mode{ "aimbot.hitbox-mode", "0" };
static settings::Float normal_fov{ "aimbot.fov", "0" };
static settings::Int priority_mode{ "aimbot.priority-mode", "0" };
@ -92,7 +92,7 @@ settings::Boolean engine_projpred{ "aimbot.debug.engine-pp", "1" };
int slow_aim;
float fov;
bool enable;
bool projectile_self_damage = false;
void spectatorUpdate()
{
switch (*specmode)
@ -164,23 +164,11 @@ std::vector<Vector> getValidHitpoints(CachedEntity *ent, int hitbox)
GenerateBoxVertices(origin, rotation, bboxmin, bboxmax, corners);
float shrink_size = 1;
switch (*multipoint)
{
// Shrink alot
case 1:
if (!isHitboxMedium(hitbox)) // hitbox should be chosen based on size.
shrink_size = 3;
break;
// Decently shrink
case 2:
shrink_size = 5;
break;
// Shrink very little (we still have to shrink a bit else we will wiff due to rotation)
case 3:
shrink_size = 10;
break;
default:
else
shrink_size = 6;
}
// Shrink positions by moving towards opposing corner
for (int i = 0; i < 8; i++)
@ -210,7 +198,23 @@ std::vector<Vector> getValidHitpoints(CachedEntity *ent, int hitbox)
return hitpoints;
}
bool isHitboxMedium(int hitbox)
{
switch (hitbox)
{
case 1:
case 2:
case 3:
case 4:
case 5:
return true;
default:
return false;
}
return false;
}
// Get the best point to aim at for a given hitbox
std::optional<Vector> getBestHitpoint(CachedEntity *ent, int hitbox)
{
@ -244,23 +248,6 @@ float stop_moving_time = 0;
// Used to make rapidfire not knock your enemies out of range
unsigned last_target_ignore_timer = 0;
int GetSentry()
{
for (int i = 1; i <= HIGHEST_ENTITY; i++)
{
CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent))
continue;
else if (ent->m_Type() != ENTITY_BUILDING || ent->m_iClassID() != CL_CLASS(CObjectSentrygun))
continue;
else if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != g_pLocalPlayer->entity_idx)
continue;
return i;
}
return -1;
}
settings::Boolean ignore_cloak{ "aimbot.target.ignore-cloaked-spies", "1" };
// Projectile info
bool projectile_mode{ false };
@ -451,6 +438,7 @@ static void CreateMove()
int weapon_case = g_pLocalPlayer->weapon()->m_iClassID();
if (projectileSpecialCases(target_last, weapon_case))
{
DoAutoshoot(target_last);
}
}
@ -459,7 +447,6 @@ static void CreateMove()
}
}
}
bool projectileSpecialCases(CachedEntity *target_entity, int weapon_case)
{
@ -559,13 +546,6 @@ bool hitscanSpecialCases(CachedEntity *target_entity, int weapon_case)
return false;
}
}
bool smallBoxChecker(CachedEntity *target_entity)
{
if (CE_BAD(target_entity) || !g_IEntityList->GetClientEntity(target_entity->m_IDX))
return false;
return true;
}
// Just hold m1 if we were aiming at something before and are in rapidfire
static void CreateMoveWarp()
{
@ -602,64 +582,6 @@ bool MouseMoving()
return false;
}
#endif
// The first check to see if the player should aim in the first place
bool ShouldAim()
{
// Checks should be in order: cheap -> expensive
// Check for +use
if (current_user_cmd->buttons & IN_USE)
return false;
// Check if using action slot item
else if (g_pLocalPlayer->using_action_slot_item)
return false;
// Using a forbidden weapon?
else if (g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFKnife) || CE_INT(LOCAL_W, netvar.iItemDefinitionIndex) == 237 || CE_INT(LOCAL_W, netvar.iItemDefinitionIndex) == 265)
return false;
// Carrying A building?
else if (CE_BYTE(g_pLocalPlayer->entity, netvar.m_bCarryingObject))
return false;
// Deadringer out?
else if (CE_BYTE(g_pLocalPlayer->entity, netvar.m_bFeignDeathReady))
return false;
else if (g_pLocalPlayer->holding_sapper)
return false;
// Is bonked?
else if (HasCondition<TFCond_Bonked>(g_pLocalPlayer->entity))
return false;
// Is taunting?
else if (HasCondition<TFCond_Taunting>(g_pLocalPlayer->entity))
return false;
// Is cloaked
else if (IsPlayerInvisible(g_pLocalPlayer->entity))
return false;
else if (LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun) && CE_INT(LOCAL_E, netvar.m_iAmmo + 4) == 0)
return false;
#if ENABLE_VISUALS
if (assistance_only && !MouseMoving())
return false;
#endif
switch (GetWeaponMode())
{
case weapon_hitscan:
break;
case weapon_melee:
break;
// Check we need to run projectile Aimbot code
case weapon_projectile:
if (!projectileAimbotRequired)
return false;
break;
// Check if player doesnt have a weapon usable by aimbot
default:
return false;
};
return true;
}
// Function to find a suitable target
CachedEntity *RetrieveBestTarget(bool aimkey_state)
{
@ -685,7 +607,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
if (!validateTickFOV(bt_tick))
continue;
hacks::tf2::backtrack::MoveToTick(bt_tick);
if (IsTargetStateGood(target_last) && smallBoxChecker(target_last) && Aim(target_last))
if (IsTargetStateGood(target_last) && Aim(target_last))
return target_last;
// Restore if bad target
hacks::tf2::backtrack::RestoreEntity(target_last->m_IDX);
@ -693,7 +615,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
}
// Check if previous target is still good
else if (!shouldbacktrack_cache && IsTargetStateGood(target_last) && smallBoxChecker(target_last) && Aim(target_last))
else if (!shouldbacktrack_cache && IsTargetStateGood(target_last) && Aim(target_last))
{
// If it is then return it again
return target_last;
@ -733,7 +655,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
if (!validateTickFOV(bt_tick))
continue;
hacks::tf2::backtrack::MoveToTick(bt_tick);
if (IsTargetStateGood(ent) && smallBoxChecker(ent) && Aim(ent))
if (IsTargetStateGood(ent) && Aim(ent))
{
isTargetGood = true;
temp_bt_tick = bt_tick;
@ -745,41 +667,46 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
}
else
{
if (IsTargetStateGood(ent) && smallBoxChecker(ent) && Aim(ent))
if (IsTargetStateGood(ent) && Aim(ent))
isTargetGood = true;
}
if (isTargetGood) // Melee mode straight up won't swing if the target is too far away. No need to prioritize based on distance. Just use whatever the user chooses.
{
switch ((int) priority_mode)
{
case 0: // Smart Priority
{
scr = GetScoreForEntity(ent);
break;
}
case 1: // Fov Priority
{
scr = 360.0f - calculated_data_array[ent->m_IDX].fov;
break;
}
case 3: // Health Priority (Lowest)
{
scr = 450.0f - ent->m_iHealth();
break;
}
case 4: // Distance Priority (Furthest Away)
{
scr = calculated_data_array[i].aim_position.DistTo(g_pLocalPlayer->v_Eye);
break;
}
case 5: // Health Priority (Highest)
{
scr = ent->m_iHealth() * 4;
break;
}
default:
break;
}
switch ((int) priority_mode)
{
case 0: // Smart Priority
{
scr = GetScoreForEntity(ent);
break;
}
case 1: // Fov Priority
{
scr = 360.0f - calculated_data_array[ent->m_IDX].fov;
break;
}
case 3: // Health Priority (Lowest)
{
scr = 450.0f - ent->m_iHealth();
break;
}
case 4: // Distance Priority (Furthest Away)
{
scr = calculated_data_array[i].aim_position.DistTo(g_pLocalPlayer->v_Eye);
break;
}
case 5: // Health Priority (Highest)
{
scr = ent->m_iHealth() * 4;
break;
}
case 6: // Fast
{
return ent;
}
default:
break;
}
// Crossbow logic
if (!ent->m_bEnemy() && ent->m_Type() == ENTITY_PLAYER && CE_GOOD(LOCAL_W) && LOCAL_W->m_iClassID() == CL_CLASS(CTFCrossbow))
{
@ -832,7 +759,7 @@ bool IsTargetStateGood(CachedEntity *entity)
// Distance
float targeting_range = EffectiveTargetingRange();
if (entity->m_flDistance()-40 > targeting_range && tickcount > hacks::shared::aimbot::last_target_ignore_timer) // m_flDistance includes the collision box. You have to subtract it (Should be the same for every model)
if (entity->m_flDistance() - 40 > targeting_range && tickcount > hacks::shared::aimbot::last_target_ignore_timer) // m_flDistance includes the collision box. You have to subtract it (Should be the same for every model)
return false;
// Rage only check
@ -937,7 +864,7 @@ bool IsTargetStateGood(CachedEntity *entity)
// Distance
else if (EffectiveTargetingRange())
{
if (entity->m_flDistance()-40 > EffectiveTargetingRange() && tickcount > hacks::shared::aimbot::last_target_ignore_timer)
if (entity->m_flDistance() - 40 > EffectiveTargetingRange() && tickcount > hacks::shared::aimbot::last_target_ignore_timer)
return false;
}
@ -982,7 +909,7 @@ bool IsTargetStateGood(CachedEntity *entity)
// Distance
float targeting_range = EffectiveTargetingRange();
if (entity->m_flDistance()-40 > targeting_range && tickcount > hacks::shared::aimbot::last_target_ignore_timer)
if (entity->m_flDistance() - 40 > targeting_range && tickcount > hacks::shared::aimbot::last_target_ignore_timer)
return false;
// Grab the prediction var
@ -1043,9 +970,10 @@ bool Aim(CachedEntity *entity)
// Get angles from eye to target
Vector is_it_good = PredictEntity(entity);
bool should_aim;
trace_t test_trace;
if (extrapolate || projectileAimbotRequired || entity->m_Type() != ENTITY_PLAYER)
{
should_aim = IsEntityVectorVisible(entity, is_it_good, true);
}
else
{
should_aim = IsEntityVectorVisible(entity, is_it_good, false);
@ -1054,10 +982,9 @@ bool Aim(CachedEntity *entity)
return false;
AimbotCalculatedData_s &cd = calculated_data_array[entity->m_IDX];
if (cd.fov > fov)
if (fov > 0 && cd.fov > fov)
return false;
Vector angles = GetAimAtAngles(g_pLocalPlayer->v_Eye, is_it_good, LOCAL_E);
// Slow aim
if (slow_aim)
DoSlowAim(angles);
@ -1149,7 +1076,7 @@ void DoAutoshoot(CachedEntity *target_entity)
// Ambassador check
else if (IsAmbassador(g_pLocalPlayer->weapon()))
else if (IsAmbassador(g_pLocalPlayer->weapon()))
{
// Check if ambasador can headshot
if (!AmbassadorCanHeadshot() && wait_for_charge)
@ -1233,9 +1160,7 @@ Vector PredictEntity(CachedEntity *entity)
{
std::pair<Vector, Vector> tmp_result;
tmp_result = BuildingPrediction(entity, GetBuildingPosition(entity), cur_proj_speed, cur_proj_grav, cur_proj_start_vel);
// Don't use the intial velocity compensated one in vischecks
result = tmp_result.second;
result = tmp_result.second; // Buildings don't have velocity but I'll keep it in nonetheless
}
else
{
@ -1383,7 +1308,6 @@ int BestHitbox(CachedEntity *target)
// Hitbox machine :b:roke
return -1;
}
// Function to find the closesnt hitbox to the crosshair for a given ent
int ClosestHitbox(CachedEntity *target)
{
@ -1585,4 +1509,4 @@ static InitRoutine EC(
#endif
});
} // namespace hacks::shared::aimbot
} // namespace hacks::shared::aimbot

View File

@ -1017,18 +1017,13 @@ std::mutex trace_lock;
bool IsEntityVectorVisible(CachedEntity *entity, Vector endpos, bool use_weapon_offset, unsigned int mask, trace_t *trace)
{
trace_t trace_object;
if (!trace)
trace = &trace_object;
Ray_t ray;
if (g_Settings.bInvalid)
return false;
if (entity == g_pLocalPlayer->entity)
return true;
if (CE_BAD(g_pLocalPlayer->entity))
return false;
if (CE_BAD(entity))
return false;
trace::filter_default.SetSelf(RAW_ENT(g_pLocalPlayer->entity));
Vector eye = g_pLocalPlayer->v_Eye;
// Adjust for weapon offsets if needed
@ -1037,7 +1032,6 @@ bool IsEntityVectorVisible(CachedEntity *entity, Vector endpos, bool use_weapon_
ray.Init(eye, endpos);
{
PROF_SECTION(IEVV_TraceRay);
std::lock_guard<std::mutex> lock(trace_lock);
if (!tcm || g_Settings.is_create_move)
g_ITrace->TraceRay(ray, mask, &trace::filter_default, trace);
}

View File

@ -140,11 +140,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs
current_user_cmd = cmd;
EC::run(EC::CreateMoveEarly);
IF_GAME(IsTF2C())
{
if (CE_GOOD(LOCAL_W) && minigun_jump && LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun))
CE_INT(LOCAL_W, netvar.iWeaponState) = 0;
}
ret = original::CreateMove(this_, input_sample_time, cmd);
if (!cmd)
@ -417,11 +412,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs
g_pLocalPlayer->UpdateEnd();
}
// PROF_END("CreateMove");
if (!(cmd->buttons & IN_ATTACK))
{
// LoadSavedState();
}
g_Settings.is_create_move = false;
if (nolerp)
{