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

View File

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