mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
Fix door detection, prep for test
This commit is contained in:
parent
b3cb4ceda1
commit
661ed9c1ac
5 changed files with 97 additions and 44 deletions
|
@ -2405,7 +2405,7 @@ void CheckAndHandleDoorObstruction(AvHAIPlayer* pBot)
|
||||||
{
|
{
|
||||||
bot_path_node ThisPathNode = pBot->BotNavInfo.CurrentPath[i];
|
bot_path_node ThisPathNode = pBot->BotNavInfo.CurrentPath[i];
|
||||||
|
|
||||||
BlockingDoorEdict = UTIL_GetDoorBlockingPathPoint(ThisPathNode.FromLocation, ThisPathNode.Location, SAMPLE_POLYAREA_GROUND, nullptr);
|
BlockingDoorEdict = UTIL_GetDoorBlockingPathPoint(ThisPathNode.FromLocation, ThisPathNode.Location, ThisPathNode.flag, nullptr);
|
||||||
|
|
||||||
NumIterations++;
|
NumIterations++;
|
||||||
|
|
||||||
|
@ -2451,7 +2451,7 @@ void CheckAndHandleDoorObstruction(AvHAIPlayer* pBot)
|
||||||
{
|
{
|
||||||
// Wait for the door to finish opening
|
// Wait for the door to finish opening
|
||||||
pBot->desiredMovementDir = g_vecZero;
|
pBot->desiredMovementDir = g_vecZero;
|
||||||
BotLookAt(pBot, BlockingDoorEdict);
|
BotLookAt(pBot, CurrentPathNode.Location);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2497,7 +2497,7 @@ void CheckAndHandleDoorObstruction(AvHAIPlayer* pBot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DoorTrigger* Trigger = UTIL_GetNearestDoorTrigger(pBot->Edict->v.origin, Door, nullptr, true);
|
DoorTrigger* Trigger = UTIL_GetNearestDoorTrigger(pBot->CurrentFloorPosition, Door, nullptr, true);
|
||||||
|
|
||||||
if (Trigger && Trigger->NextActivationTime < gpGlobals->time)
|
if (Trigger && Trigger->NextActivationTime < gpGlobals->time)
|
||||||
{
|
{
|
||||||
|
@ -7730,7 +7730,7 @@ void UTIL_UpdateDoors(bool bInitial)
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
||||||
DoorCentre.z -= 16.0f;
|
DoorCentre.z -= 24.0f;
|
||||||
|
|
||||||
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
||||||
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
||||||
|
@ -7738,7 +7738,7 @@ void UTIL_UpdateDoors(bool bInitial)
|
||||||
dtPolyRef Polys[8];
|
dtPolyRef Polys[8];
|
||||||
int polyCount;
|
int polyCount;
|
||||||
|
|
||||||
float DoorHalfExtents[3] = { it->DoorEdict->v.size.x, it->DoorEdict->v.size.z, it->DoorEdict->v.size.y };
|
float DoorHalfExtents[3] = { HalfExtents.x, HalfExtents.z, HalfExtents.y };
|
||||||
float DoorCentreFlt[3] = { DoorCentre.x, DoorCentre.z, -DoorCentre.y };
|
float DoorCentreFlt[3] = { DoorCentre.x, DoorCentre.z, -DoorCentre.y };
|
||||||
|
|
||||||
Query->queryPolygons(DoorCentreFlt, DoorHalfExtents, &StructureProfile.Filters, Polys, &polyCount, 8);
|
Query->queryPolygons(DoorCentreFlt, DoorHalfExtents, &StructureProfile.Filters, Polys, &polyCount, 8);
|
||||||
|
@ -7797,7 +7797,7 @@ void UTIL_UpdateDoors(bool bInitial)
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
||||||
DoorCentre.z -= 16.0f;
|
DoorCentre.z -= 24.0f;
|
||||||
|
|
||||||
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
||||||
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
||||||
|
@ -7805,7 +7805,7 @@ void UTIL_UpdateDoors(bool bInitial)
|
||||||
dtPolyRef Polys[8];
|
dtPolyRef Polys[8];
|
||||||
int polyCount;
|
int polyCount;
|
||||||
|
|
||||||
float DoorHalfExtents[3] = {it->DoorEdict->v.size.x, it->DoorEdict->v.size.z, it->DoorEdict->v.size.y};
|
float DoorHalfExtents[3] = { HalfExtents.x, HalfExtents.z, HalfExtents.y};
|
||||||
float DoorCentreFlt[3] = { DoorCentre.x, DoorCentre.z, -DoorCentre.y };
|
float DoorCentreFlt[3] = { DoorCentre.x, DoorCentre.z, -DoorCentre.y };
|
||||||
|
|
||||||
Query->queryPolygons(DoorCentreFlt, DoorHalfExtents, &StructureProfile.Filters, Polys, &polyCount, 8);
|
Query->queryPolygons(DoorCentreFlt, DoorHalfExtents, &StructureProfile.Filters, Polys, &polyCount, 8);
|
||||||
|
@ -7819,7 +7819,7 @@ void UTIL_UpdateDoors(bool bInitial)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
Vector DoorCentre = UTIL_GetCentreOfEntity(it->DoorEdict);
|
||||||
DoorCentre.z -= 16.0f;
|
DoorCentre.z -= 24.0f;
|
||||||
|
|
||||||
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
dtNavMeshQuery* Query = NavMeshes[BUILDING_NAV_MESH].navQuery;
|
||||||
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
nav_profile StructureProfile = GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE);
|
||||||
|
|
|
@ -1038,12 +1038,12 @@ void BotEvolveLifeform(AvHAIPlayer* pBot, Vector DesiredEvolveLocation, AvHMessa
|
||||||
|
|
||||||
if (vIsZero(EvolvePoint))
|
if (vIsZero(EvolvePoint))
|
||||||
{
|
{
|
||||||
EvolvePoint = UTIL_ProjectPointToNavmesh(DesiredEvolveLocation, Vector(400.0f, 400.0f, 400.0f), GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE));
|
EvolvePoint = UTIL_ProjectPointToNavmesh(DesiredEvolveLocation, Vector(500.0f, 500.0f, 500.0f), GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vIsZero(EvolvePoint))
|
if (vIsZero(EvolvePoint))
|
||||||
{
|
{
|
||||||
EvolvePoint = UTIL_ProjectPointToNavmesh(DesiredEvolveLocation, Vector(400.0f, 400.0f, 400.0f), GetBaseNavProfile(GORGE_BASE_NAV_PROFILE));
|
EvolvePoint = UTIL_AdjustPointAwayFromNavWall(pBot->CurrentFloorPosition, 50.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vDist2DSq(pBot->Edict->v.origin, EvolvePoint) > sqrf(32.0f))
|
if (vDist2DSq(pBot->Edict->v.origin, EvolvePoint) > sqrf(32.0f))
|
||||||
|
@ -1052,8 +1052,6 @@ void BotEvolveLifeform(AvHAIPlayer* pBot, Vector DesiredEvolveLocation, AvHMessa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (pBot->Player->GetResources() >= EvolveCost)
|
if (pBot->Player->GetResources() >= EvolveCost)
|
||||||
{
|
{
|
||||||
pBot->Impulse = TargetLifeform;
|
pBot->Impulse = TargetLifeform;
|
||||||
|
@ -1062,14 +1060,14 @@ void BotEvolveLifeform(AvHAIPlayer* pBot, Vector DesiredEvolveLocation, AvHMessa
|
||||||
|
|
||||||
void BotEvolveUpgrade(AvHAIPlayer* pBot, Vector DesiredEvolveLocation, AvHMessageID TargetUpgrade)
|
void BotEvolveUpgrade(AvHAIPlayer* pBot, Vector DesiredEvolveLocation, AvHMessageID TargetUpgrade)
|
||||||
{
|
{
|
||||||
Vector EvolvePoint = UTIL_ProjectPointToNavmesh(DesiredEvolveLocation, GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE));
|
Vector EvolvePoint = UTIL_ProjectPointToNavmesh(DesiredEvolveLocation, Vector(500.0f, 500.0f, 500.0f), GetBaseNavProfile(STRUCTURE_BASE_NAV_PROFILE));
|
||||||
|
|
||||||
if (vIsZero(EvolvePoint))
|
if (vIsZero(EvolvePoint))
|
||||||
{
|
{
|
||||||
EvolvePoint = DesiredEvolveLocation;
|
EvolvePoint = UTIL_AdjustPointAwayFromNavWall(pBot->CurrentFloorPosition, (GetPlayerRadius(pBot->Edict) * 2.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vDist2DSq(pBot->Edict->v.origin, EvolvePoint) > sqrf(32.0f))
|
if (vDist2DSq(pBot->CurrentFloorPosition, EvolvePoint) > sqrf(8.0f))
|
||||||
{
|
{
|
||||||
MoveTo(pBot, EvolvePoint, MOVESTYLE_NORMAL);
|
MoveTo(pBot, EvolvePoint, MOVESTYLE_NORMAL);
|
||||||
return;
|
return;
|
||||||
|
@ -4183,19 +4181,91 @@ void AIPlayerNSAlienThink(AvHAIPlayer* pBot)
|
||||||
|
|
||||||
AvHMessageID AlienGetDesiredUpgrade(AvHAIPlayer* pBot, HiveTechStatus DesiredTech)
|
AvHMessageID AlienGetDesiredUpgrade(AvHAIPlayer* pBot, HiveTechStatus DesiredTech)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (DesiredTech == HIVE_TECH_DEFENCE)
|
if (DesiredTech == HIVE_TECH_DEFENCE)
|
||||||
{
|
{
|
||||||
return ALIEN_EVOLUTION_ONE;
|
switch (pBot->Player->GetUser3())
|
||||||
|
{
|
||||||
|
case AVH_USER3_ALIEN_PLAYER1:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER2:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER3: // Gorges can heal themselves so regen not worth it. Redemption probably not worth it at 10 res cost to evolve
|
||||||
|
return ALIEN_EVOLUTION_ONE; // Lerks are fragile so best get carapace while the bot is still not great at staying alive with them...
|
||||||
|
case AVH_USER3_ALIEN_PLAYER4:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER5:
|
||||||
|
{
|
||||||
|
if (randbool())
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_ONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!PlayerHasWeapon(pBot->Player, WEAPON_FADE_METABOLIZE) && randbool())
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_TWO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return MESSAGE_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DesiredTech == HIVE_TECH_MOVEMENT)
|
if (DesiredTech == HIVE_TECH_MOVEMENT)
|
||||||
{
|
{
|
||||||
return ALIEN_EVOLUTION_SEVEN;
|
switch (pBot->Player->GetUser3())
|
||||||
|
{
|
||||||
|
case AVH_USER3_ALIEN_PLAYER1:
|
||||||
|
{
|
||||||
|
if (randbool())
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_SEVEN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_NINE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case AVH_USER3_ALIEN_PLAYER2:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER3:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER4:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER5:
|
||||||
|
return ALIEN_EVOLUTION_EIGHT;
|
||||||
|
default:
|
||||||
|
return MESSAGE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DesiredTech == HIVE_TECH_SENSORY)
|
if (DesiredTech == HIVE_TECH_SENSORY)
|
||||||
{
|
{
|
||||||
return ALIEN_EVOLUTION_ELEVEN;
|
switch (pBot->Player->GetUser3())
|
||||||
|
{
|
||||||
|
case AVH_USER3_ALIEN_PLAYER2:
|
||||||
|
return ALIEN_EVOLUTION_TEN;
|
||||||
|
case AVH_USER3_ALIEN_PLAYER1:
|
||||||
|
{
|
||||||
|
if (randbool())
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_TEN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ALIEN_EVOLUTION_ELEVEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case AVH_USER3_ALIEN_PLAYER3:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER4:
|
||||||
|
case AVH_USER3_ALIEN_PLAYER5:
|
||||||
|
return ALIEN_EVOLUTION_ELEVEN;
|
||||||
|
default:
|
||||||
|
return MESSAGE_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MESSAGE_NULL;
|
return MESSAGE_NULL;
|
||||||
|
|
|
@ -631,7 +631,7 @@ void AIMGR_UpdateAIPlayers()
|
||||||
|
|
||||||
int NumBotsThinkThisFrame = 0;
|
int NumBotsThinkThisFrame = 0;
|
||||||
|
|
||||||
int BotsPerFrame = ceil(BOT_THINK_RATE_HZ * NumRegularBots * FrameDelta);
|
int BotsPerFrame = max(1.0f, round(BOT_THINK_RATE_HZ * NumRegularBots * FrameDelta));
|
||||||
|
|
||||||
int BotIndex = 0;
|
int BotIndex = 0;
|
||||||
|
|
||||||
|
@ -897,8 +897,6 @@ void AIMGR_ResetRound()
|
||||||
UTIL_PopulateDoors();
|
UTIL_PopulateDoors();
|
||||||
UTIL_PopulateWeldableObstacles();
|
UTIL_PopulateWeldableObstacles();
|
||||||
|
|
||||||
UTIL_UpdateDoors(true);
|
|
||||||
|
|
||||||
bool bTileCacheFullyUpdated = UTIL_UpdateTileCache();
|
bool bTileCacheFullyUpdated = UTIL_UpdateTileCache();
|
||||||
|
|
||||||
while (!bTileCacheFullyUpdated)
|
while (!bTileCacheFullyUpdated)
|
||||||
|
|
|
@ -1415,7 +1415,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (FStrEq(pcmd, "ai_setdebugaiplayer"))
|
else if (FStrEq(pcmd, "bot_setdebugaiplayer"))
|
||||||
{
|
{
|
||||||
CBaseEntity* SpectatedPlayer = theAvHPlayer->GetSpectatingEntity();
|
CBaseEntity* SpectatedPlayer = theAvHPlayer->GetSpectatingEntity();
|
||||||
|
|
||||||
|
@ -1430,7 +1430,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
||||||
|
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
else if (FStrEq(pcmd, "ai_cometome"))
|
else if (FStrEq(pcmd, "bot_cometome"))
|
||||||
{
|
{
|
||||||
vector<AvHAIPlayer*> AIPlayers = AIMGR_GetAllAIPlayers();
|
vector<AvHAIPlayer*> AIPlayers = AIMGR_GetAllAIPlayers();
|
||||||
|
|
||||||
|
@ -1444,31 +1444,16 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
||||||
|
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
else if (FStrEq(pcmd, "ai_drawtempobstacles"))
|
else if (FStrEq(pcmd, "bot_drawtempobstacles"))
|
||||||
{
|
{
|
||||||
AIDEBUG_DrawTemporaryObstacles(10.0f);
|
AIDEBUG_DrawTemporaryObstacles(10.0f);
|
||||||
|
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
else if (FStrEq(pcmd, "ai_drawoffmeshconns"))
|
else if (FStrEq(pcmd, "bot_drawoffmeshconns"))
|
||||||
{
|
{
|
||||||
AIDEBUG_DrawOffMeshConnections(10.0f);
|
AIDEBUG_DrawOffMeshConnections(10.0f);
|
||||||
|
|
||||||
theSuccess = true;
|
|
||||||
}
|
|
||||||
else if (FStrEq(pcmd, "ai_saysomething"))
|
|
||||||
{
|
|
||||||
vector<AvHAIPlayer*> AIPlayers = AIMGR_GetAllAIPlayers();
|
|
||||||
|
|
||||||
for (auto it = AIPlayers.begin(); it != AIPlayers.end(); it++)
|
|
||||||
{
|
|
||||||
AvHAIPlayer* thisBot = (*it);
|
|
||||||
{
|
|
||||||
BotSay(thisBot, false, 1.0f, "Regular Chat");
|
|
||||||
BotSay(thisBot, true, 2.0f, "Team Chat");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
else if( FStrEq( pcmd, kcRemoveUpgrade) )
|
else if( FStrEq( pcmd, kcRemoveUpgrade) )
|
||||||
|
|
|
@ -358,7 +358,7 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
|
||||||
RegisterServerVariable(&avh_botdebugmode);
|
RegisterServerVariable(&avh_botdebugmode);
|
||||||
RegisterServerVariable(&avh_botcommandermode);
|
RegisterServerVariable(&avh_botcommandermode);
|
||||||
|
|
||||||
REGISTER_SERVER_FUNCTION("sv_addaiplayer", []()
|
REGISTER_SERVER_FUNCTION("sv_botadd", []()
|
||||||
{
|
{
|
||||||
if (!AIMGR_IsBotEnabled())
|
if (!AIMGR_IsBotEnabled())
|
||||||
{
|
{
|
||||||
|
@ -381,7 +381,7 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
|
||||||
AIMGR_AddAIPlayerToTeam(DesiredTeam);
|
AIMGR_AddAIPlayerToTeam(DesiredTeam);
|
||||||
});
|
});
|
||||||
|
|
||||||
REGISTER_SERVER_FUNCTION("sv_removeaiplayer", []()
|
REGISTER_SERVER_FUNCTION("sv_botremove", []()
|
||||||
{
|
{
|
||||||
if (!AIMGR_IsBotEnabled())
|
if (!AIMGR_IsBotEnabled())
|
||||||
{
|
{
|
||||||
|
@ -404,7 +404,7 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
|
||||||
AIMGR_RemoveAIPlayerFromTeam(DesiredTeam);
|
AIMGR_RemoveAIPlayerFromTeam(DesiredTeam);
|
||||||
});
|
});
|
||||||
|
|
||||||
REGISTER_SERVER_FUNCTION("sv_reloadnavmesh", []()
|
REGISTER_SERVER_FUNCTION("sv_botreloadnav", []()
|
||||||
{
|
{
|
||||||
if (avh_botsenabled.value > 0)
|
if (avh_botsenabled.value > 0)
|
||||||
{
|
{
|
||||||
|
@ -416,7 +416,7 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
REGISTER_SERVER_FUNCTION("sv_regenbotini", []()
|
REGISTER_SERVER_FUNCTION("sv_botregenini", []()
|
||||||
{
|
{
|
||||||
AIMGR_RegenBotIni();
|
AIMGR_RegenBotIni();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue