Minor bug fixes

This commit is contained in:
RGreenlees 2024-03-20 18:05:49 +00:00 committed by pierow
parent c75d7ec80b
commit b3cb4ceda1
3 changed files with 113 additions and 47 deletions

View file

@ -3505,7 +3505,23 @@ void AIPlayerSetMarineAssaultPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Tas
}
}
if (Task->TaskType != TASK_ATTACK)
{
DeployableSearchFilter AnyEnemyStuff;
AnyEnemyStuff.DeployableTeam = EnemyTeam;
AnyEnemyStuff.DeployableTypes = SEARCH_ALL_STRUCTURES;
AnyEnemyStuff.ReachabilityTeam = BotTeam;
AnyEnemyStuff.ReachabilityFlags = pBot->BotNavInfo.NavProfile.ReachabilityFlag;
AvHAIBuildableStructure EnemyStructure = AITAC_FindClosestDeployableToLocation(pBot->Edict->v.origin, &AnyEnemyStuff);
if (EnemyStructure.IsValid())
{
AITASK_SetAttackTask(pBot, Task, EnemyStructure.edict, false);
return;
}
}
}
void AIPlayerSetMarineBombardierPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
@ -5579,20 +5595,29 @@ void AIPlayerSetAlienCapperPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
AvHAIResourceNode* NodeToCap = nullptr;
bool bCanAttackTowers = (!IsPlayerGorge(pBot->Edict) || PlayerHasWeapon(pBot->Player, WEAPON_GORGE_BILEBOMB));
// If we're already capping a node, are at the node and there is an unfinished tower on there, then finish the job and don't move on yet
if (Task->TaskType == TASK_CAP_RESNODE)
{
const AvHAIResourceNode* ResNodeIndex = AITAC_GetNearestResourceNodeToLocation(Task->TaskLocation);
if (ResNodeIndex && ResNodeIndex->OwningTeam == BotTeam)
if (ResNodeIndex && ResNodeIndex->OwningTeam != BotTeam)
{
if (!FNullEnt(ResNodeIndex->ActiveTowerEntity) && !UTIL_StructureIsFullyBuilt(ResNodeIndex->ActiveTowerEntity))
if (ResNodeIndex->OwningTeam != BotTeam)
{
if (vDist2DSq(pBot->Edict->v.origin, ResNodeIndex->Location) < sqrf(UTIL_MetresToGoldSrcUnits(5.0f)))
{
return;
}
if (!ResNodeIndex->bIsOccupied || bCanAttackTowers) { return; }
}
else
{
if (!FNullEnt(ResNodeIndex->ActiveTowerEntity) && !UTIL_StructureIsFullyBuilt(ResNodeIndex->ActiveTowerEntity))
{
if (vDist2DSq(pBot->Edict->v.origin, ResNodeIndex->Location) < sqrf(UTIL_MetresToGoldSrcUnits(5.0f)))
{
return;
}
}
}
}
}
@ -5610,8 +5635,6 @@ void AIPlayerSetAlienCapperPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
bCanPlaceTower = pBot->Player->GetResources() >= 75 && AITAC_GetTeamResNodeOwnership(BotTeam, true) >= 0.5f;
}
bool bCanAttackTowers = (!IsPlayerGorge(pBot->Edict) || PlayerHasWeapon(pBot->Player, WEAPON_GORGE_BILEBOMB));
// If we have enough resources to cap a node, then find an empty one we can slap one down in
if (bCanPlaceTower || !bCanAttackTowers)
{
@ -5779,38 +5802,43 @@ void AIPlayerSetAlienAssaultPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task
if (Task->TaskType == TASK_EVOLVE) { return; }
if (CONFIG_IsOnosAllowed() && !IsPlayerOnos(pBot->Edict) && pBot->Player->GetResources() >= BALANCE_VAR(kOnosCost))
if (!IsPlayerFade(pBot->Edict) && !IsPlayerOnos(pBot->Edict))
{
int NumOnos = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER5, pBot->Edict);
if (NumOnos < 2)
if (CONFIG_IsOnosAllowed() && !IsPlayerOnos(pBot->Edict) && pBot->Player->GetResources() >= BALANCE_VAR(kOnosCost))
{
const AvHAIHiveDefinition* NearestHive = AITAC_GetNearestTeamHive(BotTeam, pBot->Edict->v.origin, true);
int NumOnos = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER5, pBot->Edict);
if (NearestHive)
if (NumOnos < 2)
{
AITASK_SetEvolveTask(pBot, Task, NearestHive->HiveEdict, ALIEN_LIFEFORM_FIVE, true);
return;
const AvHAIHiveDefinition* NearestHive = AITAC_GetNearestTeamHive(BotTeam, pBot->Edict->v.origin, true);
if (NearestHive)
{
AITASK_SetEvolveTask(pBot, Task, NearestHive->HiveEdict, ALIEN_LIFEFORM_FIVE, true);
return;
}
}
}
}
if (CONFIG_IsFadeAllowed() && !IsPlayerFade(pBot->Edict) && pBot->Player->GetResources() >= BALANCE_VAR(kFadeCost))
{
int NumFades = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER4, pBot->Edict);
int NumOnos = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER5, pBot->Edict);
if (NumFades < 2 || NumOnos >= 2)
if (CONFIG_IsFadeAllowed() && !IsPlayerFade(pBot->Edict) && pBot->Player->GetResources() >= BALANCE_VAR(kFadeCost))
{
const AvHAIHiveDefinition* NearestHive = AITAC_GetNearestTeamHive(BotTeam, pBot->Edict->v.origin, true);
int NumFades = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER4, pBot->Edict);
int NumOnos = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER5, pBot->Edict);
if (NearestHive)
if (NumFades < 2 || NumOnos >= 2)
{
AITASK_SetEvolveTask(pBot, Task, NearestHive->HiveEdict, ALIEN_LIFEFORM_FOUR, true);
return;
}
const AvHAIHiveDefinition* NearestHive = AITAC_GetNearestTeamHive(BotTeam, pBot->Edict->v.origin, true);
if (NearestHive)
{
AITASK_SetEvolveTask(pBot, Task, NearestHive->HiveEdict, ALIEN_LIFEFORM_FOUR, true);
return;
}
}
}
}
const AvHAIHiveDefinition* NearestSiegedHive = AITAC_GetNearestHiveUnderActiveSiege(EnemyTeam, pBot->Edict->v.origin);
@ -6683,8 +6711,18 @@ void AIPlayerSetWantsAndNeedsAlienTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
float GetHealthThreshold = 0.6f;
if (IsPlayerOnos(pBot->Edict))
{
GetHealthThreshold = 0.33f;
}
if (IsPlayerFade(pBot->Edict))
{
GetHealthThreshold = 0.5f;
}
// If we're right by a healing source, then might as well heal up, set the "find health" threshold to 90% or less health
if (vDist2DSq(pBot->Edict->v.origin, NearestHealingSource->v.origin) < sqrf(UTIL_MetresToGoldSrcUnits(10.0f)))
if (vDist2DSq(pBot->Edict->v.origin, NearestHealingSource->v.origin) < sqrf(UTIL_MetresToGoldSrcUnits(5.0f)))
{
GetHealthThreshold = 0.9f;
}

