diff --git a/code/game/ai_cmd.c b/code/game/ai_cmd.c index fe46af24..4841c51c 100644 --- a/code/game/ai_cmd.c +++ b/code/game/ai_cmd.c @@ -507,7 +507,7 @@ void BotSetDominationPoint(bot_state_t *bs, int controlPoint) { // Domination only if (gametype != GT_DOMINATION) return; // If there are no points, just assign the neutral one. - if (level.domination_points_count > 1) { + if (!BotAreThereDOMPoints()) { bs->currentPoint = 0; return; } @@ -736,6 +736,8 @@ void BotMatch_TakeA(bot_state_t *bs, bot_match_t *match) { int client; if (gametype != GT_DOUBLE_D) return; + // If the A point isn't present, don't do anything. + if (!BotIsThereDDPointA()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the match variable @@ -786,6 +788,8 @@ void BotMatch_TakeB(bot_state_t *bs, bot_match_t *match) { int client; if (gametype != GT_DOUBLE_D) return; + // If the B point isn't present, don't do anything. + if (!BotIsThereDDPointB()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the match variable @@ -835,7 +839,7 @@ void BotMatch_HoldDOMPoint(bot_state_t *bs, bot_match_t *match) { int client; if (gametype != GT_DOMINATION) return; - if (level.domination_points_count < 1) return; + if (!BotAreThereDOMPoints()) return; //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the match variable diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index c3107c54..5b9455b8 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -844,7 +844,7 @@ void BotDomSeekGoals(bot_state_t *bs) { // DD only if (gametype != GT_DOMINATION) return; // if the map has no points, just roam - if (level.domination_points_count < 1) { + if (!BotAreThereDOMPoints()) { bs->ltgtype = LTG_PATROL; BotSetUserInfo(bs, "teamtask", va("%d", TEAMTASK_PATROL)); BotSetTeamStatus(bs); @@ -5578,13 +5578,12 @@ void BotSetupDeathmatchAI(void) { if (untrap_BotGetLevelItemGoal(-1, "Blue Flag", &ctf_blueflag) < 0) BotAI_Print(PRT_WARNING, "CTF without Blue Flag\n"); } else if (gametype == GT_DOUBLE_D) { - if (untrap_BotGetLevelItemGoal(-1, "Red Flag", &ctf_redflag) < 0) + if (!BotIsThereDDPointA()) BotAI_Print(PRT_WARNING, "DD without Point A\n"); - if (untrap_BotGetLevelItemGoal(-1, "Blue Flag", &ctf_blueflag) < 0) + if (!BotIsThereDDPointB()) BotAI_Print(PRT_WARNING, "DD without Point B\n"); } else if (gametype == GT_DOMINATION) { - ent = untrap_BotGetLevelItemGoal(-1, "Domination point", &dom_points_bot[0]); - if (ent < 0) + if (!BotAreThereDOMPoints()) BotAI_Print(PRT_WARNING, "Domination without a single domination point\n"); else BotSetEntityNumForGoal(&dom_points_bot[0], va("domination_point%i", 0)); @@ -5691,3 +5690,45 @@ qboolean BotTeamOwnsControlPoint(bot_state_t *bs,int point) { } return qfalse; } + +/* +================== +BotAreThereDOMPoints +Returns true if the match has at least one control point present for Domination. +================== +*/ +qboolean BotAreThereDOMPoints(void) { + if (gametype == GT_DOMINATION) { + if (level.domination_points_count < 1) { + return qfalse; + } + } + return qtrue; +} + +/* +================== +BotIsThereDDPointA +Returns true if the match has the A point present for Double Domination. +================== +*/ +qboolean BotIsThereDDPointA(void) { + if (gametype == GT_DOUBLE_D && untrap_BotGetLevelItemGoal(-1, "Red Flag", &ctf_redflag) < 0) { + return qfalse; + } + return qtrue; +} + +/* +================== +BotIsThereDDPointB +Returns true if the match has the B point present for Double Domination. +================== +*/ +qboolean BotIsThereDDPointB(void) { + if (gametype == GT_DOUBLE_D && untrap_BotGetLevelItemGoal(-1, "Blue Flag", &ctf_blueflag) < 0) { + return qfalse; + } + return qtrue; +} + diff --git a/code/game/ai_dmq3.h b/code/game/ai_dmq3.h index effeae73..f51ade64 100644 --- a/code/game/ai_dmq3.h +++ b/code/game/ai_dmq3.h @@ -99,6 +99,12 @@ int BotCanAndWantsToRocketJump(bot_state_t *bs); int BotCanAndWantsToUseTheGrapple(bot_state_t *bs); // returns true if the bot's team owns a control point (DD/DOM) qboolean BotTeamOwnsControlPoint(bot_state_t *bs,int point); +// returns true if there is at least one control point in the map (DOM) +qboolean BotAreThereDOMPoints(void); +// returns true if there is an A control point in the map (DD) +qboolean BotIsThereDDPointA(void); +// returns true if there is a B control point in the map (DD) +qboolean BotIsThereDDPointB(void); // returns true if the bot has a persistant powerup and a weapon int BotHasPersistantPowerupAndWeapon(bot_state_t *bs); //returns true if the bot wants to and goes camping diff --git a/code/game/ai_vcmd.c b/code/game/ai_vcmd.c index ef8a0491..f7330c1e 100644 --- a/code/game/ai_vcmd.c +++ b/code/game/ai_vcmd.c @@ -72,6 +72,8 @@ BotVoiceChat_HoldPointA void BotVoiceChat_HoldPointA(bot_state_t *bs, int client, int mode) { //Only valid for Double Domination if (gametype != GT_DOUBLE_D) return; + // If the A point isn't present, don't do anything. + if (!BotIsThereDDPointA()) return; bs->decisionmaker = client; bs->ordered = qtrue; @@ -102,6 +104,8 @@ BotVoiceChat_HoldPointB void BotVoiceChat_HoldPointB(bot_state_t *bs, int client, int mode) { //Only valid for Double Domination if (gametype != GT_DOUBLE_D) return; + // If the B point isn't present, don't do anything. + if (!BotIsThereDDPointB()) return; bs->decisionmaker = client; bs->ordered = qtrue; @@ -132,7 +136,7 @@ BotVoiceChat_HoldDOMPoint void BotVoiceChat_HoldDOMPoint(bot_state_t *bs, int client, int mode) { //Only valid for Double Domination if (gametype != GT_DOMINATION) return; - if (level.domination_points_count < 1) return; + if (!BotAreThereDOMPoints()) return; bs->decisionmaker = client; bs->ordered = qtrue;