remove kebab 4

Fix some issues with NavBot and DispatchUserMessage
This commit is contained in:
LightCat 2018-11-17 17:14:33 +01:00
parent 43315bbb34
commit 51b360b6b5
2 changed files with 16 additions and 7 deletions

View File

@ -529,7 +529,7 @@ int lastent = -1;
bool NavToEnemy() bool NavToEnemy()
{ {
static CNavArea *last_area = nullptr; static CNavArea *last_area = nullptr;
if (*stay_near) if (*stay_near || *heavy_mode || *scout_mode)
{ {
if (lastent != -1) if (lastent != -1)
{ {
@ -542,6 +542,7 @@ bool NavToEnemy()
{ {
if (nav::ReadyForCommands) if (nav::ReadyForCommands)
nav::navTo(lastgoal, 1337, true, false); nav::navTo(lastgoal, 1337, true, false);
lastgoal = {};
return true; return true;
} }
} }
@ -640,7 +641,7 @@ bool NavToEnemy()
} }
return false; return false;
} }
static Timer nav_to_spot{};
bool NavToSniperSpot(int priority) bool NavToSniperSpot(int priority)
{ {
Vector random_spot{}; Vector random_spot{};
@ -648,6 +649,8 @@ bool NavToSniperSpot(int priority)
return false; return false;
if (!nav::ReadyForCommands) if (!nav::ReadyForCommands)
return false; return false;
if (!nav_to_spot.test_and_set(100))
return false;
bool use_preferred = !preferred_sniper_spots.empty(); bool use_preferred = !preferred_sniper_spots.empty();
auto snip_spot = use_preferred ? preferred_sniper_spots : sniper_spots; auto snip_spot = use_preferred ? preferred_sniper_spots : sniper_spots;
bool toret = false; bool toret = false;
@ -693,7 +696,10 @@ bool NavToSniperSpot(int priority)
int rng = rand() % snip_spot.size(); int rng = rand() % snip_spot.size();
random_spot = snip_spot.at(rng); random_spot = snip_spot.at(rng);
if (random_spot.z) if (random_spot.z)
{
nav_to_spot.update();
return nav::navTo(random_spot, false, true, priority); return nav::navTo(random_spot, false, true, priority);
}
return false; return false;
} }
random_spot = snip_spot.at(best_spot); random_spot = snip_spot.at(best_spot);
@ -711,7 +717,10 @@ bool NavToSniperSpot(int priority)
int rng = rand() % snip_spot.size(); int rng = rand() % snip_spot.size();
random_spot = snip_spot.at(rng); random_spot = snip_spot.at(rng);
if (random_spot.z) if (random_spot.z)
{
nav_to_spot.update();
toret = nav::navTo(random_spot, priority, true, false); toret = nav::navTo(random_spot, priority, true, false);
}
} }
return toret; return toret;
} }
@ -810,7 +819,7 @@ static HookedFunction
} }
} }
} }
if (*stay_near && nav_enemy_cd.test_and_set(100) && !HasLowAmmo() && if ((*stay_near || *heavy_mode || *scout_mode) && nav_enemy_cd.test_and_set(100) && !HasLowAmmo() &&
!HasLowHealth()) !HasLowHealth())
{ {
if (NavToEnemy()) if (NavToEnemy())

View File

@ -79,16 +79,16 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type,
if (type == 5) if (type == 5)
if (buf.GetNumBytesLeft() > 35) if (buf.GetNumBytesLeft() > 35)
{ {
std::string message_name{}; char message_name[buf.GetNumBytesLeft()]{};
for (int i = 0; i < buf.GetNumBytesLeft(); i++) for (int i = 0; i < buf.GetNumBytesLeft(); i++)
{ {
int byte = buf.ReadByte(); int byte = buf.ReadByte();
message_name.push_back(byte); message_name[i] = byte;
} }
if (message_name.find("#TF_Autobalance_TeamChangePending") != if (!strcmp(message_name, "TeamChangePending"))
std::string::npos)
logging::Info("test, %d %d", int(message_name[0]), logging::Info("test, %d %d", int(message_name[0]),
(CE_GOOD(LOCAL_E) ? LOCAL_E->m_IDX : -1)); (CE_GOOD(LOCAL_E) ? LOCAL_E->m_IDX : -1));
buf.Seek(0);
} }
if (type == 4) if (type == 4)
{ {