diff --git a/code/game/ai_cmd.c b/code/game/ai_cmd.c index 83183b7e..b40e5548 100644 --- a/code/game/ai_cmd.c +++ b/code/game/ai_cmd.c @@ -521,8 +521,7 @@ void BotSetDominationPoint(bot_state_t *bs, int controlPoint) { } // Search for points our team don't own. for (i=1;icurrentPoint = i; break; diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index 984da7d9..18e572ed 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -435,24 +435,16 @@ void BotSetTeamStatus(bot_state_t *bs) { teamtask = TEAMTASK_OFFENSE; break; case LTG_HOLDPOINTA: - if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusA != TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusA != TEAM_RED)) - teamtask = TEAMTASK_OFFENSE; - else if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusA == TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusA == TEAM_RED)) + if (BotTeamControlsPoint(bs,level.pointStatusA)) teamtask = TEAMTASK_DEFENSE; - else - teamtask = TEAMTASK_PATROL; + else + teamtask = TEAMTASK_OFFENSE; break; case LTG_HOLDPOINTB: - if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusB != TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusB != TEAM_RED)) - teamtask = TEAMTASK_OFFENSE; - else if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusB == TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusB == TEAM_RED)) + if (BotTeamControlsPoint(bs,level.pointStatusB)) teamtask = TEAMTASK_DEFENSE; - else - teamtask = TEAMTASK_PATROL; + else + teamtask = TEAMTASK_OFFENSE; break; case LTG_HOLDDOMPOINT: // If the bot has an invalid CP, reroll. @@ -461,15 +453,10 @@ void BotSetTeamStatus(bot_state_t *bs) { BotGetDominationPoint(bs) < level.domination_points_count)) { BotSetDominationPoint(bs,-1); } - if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusDom[BotGetDominationPoint(bs)] == TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusDom[BotGetDominationPoint(bs)] == TEAM_RED)) + if (BotTeamControlsPoint(bs,level.pointStatusDom[BotGetDominationPoint(bs)])) teamtask = TEAMTASK_DEFENSE; - else if ((BotTeam(bs) == TEAM_BLUE && level.pointStatusDom[BotGetDominationPoint(bs)] != TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusDom[BotGetDominationPoint(bs)] != TEAM_RED)) + else teamtask = TEAMTASK_OFFENSE; - else { - teamtask = TEAMTASK_PATROL; - } break; default: teamtask = TEAMTASK_PATROL; @@ -5683,3 +5670,21 @@ int BotCanAndWantsToUseTheGrapple(bot_state_t *bs) { // Else they'll be happy to use it return qtrue; } + +/* +================== +BotTeamControlsPoint +Returns true if the bot's team controls the Domination/DD point. +================== +*/ +qboolean BotTeamControlsPoint(bot_state_t *bs,int point) { + // It's true if the bot is in the blue team and the point belongs to the blue team. + if(BotTeam(bs) == TEAM_BLUE && point == TEAM_BLUE) { + return qtrue; + } + // It's true if the bot is in the red team and the point belongs to the red team. + if(BotTeam(bs) == TEAM_RED && point == TEAM_RED) { + return qtrue; + } + return qfalse; +} diff --git a/code/game/ai_dmq3.h b/code/game/ai_dmq3.h index 5775d8b0..c8a606b3 100644 --- a/code/game/ai_dmq3.h +++ b/code/game/ai_dmq3.h @@ -97,6 +97,8 @@ int BotWantsToHelp(bot_state_t *bs); int BotCanAndWantsToRocketJump(bot_state_t *bs); // returns true if the bot has the Grappling Hook and wants to use it int BotCanAndWantsToUseTheGrapple(bot_state_t *bs); +// returns true if the bot's team owns a control point (DD/DOM) +qboolean BotTeamControlsPoint(bot_state_t *bs,int point); // 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_team.c b/code/game/ai_team.c index eafd72ab..51c5e622 100644 --- a/code/game/ai_team.c +++ b/code/game/ai_team.c @@ -2509,22 +2509,21 @@ BotDDorders ================== */ void BotDDorders(bot_state_t *bs) { - if ((BotTeam(bs) == TEAM_RED && level.pointStatusA == TEAM_RED && - level.pointStatusB != TEAM_RED) || (BotTeam(bs) == TEAM_BLUE && - level.pointStatusA == TEAM_BLUE && level.pointStatusB != TEAM_BLUE)) { + // If only the control point A is taken... + if (BotTeamControlsPoint(bs,level.pointStatusA) && + !BotTeamControlsPoint(bs,level.pointStatusB)) { BotDDorders_PointATaken(bs); } - else if ((BotTeam(bs) == TEAM_RED && level.pointStatusA != TEAM_RED && - level.pointStatusB == TEAM_RED) || (BotTeam(bs) == TEAM_BLUE && - level.pointStatusA != TEAM_BLUE && level.pointStatusB == TEAM_BLUE)) { + // If only the control point B is taken... + else if (!BotTeamControlsPoint(bs,level.pointStatusA) && + BotTeamControlsPoint(bs,level.pointStatusB)) { BotDDorders_PointBTaken(bs); } - else if ((BotTeam(bs) == TEAM_RED && level.pointStatusA != TEAM_RED && - level.pointStatusB != TEAM_RED) || (BotTeam(bs) != TEAM_BLUE && - level.pointStatusA != TEAM_BLUE && level.pointStatusB != TEAM_BLUE) || - (BotTeam(bs) == TEAM_RED && level.pointStatusA == TEAM_RED && - level.pointStatusB == TEAM_RED) || (BotTeam(bs) == TEAM_BLUE && - level.pointStatusA == TEAM_BLUE && level.pointStatusB == TEAM_BLUE)) { + // If both control points (or none) are taken... + else if ((BotTeamControlsPoint(bs,level.pointStatusA) && + BotTeamControlsPoint(bs,level.pointStatusB)) || + (!BotTeamControlsPoint(bs,level.pointStatusA) && + !BotTeamControlsPoint(bs,level.pointStatusB))) { BotDDorders_BothPointsTaken(bs); } } diff --git a/code/game/ai_vcmd.c b/code/game/ai_vcmd.c index e9868d0f..81ae1c86 100644 --- a/code/game/ai_vcmd.c +++ b/code/game/ai_vcmd.c @@ -298,19 +298,16 @@ void BotVoiceChat_Defend(bot_state_t *bs, int client, int mode) { } else if (gametype == GT_DOUBLE_D) { // If the point A is under control, defend it. - if ((BotTeam(bs) == TEAM_RED && level.pointStatusA == TEAM_RED) || - (BotTeam(bs) == TEAM_BLUE && level.pointStatusA == TEAM_BLUE)) { + if (BotTeamControlsPoint(bs,level.pointStatusA)) { BotVoiceChat_HoldPointA(bs,client,mode); } // If the point B is under control, defend it. - else if ((BotTeam(bs) == TEAM_RED && level.pointStatusB == TEAM_RED) || - (BotTeam(bs) == TEAM_BLUE && level.pointStatusB == TEAM_BLUE)) { + else if (BotTeamControlsPoint(bs,level.pointStatusB)) { BotVoiceChat_HoldPointB(bs,client,mode); } // If both points are under control, pick one and defend it. - else if ((BotTeam(bs) == TEAM_RED && level.pointStatusA == TEAM_RED && - level.pointStatusB == TEAM_RED) || (BotTeam(bs) == TEAM_BLUE && - level.pointStatusA == TEAM_BLUE && level.pointStatusB == TEAM_BLUE)) { + else if (BotTeamControlsPoint(bs,level.pointStatusA) && + BotTeamControlsPoint(bs,level.pointStatusB)) { if (rand() % 10 > 5) BotVoiceChat_HoldPointA(bs,client,mode); else