View file

@ -1809,36 +1809,56 @@ void AITAC_UpdateMapAIData()
}
vector<AvHPlayer*> AllTeamAPlayers = AITAC_GetAllPlayersOnTeamOfClass(GetGameRules()->GetTeamANumber(), AVH_USER3_ALIEN_PLAYER3, nullptr);
edict_t* LastTeamALerk = nullptr;
edict_t* LastTeamALerk = LastSeenLerkTeamA;
for (auto it = AllTeamAPlayers.begin(); it != AllTeamAPlayers.end(); it++)
if (!FNullEnt(LastTeamALerk) && IsPlayerLerk(LastTeamALerk))
{
edict_t* PlayerEdict = (*it)->edict();
if (FNullEnt(LastTeamALerk) || IsPlayerHuman(PlayerEdict))
LastSeenLerkTeamATime = gpGlobals->time;
}
else
{
for (auto it = AllTeamAPlayers.begin(); it != AllTeamAPlayers.end(); it++)
{
LastTeamALerk = PlayerEdict;
LastSeenLerkTeamATime = gpGlobals->time;
edict_t* PlayerEdict = (*it)->edict();
if (FNullEnt(LastTeamALerk) || IsPlayerHuman(PlayerEdict))
{
LastTeamALerk = PlayerEdict;
LastSeenLerkTeamATime = gpGlobals->time;
}
}
LastSeenLerkTeamA = LastTeamALerk;
}
LastSeenLerkTeamA = LastTeamALerk;
vector<AvHPlayer*> AllTeamBPlayers = AITAC_GetAllPlayersOnTeamOfClass(GetGameRules()->GetTeamBNumber(), AVH_USER3_ALIEN_PLAYER3, nullptr);
edict_t* LastTeamBLerk = nullptr;
edict_t* LastTeamBLerk = LastSeenLerkTeamB;
for (auto it = AllTeamBPlayers.begin(); it != AllTeamBPlayers.end(); it++)
if (!FNullEnt(LastTeamBLerk) && IsPlayerLerk(LastTeamBLerk))
{
edict_t* PlayerEdict = (*it)->edict();
if (FNullEnt(LastTeamBLerk) || IsPlayerHuman(PlayerEdict))
LastSeenLerkTeamBTime = gpGlobals->time;
}
else
{
for (auto it = AllTeamBPlayers.begin(); it != AllTeamBPlayers.end(); it++)
{
LastTeamBLerk = PlayerEdict;
LastSeenLerkTeamBTime = gpGlobals->time;
edict_t* PlayerEdict = (*it)->edict();
if (FNullEnt(LastTeamBLerk) || IsPlayerHuman(PlayerEdict))
{
LastTeamBLerk = PlayerEdict;
LastSeenLerkTeamBTime = gpGlobals->time;
}
}
LastSeenLerkTeamB = LastTeamBLerk;
}
LastSeenLerkTeamB = LastTeamALerk;
}
@ -4604,6 +4624,8 @@ bool AITAC_IsAlienHarasserNeeded(AvHAIPlayer* pBot)
// We only go lerk if the last lerk we had in the match was either us, or we've not had another lerk in 60 seconds
// It avoids aliens spending all their resources on evolving lerks if they keep dying
// It also means that if a human was playing lerk and died, a bot doesn't immediately take over that role, and lets the human try again if they want
return (FNullEnt(PreviousLerk) || (gpGlobals->time - LastSeenTime > CONFIG_GetLerkCooldown()) || PreviousLerk == pBot->Edict);
}
@ -4626,6 +4648,11 @@ bool AITAC_ShouldBotBuildHive(AvHAIPlayer* pBot, AvHAIHiveDefinition** EligibleH
AvHTeamNumber BotTeam = pBot->Player->GetTeam();
AvHTeamNumber EnemyTeam = AIMGR_GetEnemyTeam(BotTeam);
// Prioritise getting at least one fade or Onos on the team before putting up a second hive, or we're likely to lose it pretty quickly
int NumHeavyHitters = AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER4, nullptr) + AITAC_GetNumPlayersOnTeamOfClass(BotTeam, AVH_USER3_ALIEN_PLAYER5, nullptr);
if (NumHeavyHitters == 0) { return false; }
// If we're a higher lifeform, ensure we can't leave this to someone else before considering losing those resources
// We will ignore humans and third party bots, because we don't know if they will drop the hive or not. Not everyone can be as team-spirited as us...
if (!IsPlayerSkulk(pBot->Edict) && !IsPlayerGorge(pBot->Edict))

View file

@ -1379,7 +1379,7 @@ void BotProgressReinforceStructureTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
}
BotGuardLocation(pBot, ReinforceLocation);
BotGuardLocation(pBot, (!vIsZero(Task->TaskLocation)) ? Task->TaskLocation : ReinforceLocation);
}
@ -1653,6 +1653,7 @@ void BotProgressAttackTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
}
MoveTo(pBot, pBot->LastSafeLocation, MOVESTYLE_NORMAL);
return;
}
}
}
@ -1687,7 +1688,7 @@ void BotProgressAttackTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
BotShootTarget(pBot, Weapon, Task->TaskTarget);
if (IsDamagingStructure(Task->TaskTarget))
if (IsDamagingStructure(Task->TaskTarget) && !IsMeleeWeapon(Weapon))
{
Vector EnemyOrientation = UTIL_GetVectorNormal2D(Task->TaskTarget->v.origin - pBot->Edict->v.origin);