Merge branch 'master' into master

This commit is contained in:
julianacat 2017-07-20 01:18:43 -05:00 committed by GitHub
commit d48f56133d
3 changed files with 99 additions and 9 deletions

View File

@ -322,19 +322,25 @@ void CreateMove() {
// Check if user settings allow anti-afk
if (anti_afk) {
// If the timer exceeds 1 minute, jump and reset the timer
if ( g_GlobalVars->curtime - afkTimeIdle > 60 ) {
if (g_GlobalVars->curtime - 60 > afkTimeIdle) {
// Send random commands
g_pUserCmd->sidemove = RandFloatRange(-450.0, 450.0);
g_pUserCmd->forwardmove = RandFloatRange(-450.0, 450.0);
g_pUserCmd->buttons = rand();
// If player didnt jump, then we dont reset the timer
if (CE_INT(g_pLocalPlayer->entity, netvar.movetype) == MOVETYPE_FLY)
// After 1 second we reset the idletime
if (g_GlobalVars->curtime - 61 > afkTimeIdle) {
logging::Info("Finish idle");
afkTimeIdle = g_GlobalVars->curtime;
}
} else {
// If the player uses a button, reset the timer
if (g_pUserCmd->buttons & IN_FORWARD || g_pUserCmd->buttons & IN_BACK || g_pUserCmd->buttons & IN_MOVELEFT || g_pUserCmd->buttons & IN_MOVERIGHT || g_pUserCmd->buttons & IN_JUMP || !LOCAL_E->m_bAlivePlayer)
afkTimeIdle = g_GlobalVars->curtime;
// Attemt to jump
g_pUserCmd->buttons = g_pUserCmd->buttons &~ IN_JUMP;
}
// If the player uses a button, reset the timer
if ( g_pUserCmd->buttons & IN_FORWARD || g_pUserCmd->buttons & IN_BACK || g_pUserCmd->buttons & IN_MOVELEFT || g_pUserCmd->buttons & IN_MOVERIGHT || g_pUserCmd->buttons & IN_JUMP || !LOCAL_E->m_bAlivePlayer )
afkTimeIdle = g_GlobalVars->curtime;
}
IF_GAME (IsTF2()) {

View File

@ -213,9 +213,92 @@ void Shutdown_hook(void* _this, const char* reason) {
static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles");
CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
CatVar namesteal(CV_SWITCH, "name_stealer", "0", "Name Stealer", "Attemt to steal your teammates names. Usefull for avoiding kicks\nPassive only changes when the name stolen is no longer the best name to use\nActive Attemps to change the name whenever possible");
static std::string stolen_name;
// Func to get a new entity to steal name from
bool StolenName(){
// Array to store potential namestealer targets with a bookkeeper to tell how full it is
int potential_targets[32];
int potential_targets_length = 0;
// Go through entities looking for potential targets
for (int i = 1; i < HIGHEST_ENTITY; i++) {
CachedEntity* ent = ENTITY(i);
// Check if ent is a good target
if (!ent) continue;
if (ent == LOCAL_E) continue;
if (!ent->m_Type == ENTITY_PLAYER) continue;
if (ent->m_bEnemy) continue;
// Check if name is current one
player_info_s info;
if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info)) {
// If our name is the same as current, than change it
if (std::string(info.name) == stolen_name) {
// Since we found the ent we stole our name from and it is still good, if user settings are passive, then we return true and dont alter our name
if ((int)namesteal == 1) {
return true;
// Otherwise we continue to change our name to something else
} else continue;
}
// a ent without a name is no ent we need, contine for a different one
} else continue;
// Save the ent to our array
potential_targets[potential_targets_length] = i;
potential_targets_length++;
if (potential_targets_length >= 32) break;
}
// Get random number that we can use with our array
int target_random_num = floor(RandFloatRange(0, potential_targets_length - 0.1F));
// Get a idx from our random array position
int new_target = potential_targets[target_random_num];
// Checks to prevent crashes
if (!ENTITY(new_target) || potential_targets_length == 0) return false;
// Grab username of user
player_info_s info;
if (g_IEngine->GetPlayerInfo(new_target, &info)) {
// If our name is the same as current, than change it and return true
stolen_name = std::string(info.name);
return true;
}
// Didnt get playerinfo
return false;
}
const char* GetFriendPersonaName_hook(ISteamFriends* _this, CSteamID steamID) {
static const GetFriendPersonaName_t original = (GetFriendPersonaName_t)hooks::steamfriends.GetMethod(offsets::GetFriendPersonaName());
// Check User settings if namesteal is allowed
if (namesteal && steamID == g_ISteamUser->GetSteamID()) {
// We dont want to steal names while not in-game as there are no targets to steal from
if (g_IEngine->IsInGame()) {
// Check if we have a username to steal, func automaticly steals a name in it.
if (StolenName()) {
// Return the name that has changed from the func above
return format(stolen_name, "\x0F").c_str();
}
}
}
if ((strlen(force_name.GetString()) > 1) && steamID == g_ISteamUser->GetSteamID()) {
return force_name_newlined;
}
return original(_this, steamID);

View File

@ -408,6 +408,7 @@
"name",
"fakelag",
"disconnect_reason",
"name_stealer",
"minigun_jump",
"spycrab",
"skinchanger",