Implement CPU Spiny Shell (#325)

* Implement CPU Blue Shell
This commit is contained in:
MegaMech
2025-06-22 17:29:55 -06:00
committed by GitHub
parent 19d5a2729e
commit 59cf0355a2
4 changed files with 50 additions and 6 deletions
+43 -3
View File
@@ -7022,9 +7022,9 @@ void cpu_decisions_branch_item(UNUSED s32 playerId, s16* branch, s32 itemId) {
case ITEM_BANANA_BUNCH:
value = CPU_STRATEGY_ITEM_BANANA_BUNCH;
break;
// case ITEM_BLUE_SPINY_SHELL:
// value = CPU_STRATEGY_ITEM_BLUE_SPINY_SHELL;
// break;
case ITEM_BLUE_SPINY_SHELL:
value = CPU_STRATEGY_ITEM_BLUE_SPINY_SHELL;
break;
case ITEM_GREEN_SHELL:
value = CPU_STRATEGY_ITEM_GREEN_SHELL;
break;
@@ -7553,6 +7553,46 @@ void cpu_use_item_strategy(s32 playerId) {
}
}
break;
case CPU_STRATEGY_ITEM_BLUE_SPINY_SHELL:
if (((s32) gNumActors) < 0x50) {
temp_s0->actorIndex = use_blue_shell_item(player);
if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) {
temp_s0->branch = CPU_STRATEGY_HOLD_BLUE_SPINY_SHELL;
temp_s0->timer = 0;
temp_s0->numItemUse += 1;
temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0xA;
} else {
temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM;
}
} else {
temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM;
}
break;
case CPU_STRATEGY_HOLD_BLUE_SPINY_SHELL:
shell = (struct ShellActor*) GET_ACTOR(temp_s0->actorIndex);
if ((((!(shell->flags & 0x8000)) || (shell->type != ACTOR_BLUE_SPINY_SHELL)) ||
(shell->state != HELD_SHELL)) ||
(playerId != shell->playerId)) {
temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM;
temp_s0->timer = 0;
} else if (temp_s0->timeBeforeThrow < temp_s0->timer) {
temp_s0->branch = CPU_STRATEGY_THROW_BLUE_SPINY_SHELL;
}
break;
case CPU_STRATEGY_THROW_BLUE_SPINY_SHELL:
clear_expired_strategies(temp_s0);
shell = (struct ShellActor*) GET_ACTOR(temp_s0->actorIndex);
if ((((!(shell->flags & 0x8000)) || (shell->type != ACTOR_BLUE_SPINY_SHELL)) ||
(shell->state != HELD_SHELL)) ||
(playerId != shell->playerId)) {
temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM;
temp_s0->timer = 0;
} else {
shell->state = RELEASED_SHELL;
temp_s0->timer = 0;
temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM;
}
break;
default:
break;
+5 -1
View File
@@ -89,7 +89,11 @@ enum CpuItemStrategyEnum {
CPU_STRATEGY_THROW_BANANA,
CPU_STRATEGY_HOLD_THROW_BANANA,
CPU_STRATEGY_END_THROW_BANANA
CPU_STRATEGY_END_THROW_BANANA,
CPU_STRATEGY_ITEM_BLUE_SPINY_SHELL,
CPU_STRATEGY_THROW_BLUE_SPINY_SHELL,
CPU_STRATEGY_HOLD_BLUE_SPINY_SHELL,
};
/* Function Prototypes */
+1 -1
View File
@@ -680,7 +680,7 @@ s32 use_red_shell_item(Player* player) {
// Interestingly blue shells start their life as a red shell,
// and then just change the type from red to blue shell
void use_blue_shell_item(Player* player) {
s32 use_blue_shell_item(Player* player) {
GET_ACTOR(use_red_shell_item(player))->type = ACTOR_BLUE_SPINY_SHELL;
}
+1 -1
View File
@@ -23,7 +23,7 @@ s32 use_triple_shell_item(Player*, s16);
s32 init_triple_shell(TripleShellParent*, Player*, s16, u16);
s32 use_green_shell_item(Player*);
s32 use_red_shell_item(Player*);
void use_blue_shell_item(Player*);
s32 use_blue_shell_item(Player*);
void update_actor_banana(struct BananaActor*);
void func_802B2914(struct BananaBunchParent*, Player*, s16);
s32 use_fake_itembox_item(Player*);