From 5eb6122af28ea24721350109b0e0bf2affa0650a Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 8 Apr 2022 00:07:06 -0700 Subject: [PATCH] Allow Lua to adjust default star spawn positions --- autogen/convert_structs.py | 1 + autogen/lua_definitions/structs.lua | 28 ++++++++++++++++ docs/lua/globals.md | 7 ++++ docs/lua/structs.md | 36 +++++++++++++++++++++ src/game/behavior_actions.c | 1 + src/game/behaviors/boo.inc.c | 9 ++++-- src/game/behaviors/bully.inc.c | 13 +++++--- src/game/behaviors/eyerok.inc.c | 6 ++-- src/game/behaviors/fire_piranha_plant.inc.c | 3 +- src/game/behaviors/king_bobomb.inc.c | 8 +++-- src/game/behaviors/klepto.inc.c | 3 +- src/game/behaviors/koopa.inc.c | 10 ++++-- src/game/behaviors/manta_ray.inc.c | 3 +- src/game/behaviors/mr_i.inc.c | 3 +- src/game/behaviors/racing_penguin.inc.c | 6 ++-- src/game/behaviors/snowman.inc.c | 3 +- src/game/behaviors/spawn_star_exit.inc.c | 3 +- src/game/behaviors/treasure_chest.inc.c | 10 ++++-- src/game/behaviors/tuxie.inc.c | 6 ++-- src/game/behaviors/ukiki_cage.inc.c | 3 +- src/game/behaviors/unagi.inc.c | 3 +- src/game/behaviors/water_ring.inc.c | 3 +- src/game/behaviors/whomp.inc.c | 5 ++- src/game/behaviors/wiggler.inc.c | 4 ++- src/game/hardcoded.c | 34 +++++++++++++++++++ src/game/hardcoded.h | 35 ++++++++++++++++++++ src/game/interaction.c | 4 ++- src/game/obj_behaviors.c | 1 + src/game/obj_behaviors_2.c | 1 + src/pc/lua/smlua_cobject.c | 6 ++++ src/pc/lua/smlua_cobject_autogen.c | 32 ++++++++++++++++++ src/pc/lua/smlua_cobject_autogen.h | 1 + 32 files changed, 258 insertions(+), 33 deletions(-) create mode 100644 src/game/hardcoded.c create mode 100644 src/game/hardcoded.h diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index 659e0833..5c6567fa 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -20,6 +20,7 @@ in_files = [ 'src/pc/lua/utils/smlua_collision_utils.h', 'src/game/spawn_sound.h', 'src/pc/network/network.h', + 'src/game/hardcoded.h', ] out_filename_c = 'src/pc/lua/smlua_cobject_autogen.c' diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 562c6a3e..93ee9849 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -1427,6 +1427,34 @@ --- @field public velYBase integer --- @field public velYRange integer +--- @class StarPositions +--- @field public BalconyBooStarPos Vec3f +--- @field public BigBullyStarPos Vec3f +--- @field public BigBullyTrioStarPos Vec3f +--- @field public BigPiranhasStarPos Vec3f +--- @field public CcmSlideStarPos Vec3f +--- @field public ChillBullyStarPos Vec3f +--- @field public EyerockStarPos Vec3f +--- @field public GhostHuntBooStarPos Vec3f +--- @field public JetstreamRingStarPos Vec3f +--- @field public KingBobombStarPos Vec3f +--- @field public KingWhompStarPos Vec3f +--- @field public KleptoStarPos Vec3f +--- @field public KoopaBobStarPos Vec3f +--- @field public KoopaThiStarPos Vec3f +--- @field public MantaRayStarPos Vec3f +--- @field public MerryGoRoundStarPos Vec3f +--- @field public MrIStarPos Vec3f +--- @field public PssSlideStarPos Vec3f +--- @field public RacingPenguinStarPos Vec3f +--- @field public SnowmanHeadStarPos Vec3f +--- @field public TreasureChestStarPos Vec3f +--- @field public TreasureJrbStarPos Vec3f +--- @field public TuxieMotherStarPos Vec3f +--- @field public UkikiCageStarPos Vec3f +--- @field public UnagiStarPos Vec3f +--- @field public WigglerStarPos Vec3f + --- @class Struct802A272C --- @field public vecF Vec3f --- @field public vecS Vec3s diff --git a/docs/lua/globals.md b/docs/lua/globals.md index 524a6dcf..e2d9661b 100644 --- a/docs/lua/globals.md +++ b/docs/lua/globals.md @@ -58,6 +58,13 @@ The `gGlobalObjectCollisionData` table contains references to object collision d
+## [gStarPositions](#gLakituState) +`gStarPositions`'s fields are listed in [StarPosition](structs.md#StarPosition). These are where stars will spawn for certain stars. + +[:arrow_up_small:](#) + +
+ ## [gServerSettings](#gServerSettings) `gServerSettings`'s fields are listed in [ServerSettings](structs.md#ServerSettings). diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 2ec5afea..79ced21d 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -46,6 +46,7 @@ - [SoundState](#SoundState) - [SpawnInfo](#SpawnInfo) - [SpawnParticlesInfo](#SpawnParticlesInfo) +- [StarPositions](#StarPositions) - [Struct802A272C](#Struct802A272C) - [Surface](#Surface) - [TextureInfo](#TextureInfo) @@ -1801,6 +1802,41 @@
+## [StarPositions](#StarPositions) + +| Field | Type | Access | +| ----- | ---- | ------ | +| BalconyBooStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| BigBullyStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| BigBullyTrioStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| BigPiranhasStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| CcmSlideStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| ChillBullyStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| EyerockStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| GhostHuntBooStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| JetstreamRingStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| KingBobombStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| KingWhompStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| KleptoStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| KoopaBobStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| KoopaThiStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| MantaRayStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| MerryGoRoundStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| MrIStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| PssSlideStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| RacingPenguinStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| SnowmanHeadStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| TreasureChestStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| TreasureJrbStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| TuxieMotherStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| UkikiCageStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| UnagiStarPos | [Vec3f](structs.md#Vec3f) | read-only | +| WigglerStarPos | [Vec3f](structs.md#Vec3f) | read-only | + +[:arrow_up_small:](#) + +
+ ## [Struct802A272C](#Struct802A272C) | Field | Type | Access | diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index 66cb8242..1c1cb5d4 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -45,6 +45,7 @@ #include "spawn_sound.h" #include "game/rng_position.h" #include "rumble_init.h" +#include "hardcoded.h" #include "pc/lua/utils/smlua_model_utils.h" #define o gCurrentObject diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index 61f44029..25d08a58 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -654,17 +654,20 @@ static void big_boo_act_2(void) { } static void big_boo_spawn_ghost_hunt_star(void) { - spawn_default_star(980.0f, 1100.0f, 250.0f); + f32* starPos = gStarPositions.GhostHuntBooStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); } static void big_boo_spawn_balcony_star(void) { - spawn_default_star(700.0f, 3200.0f, 1900.0f); + f32* starPos = gStarPositions.BalconyBooStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); } static void big_boo_spawn_merry_go_round_star(void) { struct Object *merryGoRound; - spawn_default_star(-1600.0f, -2100.0f, 205.0f); + f32* starPos = gStarPositions.MerryGoRoundStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); merryGoRound = cur_obj_nearest_object_with_behavior(bhvMerryGoRound); diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c index 1cd75e10..5270ed70 100644 --- a/src/game/behaviors/bully.inc.c +++ b/src/game/behaviors/bully.inc.c @@ -244,10 +244,12 @@ void bully_act_level_death(void) { } else { spawn_mist_particles(); - if (o->oBullySubtype == BULLY_STYPE_CHILL) - spawn_default_star(130.0f, 1600.0f, -4335.0f); - else { - spawn_default_star(0, 950.0f, -6800.0f); + if (o->oBullySubtype == BULLY_STYPE_CHILL) { + f32* starPos = gStarPositions.ChillBullyStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); + } else { + f32* starPos = gStarPositions.BigBullyStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); struct Object* lllTumblingBridge = cur_obj_nearest_object_with_behavior(bhvLllTumblingBridge); if (lllTumblingBridge != NULL) { lllTumblingBridge->oIntangibleTimer = 0; @@ -338,7 +340,8 @@ void bhv_big_bully_with_minions_init(void) { void big_bully_spawn_star(void) { if (obj_lava_death() == 1) { spawn_mist_particles(); - spawn_default_star(3700.0f, 600.0f, -5500.0f); + f32* starPos = gStarPositions.BigBullyTrioStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); } } diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index 6b8668c1..0221cdda 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -187,7 +187,8 @@ static void eyerok_boss_act_die(void) { /*struct MarioState* marioState = nearest_mario_state_to_object(o); if (o->oTimer == 60) { if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 0, CUTSCENE_DIALOG, DIALOG_118, eyerok_boss_act_die_continue_dialog)) { - spawn_default_star(0.0f, -900.0f, -3700.0f); + f32* starPos = gStarPositions.EyerockStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); } else { o->oTimer -= 1; } @@ -197,7 +198,8 @@ static void eyerok_boss_act_die(void) { }*/ stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); if (network_owns_object(o)) { - spawn_default_star(0.0f, -900.0f, -3700.0f); + f32* starPos = gStarPositions.EyerockStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); network_send_object_reliability(o, TRUE); } o->oAction = EYEROK_BOSS_ACT_DEAD; diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c index ad2273be..8d981cc4 100644 --- a/src/game/behaviors/fire_piranha_plant.inc.c +++ b/src/game/behaviors/fire_piranha_plant.inc.c @@ -74,7 +74,8 @@ static void fire_piranha_plant_act_hide(void) { if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) { if (++sNumKilledFirePiranhaPlants == 5) { - spawn_default_star(-6300.0f, -1850.0f, -6300.0f); + f32* starPos = gStarPositions.BigPiranhasStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); network_send_object(o); } diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index 8eddd395..15ba579f 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -240,11 +240,15 @@ void king_bobomb_act_8(void) { //cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f); f32 objectPosY = o->oPosY; o->oPosY += 200.0f + gDebugInfo[5][0]; - star = spawn_default_star(2000.0f, 4500.0f, -4500.0f); + + f32* starPos = gStarPositions.KingBobombStarPos; + star = spawn_default_star(starPos[0], starPos[1], starPos[2]); + o->oPosY = objectPosY; #else o->oPosY += 100.0f; - star = spawn_default_star(2000.0f, 4500.0f, -4500.0f); + f32* starPos = gStarPositions.KingBobombStarPos; + star = spawn_default_star(starPos[0], starPos[1], starPos[2]); #endif // If we're not the closet to King-Bombomb, // Don't play this cutscene! diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c index 6ff80ff8..ef49f26f 100644 --- a/src/game/behaviors/klepto.inc.c +++ b/src/game/behaviors/klepto.inc.c @@ -427,7 +427,8 @@ void bhv_klepto_update(void) { } } else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR) { - struct Object *star = spawn_default_star(-5550.0f, 300.0f, -930.0f); + f32* starPos = gStarPositions.KleptoStarPos; + struct Object* star = spawn_default_star(starPos[0], starPos[1], starPos[2]); // If we're not the closet to Klepto, // Don't play the cutscene! diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 29668abf..abf0da51 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -867,9 +867,13 @@ static void koopa_the_quick_act_after_race(void) { } } } else if (o->parentObj->oKoopaRaceEndpointRaceStatus != 0) { - spawn_default_star(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[0], - sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[1], - sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[2]); + if (o->oKoopaTheQuickRaceIndex == 0) { + f32* starPos = gStarPositions.KoopaBobStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); + } else { + f32* starPos = gStarPositions.KoopaThiStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); + } o->parentObj->oKoopaRaceEndpointRaceStatus = 0; } diff --git a/src/game/behaviors/manta_ray.inc.c b/src/game/behaviors/manta_ray.inc.c index c4124198..317a186d 100644 --- a/src/game/behaviors/manta_ray.inc.c +++ b/src/game/behaviors/manta_ray.inc.c @@ -133,7 +133,8 @@ void bhv_manta_ray_loop(void) { // Spawn a star after collecting 5 rings. if (o->oWaterRingSpawnerRingsCollected == 5) { spawn_mist_particles(); - spawn_default_star(-3180.0f, -3600.0f, 120.0f); + f32* starPos = gStarPositions.MantaRayStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); o->oAction = MANTA_ACT_NO_RINGS; } break; diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c index 1cc8ce78..facac92e 100644 --- a/src/game/behaviors/mr_i.inc.c +++ b/src/game/behaviors/mr_i.inc.c @@ -116,7 +116,8 @@ void mr_i_act_3(void) { o->oMrISize = sp1C * 0.6; if (o->oBehParams2ndByte) { o->oPosY += 100.0f; - spawn_default_star(1370, 2000.0f, -320.0f); + f32* starPos = gStarPositions.MrIStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); obj_mark_for_deletion(o); } else cur_obj_spawn_loot_blue_coin(); diff --git a/src/game/behaviors/racing_penguin.inc.c b/src/game/behaviors/racing_penguin.inc.c index 4f7f22c0..2f85a97a 100644 --- a/src/game/behaviors/racing_penguin.inc.c +++ b/src/game/behaviors/racing_penguin.inc.c @@ -251,10 +251,12 @@ static void racing_penguin_act_show_final_text(void) { o->oTimer = 0; } } else if (o->oRacingPenguinMarioWon) { + + f32* starPos = gStarPositions.RacingPenguinStarPos; #ifdef VERSION_JP - spawn_default_star(-7339.0f, -5700.0f, -6774.0f); + spawn_default_star(starPos[0], starPos[1], starPos[2]); #else - cur_obj_spawn_star_at_y_offset(-7339.0f, -5700.0f, -6774.0f, 200.0f); + cur_obj_spawn_star_at_y_offset(starPos[0], starPos[1], starPos[2], 200.0f); #endif o->oRacingPenguinMarioWon = FALSE; if (network_owns_object(o)) { network_send_object(o); } diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index f1bd20ff..014e45c8 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -243,7 +243,8 @@ void bhv_snowmans_head_loop(void) { case 4: if (trigger_obj_dialog_when_facing(&gMarioStates[0], &o->oSnowmansHeadUnkF4, DIALOG_111, 700.0f, 2, bhv_snowmans_head_action_4_continue_dialog)) { spawn_mist_particles(); - spawn_default_star(-4700.0f, -1024.0f, 1890.0f); + f32* starPos = gStarPositions.SnowmanHeadStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); o->oAction = 1; network_send_object(o); } diff --git a/src/game/behaviors/spawn_star_exit.inc.c b/src/game/behaviors/spawn_star_exit.inc.c index 8c5515a3..24ab41b7 100644 --- a/src/game/behaviors/spawn_star_exit.inc.c +++ b/src/game/behaviors/spawn_star_exit.inc.c @@ -5,7 +5,8 @@ void bhv_ccm_touched_star_spawn_loop(void) { o->oPosY += 100.0f; o->oPosX = 2780.0f; o->oPosZ = 4666.0f; - spawn_default_star(2500.0f, -4350.0f, 5750.0f); + f32* starPos = gStarPositions.CcmSlideStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); obj_mark_for_deletion(o); } } diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index 55d689a4..85a315d5 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -254,7 +254,10 @@ void bhv_treasure_chest_jrb_loop(void) { case 1: if (o->oTimer == 60) { spawn_mist_particles(); - spawn_networked_default_star(-1800.0f, -2500.0f, -1700.0f, o->oTreasureChestLastNetworkPlayerIndex); + + f32* starPos = gStarPositions.TreasureJrbStarPos; + spawn_networked_default_star(starPos[0], starPos[1], starPos[2], o->oTreasureChestLastNetworkPlayerIndex); + o->oAction = 2; } break; @@ -319,7 +322,10 @@ void bhv_treasure_chest_loop(void) { case 1: if (o->oTimer == 60) { spawn_mist_particles(); - spawn_networked_default_star(-1900.0f, -4000.0f, -1400.0f, o->oTreasureChestLastNetworkPlayerIndex); + + f32* starPos = gStarPositions.TreasureJrbStarPos; + spawn_networked_default_star(starPos[0], starPos[1], starPos[2], o->oTreasureChestLastNetworkPlayerIndex); + o->oAction = 2; } break; diff --git a/src/game/behaviors/tuxie.inc.c b/src/game/behaviors/tuxie.inc.c index 730c3e45..8b15dd20 100644 --- a/src/game/behaviors/tuxie.inc.c +++ b/src/game/behaviors/tuxie.inc.c @@ -84,10 +84,12 @@ void tuxies_mother_act_1(void) { // or 1, which is not affected by the bitwise AND. o->prevObj->OBJECT_FIELD_S32(o->oInteractionSubtype) &= ~INT_SUBTYPE_DROP_IMMEDIATELY; obj_set_behavior(o->prevObj, bhvUnused20E0); + + f32* starPos = gStarPositions.TuxieMotherStarPos; #ifndef VERSION_JP - cur_obj_spawn_star_at_y_offset(3167.0f, -4300.0f, 5108.0f, 200.0f); + cur_obj_spawn_star_at_y_offset(starPos[0], starPos[1], starPos[2], 200.0f); #else - spawn_default_star(3500.0f, -4300.0f, 4650.0f); + spawn_default_star(starPos[0], starPos[1], starPos[2]); #endif o->oAction = 2; network_send_object(o); diff --git a/src/game/behaviors/ukiki_cage.inc.c b/src/game/behaviors/ukiki_cage.inc.c index e7a46ffa..90b99687 100644 --- a/src/game/behaviors/ukiki_cage.inc.c +++ b/src/game/behaviors/ukiki_cage.inc.c @@ -37,7 +37,8 @@ void bhv_ukiki_cage_star_loop(void) { obj_mark_for_deletion(o); spawn_mist_particles(); spawn_triangle_break_particles(20, 138, 0.7, 3); - spawn_default_star(2500.0f, -1200.0f, 1300.0f); + f32* starPos = gStarPositions.UkikiCageStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); break; } diff --git a/src/game/behaviors/unagi.inc.c b/src/game/behaviors/unagi.inc.c index a68ea041..76cbdc19 100644 --- a/src/game/behaviors/unagi.inc.c +++ b/src/game/behaviors/unagi.inc.c @@ -215,7 +215,8 @@ void bhv_unagi_subobject_loop(void) { if (o->oBehParams2ndByte == -4) { if (o->parentObj->oAnimState != 0 && distanceToPlayer < 150.0f) { o->oBehParams = o->parentObj->oBehParams; - spawn_default_star(6833.0f, -3654.0f, 2230.0f); + f32* starPos = gStarPositions.UnagiStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); o->parentObj->oAnimState = 0; } } else { diff --git a/src/game/behaviors/water_ring.inc.c b/src/game/behaviors/water_ring.inc.c index e0d5d237..09e4d62e 100644 --- a/src/game/behaviors/water_ring.inc.c +++ b/src/game/behaviors/water_ring.inc.c @@ -194,7 +194,8 @@ void bhv_jet_stream_ring_spawner_loop(void) { if (o->oWaterRingSpawnerRingsCollected == 5) { spawn_mist_particles(); - spawn_default_star(3400.0f, -3200.0f, -500.0f); + f32* starPos = gStarPositions.JetstreamRingStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); o->oAction = JS_RING_SPAWNER_ACT_INACTIVE; network_send_object(o); diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index 2086a1a9..e1935db4 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -241,7 +241,10 @@ void whomp_act_8(void) { spawn_triangle_break_particles(20, 138, 3.0f, 4); cur_obj_shake_screen(SHAKE_POS_SMALL); o->oPosY += 100.0f; - spawn_default_star(180.0f, 3880.0f, 340.0f); + + f32* starPos = gStarPositions.KingWhompStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); + cur_obj_play_sound_2(SOUND_OBJ_KING_WHOMP_DEATH); o->oAction = 9; network_send_object(o); diff --git a/src/game/behaviors/wiggler.inc.c b/src/game/behaviors/wiggler.inc.c index b46c8361..2fdd7b5c 100644 --- a/src/game/behaviors/wiggler.inc.c +++ b/src/game/behaviors/wiggler.inc.c @@ -365,7 +365,9 @@ static void wiggler_act_shrink(void) { // 4 is the default scale, so shrink to 1/4 of regular size if (approach_f32_ptr(&o->header.gfx.scale[0], 1.0f, 0.1f)) { - struct Object *star = spawn_default_star(0.0f, 2048.0f, 0.0f); + + f32* starPos = gStarPositions.WigglerStarPos; + struct Object *star = spawn_default_star(starPos[0], starPos[1], starPos[2]); // If we're not the closet to Wiggler, // Don't play this cutscene! diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c new file mode 100644 index 00000000..9a40783d --- /dev/null +++ b/src/game/hardcoded.c @@ -0,0 +1,34 @@ +#include "hardcoded.h" + +struct StarPositions gStarPositions = { + .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, + .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, + .KingBobombStarPos = { 2000.0f, 4500.0f, -4500.0f }, + .KingWhompStarPos = { 180.0f, 3880.0f, 340.0f }, + .EyerockStarPos = { 0.0f, -900.0f, -3700.0f }, + .BigBullyStarPos = { 0.0f, 950.0f, -6800.0f }, + .ChillBullyStarPos = { 130.0f, 1600.0f, -4335.0f }, + .BigPiranhasStarPos = { -6300.0f, -1850.0f, -6300.0f }, +#ifdef VERSION_JP + .TuxieMotherStarPos = { 3500.0f, -4300.0f, 4650.0f }, +#else + .TuxieMotherStarPos = { 3167.0f, -4300.0f, 5108.0f }, +#endif + .WigglerStarPos = { 0.0f, 2048.0f, 0.0f }, + .PssSlideStarPos = { -6358.0f, -4300.0f, 4700.0f }, + .RacingPenguinStarPos = { -7339.0f, -5700.0f, -6774.0f }, + .TreasureJrbStarPos = { -1800.0f, -2500.0f, -1700.0f }, + .TreasureChestStarPos = { -1900.0f, -4000.0f, -1400.0f }, + .GhostHuntBooStarPos = { 980.0f, 1100.0f, 250.0f }, + .KleptoStarPos = { -5550.0f, 300.0f, -930.0f }, + .MerryGoRoundStarPos = { -1600.0f, -2100.0f, 205.0f }, + .MrIStarPos = { 1370.0f, 2000.0f, -320.0f }, + .BalconyBooStarPos = { 700.0f, 3200.0f, 1900.0f }, + .BigBullyTrioStarPos = { 3700.0f, 600.0f, -5500.0f }, + .MantaRayStarPos = { -3180.0f, -3600.0f, 120.0f }, + .SnowmanHeadStarPos = { -4700.0f, -1024.0f, 1890.0f }, + .CcmSlideStarPos = { 2500.0f, -4350.0f, 5750.0f }, + .UkikiCageStarPos = { 2500.0f, -1200.0f, 1300.0f }, + .UnagiStarPos = { 6833.0f, -3654.0f, 2230.0f }, + .JetstreamRingStarPos = { 3400.0f, -3200.0f, -500.0f }, +}; diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h new file mode 100644 index 00000000..341db7f1 --- /dev/null +++ b/src/game/hardcoded.h @@ -0,0 +1,35 @@ +#ifndef HARDCODED_H +#include "types.h" + +struct StarPositions { + Vec3f KoopaBobStarPos; + Vec3f KoopaThiStarPos; + Vec3f KingBobombStarPos; + Vec3f KingWhompStarPos; + Vec3f EyerockStarPos; + Vec3f BigBullyStarPos; + Vec3f ChillBullyStarPos; + Vec3f BigPiranhasStarPos; + Vec3f TuxieMotherStarPos; + Vec3f WigglerStarPos; + Vec3f PssSlideStarPos; + Vec3f RacingPenguinStarPos; + Vec3f TreasureJrbStarPos; + Vec3f TreasureChestStarPos; + Vec3f GhostHuntBooStarPos; + Vec3f KleptoStarPos; + Vec3f MerryGoRoundStarPos; + Vec3f MrIStarPos; + Vec3f BalconyBooStarPos; + Vec3f BigBullyTrioStarPos; + Vec3f MantaRayStarPos; + Vec3f SnowmanHeadStarPos; + Vec3f CcmSlideStarPos; + Vec3f UkikiCageStarPos; + Vec3f UnagiStarPos; + Vec3f JetstreamRingStarPos; +}; + +extern struct StarPositions gStarPositions; + +#endif \ No newline at end of file diff --git a/src/game/interaction.c b/src/game/interaction.c index 56869bbb..c8c81b20 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -24,6 +24,7 @@ #include "sm64.h" #include "sound_init.h" #include "rumble_init.h" +#include "hardcoded.h" #include "pc/configfile.h" #include "pc/network/network.h" @@ -2244,7 +2245,8 @@ void pss_end_slide(struct MarioState *m) { // PSS secret star uses oBehParams to spawn s32 tmp = m->marioObj->oBehParams; m->marioObj->oBehParams = (1 << 24); - spawn_default_star(-6358.0f, -4300.0f, 4700.0f); + f32* starPos = gStarPositions.PssSlideStarPos; + spawn_default_star(starPos[0], starPos[1], starPos[2]); m->marioObj->oBehParams = tmp; } gPssSlideStarted = FALSE; diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 8678d7e4..9ce0ea06 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -31,6 +31,7 @@ #include "save_file.h" #include "spawn_object.h" #include "spawn_sound.h" +#include "hardcoded.h" #include "engine/surface_load.h" #include "pc/network/network.h" #include "pc/network/reservation_area.h" diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index 352dac1e..5194f5a5 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -44,6 +44,7 @@ #include "save_file.h" #include "seq_ids.h" #include "spawn_sound.h" +#include "hardcoded.h" #include "engine/surface_load.h" #include "pc/network/network.h" #include "pc/network/reservation_area.h" diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 373e1e99..bd1fdc56 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -3,6 +3,7 @@ #include "game/level_update.h" #include "game/area.h" #include "game/mario.h" +#include "game/hardcoded.h" #include "audio/external.h" #include "object_fields.h" #include "pc/djui/djui_hud_utils.h" @@ -565,6 +566,11 @@ void smlua_cobject_init_globals(void) { lua_setglobal(L, "gServerSettings"); } + { + smlua_push_object(L, LOT_STARPOSITIONS, &gStarPositions); + lua_setglobal(L, "gStarPositions"); + } + } void smlua_cobject_init_per_file_globals(char* path) { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 8ae05fc7..808b7602 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -15,6 +15,7 @@ #include "src/pc/lua/utils/smlua_collision_utils.h" #include "src/game/spawn_sound.h" #include "src/pc/network/network.h" +#include "src/game/hardcoded.h" #include "include/object_fields.h" @@ -1573,6 +1574,36 @@ static struct LuaObjectField sSpawnParticlesInfoFields[LUA_SPAWN_PARTICLES_INFO_ { "velYRange", LVT_S8, offsetof(struct SpawnParticlesInfo, velYRange), false, LOT_NONE }, }; +#define LUA_STAR_POSITIONS_FIELD_COUNT 26 +static struct LuaObjectField sStarPositionsFields[LUA_STAR_POSITIONS_FIELD_COUNT] = { + { "BalconyBooStarPos", LVT_COBJECT, offsetof(struct StarPositions, BalconyBooStarPos), true, LOT_VEC3F }, + { "BigBullyStarPos", LVT_COBJECT, offsetof(struct StarPositions, BigBullyStarPos), true, LOT_VEC3F }, + { "BigBullyTrioStarPos", LVT_COBJECT, offsetof(struct StarPositions, BigBullyTrioStarPos), true, LOT_VEC3F }, + { "BigPiranhasStarPos", LVT_COBJECT, offsetof(struct StarPositions, BigPiranhasStarPos), true, LOT_VEC3F }, + { "CcmSlideStarPos", LVT_COBJECT, offsetof(struct StarPositions, CcmSlideStarPos), true, LOT_VEC3F }, + { "ChillBullyStarPos", LVT_COBJECT, offsetof(struct StarPositions, ChillBullyStarPos), true, LOT_VEC3F }, + { "EyerockStarPos", LVT_COBJECT, offsetof(struct StarPositions, EyerockStarPos), true, LOT_VEC3F }, + { "GhostHuntBooStarPos", LVT_COBJECT, offsetof(struct StarPositions, GhostHuntBooStarPos), true, LOT_VEC3F }, + { "JetstreamRingStarPos", LVT_COBJECT, offsetof(struct StarPositions, JetstreamRingStarPos), true, LOT_VEC3F }, + { "KingBobombStarPos", LVT_COBJECT, offsetof(struct StarPositions, KingBobombStarPos), true, LOT_VEC3F }, + { "KingWhompStarPos", LVT_COBJECT, offsetof(struct StarPositions, KingWhompStarPos), true, LOT_VEC3F }, + { "KleptoStarPos", LVT_COBJECT, offsetof(struct StarPositions, KleptoStarPos), true, LOT_VEC3F }, + { "KoopaBobStarPos", LVT_COBJECT, offsetof(struct StarPositions, KoopaBobStarPos), true, LOT_VEC3F }, + { "KoopaThiStarPos", LVT_COBJECT, offsetof(struct StarPositions, KoopaThiStarPos), true, LOT_VEC3F }, + { "MantaRayStarPos", LVT_COBJECT, offsetof(struct StarPositions, MantaRayStarPos), true, LOT_VEC3F }, + { "MerryGoRoundStarPos", LVT_COBJECT, offsetof(struct StarPositions, MerryGoRoundStarPos), true, LOT_VEC3F }, + { "MrIStarPos", LVT_COBJECT, offsetof(struct StarPositions, MrIStarPos), true, LOT_VEC3F }, + { "PssSlideStarPos", LVT_COBJECT, offsetof(struct StarPositions, PssSlideStarPos), true, LOT_VEC3F }, + { "RacingPenguinStarPos", LVT_COBJECT, offsetof(struct StarPositions, RacingPenguinStarPos), true, LOT_VEC3F }, + { "SnowmanHeadStarPos", LVT_COBJECT, offsetof(struct StarPositions, SnowmanHeadStarPos), true, LOT_VEC3F }, + { "TreasureChestStarPos", LVT_COBJECT, offsetof(struct StarPositions, TreasureChestStarPos), true, LOT_VEC3F }, + { "TreasureJrbStarPos", LVT_COBJECT, offsetof(struct StarPositions, TreasureJrbStarPos), true, LOT_VEC3F }, + { "TuxieMotherStarPos", LVT_COBJECT, offsetof(struct StarPositions, TuxieMotherStarPos), true, LOT_VEC3F }, + { "UkikiCageStarPos", LVT_COBJECT, offsetof(struct StarPositions, UkikiCageStarPos), true, LOT_VEC3F }, + { "UnagiStarPos", LVT_COBJECT, offsetof(struct StarPositions, UnagiStarPos), true, LOT_VEC3F }, + { "WigglerStarPos", LVT_COBJECT, offsetof(struct StarPositions, WigglerStarPos), true, LOT_VEC3F }, +}; + #define LUA_STRUCT802_A272_C_FIELD_COUNT 2 static struct LuaObjectField sStruct802A272CFields[LUA_STRUCT802_A272_C_FIELD_COUNT] = { { "vecF", LVT_COBJECT, offsetof(struct Struct802A272C, vecF), true, LOT_VEC3F }, @@ -1738,6 +1769,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_SOUNDSTATE, sSoundStateFields, LUA_SOUND_STATE_FIELD_COUNT }, { LOT_SPAWNINFO, sSpawnInfoFields, LUA_SPAWN_INFO_FIELD_COUNT }, { LOT_SPAWNPARTICLESINFO, sSpawnParticlesInfoFields, LUA_SPAWN_PARTICLES_INFO_FIELD_COUNT }, + { LOT_STARPOSITIONS, sStarPositionsFields, LUA_STAR_POSITIONS_FIELD_COUNT }, { LOT_STRUCT802A272C, sStruct802A272CFields, LUA_STRUCT802_A272_C_FIELD_COUNT }, { LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT }, { LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT }, diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 32fcaa85..52a3ac1e 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -48,6 +48,7 @@ enum LuaObjectAutogenType { LOT_SOUNDSTATE, LOT_SPAWNINFO, LOT_SPAWNPARTICLESINFO, + LOT_STARPOSITIONS, LOT_STRUCT802A272C, LOT_SURFACE, LOT_TEXTUREINFO,