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 exitCastleLevel LevelNum
--- @field public exitCastleWarpNode integer
--- @field public fixCollisionBugs integer
--- @field public fixCollisionBugs boolean
--- @field public fixVanishFloors boolean
--- @field public floorLowerLimit integer
--- @field public floorLowerLimitMisc integer
--- @field public floorLowerLimitShadow integer

View file

@ -924,7 +924,8 @@
| exitCastleArea | `integer` | |
| exitCastleLevel | [enum LevelNum](constants.md#enum-LevelNum) | |
| exitCastleWarpNode | `integer` | |
| fixCollisionBugs | `integer` | |
| fixCollisionBugs | `boolean` | |
| fixVanishFloors | `boolean` | |
| floorLowerLimit | `integer` | |
| floorLowerLimitMisc | `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
&& (gMarioStates[i].flags & MARIO_VANISH_CAP)) {
passThroughWall = TRUE;
continue;
break;
}
}
if (passThroughWall) { continue; }
@ -414,9 +414,30 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
continue;
}
}
// Ignore camera only surfaces.
else if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) {
continue;
else {
// Ignore camera only surfaces.
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;
}
}
// If we are not checking for the camera, ignore camera only floors.
else if (surf->type == SURFACE_CAMERA_BOUNDARY || surf->type == SURFACE_RAYCAST) {
continue;
}
else {
// If we are not checking for the camera, ignore camera only floors.
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) {
f32 y1, y2, y3;

View file

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

View file

@ -37,7 +37,8 @@ struct StarPositions {
};
struct LevelValues {
u8 fixCollisionBugs;
bool fixCollisionBugs;
bool fixVanishFloors;
enum LevelNum entryLevel;
enum LevelNum exitCastleLevel;
s16 exitCastleArea;
@ -228,4 +229,4 @@ extern struct BehaviorValues gBehaviorValues;
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 },
};
#define LUA_LEVEL_VALUES_FIELD_COUNT 20
#define LUA_LEVEL_VALUES_FIELD_COUNT 21
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), 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 },
{ "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), 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 },
{ "floorLowerLimitMisc", LVT_S16, offsetof(struct LevelValues, floorLowerLimitMisc), false, LOT_NONE },
{ "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE },