mirror of
https://github.com/ENSL/NS.git
synced 2025-03-14 06:34:33 +00:00
Commander building improvements
This commit is contained in:
parent
1c78990e2a
commit
3add241a64
9 changed files with 180 additions and 177 deletions
|
@ -949,7 +949,7 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
bool bEnemyInBase = NumInfantryPortals > 1 && AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bSuccess = !bEnemyInBase && AICOMM_BuildInfantryPortal(pBot, CommChair);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kInfantryPortalCost) + 5);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kInfantryPortalCost) + 10);
|
||||
}
|
||||
|
||||
StructureFilter.DeployableTypes = (STRUCTURE_MARINE_ARMOURY | STRUCTURE_MARINE_ADVARMOURY);
|
||||
|
@ -959,49 +959,55 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
if (!BaseArmoury && !FNullEnt(BaseBuilder))
|
||||
{
|
||||
Vector BuildLocation = AITAC_GetRandomBuildHintInLocation(STRUCTURE_MARINE_ARMOURY, CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bFoundLocation = !vIsZero(BuildLocation);
|
||||
bool bSuccess = false;
|
||||
|
||||
if (bFoundLocation)
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
if (!bSuccess)
|
||||
StructureFilter.DeployableTypes = STRUCTURE_MARINE_INFANTRYPORTAL;
|
||||
|
||||
AvHAIBuildableStructure* NearestInfantryPortal = AITAC_FindClosestDeployableToLocation(CommChair->v.origin, &StructureFilter);
|
||||
|
||||
if (NearestInfantryPortal)
|
||||
{
|
||||
StructureFilter.DeployableTypes = STRUCTURE_MARINE_INFANTRYPORTAL;
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), NearestInfantryPortal->Location, UTIL_MetresToGoldSrcUnits(5.0f));
|
||||
|
||||
AvHAIBuildableStructure* NearestInfantryPortal = AITAC_FindClosestDeployableToLocation(CommChair->v.origin, &StructureFilter);
|
||||
|
||||
|
||||
if (NearestInfantryPortal)
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), NearestInfantryPortal->Location, UTIL_MetresToGoldSrcUnits(5.0f));
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
bFoundLocation = true;
|
||||
}
|
||||
}
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
|
||||
if (!bSuccess)
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
bFoundLocation = true;
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bFoundLocation)
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kArmoryCost) + 5);
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMOURY, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
if (pBot->Player->GetResources() <= BALANCE_VAR(kArmoryCost) + 5) { return true; }
|
||||
}
|
||||
|
||||
const AvHAIHiveDefinition* HiveUnderSiege = AITAC_GetNearestHiveUnderActiveSiege(pBot->Player->GetTeam(), AITAC_GetCommChairLocation(pBot->Player->GetTeam()));
|
||||
|
@ -1033,17 +1039,26 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
|
||||
Vector BuildLocation = AITAC_GetRandomBuildHintInLocation(STRUCTURE_MARINE_PHASEGATE, CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (vIsZero(BuildLocation))
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PHASEGATE, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bSuccess = !bEnemyInBase && AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PHASEGATE, BuildLocation);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kPhaseGateCost) + 5);
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kPhaseGateCost) + 10) { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1053,7 +1068,9 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
if (CappableNode)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_RESTOWER, CappableNode->Location);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kResourceTowerCost) + 5);
|
||||
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kResourceTowerCost) + 10) { return true; }
|
||||
|
||||
}
|
||||
|
||||
const AvHAIHiveDefinition* HiveToSecure = AICOMM_GetEmptyHiveOpportunityNearestLocation(pBot, AITAC_GetCommChairLocation(TeamNumber));
|
||||
|
@ -1061,7 +1078,8 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
if (HiveToSecure)
|
||||
{
|
||||
bool bSuccess = AICOMM_PerformNextSecureHiveAction(pBot, HiveToSecure);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kTurretFactoryCost) + 5);
|
||||
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kTurretFactoryCost) + 5) { return true; }
|
||||
}
|
||||
|
||||
if (AICOMM_ShouldCommanderPrioritiseNodes(pBot) && pBot->Player->GetResources() < 30) { return false; }
|
||||
|
@ -1075,17 +1093,27 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
{
|
||||
Vector BuildLocation = AITAC_GetRandomBuildHintInLocation(STRUCTURE_MARINE_ARMSLAB, CommChair->v.origin, UTIL_MetresToGoldSrcUnits(15.0f));
|
||||
|
||||
if (vIsZero(BuildLocation))
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
}
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMSLAB, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bSuccess = !bEnemyInBase && AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_ARMSLAB, BuildLocation);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kArmsLabCost) + 5);
|
||||
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kArmsLabCost) + 10) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,19 +1123,32 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
|
||||
if (!bHasObservatory && !FNullEnt(BaseBuilder))
|
||||
{
|
||||
|
||||
|
||||
Vector BuildLocation = AITAC_GetRandomBuildHintInLocation(STRUCTURE_MARINE_OBSERVATORY, CommChair->v.origin, UTIL_MetresToGoldSrcUnits(15.0f));
|
||||
|
||||
if (vIsZero(BuildLocation))
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_OBSERVATORY, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bSuccess = !bEnemyInBase && AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_OBSERVATORY, BuildLocation);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kObservatoryCost) + 5);
|
||||
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kObservatoryCost) + 10) { return true; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1162,7 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
if (HiveToSiege)
|
||||
{
|
||||
bool bSuccess = AICOMM_PerformNextSiegeHiveAction(pBot, HiveToSiege);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kTurretFactoryCost) + 5);
|
||||
if (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kTurretFactoryCost) + 5) { return true; }
|
||||
}
|
||||
|
||||
StructureFilter.DeployableTypes = STRUCTURE_MARINE_ADVARMOURY;
|
||||
|
@ -1163,22 +1204,44 @@ bool AICOMM_CheckForNextBuildAction(AvHAIPlayer* pBot)
|
|||
{
|
||||
Vector BuildLocation = AITAC_GetRandomBuildHintInLocation(STRUCTURE_MARINE_PROTOTYPELAB, CommChair->v.origin, UTIL_MetresToGoldSrcUnits(15.0f));
|
||||
|
||||
if (vIsZero(BuildLocation))
|
||||
if(!vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInDonutIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), BaseArmoury->Location, UTIL_MetresToGoldSrcUnits(3.0f), UTIL_MetresToGoldSrcUnits(5.0f));
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PROTOTYPELAB, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
if (vIsZero(BuildLocation))
|
||||
{
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
}
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
bool bSuccess = !bEnemyInBase && AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PROTOTYPELAB, BuildLocation);
|
||||
return (bSuccess || pBot->Player->GetResources() <= BALANCE_VAR(kPrototypeLabCost) + 5);
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PROTOTYPELAB, BuildLocation);
|
||||
|
||||
if (bSuccess) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
BuildLocation = UTIL_GetRandomPointOnNavmeshInRadiusIgnoreReachability(GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE), CommChair->v.origin, UTIL_MetresToGoldSrcUnits(20.0f));
|
||||
|
||||
if (!vIsZero(BuildLocation))
|
||||
{
|
||||
bool bEnemyInBase = AITAC_AnyPlayerOnTeamWithLOS(AIMGR_GetEnemyTeam(TeamNumber), BuildLocation + Vector(0.0f, 0.0f, 32.0f), UTIL_MetresToGoldSrcUnits(10.0f));
|
||||
|
||||
if (!bEnemyInBase)
|
||||
{
|
||||
bool bSuccess = AICOMM_DeployStructure(pBot, STRUCTURE_MARINE_PROTOTYPELAB, BuildLocation);
|
||||
|
||||
if (bSuccess || pBot->Player->GetResources() < BALANCE_VAR(kPrototypeLabCost) + 20) { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -777,8 +777,32 @@ void GetFullFilePath(char* buffer, const char* mapname)
|
|||
|
||||
void ReloadNavMeshes()
|
||||
{
|
||||
vector<AvHAIPlayer*> AllBots = AIMGR_GetAllAIPlayers();
|
||||
|
||||
for (auto it = AllBots.begin(); it != AllBots.end(); it++)
|
||||
{
|
||||
AvHAIPlayer* ThisPlayer = (*it);
|
||||
|
||||
ClearBotMovement(ThisPlayer);
|
||||
}
|
||||
AITAC_ClearMapAIData(false);
|
||||
UnloadNavMeshes();
|
||||
LoadNavMesh(STRING(gpGlobals->mapname));
|
||||
bool bSuccess = LoadNavMesh(STRING(gpGlobals->mapname));
|
||||
|
||||
if (bSuccess)
|
||||
{
|
||||
UTIL_PopulateDoors();
|
||||
UTIL_PopulateWeldableObstacles();
|
||||
|
||||
UTIL_UpdateDoors(true);
|
||||
|
||||
bool bTileCacheFullyUpdated = UTIL_UpdateTileCache();
|
||||
|
||||
while (!bTileCacheFullyUpdated)
|
||||
{
|
||||
bTileCacheFullyUpdated = UTIL_UpdateTileCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnloadNavMeshes()
|
||||
|
|
|
@ -1629,7 +1629,7 @@ void StartNewBotFrame(AvHAIPlayer* pBot)
|
|||
{
|
||||
pBot->BotNavInfo.LastNavMeshPosition = pBot->CurrentFloorPosition;
|
||||
|
||||
if (pBot->BotNavInfo.IsOnGround)
|
||||
if (pBot->BotNavInfo.IsOnGround || IsPlayerLerk(pBot->Edict))
|
||||
{
|
||||
Vector ForwardVector = UTIL_GetForwardVector2D(pBot->Edict->v.angles);
|
||||
Vector RightVector = UTIL_GetCrossProduct(ForwardVector, UP_VECTOR);
|
||||
|
@ -1656,7 +1656,7 @@ void StartNewBotFrame(AvHAIPlayer* pBot)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!UTIL_TraceNav(pBot->BotNavInfo.NavProfile, pBot->CollisionHullBottomLocation, EndNavTrace, 0.0f))
|
||||
if (!UTIL_TraceNav(pBot->BotNavInfo.NavProfile, pBot->CurrentFloorPosition, EndNavTrace, 0.0f))
|
||||
{
|
||||
bHasRoom = false;
|
||||
break;
|
||||
|
@ -5040,7 +5040,7 @@ void BotSwitchToWeapon(AvHAIPlayer* pBot, AvHAIWeapon NewWeaponSlot)
|
|||
|
||||
bool ShouldBotThink(AvHAIPlayer* pBot)
|
||||
{
|
||||
return GetGameRules()->GetGameStarted() && (IsPlayerActiveInGame(pBot->Edict) || IsPlayerCommander(pBot->Edict)) && !IsPlayerGestating(pBot->Edict);
|
||||
return NavmeshLoaded() && GetGameRules()->GetGameStarted() && (IsPlayerActiveInGame(pBot->Edict) || IsPlayerCommander(pBot->Edict)) && !IsPlayerGestating(pBot->Edict);
|
||||
}
|
||||
|
||||
void BotResumePlay(AvHAIPlayer* pBot)
|
||||
|
|
|
@ -107,6 +107,8 @@ float AIMGR_GetCommanderAllowedTime(AvHTeamNumber Team)
|
|||
|
||||
void AIMGR_UpdateAIPlayerCounts()
|
||||
{
|
||||
if (!NavmeshLoaded()) { return; }
|
||||
|
||||
for (auto BotIt = ActiveAIPlayers.begin(); BotIt != ActiveAIPlayers.end();)
|
||||
{
|
||||
// If bot has been kicked from the server then remove from active AI player list
|
||||
|
@ -905,7 +907,7 @@ void AIMGR_RemoveBotsInReadyRoom()
|
|||
|
||||
void AIMGR_ResetRound()
|
||||
{
|
||||
if (avh_botsenabled.value == 0) { return; } // Do nothing if we're not using bots
|
||||
if (avh_botsenabled.value == 0 || !NavmeshLoaded()) { return; } // Do nothing if we're not using bots
|
||||
|
||||
// AI Players would be 0 if the round is being reset because a new game is starting. If the round is reset
|
||||
// from a console command, or tournament mode readying up etc, then bot logic is unaffected
|
||||
|
@ -939,6 +941,14 @@ void AIMGR_ResetRound()
|
|||
CountdownStartedTime = 0.0f;
|
||||
}
|
||||
|
||||
void AIMGR_ReloadNavigationData()
|
||||
{
|
||||
if (NavmeshLoaded())
|
||||
{
|
||||
ReloadNavMeshes();
|
||||
}
|
||||
}
|
||||
|
||||
void AIMGR_RoundStarted()
|
||||
{
|
||||
bHasRoundStarted = true;
|
||||
|
@ -966,6 +976,8 @@ void AIMGR_RoundStarted()
|
|||
AIMGR_SetCommanderAllowedTime(TeamBNumber, 0.0f);
|
||||
}
|
||||
|
||||
AITAC_RefreshTeamStartingLocations();
|
||||
|
||||
AITAC_OnNavMeshModified();
|
||||
}
|
||||
|
||||
|
@ -1180,6 +1192,8 @@ bool AIMGR_ShouldStartPlayerBalancing()
|
|||
|
||||
void AIMGR_UpdateAIMapData()
|
||||
{
|
||||
if (!NavmeshLoaded()) { return; }
|
||||
|
||||
if (GetGameRules()->GetCountdownStarted() && CountdownStartedTime == 0.0f)
|
||||
{
|
||||
CountdownStartedTime = gpGlobals->time;
|
||||
|
|
|
@ -68,6 +68,8 @@ int AIMGR_GetNumAIPlayersWithRoleOnTeam(AvHTeamNumber Team, AvHAIBotRole Role, A
|
|||
|
||||
int AIMGR_GetNumHumansOfClassOnTeam(AvHTeamNumber Team, AvHUser3 PlayerType);
|
||||
|
||||
void AIMGR_ReloadNavigationData();
|
||||
|
||||
AvHAIPlayer* AIMGR_GetAICommander(AvHTeamNumber Team);
|
||||
|
||||
AvHAIPlayer* AIMGR_GetBotRefFromPlayer(AvHPlayer* PlayerRef);
|
||||
|
|
|
@ -1503,12 +1503,12 @@ void AITAC_CheckNavMeshModified()
|
|||
if (bNavMeshModified)
|
||||
{
|
||||
AITAC_OnNavMeshModified();
|
||||
bNavMeshModified = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AITAC_OnNavMeshModified()
|
||||
{
|
||||
if (!NavmeshLoaded()) { return; }
|
||||
|
||||
for (auto it = TeamAStructureMap.begin(); it != TeamAStructureMap.end(); it++)
|
||||
{
|
||||
|
@ -1541,6 +1541,8 @@ void AITAC_OnNavMeshModified()
|
|||
ThisPlayer->BotNavInfo.NextForceRecalc = gpGlobals->time + frandrange(0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
bNavMeshModified = false;
|
||||
}
|
||||
|
||||
void AITAC_RefreshBuildableStructures()
|
||||
|
@ -2430,6 +2432,14 @@ void AITAC_ClearMapAIData(bool bInitialMapLoad)
|
|||
TeamBStartingLocation = ZERO_VECTOR;
|
||||
}
|
||||
|
||||
void AITAC_RefreshTeamStartingLocations()
|
||||
{
|
||||
TeamAStartingLocation = ZERO_VECTOR;
|
||||
TeamBStartingLocation = ZERO_VECTOR;
|
||||
|
||||
AITAC_GetTeamStartingLocation(GetGameRules()->GetTeamANumber());
|
||||
}
|
||||
|
||||
void AITAC_ClearHiveInfo()
|
||||
{
|
||||
for (auto it = Hives.begin(); it != Hives.end(); it++)
|
||||
|
|
|
@ -90,6 +90,8 @@ void AITAC_ClearMapAIData(bool bInitialMapLoad = false);
|
|||
// Clear out all the hive information
|
||||
void AITAC_ClearHiveInfo();
|
||||
|
||||
void AITAC_RefreshTeamStartingLocations();
|
||||
|
||||
void AITAC_ClearStructureNavData();
|
||||
|
||||
bool AITAC_AlienHiveNeedsReinforcing(const AvHAIHiveDefinition* Hive);
|
||||
|
|
|
@ -1415,7 +1415,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
|||
theSuccess = true;
|
||||
}
|
||||
}
|
||||
else if (FStrEq(pcmd, "setdebugaiplayer"))
|
||||
else if (FStrEq(pcmd, "ai_setdebugaiplayer"))
|
||||
{
|
||||
CBaseEntity* SpectatedPlayer = theAvHPlayer->GetSpectatingEntity();
|
||||
|
||||
|
@ -1430,19 +1430,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
|||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "setdebugvector1"))
|
||||
{
|
||||
AIDEBUG_SetDebugVector1(UTIL_GetFloorUnderEntity(theAvHPlayer->edict()));
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "setdebugvector2"))
|
||||
{
|
||||
AIDEBUG_SetDebugVector2(UTIL_GetFloorUnderEntity(theAvHPlayer->edict()));
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "cometome"))
|
||||
else if (FStrEq(pcmd, "ai_cometome"))
|
||||
{
|
||||
vector<AvHAIPlayer*> AIPlayers = AIMGR_GetAllAIPlayers();
|
||||
|
||||
|
@ -1456,120 +1444,15 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
|||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "drawtempobstacles"))
|
||||
else if (FStrEq(pcmd, "ai_drawtempobstacles"))
|
||||
{
|
||||
AIDEBUG_DrawTemporaryObstacles(10.0f);
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "nextmineposition"))
|
||||
else if (FStrEq(pcmd, "ai_drawoffmeshconns"))
|
||||
{
|
||||
DeployableSearchFilter NearestStructureFilter;
|
||||
NearestStructureFilter.DeployableTeam = theAvHPlayer->GetTeam();
|
||||
NearestStructureFilter.DeployableTypes = (STRUCTURE_MARINE_INFANTRYPORTAL | STRUCTURE_MARINE_TURRETFACTORY | STRUCTURE_MARINE_ARMOURY);
|
||||
|
||||
AvHAIBuildableStructure* Nearest = AITAC_FindClosestDeployableToLocation(theAvHPlayer->pev->origin, &NearestStructureFilter);
|
||||
|
||||
if (Nearest)
|
||||
{
|
||||
Vector MinePosition = UTIL_GetNextMinePosition2(Nearest->edict);
|
||||
|
||||
if (!vIsZero(MinePosition))
|
||||
{
|
||||
UTIL_DrawLine(INDEXENT(1), INDEXENT(1)->v.origin, MinePosition, 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "testoffwalknode"))
|
||||
{
|
||||
Vector MoveFrom = AIDEBUG_GetDebugVector1();
|
||||
Vector MoveTo = AIDEBUG_GetDebugVector2();
|
||||
|
||||
if (!vIsZero(MoveFrom) && !vIsZero(MoveTo))
|
||||
{
|
||||
bool bOnGround = (theAvHPlayer->pev->flags & FL_ONGROUND) || IsPlayerOnLadder(theAvHPlayer->edict());
|
||||
bool Result = false;
|
||||
|
||||
if (!bOnGround)
|
||||
{
|
||||
Result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector NearestPointOnLine = vClosestPointOnLine2D(MoveFrom, MoveTo, theAvHPlayer->pev->origin);
|
||||
|
||||
if (vDist2DSq(theAvHPlayer->pev->origin, NearestPointOnLine) > sqrf(GetPlayerRadius(theAvHPlayer->edict()) * 3.0f)) { Result = true; }
|
||||
|
||||
if (vEquals2D(NearestPointOnLine, MoveFrom) && !UTIL_PointIsDirectlyReachable(GetPlayerBottomOfCollisionHull(theAvHPlayer->edict()), MoveFrom)) { Result = true; }
|
||||
if (vEquals2D(NearestPointOnLine, MoveTo) && !UTIL_PointIsDirectlyReachable(GetPlayerBottomOfCollisionHull(theAvHPlayer->edict()), MoveTo)) { Result = true; }
|
||||
}
|
||||
|
||||
if (Result)
|
||||
{
|
||||
UTIL_SayText("TRUE\n", theAvHPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_SayText("FALSE\n", theAvHPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "testoffclimbnode"))
|
||||
{
|
||||
Vector MoveStart = AIDEBUG_GetDebugVector1();
|
||||
Vector MoveEnd = AIDEBUG_GetDebugVector2();
|
||||
|
||||
if (!vIsZero(MoveStart) && !vIsZero(MoveEnd))
|
||||
{
|
||||
bool bOnGround = (theAvHPlayer->pev->flags & FL_ONGROUND) || IsPlayerOnLadder(theAvHPlayer->edict());
|
||||
bool Result = false;
|
||||
|
||||
edict_t* PlayerEdict = theAvHPlayer->edict();
|
||||
|
||||
if (bOnGround)
|
||||
{
|
||||
if (!UTIL_PointIsDirectlyReachable(GetPlayerBottomOfCollisionHull(PlayerEdict), MoveStart) && !UTIL_PointIsDirectlyReachable(GetPlayerBottomOfCollisionHull(PlayerEdict), MoveEnd))
|
||||
{
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector ClosestPointOnLine = vClosestPointOnLine2D(MoveStart, MoveEnd, PlayerEdict->v.origin);
|
||||
|
||||
Result = vDist2DSq(PlayerEdict->v.origin, ClosestPointOnLine) > sqrf(GetPlayerRadius(PlayerEdict) * 3.0f);
|
||||
}
|
||||
|
||||
if (Result)
|
||||
{
|
||||
UTIL_SayText("TRUE\n", theAvHPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_SayText("FALSE\n", theAvHPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
else if (FStrEq(pcmd, "amonladder"))
|
||||
{
|
||||
if (IsPlayerOnLadder(theAvHPlayer->edict()))
|
||||
{
|
||||
UTIL_SayText("TRUE\n", theAvHPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_SayText("FALSE\n", theAvHPlayer);
|
||||
}
|
||||
AIDEBUG_DrawOffMeshConnections(10.0f);
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
|
|
|
@ -392,6 +392,11 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
|
|||
AIMGR_RemoveAIPlayerFromTeam(DesiredTeam);
|
||||
});
|
||||
|
||||
REGISTER_SERVER_FUNCTION("sv_reloadnavmesh", []()
|
||||
{
|
||||
AIMGR_ReloadNavigationData();
|
||||
});
|
||||
|
||||
g_VoiceGameMgr.Init(&gVoiceHelper, gpGlobals->maxClients);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
Loading…
Reference in a new issue