mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Adjustments for Lua/Mods
This commit is contained in:
parent
b5b9d509e8
commit
6751829f91
13 changed files with 235 additions and 1 deletions
|
@ -31,6 +31,7 @@ in_files = [
|
|||
"levels/level_defines.h",
|
||||
"src/game/obj_behaviors.c",
|
||||
"src/game/save_file.h",
|
||||
"src/game/obj_behaviors_2.h",
|
||||
]
|
||||
|
||||
exclude_constants = {
|
||||
|
|
|
@ -45,6 +45,7 @@ in_files = [
|
|||
"src/game/obj_behaviors_2.c",
|
||||
"src/game/spawn_sound.c",
|
||||
"src/engine/surface_load.h",
|
||||
"src/game/object_list_processor.h",
|
||||
]
|
||||
|
||||
override_allowed_functions = {
|
||||
|
@ -53,6 +54,7 @@ override_allowed_functions = {
|
|||
"src/pc/djui/djui_popup.h" : [ "create" ],
|
||||
"src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags" ],
|
||||
"src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ],
|
||||
"src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
|
||||
}
|
||||
|
||||
override_disallowed_functions = {
|
||||
|
|
|
@ -3865,6 +3865,33 @@ OBJ_COL_FLAG_NO_Y_VEL = (1 << 3)
|
|||
--- @type integer
|
||||
OBJ_COL_FLAG_UNDERWATER = (1 << 2)
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_DIE_IF_HEALTH_NON_POSITIVE = 1
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_KNOCKBACK = 2
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_NOP = 0
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SET_SPEED_TO_ZERO = 5
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SPECIAL_HUGE_GOOMBA_WEAKLY_ATTACKED = 7
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SPECIAL_KOOPA_LOSE_SHELL = 4
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SPECIAL_WIGGLER_JUMPED_ON = 6
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SQUISHED = 3
|
||||
|
||||
--- @type integer
|
||||
ATTACK_HANDLER_SQUISHED_WITH_BLUE_COIN = 8
|
||||
|
||||
--- @type integer
|
||||
ACTIVE_FLAG_ACTIVE = (1 << 0)
|
||||
|
||||
|
|
|
@ -4026,6 +4026,13 @@ function stub_obj_helpers_4()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param obj Object
|
||||
--- @param bits integer
|
||||
--- @return nil
|
||||
function set_object_respawn_info_bits(obj, bits)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param a0 integer
|
||||
--- @param a1 integer
|
||||
--- @return nil
|
||||
|
@ -4153,6 +4160,12 @@ function allocate_mario_action(actFlags)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param pointer Pointer_integer
|
||||
--- @return integer
|
||||
function deref_s32_pointer(pointer)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_environment_region(index)
|
||||
|
@ -4185,6 +4198,12 @@ function get_network_area_timer()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param initialValue integer
|
||||
--- @return Pointer_integer
|
||||
function get_temp_s32_pointer(initialValue)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function hud_hide()
|
||||
-- ...
|
||||
|
|
|
@ -64,6 +64,7 @@ void *DynOS_Lvl_GetFunctionPointerFromIndex(s32 aIndex) {
|
|||
#define LEVEL_SCRIPT_SIZE_PER_TOKEN 4
|
||||
|
||||
#define lvl_constant(x) if (_Arg == #x) { return (LevelScript) (x); }
|
||||
#define lvl_legacy_constant(x, y) if (_Arg == #x) { return (LevelScript) (y); }
|
||||
|
||||
s64 DynOS_Lvl_ParseLevelScriptConstants(const String& _Arg, bool* found) {
|
||||
*found = true;
|
||||
|
@ -606,6 +607,11 @@ s64 DynOS_Lvl_ParseLevelScriptConstants(const String& _Arg, bool* found) {
|
|||
lvl_constant(bhvIntroScene);
|
||||
lvl_constant(bhvUnusedFakeStar);
|
||||
|
||||
// Legacy behavior names
|
||||
lvl_legacy_constant(bhvFish2, bhvManyBlueFishSpawner);
|
||||
lvl_legacy_constant(bhvFish3, bhvFewBlueFishSpawner);
|
||||
lvl_legacy_constant(bhvLargeFishGroup, bhvFishSpawner);
|
||||
|
||||
// Level constants
|
||||
lvl_constant(LEVEL_UNKNOWN_1);
|
||||
lvl_constant(LEVEL_UNKNOWN_2);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
- [network_player.h](#network_playerh)
|
||||
- [enum NetworkPlayerType](#enum-NetworkPlayerType)
|
||||
- [obj_behaviors.c](#obj_behaviorsc)
|
||||
- [obj_behaviors_2.h](#obj_behaviors_2h)
|
||||
- [object_constants.h](#object_constantsh)
|
||||
- [object_list_processor.h](#object_list_processorh)
|
||||
- [enum ObjectList](#enum-ObjectList)
|
||||
|
@ -1377,6 +1378,21 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [obj_behaviors_2.h](#obj_behaviors_2.h)
|
||||
- ATTACK_HANDLER_DIE_IF_HEALTH_NON_POSITIVE
|
||||
- ATTACK_HANDLER_KNOCKBACK
|
||||
- ATTACK_HANDLER_NOP
|
||||
- ATTACK_HANDLER_SET_SPEED_TO_ZERO
|
||||
- ATTACK_HANDLER_SPECIAL_HUGE_GOOMBA_WEAKLY_ATTACKED
|
||||
- ATTACK_HANDLER_SPECIAL_KOOPA_LOSE_SHELL
|
||||
- ATTACK_HANDLER_SPECIAL_WIGGLER_JUMPED_ON
|
||||
- ATTACK_HANDLER_SQUISHED
|
||||
- ATTACK_HANDLER_SQUISHED_WITH_BLUE_COIN
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [object_constants.h](#object_constants.h)
|
||||
- ACTIVE_FLAG_ACTIVE
|
||||
- ACTIVE_FLAG_DEACTIVATED
|
||||
|
|
|
@ -698,6 +698,11 @@
|
|||
|
||||
<br />
|
||||
|
||||
- object_list_processor.h
|
||||
- [set_object_respawn_info_bits](#set_object_respawn_info_bits)
|
||||
|
||||
<br />
|
||||
|
||||
- rumble_init.c
|
||||
- [queue_rumble_data](#queue_rumble_data)
|
||||
- [queue_rumble_data_mario](#queue_rumble_data_mario)
|
||||
|
@ -730,11 +735,13 @@
|
|||
|
||||
- smlua_misc_utils.h
|
||||
- [allocate_mario_action](#allocate_mario_action)
|
||||
- [deref_s32_pointer](#deref_s32_pointer)
|
||||
- [get_environment_region](#get_environment_region)
|
||||
- [get_hand_foot_pos_x](#get_hand_foot_pos_x)
|
||||
- [get_hand_foot_pos_y](#get_hand_foot_pos_y)
|
||||
- [get_hand_foot_pos_z](#get_hand_foot_pos_z)
|
||||
- [get_network_area_timer](#get_network_area_timer)
|
||||
- [get_temp_s32_pointer](#get_temp_s32_pointer)
|
||||
- [hud_hide](#hud_hide)
|
||||
- [hud_show](#hud_show)
|
||||
- [set_environment_region](#set_environment_region)
|
||||
|
@ -13310,6 +13317,33 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from object_list_processor.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [set_object_respawn_info_bits](#set_object_respawn_info_bits)
|
||||
|
||||
### Lua Example
|
||||
`set_object_respawn_info_bits(obj, bits)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
| bits | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_object_respawn_info_bits(struct Object *obj, u8 bits);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from rumble_init.c
|
||||
|
||||
|
@ -13724,6 +13758,26 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [deref_s32_pointer](#deref_s32_pointer)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = deref_s32_pointer(pointer)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| pointer | `Pointer` <`integer`> |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 deref_s32_pointer(s32* pointer);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_environment_region](#get_environment_region)
|
||||
|
||||
### Lua Example
|
||||
|
@ -13825,6 +13879,26 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [get_temp_s32_pointer](#get_temp_s32_pointer)
|
||||
|
||||
### Lua Example
|
||||
`local PointerValue = get_temp_s32_pointer(initialValue)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| initialValue | `integer` |
|
||||
|
||||
### Returns
|
||||
- `Pointer` <`integer`>
|
||||
|
||||
### C Prototype
|
||||
`s32* get_temp_s32_pointer(s32 initialValue);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [hud_hide](#hud_hide)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -1431,6 +1431,15 @@ char gSmluaConstants[] = ""
|
|||
"OBJ_COL_FLAG_UNDERWATER = (1 << 2)\n"
|
||||
"OBJ_COL_FLAG_NO_Y_VEL = (1 << 3)\n"
|
||||
"OBJ_COL_FLAGS_LANDED = (OBJ_COL_FLAG_GROUNDED | OBJ_COL_FLAG_NO_Y_VEL)\n"
|
||||
"ATTACK_HANDLER_NOP = 0\n"
|
||||
"ATTACK_HANDLER_DIE_IF_HEALTH_NON_POSITIVE = 1\n"
|
||||
"ATTACK_HANDLER_KNOCKBACK = 2\n"
|
||||
"ATTACK_HANDLER_SQUISHED = 3\n"
|
||||
"ATTACK_HANDLER_SPECIAL_KOOPA_LOSE_SHELL = 4\n"
|
||||
"ATTACK_HANDLER_SET_SPEED_TO_ZERO = 5\n"
|
||||
"ATTACK_HANDLER_SPECIAL_WIGGLER_JUMPED_ON = 6\n"
|
||||
"ATTACK_HANDLER_SPECIAL_HUGE_GOOMBA_WEAKLY_ATTACKED = 7\n"
|
||||
"ATTACK_HANDLER_SQUISHED_WITH_BLUE_COIN = 8\n"
|
||||
"ACTIVE_FLAG_DEACTIVATED = 0\n"
|
||||
"ACTIVE_FLAG_ACTIVE = (1 << 0)\n"
|
||||
"ACTIVE_FLAG_FAR_AWAY = (1 << 1)\n"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "src/pc/lua/utils/smlua_collision_utils.h"
|
||||
#include "src/pc/lua/utils/smlua_model_utils.h"
|
||||
#include "src/engine/surface_load.h"
|
||||
#include "src/game/object_list_processor.h"
|
||||
|
||||
|
||||
//////////////////////
|
||||
|
@ -8967,6 +8968,23 @@ int smlua_func_stub_obj_helpers_4(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// object_list_processor.h //
|
||||
/////////////////////////////
|
||||
|
||||
int smlua_func_set_object_respawn_info_bits(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u8 bits = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
set_object_respawn_info_bits(obj, bits);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// rumble_init.c //
|
||||
///////////////////
|
||||
|
@ -9233,6 +9251,17 @@ int smlua_func_allocate_mario_action(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_deref_s32_pointer(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
s32* pointer = (s32*)smlua_to_cpointer(L, 1, LVT_S32_P);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
lua_pushinteger(L, deref_s32_pointer(pointer));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_environment_region(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
@ -9292,6 +9321,17 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_temp_s32_pointer(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
s32 initialValue = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_push_pointer(L, LVT_S32_P, (void*)get_temp_s32_pointer(initialValue));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_hud_hide(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
@ -10748,6 +10788,9 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "stub_obj_helpers_3", smlua_func_stub_obj_helpers_3);
|
||||
smlua_bind_function(L, "stub_obj_helpers_4", smlua_func_stub_obj_helpers_4);
|
||||
|
||||
// object_list_processor.h
|
||||
smlua_bind_function(L, "set_object_respawn_info_bits", smlua_func_set_object_respawn_info_bits);
|
||||
|
||||
// rumble_init.c
|
||||
smlua_bind_function(L, "queue_rumble_data", smlua_func_queue_rumble_data);
|
||||
smlua_bind_function(L, "queue_rumble_data_mario", smlua_func_queue_rumble_data_mario);
|
||||
|
@ -10774,11 +10817,13 @@ void smlua_bind_functions_autogen(void) {
|
|||
|
||||
// smlua_misc_utils.h
|
||||
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
|
||||
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
|
||||
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
|
||||
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
||||
smlua_bind_function(L, "hud_show", smlua_func_hud_show);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
|
|
|
@ -150,6 +150,10 @@ void* smlua_to_cobject(lua_State* L, int index, u16 lot) {
|
|||
}
|
||||
|
||||
void* smlua_to_cpointer(lua_State* L, int index, u16 lvt) {
|
||||
if (lua_type(L, index) == LUA_TNIL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lua_type(L, index) != LUA_TTABLE) {
|
||||
LOG_LUA("smlua_to_cpointer received improper type '%d'", lua_type(L, index));
|
||||
smlua_logline();
|
||||
|
|
|
@ -13,6 +13,24 @@ u32 get_network_area_timer(void) {
|
|||
return gNetworkAreaTimer;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
s32* get_temp_s32_pointer(s32 initialValue) {
|
||||
static s32 value = 0;
|
||||
value = initialValue;
|
||||
return &value;
|
||||
}
|
||||
|
||||
s32 deref_s32_pointer(s32* pointer) {
|
||||
if (pointer == NULL) {
|
||||
LOG_LUA("Tried to dereference null pointer!");
|
||||
return 0;
|
||||
}
|
||||
return *pointer;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void hud_hide(void) {
|
||||
gOverrideHideHud = 1;
|
||||
}
|
||||
|
@ -21,6 +39,8 @@ void hud_show(void) {
|
|||
gOverrideHideHud = 0;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct) {
|
||||
return dynos_warp_to_level(aLevel, aArea, aAct);
|
||||
}
|
||||
|
@ -37,11 +57,15 @@ bool warp_to_castle(s32 aLevel) {
|
|||
return dynos_warp_to_castle(aLevel);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
u32 allocate_mario_action(u32 actFlags) {
|
||||
actFlags = actFlags & (~((u32)0xFF));
|
||||
return actFlags | ACT_FLAG_CUSTOM_ACTION | gLuaMarioActionIndex++;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
f32 get_hand_foot_pos_x(struct MarioState* m, u8 index) {
|
||||
if (index >= 4) { index = 0; }
|
||||
return m->marioBodyState->handFootPos[index][0];
|
||||
|
@ -57,10 +81,14 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index) {
|
|||
return m->marioBodyState->handFootPos[index][2];
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
LevelScript* smlua_level_util_get(const char* name) {
|
||||
return dynos_level_get(name);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
f32 get_environment_region(u8 index) {
|
||||
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) {
|
||||
return gEnvironmentRegions[6 * (int)index];
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
u32 get_network_area_timer(void);
|
||||
|
||||
s32* get_temp_s32_pointer(s32 initialValue);
|
||||
s32 deref_s32_pointer(s32* pointer);
|
||||
|
||||
void hud_hide(void);
|
||||
void hud_show(void);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "src/pc/platform.h"
|
||||
#include "mod.h"
|
||||
|
||||
#define MAX_MOD_SIZE (5 * 1048576) // 5MB
|
||||
#define MAX_MOD_SIZE (10 * 1048576) // 10MB
|
||||
#define TMP_DIRECTORY "tmp"
|
||||
|
||||
struct Mods {
|
||||
|
|
Loading…
Reference in a new issue