Merge remote-tracking branch 'origin/master' into testing

This commit is contained in:
TotallyNotElite 2019-01-02 21:37:41 +01:00
commit bdcc5a5065
7 changed files with 210 additions and 63 deletions

View File

@ -7,7 +7,7 @@
#pragma once
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
@ -139,8 +139,8 @@ public:
void RegisterItem(std::string modelpath, k_EItemType type);
k_EItemType GetItemType(CachedEntity *entity);
std::map<std::string, k_EItemType> models;
std::map<uintptr_t, k_EItemType> map;
std::unordered_map<std::string, k_EItemType> models;
std::unordered_map<uintptr_t, k_EItemType> map;
};
class ItemManager
@ -151,7 +151,7 @@ public:
void RegisterSpecialMapping(ItemCheckerFn fn, k_EItemType type);
k_EItemType GetItemType(CachedEntity *ent);
std::map<ItemCheckerFn, k_EItemType> special_map;
std::unordered_map<ItemCheckerFn, k_EItemType> special_map;
std::vector<ItemSpecialMapperFn> specials;
ItemModelMapper mapper_special;
ItemModelMapper mapper;

View File

@ -1003,18 +1003,10 @@ int BestHitbox(CachedEntity *target)
{
headonly = true;
}
// Head only
if (headonly)
{
IF_GAME(IsTF())
return hitbox_t::head;
IF_GAME(IsCSS())
return 12;
}
// If the prefered hitbox vis check passes, use it
namespace bt = hacks::shared::backtrack;
if (IsBacktracking() && !projectile_mode)
{
namespace bt = hacks::shared::backtrack;
good_tick = { -1, -1 };
auto ticks = bt::headPositions[target->m_IDX];
for (int i = 0; i < 66; i++)
@ -1038,6 +1030,20 @@ int BestHitbox(CachedEntity *target)
break;
}
}
}
// Head only
if (headonly)
{
IF_GAME(IsTF())
return hitbox_t::head;
IF_GAME(IsCSS())
return 12;
}
// If the prefered hitbox vis check passes, use it
if (IsBacktracking() && !projectile_mode)
{
namespace bt = hacks::shared::backtrack;
if (good_tick.first != -1)
if (IsEntityVectorVisible(target, bt::headPositions[target->m_IDX][good_tick.first].hitboxes.at(preferred).center))
return preferred;
@ -1047,6 +1053,7 @@ int BestHitbox(CachedEntity *target)
// Else attempt to find a hitbox at all
if (IsBacktracking() && !projectile_mode && good_tick.first != -1)
{
namespace bt = hacks::shared::backtrack;
for (int i = 0; i < 18; i++)
if (IsEntityVectorVisible(target, bt::headPositions[target->m_IDX][good_tick.first].hitboxes.at(i).center))
return i;
@ -1061,11 +1068,49 @@ int BestHitbox(CachedEntity *target)
break;
case 1:
{ // AUTO-CLOSEST priority, Return closest hitbox to crosshair
return ClosestHitbox(target);
int hb = ClosestHitbox(target);
if (IsBacktracking() && !projectile_mode)
{
namespace bt = hacks::shared::backtrack;
good_tick = { -1, -1 };
auto ticks = bt::headPositions[target->m_IDX];
for (int i = 0; i < 66; i++)
{
if (!ticks->tickcount)
continue;
if (!bt::ValidTick(ticks[i], target))
continue;
if (IsEntityVectorVisible(target, ticks->hitboxes.at(hb).center))
{
good_tick = { i, target->m_IDX };
break;
}
}
}
return hb;
}
break;
case 2:
{ // STATIC priority, Return a user chosen hitbox
int hb = *hitbox;
if (IsBacktracking() && !projectile_mode)
{
namespace bt = hacks::shared::backtrack;
good_tick = { -1, -1 };
auto ticks = bt::headPositions[target->m_IDX];
for (int i = 0; i < 66; i++)
{
if (!ticks->tickcount)
continue;
if (!bt::ValidTick(ticks[i], target))
continue;
if (IsEntityVectorVisible(target, ticks->hitboxes.at(hb).center))
{
good_tick = { i, target->m_IDX };
break;
}
}
}
return (int) hitbox;
}
break;

View File

@ -1,7 +1,8 @@
/*
Created on 29.07.18.
* Created on 29.07.18.
*/
#include <common.hpp>
#include <hacks/AntiAntiAim.hpp>
static settings::Bool enable{ "anti-anti-aim.enable", "false" };
@ -45,6 +46,8 @@ void hacks::shared::anti_anti_aim::resolveEnt(int IDX, IClientEntity *entity)
g_Settings.brute.brutenum[IDX] = 0;
brutepitch = !brutepitch;
}
if (quota > 0.8f)
brutepitch = true;
angles.y = fmod(angles.y + 180.0f, 360.0f);
if (angles.y < 0)
angles.y += 360.0f;
@ -74,7 +77,7 @@ void hacks::shared::anti_anti_aim::resolveEnt(int IDX, IClientEntity *entity)
angles.y = 0.0f;
break;
}
if (brutepitch || quota < 0.8f)
if (brutepitch)
switch (g_Settings.brute.brutenum[IDX] % 4)
{
case 0:
@ -91,3 +94,36 @@ void hacks::shared::anti_anti_aim::resolveEnt(int IDX, IClientEntity *entity)
}
}
}
void ResetPlayer(int idx)
{
g_Settings.brute.choke[idx] = {};
g_Settings.brute.brutenum[idx] = 0;
g_Settings.brute.last_angles[idx] = {};
g_Settings.brute.lastsimtime = 0.0f;
}
class ResolverListener : public IGameEventListener
{
public:
virtual void FireGameEvent(KeyValues *event)
{
if (!enable)
return;
std::string name(event->GetName());
if (name == "player_activate")
{
int uid = event->GetInt("userid");
int entity = g_IEngine->GetPlayerForUserID(uid);
ResetPlayer(entity);
}
else if (name == "player_disconnect")
{
int uid = event->GetInt("userid");
int entity = g_IEngine->GetPlayerForUserID(uid);
ResetPlayer(entity);
}
}
};
static ResolverListener listener;
static InitRoutine init([]() { g_IGameEventManager->AddListener(&listener, false); });

