Skip to content

Commit

Permalink
port: fix #352
Browse files Browse the repository at this point in the history
patch submitted by Ryan Dwyer

The patch allows all humans/bots to be selected regardless of team. It also adds a check to make sure a bot is not given a command to attack itself.
  • Loading branch information
fgsfdsfgs committed Jan 15, 2024
1 parent 81313f0 commit 8a7b438
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/game/activemenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,8 @@ MenuItemHandlerResult amPickTargetMenuList(s32 operation, struct menuitem *item,
switch (operation) {
case MENUOP_GETOPTIONCOUNT:
if (g_AmMenus[g_AmIndex].prevallbots) {
// All bots: num bot opponents + all human players
s32 count = 0;
s32 i;
struct chrdata *playerchr = g_Vars.currentplayer->prop->chr;

for (i = PLAYERCOUNT(); i < g_MpNumChrs; i++) {
if (g_MpAllChrPtrs[i]->team != playerchr->team) {
count++;
}
}

count += PLAYERCOUNT();
data->list.value = count;
// All bots
data->list.value = g_MpNumChrs;
} else {
// Single bot: All except the bot itself
data->list.value = g_MpNumChrs - 1;
Expand All @@ -125,9 +114,7 @@ MenuItemHandlerResult amPickTargetMenuList(s32 operation, struct menuitem *item,
chrindex++;

if (g_AmMenus[g_AmIndex].prevallbots) {
if (playerchr == g_MpAllChrPtrs[chrindex] || playerchr->team != g_MpAllChrPtrs[chrindex]->team) {
numremaining--;
}
numremaining--;
} else {
if (botchr != g_MpAllChrPtrs[chrindex]) {
numremaining--;
Expand All @@ -139,7 +126,9 @@ MenuItemHandlerResult amPickTargetMenuList(s32 operation, struct menuitem *item,
g_AmMenus[g_AmIndex].prevallbots = false;

for (i = 0; i < g_Vars.currentplayer->numaibuddies; i++) {
botApplyAttack(g_MpAllChrPtrs[g_Vars.currentplayer->aibuddynums[i]], g_MpAllChrPtrs[chrindex]->prop);
if (g_Vars.currentplayer->aibuddynums[i] != chrindex) {
botApplyAttack(g_MpAllChrPtrs[g_Vars.currentplayer->aibuddynums[i]], g_MpAllChrPtrs[chrindex]->prop);
}
}
} else {
botApplyAttack(botchr, g_MpAllChrPtrs[chrindex]->prop);
Expand Down Expand Up @@ -167,9 +156,7 @@ MenuItemHandlerResult amPickTargetMenuList(s32 operation, struct menuitem *item,
chrindex++;

if (g_AmMenus[g_AmIndex].prevallbots) {
if (playerchr == g_MpAllChrPtrs[chrindex] || playerchr->team != g_MpAllChrPtrs[chrindex]->team) {
numremaining--;
}
numremaining--;
} else {
if (botchr != g_MpAllChrPtrs[chrindex]) {
numremaining--;
Expand Down

0 comments on commit 8a7b438

Please sign in to comment.