diff --git a/code/game/ai_cmd.c b/code/game/ai_cmd.c index 4841c51c..a3528239 100644 --- a/code/game/ai_cmd.c +++ b/code/game/ai_cmd.c @@ -675,17 +675,21 @@ void BotMatch_DefendKeyArea(bot_state_t *bs, bot_match_t *match) { if (!G_IsATeamGametype(gametype)) return; // Double Domination had other rules - if (gametype == GT_DOUBLE_D) { + else if (gametype == GT_DOUBLE_D) { // "Defend" will make bots to focus on point B. BotMatch_TakeB(bs,match); return; } // Domination has clear rules - if (gametype == GT_DOMINATION) { + else if (gametype == GT_DOMINATION) { // Reroll to get a different DOM point. BotSetDominationPoint(bs,-1); BotMatch_HoldDOMPoint(bs,match); - } + } + // eCTF in AvD mode only allows defenders to defend. + else if (gametype == GT_CTF_ELIMINATION && g_elimination_ctf_oneway.integer && BotIsOnAttackingTeam(bs)) { + return; + } //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; //get the match variable @@ -1054,19 +1058,18 @@ void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) { char netname[MAX_MESSAGE_SIZE]; int client; - if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) { - if (!ctf_redflag.areanum || !ctf_blueflag.areanum) - return; + if (!G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) { + return; } - else if (gametype == GT_1FCTF) { - if (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum) + if (G_UsesTeamFlags(gametype)) { + if (!BotIsThereABlueFlag() || !BotIsThereARedFlag()) return; } - else if (gametype == GT_POSSESSION) { - if (!ctf_neutralflag.areanum) + if (G_UsesTheWhiteFlag(gametype)) { + if (!BotIsThereANeutralFlag()) return; } - else { + if (gametype == GT_CTF_ELIMINATION && g_elimination_ctf_oneway.integer && !BotIsOnAttackingTeam(bs)) { return; } //if not addressed to this bot @@ -1114,7 +1117,7 @@ void BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) { } else if ((G_UsesTeamFlags(gametype) && G_UsesTheWhiteFlag(gametype)) || gametype == GT_HARVESTER || gametype == GT_OBELISK) { - if (!redobelisk.areanum || !blueobelisk.areanum) + if (!BotIsThereARedObelisk() || !BotIsThereABlueObelisk()) return; } else if (gametype == GT_DOUBLE_D) { @@ -1166,13 +1169,12 @@ void BotMatch_Harvest(bot_state_t *bs, bot_match_t *match) { char netname[MAX_MESSAGE_SIZE]; int client; - if (gametype == GT_HARVESTER) { - if (!neutralobelisk.areanum || !redobelisk.areanum || !blueobelisk.areanum) - return; - } - else { + if (gametype != GT_HARVESTER) { return; } + if (!BotIsThereANeutralObelisk() || !BotIsThereARedObelisk() || !BotIsThereABlueObelisk()) { + return; + } //if not addressed to this bot if (!BotAddressedToBot(bs, match)) return; // @@ -1210,11 +1212,11 @@ void BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) { int client; if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) { - if (!ctf_redflag.areanum || !ctf_blueflag.areanum) + if (!BotIsThereARedFlag() || !BotIsThereABlueFlag()) return; } else if (gametype == GT_1FCTF || gametype == GT_HARVESTER) { - if (!redobelisk.areanum || !blueobelisk.areanum) + if (!BotIsThereARedObelisk() || !BotIsThereABlueObelisk()) return; } else { diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index 5b9455b8..7519c030 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -778,7 +778,7 @@ void BotCTFSeekGoals(bot_state_t *bs) { } //get the flag or defend the base rnd = random(); - if (rnd < l1 && ctf_redflag.areanum && ctf_blueflag.areanum) { + if (rnd < l1 && BotIsThereARedFlag() && BotIsThereABlueFlag()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; bs->ltgtype = LTG_GETFLAG; @@ -787,7 +787,7 @@ void BotCTFSeekGoals(bot_state_t *bs) { //get an alternative route goal towards the enemy base BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs)); BotSetTeamStatus(bs); - } else if (rnd < l2 && ctf_redflag.areanum && ctf_blueflag.areanum) { + } else if (rnd < l2 && BotIsThereARedFlag() && BotIsThereABlueFlag()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; // @@ -1220,7 +1220,7 @@ void Bot1FCTFSeekGoals(bot_state_t *bs) { //set the time the bot will stop getting the flag bs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME; BotSetTeamStatus(bs); - } else if (rnd < l2 && ctf_redflag.areanum && ctf_blueflag.areanum) { + } else if (rnd < l2 && BotIsThereARedFlag() && BotIsThereABlueFlag()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; // @@ -1324,7 +1324,7 @@ void BotObeliskSeekGoals(bot_state_t *bs) { } //get the flag or defend the base rnd = random(); - if (rnd < l1 && redobelisk.areanum && blueobelisk.areanum) { + if (rnd < l1 && BotIsThereARedObelisk() && BotIsThereABlueObelisk()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; // @@ -1337,7 +1337,7 @@ void BotObeliskSeekGoals(bot_state_t *bs) { //get an alternate route goal towards the enemy base BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs)); BotSetTeamStatus(bs); - } else if (rnd < l2 && redobelisk.areanum && blueobelisk.areanum) { + } else if (rnd < l2 && BotIsThereARedObelisk() && BotIsThereABlueObelisk()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; // @@ -1495,11 +1495,11 @@ void BotHarvesterSeekGoals(bot_state_t *bs) { } // rnd = random(); - if (rnd < l1 && redobelisk.areanum && blueobelisk.areanum) { + if (rnd < l1 && BotIsThereARedObelisk() && BotIsThereABlueObelisk()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; BotGoHarvest(bs); - } else if (rnd < l2 && redobelisk.areanum && blueobelisk.areanum) { + } else if (rnd < l2 && BotIsThereARedObelisk() && BotIsThereABlueObelisk()) { bs->decisionmaker = bs->client; bs->ordered = qfalse; // @@ -5699,11 +5699,11 @@ 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; + if (level.domination_points_count >= 1) { + return qtrue; } } - return qtrue; + return qfalse; } /* @@ -5713,10 +5713,10 @@ 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; + if (gametype == GT_DOUBLE_D && untrap_BotGetLevelItemGoal(-1, "Red Flag", &ctf_redflag) >= 1) { + return qtrue; } - return qtrue; + return qfalse; } /* @@ -5726,9 +5726,90 @@ 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; + if (gametype == GT_DOUBLE_D && untrap_BotGetLevelItemGoal(-1, "Red Flag", &ctf_blueflag) >= 1) { + return qtrue; } - return qtrue; + return qfalse; +} + +/* +================== +BotIsThereABlueFlag +Returns true if the match has a blue CTF flag present for flag-based matches. +================== +*/ +qboolean BotIsThereABlueFlag(void) { + if (G_UsesTeamFlags(gametype) && ctf_blueflag.areanum) { + return qtrue; + } + return qfalse; +} + +/* +================== +BotIsThereARedFlag +Returns true if the match has a red CTF flag present for flag-based matches. +================== +*/ +qboolean BotIsThereARedFlag(void) { + if (G_UsesTeamFlags(gametype) && ctf_redflag.areanum) { + return qtrue; + } + return qfalse; +} + +/* +================== +BotIsThereANeutralFlag +Returns true if the match has a white CTF flag present for flag-based matches. +================== +*/ +qboolean BotIsThereANeutralFlag(void) { + if (G_UsesTheWhiteFlag(gametype) && ctf_neutralflag.areanum) { + return qtrue; + } + return qfalse; +} + +/* +================== +BotIsThereARedObelisk +Returns true if the match has a red obelisk present for 1FCTF/Harvester/Overload matches. +================== +*/ +qboolean BotIsThereARedObelisk(void) { + if ((gametype == GT_1FCTF || gametype == GT_HARVESTER || + gametype == GT_OBELISK) && redobelisk.areanum) { + return qtrue; + } + return qfalse; +} + +/* +================== +BotIsThereABlueObelisk +Returns true if the match has a blue obelisk present for 1FCTF/Harvester/Overload matches. +================== +*/ +qboolean BotIsThereABlueObelisk(void) { + if ((gametype == GT_1FCTF || gametype == GT_HARVESTER || + gametype == GT_OBELISK) && blueobelisk.areanum) { + return qtrue; + } + return qfalse; +} + +/* +================== +BotIsThereANeutralObelisk +Returns true if the match has a neutral obelisk present for 1FCTF/Harvester/Possession matches. +================== +*/ +qboolean BotIsThereANeutralObelisk(void) { + if ((gametype == GT_1FCTF || gametype == GT_HARVESTER || + gametype == GT_OBELISK) && neutralobelisk.areanum) { + return qtrue; + } + return qfalse; } diff --git a/code/game/ai_dmq3.h b/code/game/ai_dmq3.h index f51ade64..c9f34cda 100644 --- a/code/game/ai_dmq3.h +++ b/code/game/ai_dmq3.h @@ -105,6 +105,18 @@ qboolean BotAreThereDOMPoints(void); qboolean BotIsThereDDPointA(void); // returns true if there is a B control point in the map (DD) qboolean BotIsThereDDPointB(void); +// returns true if there is a blue CTF flag in the map (CTF/eCTF/1FCTF) +qboolean BotIsThereABlueFlag(void); +// returns true if there is a red CTF flag in the map (CTF/eCTF/1FCTF) +qboolean BotIsThereARedFlag(void); +// returns true if there is a neutral CTF flag in the map (1FCTF/Possession) +qboolean BotIsThereANeutralFlag(void); +// returns true if there is a blue obelisk in the map (1FCTF/Harvester/Overload) +qboolean BotIsThereABlueObelisk(void); +// returns true if there is a red obelisk in the map (1FCTF/Harvester/Overload) +qboolean BotIsThereARedObelisk(void); +// returns true if there is a neutral obelisk in the map (1FCTF/Harvester) +qboolean BotIsThereANeutralObelisk(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 e1ab5ea9..30074b2c 100644 --- a/code/game/ai_vcmd.c +++ b/code/game/ai_vcmd.c @@ -166,15 +166,18 @@ BotVoiceChat_GetFlag */ void BotVoiceChat_GetFlag(bot_state_t *bs, int client, int mode) { // - if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) { - if (!ctf_redflag.areanum || !ctf_blueflag.areanum) + if (!G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) { + return; + } + if (G_UsesTeamFlags(gametype)) { + if (!BotIsThereABlueFlag() || !BotIsThereARedFlag()) return; } - else if (gametype == GT_1FCTF) { - if (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum) + if (G_UsesTheWhiteFlag(gametype)) { + if (!BotIsThereANeutralFlag()) return; } - else { + if (gametype == GT_CTF_ELIMINATION && g_elimination_ctf_oneway.integer && !BotIsOnAttackingTeam(bs)) { return; } // @@ -324,6 +327,10 @@ void BotVoiceChat_Defend(bot_state_t *bs, int client, int mode) { BotVoiceChat_HoldDOMPoint(bs,client,mode); return; } + // eCTF in AvD mode only allows defenders to defend. + else if (gametype == GT_CTF_ELIMINATION && g_elimination_ctf_oneway.integer && BotIsOnAttackingTeam(bs)) { + return; + } // bs->decisionmaker = client; bs->ordered = qtrue;