summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-06-22 17:29:55 -0600
committerGitHub <noreply@github.com>2025-06-22 17:29:55 -0600
commit59cf0355a2ae7716b7ffb2cd08756423ab3d93c6 (patch)
treeb00f43a333a9c0bec9059771275107cebaf02d98
parent19d5a2729ed0d7c86c3a9b1eeb1cf8b824f58199 (diff)
Implement CPU Spiny Shell (#325)
* Implement CPU Blue Shell
-rw-r--r--src/code_80005FD0.c46
-rw-r--r--src/code_80005FD0.h6
-rw-r--r--src/racing/actors_extended.c2
-rw-r--r--src/racing/actors_extended.h2
4 files changed, 50 insertions, 6 deletions
diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c
index dcdb3e416..a66d410fb 100644
--- a/src/code_80005FD0.c
+++ b/src/code_80005FD0.c
@@ -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;
diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h
index b84d5f6fe..e0496a806 100644
--- a/src/code_80005FD0.h
+++ b/src/code_80005FD0.h
@@ -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 */
diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c
index 66fcfe611..fb7a8aeeb 100644
--- a/src/racing/actors_extended.c
+++ b/src/racing/actors_extended.c
@@ -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;
}
diff --git a/src/racing/actors_extended.h b/src/racing/actors_extended.h
index e054ce12a..942ce943a 100644
--- a/src/racing/actors_extended.h
+++ b/src/racing/actors_extended.h
@@ -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*);