Auto VACC + improved ncc gui readability
This commit is contained in:
parent
d56eab0438
commit
a0f24876b9
@ -46,7 +46,7 @@ void CTextLabel::SetText(std::string text) {
|
|||||||
if (ms.first > 0) {
|
if (ms.first > 0) {
|
||||||
std::string txt = WordWrap(text, ms.first - 2 * padding.first);
|
std::string txt = WordWrap(text, ms.first - 2 * padding.first);
|
||||||
auto size2 = draw::GetStringLength(fonts::MENU, txt);
|
auto size2 = draw::GetStringLength(fonts::MENU, txt);
|
||||||
SetSize(-1, size2.second + padding.second * 2);
|
SetSize(size2.first + padding.first * 2, size2.second + padding.second * 2);
|
||||||
Props()->SetString("text", txt.c_str());
|
Props()->SetString("text", txt.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ Item::Item(std::string name) : CBaseWidget(name, nullptr) {
|
|||||||
void Item::Draw(int x, int y) {
|
void Item::Draw(int x, int y) {
|
||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
//draw::DrawRect(x, y, size.first, size.second, colors::red);
|
//draw::DrawRect(x, y, size.first, size.second, colors::red);
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 65));
|
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 77));
|
||||||
if (IsHovered()) {
|
if (IsHovered()) {
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(GUIColor(), 0.32f));
|
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(GUIColor(), 0.32f));
|
||||||
}
|
}
|
||||||
|
@ -289,6 +289,25 @@ static const std::string list_tf2 = R"(
|
|||||||
"Trigger Bot Menu"
|
"Trigger Bot Menu"
|
||||||
"trigger_enabled"
|
"trigger_enabled"
|
||||||
"autobackstab"
|
"autobackstab"
|
||||||
|
"Auto Vaccinator" [
|
||||||
|
"Auto Vaccinator"
|
||||||
|
"auto_vacc"
|
||||||
|
"auto_vacc_blast"
|
||||||
|
"auto_vacc_blast_pop_health"
|
||||||
|
"auto_vacc_blast_pop_crit"
|
||||||
|
"auto_vacc_rocket_range"
|
||||||
|
"auto_vacc_fire"
|
||||||
|
"auto_vacc_fire_pop_pyro"
|
||||||
|
"auto_vacc_afterburn"
|
||||||
|
"auto_vacc_pyro_range"
|
||||||
|
"auto_vacc_bullets"
|
||||||
|
"auto_vacc_sniper_pop"
|
||||||
|
"auto_vacc_default_resist"
|
||||||
|
"auto_vacc_reset_timer"
|
||||||
|
"auto_vacc_blast_pop_ubers"
|
||||||
|
"auto_vacc_fire_pop_ubers"
|
||||||
|
"auto_vacc_bullet_pop_ubers"
|
||||||
|
]
|
||||||
"Auto Sticky" [
|
"Auto Sticky" [
|
||||||
"Auto Sticky Menu"
|
"Auto Sticky Menu"
|
||||||
"sticky_enabled"
|
"sticky_enabled"
|
||||||
|
@ -18,7 +18,7 @@ PlayerList::PlayerList() : CBaseContainer() {
|
|||||||
void PlayerList::Draw(int x, int y) {
|
void PlayerList::Draw(int x, int y) {
|
||||||
if (g_Settings.bInvalid) return;
|
if (g_Settings.bInvalid) return;
|
||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 65));
|
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 77));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||||
for (int i = 0; i < Props()->GetInt("vischildren"); i++) {
|
for (int i = 0; i < Props()->GetInt("vischildren"); i++) {
|
||||||
draw::DrawLine(x, y + i * 17, size_table_width(), 0, GUIColor());
|
draw::DrawLine(x, y + i * 17, size_table_width(), 0, GUIColor());
|
||||||
|
@ -13,7 +13,7 @@ namespace menu { namespace ncc {
|
|||||||
|
|
||||||
Tooltip::Tooltip() : CTextLabel("ncc_tooltip") {
|
Tooltip::Tooltip() : CTextLabel("ncc_tooltip") {
|
||||||
SetZIndex(999);
|
SetZIndex(999);
|
||||||
SetPadding(2, 1);
|
SetPadding(3, 2);
|
||||||
SetMaxSize(220, -1);
|
SetMaxSize(220, -1);
|
||||||
SetAutoSize(false);
|
SetAutoSize(false);
|
||||||
SetSize(220, -1);
|
SetSize(220, -1);
|
||||||
@ -25,7 +25,7 @@ void Tooltip::Draw(int x, int y) {
|
|||||||
int originy = y;
|
int originy = y;
|
||||||
if (originx + size.first > draw::width) originx -= size.first;
|
if (originx + size.first > draw::width) originx -= size.first;
|
||||||
if (originx + size.second > draw::height) originy -= size.second;
|
if (originx + size.second > draw::height) originy -= size.second;
|
||||||
static int bgcolor = colors::Create(0, 0, 0, 65); //colors::Create(70, 86, 47, 28);
|
static int bgcolor = colors::Create(0, 0, 0, 77); //colors::Create(70, 86, 47, 28);
|
||||||
static int fgcolor = colors::Create(200, 200, 190, 255);
|
static int fgcolor = colors::Create(200, 200, 190, 255);
|
||||||
draw::DrawRect(x, y, size.first, size.second, bgcolor);
|
draw::DrawRect(x, y, size.first, size.second, bgcolor);
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||||
|
@ -26,7 +26,17 @@ static CatVar share_uber(CV_SWITCH, "autoheal_share_uber", "1", "Share ubercharg
|
|||||||
int vaccinator_change_stage = 0;
|
int vaccinator_change_stage = 0;
|
||||||
int vaccinator_change_ticks = 0;
|
int vaccinator_change_ticks = 0;
|
||||||
int vaccinator_ideal_resist = 0;
|
int vaccinator_ideal_resist = 0;
|
||||||
|
int vaccinator_change_timer = 0;
|
||||||
|
|
||||||
|
static CatVar auto_vacc_bullets(CV_SWITCH, "auto_vacc_bullets", "1", "Check bullet danger");
|
||||||
|
static CatEnum vacc_sniper_enum({"NEVER", "ZOOM & VISIBLE", "ANY ZOOMED"});
|
||||||
|
static CatVar vacc_sniper(vacc_sniper_enum, "auto_vacc_sniper_pop", "1", "Pop if Sniper", "Defines Auto-Vacc behaviour with snipers");
|
||||||
|
|
||||||
|
int ChargeCount() {
|
||||||
|
return (CE_FLOAT(LOCAL_W, netvar.m_flChargeLevel) / 0.25f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Angle Checking
|
||||||
int BulletDangerValue(CachedEntity* patient) {
|
int BulletDangerValue(CachedEntity* patient) {
|
||||||
// Find zoomed in snipers in other team
|
// Find zoomed in snipers in other team
|
||||||
bool any_zoomed_snipers = false;
|
bool any_zoomed_snipers = false;
|
||||||
@ -38,39 +48,85 @@ int BulletDangerValue(CachedEntity* patient) {
|
|||||||
if (!HasCondition(ent, TFCond_Zoomed)) continue;
|
if (!HasCondition(ent, TFCond_Zoomed)) continue;
|
||||||
any_zoomed_snipers = true;
|
any_zoomed_snipers = true;
|
||||||
// TODO VisCheck from patient.
|
// TODO VisCheck from patient.
|
||||||
if (!IsEntityVisible(ent, head)) continue;
|
if ((int)vacc_sniper == 1)
|
||||||
return 2;
|
if (!IsEntityVisible(ent, head)) continue;
|
||||||
|
return vacc_sniper ? 2 : 1;
|
||||||
}
|
}
|
||||||
return any_zoomed_snipers;
|
return any_zoomed_snipers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CatVar auto_vacc_fire_checking(CV_SWITCH, "auto_vacc_fire", "1", "Check fire danger");
|
||||||
|
static CatEnum pyro_enum({"NEVER", "PRIMARY OUT", "ALWAYS"});
|
||||||
|
static CatVar auto_vacc_pop_if_pyro(pyro_enum, "auto_vacc_fire_pop_pyro", "1", "Pop if pyro is near", "Defines Auto-Vacc behaviour with pyros");
|
||||||
|
static CatVar auto_vacc_check_on_fire(CV_SWITCH, "auto_vacc_afterburn", "1", "Anti-Afterburn");
|
||||||
|
static CatVar auto_vacc_pyro_range(CV_INT, "auto_vacc_pyro_range", "450", "Pyro Danger Range");
|
||||||
|
|
||||||
int FireDangerValue(CachedEntity* patient) {
|
int FireDangerValue(CachedEntity* patient) {
|
||||||
// Find nearby pyros
|
// Find nearby pyros
|
||||||
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++) {
|
if (!auto_vacc_fire_checking) return 0;
|
||||||
CachedEntity* ent = ENTITY(i);
|
if (auto_vacc_pop_if_pyro) {
|
||||||
if (!ent->m_bEnemy) continue;
|
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++) {
|
||||||
if (g_pPlayerResource->GetClass(ent) != tf_pyro) continue;
|
CachedEntity* ent = ENTITY(i);
|
||||||
if (CE_BYTE(ent, netvar.iLifeState)) continue;
|
if (!ent->m_bEnemy) continue;
|
||||||
if (patient->m_vecOrigin.DistToSqr(ent->m_vecOrigin) > 300.0f * 300.0f) continue;
|
if (g_pPlayerResource->GetClass(ent) != tf_pyro) continue;
|
||||||
IClientEntity* pyro_weapon = g_IEntityList->GetClientEntity(CE_INT(ent, netvar.hActiveWeapon) & 0xFFF);
|
if (CE_BYTE(ent, netvar.iLifeState)) continue;
|
||||||
return (pyro_weapon && pyro_weapon->GetClientClass()->m_ClassID == g_pClassID->CTFFlameThrower) ? 2 : 0;
|
if (patient->m_vecOrigin.DistTo(ent->m_vecOrigin) > (int)auto_vacc_pyro_range) continue;
|
||||||
|
if ((int)auto_vacc_pop_if_pyro == 2) return 2;
|
||||||
|
IClientEntity* pyro_weapon = g_IEntityList->GetClientEntity(CE_INT(ent, netvar.hActiveWeapon) & 0xFFF);
|
||||||
|
return (pyro_weapon && pyro_weapon->GetClientClass()->m_ClassID == g_pClassID->CTFFlameThrower) ? 2 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (HasCondition(patient, TFCond_OnFire)) {
|
if (HasCondition(patient, TFCond_OnFire)) {
|
||||||
return 1;
|
return (bool)auto_vacc_check_on_fire;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct proj_data_s {
|
||||||
|
int eid;
|
||||||
|
Vector last_pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<proj_data_s> proj_data_array;
|
||||||
|
|
||||||
|
static CatVar auto_vacc_blast_health(CV_INT, "auto_vacc_blast_pop_health", "80", "Pop Blast if rocket & HP <");
|
||||||
|
static CatVar auto_vacc_blast_crit_pop(CV_SWITCH, "auto_vacc_blast_pop_crit", "1", "Pop Blast if crit rocket near");
|
||||||
|
static CatVar auto_vacc_blast_checking(CV_SWITCH, "auto_vacc_blast", "1", "Check blast danger");
|
||||||
|
static CatVar auto_vacc_proj_danger_range(CV_INT, "auto_vacc_rocket_range", "650", "Rocket Danger Range", "This range should be high enough to give more time to change resistances.");
|
||||||
|
|
||||||
int BlastDangerValue(CachedEntity* patient) {
|
int BlastDangerValue(CachedEntity* patient) {
|
||||||
|
if (!auto_vacc_blast_checking) return 0;
|
||||||
|
// Check rockets for being closer
|
||||||
|
bool hasCritRockets = false;
|
||||||
|
bool hasRockets = false;
|
||||||
|
for (auto it = proj_data_array.begin(); it != proj_data_array.end();) {
|
||||||
|
const auto& d = *it;
|
||||||
|
CachedEntity* ent = ENTITY(d.eid);
|
||||||
|
if (CE_GOOD(ent)) {
|
||||||
|
// Rocket is getting closer
|
||||||
|
if (patient->m_vecOrigin.DistToSqr(d.last_pos) > patient->m_vecOrigin.DistToSqr(ent->m_vecOrigin)) {
|
||||||
|
if (ent->m_bCritProjectile) hasCritRockets = true;
|
||||||
|
hasRockets = true;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
} else {
|
||||||
|
proj_data_array.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasRockets) {
|
||||||
|
if (patient->m_iHealth < (int)auto_vacc_blast_health || (auto_vacc_blast_crit_pop && hasCritRockets)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
// Find crit rockets/pipes nearby
|
// Find crit rockets/pipes nearby
|
||||||
for (int i = 32; i < HIGHEST_ENTITY; i++) {
|
for (int i = 32; i < HIGHEST_ENTITY; i++) {
|
||||||
CachedEntity* ent = ENTITY(i);
|
CachedEntity* ent = ENTITY(i);
|
||||||
if (CE_BAD(ent)) continue;
|
if (CE_BAD(ent)) continue;
|
||||||
if (!ent->m_bEnemy) continue;
|
if (!ent->m_bEnemy) continue;
|
||||||
if (ent->m_Type != ENTITY_PROJECTILE) continue;
|
if (ent->m_Type != ENTITY_PROJECTILE) continue;
|
||||||
if (patient->m_vecOrigin.DistToSqr(ent->m_vecOrigin) > 420.0f * 420.0f) continue;
|
if (patient->m_vecOrigin.DistTo(ent->m_vecOrigin) > (int)auto_vacc_proj_danger_range) continue;
|
||||||
// TODO Velocity checking
|
proj_data_array.push_back(proj_data_s{i, ent->m_vecOrigin});
|
||||||
return ((ent->m_bCritProjectile || (patient->m_iHealth < 80)) ? 2 : 1);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -80,21 +136,36 @@ int CurrentResistance() {
|
|||||||
return CE_INT(LOCAL_W, netvar.m_nChargeResistType);
|
return CE_INT(LOCAL_W, netvar.m_nChargeResistType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CatVar change_timer(CV_INT, "auto_vacc_reset_timer", "200", "Reset Timer", "If no dangers were detected for # ticks, resistance will be reset to default, 0 to disable");
|
||||||
|
|
||||||
|
static CatVar auto_vacc_bullet_pop_ubers(CV_INT, "auto_vacc_bullet_pop_ubers", "0", "Pop Bullet if Ubers >=", "Only pop an uber if you have >= # Ubercharges in your Vaccinator", 0, 4);
|
||||||
|
static CatVar auto_vacc_fire_pop_ubers(CV_INT, "auto_vacc_fire_pop_ubers", "0", "Pop Fire if Ubers >=", "Only pop an uber if you have >= # Ubercharges in your Vaccinator", 0, 4);
|
||||||
|
static CatVar auto_vacc_blast_pop_ubers(CV_INT, "auto_vacc_blast_pop_ubers", "0", "Pop Blast if Ubers >=", "Only pop an uber if you have >= # Ubercharges in your Vaccinator", 0, 4);
|
||||||
|
|
||||||
int OptimalResistance(CachedEntity* patient, bool* shouldPop) {
|
int OptimalResistance(CachedEntity* patient, bool* shouldPop) {
|
||||||
int bd = BlastDangerValue(patient),
|
int bd = BlastDangerValue(patient),
|
||||||
fd = FireDangerValue(patient),
|
fd = FireDangerValue(patient),
|
||||||
hd = BulletDangerValue(patient);
|
hd = BulletDangerValue(patient);
|
||||||
if (shouldPop) {
|
if (shouldPop) {
|
||||||
if (bd > 1 || fd > 1 || hd > 1) *shouldPop = true;
|
int charges = ChargeCount();
|
||||||
|
if (bd > 1 && charges >= (int)auto_vacc_blast_pop_ubers) *shouldPop = true;
|
||||||
|
if (fd > 1 && charges >= (int)auto_vacc_fire_pop_ubers) *shouldPop = true;
|
||||||
|
if (hd > 1 && charges >= (int)auto_vacc_bullet_pop_ubers) *shouldPop = true;
|
||||||
}
|
}
|
||||||
if (!hd && !fd && !bd) return -1;
|
if (!hd && !fd && !bd) return -1;
|
||||||
|
vaccinator_change_timer = (int)change_timer;
|
||||||
if (hd >= fd && hd >= bd) return 0;
|
if (hd >= fd && hd >= bd) return 0;
|
||||||
if (bd >= fd && bd >= hd) return 1;
|
if (bd >= fd && bd >= hd) return 1;
|
||||||
if (fd >= hd && fd >= bd) return 2;
|
if (fd >= hd && fd >= bd) return 2;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CatEnum resistances_enum({"BULLET", "BLAST", "FIRE"});
|
||||||
|
static CatVar default_resistance(resistances_enum, "auto_vacc_default_resist", "0", "Default Resistance", "Select default resistance type");
|
||||||
|
|
||||||
void SetResistance(int resistance) {
|
void SetResistance(int resistance) {
|
||||||
|
resistance = _clamp(0, 2, resistance);
|
||||||
|
vaccinator_change_timer = (int)change_timer;
|
||||||
vaccinator_ideal_resist = resistance;
|
vaccinator_ideal_resist = resistance;
|
||||||
int cur = CurrentResistance();
|
int cur = CurrentResistance();
|
||||||
if (resistance == cur) return;
|
if (resistance == cur) return;
|
||||||
@ -103,6 +174,12 @@ void SetResistance(int resistance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DoResistSwitching() {
|
void DoResistSwitching() {
|
||||||
|
if (vaccinator_change_timer > 0) {
|
||||||
|
if (vaccinator_change_timer == 1) {
|
||||||
|
SetResistance((int)default_resistance);
|
||||||
|
}
|
||||||
|
vaccinator_change_timer--;
|
||||||
|
}
|
||||||
if (!vaccinator_change_stage) return;
|
if (!vaccinator_change_stage) return;
|
||||||
if (CurrentResistance() == vaccinator_ideal_resist) {
|
if (CurrentResistance() == vaccinator_ideal_resist) {
|
||||||
vaccinator_change_ticks = 0;
|
vaccinator_change_ticks = 0;
|
||||||
|
@ -37,6 +37,7 @@ void NetVars::Init() {
|
|||||||
this->_condition_bits = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_ConditionList", "_condition_bits");
|
this->_condition_bits = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_ConditionList", "_condition_bits");
|
||||||
this->m_flStealthNoAttackExpire = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "tfsharedlocaldata", "m_flStealthNoAttackExpire");
|
this->m_flStealthNoAttackExpire = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "tfsharedlocaldata", "m_flStealthNoAttackExpire");
|
||||||
this->m_nChargeResistType = gNetvars.get_offset("DT_WeaponMedigun", "m_nChargeResistType");
|
this->m_nChargeResistType = gNetvars.get_offset("DT_WeaponMedigun", "m_nChargeResistType");
|
||||||
|
this->m_flChargeLevel = gNetvars.get_offset("DT_WeaponMedigun", "NonLocalTFWeaponMedigunData", "m_flChargeLevel");
|
||||||
}
|
}
|
||||||
if (TF2 || TF2C) {
|
if (TF2 || TF2C) {
|
||||||
this->res_iMaxHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxHealth");
|
this->res_iMaxHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxHealth");
|
||||||
|
@ -125,6 +125,7 @@ public:
|
|||||||
offset_t m_Collision;
|
offset_t m_Collision;
|
||||||
offset_t res_iTeam;
|
offset_t res_iTeam;
|
||||||
offset_t m_nChargeResistType;
|
offset_t m_nChargeResistType;
|
||||||
|
offset_t m_flChargeLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NetVars netvar;
|
extern NetVars netvar;
|
||||||
|
Reference in New Issue
Block a user