Refactored StarPositions

This commit is contained in:
MysterD 2022-04-08 19:46:01 -07:00
parent 41e8b80f97
commit 72584d5552
28 changed files with 67 additions and 80 deletions

View file

@ -28,9 +28,6 @@ gGlobalSyncTable = {}
--- @type SyncTable[]
gPlayerSyncTable = {}
--- @type StarPositions
gStarPositions = {}
--- @type LevelValues
gLevelValues = {}

View file

@ -442,6 +442,7 @@
--- @class LevelValues
--- @field public entryLevel LevelNum
--- @field public starPositions StarPositions
--- @class LinearTransitionPoint
--- @field public dist number

View file

@ -58,13 +58,6 @@ The `gGlobalObjectCollisionData` table contains references to object collision d
<br />
## [gStarPositions](#gLakituState)
`gStarPositions`'s fields are listed in [StarPosition](structs.md#StarPosition). These are where stars will spawn for certain stars.
[:arrow_up_small:](#)
<br />
## [gLevelValues](#gLevelValues)
`gLevelValues`'s fields are listed in [LevelValue](structs.md#LevelValue).

View file

@ -680,6 +680,7 @@
| Field | Type | Access |
| ----- | ---- | ------ |
| entryLevel | [enum LevelNum](constants.md#enum-LevelNum) | |
| starPositions | [StarPositions](structs.md#StarPositions) | read-only |
[:arrow_up_small:](#)

View file

@ -654,19 +654,19 @@ static void big_boo_act_2(void) {
}
static void big_boo_spawn_ghost_hunt_star(void) {
f32* starPos = gStarPositions.GhostHuntBooStarPos;
f32* starPos = gLevelValues.starPositions.GhostHuntBooStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
}
static void big_boo_spawn_balcony_star(void) {
f32* starPos = gStarPositions.BalconyBooStarPos;
f32* starPos = gLevelValues.starPositions.BalconyBooStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
}
static void big_boo_spawn_merry_go_round_star(void) {
struct Object *merryGoRound;
f32* starPos = gStarPositions.MerryGoRoundStarPos;
f32* starPos = gLevelValues.starPositions.MerryGoRoundStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
merryGoRound = cur_obj_nearest_object_with_behavior(bhvMerryGoRound);

View file

@ -245,10 +245,10 @@ void bully_act_level_death(void) {
spawn_mist_particles();
if (o->oBullySubtype == BULLY_STYPE_CHILL) {
f32* starPos = gStarPositions.ChillBullyStarPos;
f32* starPos = gLevelValues.starPositions.ChillBullyStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
} else {
f32* starPos = gStarPositions.BigBullyTrioStarPos;
f32* starPos = gLevelValues.starPositions.BigBullyTrioStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
struct Object* lllTumblingBridge = cur_obj_nearest_object_with_behavior(bhvLllTumblingBridge);
if (lllTumblingBridge != NULL) {
@ -340,7 +340,7 @@ void bhv_big_bully_with_minions_init(void) {
void big_bully_spawn_star(void) {
if (obj_lava_death() == 1) {
spawn_mist_particles();
f32* starPos = gStarPositions.BigBullyStarPos;
f32* starPos = gLevelValues.starPositions.BigBullyStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
}
}

View file

@ -187,7 +187,7 @@ 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)) {
f32* starPos = gStarPositions.EyerockStarPos;
f32* starPos = gLevelValues.starPositions.EyerockStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
} else {
o->oTimer -= 1;
@ -198,7 +198,7 @@ static void eyerok_boss_act_die(void) {
}*/
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
if (network_owns_object(o)) {
f32* starPos = gStarPositions.EyerockStarPos;
f32* starPos = gLevelValues.starPositions.EyerockStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
network_send_object_reliability(o, TRUE);
}

View file

@ -74,7 +74,7 @@ static void fire_piranha_plant_act_hide(void) {
if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) {
if (++sNumKilledFirePiranhaPlants == 5) {
f32* starPos = gStarPositions.BigPiranhasStarPos;
f32* starPos = gLevelValues.starPositions.BigPiranhasStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
network_send_object(o);
}

View file

@ -241,13 +241,13 @@ void king_bobomb_act_8(void) {
f32 objectPosY = o->oPosY;
o->oPosY += 200.0f + gDebugInfo[5][0];
f32* starPos = gStarPositions.KingBobombStarPos;
f32* starPos = gLevelValues.starPositions.KingBobombStarPos;
star = spawn_default_star(starPos[0], starPos[1], starPos[2]);
o->oPosY = objectPosY;
#else
o->oPosY += 100.0f;
f32* starPos = gStarPositions.KingBobombStarPos;
f32* starPos = gLevelValues.starPositions.KingBobombStarPos;
star = spawn_default_star(starPos[0], starPos[1], starPos[2]);
#endif
// If we're not the closet to King-Bombomb,

View file

@ -427,7 +427,7 @@ void bhv_klepto_update(void) {
}
} else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR) {
f32* starPos = gStarPositions.KleptoStarPos;
f32* starPos = gLevelValues.starPositions.KleptoStarPos;
struct Object* star = spawn_default_star(starPos[0], starPos[1], starPos[2]);
// If we're not the closet to Klepto,

View file

@ -868,10 +868,10 @@ static void koopa_the_quick_act_after_race(void) {
}
} else if (o->parentObj->oKoopaRaceEndpointRaceStatus != 0) {
if (o->oKoopaTheQuickRaceIndex == 0) {
f32* starPos = gStarPositions.KoopaBobStarPos;
f32* starPos = gLevelValues.starPositions.KoopaBobStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
} else {
f32* starPos = gStarPositions.KoopaThiStarPos;
f32* starPos = gLevelValues.starPositions.KoopaThiStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
}

View file

@ -133,7 +133,7 @@ void bhv_manta_ray_loop(void) {
// Spawn a star after collecting 5 rings.
if (o->oWaterRingSpawnerRingsCollected == 5) {
spawn_mist_particles();
f32* starPos = gStarPositions.MantaRayStarPos;
f32* starPos = gLevelValues.starPositions.MantaRayStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
o->oAction = MANTA_ACT_NO_RINGS;
}

View file

@ -116,7 +116,7 @@ void mr_i_act_3(void) {
o->oMrISize = sp1C * 0.6;
if (o->oBehParams2ndByte) {
o->oPosY += 100.0f;
f32* starPos = gStarPositions.MrIStarPos;
f32* starPos = gLevelValues.starPositions.MrIStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
obj_mark_for_deletion(o);
} else

View file

@ -252,7 +252,7 @@ static void racing_penguin_act_show_final_text(void) {
}
} else if (o->oRacingPenguinMarioWon) {
f32* starPos = gStarPositions.RacingPenguinStarPos;
f32* starPos = gLevelValues.starPositions.RacingPenguinStarPos;
#ifdef VERSION_JP
spawn_default_star(starPos[0], starPos[1], starPos[2]);
#else

View file

@ -243,7 +243,7 @@ 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();
f32* starPos = gStarPositions.SnowmanHeadStarPos;
f32* starPos = gLevelValues.starPositions.SnowmanHeadStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
o->oAction = 1;
network_send_object(o);

View file

@ -5,7 +5,7 @@ void bhv_ccm_touched_star_spawn_loop(void) {
o->oPosY += 100.0f;
o->oPosX = 2780.0f;
o->oPosZ = 4666.0f;
f32* starPos = gStarPositions.CcmSlideStarPos;
f32* starPos = gLevelValues.starPositions.CcmSlideStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
obj_mark_for_deletion(o);
}

View file

@ -255,7 +255,7 @@ void bhv_treasure_chest_jrb_loop(void) {
if (o->oTimer == 60) {
spawn_mist_particles();
f32* starPos = gStarPositions.TreasureJrbStarPos;
f32* starPos = gLevelValues.starPositions.TreasureJrbStarPos;
spawn_networked_default_star(starPos[0], starPos[1], starPos[2], o->oTreasureChestLastNetworkPlayerIndex);
o->oAction = 2;
@ -323,7 +323,7 @@ void bhv_treasure_chest_loop(void) {
if (o->oTimer == 60) {
spawn_mist_particles();
f32* starPos = gStarPositions.TreasureJrbStarPos;
f32* starPos = gLevelValues.starPositions.TreasureJrbStarPos;
spawn_networked_default_star(starPos[0], starPos[1], starPos[2], o->oTreasureChestLastNetworkPlayerIndex);
o->oAction = 2;

View file

@ -85,7 +85,7 @@ void tuxies_mother_act_1(void) {
o->prevObj->OBJECT_FIELD_S32(o->oInteractionSubtype) &= ~INT_SUBTYPE_DROP_IMMEDIATELY;
obj_set_behavior(o->prevObj, bhvUnused20E0);
f32* starPos = gStarPositions.TuxieMotherStarPos;
f32* starPos = gLevelValues.starPositions.TuxieMotherStarPos;
#ifndef VERSION_JP
cur_obj_spawn_star_at_y_offset(starPos[0], starPos[1], starPos[2], 200.0f);
#else

View file

@ -37,7 +37,7 @@ void bhv_ukiki_cage_star_loop(void) {
obj_mark_for_deletion(o);
spawn_mist_particles();
spawn_triangle_break_particles(20, 138, 0.7, 3);
f32* starPos = gStarPositions.UkikiCageStarPos;
f32* starPos = gLevelValues.starPositions.UkikiCageStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
break;
}

View file

@ -215,7 +215,7 @@ void bhv_unagi_subobject_loop(void) {
if (o->oBehParams2ndByte == -4) {
if (o->parentObj->oAnimState != 0 && distanceToPlayer < 150.0f) {
o->oBehParams = o->parentObj->oBehParams;
f32* starPos = gStarPositions.UnagiStarPos;
f32* starPos = gLevelValues.starPositions.UnagiStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
o->parentObj->oAnimState = 0;
}

View file

@ -194,7 +194,7 @@ void bhv_jet_stream_ring_spawner_loop(void) {
if (o->oWaterRingSpawnerRingsCollected == 5) {
spawn_mist_particles();
f32* starPos = gStarPositions.JetstreamRingStarPos;
f32* starPos = gLevelValues.starPositions.JetstreamRingStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
o->oAction = JS_RING_SPAWNER_ACT_INACTIVE;

View file

@ -242,7 +242,7 @@ void whomp_act_8(void) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
o->oPosY += 100.0f;
f32* starPos = gStarPositions.KingWhompStarPos;
f32* starPos = gLevelValues.starPositions.KingWhompStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
cur_obj_play_sound_2(SOUND_OBJ_KING_WHOMP_DEATH);

View file

@ -366,7 +366,7 @@ 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)) {
f32* starPos = gStarPositions.WigglerStarPos;
f32* starPos = gLevelValues.starPositions.WigglerStarPos;
struct Object *star = spawn_default_star(starPos[0], starPos[1], starPos[2]);
// If we're not the closet to Wiggler,

View file

@ -2,37 +2,36 @@
struct LevelValues gLevelValues = {
.entryLevel = LEVEL_CASTLE_GROUNDS,
};
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 = { 3700.0f, 600.0f, -5500.0f },
.ChillBullyStarPos = { 130.0f, 1600.0f, -4335.0f },
.BigPiranhasStarPos = { -6300.0f, -1850.0f, -6300.0f },
.starPositions = {
.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 = { 3700.0f, 600.0f, -5500.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 },
.TuxieMotherStarPos = { 3500.0f, -4300.0f, 4650.0f },
#else
.TuxieMotherStarPos = { 3167.0f, -4300.0f, 5108.0f },
.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 = { 0.0f, 950.0f, -6800.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 },
.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 = { 0.0f, 950.0f, -6800.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 },
},
};

View file

@ -2,10 +2,6 @@
#include "types.h"
#include "level_table.h"
struct LevelValues {
enum LevelNum entryLevel;
};
struct StarPositions {
Vec3f KoopaBobStarPos;
Vec3f KoopaThiStarPos;
@ -35,7 +31,11 @@ struct StarPositions {
Vec3f JetstreamRingStarPos;
};
struct LevelValues {
enum LevelNum entryLevel;
struct StarPositions starPositions;
};
extern struct LevelValues gLevelValues;
extern struct StarPositions gStarPositions;
#endif

View file

@ -2245,7 +2245,7 @@ void pss_end_slide(struct MarioState *m) {
// PSS secret star uses oBehParams to spawn
s32 tmp = m->marioObj->oBehParams;
m->marioObj->oBehParams = (1 << 24);
f32* starPos = gStarPositions.PssSlideStarPos;
f32* starPos = gLevelValues.starPositions.PssSlideStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
m->marioObj->oBehParams = tmp;
}

View file

@ -566,11 +566,6 @@ void smlua_cobject_init_globals(void) {
lua_setglobal(L, "gServerSettings");
}
{
smlua_push_object(L, LOT_STARPOSITIONS, &gStarPositions);
lua_setglobal(L, "gStarPositions");
}
{
smlua_push_object(L, LOT_LEVELVALUES, &gLevelValues);
lua_setglobal(L, "gLevelValues");

View file

@ -530,9 +530,10 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] =
{ "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
};
#define LUA_LEVEL_VALUES_FIELD_COUNT 1
#define LUA_LEVEL_VALUES_FIELD_COUNT 2
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE },
{ "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE },
{ "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS },
};
#define LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT 5