Add lifeCap, coinCap and coinToLife to gLevelValues (#429)

* Add lifeCap, coinCap and coinToLife to gLevelValues

* autogen

* forgor

* renamed the properties
This commit is contained in:
Dominicentek 2023-07-04 23:16:07 +02:00 committed by GitHub
parent 4210312a6a
commit 809cbc314b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 11 deletions

View file

@ -663,10 +663,13 @@
--- @field public hudCapTimer integer --- @field public hudCapTimer integer
--- @field public hudRedCoinsRadar integer --- @field public hudRedCoinsRadar integer
--- @field public hudSecretsRadar integer --- @field public hudSecretsRadar integer
--- @field public maxCoins integer
--- @field public maxLives integer
--- @field public metalCapDuration integer --- @field public metalCapDuration integer
--- @field public metalCapDurationCotmc integer --- @field public metalCapDurationCotmc integer
--- @field public metalCapSequence integer --- @field public metalCapSequence integer
--- @field public mushroom1UpHeal integer --- @field public mushroom1UpHeal integer
--- @field public numCoinsToLife integer
--- @field public pauseExitAnywhere boolean --- @field public pauseExitAnywhere boolean
--- @field public previewBlueCoins integer --- @field public previewBlueCoins integer
--- @field public pssSlideStarIndex integer --- @field public pssSlideStarIndex integer

View file

@ -969,10 +969,13 @@
| hudCapTimer | `integer` | | | hudCapTimer | `integer` | |
| hudRedCoinsRadar | `integer` | | | hudRedCoinsRadar | `integer` | |
| hudSecretsRadar | `integer` | | | hudSecretsRadar | `integer` | |
| maxCoins | `integer` | |
| maxLives | `integer` | |
| metalCapDuration | `integer` | | | metalCapDuration | `integer` | |
| metalCapDurationCotmc | `integer` | | | metalCapDurationCotmc | `integer` | |
| metalCapSequence | `integer` | | | metalCapSequence | `integer` | |
| mushroom1UpHeal | `integer` | | | mushroom1UpHeal | `integer` | |
| numCoinsToLife | `integer` | |
| pauseExitAnywhere | `boolean` | | | pauseExitAnywhere | `boolean` | |
| previewBlueCoins | `integer` | | | previewBlueCoins | `integer` | |
| pssSlideStarIndex | `integer` | | | pssSlideStarIndex | `integer` | |

View file

@ -115,6 +115,9 @@ struct LevelValues gDefaultLevelValues = {
.pauseExitAnywhere = 1, .pauseExitAnywhere = 1,
.disableActs = false, .disableActs = false,
.wingCapLookUpReq = 10, .wingCapLookUpReq = 10,
.maxLives = 100,
.maxCoins = 999,
.numCoinsToLife = 50
}; };
struct LevelValues gLevelValues = { 0 }; struct LevelValues gLevelValues = { 0 };

View file

@ -82,6 +82,9 @@ struct LevelValues {
s16 floorLowerLimitShadow; s16 floorLowerLimitShadow;
bool pauseExitAnywhere; bool pauseExitAnywhere;
bool disableActs; bool disableActs;
u16 maxLives;
u16 maxCoins;
u16 numCoinsToLife;
}; };
extern struct LevelValues gLevelValues; extern struct LevelValues gLevelValues;

View file

@ -3316,7 +3316,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
gCourseCompleteCoins++; gCourseCompleteCoins++;
play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource); play_sound(SOUND_MENU_YOSHI_GAIN_LIVES, gGlobalSoundSource);
if (gCourseCompleteCoins == 50 || gCourseCompleteCoins == 100 || gCourseCompleteCoins == 150) { if (gCourseCompleteCoins % gLevelValues.numCoinsToLife == 0 && gCourseCompleteCoins > 0) {
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
gMarioStates[0].numLives++; gMarioStates[0].numLives++;
} }

View file

