From 4310b698a76aa31e52c63ac6ffecf7e3e1dc8c78 Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Sat, 25 Sep 2021 11:45:19 -0700 Subject: [PATCH] Blue coin switch allows retries for remaining coins --- include/config.h | 5 ++ include/object_constants.h | 109 +++++++++++++++++++-------- src/game/behaviors/blue_coin.inc.c | 59 ++++++++++++--- src/game/behaviors/bobomb.inc.c | 8 +- src/game/behaviors/bully.inc.c | 12 +-- src/game/behaviors/moving_coin.inc.c | 4 +- 6 files changed, 143 insertions(+), 54 deletions(-) diff --git a/include/config.h b/include/config.h index fd8a9140..670b367c 100644 --- a/include/config.h +++ b/include/config.h @@ -1,4 +1,5 @@ #pragma once + /** * @file config.h * A catch-all file for configuring various bugfixes and other settings in SM64 @@ -100,6 +101,10 @@ #define COLLISION_DATA_TYPE s16 #define ROOM_DATA_TYPE s8 +// -- SPECIFIC OBJECT SETTINGS -- +// Allow for retries on collecting the remaining blue coins from a blue coin switch +#define BLUE_COIN_SWITCH_RETRY + // -- CUTSCENE SKIPS -- // Skip peach letter cutscene #define PEACH_SKIP diff --git a/include/object_constants.h b/include/object_constants.h index 27875101..ef7e7687 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -116,55 +116,100 @@ #define ACTIVE_PARTICLE_V_STAR (1 << 18) // 0x00040000 #define ACTIVE_PARTICLE_TRIANGLE (1 << 19) // 0x00080000 -/* oAction */ -#define OBJ_ACT_LAVA_DEATH 100 -#define OBJ_ACT_DEATH_PLANE_DEATH 101 +/* oBehParams2ndByte */ +#define OBJ_BP_NONE 0x0 -#define OBJ_ACT_HORIZONTAL_KNOCKBACK 100 -#define OBJ_ACT_VERTICAL_KNOCKBACK 101 -#define OBJ_ACT_SQUISHED 102 +/* oAction */ +#define OBJ_ACT_PROJECTILE_HIT_MARIO -0x1 + +/* oAction */ +#define OBJ_ACT_LAVA_DEATH 100 +#define OBJ_ACT_DEATH_PLANE_DEATH 101 + +#define OBJ_ACT_HORIZONTAL_KNOCKBACK 100 +#define OBJ_ACT_VERTICAL_KNOCKBACK 101 +#define OBJ_ACT_SQUISHED 102 + +/* oAnimState */ +#define OBJ_ANIM_STATE_INIT_ANIM -0x1 +#define OBJ_ANIM_STATE_DEFAULT 0x0 + /* cur_obj_update_blinking */ +#define OBJ_BLINKING_ANIM_STATE_EYES_OPEN 0x0 +#define OBJ_BLINKING_ANIM_STATE_EYES_CLOSED 0x1 + +/* Animations */ +#define OBJ_ANIM_NONE -0x1 /* gTTCSpeedSetting */ -#define TTC_SPEED_SLOW 0 -#define TTC_SPEED_FAST 1 -#define TTC_SPEED_RANDOM 2 -#define TTC_SPEED_STOPPED 3 +#define TTC_SPEED_SLOW 0x0 +#define TTC_SPEED_FAST 0x1 +#define TTC_SPEED_RANDOM 0x2 +#define TTC_SPEED_STOPPED 0x3 -/* Bob-omb */ - /* oBehParams2ndByte */ - #define BOBOMB_BP_STYPE_GENERIC 0 - #define BOBOMB_BP_STYPE_STATIONARY 1 - /* oAction */ - #define BOBOMB_ACT_PATROL 0 - #define BOBOMB_ACT_LAUNCHED 1 - #define BOBOMB_ACT_CHASE_MARIO 2 - #define BOBOMB_ACT_EXPLODE 3 - #define BOBOMB_ACT_LAVA_DEATH 100 - #define BOBOMB_ACT_DEATH_PLANE_DEATH 101 +/* geo_update_layer_transparency */ +#define TRANSPARENCY_ANIM_STATE_OPAQUE 0x0 +#define TRANSPARENCY_ANIM_STATE_TRANSPARENT 0x1 + +/* Orange Number */ + /* oBehParams2ndByte, oAnimState */ + #define ORANGE_NUMBER_0 0x0 + #define ORANGE_NUMBER_1 0x1 + #define ORANGE_NUMBER_2 0x2 + #define ORANGE_NUMBER_3 0x3 + #define ORANGE_NUMBER_4 0x4 + #define ORANGE_NUMBER_5 0x5 + #define ORANGE_NUMBER_6 0x6 + #define ORANGE_NUMBER_7 0x7 + #define ORANGE_NUMBER_8 0x8 + #define ORANGE_NUMBER_9 0x9 + #define ORANGE_NUMBER_A 0xA + #define ORANGE_NUMBER_B 0xB + #define ORANGE_NUMBER_C 0xC + #define ORANGE_NUMBER_D 0xD + #define ORANGE_NUMBER_E 0xE + #define ORANGE_NUMBER_F 0xF + +/* Coin Type */ + /* coinType */ + #define COIN_TYPE_NONE 0x0 + #define COIN_TYPE_YELLOW 0x1 + #define COIN_TYPE_BLUE 0x2 /* Hidden Blue Coin */ /* oAction */ - #define HIDDEN_BLUE_COIN_ACT_INACTIVE 0 - #define HIDDEN_BLUE_COIN_ACT_WAITING 1 - #define HIDDEN_BLUE_COIN_ACT_ACTIVE 2 + #define HIDDEN_BLUE_COIN_ACT_INACTIVE 0x0 + #define HIDDEN_BLUE_COIN_ACT_WAITING 0x1 + #define HIDDEN_BLUE_COIN_ACT_ACTIVE 0x2 /* Blue Coin Switch */ /* oAction */ - #define BLUE_COIN_SWITCH_ACT_IDLE 0 - #define BLUE_COIN_SWITCH_ACT_RECEDING 1 - #define BLUE_COIN_SWITCH_ACT_TICKING 2 + #define BLUE_COIN_SWITCH_ACT_IDLE 0x0 + #define BLUE_COIN_SWITCH_ACT_RECEDING 0x1 + #define BLUE_COIN_SWITCH_ACT_TICKING 0x2 + #define BLUE_COIN_SWITCH_ACT_EXTENDING 0x3 /* Moving Blue Coin */ /* oAction */ - #define MOV_BCOIN_ACT_STILL 0 - #define MOV_BCOIN_ACT_MOVING 1 + #define MOV_BCOIN_ACT_STILL 0x0 + #define MOV_BCOIN_ACT_MOVING 0x1 + #define MOV_BCOIN_ACT_SLOWING_DOWN 0x2 + #define MOV_BCOIN_ACT_STOPPED 0x3 + #define MOV_BCOIN_ACT_FLICKERING 0x4 + +/* Bob-omb */ + /* oBehParams2ndByte */ + #define BOBOMB_BP_STYPE_GENERIC 0x0 + #define BOBOMB_BP_STYPE_STATIONARY 0x1 + /* oAction */ + #define BOBOMB_ACT_PATROL 0x0 + #define BOBOMB_ACT_LAUNCHED 0x1 + #define BOBOMB_ACT_CHASE_MARIO 0x2 + #define BOBOMB_ACT_EXPLODE 0x3 /* Moving Yellow Coin */ /* oAction */ #define MOV_YCOIN_ACT_IDLE 0 #define MOV_YCOIN_ACT_BLINKING 1 - #define MOV_YCOIN_ACT_LAVA_DEATH 100 - #define MOV_YCOIN_ACT_DEATH_PLANE_DEATH 101 /* Bob-omb Buddy */ /* oBehParams2ndByte */ @@ -376,8 +421,6 @@ #define BULLY_ACT_BACK_UP 3 #define BULLY_ACT_INACTIVE 4 #define BULLY_ACT_ACTIVATE_AND_FALL 5 - #define BULLY_ACT_LAVA_DEATH 100 - #define BULLY_ACT_DEATH_PLANE_DEATH 101 /* oBullySubtype */ #define BULLY_STYPE_GENERIC 0 #define BULLY_STYPE_MINION 1 diff --git a/src/game/behaviors/blue_coin.inc.c b/src/game/behaviors/blue_coin.inc.c index d10e3600..369be4c7 100644 --- a/src/game/behaviors/blue_coin.inc.c +++ b/src/game/behaviors/blue_coin.inc.c @@ -37,6 +37,9 @@ void bhv_hidden_blue_coin_loop(void) { // Become tangible cur_obj_enable_rendering(); cur_obj_become_tangible(); +#ifdef BLUE_COIN_SWITCH_RETRY + o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; +#endif // Delete the coin once collected if (o->oInteractStatus & INT_STATUS_INTERACTED) { @@ -47,7 +50,11 @@ void bhv_hidden_blue_coin_loop(void) { // After 200 frames of waiting and 20 2-frame blinks (for 240 frames total), // delete the object. if (cur_obj_wait_then_blink(200, 20)) { +#ifdef BLUE_COIN_SWITCH_RETRY + o->oAction = HIDDEN_BLUE_COIN_ACT_INACTIVE; +#else obj_mark_for_deletion(o); +#endif } break; @@ -70,10 +77,14 @@ void bhv_blue_coin_switch_loop(void) { if (gMarioObject->platform == o) { if (gMarioStates[0].action == ACT_GROUND_POUND_LAND) { // Set to BLUE_COIN_SWITCH_ACT_RECEDING - o->oAction++; - + o->oAction = BLUE_COIN_SWITCH_ACT_RECEDING; +#ifdef BLUE_COIN_SWITCH_RETRY + // Recede at a rate of 16 units/frame. + o->oVelY = -16.0f; +#else // Recede at a rate of 20 units/frame. - o->oVelY = -20.0f; + o->oVelY = -20.0f; +#endif // Set gravity to 0 so it doesn't accelerate when receding. o->oGravity = 0.0f; @@ -89,13 +100,21 @@ void bhv_blue_coin_switch_loop(void) { // Recede for 6 frames before going invisible and ticking. // This is probably an off-by-one error, since the switch is 100 units tall // and recedes at 20 units/frame, which means it will fully recede after 5 frames. +#ifdef BLUE_COIN_SWITCH_RETRY + if (o->oTimer > 3) { +#else if (o->oTimer > 5) { cur_obj_hide(); - +#endif // Set to BLUE_COIN_SWITCH_ACT_TICKING - o->oAction++; + o->oAction = BLUE_COIN_SWITCH_ACT_TICKING; +#ifdef BLUE_COIN_SWITCH_RETRY // ??? - o->oPosY = gMarioObject->oPosY - 40.0f; + o->oVelY = 0.0f; + o->oGravity = 0.0f; +#else + o->oPosY = (gMarioObject->oPosY - 40.0f); +#endif // Spawn particles. There's a function that calls this same function // with the same arguments, spawn_mist_particles, why didn't they just call that? @@ -115,13 +134,35 @@ void bhv_blue_coin_switch_loop(void) { } else { play_sound(SOUND_GENERAL2_SWITCH_TICK_SLOW, gGlobalSoundSource); } - +#ifdef BLUE_COIN_SWITCH_RETRY + if (cur_obj_nearest_object_with_behavior(bhvHiddenBlueCoin) == NULL) { + spawn_mist_particles_variable(0, 0, 46.0f); + obj_mark_for_deletion(o); + // Set to BLUE_COIN_SWITCH_ACT_EXTENDING after the coins unload after the 240-frame timer expires. + } else if (o->oTimer > 240) { + o->oAction = BLUE_COIN_SWITCH_ACT_EXTENDING; + o->oVelY = 16.0f; + o->oGravity = 0.0f; + } + load_object_collision_model(); + break; + case BLUE_COIN_SWITCH_ACT_EXTENDING: + if (o->oTimer > 3) { + // Set to BLUE_COIN_SWITCH_ACT_IDLE + o->oAction = BLUE_COIN_SWITCH_ACT_IDLE; + } else { + // Have collision while extending + load_object_collision_model(); + // Extend + cur_obj_move_using_fvel_and_gravity(); + } +#else // Delete the switch (which stops the sound) after the last coin is collected, // or after the coins unload after the 240-frame timer expires. - if (cur_obj_nearest_object_with_behavior(bhvHiddenBlueCoin) == NULL || o->oTimer > 240) { + if ((cur_obj_nearest_object_with_behavior(bhvHiddenBlueCoin) == NULL) || (o->oTimer > 240)) { obj_mark_for_deletion(o); } - +#endif break; } } diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c index 8acd1673..6c60e5d2 100644 --- a/src/game/behaviors/bobomb.inc.c +++ b/src/game/behaviors/bobomb.inc.c @@ -117,12 +117,12 @@ void generic_bobomb_free_loop(void) { bobomb_act_explode(); break; - case BOBOMB_ACT_LAVA_DEATH: + case OBJ_ACT_LAVA_DEATH: if (obj_lava_death() == 1) create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; - case BOBOMB_ACT_DEATH_PLANE_DEATH: + case OBJ_ACT_DEATH_PLANE_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; @@ -144,12 +144,12 @@ void stationary_bobomb_free_loop(void) { bobomb_act_explode(); break; - case BOBOMB_ACT_LAVA_DEATH: + case OBJ_ACT_LAVA_DEATH: if (obj_lava_death() == 1) create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; - case BOBOMB_ACT_DEATH_PLANE_DEATH: + case OBJ_ACT_DEATH_PLANE_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c index d4b40781..8437120f 100644 --- a/src/game/behaviors/bully.inc.c +++ b/src/game/behaviors/bully.inc.c @@ -52,7 +52,7 @@ void bhv_big_bully_init(void) { } void bully_check_mario_collision(void) { - if (o->oAction != BULLY_ACT_LAVA_DEATH && o->oAction != BULLY_ACT_DEATH_PLANE_DEATH && o->oInteractStatus & INT_STATUS_INTERACTED) { + if (o->oAction != OBJ_ACT_LAVA_DEATH && o->oAction != OBJ_ACT_DEATH_PLANE_DEATH && o->oInteractStatus & INT_STATUS_INTERACTED) { if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) cur_obj_play_sound_2(SOUND_OBJ2_BULLY_ATTACKED); else @@ -171,7 +171,7 @@ void bully_step(void) { if (o->oBullySubtype & BULLY_STYPE_CHILL) { if (o->oPosY < 1030.0f) - o->oAction = BULLY_ACT_LAVA_DEATH; + o->oAction = OBJ_ACT_LAVA_DEATH; } } @@ -248,11 +248,11 @@ void bhv_bully_loop(void) { bully_step(); break; - case BULLY_ACT_LAVA_DEATH: + case OBJ_ACT_LAVA_DEATH: bully_act_level_death(); break; - case BULLY_ACT_DEATH_PLANE_DEATH: + case OBJ_ACT_DEATH_PLANE_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } @@ -350,11 +350,11 @@ void bhv_big_bully_with_minions_loop(void) { cur_obj_become_tangible(); break; - case BULLY_ACT_LAVA_DEATH: + case OBJ_ACT_LAVA_DEATH: big_bully_spawn_star(); break; - case BULLY_ACT_DEATH_PLANE_DEATH: + case OBJ_ACT_DEATH_PLANE_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } diff --git a/src/game/behaviors/moving_coin.inc.c b/src/game/behaviors/moving_coin.inc.c index dffe8dcd..1b14cf4b 100644 --- a/src/game/behaviors/moving_coin.inc.c +++ b/src/game/behaviors/moving_coin.inc.c @@ -77,11 +77,11 @@ void bhv_moving_yellow_coin_loop(void) { moving_coin_flicker(); break; - case MOV_YCOIN_ACT_LAVA_DEATH: + case OBJ_ACT_LAVA_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; - case MOV_YCOIN_ACT_DEATH_PLANE_DEATH: + case OBJ_ACT_DEATH_PLANE_DEATH: o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; }