Improved bhop and auto-sticky
This commit is contained in:
parent
d9fb1807d7
commit
b022a74519
@ -45,7 +45,12 @@ void DrawCheatVisuals() {
|
||||
std::string name_s, reason_s;
|
||||
PROF_SECTION(PT_info_text);
|
||||
AddSideString("cathook by nullifiedcat", colors::RainbowCurrent());
|
||||
AddSideString(hack::GetVersion(), GUIColor());
|
||||
AddSideString(hack::GetVersion(), GUIColor()); // github commit and date
|
||||
AddSideString(hack::GetType(), GUIColor()); // Compile type
|
||||
#if ENABLE_GUI
|
||||
AddSideString("Press 'INSERT' or 'F11' key to open/close cheat menu.", GUIColor());
|
||||
AddSideString("Use mouse to navigate in menu.", GUIColor());
|
||||
#endif
|
||||
if (!g_IEngine->IsInGame()
|
||||
#if ENABLE_GUI
|
||||
|| g_pGUI->Visible()
|
||||
|
14
src/hack.cpp
14
src/hack.cpp
@ -59,10 +59,18 @@ const std::string& hack::GetVersion() {
|
||||
static std::string version("Unknown Version");
|
||||
static bool version_set = false;
|
||||
if (version_set) return version;
|
||||
version = "";
|
||||
#if defined(GIT_COMMIT_HASH) && defined(GIT_COMMIT_DATE)
|
||||
version += " Version: #" GIT_COMMIT_HASH " " GIT_COMMIT_DATE "\n";
|
||||
#if defined(GIT_COMMIT_HASH) && defined(GIT_COMMIT_DATE)
|
||||
version = "Version: #" GIT_COMMIT_HASH " " GIT_COMMIT_DATE;
|
||||
#endif
|
||||
version_set = true;
|
||||
return version;
|
||||
}
|
||||
|
||||
const std::string& hack::GetType() {
|
||||
static std::string version("Unknown Type");
|
||||
static bool version_set = false;
|
||||
if (version_set) return version;
|
||||
version = "";
|
||||
#if not defined(IPC_ENABLED)
|
||||
version += " NOIPC";
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@ void ExecuteCommand(const std::string command);
|
||||
extern bool shutdown;
|
||||
|
||||
const std::string& GetVersion();
|
||||
const std::string& GetType();
|
||||
void Initialize();
|
||||
void Think();
|
||||
void Shutdown();
|
||||
|
@ -357,7 +357,7 @@ bool IsTargetStateGood(CachedEntity* entity) {
|
||||
}
|
||||
// If settings allow, ignore taunting players
|
||||
if (ignore_taunting && HasCondition<TFCond_Taunting>(entity)) return false;
|
||||
// Dont target invulnerable players, ex: uder, bonk
|
||||
// Dont target invulnerable players, ex: uber, bonk
|
||||
if (IsPlayerInvulnerable(entity)) return false;
|
||||
// If settings allow, dont target cloaked players
|
||||
if (respect_cloak && IsPlayerInvisible(entity)) return false;
|
||||
|
@ -12,81 +12,140 @@
|
||||
|
||||
namespace hacks { namespace tf { namespace autosticky {
|
||||
|
||||
// Vars for user settings
|
||||
CatVar enabled(CV_SWITCH, "sticky_enabled", "0", "AutoSticky", "Master AutoSticky switch");
|
||||
CatVar buildings(CV_SWITCH, "sticky_buildings", "1", "Detonate buildings", "Stickies react to buildings");
|
||||
CatVar distance(CV_INT, "sticky_distance", "150", "Distance", "Maximum distance to detonate");
|
||||
CatVar visCheck(CV_SWITCH, "sticky_visable", "1", "Vis check", "Simple check to see if the sticky will hit someone");
|
||||
//CatVar legit(CV_SWITCH, "sticky_legit", "0", "Legit", "Stickys only detonate when you see them");
|
||||
CatVar legit(CV_SWITCH, "sticky_legit", "0", "Legit", "Stickys only detonate when you see them\nAlso ignores invis spies");
|
||||
|
||||
// A storage array for ents
|
||||
std::vector<CachedEntity*> bombs;
|
||||
std::vector<CachedEntity*> targets;
|
||||
|
||||
|
||||
// Function to tell when an ent is the local players own bomb
|
||||
bool IsBomb(CachedEntity* ent) {
|
||||
// Check if ent is a stickybomb
|
||||
if (ent->m_iClassID != CL_CLASS(CTFGrenadePipebombProjectile)) return false;
|
||||
if (CE_INT(ent, netvar.iPipeType) != 1) return false;
|
||||
|
||||
// Check if the stickybomb is the players own
|
||||
if ((CE_INT(ent, netvar.hThrower) & 0xFFF) != g_pLocalPlayer->entity->m_IDX) return false;
|
||||
|
||||
// Check passed, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function to check ent if it is a good target
|
||||
bool IsTarget(CachedEntity* ent) {
|
||||
// Check if target is The local player
|
||||
if (ent == LOCAL_E) return false;
|
||||
|
||||
// Check if target is an enemy
|
||||
if (!ent->m_bEnemy) return false;
|
||||
|
||||
// Player specific
|
||||
if (ent->m_Type == ENTITY_PLAYER) {
|
||||
if (CE_BYTE(ent, netvar.iLifeState)) return false;
|
||||
// Dont detonate on dead players
|
||||
if (!ent->m_bAlivePlayer) return false;
|
||||
// Dont detonate on friendly players
|
||||
if (playerlist::IsFriendly(playerlist::AccessData(ent).state)) return false;
|
||||
|
||||
IF_GAME (IsTF()) {
|
||||
// Dont target invulnerable players, ex: uber, bonk
|
||||
if (IsPlayerInvulnerable(ent)) return false;
|
||||
|
||||
// If settings allow, ignore taunting players
|
||||
//if (ignore_taunting && HasCondition<TFCond_Taunting>(ent)) return false;
|
||||
|
||||
// If settings allow, dont target cloaked players
|
||||
if (legit && IsPlayerInvisible(ent)) return false;
|
||||
}
|
||||
|
||||
// Target is good
|
||||
return true;
|
||||
|
||||
// Building specific
|
||||
} else if (ent->m_Type == ENTITY_BUILDING) {
|
||||
return buildings;
|
||||
}
|
||||
|
||||
// Target isnt a good type
|
||||
return false;
|
||||
}
|
||||
|
||||
bool stickyVisable(CachedEntity* targetTrace, CachedEntity* bombTrace) {
|
||||
trace_t trace;
|
||||
trace::filter_default.SetSelf(RAW_ENT(bombTrace));
|
||||
Ray_t ray;
|
||||
ray.Init(bombTrace->m_vecOrigin, RAW_ENT(targetTrace)->GetCollideable()->GetCollisionOrigin());
|
||||
{
|
||||
PROF_SECTION(IEVV_TraceRay);
|
||||
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace);
|
||||
}
|
||||
//deboog1 = bombTrace.DistToSqr(trace->endpos);
|
||||
if (trace.m_pEnt) {
|
||||
if ((((IClientEntity*)trace.m_pEnt)) == RAW_ENT(targetTrace)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Function called by game for movement
|
||||
void CreateMove() {
|
||||
// Check user settings if auto-sticky is enabled
|
||||
if (!enabled) return;
|
||||
|
||||
// Check if player is demoman
|
||||
if (g_pLocalPlayer->clazz != tf_demoman) return;
|
||||
|
||||
// Check for sticky jumper, which is item 265, if true, return
|
||||
if (HasWeapon(LOCAL_E, 265));
|
||||
|
||||
// Clear the arrays
|
||||
bombs.clear();
|
||||
targets.clear();
|
||||
|
||||
// Cycle through the ents and search for valid ents
|
||||
for (int i = 0; i < HIGHEST_ENTITY; i++) {
|
||||
// Assign the for loops tick number to an ent
|
||||
CachedEntity* ent = ENTITY(i);
|
||||
// Check for dormancy and if valid
|
||||
if (CE_BAD(ent)) continue;
|
||||
// Check if ent is a bomb or suitable target and push to respective arrays
|
||||
if (IsBomb(ent)) {
|
||||
bombs.push_back(ent);
|
||||
} else if (IsTarget(ent)) {
|
||||
targets.push_back(ent);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop once for every bomb in the array
|
||||
for (auto bomb : bombs) {
|
||||
// Loop through every target for a given bomb
|
||||
for (auto target : targets) {
|
||||
if (bomb->m_vecOrigin.DistToSqr(target->m_vecOrigin) < ((float)distance * (float)distance)) {
|
||||
if (visCheck) {
|
||||
if (stickyVisable(target, bomb)) {
|
||||
logging::Info("Det");
|
||||
g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
/*if (legit) {
|
||||
if (stickyVisable(g_pLocalPlayer->entity, bomb)) g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
} else g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
*/
|
||||
}
|
||||
} else g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
|
||||
return;
|
||||
// Check distance to the target to see if the sticky will hit
|
||||
if (bomb->m_vecOrigin.DistToSqr(target->m_vecOrigin) < 16900) {
|
||||
// Vis check the target from the bomb
|
||||
if (VisCheckEntFromEnt(bomb, target)) {
|
||||
// Check user settings if legit mode is off, if legit mode is off then detonate
|
||||
if (!legit) {
|
||||
// Check for scottish, id 130, if true then aim at bomb
|
||||
if (HasWeapon(LOCAL_E, 130)) {
|
||||
// Aim at bomb
|
||||
AimAt(g_pLocalPlayer->v_Eye, bomb->m_vecOrigin, g_pUserCmd);
|
||||
// Use silent
|
||||
g_pLocalPlayer->bUseSilentAngles = true;
|
||||
}
|
||||
|
||||
// Detonate
|
||||
g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
|
||||
// Return as its a waste to check anymore, we detonated and all the rest of the stickys are gone
|
||||
return;
|
||||
|
||||
// Since legit mode is on, check if the sticky can see the local player
|
||||
} else if (VisCheckEntFromEnt(bomb, LOCAL_E)) {
|
||||
// Check for scottish, id 130, if true then aim at bomb
|
||||
if (HasWeapon(LOCAL_E, 130)) {
|
||||
// Aim at bomb
|
||||
AimAt(g_pLocalPlayer->v_Eye, bomb->m_vecOrigin, g_pUserCmd);
|
||||
// Use silent
|
||||
g_pLocalPlayer->bUseSilentAngles = true;
|
||||
}
|
||||
|
||||
// Detonate
|
||||
g_pUserCmd->buttons |= IN_ATTACK2;
|
||||
|
||||
// Return as its a waste to check anymore, we detonated and all the rest of the stickys are gone
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of function, just return
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -12,32 +12,41 @@
|
||||
|
||||
namespace hacks { namespace shared { namespace bunnyhop {
|
||||
|
||||
// Var for user settings
|
||||
CatVar enabled(CV_SWITCH, "bhop_enabled", "0", "Bunnyhop", "Enable Bunnyhop. All extra features like autojump and perfect jump limit were temporary removed.");
|
||||
|
||||
int iTicksFlying { 0 };
|
||||
int iTicksLastJump { 0 };
|
||||
|
||||
int iTicksLastJump = 0;
|
||||
|
||||
// Function called by game for movement
|
||||
void CreateMove() {
|
||||
// Check user settings if bhop is enabled
|
||||
if (!enabled) return;
|
||||
|
||||
// Check if there is usercommands
|
||||
if (!g_pUserCmd->command_number) return;
|
||||
//if (HasCondition(g_pLocalPlayer->entity, TFCond_GrapplingHook)) return;
|
||||
|
||||
// Check if local player is airborne, if true then return
|
||||
//if (CE_INT(g_pLocalPlayer->entity, netvar.movetype) == MOVETYPE_FLY) return;
|
||||
|
||||
// Grab netvar for flags from the local player
|
||||
int flags = CE_INT(g_pLocalPlayer->entity, netvar.iFlags);
|
||||
|
||||
if (CE_INT(g_pLocalPlayer->entity, netvar.movetype) == MOVETYPE_FLY) return;
|
||||
|
||||
// var for "if on ground" from the flags netvar
|
||||
bool ground = (flags & (1 << 0));
|
||||
// Var for if the player is pressing jump
|
||||
bool jump = (g_pUserCmd->buttons & IN_JUMP);
|
||||
|
||||
if (ground) {
|
||||
iTicksFlying = 0;
|
||||
} else {
|
||||
iTicksFlying++;
|
||||
}
|
||||
|
||||
// Check if player is not on the ground and player is holding their jump key
|
||||
if (!ground && jump) {
|
||||
// If the ticks since last jump are greater or equal to 7, then force the player to stop jumping
|
||||
// The bot disables jump untill player hits the ground or lets go of jump
|
||||
if (iTicksLastJump++ >= 9) g_pUserCmd->buttons = g_pUserCmd->buttons &~ IN_JUMP;
|
||||
}
|
||||
|
||||
// If the players jump cmd has been used, then we reset our var
|
||||
if (!jump) iTicksLastJump = 0;
|
||||
|
||||
// Finish the function with return
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,14 +120,29 @@ powerup_type GetPowerupOnPlayer(CachedEntity* player) {
|
||||
return powerup_type::not_powerup;
|
||||
}
|
||||
|
||||
bool HasDarwins(CachedEntity* ent) {
|
||||
// A function to tell if a player is using a specific weapon
|
||||
bool HasWeapon(CachedEntity* ent, int wantedId) {
|
||||
// Create a var to store the handle
|
||||
int *hWeapons;
|
||||
if (CE_INT(ent, netvar.iClass) != tf_sniper) return false;
|
||||
// Grab the handle and store it into the var
|
||||
hWeapons = (int*)((unsigned)(RAW_ENT(ent) + netvar.hMyWeapons));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Go through the handle array and search for the item
|
||||
for (int i = 0; hWeapons[i]; i++) {
|
||||
// Get the weapon id from the handle array
|
||||
IClientEntity* weapon = g_IEntityList->GetClientEntityFromHandle(hWeapons[i]);
|
||||
if (weapon && NET_INT(weapon, netvar.iItemDefinitionIndex) == 231) return true;
|
||||
// if weapon is what we are looking for, return true
|
||||
if (weapon && NET_INT(weapon, netvar.iItemDefinitionIndex) == wantedId) return true;
|
||||
}
|
||||
// We didnt find the weapon we needed, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasDarwins(CachedEntity* ent) {
|
||||
// Check if player is sniper
|
||||
if (CE_INT(ent, netvar.iClass) != tf_sniper) return false;
|
||||
// Check if player is using darwins, 231 is the id for darwins danger sheild
|
||||
if (HasWeapon(ent, 231)) return true;
|
||||
// Else return false
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -301,6 +316,26 @@ bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos) {
|
||||
return (trace_object.fraction >= 0.99f || (((IClientEntity*)trace_object.m_pEnt)) == RAW_ENT(entity));
|
||||
}
|
||||
|
||||
bool VisCheckEntFromEnt(CachedEntity* startEnt, CachedEntity* endEnt) {
|
||||
// We setSelf as the starting ent as we dont want to hit it, we want the other ent
|
||||
trace_t trace;
|
||||
trace::filter_default.SetSelf(RAW_ENT(startEnt));
|
||||
|
||||
// Setup the trace starting with the origin of the starting ent attemting to hit the origin of the end ent
|
||||
Ray_t ray;
|
||||
ray.Init(startEnt->m_vecOrigin, endEnt->m_vecOrigin);
|
||||
{
|
||||
PROF_SECTION(IEVV_TraceRay);
|
||||
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace);
|
||||
}
|
||||
// Is the entity that we hit our target ent? if so, the vis check passes
|
||||
if (trace.m_pEnt) {
|
||||
if ((((IClientEntity*)trace.m_pEnt)) == RAW_ENT(endEnt)) return true;
|
||||
}
|
||||
// Since we didnt hit our target ent, the vis check failed so return false
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector GetBuildingPosition(CachedEntity* ent) {
|
||||
Vector res;
|
||||
res = ent->m_vecOrigin;
|
||||
|
@ -73,6 +73,7 @@ void VectorAngles(Vector &forward, Vector &angles);
|
||||
|
||||
bool IsEntityVisible(CachedEntity* entity, int hb);
|
||||
bool IsEntityVectorVisible(CachedEntity* entity, Vector endpos);
|
||||
bool VisCheckEntFromEnt(CachedEntity* startEnt, CachedEntity* endEnt);
|
||||
|
||||
bool LineIntersectsBox(Vector& bmin, Vector& bmax, Vector& lmin, Vector& lmax);
|
||||
|
||||
@ -84,6 +85,7 @@ bool IsVectorVisible(Vector a, Vector b);
|
||||
bool IsSentryBuster(CachedEntity* ent);
|
||||
char* strfmt(const char* fmt, ...);
|
||||
// TODO move that to weaponid.h
|
||||
bool HasWeapon(CachedEntity* ent, int wantedId);
|
||||
bool IsAmbassador(CachedEntity* ent);
|
||||
bool HasDarwins(CachedEntity* ent);
|
||||
bool AmbassadorCanHeadshot();
|
||||
|
Reference in New Issue
Block a user