mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Merge branch 'unstable' of github.com:sm64ex-coop-dev/sm64ex-coop into unstable
This commit is contained in:
commit
887d033804
18 changed files with 518 additions and 7 deletions
|
@ -43,7 +43,7 @@ in_files = [
|
|||
|
||||
override_allowed_functions = {
|
||||
"src/audio/external.h": [ " play_", "fade" ],
|
||||
"src/game/camera.h": [ "set_.*camera_.*shake" ],
|
||||
"src/game/camera.h": [ "set_.*camera_.*shake", "set_camera_mode" ],
|
||||
"src/game/thread6.c": [ "queue_rumble_"],
|
||||
"src/pc/djui/djui_popup.h" : [ "create" ],
|
||||
"src/game/save_file.h": [ "save_file_get_" ],
|
||||
|
|
|
@ -1769,6 +1769,8 @@
|
|||
- CONT_TYPE_NORMAL
|
||||
- CONT_TYPE_VOICE
|
||||
- CONT_UP
|
||||
- CONT_X
|
||||
- CONT_Y
|
||||
- D_CBUTTONS
|
||||
- D_JPAD
|
||||
- L_CBUTTONS
|
||||
|
@ -1780,6 +1782,8 @@
|
|||
- START_BUTTON
|
||||
- U_CBUTTONS
|
||||
- U_JPAD
|
||||
- X_BUTTON
|
||||
- Y_BUTTON
|
||||
- Z_TRIG
|
||||
|
||||
<br />
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<br />
|
||||
|
||||
- camera.h
|
||||
- [set_camera_mode](#set_camera_mode)
|
||||
- [set_camera_mode_fixed](#set_camera_mode_fixed)
|
||||
- [set_camera_pitch_shake](#set_camera_pitch_shake)
|
||||
- [set_camera_roll_shake](#set_camera_roll_shake)
|
||||
- [set_camera_shake_from_hit](#set_camera_shake_from_hit)
|
||||
|
@ -454,6 +456,14 @@
|
|||
<br />
|
||||
|
||||
- smlua_obj_utils.h
|
||||
- [obj_get_first](#obj_get_first)
|
||||
- [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
|
||||
- [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
|
||||
- [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
|
||||
- [obj_get_next](#obj_get_next)
|
||||
- [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
|
||||
- [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
|
||||
- [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
|
||||
- [spawn_sync_object](#spawn_sync_object)
|
||||
|
||||
<br />
|
||||
|
@ -547,6 +557,51 @@
|
|||
<br />
|
||||
|
||||
|
||||
## [set_camera_mode](#set_camera_mode)
|
||||
|
||||
### Lua Example
|
||||
`set_camera_mode(c, mode, frames)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| c | [Camera](structs.md#Camera) |
|
||||
| mode | integer |
|
||||
| frames | integer |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_camera_mode(struct Camera *c, s16 mode, s16 frames);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_camera_mode_fixed](#set_camera_mode_fixed)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = set_camera_mode_fixed(c, x, y, z)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| c | [Camera](structs.md#Camera) |
|
||||
| x | integer |
|
||||
| y | integer |
|
||||
| z | integer |
|
||||
|
||||
### Returns
|
||||
- integer
|
||||
|
||||
### C Prototype
|
||||
`s32 set_camera_mode_fixed(struct Camera* c, s16 x, s16 y, s16 z);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_camera_pitch_shake](#set_camera_pitch_shake)
|
||||
|
||||
### Lua Example
|
||||
|
@ -8030,6 +8085,174 @@
|
|||
<br />
|
||||
|
||||
|
||||
## [obj_get_first](#obj_get_first)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_first(objList)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| objList | integer |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_first(enum ObjectList objList);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_first_with_behavior_id(behaviorId)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| behaviorId | integer |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| behaviorId | integer |
|
||||
| fieldIndex | integer |
|
||||
| value | number |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| behaviorId | integer |
|
||||
| fieldIndex | integer |
|
||||
| value | integer |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_next](#obj_get_next)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_next(o)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_next(struct Object *o);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_next_with_same_behavior_id(o)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_next_with_same_behavior_id(struct Object *o);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
| fieldIndex | integer |
|
||||
| value | number |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectValue = obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
| fieldIndex | integer |
|
||||
| value | integer |
|
||||
|
||||
### Returns
|
||||
[Object](structs.md#Object)
|
||||
|
||||
### C Prototype
|
||||
`struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [spawn_sync_object](#spawn_sync_object)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -123,6 +123,8 @@ typedef struct {
|
|||
|
||||
#define CONT_A 0x8000
|
||||
#define CONT_B 0x4000
|
||||
#define CONT_X 0x0040
|
||||
#define CONT_Y 0x0080
|
||||
#define CONT_G 0x2000
|
||||
#define CONT_START 0x1000
|
||||
#define CONT_UP 0x0800
|
||||
|
@ -140,6 +142,8 @@ typedef struct {
|
|||
|
||||
#define A_BUTTON CONT_A
|
||||
#define B_BUTTON CONT_B
|
||||
#define X_BUTTON CONT_X
|
||||
#define Y_BUTTON CONT_Y
|
||||
#define L_TRIG CONT_L
|
||||
#define R_TRIG CONT_R
|
||||
#define Z_TRIG CONT_G
|
||||
|
|
|
@ -428,7 +428,7 @@
|
|||
|
||||
#define VALID_BUTTONS (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | \
|
||||
U_JPAD | D_JPAD | L_JPAD | R_JPAD | \
|
||||
L_TRIG | R_TRIG | \
|
||||
L_TRIG | R_TRIG | X_BUTTON | Y_BUTTON | \
|
||||
U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
|
||||
|
||||
#define C_BUTTONS (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
|
||||
|
|
|
@ -1467,7 +1467,6 @@ copyPlayerGoto:;
|
|||
* Handles Mario's input flags as well as a couple timers.
|
||||
*/
|
||||
void update_mario_inputs(struct MarioState *m) {
|
||||
m->particleFlags = 0;
|
||||
if (m->playerIndex == 0) { m->input = 0; }
|
||||
|
||||
u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED || m->freeze > 0);
|
||||
|
|
|
@ -2464,6 +2464,7 @@ s32 cur_obj_is_mario_on_platform(void) {
|
|||
s32 cur_obj_is_any_player_on_platform(void) {
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
if (!is_player_active(&gMarioStates[i])) { continue; }
|
||||
if (gMarioStates[i].marioObj == NULL) { continue; }
|
||||
if (gMarioStates[i].marioObj->platform == o) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -282,14 +282,16 @@ void bhv_mario_update(void) {
|
|||
vec3f_copy(gMarioState->marioBodyState->torsoPos, gMarioState->pos);
|
||||
}
|
||||
|
||||
gMarioState->particleFlags = 0;
|
||||
smlua_call_event_hooks_mario_param(HOOK_BEFORE_MARIO_UPDATE, gMarioState);
|
||||
|
||||
u32 particleFlags = 0;
|
||||
s32 i;
|
||||
|
||||
particleFlags = execute_mario_action(gCurrentObject);
|
||||
gCurrentObject->oMarioParticleFlags = particleFlags;
|
||||
smlua_call_event_hooks_mario_param(HOOK_MARIO_UPDATE, gMarioState);
|
||||
particleFlags |= gMarioState->particleFlags;
|
||||
gCurrentObject->oMarioParticleFlags = particleFlags;
|
||||
|
||||
// Mario code updates MarioState's versions of position etc, so we need
|
||||
// to sync it with the Mario object
|
||||
|
|
|
@ -62,7 +62,9 @@ unsigned int configEnvVolume = MAX_VOLUME;
|
|||
|
||||
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
|
||||
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
|
||||
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };
|
||||
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1001, 0x1101 };
|
||||
unsigned int configKeyX[MAX_BINDS] = { 0x0025, 0x1002, VK_INVALID };
|
||||
unsigned int configKeyY[MAX_BINDS] = { 0x0032, 0x1003, VK_INVALID };
|
||||
unsigned int configKeyStart[MAX_BINDS] = { 0x0039, 0x1006, VK_INVALID };
|
||||
unsigned int configKeyL[MAX_BINDS] = { 0x002A, 0x1009, 0x1104 };
|
||||
unsigned int configKeyR[MAX_BINDS] = { 0x0036, 0x100A, 0x101B };
|
||||
|
@ -137,6 +139,8 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "env_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configEnvVolume},
|
||||
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
|
||||
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
|
||||
{.name = "key_x", .type = CONFIG_TYPE_BIND, .uintValue = configKeyX},
|
||||
{.name = "key_y", .type = CONFIG_TYPE_BIND, .uintValue = configKeyY},
|
||||
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
|
||||
{.name = "key_l", .type = CONFIG_TYPE_BIND, .uintValue = configKeyL},
|
||||
{.name = "key_r", .type = CONFIG_TYPE_BIND, .uintValue = configKeyR},
|
||||
|
|
|
@ -30,6 +30,8 @@ extern unsigned int configSfxVolume;
|
|||
extern unsigned int configEnvVolume;
|
||||
extern unsigned int configKeyA[];
|
||||
extern unsigned int configKeyB[];
|
||||
extern unsigned int configKeyX[];
|
||||
extern unsigned int configKeyY[];
|
||||
extern unsigned int configKeyStart[];
|
||||
extern unsigned int configKeyL[];
|
||||
extern unsigned int configKeyR[];
|
||||
|
|
|
@ -92,6 +92,8 @@ static void keyboard_bindkeys(void) {
|
|||
keyboard_add_binds(STICK_RIGHT, configKeyStickRight);
|
||||
keyboard_add_binds(A_BUTTON, configKeyA);
|
||||
keyboard_add_binds(B_BUTTON, configKeyB);
|
||||
keyboard_add_binds(X_BUTTON, configKeyX);
|
||||
keyboard_add_binds(Y_BUTTON, configKeyY);
|
||||
keyboard_add_binds(Z_TRIG, configKeyZ);
|
||||
keyboard_add_binds(U_CBUTTONS, configKeyCUp);
|
||||
keyboard_add_binds(L_CBUTTONS, configKeyCLeft);
|
||||
|
|
|
@ -88,6 +88,8 @@ static void controller_sdl_bind(void) {
|
|||
|
||||
controller_add_binds(A_BUTTON, configKeyA);
|
||||
controller_add_binds(B_BUTTON, configKeyB);
|
||||
controller_add_binds(X_BUTTON, configKeyX);
|
||||
controller_add_binds(Y_BUTTON, configKeyY);
|
||||
controller_add_binds(Z_TRIG, configKeyZ);
|
||||
controller_add_binds(STICK_UP, configKeyStickUp);
|
||||
controller_add_binds(STICK_LEFT, configKeyStickLeft);
|
||||
|
|
|
@ -75,6 +75,8 @@ static void controller_sdl_bind(void) {
|
|||
|
||||
controller_add_binds(A_BUTTON, configKeyA);
|
||||
controller_add_binds(B_BUTTON, configKeyB);
|
||||
controller_add_binds(X_BUTTON, configKeyX);
|
||||
controller_add_binds(Y_BUTTON, configKeyY);
|
||||
controller_add_binds(Z_TRIG, configKeyZ);
|
||||
controller_add_binds(STICK_UP, configKeyStickUp);
|
||||
controller_add_binds(STICK_LEFT, configKeyStickLeft);
|
||||
|
|
|
@ -21,6 +21,8 @@ void djui_panel_controls_n64_create(struct DjuiBase* caller) {
|
|||
djui_bind_create(&bindBody->base, "Right", configKeyStickRight);
|
||||
djui_bind_create(&bindBody->base, "A", configKeyA);
|
||||
djui_bind_create(&bindBody->base, "B", configKeyB);
|
||||
djui_bind_create(&bindBody->base, "X", configKeyX);
|
||||
djui_bind_create(&bindBody->base, "Y", configKeyY);
|
||||
djui_bind_create(&bindBody->base, "Start", configKeyStart);
|
||||
djui_bind_create(&bindBody->base, "L", configKeyL);
|
||||
djui_bind_create(&bindBody->base, "R", configKeyR);
|
||||
|
|
|
@ -1766,6 +1766,8 @@ char gSmluaConstants[] = ""
|
|||
"CONT_EEPROM_BUSY = 0x80\n"
|
||||
"CONT_A = 0x8000\n"
|
||||
"CONT_B = 0x4000\n"
|
||||
"CONT_X = 0x0040\n"
|
||||
"CONT_Y = 0x0080\n"
|
||||
"CONT_G = 0x2000\n"
|
||||
"CONT_START = 0x1000\n"
|
||||
"CONT_UP = 0x0800\n"
|
||||
|
@ -1780,6 +1782,8 @@ char gSmluaConstants[] = ""
|
|||
"CONT_F = 0x0001\n"
|
||||
"A_BUTTON = CONT_A\n"
|
||||
"B_BUTTON = CONT_B\n"
|
||||
"X_BUTTON = CONT_X\n"
|
||||
"Y_BUTTON = CONT_Y\n"
|
||||
"L_TRIG = CONT_L\n"
|
||||
"R_TRIG = CONT_R\n"
|
||||
"Z_TRIG = CONT_G\n"
|
||||
|
@ -2143,7 +2147,7 @@ char gSmluaConstants[] = ""
|
|||
"ACT_HOLDING_BOWSER = 0x00000391\n"
|
||||
"ACT_RELEASING_BOWSER = 0x00000392\n"
|
||||
"END_DEMO = (1 << 7)\n"
|
||||
"VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
|
||||
"VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | X_BUTTON | Y_BUTTON | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
|
||||
"C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
|
||||
"HOOK_UPDATE = 0\n"
|
||||
"HOOK_MARIO_UPDATE = 1\n"
|
||||
|
|
|
@ -52,6 +52,38 @@ int smlua_func_get_id_from_behavior(lua_State* L) {
|
|||
// camera.h //
|
||||
//////////////
|
||||
|
||||
int smlua_func_set_camera_mode(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 mode = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 frames = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
set_camera_mode(c, mode, frames);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_camera_mode_fixed(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 x = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 y = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 z = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
lua_pushinteger(L, set_camera_mode_fixed(c, x, y, z));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_camera_pitch_shake(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
|
@ -5286,6 +5318,110 @@ int smlua_func_save_file_get_total_star_count(lua_State* L) {
|
|||
// smlua_obj_utils.h //
|
||||
///////////////////////
|
||||
|
||||
int smlua_func_obj_get_first(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
int objList = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_first(objList));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_first_with_behavior_id(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
int behaviorId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id(behaviorId));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_first_with_behavior_id_and_field_f32(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
int behaviorId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 fieldIndex = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 value = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_first_with_behavior_id_and_field_s32(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
int behaviorId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 fieldIndex = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 value = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_next(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_next(o));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_next_with_same_behavior_id(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id(o));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_next_with_same_behavior_id_and_field_f32(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 fieldIndex = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
f32 value = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_get_next_with_same_behavior_id_and_field_s32(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 fieldIndex = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 value = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_spawn_sync_object(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
|
||||
|
||||
|
@ -5706,6 +5842,8 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "get_id_from_behavior", smlua_func_get_id_from_behavior);
|
||||
|
||||
// camera.h
|
||||
smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode);
|
||||
smlua_bind_function(L, "set_camera_mode_fixed", smlua_func_set_camera_mode_fixed);
|
||||
smlua_bind_function(L, "set_camera_pitch_shake", smlua_func_set_camera_pitch_shake);
|
||||
smlua_bind_function(L, "set_camera_roll_shake", smlua_func_set_camera_roll_shake);
|
||||
smlua_bind_function(L, "set_camera_shake_from_hit", smlua_func_set_camera_shake_from_hit);
|
||||
|
@ -6121,6 +6259,14 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "save_file_get_total_star_count", smlua_func_save_file_get_total_star_count);
|
||||
|
||||
// smlua_obj_utils.h
|
||||
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
||||
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
|
||||
smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_f32", smlua_func_obj_get_first_with_behavior_id_and_field_f32);
|
||||
smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_s32", smlua_func_obj_get_first_with_behavior_id_and_field_s32);
|
||||
smlua_bind_function(L, "obj_get_next", smlua_func_obj_get_next);
|
||||
smlua_bind_function(L, "obj_get_next_with_same_behavior_id", smlua_func_obj_get_next_with_same_behavior_id);
|
||||
smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_f32", smlua_func_obj_get_next_with_same_behavior_id_and_field_f32);
|
||||
smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_s32", smlua_func_obj_get_next_with_same_behavior_id_and_field_s32);
|
||||
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
|
||||
|
||||
// sound_init.h
|
||||
|
|
|
@ -76,4 +76,103 @@ struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedI
|
|||
// this is too dangerous for now
|
||||
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z) {
|
||||
spawn_object_internal(behaviorId, modelId, x, y, z, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Helpers to iterate through the object table
|
||||
//
|
||||
|
||||
struct Object *obj_get_first(enum ObjectList objList) {
|
||||
if (gObjectLists && objList >= 0 && objList < NUM_OBJ_LISTS) {
|
||||
struct Object *head = (struct Object *) &gObjectLists[objList];
|
||||
struct Object *obj = (struct Object *) head->header.next;
|
||||
if (obj != head) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId) {
|
||||
const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
|
||||
if (behavior) {
|
||||
enum ObjectList objList = get_object_list_from_behavior(behavior);
|
||||
for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value) {
|
||||
const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
|
||||
if (behavior) {
|
||||
enum ObjectList objList = get_object_list_from_behavior(behavior);
|
||||
for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_S32(fieldIndex) == value) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value) {
|
||||
const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
|
||||
if (behavior) {
|
||||
enum ObjectList objList = get_object_list_from_behavior(behavior);
|
||||
for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_F32(fieldIndex) == value) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_next(struct Object *o) {
|
||||
if (gObjectLists && o) {
|
||||
enum ObjectList objList = get_object_list_from_behavior(o->behavior);
|
||||
struct Object *head = (struct Object *) &gObjectLists[objList];
|
||||
struct Object *next = (struct Object *) o->header.next;
|
||||
if (next != head) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_next_with_same_behavior_id(struct Object *o) {
|
||||
if (o) {
|
||||
for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value) {
|
||||
if (o) {
|
||||
for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_S32(fieldIndex) == value) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value) {
|
||||
if (o) {
|
||||
for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
|
||||
if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_F32(fieldIndex) == value) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,25 @@
|
|||
|
||||
#include "behavior_table.h"
|
||||
#include "smlua_model_utils.h"
|
||||
#include "game/object_list_processor.h"
|
||||
|
||||
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
|
||||
|
||||
// this is too dangerous for now
|
||||
//struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z);
|
||||
|
||||
//
|
||||
// Helpers to iterate through the object table
|
||||
//
|
||||
|
||||
struct Object *obj_get_first(enum ObjectList objList);
|
||||
struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);
|
||||
struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);
|
||||
struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);
|
||||
|
||||
struct Object *obj_get_next(struct Object *o);
|
||||
struct Object *obj_get_next_with_same_behavior_id(struct Object *o);
|
||||
struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);
|
||||
struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue