mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-23 16:14:47 -05:00
add a way to create/modify whirlpools (#267)
This commit is contained in:
parent
35f7caecc1
commit
2d1cb4712c
7 changed files with 83 additions and 2 deletions
|
@ -8563,6 +8563,17 @@ function obj_set_vel(o, vx, vy, vz)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param x number
|
||||||
|
--- @param y number
|
||||||
|
--- @param z number
|
||||||
|
--- @param strength integer
|
||||||
|
--- @param area integer
|
||||||
|
--- @param index integer
|
||||||
|
--- @return nil
|
||||||
|
function set_whirlpools(x, y, z, strength, area, index)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param behaviorId BehaviorId
|
--- @param behaviorId BehaviorId
|
||||||
--- @param modelId ModelExtendedId
|
--- @param modelId ModelExtendedId
|
||||||
--- @param x number
|
--- @param x number
|
||||||
|
|
|
@ -614,6 +614,31 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [set_whirlpools](#set_whirlpools)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`set_whirlpools(x, y, z, strength, area, index)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| x | `number` |
|
||||||
|
| y | `number` |
|
||||||
|
| z | `number` |
|
||||||
|
| strength | `integer` |
|
||||||
|
| area | `integer` |
|
||||||
|
| index | `integer` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void set_whirlpools(f32 x, f32 y, f32 z, s16 strength, s16 area, s32 index);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [spawn_non_sync_object](#spawn_non_sync_object)
|
## [spawn_non_sync_object](#spawn_non_sync_object)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
|
|
@ -1580,6 +1580,7 @@
|
||||||
- [obj_move_xyz](functions-5.md#obj_move_xyz)
|
- [obj_move_xyz](functions-5.md#obj_move_xyz)
|
||||||
- [obj_set_model_extended](functions-5.md#obj_set_model_extended)
|
- [obj_set_model_extended](functions-5.md#obj_set_model_extended)
|
||||||
- [obj_set_vel](functions-5.md#obj_set_vel)
|
- [obj_set_vel](functions-5.md#obj_set_vel)
|
||||||
|
- [set_whirlpools](functions-5.md#set_whirlpools)
|
||||||
- [spawn_non_sync_object](functions-5.md#spawn_non_sync_object)
|
- [spawn_non_sync_object](functions-5.md#spawn_non_sync_object)
|
||||||
- [spawn_sync_object](functions-5.md#spawn_sync_object)
|
- [spawn_sync_object](functions-5.md#spawn_sync_object)
|
||||||
|
|
||||||
|
|
|
@ -27799,6 +27799,33 @@ int smlua_func_obj_set_vel(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_set_whirlpools(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", "set_whirlpools", 6, top);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 x = smlua_to_number(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_whirlpools"); return 0; }
|
||||||
|
f32 y = smlua_to_number(L, 2);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_whirlpools"); return 0; }
|
||||||
|
f32 z = smlua_to_number(L, 3);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "set_whirlpools"); return 0; }
|
||||||
|
s16 strength = smlua_to_integer(L, 4);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "set_whirlpools"); return 0; }
|
||||||
|
s16 area = smlua_to_integer(L, 5);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "set_whirlpools"); return 0; }
|
||||||
|
s32 index = smlua_to_integer(L, 6);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "set_whirlpools"); return 0; }
|
||||||
|
|
||||||
|
set_whirlpools(x, y, z, strength, area, index);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_spawn_non_sync_object(lua_State* L) {
|
int smlua_func_spawn_non_sync_object(lua_State* L) {
|
||||||
if (L == NULL) { return 0; }
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
@ -30185,6 +30212,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "obj_move_xyz", smlua_func_obj_move_xyz);
|
smlua_bind_function(L, "obj_move_xyz", smlua_func_obj_move_xyz);
|
||||||
smlua_bind_function(L, "obj_set_model_extended", smlua_func_obj_set_model_extended);
|
smlua_bind_function(L, "obj_set_model_extended", smlua_func_obj_set_model_extended);
|
||||||
smlua_bind_function(L, "obj_set_vel", smlua_func_obj_set_vel);
|
smlua_bind_function(L, "obj_set_vel", smlua_func_obj_set_vel);
|
||||||
|
smlua_bind_function(L, "set_whirlpools", smlua_func_set_whirlpools);
|
||||||
smlua_bind_function(L, "spawn_non_sync_object", smlua_func_spawn_non_sync_object);
|
smlua_bind_function(L, "spawn_non_sync_object", smlua_func_spawn_non_sync_object);
|
||||||
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
|
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,16 @@ int smlua_call_hook(lua_State* L, int nargs, int nresults, int errfunc, struct M
|
||||||
gLuaActiveMod = activeMod;
|
gLuaActiveMod = activeMod;
|
||||||
gLuaLastHookMod = activeMod;
|
gLuaLastHookMod = activeMod;
|
||||||
#if defined(LUA_PROFILER)
|
#if defined(LUA_PROFILER)
|
||||||
lua_profiler_start_counter(activeMod);
|
extern bool configLuaProfiler;
|
||||||
|
if (configLuaProfiler) {
|
||||||
|
lua_profiler_start_counter(activeMod);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
int rc = smlua_pcall(L, nargs, nresults, errfunc);
|
int rc = smlua_pcall(L, nargs, nresults, errfunc);
|
||||||
#if defined(LUA_PROFILER)
|
#if defined(LUA_PROFILER)
|
||||||
lua_profiler_stop_counter(activeMod);
|
if (configLuaProfiler) {
|
||||||
|
lua_profiler_stop_counter(activeMod);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
gLuaActiveMod = prev;
|
gLuaActiveMod = prev;
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -383,3 +383,13 @@ void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz) {
|
||||||
o->oPosY += dy;
|
o->oPosY += dy;
|
||||||
o->oPosZ += dz;
|
o->oPosZ += dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_whirlpools(f32 x, f32 y, f32 z, s16 strength, s16 area, s32 index) {
|
||||||
|
static struct Whirlpool whirlpool;
|
||||||
|
|
||||||
|
gAreas[area].whirlpools[index] = &whirlpool;
|
||||||
|
gAreas[area].whirlpools[index]->pos[0] = x;
|
||||||
|
gAreas[area].whirlpools[index]->pos[1] = y;
|
||||||
|
gAreas[area].whirlpools[index]->pos[2] = z;
|
||||||
|
gAreas[area].whirlpools[index]->strength = strength;
|
||||||
|
}
|
||||||
|
|
|
@ -53,5 +53,6 @@ bool obj_check_overlap_with_hitbox_params(struct Object *o, f32 x, f32 y, f32 z,
|
||||||
void obj_set_vel(struct Object *o, f32 vx, f32 vy, f32 vz);
|
void obj_set_vel(struct Object *o, f32 vx, f32 vy, f32 vz);
|
||||||
void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz);
|
void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz);
|
||||||
|
|
||||||
|
void set_whirlpools(f32 x, f32 y, f32 z, s16 strength, s16 area, s32 index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue