Make spawn_*_object setup function optional (and everything else) (#1321)

* sep

* aughh i forgot to run autogen
This commit is contained in:
Cooliokid956 2026-06-21 11:24:53 -05:00 committed by GitHub
parent ffe63b9f8a
commit be8ad7acc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 33 additions and 31 deletions

View file

@ -12430,7 +12430,7 @@ end
--- @param x number
--- @param y number
--- @param z number
--- @param objSetupFunction function
--- @param objSetupFunction? function
--- @return Object
--- Spawns a synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.<br>
--- You can change the fields of the object in `objSetupFunction`
@ -12443,7 +12443,7 @@ end
--- @param x number
--- @param y number
--- @param z number
--- @param objSetupFunction function
--- @param objSetupFunction? function
--- @return Object
--- Spawns a non-synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.<br>
--- You can change the fields of the object in `objSetupFunction`

View file

@ -4104,7 +4104,7 @@ You can change the fields of the object in `objSetupFunction`
- [Object](structs.md#Object)
### C Prototype
`struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
`struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);`
[:arrow_up_small:](#)
@ -4133,7 +4133,7 @@ You can change the fields of the object in `objSetupFunction`
- [Object](structs.md#Object)
### C Prototype
`struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
`struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);`
[:arrow_up_small:](#)

View file

@ -113,21 +113,21 @@ s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046,
#include "behaviors/white_puff_explode.inc.c"
// not in behavior file
struct SpawnParticlesInfo D_8032F270 = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
struct SpawnParticlesInfo sMistParticles = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
// generate_wind_puffs/dust (something like that)
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) {
D_8032F270.sizeBase = size;
D_8032F270.sizeRange = size / 20.0;
D_8032F270.offsetY = offsetY;
sMistParticles.sizeBase = size;
sMistParticles.sizeRange = size / 20.0;
sMistParticles.offsetY = offsetY;
if (count == 0) {
D_8032F270.count = 20;
sMistParticles.count = 20;
} else if (count > 20) {
D_8032F270.count = count;
sMistParticles.count = count;
} else {
D_8032F270.count = 4;
sMistParticles.count = 4;
}
cur_obj_spawn_particles(&D_8032F270);
cur_obj_spawn_particles(&sMistParticles);
}
#include "behaviors/sparkle_spawn_star.inc.c"

View file

@ -9,8 +9,7 @@
#include "object_constants.h"
// used for chain chomp and wiggler
struct ChainSegment
{
struct ChainSegment {
f32 posX;
f32 posY;
f32 posZ;
@ -27,8 +26,7 @@ struct ChainSegment
#define WATER_DROPLET_FLAG_RAND_ANGLE_INCR 0x80 // Unused
// Call spawn_water_droplet with this struct to spawn an object.
struct WaterDropletParams
{
struct WaterDropletParams {
s16 flags; // Droplet spawn flags, see defines above
s16 model;
const BehaviorScript *behavior;
@ -42,9 +40,7 @@ struct WaterDropletParams
f32 randSizeScale;
};
// TODO: Field names
struct SpawnParticlesInfo
{
struct SpawnParticlesInfo {
/*0x00*/ s8 behParam;
/*0x01*/ s8 count;
/*0x02*/ u16 model;

View file

@ -34968,8 +34968,8 @@ int smlua_func_spawn_sync_object(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", "spawn_sync_object", 6, top);
if (top < 5 || top > 6) {
LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "spawn_sync_object", 5, 6, top);
return 0;
}
@ -34983,8 +34983,11 @@ int smlua_func_spawn_sync_object(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "spawn_sync_object"); return 0; }
f32 z = smlua_to_number(L, 5);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "spawn_sync_object"); return 0; }
LuaFunction objSetupFunction = smlua_to_lua_function(L, 6);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_sync_object"); return 0; }
LuaFunction objSetupFunction = (LuaFunction) 0;
if (top >= 6) {
objSetupFunction = smlua_to_lua_function(L, 6);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_sync_object"); return 0; }
}
smlua_push_object(L, LOT_OBJECT, spawn_sync_object(behaviorId, modelId, x, y, z, objSetupFunction), NULL);
@ -34995,8 +34998,8 @@ int smlua_func_spawn_non_sync_object(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", "spawn_non_sync_object", 6, top);
if (top < 5 || top > 6) {
LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "spawn_non_sync_object", 5, 6, top);
return 0;
}
@ -35010,8 +35013,11 @@ int smlua_func_spawn_non_sync_object(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "spawn_non_sync_object"); return 0; }
f32 z = smlua_to_number(L, 5);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "spawn_non_sync_object"); return 0; }
LuaFunction objSetupFunction = smlua_to_lua_function(L, 6);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_non_sync_object"); return 0; }
LuaFunction objSetupFunction = (LuaFunction) 0;
if (top >= 6) {
objSetupFunction = smlua_to_lua_function(L, 6);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_non_sync_object"); return 0; }
}
smlua_push_object(L, LOT_OBJECT, spawn_non_sync_object(behaviorId, modelId, x, y, z, objSetupFunction), NULL);

View file

@ -76,11 +76,11 @@ static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum Mod
return obj;
}
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction) {
return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true);
}
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction) {
return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false);
}

View file

@ -9,12 +9,12 @@
Spawns a synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
You can change the fields of the object in `objSetupFunction`
|descriptionEnd| */
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);
/* |description|
Spawns a non-synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
You can change the fields of the object in `objSetupFunction`
|descriptionEnd| */
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);
/* |description|Checks if an object has `behaviorId`|descriptionEnd| */
s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId);