diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 58e0d8416..f8ac5d02d 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -181,6 +181,7 @@ --- @field public BowlingBallThiSmallSpeed number --- @field public BowlingBallTtmSpeed number --- @field public GrateStarRequirement integer +--- @field public InfiniteRenderDistance integer --- @field public KingBobombFVel number --- @field public KingBobombHealth integer --- @field public KingBobombYawVel integer @@ -190,6 +191,7 @@ --- @field public KoopaThiAgility number --- @field public MipsStar1Requirement integer --- @field public MipsStar2Requirement integer +--- @field public MultipleCapCollection integer --- @field public RacingPenguinBigHeight number --- @field public RacingPenguinBigRadius number --- @field public RacingPenguinHeight number diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 80986719f..ff78a3e14 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -314,6 +314,7 @@ | BowlingBallThiSmallSpeed | `number` | | | BowlingBallTtmSpeed | `number` | | | GrateStarRequirement | `integer` | | +| InfiniteRenderDistance | `integer` | | | KingBobombFVel | `number` | | | KingBobombHealth | `integer` | | | KingBobombYawVel | `integer` | | @@ -323,6 +324,7 @@ | KoopaThiAgility | `number` | | | MipsStar1Requirement | `integer` | | | MipsStar2Requirement | `integer` | | +| MultipleCapCollection | `integer` | | | RacingPenguinBigHeight | `number` | | | RacingPenguinBigRadius | `number` | | | RacingPenguinHeight | `number` | | diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 67afa4bd6..bc07003b0 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -21,6 +21,7 @@ #include "pc/lua/smlua_utils.h" #include "game/rng_position.h" #include "game/interaction.h" +#include "game/hardcoded.h" // Macros for retrieving arguments from behavior scripts. #define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused @@ -1414,10 +1415,15 @@ cur_obj_update_begin:; // Out of render distance, hide the object. gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - // the following flag would deactivate behavior code - //gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; - gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; - + if (gBehaviorValues.InfiniteRenderDistance) + { + gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; + } + else + { + // the following flag would deactivate behavior code // sorry but I need this + gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; + } } else if (gCurrentObject->oHeldState == HELD_FREE) { // In render distance (and not being held), show the object. gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; @@ -1460,6 +1466,8 @@ u8 cur_obj_is_last_nat_update_per_frame(void) { } f32 draw_distance_scalar(void) { + if (!gBehaviorValues.InfiniteRenderDistance) { return 1.0f; } + switch (configDrawDistance) { case 0: return 0.5f; case 1: return 1.0f; diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index a26c748fb..01a170b45 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -146,6 +146,8 @@ struct BehaviorValues gDefaultBehaviorValues = { .GrateStarRequirement = 120, .ShowStarMilestones = TRUE, .RespawnShellBoxes = TRUE, + .MultipleCapCollection = FALSE, + .InfiniteRenderDistance = TRUE, .starsNeededForDialog = { 1, 3, 8, 30, 50, 70 }, .dialogs = { .BobombBuddyBob1Dialog = DIALOG_004, diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index d9b8ce92f..c9c474335 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -243,6 +243,8 @@ struct BehaviorValues { u16 GrateStarRequirement; u8 ShowStarMilestones; u8 RespawnShellBoxes; + u8 MultipleCapCollection; + u8 InfiniteRenderDistance; struct StarsNeededForDialog starsNeededForDialog; struct BehaviorDialogs dialogs; struct BehaviorTrajectories trajectories; diff --git a/src/game/interaction.c b/src/game/interaction.c index 1df551bdb..4c30fc1f4 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1942,6 +1942,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O for (s32 i = 0; i < MAX_PLAYERS; i++) { if (!is_player_active(&gMarioStates[i])) { continue; } + if (i == 0) { continue; } if (gMarioStates[i].riddenObj == o) { return FALSE; } } @@ -2078,7 +2079,7 @@ u32 interact_cap(struct MarioState *m, UNUSED u32 interactType, struct Object *o u16 capMusic = 0; u16 capTime = 0; - if (capFlag == MARIO_NORMAL_CAP) { + if ((capFlag == MARIO_NORMAL_CAP) && (!(gBehaviorValues.MultipleCapCollection)) ) { // refuse normal cap when already on head if (m->flags & (MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD)) { return FALSE; } } diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 92e606e6d..b7f1683a4 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -1085,6 +1085,7 @@ s32 act_bubbled(struct MarioState* m) { m->marioObj->oIntangibleTimer = 0; m->peakHeight = m->pos[1]; mario_set_forward_vel(m, 0.0f); + m->vel[1] = 0.0f; m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; if (m->playerIndex == 0) { soft_reset_camera(m->area->camera); diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 2151f2443..73a03ce5b 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -216,7 +216,7 @@ static struct LuaObjectField sBehaviorTrajectoriesFields[LUA_BEHAVIOR_TRAJECTORI { "UnagiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, UnagiTrajectory), false, LOT_POINTER }, }; -#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 27 +#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 29 static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COUNT] = { { "BowlingBallBob2Speed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallBob2Speed), false, LOT_NONE }, { "BowlingBallBobSpeed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallBobSpeed), false, LOT_NONE }, @@ -224,6 +224,7 @@ static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COU { "BowlingBallThiSmallSpeed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallThiSmallSpeed), false, LOT_NONE }, { "BowlingBallTtmSpeed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallTtmSpeed), false, LOT_NONE }, { "GrateStarRequirement", LVT_U16, offsetof(struct BehaviorValues, GrateStarRequirement), false, LOT_NONE }, + { "InfiniteRenderDistance", LVT_U8, offsetof(struct BehaviorValues, InfiniteRenderDistance), false, LOT_NONE }, { "KingBobombFVel", LVT_F32, offsetof(struct BehaviorValues, KingBobombFVel), false, LOT_NONE }, { "KingBobombHealth", LVT_S16, offsetof(struct BehaviorValues, KingBobombHealth), false, LOT_NONE }, { "KingBobombYawVel", LVT_S16, offsetof(struct BehaviorValues, KingBobombYawVel), false, LOT_NONE }, @@ -233,6 +234,7 @@ static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COU { "KoopaThiAgility", LVT_F32, offsetof(struct BehaviorValues, KoopaThiAgility), false, LOT_NONE }, { "MipsStar1Requirement", LVT_S16, offsetof(struct BehaviorValues, MipsStar1Requirement), false, LOT_NONE }, { "MipsStar2Requirement", LVT_S16, offsetof(struct BehaviorValues, MipsStar2Requirement), false, LOT_NONE }, + { "MultipleCapCollection", LVT_U8, offsetof(struct BehaviorValues, MultipleCapCollection), false, LOT_NONE }, { "RacingPenguinBigHeight", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinBigHeight), false, LOT_NONE }, { "RacingPenguinBigRadius", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinBigRadius), false, LOT_NONE }, { "RacingPenguinHeight", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinHeight), false, LOT_NONE },