Re-introduce a few vanilla bugs under gBehaviorValues (#413)

* Properly set Mario's y vel to 0 on popping

* Re-introduce a few vanilla bugs under gBehaviorValues

The Shell Mario glitch was patched as a side effect to patching a different bug, but several romhacks use it so I need it back.
The ability to collect multiple normal caps at once is needed for hat-in-hand using the hat factory glitch.

* Fix Shell Mario fix

Found the actual reason why the glitch doesn't work and figured that this change shouldn't affect anything else, so I removed its entry from gBehaviorValues.

* Add InfiniteRenderDistance to gBehaviorValues

I'm well aware that disabling the infinite render distance will be very desync prone, however a few glitches, most notably cloning and chuckya double jump, need objects load and unload from render distance.
This commit is contained in:
Sunk 2023-06-11 17:24:13 -04:00 committed by GitHub
parent 5fdc7b67e8
commit a0ff975ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 6 deletions

View file

@ -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

View file

@ -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` | |

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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; }
}

View file

@ -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);

View file

@ -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 },