From 958b04378ceb0b015317920aaeffba9e794e9dcf Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 10 Apr 2022 02:29:44 -0700 Subject: [PATCH] Add exit castle warp params to Lua --- autogen/lua_definitions/structs.lua | 3 +++ docs/lua/structs.md | 3 +++ src/game/hardcoded.c | 3 +++ src/game/hardcoded.h | 3 +++ src/game/level_update.c | 2 +- src/pc/lua/smlua_cobject_autogen.c | 9 ++++++--- src/pc/mods/mod.c | 6 +++--- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 1b1e449e..010a7f64 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -572,6 +572,9 @@ --- @class LevelValues --- @field public entryLevel LevelNum +--- @field public exitCastleArea integer +--- @field public exitCastleLevel LevelNum +--- @field public exitCastleWarpNode integer --- @field public starPositions StarPositions --- @class LinearTransitionPoint diff --git a/docs/lua/structs.md b/docs/lua/structs.md index a06c85c9..796b371a 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -834,6 +834,9 @@ | Field | Type | Access | | ----- | ---- | ------ | | entryLevel | [enum LevelNum](constants.md#enum-LevelNum) | | +| exitCastleArea | `integer` | | +| exitCastleLevel | [enum LevelNum](constants.md#enum-LevelNum) | | +| exitCastleWarpNode | `integer` | | | starPositions | [StarPositions](structs.md#StarPositions) | read-only | [:arrow_up_small:](#) diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 3f530ea4..e41510bb 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -39,6 +39,9 @@ struct LevelValues gLevelValues = { .entryLevel = LEVEL_CASTLE_GROUNDS, + .exitCastleLevel = LEVEL_CASTLE, + .exitCastleArea = 1, + .exitCastleWarpNode = 0x1F, .starPositions = { .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 2693cc87..3a29cf2e 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -38,6 +38,9 @@ struct StarPositions { struct LevelValues { enum LevelNum entryLevel; + enum LevelNum exitCastleLevel; + s16 exitCastleArea; + u8 exitCastleWarpNode; struct StarPositions starPositions; }; diff --git a/src/game/level_update.c b/src/game/level_update.c index 2b25f9d8..84e07148 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1167,7 +1167,7 @@ s32 play_mode_paused(void) { if (gDebugLevelSelect) { fade_into_special_warp(-9, 1); } else { - initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); + initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0); fade_into_special_warp(0, 0); gSavedCourseNum = COURSE_NONE; } diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index f8c1d94f..57e03cff 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -666,10 +666,13 @@ 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 2 +#define LUA_LEVEL_VALUES_FIELD_COUNT 5 static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { - { "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE }, - { "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS }, + { "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE }, + { "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE }, + { "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE }, + { "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE }, + { "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS }, }; #define LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT 5 diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index 888731f2..1af16c45 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -30,8 +30,8 @@ static void mod_activate_bin(struct Mod* mod, struct ModFile* file) { } // Add to custom actors - dynos_add_actor_custom(dynosPath, geoName); LOG_INFO("Activating DynOS bin: '%s', '%s'", dynosPath, geoName); + dynos_add_actor_custom(dynosPath, geoName); } static void mod_activate_col(struct Mod* mod, struct ModFile* file) { @@ -59,8 +59,8 @@ static void mod_activate_col(struct Mod* mod, struct ModFile* file) { } // Add to custom actors - dynos_add_collision(dynosPath, colName); LOG_INFO("Activating DynOS col: '%s', '%s'", dynosPath, colName); + dynos_add_collision(dynosPath, colName); } static void mod_activate_lvl(struct Mod* mod, struct ModFile* file) { @@ -88,8 +88,8 @@ static void mod_activate_lvl(struct Mod* mod, struct ModFile* file) { } // Add to levels - dynos_add_level(mod->index, dynosPath, lvlName); LOG_INFO("Activating DynOS lvl: '%s', '%s'", dynosPath, lvlName); + dynos_add_level(mod->index, dynosPath, lvlName); } void mod_activate(struct Mod* mod) {