mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
area_create_warp_node and area_get_warp_node* (#270)
* area_get_warp_node* - Added area_get_warp_node to Lua - Added area_get_warp_node_from_params to Lua * area_create_warp_node and warp constants Here you go Isaac! * Add object param * Commits work again, pushing everything else
This commit is contained in:
parent
e5cb5e5e15
commit
4aada40a62
13 changed files with 240 additions and 3 deletions
|
@ -38,7 +38,8 @@ in_files = [
|
|||
"include/seq_ids.h",
|
||||
"include/surface_terrains.h",
|
||||
"src/game/level_update.h",
|
||||
"src/pc/network/version.h"
|
||||
"src/pc/network/version.h",
|
||||
"include/level_commands.h"
|
||||
]
|
||||
|
||||
exclude_constants = {
|
||||
|
@ -47,6 +48,7 @@ exclude_constants = {
|
|||
}
|
||||
|
||||
include_constants = {
|
||||
'include/level_commands.h': [ "WARP_CHECKPOINT", "WARP_NO_CHECKPOINT" ],
|
||||
}
|
||||
|
||||
pretend_find = [
|
||||
|
|
|
@ -55,7 +55,9 @@ in_files = [
|
|||
"src/game/mario_misc.h",
|
||||
"src/pc/mods/mod_storage.h",
|
||||
"src/pc/utils/misc.h",
|
||||
"src/game/level_update.h"
|
||||
"src/game/level_update.h",
|
||||
"src/game/area.h",
|
||||
"src/engine/level_script.h"
|
||||
]
|
||||
|
||||
override_allowed_functions = {
|
||||
|
@ -66,8 +68,10 @@ override_allowed_functions = {
|
|||
"src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ],
|
||||
"src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
|
||||
"src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*" ],
|
||||
"src/pc/utils/misc.h": [ "update_all_mario_stars" ],
|
||||
"src/game/level_update.h": [ "level_trigger_warp" ],
|
||||
"src/pc/utils/misc.h": [ "update_all_mario_stars"],
|
||||
"src/game/area.h": [ "area_get_warp_node" ],
|
||||
"src/engine/level_script.h": [ "area_create_warp_node" ]
|
||||
}
|
||||
|
||||
override_disallowed_functions = {
|
||||
|
|
|
@ -3627,6 +3627,12 @@ INTERACT_IGLOO_BARRIER = (1 << 30)
|
|||
--- @type InteractionType
|
||||
INTERACT_PLAYER = (1 << 31)
|
||||
|
||||
--- @type integer
|
||||
WARP_CHECKPOINT = 0x80
|
||||
|
||||
--- @type integer
|
||||
WARP_NO_CHECKPOINT = 0x00
|
||||
|
||||
--- @class LevelNum
|
||||
|
||||
--- @type LevelNum
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
-- AUTOGENERATED FOR CODE EDITORS --
|
||||
|
||||
--- @param id integer
|
||||
--- @return ObjectWarpNode
|
||||
function area_get_warp_node(id)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param o Object
|
||||
--- @return ObjectWarpNode
|
||||
function area_get_warp_node_from_params(o)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param a0 Vec3f
|
||||
--- @param a1 Vec3f
|
||||
--- @param yVel number
|
||||
|
@ -4002,6 +4014,17 @@ function get_star_name_sm64(courseNum, starNum, charCase)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param id integer
|
||||
--- @param destLevel integer
|
||||
--- @param destArea integer
|
||||
--- @param destNode integer
|
||||
--- @param checkpoint integer
|
||||
--- @param o Object
|
||||
--- @return ObjectWarpNode
|
||||
function area_create_warp_node(id, destLevel, destArea, destNode, checkpoint, o)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param m MarioState
|
||||
--- @param warpOp integer
|
||||
--- @return integer
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
- [enum InteractionFlag](#enum-InteractionFlag)
|
||||
- [interaction.h](#interactionh)
|
||||
- [enum InteractionType](#enum-InteractionType)
|
||||
- [level_commands.h](#level_commandsh)
|
||||
- [level_defines.h](#level_definesh)
|
||||
- [enum LevelNum](#enum-LevelNum)
|
||||
- [level_update.h](#level_updateh)
|
||||
|
@ -1244,6 +1245,14 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [level_commands.h](#level_commands.h)
|
||||
- WARP_CHECKPOINT
|
||||
- WARP_NO_CHECKPOINT
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [level_defines.h](#level_defines.h)
|
||||
|
||||
### [enum LevelNum](#LevelNum)
|
||||
|
|
|
@ -3358,6 +3358,37 @@
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from level_script.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [area_create_warp_node](#area_create_warp_node)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectWarpNodeValue = area_create_warp_node(id, destLevel, destArea, destNode, checkpoint, o)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| id | `integer` |
|
||||
| destLevel | `integer` |
|
||||
| destArea | `integer` |
|
||||
| destNode | `integer` |
|
||||
| checkpoint | `integer` |
|
||||
| o | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
[ObjectWarpNode](structs.md#ObjectWarpNode)
|
||||
|
||||
### C Prototype
|
||||
`struct ObjectWarpNode *area_create_warp_node(u8 id, u8 destLevel, u8 destArea, u8 destNode, u8 checkpoint, struct Object *o);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from level_update.h
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
|
||||
<br />
|
||||
|
||||
- area.h
|
||||
- [area_get_warp_node](functions.md#area_get_warp_node)
|
||||
- [area_get_warp_node_from_params](functions.md#area_get_warp_node_from_params)
|
||||
|
||||
<br />
|
||||
|
||||
- behavior_actions.h
|
||||
- [arc_to_goal_pos](functions-2.md#arc_to_goal_pos)
|
||||
- [bhv_1up_common_init](functions-2.md#bhv_1up_common_init)
|
||||
|
@ -788,6 +794,11 @@
|
|||
|
||||
<br />
|
||||
|
||||
- level_script.h
|
||||
- [area_create_warp_node](functions-3.md#area_create_warp_node)
|
||||
|
||||
<br />
|
||||
|
||||
- level_update.h
|
||||
- [level_trigger_warp](functions-3.md#level_trigger_warp)
|
||||
|
||||
|
@ -1843,6 +1854,52 @@ Retrieves a texture by name.
|
|||
|
||||
<br />
|
||||
|
||||
|
||||
---
|
||||
# functions from area.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [area_get_warp_node](#area_get_warp_node)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectWarpNodeValue = area_get_warp_node(id)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| id | `integer` |
|
||||
|
||||
### Returns
|
||||
[ObjectWarpNode](structs.md#ObjectWarpNode)
|
||||
|
||||
### C Prototype
|
||||
`struct ObjectWarpNode *area_get_warp_node(u8 id);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [area_get_warp_node_from_params](#area_get_warp_node_from_params)
|
||||
|
||||
### Lua Example
|
||||
`local ObjectWarpNodeValue = area_get_warp_node_from_params(o)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| o | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
[ObjectWarpNode](structs.md#ObjectWarpNode)
|
||||
|
||||
### C Prototype
|
||||
`struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
---
|
||||
|
||||
1 | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | [next >](functions-2.md)]
|
||||
|
|
|
@ -102,6 +102,26 @@ static s32 eval_script_op(s8 op, s32 arg) {
|
|||
return result;
|
||||
}
|
||||
|
||||
struct ObjectWarpNode *area_create_warp_node(u8 id, u8 destLevel, u8 destArea, u8 destNode, u8 checkpoint, struct Object *o) {
|
||||
if (sCurrAreaIndex != -1) {
|
||||
struct ObjectWarpNode *warpNode =
|
||||
alloc_only_pool_alloc(sLevelPool, sizeof(struct ObjectWarpNode));
|
||||
|
||||
warpNode->node.id = id;
|
||||
warpNode->node.destLevel = destLevel + checkpoint;
|
||||
warpNode->node.destArea = destArea;
|
||||
warpNode->node.destNode = destNode;
|
||||
|
||||
warpNode->object = o;
|
||||
|
||||
warpNode->next = gAreas[sCurrAreaIndex].warpNodes;
|
||||
gAreas[sCurrAreaIndex].warpNodes = warpNode;
|
||||
|
||||
return warpNode;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void area_check_red_coin_or_secret(void *arg, bool isMacroObject) {
|
||||
const BehaviorScript *bhv = NULL;
|
||||
if (isMacroObject) {
|
||||
|
|
|
@ -10,6 +10,8 @@ extern LevelScript* gLevelScriptActive;
|
|||
|
||||
extern u8 level_script_entry[];
|
||||
|
||||
struct ObjectWarpNode *area_create_warp_node(u8 id, u8 destLevel, u8 destArea, u8 destNode, u8 checkpoint, struct Object *o);
|
||||
|
||||
struct LevelCommand *level_script_execute(struct LevelCommand *cmd);
|
||||
|
||||
#endif // LEVEL_SCRIPT_H
|
||||
|
|
|
@ -170,6 +170,8 @@ struct ObjectWarpNode *area_get_warp_node(u8 id) {
|
|||
}
|
||||
|
||||
struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o) {
|
||||
if (o == NULL) { return NULL; }
|
||||
|
||||
u8 sp1F = (o->oBehParams & 0x00FF0000) >> 16;
|
||||
|
||||
return area_get_warp_node(sp1F);
|
||||
|
|
|
@ -160,6 +160,7 @@ void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e);
|
|||
void print_intro_text(void);
|
||||
u32 get_mario_spawn_type(struct Object *o);
|
||||
struct ObjectWarpNode *area_get_warp_node(u8 id);
|
||||
struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o);
|
||||
void clear_areas(void);
|
||||
void clear_area_graph_nodes(void);
|
||||
void load_area(s32 index);
|
||||
|
|
|
@ -1398,6 +1398,8 @@ char gSmluaConstants[] = ""
|
|||
"INT_STATUS_HIT_MINE = (1 << 21)\n"
|
||||
"INT_STATUS_STOP_RIDING = (1 << 22)\n"
|
||||
"INT_STATUS_TOUCHED_BOB_OMB = (1 << 23)\n"
|
||||
"WARP_CHECKPOINT = 0x80\n"
|
||||
"WARP_NO_CHECKPOINT = 0x00\n"
|
||||
"LEVEL_NONE = 0\n"
|
||||
"LEVEL_UNKNOWN_1 = 1\n"
|
||||
"LEVEL_UNKNOWN_2 = 2\n"
|
||||
|
|
|
@ -35,8 +35,48 @@
|
|||
#include "src/pc/mods/mod_storage.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
#include "src/game/level_update.h"
|
||||
#include "src/game/area.h"
|
||||
#include "src/engine/level_script.h"
|
||||
|
||||
|
||||
////////////
|
||||
// area.h //
|
||||
////////////
|
||||
|
||||
int smlua_func_area_get_warp_node(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", "area_get_warp_node", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 id = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "area_get_warp_node"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECTWARPNODE, area_get_warp_node(id));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_area_get_warp_node_from_params(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", "area_get_warp_node_from_params", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "area_get_warp_node_from_params"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECTWARPNODE, area_get_warp_node_from_params(o));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// behavior_actions.h //
|
||||
////////////////////////
|
||||
|
@ -12605,6 +12645,37 @@ int smlua_func_get_star_name_sm64(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// level_script.h //
|
||||
////////////////////
|
||||
|
||||
int smlua_func_area_create_warp_node(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 6) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "area_create_warp_node", 6, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 id = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "area_create_warp_node"); return 0; }
|
||||
u8 destLevel = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "area_create_warp_node"); return 0; }
|
||||
u8 destArea = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "area_create_warp_node"); return 0; }
|
||||
u8 destNode = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "area_create_warp_node"); return 0; }
|
||||
u8 checkpoint = smlua_to_integer(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "area_create_warp_node"); return 0; }
|
||||
struct Object* o = (struct Object*)smlua_to_cobject(L, 6, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "area_create_warp_node"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_OBJECTWARPNODE, area_create_warp_node(id, destLevel, destArea, destNode, checkpoint, o));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// level_update.h //
|
||||
////////////////////
|
||||
|
@ -28721,6 +28792,10 @@ int smlua_func_load_object_collision_model(UNUSED lua_State* L) {
|
|||
void smlua_bind_functions_autogen(void) {
|
||||
lua_State* L = gLuaState;
|
||||
|
||||
// area.h
|
||||
smlua_bind_function(L, "area_get_warp_node", smlua_func_area_get_warp_node);
|
||||
smlua_bind_function(L, "area_get_warp_node_from_params", smlua_func_area_get_warp_node_from_params);
|
||||
|
||||
// behavior_actions.h
|
||||
smlua_bind_function(L, "arc_to_goal_pos", smlua_func_arc_to_goal_pos);
|
||||
smlua_bind_function(L, "bhv_1up_common_init", smlua_func_bhv_1up_common_init);
|
||||
|
@ -29481,6 +29556,9 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "get_star_name_ascii", smlua_func_get_star_name_ascii);
|
||||
smlua_bind_function(L, "get_star_name_sm64", smlua_func_get_star_name_sm64);
|
||||
|
||||
// level_script.h
|
||||
smlua_bind_function(L, "area_create_warp_node", smlua_func_area_create_warp_node);
|
||||
|
||||
// level_update.h
|
||||
smlua_bind_function(L, "level_trigger_warp", smlua_func_level_trigger_warp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue