From d55daf4319fda5bc07176ef2d2323069cc9d0870 Mon Sep 17 00:00:00 2001 From: Renato Rotenerg Date: Mon, 20 Feb 2023 21:53:30 -0300 Subject: [PATCH] Add some more mario functions sm64_set_mario_invincibility sm64_set_mario_health sm64_mario_extend_cap --- src/libsm64.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/libsm64.h | 3 +++ 2 files changed, 47 insertions(+) diff --git a/src/libsm64.c b/src/libsm64.c index 3b8d523..3e84664 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -429,6 +429,20 @@ SM64_LIB_FN void sm64_set_mario_forward_velocity(int32_t marioId, float vel) gMarioState->forwardVel = vel; } +SM64_LIB_FN void sm64_set_mario_invincibility(int32_t marioId, int16_t timer) +{ + 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->invincTimer = timer; +} + SM64_LIB_FN void sm64_set_mario_water_level(int32_t marioId, signed int level) { if( marioId >= s_mario_instance_pool.size || s_mario_instance_pool.objects[marioId] == NULL ) @@ -457,6 +471,22 @@ SM64_LIB_FN void sm64_set_mario_gas_level(int32_t marioId, signed int level) gMarioState->gasLevel = level; } +SM64_LIB_FN void sm64_set_mario_health(int32_t marioId, uint16_t health) +{ + 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->health = health; + gMarioState->hurtCounter = 0; + gMarioState->healCounter = 0; +} + 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 ) @@ -552,6 +582,20 @@ SM64_LIB_FN void sm64_mario_interact_cap(int32_t marioId, uint32_t capFlag, uint } } +SM64_LIB_FN void sm64_mario_extend_cap(int32_t marioId, uint16_t capTime) +{ + 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->capTimer += capTime; +} + SM64_LIB_FN bool sm64_mario_attack(int32_t marioId, float x, float y, float z, float hitboxHeight) { 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 889a4bf..31f231f 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -160,12 +160,15 @@ extern SM64_LIB_FN void sm64_set_mario_angle(int32_t marioId, float x, float y, 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_invincibility(int32_t marioId, int16_t timer); 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_set_mario_health(int32_t marioId, uint16_t health); 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); extern SM64_LIB_FN void sm64_mario_interact_cap(int32_t marioId, uint32_t capFlag, uint16_t capTime, uint8_t playMusic); +extern SM64_LIB_FN void sm64_mario_extend_cap(int32_t marioId, uint16_t capTime); extern SM64_LIB_FN bool sm64_mario_attack(int32_t marioId, float x, float y, float z, float hitboxHeight); extern SM64_LIB_FN uint32_t sm64_surface_object_create( const struct SM64SurfaceObject *surfaceObject );