@ -1071,28 +1071,28 @@ void update_hud_values(void) {
gHudDisplay.coins += 1; gHudDisplay.coins += 1;
play_sound(coinSound, gMarioState->marioObj->header.gfx.cameraToObject); play_sound(coinSound, gMarioState->marioObj->header.gfx.cameraToObject);
if (gServerSettings.stayInLevelAfterStar > 0 && gCurrCourseNum != COURSE_NONE && (gHudDisplay.coins == 50 || gHudDisplay.coins == 100 || gHudDisplay.coins == 150)) { if (gServerSettings.stayInLevelAfterStar > 0 && gCurrCourseNum != COURSE_NONE && (gHudDisplay.coins % gLevelValues.numCoinsToLife == 0 && gHudDisplay.coins > 0)) {
gMarioState->numLives++; gMarioState->numLives++;
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
} }
} }
} }
if (gMarioState->numLives > 100) { if (gMarioState->numLives > gLevelValues.maxLives) {
gMarioState->numLives = 100; gMarioState->numLives = gLevelValues.maxLives;
} }
#if BUGFIX_MAX_LIVES #if BUGFIX_MAX_LIVES
if (gMarioState->numCoins > 999) { if (gMarioState->numCoins > gLevelValues.maxCoins) {
gMarioState->numCoins = 999; gMarioState->numCoins = gLevelValues.maxCoins;
} }
if (gHudDisplay.coins > 999) { if (gHudDisplay.coins > gLevelValues.maxCoins) {
gHudDisplay.coins = 999; gHudDisplay.coins = gLevelValues.maxCoins;
} }
#else #else
if (gMarioState->numCoins > 999) { if (gMarioState->numCoins > gLevelValues.maxCoins) {
gMarioState->numCoins = (s16) 999; gMarioState->numCoins = (s16) gLevelValues.maxCoins;
} }
#endif #endif

View file

@ -743,7 +743,7 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] =
{ "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
}; };
#define LUA_LEVEL_VALUES_FIELD_COUNT 42 #define LUA_LEVEL_VALUES_FIELD_COUNT 45
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE },
{ "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE }, { "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE },
@ -766,10 +766,13 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] =
{ "hudCapTimer", LVT_U8, offsetof(struct LevelValues, hudCapTimer), false, LOT_NONE }, { "hudCapTimer", LVT_U8, offsetof(struct LevelValues, hudCapTimer), false, LOT_NONE },
{ "hudRedCoinsRadar", LVT_U8, offsetof(struct LevelValues, hudRedCoinsRadar), false, LOT_NONE }, { "hudRedCoinsRadar", LVT_U8, offsetof(struct LevelValues, hudRedCoinsRadar), false, LOT_NONE },
{ "hudSecretsRadar", LVT_U8, offsetof(struct LevelValues, hudSecretsRadar), false, LOT_NONE }, { "hudSecretsRadar", LVT_U8, offsetof(struct LevelValues, hudSecretsRadar), false, LOT_NONE },
{ "maxCoins", LVT_U16, offsetof(struct LevelValues, maxCoins), false, LOT_NONE },
{ "maxLives", LVT_U16, offsetof(struct LevelValues, maxLives), false, LOT_NONE },
{ "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE }, { "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE },
{ "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE }, { "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE },
{ "metalCapSequence", LVT_U8, offsetof(struct LevelValues, metalCapSequence), false, LOT_NONE }, { "metalCapSequence", LVT_U8, offsetof(struct LevelValues, metalCapSequence), false, LOT_NONE },
{ "mushroom1UpHeal", LVT_U8, offsetof(struct LevelValues, mushroom1UpHeal), false, LOT_NONE }, { "mushroom1UpHeal", LVT_U8, offsetof(struct LevelValues, mushroom1UpHeal), false, LOT_NONE },
{ "numCoinsToLife", LVT_U16, offsetof(struct LevelValues, numCoinsToLife), false, LOT_NONE },
{ "pauseExitAnywhere", LVT_BOOL, offsetof(struct LevelValues, pauseExitAnywhere), false, LOT_NONE }, { "pauseExitAnywhere", LVT_BOOL, offsetof(struct LevelValues, pauseExitAnywhere), false, LOT_NONE },
{ "previewBlueCoins", LVT_U8, offsetof(struct LevelValues, previewBlueCoins), false, LOT_NONE }, { "previewBlueCoins", LVT_U8, offsetof(struct LevelValues, previewBlueCoins), false, LOT_NONE },
{ "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE }, { "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE },

View file

