From 4fe93a7fd62067b8bc3fdb5bb9ff13721ec17d71 Mon Sep 17 00:00:00 2001 From: RichardGreenlees Date: Tue, 20 Feb 2024 08:29:08 +0000 Subject: [PATCH] Start combat mode stuff --- main/source/mod/AIPlayers/AvHAIConstants.h | 1 + main/source/mod/AIPlayers/AvHAIPlayer.cpp | 165 ++++++++++++++++++++- main/source/mod/AIPlayers/AvHAIPlayer.h | 4 + 3 files changed, 165 insertions(+), 5 deletions(-) diff --git a/main/source/mod/AIPlayers/AvHAIConstants.h b/main/source/mod/AIPlayers/AvHAIConstants.h index 09646253..c98bc4d9 100644 --- a/main/source/mod/AIPlayers/AvHAIConstants.h +++ b/main/source/mod/AIPlayers/AvHAIConstants.h @@ -758,6 +758,7 @@ typedef struct AVH_AI_PLAYER AvHAIBotRole BotRole = BOT_ROLE_NONE; + int ExperiencePointsAvailable = 0; // How much experience the bot has to spend } AvHAIPlayer; diff --git a/main/source/mod/AIPlayers/AvHAIPlayer.cpp b/main/source/mod/AIPlayers/AvHAIPlayer.cpp index b9090db8..278de535 100644 --- a/main/source/mod/AIPlayers/AvHAIPlayer.cpp +++ b/main/source/mod/AIPlayers/AvHAIPlayer.cpp @@ -1815,6 +1815,32 @@ void SetNewAIPlayerRole(AvHAIPlayer* pBot, AvHAIBotRole NewRole) void UpdateAIPlayerCORole(AvHAIPlayer* pBot) { + + if (AIMGR_GetNumAIPlayersWithRoleOnTeam(pBot->Player->GetTeam(), BOT_ROLE_SWEEPER, pBot) == 0) + { + SetNewAIPlayerRole(pBot, BOT_ROLE_SWEEPER); + return; + } + + if (IsPlayerAlien(pBot->Edict)) + { + if (IsPlayerLerk(pBot->Edict)) + { + SetNewAIPlayerRole(pBot, BOT_ROLE_SWEEPER); + return; + } + + int NumLerks = AITAC_GetNumPlayersOnTeamOfClass(pBot->Player->GetTeam(), AVH_USER3_ALIEN_PLAYER3, pBot->Edict); + int NumHarassers = AIMGR_GetNumAIPlayersWithRoleOnTeam(pBot->Player->GetTeam(), BOT_ROLE_HARASS, pBot); + + if (NumLerks + NumHarassers == 0) + { + SetNewAIPlayerRole(pBot, BOT_ROLE_SWEEPER); + return; + } + } + + SetNewAIPlayerRole(pBot, BOT_ROLE_ASSAULT); } void UpdateAIPlayerDMRole(AvHAIPlayer* pBot) @@ -3881,13 +3907,147 @@ AvHMessageID AlienGetDesiredUpgrade(AvHAIPlayer* pBot, HiveTechStatus DesiredTec return MESSAGE_NULL; } +AvHMessageID GetNextAIPlayerCOUpgrade(AvHAIPlayer* pBot) +{ + if (IsPlayerMarine(pBot->Player)) + { + return GetNextAIPlayerCOMarineUpgrade(pBot); + } + else + { + return GetNextAIPlayerCOAlienUpgrade(pBot); + } + +} + +AvHMessageID GetNextAIPlayerCOMarineUpgrade(AvHAIPlayer* pBot) +{ + // Make sure sweeper always has a welder to repair CC / armouries / unlock new armouries + if (pBot->BotRole == BOT_ROLE_SWEEPER) + { + if (!pBot->Player->GetHasCombatModeUpgrade(BUILD_WELDER)) + { + return BUILD_WELDER; + } + } + + if (!pBot->Player->GetHasCombatModeUpgrade(RESEARCH_GRENADES)) + { + return RESEARCH_GRENADES; + } + + if (!pBot->Player->GetHasCombatModeUpgrade(RESEARCH_ARMOR_ONE)) + { + return RESEARCH_ARMOR_ONE; + } + + if (!pBot->Player->GetHasCombatModeUpgrade(RESEARCH_WEAPONS_ONE)) + { + return RESEARCH_WEAPONS_ONE; + } + +} + +AvHMessageID GetNextAIPlayerCOAlienUpgrade(AvHAIPlayer* pBot) +{ + // Always start off getting carapace, to improve viability early game + if (!pBot->Player->GetHasCombatModeUpgrade(ALIEN_EVOLUTION_ONE)) + { + return ALIEN_EVOLUTION_ONE; + } + + // Unlock leap for further viability early game + if (!pBot->Player->GetHasCombatModeUpgrade(ALIEN_HIVE_TWO_UNLOCK)) + { + return ALIEN_HIVE_TWO_UNLOCK; + } + + // If we are a sweeper, always ensure we have enough resources to go gorge in case we want to heal the hive + if (pBot->BotRole == BOT_ROLE_SWEEPER) + { + if (!IsPlayerGorge(pBot->Edict)) + { + if (pBot->ExperiencePointsAvailable <= GetGameRules()->GetCostForMessageID(ALIEN_LIFEFORM_TWO)) + { + return MESSAGE_NULL; + } + } + } + + // If we are a harasser, always ensure we have enough resources to go lerk + if (pBot->BotRole == BOT_ROLE_HARASS) + { + if (!IsPlayerLerk(pBot->Edict)) + { + if (pBot->ExperiencePointsAvailable <= GetGameRules()->GetCostForMessageID(ALIEN_LIFEFORM_THREE)) + { + return MESSAGE_NULL; + } + } + } + + + +} + void AIPlayerCOThink(AvHAIPlayer* pBot) { + pBot->ExperiencePointsAvailable = (pBot->Player->GetExperienceLevel() - pBot->Player->GetExperienceLevelsSpent() - 1); + pBot->CurrentEnemy = BotGetNextEnemyTarget(pBot); + + if (pBot->CurrentEnemy > -1) + { + if (IsPlayerMarine(pBot->Player)) + { + MarineCombatThink(pBot); + } + else + { + AlienCombatThink(pBot); + } + + return; + } + + UpdateAIPlayerCORole(pBot); + + AvHMessageID NextCombatUpgrade = GetNextAIPlayerCOUpgrade(pBot); } void AIPlayerDMThink(AvHAIPlayer* pBot) { + pBot->CurrentEnemy = BotGetNextEnemyTarget(pBot); + + if (pBot->CurrentEnemy > -1) + { + if (IsPlayerMarine(pBot->Player)) + { + MarineCombatThink(pBot); + } + else + { + AlienCombatThink(pBot); + } + + return; + } + + pBot->CurrentTask = &pBot->PrimaryBotTask; + + AITASK_BotUpdateAndClearTasks(pBot); + + if (pBot->CurrentTask->TaskType == TASK_NONE) + { + Vector RandomMovePoint = UTIL_GetRandomPointOnNavmeshInRadius(pBot->BotNavInfo.NavProfile, pBot->CurrentFloorPosition, UTIL_MetresToGoldSrcUnits(50.0f)); + + if (!vIsZero(RandomMovePoint)) + { + AITASK_SetMoveTask(pBot, pBot->CurrentTask, RandomMovePoint, false); + } + } + + BotProgressTask(pBot, pBot->CurrentTask); } @@ -3905,11 +4065,6 @@ void AIPlayerThink(AvHAIPlayer* pBot) } } - if (pBot->PrimaryBotTask.TaskType == TASK_BUILD) - { - UTIL_DrawLine(INDEXENT(1), pBot->Edict->v.origin, pBot->PrimaryBotTask.TaskLocation, 0, 255, 255); - } - switch (GetGameRules()->GetMapMode()) { case MAP_MODE_NS: diff --git a/main/source/mod/AIPlayers/AvHAIPlayer.h b/main/source/mod/AIPlayers/AvHAIPlayer.h index b8bdb9ee..bc6873dd 100644 --- a/main/source/mod/AIPlayers/AvHAIPlayer.h +++ b/main/source/mod/AIPlayers/AvHAIPlayer.h @@ -70,6 +70,10 @@ void TestNavThink(AvHAIPlayer* pBot); void DroneThink(AvHAIPlayer* pBot); void CustomThink(AvHAIPlayer* pBot); +AvHMessageID GetNextAIPlayerCOUpgrade(AvHAIPlayer* pBot); +AvHMessageID GetNextAIPlayerCOMarineUpgrade(AvHAIPlayer* pBot); +AvHMessageID GetNextAIPlayerCOAlienUpgrade(AvHAIPlayer* pBot); + bool AIPlayerMustFinishCurrentTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task); AvHAIPlayerTask* AIPlayerGetNextTask(AvHAIPlayer* pBot); void AIPlayerSetPrimaryMarineTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task);