View File

@ -192,7 +192,7 @@ void Draw()
if (*fov > 0.0f && *fov < 180)
{
// Dont show ring while player is dead
if (LOCAL_E->m_bAlivePlayer())
if (CE_GOOD(LOCAL_E) && LOCAL_E->m_bAlivePlayer())
{
rgba_t color = GUIColor();
color.a = float(fovcircle_opacity);

View File

@ -481,12 +481,87 @@ void ReplaceString(std::string &input, const std::string &what, const std::strin
}
}
void ReplaceSpecials(std::string &input)
{
ReplaceString(input, "\\015", "\015");
ReplaceString(input, "\\n", "\n");
ReplaceString(input, "\\r", "\r");
ReplaceString(input, "\\u200F", "\u200F");
void ReplaceSpecials(std::string &str) {
int val, i;
size_t c = 0, len = str.size();
for (int i = 0; i + c < len; ++i) {
str[i] = str[i + c];
if (str[i] != '\\')
continue;
if (i + c + 1 == len)
break;
switch (str[i + c + 1]) {
// Several control characters
case 'b':
++c;
str[i] = '\b';
break;
case 'n':
++c;
str[i] = '\n';
break;
case 'v':
++c;
str[i] = '\v';
break;
case 'r':
++c;
str[i] = '\r';
break;
case 't':
++c;
str[i] = '\t';
break;
case 'f':
++c;
str[i] = '\f';
break;
case 'a':
++c;
str[i] = '\a';
break;
case 'e':
++c;
str[i] = '\e';
break;
// Write escaped escape character as is
case '\\':
++c;
break;
// Convert specified value from HEX
case 'x':
if (i + c + 4 > len)
continue;
std::sscanf(&str[i + c + 2], "%02X", &val);
c += 3;
str[i] = val;
break;
// Convert from unicode
case 'u':
if (i + c + 6 > len)
continue;
// 1. Scan 16bit HEX value
std::sscanf(&str[i + c + 2], "%04X", &val);
c += 5;
// 2. Convert value to UTF-8
if (val <= 0x7F) {
str[i] = val;
} else if (val <= 0x7FF) {
str[i] = 0xC0 | ((val >> 6) & 0x1F);
str[i + 1] = 0x80 | (val & 0x3F);
++i;
--c;
} else {
str[i] = 0xE0 | ((val >> 12) & 0xF);
str[i + 1] = 0x80 | ((val >> 6) & 0x3F);
str[i + 2] = 0x80 | (val & 0x3F);
i += 2;
c -= 2;
}
break;
}
}
str.resize(len - c);
}
powerup_type GetPowerupOnPlayer(CachedEntity *player)

View File

@ -167,54 +167,45 @@ void ItemManager::RegisterModelMapping(std::string path, k_EItemType type)
void ItemManager::RegisterSpecialMapping(ItemCheckerFn fn, k_EItemType type)
{
special_map.emplace(fn, type);
special_map[fn] = type;
}
k_EItemType ItemManager::GetItemType(CachedEntity *ent)
{
for (const auto &it : specials)
{
const auto type = it(ent);
if (type != ITEM_NONE)
return type;
}
for (const auto &it : special_map)
{
if (it.first(ent))
return it.second;
}
return mapper.GetItemType(ent);
}
void ItemModelMapper::RegisterItem(std::string modelpath, k_EItemType type)
{
models.emplace(modelpath, type);
models[modelpath] = type;
}
k_EItemType ItemModelMapper::GetItemType(CachedEntity *entity)
{
const uintptr_t model = (uintptr_t) RAW_ENT(entity)->GetModel();
for (const auto &it : map)
const uintptr_t model = (uint64_t) RAW_ENT(entity)->GetModel();
try
{
if (it.first == model)
return it.second;
return map.at(model);
}
// Do Nothing
catch (std::out_of_range)
{
}
std::string path(g_IModelInfo->GetModelName((const model_t *) model));
bool set = false;
for (const auto &it : models)
// Do Nothing
try
{
// logging::Info("comparing [%s] to [%s]", path.c_str(),
// it.first.c_str());
if (it.first == path)
{
// logging::Info("Found %s!", path.c_str());
map.emplace(model, it.second);
models.at(path);
set = true;
break;
}
catch (std::out_of_range)
{
}
if (!set)
map.emplace(model, k_EItemType::ITEM_NONE);
map[model] = k_EItemType::ITEM_NONE;
return k_EItemType::ITEM_NONE;
}

View File

@ -50,32 +50,32 @@ public:
}
else if (name == "player_disconnect")
{
logging::Info("removePlayer %d", userid);
//logging::Info("removePlayer %d", userid);
controller->removePlayer(userid);
}
else if (name == "player_team")
{
logging::Info("updatePlayerTeam %d", userid);
//logging::Info("updatePlayerTeam %d", userid);
controller->updatePlayerTeam(userid, event->GetInt("team") - 1);
}
else if (name == "player_changeclass")
{
logging::Info("updatePlayerClass %d", userid);
//logging::Info("updatePlayerClass %d", userid);
controller->updatePlayerClass(userid, event->GetInt("class"));
}
else if (name == "player_changename")
{
logging::Info("updatePlayerName %d", userid);
//logging::Info("updatePlayerName %d", userid);
controller->updatePlayerName(userid, event->GetString("newname"));
}
else if (name == "player_death")
{
logging::Info("updatePlayerLifeState %d", userid);
//logging::Info("updatePlayerLifeState %d", userid);
controller->updatePlayerLifeState(userid, true);
}
else if (name == "player_spawn")
{
logging::Info("updatePlayerLifeState %d", userid);
//logging::Info("updatePlayerLifeState %d", userid);
controller->updatePlayerLifeState(userid, false);
}
}
@ -148,7 +148,7 @@ bool gui::handleSdlEvent(SDL_Event *event)
{
if (event->key.keysym.scancode == (*open_gui_button).scan)
{
logging::Info("GUI open button pressed");
//logging::Info("GUI open button pressed");
zerokernel::Menu::instance->setInGame(!zerokernel::Menu::instance->isInGame());
if (!zerokernel::Menu::instance->isInGame())
{