From 349a3eb702d54ffca0854f73cbbed7d2bcbb4a27 Mon Sep 17 00:00:00 2001 From: headshot2017 Date: Thu, 26 Jan 2023 22:25:21 -0400 Subject: [PATCH] allow setting poison gas level also commented out some find_water_level calls --- src/decomp/game/mario.c | 10 ++++++---- src/decomp/game/mario_step.c | 6 ++++-- src/decomp/include/types.h | 1 + src/libsm64.c | 14 ++++++++++++++ src/libsm64.h | 1 + 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/decomp/game/mario.c b/src/decomp/game/mario.c index 1a594ce..d1b2871 100644 --- a/src/decomp/game/mario.c +++ b/src/decomp/game/mario.c @@ -1321,7 +1321,7 @@ void update_mario_joystick_inputs(struct MarioState *m) { * Resolves wall collisions, and updates a variety of inputs. */ void update_mario_geometry_inputs(struct MarioState *m) { - f32 gasLevel; + //f32 gasLevel; f32 ceilToFloorDist; f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f); @@ -1343,8 +1343,8 @@ void update_mario_geometry_inputs(struct MarioState *m) { } m->ceilHeight = vec3f_find_ceil(&m->pos[0], m->floorHeight, &m->ceil); - gasLevel = find_poison_gas_level(m->pos[0], m->pos[2]); - m->waterLevel = find_water_level(m->pos[0], m->pos[2]); + //gasLevel = find_poison_gas_level(m->pos[0], m->pos[2]); + //m->waterLevel = find_water_level(m->pos[0], m->pos[2]); if (m->floor != NULL) { m->floorAngle = atan2s(m->floor->normal.z, m->floor->normal.x); @@ -1371,7 +1371,7 @@ void update_mario_geometry_inputs(struct MarioState *m) { m->input |= INPUT_IN_WATER; } - if (m->pos[1] < (gasLevel - 100.0f)) { + if (m->pos[1] < (m->gasLevel - 100.0f)) { m->input |= INPUT_IN_POISON_GAS; } @@ -1831,6 +1831,8 @@ int init_mario(void) { gMarioState->waterLevel = find_water_level(gMarioSpawnInfo->startPos[0], gMarioSpawnInfo->startPos[2]); + gMarioState->gasLevel = + find_poison_gas_level(gMarioSpawnInfo->startPos[0], gMarioSpawnInfo->startPos[2]); gMarioState->area = gCurrentArea; gMarioState->marioObj = gMarioObject; diff --git a/src/decomp/game/mario_step.c b/src/decomp/game/mario_step.c index 37e92f9..1bbbd41 100644 --- a/src/decomp/game/mario_step.c +++ b/src/decomp/game/mario_step.c @@ -269,7 +269,8 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) { floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor); ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil); - waterLevel = find_water_level(nextPos[0], nextPos[2]); + //waterLevel = find_water_level(nextPos[0], nextPos[2]); + waterLevel = m->waterLevel; m->wall = upperWall; @@ -403,7 +404,8 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor); ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil); - waterLevel = find_water_level(nextPos[0], nextPos[2]); + //waterLevel = find_water_level(nextPos[0], nextPos[2]); + waterLevel = m->waterLevel; m->wall = NULL; diff --git a/src/decomp/include/types.h b/src/decomp/include/types.h index 5272aa7..118b5c6 100644 --- a/src/decomp/include/types.h +++ b/src/decomp/include/types.h @@ -325,6 +325,7 @@ struct MarioState /*0xC4*/ f32 unkC4; u16 curTerrain; // libsm64: added field + s32 gasLevel; // libsm64: added field }; #endif // TYPES_H diff --git a/src/libsm64.c b/src/libsm64.c index 9fe3fb3..1def575 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -440,6 +440,20 @@ SM64_LIB_FN void sm64_set_mario_water_level(int32_t marioId, signed int level) gMarioState->waterLevel = level; } +SM64_LIB_FN void sm64_set_mario_gas_level(int32_t marioId, signed int level) +{ + if( marioId >= s_mario_instance_pool.size || s_mario_instance_pool.objects[marioId] == NULL ) + { + DEBUG_PRINT("Tried to use non-existant Mario with ID: %d", marioId); + return; + } + + struct GlobalState *globalState = ((struct MarioInstance *)s_mario_instance_pool.objects[ marioId ])->globalState; + global_state_bind( globalState ); + + gMarioState->gasLevel = level; +} + SM64_LIB_FN void sm64_mario_take_damage(int32_t marioId, uint32_t damage, uint32_t subtype, float x, float y, float z) { if( marioId >= s_mario_instance_pool.size || s_mario_instance_pool.objects[marioId] == NULL ) diff --git a/src/libsm64.h b/src/libsm64.h index 73d2842..c2f81ba 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -161,6 +161,7 @@ extern SM64_LIB_FN void sm64_set_mario_faceangle(int32_t marioId, float y); extern SM64_LIB_FN void sm64_set_mario_velocity(int32_t marioId, float x, float y, float z); extern SM64_LIB_FN void sm64_set_mario_forward_velocity(int32_t marioId, float vel); extern SM64_LIB_FN void sm64_set_mario_water_level(int32_t marioId, signed int level); +extern SM64_LIB_FN void sm64_set_mario_gas_level(int32_t marioId, signed int level); extern SM64_LIB_FN void sm64_mario_take_damage(int32_t marioId, uint32_t damage, uint32_t subtype, float x, float y, float z); extern SM64_LIB_FN void sm64_mario_heal(int32_t marioId, uint8_t healCounter); extern SM64_LIB_FN void sm64_mario_kill(int32_t marioId);