@ -1,6 +1,8 @@
char gSmluaConstants[] = "" char gSmluaConstants[] = ""
"math.randomseed(get_time())\n" "math.randomseed(get_time())\n"
"\n"
"_CObjectPool = {}\n" "_CObjectPool = {}\n"
"\n"
"_CObject = {\n" "_CObject = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" return _get_field(t['_lot'], t['_pointer'], k, t)\n" " return _get_field(t['_lot'], t['_pointer'], k, t)\n"
@ -15,10 +17,12 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n" " return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"function _NewCObject(lot, pointer)\n" "function _NewCObject(lot, pointer)\n"
" if _CObjectPool[lot] == nil then\n" " if _CObjectPool[lot] == nil then\n"
" _CObjectPool[lot] = {}\n" " _CObjectPool[lot] = {}\n"
" end\n" " end\n"
"\n"
" if _CObjectPool[lot][pointer] == nil then\n" " if _CObjectPool[lot][pointer] == nil then\n"
" local obj = {}\n" " local obj = {}\n"
" rawset(obj, '_pointer', pointer)\n" " rawset(obj, '_pointer', pointer)\n"
@ -27,9 +31,12 @@ char gSmluaConstants[] = ""
" _CObjectPool[lot][pointer] = obj\n" " _CObjectPool[lot][pointer] = obj\n"
" return obj\n" " return obj\n"
" end\n" " end\n"
"\n"
" return _CObjectPool[lot][pointer]\n" " return _CObjectPool[lot][pointer]\n"
"end\n" "end\n"
"\n"
"local _CPointerPool = {}\n" "local _CPointerPool = {}\n"
"\n"
"_CPointer = {\n" "_CPointer = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" return nil\n" " return nil\n"
@ -43,10 +50,12 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n" " return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"function _NewCPointer(lvt, pointer)\n" "function _NewCPointer(lvt, pointer)\n"
" if _CPointerPool[lvt] == nil then\n" " if _CPointerPool[lvt] == nil then\n"
" _CPointerPool[lvt] = {}\n" " _CPointerPool[lvt] = {}\n"
" end\n" " end\n"
"\n"
" if _CPointerPool[lvt][pointer] == nil then\n" " if _CPointerPool[lvt][pointer] == nil then\n"
" local obj = {}\n" " local obj = {}\n"
" rawset(obj, '_pointer', pointer)\n" " rawset(obj, '_pointer', pointer)\n"
@ -55,8 +64,10 @@ char gSmluaConstants[] = ""
" _CPointerPool[lvt][pointer] = obj\n" " _CPointerPool[lvt][pointer] = obj\n"
" return obj\n" " return obj\n"
" end\n" " end\n"
"\n"
" return _CPointerPool[lvt][pointer]\n" " return _CPointerPool[lvt][pointer]\n"
"end\n" "end\n"
"\n"
"_SyncTable = {\n" "_SyncTable = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n" " local _table = rawget(t, '_table')\n"
@ -68,6 +79,7 @@ char gSmluaConstants[] = ""
" _set_sync_table_field(t, k, v)\n" " _set_sync_table_field(t, k, v)\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"_ReadOnlyTable = {\n" "_ReadOnlyTable = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n" " local _table = rawget(t, '_table')\n"
@ -76,6 +88,7 @@ char gSmluaConstants[] = ""
" __newindex = function (t,k,v)\n" " __newindex = function (t,k,v)\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param src Vec3f\n" "--- @param src Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -85,6 +98,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n" " dest.z = src.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param x number\n" "--- @param x number\n"
"--- @param y number\n" "--- @param y number\n"
@ -96,6 +110,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n" " dest.z = z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -105,6 +120,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n" " dest.z = dest.z + a.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @param b Vec3f\n" "--- @param b Vec3f\n"
@ -115,6 +131,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n" " dest.z = a.z + b.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a number\n" "--- @param a number\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -124,6 +141,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n" " dest.z = dest.z * a\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
"function vec3f_normalize(dest)\n" "function vec3f_normalize(dest)\n"
@ -131,23 +149,28 @@ char gSmluaConstants[] = ""
" if divisor == 0 then\n" " if divisor == 0 then\n"
" return dest\n" " return dest\n"
" end\n" " end\n"
"\n"
" local invsqrt = 1.0 / divisor\n" " local invsqrt = 1.0 / divisor\n"
" dest.x = dest.x * invsqrt\n" " dest.x = dest.x * invsqrt\n"
" dest.y = dest.y * invsqrt\n" " dest.y = dest.y * invsqrt\n"
" dest.z = dest.z * invsqrt\n" " dest.z = dest.z * invsqrt\n"
"\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @return number\n" "--- @return number\n"
"function vec3f_length(a)\n" "function vec3f_length(a)\n"
" return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n" " return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n"
"end\n" "end\n"
"\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @param b Vec3f\n" "--- @param b Vec3f\n"
"--- @return number\n" "--- @return number\n"
"function vec3f_dot(a, b)\n" "function vec3f_dot(a, b)\n"
" return a.x * b.x + a.y * b.y + a.z * b.z\n" " return a.x * b.x + a.y * b.y + a.z * b.z\n"
"end\n" "end\n"
"\n"
"--- @param vec Vec3f\n" "--- @param vec Vec3f\n"
"--- @param onto Vec3f\n" "--- @param onto Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -159,6 +182,7 @@ char gSmluaConstants[] = ""
" vec3f_mul(out, numerator / denominator)\n" " vec3f_mul(out, numerator / denominator)\n"
" return out\n" " return out\n"
"end\n" "end\n"
"\n"
"--- @param v1 Vec3f\n" "--- @param v1 Vec3f\n"
"--- @param v2 Vec3f\n" "--- @param v2 Vec3f\n"
"--- @return number\n" "--- @return number\n"
@ -168,6 +192,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n" " dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param src Vec3s\n" "--- @param src Vec3s\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -177,6 +202,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n" " dest.z = src.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param x number\n" "--- @param x number\n"
"--- @param y number\n" "--- @param y number\n"
@ -188,6 +214,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n" " dest.z = z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a Vec3s\n" "--- @param a Vec3s\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -197,6 +224,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n" " dest.z = dest.z + a.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a Vec3s\n" "--- @param a Vec3s\n"
"--- @param b Vec3s\n" "--- @param b Vec3s\n"
@ -207,6 +235,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n" " dest.z = a.z + b.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a number\n" "--- @param a number\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -216,6 +245,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n" " dest.z = dest.z * a\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param v1 Vec3s\n" "--- @param v1 Vec3s\n"
"--- @param v2 Vec3s\n" "--- @param v2 Vec3s\n"
"--- @return number\n" "--- @return number\n"
@ -225,6 +255,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n" " dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n" "end\n"
"\n"
"--- @param current number\n" "--- @param current number\n"
"--- @param target number\n" "--- @param target number\n"
"--- @param inc number\n" "--- @param inc number\n"
@ -244,6 +275,7 @@ char gSmluaConstants[] = ""
" end\n" " end\n"
" return current;\n" " return current;\n"
"end\n" "end\n"
"\n"
"--- @param current number\n" "--- @param current number\n"
"--- @param target number\n" "--- @param target number\n"
"--- @param inc number\n" "--- @param inc number\n"
@ -261,6 +293,7 @@ char gSmluaConstants[] = ""
" current = target\n" " current = target\n"
" end\n" " end\n"
" end\n" " end\n"
"\n"
" -- keep within 32 bits\n" " -- keep within 32 bits\n"
" if current > 2147483647 then\n" " if current > 2147483647 then\n"
" current = -2147483648 + (current - 2147483647)\n" " current = -2147483648 + (current - 2147483647)\n"
@ -269,6 +302,7 @@ char gSmluaConstants[] = ""
" end\n" " end\n"
" return current;\n" " return current;\n"
"end\n" "end\n"
"\n"
"--- @param bank number\n" "--- @param bank number\n"
"--- @param soundID number\n" "--- @param soundID number\n"
"--- @param priority number\n" "--- @param priority number\n"
@ -278,9 +312,11 @@ char gSmluaConstants[] = ""
" if flags == nil then flags = 0 end\n" " if flags == nil then flags = 0 end\n"
" return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n" " return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n"
"end\n" "end\n"
"\n"
"-------------\n" "-------------\n"
"-- courses --\n" "-- courses --\n"
"-------------\n" "-------------\n"
"\n"
"--- @type integer\n" "--- @type integer\n"
"COURSE_NONE = 0\n" "COURSE_NONE = 0\n"
"--- @type integer\n" "--- @type integer\n"