This commit is contained in:
nullifiedcat 2016-11-21 18:30:02 +03:00
parent 0692a7133b
commit 633acd528c
21 changed files with 363 additions and 156 deletions

View File

@ -21,6 +21,10 @@ Aimbot charge detection respect powerups
ignore taunt
Followbot medic AI+
Flash uber bots
CritTrigger
CritAim

View File

@ -34,6 +34,7 @@ void EntityVariables::Init() {
this->bGlowEnabled = gNetvars.get_offset("DT_TFPlayer", "m_bGlowEnabled");
this->iReloadMode = gNetvars.get_offset("DT_TFWeaponBase", "m_iReloadMode");
this->iMaxHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxHealth");
this->iMaxBuffedHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxBuffedHealth");
this->flNextAttack = gNetvars.get_offset("DT_BaseCombatCharacter", "bcc_localdata", "m_flNextAttack");
this->iNextMeleeCrit = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_iNextMeleeCrit");
this->iDecapitations = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_iDecapitations");

View File

@ -63,6 +63,7 @@ public:
offset_t flObservedCritChance;
offset_t nTickBase;
offset_t iDecapitations;
offset_t iMaxBuffedHealth;
};
// TODO globals

View File

@ -145,10 +145,6 @@ enum pack_type {
PACK_COUNT
};
enum entities {
E_PLAYER = 241
};
enum ClassID {
CTFWearableLevelableItem = 326,
CTFWearableDemoShield = 324,

View File

@ -21,6 +21,23 @@
#include <convar.h>
#include <client_class.h>
bool IsReflectableProjectile(IClientEntity* ent) {
if (!ent) return false;
switch (ent->GetClientClass()->m_ClassID) {
case ClassID::CTFProjectile_Arrow:
case ClassID::CTFProjectile_Cleaver:
case ClassID::CTFProjectile_Flare:
case ClassID::CTFProjectile_HealingBolt:
case ClassID::CTFProjectile_Jar:
case ClassID::CTFProjectile_JarMilk:
case ClassID::CTFProjectile_Rocket:
case ClassID::CTFProjectile_SentryRocket:
case ClassID::CTFGrenadePipebombProjectile:
return true;
}
return false;
}
// Hack Methods
void AutoReflect::Create() {
@ -30,8 +47,7 @@ void AutoReflect::Create() {
// TODO
bool AutoReflect::CreateMove(void*, float, CUserCmd* cmd) {
if (!v_bEnabled->GetBool()) return true;
if (g_pLocalPlayer->weapon->GetClientClass()->m_ClassID != ClassID::CTFFlameThrower) return true;
if (g_pLocalPlayer->weapon && g_pLocalPlayer->weapon->GetClientClass()->m_ClassID != ClassID::CTFFlameThrower) return true;
CachedEntity* closest = 0;
float closest_dist = 0.0f;
@ -39,8 +55,7 @@ bool AutoReflect::CreateMove(void*, float, CUserCmd* cmd) {
for (int i = 0; i < gEntityCache.m_nMax; i++) {
CachedEntity* ent = gEntityCache.GetEntity(i);
if (!ent || ent->m_bNULL || ent->m_bDormant) continue;
if (ent->m_iClassID != ClassID::CTFProjectile_Rocket &&
ent->m_iClassID != ClassID::CTFGrenadePipebombProjectile) continue;
if (!IsReflectableProjectile(ent->m_pEntity)) continue;
if (ent->Var<int>(eoffsets.iTeamNum) == g_pLocalPlayer->team) continue;
float dist = ent->m_pEntity->GetAbsOrigin().DistToSqr(g_pLocalPlayer->v_Origin);
if (dist < closest_dist || !closest) {

View File

@ -10,6 +10,10 @@
#include "IHack.h"
class IClientEntity;
bool IsReflectableProjectile(IClientEntity* ent);
class AutoReflect : public IHack {
public:
DECLARE_HACK()

View File

@ -13,6 +13,8 @@
#include "../localplayer.h"
#include "../logging.h"
#include "../usercmd.h"
#include "../playerresource.h"
#include "../sdk/in_buttons.h"
#include "../fixsdk.h"
#include <icliententity.h>
@ -54,11 +56,24 @@ class MedicCallListener : public IGameEventListener2 {
public:
MedicCallListener() {}
void FireGameEvent(IGameEvent* pEvent) {
if (!g_phFollowBot->v_bEnabled->GetBool()) return;
if (strcmp("player_calledformedic", pEvent->GetName())) return;
int id = interfaces::engineClient->GetPlayerForUserID(pEvent->GetInt("userid", -1));
logging::Info("%i called for medic");
player_info_s info;
interfaces::engineClient->GetPlayerInfo(id, &info);
if (info.friendsID == g_phFollowBot->m_nOwnerID) {
g_phFollowBot->m_iShouldUbercharge = 1;
}
}
};
void CC_ResetList(const CCommand& args) {
g_phFollowBot->ResetBotList();
}
MedicCallListener* g_pListener;
void FollowBot::ProcessEntity(IClientEntity* entity, bool enemy) {
IClientEntity* target = GetTarget();
@ -108,21 +123,6 @@ void FollowBot::ProcessEntity(IClientEntity* entity, bool enemy) {
}
}
void AimAt(IClientEntity* entity, CUserCmd* cmd) {
Vector hit;
Vector angles;
if (GetHitboxPosition(entity, 4, hit)) return;
Vector tr = (hit - g_pLocalPlayer->v_Eye);
fVectorAngles(tr, angles);
fClampAngle(angles);
cmd->viewangles = angles;
QAngle a;
a.x = angles.x;
a.y = angles.y;
a.z = angles.z;
interfaces::engineClient->SetViewAngles(a);
}
/*
* pick target
* if can't pick target:
@ -134,7 +134,7 @@ void AimAt(IClientEntity* entity, CUserCmd* cmd) {
* shoot
*/
int FollowBot::ShouldTarget(IClientEntity* ent, bool notrace) {
int FollowBot::ShouldNotTarget(IClientEntity* ent, bool notrace) {
if (!ent || ent->IsDormant()) return 1;
if (ent->GetClientClass()->m_ClassID != 241) return 2;
if (GetEntityValue<char>(ent, eoffsets.iLifeState)) return 3;
@ -142,7 +142,7 @@ int FollowBot::ShouldTarget(IClientEntity* ent, bool notrace) {
if (enemy) {
if (IsPlayerInvulnerable(ent)) return 4;
}
if (DistToSqr(ent) > (v_iMaxDistance->GetInt() * v_iMaxDistance->GetInt())) return 5;
if (!notrace) {
bool a = false;
for (int i = 0; i < 17; i++) {
@ -151,7 +151,15 @@ int FollowBot::ShouldTarget(IClientEntity* ent, bool notrace) {
if (!a) return 6;
}
if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return 7;
if (v_bMediBot->GetBool()) {
if (!this->IsOwner(ent)) {
return 7;
}
} else {
if (DistToSqr(ent) > (v_iMaxDistance->GetInt() * v_iMaxDistance->GetInt())) return 5;
if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return 8;
}
return 0;
}
@ -162,10 +170,76 @@ void FollowBot::Tick(CUserCmd* cmd) {
IClientEntity* target = GetTarget();
IClientEntity* target_old = target;
//bool target_lost = (!target || ShouldTarget(target) || (g_bState != bot_state_t::FOLLOWING_ENEMY && g_bState != bot_state_t::FOLLOWING_TEAMMATE));
bool target_lost = (!target || ShouldTarget(target, true) || (g_bState != bot_state_t::FOLLOWING_ENEMY && g_bState != bot_state_t::FOLLOWING_TEAMMATE));
if (v_bMediBot->GetBool()) {
cmd->buttons |= IN_ATTACK;
if ((g_nTick % 20) == 0) {
interfaces::engineClient->ExecuteClientCmd("slot2");
cmd->buttons &= ~IN_ATTACK;
}
if (this->m_iShouldUbercharge && this->m_iShouldUbercharge < 30) {
cmd->buttons |= IN_ATTACK2;
interfaces::engineClient->ExecuteClientCmd("voicemenu 2 1");
this->m_iShouldUbercharge++;
} else {
this->m_iShouldUbercharge = 0;
}
if (target_lost && g_bState != bot_state_t::PILOT_SEARCH) logging::Info("Target lost! Target: %i, State: %i, ShouldTarget: %i", target, g_bState, ShouldTarget(target, true));
if (!target || ShouldNotTarget(target, true)) {
//g_bState = bot_state_t::PILOT_SEARCH;
nPilotSearch++;
} else {
//g_bState = bot_state_t::FOLLOWING_TEAMMATE;
nPilotSearch = 0;
}
// TODO movements with cmd
if (nPilotSearch < SEARCH_TICKS) {
//interfaces::engineClient->ExecuteClientCmd("+forward");
} else {
//interfaces::engineClient->ExecuteClientCmd("-forward");
}
IClientEntity* ptf = 0;
for (int i = 0; i < 64 && i < interfaces::entityList->GetHighestEntityIndex(); i++) {
if (IsOwner(interfaces::entityList->GetClientEntity(i))) {
m_hTargetFollowing = i;
ptf = interfaces::entityList->GetClientEntity(i);
}
}
IClientEntity* healtr = this->GetBestHealingTarget();
m_hTargetHealing = (healtr ? healtr->entindex() : 0);
if (healtr) {
if (GetEntityValue<int>(healtr, eoffsets.iHealth) < 35 && !GetEntityValue<char>(healtr, eoffsets.iLifeState)) {
m_iShouldUbercharge = 1;
}
if (g_pLocalPlayer->health < 35) {
m_iShouldUbercharge = 1;
}
}
if (!ptf) return;
if (GetEntityValue<Vector>(g_pLocalPlayer->entity, eoffsets.vVelocity).IsZero(10.0f) && (0 == (g_nTick % 20))) {
interfaces::engineClient->ExecuteClientCmd("+jump");
} else if (0 == (g_nTick % 20)) {
interfaces::engineClient->ExecuteClientCmd("-jump");
}
if (DistToSqr(ptf) < (100 * 100) && (0 == (g_nTick % 20))) {
interfaces::engineClient->ExecuteClientCmd("-forward");
} else if (0 == (g_nTick % 20)) {
interfaces::engineClient->ExecuteClientCmd("+forward");
}
return;
} else {
return;
}
// OLD CODE
/*bool target_lost = (!target || ShouldNotTarget(target, true) || (g_bState != bot_state_t::FOLLOWING_ENEMY && g_bState != bot_state_t::FOLLOWING_TEAMMATE));
if (target_lost && g_bState != bot_state_t::PILOT_SEARCH) logging::Info("Target lost! Target: %i, State: %i, ShouldTarget: %i", target, g_bState, ShouldNotTarget(target, true));
if (target_lost && g_bState == bot_state_t::FOLLOWING_ENEMY) {
g_bState = bot_state_t::PILOT_SEARCH;
@ -188,18 +262,17 @@ void FollowBot::Tick(CUserCmd* cmd) {
interfaces::engineClient->ExecuteClientCmd("-forward");
}
if ((g_nTick % 300 == 0) || target_lost) {
for (int i = 0; i < 64 && i < interfaces::entityList->GetMaxEntities(); i++) {
IClientEntity* ent = interfaces::entityList->GetClientEntity(i);
if (ShouldTarget(ent, false)) continue;
if (ShouldNotTarget(ent, false)) continue;
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
ProcessEntity(ent, enemy);
}
}
target = GetTarget();
target_lost = (!target || ShouldTarget(target, true) || g_bState == bot_state_t::IDLE || g_bState == bot_state_t::PILOT_SEARCH || g_bState == bot_state_t::TARGET_LOST);
target_lost = (!target || ShouldNotTarget(target, true) || g_bState == bot_state_t::IDLE || g_bState == bot_state_t::PILOT_SEARCH || g_bState == bot_state_t::TARGET_LOST);
if (target_lost) {
if (target_old != 0) {
@ -237,7 +310,11 @@ void FollowBot::Tick(CUserCmd* cmd) {
interfaces::engineClient->ExecuteClientCmd("-jump");
}
AimAt(target, cmd);
Vector hb;
if (GetHitboxPosition(target, 4, hb)) return;
AimAt(g_pLocalPlayer->v_Eye, hb, cmd);
QAngle angles = VectorToQAngle(cmd->viewangles);
interfaces::engineClient->SetViewAngles(angles);
if (DistToSqr(target) < (200 * 200) && g_bState == bot_state_t::FOLLOWING_TEAMMATE) {
interfaces::engineClient->ExecuteClientCmd("-forward");
@ -247,35 +324,169 @@ void FollowBot::Tick(CUserCmd* cmd) {
interfaces::engineClient->ExecuteClientCmd("+attack");
} else {
interfaces::engineClient->ExecuteClientCmd("-attack");
}*/
}
void FollowBot::ActuallyCreateMove(CUserCmd* cmd) {
IClientEntity* tr_follow = interfaces::entityList->GetClientEntity(this->m_hTargetFollowing);
IClientEntity* tr_heal = interfaces::entityList->GetClientEntity(this->m_hTargetHealing);
QAngle angles = VectorToQAngle(cmd->viewangles);
if (v_bMediBot->GetBool()) {
if (tr_follow) {
AimAtHitbox(tr_follow, 4, cmd);
angles = VectorToQAngle(cmd->viewangles);
g_pLocalPlayer->v_OrigViewangles = cmd->viewangles;
}
if (tr_heal) {
AimAtHitbox(tr_heal, 4, cmd);
g_pLocalPlayer->bUseSilentAngles = true;
}
} else {
return;
}
interfaces::engineClient->SetViewAngles(angles);
}
// TODO optimize, cache or something
bool FollowBot::IsOwner(IClientEntity* ent) {
if (!ent) return false;
if (ent->GetClientClass()->m_ClassID != ClassID::CTFPlayer) return false;
player_info_t info;
if (!interfaces::engineClient->GetPlayerInfo(ent->entindex(), &info)) return false;
return (info.friendsID == this->m_nOwnerID);
}
void FollowBot::ResetBotList() {
this->m_nOtherBots = 0;
}
bool FollowBot::IsFriendlyBot(IClientEntity* ent) {
if (!ent) return false;
if (ent->GetClientClass()->m_ClassID != ClassID::CTFPlayer) return false;
player_info_t info;
if (!interfaces::engineClient->GetPlayerInfo(ent->entindex(), &info)) return false;
for (unsigned i = 0; i < this->m_nOtherBots && i < 32; i++) {
if (info.friendsID == this->m_OtherBots[i]) return true;
}
return false;
}
IClientEntity* FollowBot::GetBestHealingTarget() {
IClientEntity* best = 0;
int best_score = -65536;
for (int i = 0; i < 64 && i < interfaces::entityList->GetHighestEntityIndex(); i++) {
IClientEntity* cur = interfaces::entityList->GetClientEntity(i);
if (cur && cur->GetClientClass()->m_ClassID == ClassID::CTFPlayer) {
if (GetEntityValue<int>(cur, eoffsets.iTeamNum) != g_pLocalPlayer->team) continue;
if (GetEntityValue<char>(cur, eoffsets.iLifeState)) continue;
if (cur == g_pLocalPlayer->entity) continue;
int score = this->GetHealingPriority(cur);
if (score > best_score && score != 0) {
best = cur;
best_score = score;
}
}
}
return best;
}
bool FollowBot::CreateMove(void*, float, CUserCmd* cmd) {
if (!v_bEnabled->GetBool()) return true;
Tick(cmd);
g_nTick++;
return true;
this->ActuallyCreateMove(cmd);
return false;
}
void CC_Status(const CCommand& args) {
logging::Info("W+M1 State: %i, ID: %i, Search: %i", g_bState, g_nTargetID, nPilotSearch);
int FollowBot::GetHealingPriority(IClientEntity* ent) {
if (!ent) return 0;
int result = 0;
int health = GetEntityValue<int>(ent, eoffsets.iHealth);
int maxhealth = g_pPlayerResource->GetMaxHealth(ent);
int maxbuffedhealth = maxhealth * 1.5;
int maxoverheal = maxbuffedhealth - maxhealth;
int overheal = maxoverheal - (maxbuffedhealth - health);
float overhealp = ((float)overheal / (float)maxoverheal);
float healthp = ((float)health / (float)maxhealth);
if (ent->GetAbsOrigin().DistToSqr(g_pLocalPlayer->v_Eye) > 1000 * 1000) return 0;
if (this->IsFriendlyBot(ent)) {
// Friendly bot medics must be constantly at 100%+ hp
if (healthp < 0.75) {
result += 60;
}
result += (maxbuffedhealth - health);
} else if (this->IsOwner(ent)) {
if (overhealp > 0.75) result -= 25;
result += (maxbuffedhealth - health) * 1.25;
} else {
result += (maxhealth - health);
if (result > 50) result = 50;
}
//logging::Info("idx %i score %i | HP %i MH %i MBH %i MO %i O %i", ent->entindex(), result, health, maxhealth, maxbuffedhealth, maxoverheal, overheal);
return result;
}
void FollowBot::AddBotID(uint32 id) {
logging::Info("Added bot: %lu", id);
this->m_OtherBots[this->m_nOtherBots++] = id;
}
void FollowBot::SetOwner(uint32 id) {
logging::Info("Owner set: %lu", id);
this->m_nOwnerID = id;
}
// TODO
void CC_BotStatus(const CCommand& args) {
logging::Info("Bot Status: %i, ID: %i, Search: %i", g_bState, g_nTargetID, nPilotSearch);
}
void CC_AddBotID(const CCommand& args) {
if (args.ArgC() < 1) return;
uint32 id = strtoul(args.Arg(1), 0, 0);
if (!id) return;
g_phFollowBot->AddBotID(id);
}
void CC_SetOwner(const CCommand& args) {
if (args.ArgC() < 1) return;
uint32 id = strtoul(args.Arg(1), 0, 0);
if (!id) return;
g_phFollowBot->m_nOwnerID = id;
}
void FollowBot::Create() {
v_bEnabled = CreateConVar("u_follow_enabled", "0", "Enables followbot");
v_iForceFollow = CreateConVar("u_follow_force_follow", "-1", "Force follow by UID");
v_bForceFollowOnly = CreateConVar("u_follow_force_follow_only", "1", "Only follow that player");
v_iMaxDeltaY = CreateConVar("u_follow_max_height", "450", "Max dY");
v_iMaxDistance = CreateConVar("u_follow_aim_distance", "1300", "Distance");
v_iShootDistance = CreateConVar("u_follow_shoot_distance", "800", "Shoot distance");
v_bChat = CreateConVar("u_follow_chat", "0", "Enable chat");
v_bEnabled = CreateConVar("u_bot_enabled", "0", "Enables followbot");
v_iForceFollow = CreateConVar("u_bot_force_follow", "-1", "Force follow by UID");
v_bForceFollowOnly = CreateConVar("u_bot_force_follow_only", "1", "Only follow that player");
v_iMaxDeltaY = CreateConVar("u_bot_max_height", "450", "Max dY");
v_iMaxDistance = CreateConVar("u_bot_aim_distance", "1300", "Distance");
v_iShootDistance = CreateConVar("u_bot_shoot_distance", "800", "Shoot distance");
v_bChat = CreateConVar("u_bot_chat", "0", "Enable chat");
v_bMediBot = CreateConVar("u_followbot", "1", "Medic mode");
v_bMediBot = CreateConVar("u_bot_medic", "1", "Medic mode");
c_AddBotID = CreateConCommand("u_bot_addbot", CC_AddBotID, "Adds another bot's ID");
c_SetOwner = CreateConCommand("u_bot_owner", CC_SetOwner, "Set followbot owner");
c_ResetList = CreateConCommand("u_bot_reset", CC_ResetList, "Resets bot list");
m_nOwnerID = 0;
cmd_Status = CreateConCommand("u_followbot_status", CC_Status, "Status");
cmd_Status = CreateConCommand("u_bot_status", CC_BotStatus, "Status");
g_pListener = new MedicCallListener();
interfaces::eventManager->AddListener(g_pListener, "player_calledformedic", false);
}
void FollowBot::Destroy() {
interfaces::eventManager->RemoveListener(g_pListener);
}
void FollowBot::Destroy() {}
void FollowBot::PaintTraverse(void*, unsigned int, bool, bool) {}
FollowBot* g_phFollowBot = 0;

View File

@ -10,9 +10,12 @@
#include "IHack.h"
class ConVar;
class IClientEntity;
class ConCommand;
void CC_ResetList(const CCommand& args);
void CC_AddBotID(const CCommand& args);
void CC_BotStatus(const CCommand& args);
void CC_SetOwner(const CCommand& args);
class FollowBot : public IHack {
public:
@ -22,16 +25,39 @@ public:
void PaintTraverse(void*, unsigned int, bool, bool);
void ProcessEntity(IClientEntity* entity, bool enemy);
void Tick(CUserCmd*);
int ShouldTarget(IClientEntity* ent, bool notrace);
int ShouldNotTarget(IClientEntity* ent, bool notrace);
void ActuallyCreateMove(CUserCmd*);
IClientEntity* GetBestHealingTarget();
int GetHealingPriority(IClientEntity* ent);
bool IsFriendlyBot(IClientEntity* ent);
bool IsOwner(IClientEntity* ent);
void ResetBotList();
void AddBotID(uint32 id);
void SetOwner(uint32 id);
void UpdateOwner();
int m_hTargetFollowing;
int m_hTargetHealing;
ConCommand* cmd_Status;
ConVar* v_bEnabled;
ConVar* v_iForceFollow;
ConVar* v_bForceFollowOnly;
ConVar* v_iMaxDistance;
ConVar* v_iShootDistance;
ConVar* v_iMaxDeltaY;
ConVar* v_bMediBot;
ConVar* v_bChat;
int m_iShouldUbercharge;
ConVar* v_bMediBot;
ConCommand* c_AddBotID;
ConCommand* c_SetOwner;
ConCommand* c_ResetList;
uint32 m_nOwnerID;
uint32 m_OtherBots[32];
uint32 m_nOtherBots;
};
extern FollowBot* g_phFollowBot;

View File

@ -13,6 +13,8 @@ class ConVar;
class ConCommand;
class CCommand;
typedef unsigned int uint32;
#define DECLARE_HACK() \
void Create(); \
bool CreateMove(void*, float, CUserCmd*); \

View File

@ -100,6 +100,11 @@ void CC_DumpVars(const CCommand& args) {
DumpRecvTable(ent, clz->m_pRecvTable, 0, ft);
}
void CC_ResetLists(const CCommand& args) {
n_friends = 0;
n_rage = 0;
}
void CC_DumpPlayers(const CCommand& args) {
for (int i = 0; i < 64 && i < interfaces::entityList->GetHighestEntityIndex(); i++) {
IClientEntity* ent = interfaces::entityList->GetClientEntity(i);
@ -168,6 +173,7 @@ void Misc::Create() {
c_DumpPlayers = CreateConCommand("u_dumpplayers", CC_DumpPlayers, "Dumps player data");
c_Teamname = CreateConCommand("u_teamname", CC_Teamname, "Team name");
c_Lockee = CreateConCommand("u_lockee", CC_Lockee, "Lock/Unlock commands");
c_Reset = CreateConCommand("u_reset_lists", CC_ResetLists, "Remove all friends and rage");
}
int sa_switch = 0;

View File

@ -30,6 +30,7 @@ public:
ConCommand* c_Teamname;
ConCommand* c_Lockee;
ConCommand* c_Info;
ConCommand* c_Reset;
};
extern Misc* g_phMisc;

View File

@ -210,27 +210,6 @@ void VectorTransform (const float *in1, const matrix3x4_t& in2, float *out)
out[2] = (in1[0] * in2[2][0] + in1[1] * in2[2][1] + in1[2] * in2[2][2]) + in2[2][3];
}
// TODO deprecated
/*int ClassMaxHealth(int clazz) {
switch(clazz) {
case tf_scout:
case tf_spy:
case tf_sniper:
case tf_engineer:
return 125;
case tf_soldier:
return 200;
case tf_medic:
return 150;
case tf_heavy:
return 300;
case tf_demoman:
case tf_pyro:
return 175;
}
return 0;
}*/
int GetHitboxPosition(IClientEntity* entity, int hb, Vector& out) {
if (!entity) return 1;
if (entity->IsDormant()) return 1;
@ -567,6 +546,30 @@ bool CanShoot(IClientEntity* player) {
return BulletTime(g_pLocalPlayer->weapon, true);
}
// TODO casting
QAngle VectorToQAngle(Vector in) {
return QAngle(in.x, in.y, in.z);
}
Vector QAngleToVector(QAngle in) {
return Vector(in.x, in.y, in.z);
}
void AimAt(Vector origin, Vector target, CUserCmd* cmd) {
Vector angles;
Vector tr = (target - origin);
fVectorAngles(tr, angles);
fClampAngle(angles);
cmd->viewangles = angles;
}
void AimAtHitbox(IClientEntity* ent, int hitbox, CUserCmd* cmd) {
Vector r = ent->GetAbsOrigin();
GetHitboxPosition(ent, hitbox, r);
AimAt(g_pLocalPlayer->v_Eye, r, cmd);
//logging::Info("Aiming at %f %f %f", r.x, r.y, r.z);
}
bool IsEntityVisiblePenetration(IClientEntity* entity, int hb) {
if (!trace::g_pFilterPenetration) {
trace::g_pFilterPenetration = new trace::FilterPenetration();

View File

@ -27,6 +27,8 @@ class Vector;
//typedef void ( *FnCommandCallback_t )( const CCommand &command );
// TODO split this shit
bool IsPlayerCritBoosted(IClientEntity* player);
bool IsPlayerInvulnerable(IClientEntity* player);
bool IsPlayerInvisible(IClientEntity* player);
@ -54,10 +56,13 @@ relation GetRelation(IClientEntity* ent);
bool IsSentryBuster(IClientEntity* ent);
char* strfmt(const char* fmt, ...);
bool CanHeadshot(IClientEntity* player);
void AimAt(Vector origin, Vector target, CUserCmd* cmd);
void AimAtHitbox(IClientEntity* ent, int hitbox, CUserCmd* cmd);
// TODO deprecated
//int ClassMaxHealth(int clazz);
QAngle VectorToQAngle(Vector in);
Vector QAngleToVector(QAngle in);
bool CanHeadshot(IClientEntity* player);
bool CheckCE(CachedEntity* entity);
bool BulletTime(IClientEntity* ent, bool interval);

View File

@ -25,6 +25,7 @@ void LocalPlayer::Update() {
v_Eye = v_Origin + v_ViewOffset;
cond_0 = GetEntityValue<int>(entity, eoffsets.iCond);
clazz = GetEntityValue<int>(entity, eoffsets.iClass);
health = GetEntityValue<int>(entity, eoffsets.iHealth);

View File

@ -1,9 +0,0 @@
/*
* menu.cpp
*
* Created on: Nov 5, 2016
* Author: nullifiedcat
*/
#include "menu.h"

View File

@ -1,69 +0,0 @@
/*
* menu.h
*
* Created on: Nov 5, 2016
* Author: nullifiedcat
*/
#ifndef MENU_H_
#define MENU_H_
#include <vector>
class ConVar;
class Changer {
public:
virtual ~Changer();
virtual void NextValue(ConVar* var);
virtual void PrevValue(ConVar* var);
};
class BoolChanger : public Changer {
public:
virtual void NextValue(ConVar* var);
virtual void PrevValue(ConVar* var);
};
class IntChanger : public Changer {
public:
virtual void NextValue(ConVar* var);
virtual void PrevValue(ConVar* var);
int m_iMinValue;
int m_iMaxValue;
int m_iStep;
};
class FloatChanger : public Changer {
public:
virtual void NextValue(ConVar* var);
virtual void PrevValue(ConVar* var);
float m_iMinValue;
float m_iMaxValue;
float m_iStep;
};
class MenuEntry {
public:
MenuEntry(ConVar* variable, Changer changer);
Changer m_Changer;
ConVar* m_ConVar;
};
class MenuArray {
public:
void AddEntry(MenuEntry entry);
const char* GetName();
std::vector<MenuEntry> m_Entries;
const char* m_Name;
};
class Menu {
public:
};
Menu g_Menu;
#endif /* MENU_H_ */

View File

@ -33,4 +33,13 @@ int TFPlayerResource::GetMaxHealth(IClientEntity* player) {
return *(int*)((unsigned int)m_pEntity + eoffsets.iMaxHealth + 4 * idx);
}
int TFPlayerResource::GetMaxBuffedHealth(IClientEntity* player) {
if (!player) return 0;
if (!m_pEntity) return 0;
int idx = player->entindex();
if (idx >= 64 || idx < 0) return 0;
return *(int*)((unsigned int)m_pEntity + eoffsets.iMaxBuffedHealth + 4 * idx);
}
TFPlayerResource* g_pPlayerResource = 0;

View File

@ -14,6 +14,7 @@ class TFPlayerResource {
public:
void Update();
int GetMaxHealth(IClientEntity* player);
int GetMaxBuffedHealth(IClientEntity* player);
IClientEntity* m_pEntity;
};

View File

@ -37,7 +37,7 @@ void CRelations::Remove(uint32 id) {
void CRelations::WriteConfig() {
// TODO path
FILE* cfg = fopen("/home/nullifiedcat/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg", "w");
FILE* cfg = fopen("/home/nullifiedcat/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg/u_relations.cfg", "w");
for (int i = 0; i < m_nFriends; i++) {
fprintf(cfg, "u_add_friend %lu\n", m_Friends[i]);
}

View File

@ -41,6 +41,8 @@ public:
void CC_AddFriend(const CCommand& args);
void CC_AddFriendly(const CCommand& args);
void CC_AddRage(const CCommand& args);
void CC_RemoveRelation(const CCommand& args);
void CC_SaveRelations(const CCommand& args);
extern char* RelStr[4];
extern CRelations* g_pRelations;

View File

@ -15,9 +15,6 @@
#include <libgen.h>
#include <pwd.h>
// TODO
#define STEAM_BASEDIR "/home/nullifiedcat/.local/share/Steam/"
namespace logging {
void Info(const char* fmt, ...);
}