Add support for custom cap sequences. (#250)

This commit is contained in:
Prince Frizzy 2023-01-31 05:55:18 -05:00 committed by GitHub
parent d5a19a4d90
commit 46b2e24052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 6 deletions

View File

@ -640,14 +640,17 @@
--- @field public floorLowerLimitShadow integer
--- @field public metalCapDuration integer
--- @field public metalCapDurationCotmc integer
--- @field public metalCapSequence integer
--- @field public pssSlideStarIndex integer
--- @field public pssSlideStarTime integer
--- @field public skipCreditsAt LevelNum
--- @field public starPositions StarPositions
--- @field public vanishCapDuration integer
--- @field public vanishCapDurationVcutm integer
--- @field public vanishCapSequence integer
--- @field public wingCapDuration integer
--- @field public wingCapDurationTotwc integer
--- @field public wingCapSequence integer
--- @class LinearTransitionPoint
--- @field public dist number
@ -748,6 +751,7 @@
--- @field public unkC4 number
--- @field public usedObj Object
--- @field public vel Vec3f
--- @field public visibleToEnemies integer
--- @field public wall Surface
--- @field public wallKickTimer integer
--- @field public wallNormal Vec3f

View File

@ -935,14 +935,17 @@
| floorLowerLimitShadow | `integer` | |
| metalCapDuration | `integer` | |
| metalCapDurationCotmc | `integer` | |
| metalCapSequence | `integer` | |
| pssSlideStarIndex | `integer` | |
| pssSlideStarTime | `integer` | |
| skipCreditsAt | [enum LevelNum](constants.md#enum-LevelNum) | |
| starPositions | [StarPositions](structs.md#StarPositions) | read-only |
| vanishCapDuration | `integer` | |
| vanishCapDurationVcutm | `integer` | |
| vanishCapSequence | `integer` | |
| wingCapDuration | `integer` | |
| wingCapDurationTotwc | `integer` | |
| wingCapSequence | `integer` | |
[:arrow_up_small:](#)
@ -1071,6 +1074,7 @@
| unkC4 | `number` | |
| usedObj | [Object](structs.md#Object) | |
| vel | [Vec3f](structs.md#Vec3f) | read-only |
| visibleToEnemies | `integer` | |
| wall | [Surface](structs.md#Surface) | |
| wallKickTimer | `integer` | |
| wallNormal | [Vec3f](structs.md#Vec3f) | read-only |

View File

@ -58,6 +58,9 @@ struct LevelValues gDefaultLevelValues = {
.wingCapDurationTotwc = 1200,
.metalCapDurationCotmc = 600,
.vanishCapDurationVcutm = 600,
.wingCapSequence = SEQ_EVENT_POWERUP,
.metalCapSequence = SEQ_EVENT_METAL_CAP,
.vanishCapSequence = SEQ_EVENT_POWERUP,
.starPositions = {
.KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f },
.KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f },

View File

@ -1,7 +1,8 @@
#ifndef HARDCODED_H
#include "types.h"
#include "level_table.h"
#include "dialog_ids.h"
#include "dialog_ids.h"
#include "seq_ids.h"
////////////
// Levels //
@ -53,6 +54,9 @@ struct LevelValues {
u16 wingCapDurationTotwc;
u16 metalCapDurationCotmc;
u16 vanishCapDurationVcutm;
u8 wingCapSequence;
u8 metalCapSequence;
u8 vanishCapSequence;
struct StarPositions starPositions;
s16 cellHeightLimit;
s16 floorLowerLimit;

View File

@ -1986,17 +1986,17 @@ u32 interact_cap(struct MarioState *m, UNUSED u32 interactType, struct Object *o
switch (capFlag) {
case MARIO_VANISH_CAP:
capTime = gLevelValues.vanishCapDuration;
capMusic = SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP);
capMusic = SEQUENCE_ARGS(4, gLevelValues.vanishCapSequence);
break;
case MARIO_METAL_CAP:
capTime = gLevelValues.metalCapDuration;
capMusic = SEQUENCE_ARGS(4, SEQ_EVENT_METAL_CAP);
capMusic = SEQUENCE_ARGS(4, gLevelValues.metalCapSequence);
break;
case MARIO_WING_CAP:
capTime = gLevelValues.wingCapDuration;
capMusic = SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP);
capMusic = SEQUENCE_ARGS(4, gLevelValues.wingCapSequence);
break;
}

View File

@ -726,7 +726,7 @@ 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 21
#define LUA_LEVEL_VALUES_FIELD_COUNT 24
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE },
{ "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE },
@ -741,14 +741,17 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] =
{ "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE },
{ "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE },
{ "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE },
{ "metalCapSequence", LVT_U8, offsetof(struct LevelValues, metalCapSequence), false, LOT_NONE },
{ "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE },
{ "pssSlideStarTime", LVT_U16, offsetof(struct LevelValues, pssSlideStarTime), false, LOT_NONE },
{ "skipCreditsAt", LVT_S32, offsetof(struct LevelValues, skipCreditsAt), false, LOT_NONE },
{ "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS },
{ "vanishCapDuration", LVT_U16, offsetof(struct LevelValues, vanishCapDuration), false, LOT_NONE },
{ "vanishCapDurationVcutm", LVT_U16, offsetof(struct LevelValues, vanishCapDurationVcutm), false, LOT_NONE },
{ "vanishCapSequence", LVT_U8, offsetof(struct LevelValues, vanishCapSequence), false, LOT_NONE },
{ "wingCapDuration", LVT_U16, offsetof(struct LevelValues, wingCapDuration), false, LOT_NONE },
{ "wingCapDurationTotwc", LVT_U16, offsetof(struct LevelValues, wingCapDurationTotwc), false, LOT_NONE },
{ "wingCapSequence", LVT_U8, offsetof(struct LevelValues, wingCapSequence), false, LOT_NONE },
};
#define LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT 5
@ -787,7 +790,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO
{ "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE },
};
#define LUA_MARIO_STATE_FIELD_COUNT 76
#define LUA_MARIO_STATE_FIELD_COUNT 77
static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
{ "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE },
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE },
@ -860,6 +863,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
{ "unkC4", LVT_F32, offsetof(struct MarioState, unkC4), false, LOT_NONE },
{ "usedObj", LVT_COBJECT_P, offsetof(struct MarioState, usedObj), false, LOT_OBJECT },
{ "vel", LVT_COBJECT, offsetof(struct MarioState, vel), true, LOT_VEC3F },
{ "visibleToEnemies", LVT_U8, offsetof(struct MarioState, visibleToEnemies), false, LOT_NONE },
{ "wall", LVT_COBJECT_P, offsetof(struct MarioState, wall), false, LOT_SURFACE },
{ "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer), false, LOT_NONE },
{ "wallNormal", LVT_COBJECT, offsetof(struct MarioState, wallNormal), true, LOT_VEC3F },

View File

@ -10,6 +10,7 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n"
" end\n"
"}\n"
"\n"
"_CPointer = {\n"
" __index = function (t,k)\n"
" return nil\n"
@ -23,6 +24,7 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n"
" end\n"
"}\n"
"\n"
"_SyncTable = {\n"
" __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n"
@ -34,6 +36,7 @@ char gSmluaConstants[] = ""
" _set_sync_table_field(t, k, v)\n"
" end\n"
"}\n"
"\n"
"_ReadOnlyTable = {\n"
" __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n"
@ -42,6 +45,7 @@ char gSmluaConstants[] = ""
" __newindex = function (t,k,v)\n"
" end\n"
"}\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param src Vec3f\n"
"--- @return Vec3f\n"
@ -51,6 +55,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param x number\n"
"--- @param y number\n"
@ -62,6 +67,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a Vec3f\n"
"--- @return Vec3f\n"
@ -71,6 +77,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a Vec3f\n"
"--- @param b Vec3f\n"
@ -81,6 +88,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a number\n"
"--- @return Vec3f\n"
@ -90,6 +98,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @return Vec3f\n"
"function vec3f_normalize(dest)\n"
@ -97,23 +106,28 @@ char gSmluaConstants[] = ""
" if divisor == 0 then\n"
" return dest\n"
" end\n"
"\n"
" local invsqrt = 1.0 / divisor\n"
" dest.x = dest.x * invsqrt\n"
" dest.y = dest.y * invsqrt\n"
" dest.z = dest.z * invsqrt\n"
"\n"
" return dest\n"
"end\n"
"\n"
"--- @param a Vec3f\n"
"--- @return number\n"
"function vec3f_length(a)\n"
" return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n"
"end\n"
"\n"
"--- @param a Vec3f\n"
"--- @param b Vec3f\n"
"--- @return number\n"
"function vec3f_dot(a, b)\n"
" return a.x * b.x + a.y * b.y + a.z * b.z\n"
"end\n"
"\n"
"--- @param vec Vec3f\n"
"--- @param onto Vec3f\n"
"--- @return Vec3f\n"
@ -125,6 +139,7 @@ char gSmluaConstants[] = ""
" vec3f_mul(out, numerator / denominator)\n"
" return out\n"
"end\n"
"\n"
"--- @param v1 Vec3f\n"
"--- @param v2 Vec3f\n"
"--- @return number\n"
@ -134,6 +149,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param src Vec3s\n"
"--- @return Vec3s\n"
@ -143,6 +159,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param x number\n"
"--- @param y number\n"
@ -154,6 +171,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a Vec3s\n"
"--- @return Vec3s\n"
@ -163,6 +181,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a Vec3s\n"
"--- @param b Vec3s\n"
@ -173,6 +192,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a number\n"
"--- @return Vec3s\n"
@ -182,6 +202,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n"
" return dest\n"
"end\n"
"\n"
"--- @param v1 Vec3s\n"
"--- @param v2 Vec3s\n"
"--- @return number\n"
@ -191,6 +212,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n"
"\n"
"--- @param current number\n"
"--- @param target number\n"
"--- @param inc number\n"
@ -210,6 +232,7 @@ char gSmluaConstants[] = ""
" end\n"
" return current;\n"
"end\n"
"\n"
"--- @param current number\n"
"--- @param target number\n"
"--- @param inc number\n"
@ -227,6 +250,7 @@ char gSmluaConstants[] = ""
" current = target\n"
" end\n"
" end\n"
"\n"
" -- keep within 32 bits\n"
" if current > 2147483647 then\n"
" current = -2147483648 + (current - 2147483647)\n"
@ -235,6 +259,7 @@ char gSmluaConstants[] = ""
" end\n"
" return current;\n"
"end\n"
"\n"
"--- @param bank number\n"
"--- @param soundID number\n"
"--- @param priority number\n"
@ -244,9 +269,11 @@ char gSmluaConstants[] = ""
" if flags == nil then flags = 0 end\n"
" return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n"
"end\n"
"\n"
"-------------\n"
"-- courses --\n"
"-------------\n"
"\n"
"--- @type integer\n"
"COURSE_NONE = 0\n"
"--- @type integer\n"