Skip to content

Commit

Permalink
Some better changes?
Browse files Browse the repository at this point in the history
  • Loading branch information
OfficerSpy committed Nov 15, 2024
1 parent c536f11 commit 07d4642
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 54 deletions.
7 changes: 6 additions & 1 deletion source/redbots3/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ static void Event_MvmWaveBegin(Event event, const char[] name, bool dontBroadcas
{
if (IsClientInGame(i) && g_bIsDefenderBot[i] && IsPlayerAlive(i))
{
//Looking for sniping spots, don't disturb
if (ActionsManager.GetAction(i, "SniperLurk") != INVALID_ACTION)
continue;

//Rethink what we're supposed to do
ResetIntentionInterface(i);
}
Expand Down Expand Up @@ -227,7 +231,8 @@ static Action Timer_PlayerSpawn(Handle timer, any data)
#endif

#if defined MOD_CUSTOM_ATTRIBUTES
TF2Attrib_SetByName(data, "cannot be sapped", 1.0);
if (TF2Attrib_IsValidAttributeName("cannot be sapped"))
TF2Attrib_SetByName(data, "cannot be sapped", 1.0);
#endif

SetRandomNameOnBot(data);
Expand Down
34 changes: 6 additions & 28 deletions source/redbots3/nextbot_actions.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,12 @@ bool CTFBotDefenderAttack_SelectTarget(int actor, bool bBombCarrierOnly = false)
//Found a valid target, update
if (target != -1)
{
//Go after the healer first
int healer = GetHealerOfPlayer(target, true);

if (healer != -1)
target = healer;

m_iAttackTarget[actor] = target;
return true;
}
Expand Down Expand Up @@ -5499,32 +5505,4 @@ void GetFlameThrowerAimForTank(int tank, float aimPos[3])
{
aimPos = WorldSpaceCenter(tank);
aimPos[2] += 90.0;
}

bool IsImmediateThreat(int client, const CKnownEntity threat)
{
if (!threat.IsVisibleRecently())
return false;

int iThreat = threat.GetEntity();

if (!TF2_IsLineOfFireClear4(client, iThreat))
return false;

float myAbsOrigin[3]; GetClientAbsOrigin(client, myAbsOrigin);
float lastKnownPos[3]; threat.GetLastKnownPosition(lastKnownPos);

float to[3]; SubtractVectors(myAbsOrigin, lastKnownPos, to);
float threatRange = NormalizeVector(to, to);

const float nearbyRange = 500.0;

//Nearby threats are always dangerous
if (threatRange < nearbyRange)
return true;

if (!BaseEntity_IsPlayer(iThreat))
return false;

return false;
}
18 changes: 18 additions & 0 deletions source/redbots3/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,24 @@ bool IsCloakedPlayerExposed(int client)
return false;
}

int GetHealerOfPlayer(int client, bool bPlayerOnly = false)
{
for (int i = 0; i < TF2_GetNumHealers(client); i++)
{
int healer = TF2Util_GetPlayerHealer(client, i);

if (healer != -1)
{
if (bPlayerOnly && !BaseEntity_IsPlayer(healer))
continue;

return healer;
}
}

return -1;
}

int GetNearestCurrencyPack(int client, const float max_distance = 999999.0)
{
float origin[3]; GetClientAbsOrigin(client, origin);
Expand Down
69 changes: 44 additions & 25 deletions source/tf2_defenderbots.sp
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,26 @@ public void OnMapStart()

public void OnConfigsExecuted()
{
tf_bot_path_lookahead_range = FindConVar("tf_bot_path_lookahead_range");
tf_bot_health_critical_ratio = FindConVar("tf_bot_health_critical_ratio");
tf_bot_health_ok_ratio = FindConVar("tf_bot_health_ok_ratio");
tf_bot_ammo_search_range = FindConVar("tf_bot_ammo_search_range");
tf_bot_health_search_far_range = FindConVar("tf_bot_health_search_far_range");
tf_bot_health_search_near_range = FindConVar("tf_bot_health_search_near_range");
tf_bot_suicide_bomb_range = FindConVar("tf_bot_suicide_bomb_range");
if (!tf_bot_path_lookahead_range)
tf_bot_path_lookahead_range = FindConVar("tf_bot_path_lookahead_range");

if (!tf_bot_health_critical_ratio)
tf_bot_health_critical_ratio = FindConVar("tf_bot_health_critical_ratio");

if (!tf_bot_health_ok_ratio)
tf_bot_health_ok_ratio = FindConVar("tf_bot_health_ok_ratio");

if (!tf_bot_ammo_search_range)
tf_bot_ammo_search_range = FindConVar("tf_bot_ammo_search_range");

if (!tf_bot_health_search_far_range)
tf_bot_health_search_far_range = FindConVar("tf_bot_health_search_far_range");

if (!tf_bot_health_search_near_range)
tf_bot_health_search_near_range = FindConVar("tf_bot_health_search_near_range");

if (!tf_bot_suicide_bomb_range)
tf_bot_suicide_bomb_range = FindConVar("tf_bot_suicide_bomb_range");
}

/* public void OnMapEnd()
Expand Down Expand Up @@ -1034,26 +1047,32 @@ public Action Listener_TournamentPlayerReadystate(int client, const char[] comma

public Action SoundHook_General(int clients[MAXPLAYERS], int &numClients, char sample[PLATFORM_MAX_PATH], int &entity, int &channel, float &volume, int &level, int &pitch, int &flags, char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
if (channel == SNDCHAN_VOICE && volume > 0.0 && BaseEntity_IsPlayer(entity) && TF2_IsPlayerInCondition(entity, TFCond_Disguised) && !TF2_IsStealthed(entity))
if (channel == SNDCHAN_VOICE && volume > 0.0 && BaseEntity_IsPlayer(entity))
{
//Robots have robotic voices even when disguised
//Any defender bot that can see him right now will call him out
for (int i = 1; i <= MaxClients; i++)
if (StrContains(sample, "spy_mvm_LaughShort", false) != -1)
{
if (i == entity)
continue;

if (!IsClientInGame(i))
continue;

if (g_bIsDefenderBot[i] == false)
continue;

if (GetClientTeam(entity) == GetClientTeam(i))
continue;

if (TF2_IsLineOfFireClear4(i, entity))
RealizeSpy(i, entity);
if (TF2_IsPlayerInCondition(entity, TFCond_Disguised) && !TF2_IsStealthed(entity))
{
/* Robots have robotic voices even when disguised so any
defender bot that can see him right now will call him out */
for (int i = 1; i <= MaxClients; i++)
{
if (i == entity)
continue;

if (!IsClientInGame(i))
continue;

if (g_bIsDefenderBot[i] == false)
continue;

if (GetClientTeam(entity) == GetClientTeam(i))
continue;

if (TF2_IsLineOfFireClear4(i, entity))
RealizeSpy(i, entity);
}
}
}
}

Expand Down

0 comments on commit 07d4642

Please sign in to comment.