mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-12-20 15:02:28 +00:00
Add mario_is_crouching(m)
This commit is contained in:
parent
7cf5bce67b
commit
c32cf2054a
7 changed files with 56 additions and 3 deletions
|
|
@ -4404,6 +4404,12 @@ function mario_get_terrain_sound_addend(m)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param m MarioState
|
||||||
|
--- @return boolean
|
||||||
|
function mario_is_crouching(m)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param m MarioState
|
--- @param m MarioState
|
||||||
--- @return nil
|
--- @return nil
|
||||||
function mario_set_bubbled(m)
|
function mario_set_bubbled(m)
|
||||||
|
|
|
||||||
|
|
@ -4547,6 +4547,26 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [mario_is_crouching](#mario_is_crouching)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local booleanValue = mario_is_crouching(m)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| m | [MarioState](structs.md#MarioState) |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- `boolean`
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`bool mario_is_crouching(struct MarioState *m);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [mario_set_bubbled](#mario_set_bubbled)
|
## [mario_set_bubbled](#mario_set_bubbled)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
|
|
||||||
|
|
@ -888,6 +888,7 @@
|
||||||
- [mario_floor_is_steep](functions-3.md#mario_floor_is_steep)
|
- [mario_floor_is_steep](functions-3.md#mario_floor_is_steep)
|
||||||
- [mario_get_floor_class](functions-3.md#mario_get_floor_class)
|
- [mario_get_floor_class](functions-3.md#mario_get_floor_class)
|
||||||
- [mario_get_terrain_sound_addend](functions-3.md#mario_get_terrain_sound_addend)
|
- [mario_get_terrain_sound_addend](functions-3.md#mario_get_terrain_sound_addend)
|
||||||
|
- [mario_is_crouching](functions-3.md#mario_is_crouching)
|
||||||
- [mario_set_bubbled](functions-3.md#mario_set_bubbled)
|
- [mario_set_bubbled](functions-3.md#mario_set_bubbled)
|
||||||
- [mario_set_forward_vel](functions-3.md#mario_set_forward_vel)
|
- [mario_set_forward_vel](functions-3.md#mario_set_forward_vel)
|
||||||
- [mario_update_wall](functions-3.md#mario_update_wall)
|
- [mario_update_wall](functions-3.md#mario_update_wall)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "level_update.h"
|
#include "level_update.h"
|
||||||
#include "object_list_processor.h"
|
#include "object_list_processor.h"
|
||||||
#include "object_helpers.h"
|
#include "object_helpers.h"
|
||||||
|
#include "mario.h"
|
||||||
|
|
||||||
#include "engine/math_util.h"
|
#include "engine/math_util.h"
|
||||||
|
|
||||||
|
|
@ -104,9 +105,7 @@ void first_person_camera_update(void) {
|
||||||
m->area->camera->yaw = gFirstPersonCamera.yaw;
|
m->area->camera->yaw = gFirstPersonCamera.yaw;
|
||||||
|
|
||||||
// update crouch
|
// update crouch
|
||||||
if (m->action == ACT_START_CROUCHING || m->action == ACT_CROUCHING || m->action == ACT_STOP_CROUCHING ||
|
if (mario_is_crouching(m) || m->action == ACT_LEDGE_GRAB) {
|
||||||
m->action == ACT_START_CRAWLING || m->action == ACT_CRAWLING || m->action == ACT_STOP_CRAWLING ||
|
|
||||||
m->action == ACT_CROUCH_SLIDE || m->action == ACT_LEDGE_GRAB) {
|
|
||||||
f32 inc = 10 * (m->controller->buttonDown & Z_TRIG) != 0 || m->action == ACT_CROUCH_SLIDE || m->action == ACT_LEDGE_GRAB ? 1 : -1;
|
f32 inc = 10 * (m->controller->buttonDown & Z_TRIG) != 0 || m->action == ACT_CROUCH_SLIDE || m->action == ACT_LEDGE_GRAB ? 1 : -1;
|
||||||
gFirstPersonCamera.crouch = CLAMP(gFirstPersonCamera.crouch + inc, 0, MARIO_HEAD_POS - MARIO_HEAD_POS_SHORT);
|
gFirstPersonCamera.crouch = CLAMP(gFirstPersonCamera.crouch + inc, 0, MARIO_HEAD_POS - MARIO_HEAD_POS_SHORT);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -492,6 +492,14 @@ void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) {
|
||||||
* ACTIONS *
|
* ACTIONS *
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
|
bool mario_is_crouching(struct MarioState *m) {
|
||||||
|
if (!m) { return false; }
|
||||||
|
|
||||||
|
return m->action == ACT_START_CROUCHING || m->action == ACT_CROUCHING || m->action == ACT_STOP_CROUCHING ||
|
||||||
|
m->action == ACT_START_CRAWLING || m->action == ACT_CRAWLING || m->action == ACT_STOP_CRAWLING ||
|
||||||
|
m->action == ACT_CROUCH_SLIDE;
|
||||||
|
}
|
||||||
|
|
||||||
bool mario_can_bubble(struct MarioState* m) {
|
bool mario_can_bubble(struct MarioState* m) {
|
||||||
if (!m) { return false; }
|
if (!m) { return false; }
|
||||||
if (!gServerSettings.bubbleDeath) { return false; }
|
if (!gServerSettings.bubbleDeath) { return false; }
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits);
|
||||||
void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits);
|
void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits);
|
||||||
void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits);
|
void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits);
|
||||||
void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits);
|
void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits);
|
||||||
|
bool mario_is_crouching(struct MarioState *m);
|
||||||
bool mario_can_bubble(struct MarioState* m);
|
bool mario_can_bubble(struct MarioState* m);
|
||||||
void mario_set_bubbled(struct MarioState* m);
|
void mario_set_bubbled(struct MarioState* m);
|
||||||
void mario_set_forward_vel(struct MarioState *m, f32 speed);
|
void mario_set_forward_vel(struct MarioState *m, f32 speed);
|
||||||
|
|
|
||||||
|
|
@ -14328,6 +14328,23 @@ int smlua_func_mario_get_terrain_sound_addend(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_mario_is_crouching(lua_State* L) {
|
||||||
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
if (top != 1) {
|
||||||
|
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "mario_is_crouching", 1, top);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "mario_is_crouching"); return 0; }
|
||||||
|
|
||||||
|
lua_pushboolean(L, mario_is_crouching(m));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_mario_set_bubbled(lua_State* L) {
|
int smlua_func_mario_set_bubbled(lua_State* L) {
|
||||||
if (L == NULL) { return 0; }
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
|
@ -32130,6 +32147,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "mario_floor_is_steep", smlua_func_mario_floor_is_steep);
|
smlua_bind_function(L, "mario_floor_is_steep", smlua_func_mario_floor_is_steep);
|
||||||
smlua_bind_function(L, "mario_get_floor_class", smlua_func_mario_get_floor_class);
|
smlua_bind_function(L, "mario_get_floor_class", smlua_func_mario_get_floor_class);
|
||||||
smlua_bind_function(L, "mario_get_terrain_sound_addend", smlua_func_mario_get_terrain_sound_addend);
|
smlua_bind_function(L, "mario_get_terrain_sound_addend", smlua_func_mario_get_terrain_sound_addend);
|
||||||
|
smlua_bind_function(L, "mario_is_crouching", smlua_func_mario_is_crouching);
|
||||||
smlua_bind_function(L, "mario_set_bubbled", smlua_func_mario_set_bubbled);
|
smlua_bind_function(L, "mario_set_bubbled", smlua_func_mario_set_bubbled);
|
||||||
smlua_bind_function(L, "mario_set_forward_vel", smlua_func_mario_set_forward_vel);
|
smlua_bind_function(L, "mario_set_forward_vel", smlua_func_mario_set_forward_vel);
|
||||||
smlua_bind_function(L, "mario_update_wall", smlua_func_mario_update_wall);
|
smlua_bind_function(L, "mario_update_wall", smlua_func_mario_update_wall);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue