Fixed Vanish floors/ceilings (non-wall surfaces) (#225)

In the vanilla game, vanish does only work with walls specifically, and not floors and ceilings. This is because the check for vanish surfaces was only implemented with the walls. So I simply pasted the same code but with the floors and the ceilings.
This commit is contained in:
wRadion 2022-11-19 03:39:17 +01:00 committed by GitHub
parent a94565a604
commit 34a0b12e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 14 deletions

View File

@ -629,7 +629,8 @@
--- @field public exitCastleArea integer --- @field public exitCastleArea integer
--- @field public exitCastleLevel LevelNum --- @field public exitCastleLevel LevelNum
--- @field public exitCastleWarpNode integer --- @field public exitCastleWarpNode integer
--- @field public fixCollisionBugs integer --- @field public fixCollisionBugs boolean
--- @field public fixVanishFloors boolean
--- @field public floorLowerLimit integer --- @field public floorLowerLimit integer
--- @field public floorLowerLimitMisc integer --- @field public floorLowerLimitMisc integer
--- @field public floorLowerLimitShadow integer --- @field public floorLowerLimitShadow integer

View File

@ -924,7 +924,8 @@
| exitCastleArea | `integer` | | | exitCastleArea | `integer` | |
| exitCastleLevel | [enum LevelNum](constants.md#enum-LevelNum) | | | exitCastleLevel | [enum LevelNum](constants.md#enum-LevelNum) | |
| exitCastleWarpNode | `integer` | | | exitCastleWarpNode | `integer` | |
| fixCollisionBugs | `integer` | | | fixCollisionBugs | `boolean` | |
| fixVanishFloors | `boolean` | |
| floorLowerLimit | `integer` | | | floorLowerLimit | `integer` | |
| floorLowerLimitMisc | `integer` | | | floorLowerLimitMisc | `integer` | |
| floorLowerLimitShadow | `integer` | | | floorLowerLimitShadow | `integer` | |

View File

@ -263,7 +263,7 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
if (gCurrentObject != NULL && gCurrentObject == gMarioStates[i].marioObj if (gCurrentObject != NULL && gCurrentObject == gMarioStates[i].marioObj
&& (gMarioStates[i].flags & MARIO_VANISH_CAP)) { && (gMarioStates[i].flags & MARIO_VANISH_CAP)) {
passThroughWall = TRUE; passThroughWall = TRUE;
continue; break;
} }
} }
if (passThroughWall) { continue; } if (passThroughWall) { continue; }
@ -414,9 +414,30 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
continue; continue;
} }
} }
// Ignore camera only surfaces. else {
else if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) { // Ignore camera only surfaces.
continue; if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) {
continue;
}
// If an object can pass through a vanish cap surface, pass through.
if (gLevelValues.fixVanishFloors && surf->type == SURFACE_VANISH_CAP_WALLS) {
if (gCurrentObject != NULL
&& (gCurrentObject->activeFlags & ACTIVE_FLAG_MOVE_THROUGH_GRATE)) {
continue;
}
// If Mario has a vanish cap, pass through the vanish cap surface.
u8 passThrough = FALSE;
for (s32 i = 0; i < MAX_PLAYERS; i++) {
if (gCurrentObject != NULL && gCurrentObject == gMarioStates[i].marioObj
&& (gMarioStates[i].flags & MARIO_VANISH_CAP)) {
passThrough = TRUE;
break;
}
}
if (passThrough) { continue; }
}
} }
{ {
@ -642,11 +663,31 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
continue; continue;
} }
} }
// If we are not checking for the camera, ignore camera only floors. else {
else if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) { // If we are not checking for the camera, ignore camera only floors.
continue; if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) {
} continue;
}
// If an object can pass through a vanish cap surface, pass through.
if (gLevelValues.fixVanishFloors && surf->type == SURFACE_VANISH_CAP_WALLS) {
if (gCurrentObject != NULL
&& (gCurrentObject->activeFlags & ACTIVE_FLAG_MOVE_THROUGH_GRATE)) {
continue;
}
// If Mario has a vanish cap, pass through the vanish cap surface.
u8 passThrough = FALSE;
for (s32 i = 0; i < MAX_PLAYERS; i++) {
if (gCurrentObject != NULL && gCurrentObject == gMarioStates[i].marioObj
&& (gMarioStates[i].flags & MARIO_VANISH_CAP)) {
passThrough = TRUE;
break;
}
}
if (passThrough) { continue; }
}
}
if (interpolate) { if (interpolate) {
f32 y1, y2, y3; f32 y1, y2, y3;

View File

@ -43,6 +43,7 @@ extern Trajectory sThiTinyMetalBallTraj[];
struct LevelValues gDefaultLevelValues = { struct LevelValues gDefaultLevelValues = {
.fixCollisionBugs = 0, .fixCollisionBugs = 0,
.fixVanishFloors = 0,
.entryLevel = LEVEL_CASTLE_GROUNDS, .entryLevel = LEVEL_CASTLE_GROUNDS,
.exitCastleLevel = LEVEL_CASTLE, .exitCastleLevel = LEVEL_CASTLE,
.exitCastleArea = 1, .exitCastleArea = 1,

View File

@ -37,7 +37,8 @@ struct StarPositions {
}; };
struct LevelValues { struct LevelValues {
u8 fixCollisionBugs; bool fixCollisionBugs;
bool fixVanishFloors;
enum LevelNum entryLevel; enum LevelNum entryLevel;
enum LevelNum exitCastleLevel; enum LevelNum exitCastleLevel;
s16 exitCastleArea; s16 exitCastleArea;
@ -228,4 +229,4 @@ extern struct BehaviorValues gBehaviorValues;
void hardcoded_reset_default_values(void); void hardcoded_reset_default_values(void);
#endif #endif

View File

@ -726,7 +726,7 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] =
{ "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
}; };
#define LUA_LEVEL_VALUES_FIELD_COUNT 20 #define LUA_LEVEL_VALUES_FIELD_COUNT 21
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE },
{ "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE }, { "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE },
@ -734,7 +734,8 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] =
{ "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE }, { "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE },
{ "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE }, { "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE },
{ "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE }, { "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE },
{ "fixCollisionBugs", LVT_U8, offsetof(struct LevelValues, fixCollisionBugs), false, LOT_NONE }, { "fixCollisionBugs", LVT_BOOL, offsetof(struct LevelValues, fixCollisionBugs), false, LOT_NONE },
{ "fixVanishFloors", LVT_BOOL, offsetof(struct LevelValues, fixVanishFloors), false, LOT_NONE },
{ "floorLowerLimit", LVT_S16, offsetof(struct LevelValues, floorLowerLimit), false, LOT_NONE }, { "floorLowerLimit", LVT_S16, offsetof(struct LevelValues, floorLowerLimit), false, LOT_NONE },
{ "floorLowerLimitMisc", LVT_S16, offsetof(struct LevelValues, floorLowerLimitMisc), false, LOT_NONE }, { "floorLowerLimitMisc", LVT_S16, offsetof(struct LevelValues, floorLowerLimitMisc), false, LOT_NONE },
{ "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE }, { "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE },