Merge branch 'unstable' of github.com:sm64ex-coop-dev/sm64ex-coop into unstable-dev

This commit is contained in:
MysterD 2022-03-01 12:00:47 -08:00
commit 555d10433b
4 changed files with 442 additions and 1 deletions

View File

@ -14,6 +14,7 @@
- [set_camera_shake_from_point](#set_camera_shake_from_point)
- [set_camera_yaw_shake](#set_camera_yaw_shake)
- [set_environmental_camera_shake](#set_environmental_camera_shake)
- [set_camera_mode](#set_camera_mode)
<br />
@ -455,6 +456,14 @@
- smlua_obj_utils.h
- [spawn_sync_object](#spawn_sync_object)
- [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_s32](#obj_get_first_with_behavior_id_and_field_s32)
- [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
- [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_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
- [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
<br />
@ -676,6 +685,28 @@
<br />
## [set_camera_mode](#set_camera_mode)
### Lua Example
`set_camera_mode(c, mode, frames)`
### Parameters
| Field | Type |
| ----- | ---- |
| c | Camera |
| mode | integer |
| frames | integer |
### Returns
- None
### C Prototype
`void set_camera_mode(struct Camera *c, s16 mode, s16 frames);`
[:arrow_up_small:](#)
<br />
---
# functions from characters.h
@ -8055,6 +8086,174 @@
<br />
## [obj_get_first](#obj_get_first)
### Lua Example
`local obj = 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 obj = 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_s32](#obj_get_first_with_behavior_id_and_field_s32)
### Lua Example
`local obj = 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_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
### Lua Example
`local obj = 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_next](#obj_get_next)
### Lua Example
`local obj = obj_get_next(o)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | 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 obj = obj_get_next_with_same_behavior_id(o)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | 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_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
### Lua Example
`local obj = obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | 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 />
## [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
### Lua Example
`local obj = obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | 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 />
---
# functions from sound_init.h

View File

@ -136,6 +136,21 @@ int smlua_func_set_environmental_camera_shake(lua_State* L) {
return 1;
}
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;
}
//////////////////
// characters.h //
//////////////////
@ -5307,6 +5322,110 @@ int smlua_func_spawn_sync_object(lua_State* L) {
return 1;
}
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_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; }
int fieldIndex = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { return 0; }
int 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_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; }
int fieldIndex = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { return 0; }
float 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_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_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; }
int fieldIndex = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { return 0; }
int 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_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; }
int fieldIndex = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { return 0; }
float 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;
}
//////////////////
// sound_init.h //
//////////////////
@ -5712,6 +5831,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point);
smlua_bind_function(L, "set_camera_yaw_shake", smlua_func_set_camera_yaw_shake);
smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake);
smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode);
// characters.h
smlua_bind_function(L, "get_character", smlua_func_get_character);
@ -6122,6 +6242,14 @@ void smlua_bind_functions_autogen(void) {
// smlua_obj_utils.h
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
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_s32", smlua_func_obj_get_first_with_behavior_id_and_field_s32);
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_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_s32", smlua_func_obj_get_next_with_same_behavior_id_and_field_s32);
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);
// sound_init.h
smlua_bind_function(L, "disable_background_sound", smlua_func_disable_background_sound);

View File

@ -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;
}

View File

@ -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