diff --git a/mods/character-select-coop/a-github.lua b/mods/character-select-coop/a-github.lua new file mode 100644 index 000000000..86039f611 --- /dev/null +++ b/mods/character-select-coop/a-github.lua @@ -0,0 +1,3 @@ +GITHUB_COMMIT_TIME = '05/16/2025 07:27:43 PM PST' +GITHUB_COMMIT_ID = '115b65e' +GITHUB_REPO = 'Squishy6094/character-select-coop' diff --git a/mods/character-select-coop/a-utils.lua b/mods/character-select-coop/a-utils.lua index 0daacd32c..a2743c1f7 100644 --- a/mods/character-select-coop/a-utils.lua +++ b/mods/character-select-coop/a-utils.lua @@ -1,6 +1,14 @@ -- localize functions to improve performance - a-utils.lua local string_lower,string_format,table_insert,get_date_and_time = string.lower,string.format,table.insert,get_date_and_time +-- Version Data -- +MOD_VERSION_API = 1 +MOD_VERSION_MAJOR = 14 +MOD_VERSION_MINOR = 1 +MOD_VERSION_INDEV = false +MOD_VERSION_STRING = tostring(MOD_VERSION_API) .. "." .. tostring(MOD_VERSION_MAJOR) .. (MOD_VERSION_MINOR > 0 and ("." .. tostring(MOD_VERSION_MINOR)) or "") .. (MOD_VERSION_INDEV and " (In-Dev)" or "") +MOD_VERSION_DEBUG = tostring(GITHUB_REPO) .. " | " .. tostring(GITHUB_COMMIT_ID) .. " | " .. tostring(GITHUB_COMMIT_TIME) + if VERSION_NUMBER < 38 then djui_popup_create("\n\\#FFAAAA\\Character Select requires\n the latest version of CoopDX to use!\n\nYou can find CoopDX here:\n\\#6666FF\\https://sm64coopdx.com", 5) incompatibleClient = true @@ -9,6 +17,8 @@ end local dependacyFiles = { -- Required Lua File + --"a-github.lua", + "dialog.lua", "main.lua", "n-hud.lua", "o-api.lua", @@ -24,41 +34,42 @@ local legacyFiles = { "z-anims.lua", } +local fileErrorList = {} + -- Check for Missing Files -local missingDependacyFiles = false for i = 1, #dependacyFiles do if not mod_file_exists(dependacyFiles[i]) then - log_to_console("Character Select file missing: '" .. dependacyFiles[i] .. "'", CONSOLE_MESSAGE_ERROR) - missingDependacyFiles = true + log_to_console("Character Select file missing: '" .. dependacyFiles[i] .. "'", CONSOLE_MESSAGE_WARNING) + table_insert(fileErrorList, "Missing File '" .. dependacyFiles[i] .. "'") end end -if missingDependacyFiles then - djui_popup_create("\n\\#FFAAAA\\Character Select is missing\nan important file!\n\nYou can find a list of\nmissing files in the console!", 5) - incompatibleClient = true - return 0 -end - -- Check for Legacy Files -local foundLegacyFiles = false for i = 1, #legacyFiles do if mod_file_exists(legacyFiles[i]) then - log_to_console("Character Select legacy file found: '" .. legacyFiles[i] .. "'", CONSOLE_MESSAGE_ERROR) - foundLegacyFiles = true + log_to_console("Character Select legacy file found: '" .. legacyFiles[i] .. "'", CONSOLE_MESSAGE_WARNING) + table_insert(fileErrorList, "Legacy File '" .. legacyFiles[i] .. "'") end end -if foundLegacyFiles then - djui_popup_create("\n\\#FFAAAA\\Character Select is loading\nan outdated file!\n\nYou can find a list of\nold files in the console!", 5) +if #fileErrorList > 0 then incompatibleClient = true + local frameCount = 0 + hook_event(HOOK_UPDATE, function () + frameCount = frameCount + 1 + if frameCount == 5 then + local errorString = "\\#FFAAAA\\Character Select File Issues:" + djui_popup_create("\\#FFAAAA\\Character Select is having\nfile issues and cannot load!\n\nErrors have been logged in chat!", 4) + for i = 1, #fileErrorList do + errorString = errorString .. "\n" .. fileErrorList[i] + end + errorString = errorString .. "\n\nThe best way to resolve these issues is to delete your current version of Character Select and then install the latest version!" + + log_to_console(errorString) + djui_chat_message_create(errorString) + end + end) return 0 end --- Version Data -- -MOD_VERSION_API = 1 -MOD_VERSION_MAJOR = 13 -MOD_VERSION_MINOR = 1 -MOD_VERSION_INDEV = false -MOD_VERSION_STRING = tostring(MOD_VERSION_API) .. "." .. tostring(MOD_VERSION_MAJOR) .. (MOD_VERSION_MINOR > 0 and ("." .. tostring(MOD_VERSION_MINOR)) or "") .. (MOD_VERSION_INDEV and " (In-Dev)" or "") - ommActive = false for i in pairs(gActiveMods) do if gActiveMods[i].relativePath == "omm-coop" then @@ -67,49 +78,51 @@ for i in pairs(gActiveMods) do end end +E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo") + local saveableCharacters = { - ["1"] = true, - ["2"] = true, - ["3"] = true, - ["4"] = true, - ["5"] = true, - ["6"] = true, - ["7"] = true, - ["8"] = true, - ["9"] = true, - ["0"] = true, - ["a"] = true, - ["b"] = true, - ["c"] = true, - ["d"] = true, - ["e"] = true, - ["f"] = true, - ["g"] = true, - ["h"] = true, - ["i"] = true, - ["j"] = true, - ["k"] = true, - ["l"] = true, - ["m"] = true, - ["n"] = true, - ["o"] = true, - ["p"] = true, - ["q"] = true, - ["r"] = true, - ["s"] = true, - ["t"] = true, - ["u"] = true, - ["v"] = true, - ["w"] = true, - ["x"] = true, - ["y"] = true, - ["z"] = true, - ["_"] = true, - ["-"] = true, - ["."] = true, + ["1"] = 1, + ["2"] = 1, + ["3"] = 1, + ["4"] = 1, + ["5"] = 1, + ["6"] = 1, + ["7"] = 1, + ["8"] = 1, + ["9"] = 1, + ["0"] = 1, + ["a"] = 1, + ["b"] = 1, + ["c"] = 1, + ["d"] = 1, + ["e"] = 1, + ["f"] = 1, + ["g"] = 1, + ["h"] = 1, + ["i"] = 1, + ["j"] = 1, + ["k"] = 1, + ["l"] = 1, + ["m"] = 1, + ["n"] = 1, + ["o"] = 1, + ["p"] = 1, + ["q"] = 1, + ["r"] = 1, + ["s"] = 1, + ["t"] = 1, + ["u"] = 1, + ["v"] = 1, + ["w"] = 1, + ["x"] = 1, + ["y"] = 1, + ["z"] = 1, + ["_"] = 1, + ["-"] = 1, + ["."] = 1, -- Replace with Underscore - [" "] = false, + [" "] = 0, } --- @param string string @@ -126,9 +139,9 @@ function string_space_to_underscore(string) local s = '' for i = 1, #string do local c = string:sub(i,i) - if saveableCharacters[string_lower(c)] then + if saveableCharacters[string_lower(c)] == 1 then s = s .. c - elseif saveableCharacters[string_lower(c)] ~= nil then + elseif saveableCharacters[string_lower(c)] == 0 then s = s .. "_" end end @@ -137,9 +150,12 @@ end --- @param string string --- Splits a string into a table by spaces -function string_split(string) +function string_split(string, splitAt) + if splitAt == nil then + splitAt = " " + end local result = {} - for match in string:gmatch(string_format("[^%s]+", " ")) do + for match in string:gmatch(string_format("[^%s]+", splitAt)) do table_insert(result, match) end return result diff --git a/mods/character-select-coop/dialog.lua b/mods/character-select-coop/dialog.lua index b67b9e157..25c55666f 100644 --- a/mods/character-select-coop/dialog.lua +++ b/mods/character-select-coop/dialog.lua @@ -1,3 +1,5 @@ +if incompatibleClient then return 0 end + -- Original Made by EliteMasterEric along with CoopDX PR #321 to replace dialog depending on character -- -- https://github.com/coop-deluxe/sm64coopdx/pull/321 -- -- Eric's Original stuffs will be added as soon as there is some way to directly get dialog strings @@ -107,7 +109,7 @@ define_cs_dialog(DIALOG_086, 1, 3, 30, 200, ("Running around in circles\nmakes s define_cs_dialog(DIALOG_087, 1, 4, 30, 200, ("Santa Claus isn't the only\none who can go down a\nchimney! Come on in!\n/--Cabin Proprietor")) define_cs_dialog(DIALOG_088, 1, 5, 30, 200, ("Work Elevator\nFor those who get off\nhere: Grab the pole to the\nleft and slide carefully\ndown.")) define_cs_dialog(DIALOG_089, 1, 5, 95, 200, ("Both ways fraught with\ndanger! Watch your feet!\nThose who can't do the\nLong Jump, tsk, tsk. Make\nyour way to the right.\nRight: Work Elevator\n/// Cloudy Maze\nLeft: Black Hole\n///Underground Lake\n\nRed Circle: Elevator 2\n//// Underground Lake\nArrow: You are here")) -define_cs_dialog(DIALOG_090, 1, 6, 30, 200, ("Bwa ha ha ha!\nYou've stepped right into\nmy trap, just as I knew\nyou would! I warn you,\n『Friend,』 watch your\nstep!")) +define_cs_dialog(DIALOG_090, 1, 6, 30, 200, ("Bwa ha ha ha!\nYou've stepped right into\nmy trap, just as I knew\nyou would! I warn you,\n" .. ' "Friend," ' .. "watch your\nstep!")) define_cs_dialog(DIALOG_091, 2, 2, 30, 200, ("Danger!\nStrong Gusts!\nBut the wind makes a\ncomfy ride.")) define_cs_dialog(DIALOG_092, 1, 5, 30, 200, ("Pestering me again, are\nyou, Mario? Can't you see\nthat I'm having a merry\nlittle time, making\nmischief with my minions?\nNow, return those Stars!\nMy troops in the walls\nneed them! Bwa ha ha!")) define_cs_dialog(DIALOG_093, 1, 5, 30, 200, ("Mario! You again! Well\nthat's just fine--I've\nbeen looking for something\nto fry with my fire\nbreath!\nYour Star Power is\nuseless against me!\nYour friends are all\ntrapped within the\nwalls...\nAnd you'll never see the\nPrincess again!\nBwa ha ha ha!")) @@ -201,7 +203,7 @@ local function dialog_swap(charName) for i = DIALOG_000, #dialogTable do if dialogTable[i] ~= nil then local dialog = dialogTable[i] - charName = charName:gsub('"', "'") + charName = charName:gsub('"', "''") local replaced_dialog = dialog.str:gsub(DIALOG_NAME, charName) real_dialog_replace(i, dialog.unused, dialog.linesPerBox, dialog.leftOffset, dialog.width, replaced_dialog) end diff --git a/mods/character-select-coop/main.lua b/mods/character-select-coop/main.lua index d44c146cb..6cc963dae 100644 --- a/mods/character-select-coop/main.lua +++ b/mods/character-select-coop/main.lua @@ -1,10 +1,27 @@ -- name: Character Select --- description:\\#ffff33\\-- Character Select Coop v1.13.1 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop +-- description:\\#ffff33\\-- Character Select Coop v1.14.1 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop -- pausable: false -- category: cs if incompatibleClient then return 0 end +--- @param hookEventType LuaHookedEventType +local function create_hook_wrapper(hookEventType) + local callbacks = {} + + hook_event(hookEventType, function(...) + for _, func in pairs(callbacks) do + func(...) + end + end) + + return function(func) + table.insert(callbacks, func) + end +end + +cs_hook_mario_update = create_hook_wrapper(HOOK_MARIO_UPDATE) + -- localize functions to improve performance - main.lua local mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math_random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math_min,math_ceil,math_abs,math_sin,minf,djui_hud_set_rotation,table_insert,djui_hud_print_text_interpolated,math_max,play_sound,play_character_sound,string_lower = mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math.random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math.min,math.ceil,math.abs,math.sin,minf,djui_hud_set_rotation,table.insert,djui_hud_print_text_interpolated,math.max,play_sound,play_character_sound,string.lower @@ -14,6 +31,8 @@ options = false local credits = false local creditsAndTransition = false currChar = 1 +currCharRender = 1 +currCategory = 1 local currOption = 1 local creditScroll = 0 local prevCreditScroll = creditScroll @@ -35,6 +54,8 @@ function header_set_texture(texture) TEX_OVERRIDE_HEADER = texture end +CS_ANIM_MENU = CHAR_ANIM_MAX + 1 + local TEXT_PREF_LOAD_NAME = "Default" local TEXT_PREF_LOAD_ALT = 1 @@ -48,6 +69,8 @@ local TEXT_PREF_LOAD_ALT = 1 characterTable = { [1] = { saveName = "Default", + category = "All_CoopDX", + ogNum = 1, currAlt = 1, hasMoveset = false, locked = false, @@ -85,6 +108,12 @@ characterTable = { lifeIcon = gTextures.luigi_head, starIcon = gTextures.star, camScale = 1.0, + healthTexture = { + label = { + left = get_texture_info("char-select-luigi-meter-left"), + right = get_texture_info("char-select-luigi-meter-right"), + } + } }, [3] = { name = "Toad", @@ -102,6 +131,12 @@ characterTable = { lifeIcon = gTextures.toad_head, starIcon = gTextures.star, camScale = 0.8, + healthTexture = { + label = { + left = get_texture_info("char-select-toad-meter-left"), + right = get_texture_info("char-select-toad-meter-right"), + } + } }, [4] = { name = "Waluigi", @@ -119,6 +154,12 @@ characterTable = { lifeIcon = gTextures.waluigi_head, starIcon = gTextures.star, camScale = 1.1, + healthTexture = { + label = { + left = get_texture_info("char-select-waluigi-meter-left"), + right = get_texture_info("char-select-waluigi-meter-right"), + } + } }, [5] = { name = "Wario", @@ -137,10 +178,52 @@ characterTable = { lifeIcon = gTextures.wario_head, starIcon = gTextures.star, camScale = 1.0, + healthTexture = { + label = { + left = get_texture_info("char-select-wario-meter-left"), + right = get_texture_info("char-select-wario-meter-right"), + } + } }, }, } +characterCategories = { + "All", + "CoopDX", + "Locked", +} + +local characterTableRender = {} + +local function update_character_render_table() + local ogNum = currChar + currChar = 1 + currCharRender = 1 + local category = characterCategories[currCategory] + if category == nil then return false end + characterTableRender = {} + local listCount = 0 + for i = 1, #characterTable do + local charCategories = string_split(characterTable[i].category, "_") + for c = 1, #charCategories do + if category == charCategories[c] and not characterTable[i].locked then + table_insert(characterTableRender, characterTable[i]) + if ogNum == i then + currChar = ogNum + currCharRender = #characterTableRender + end + end + end + end + if #characterTableRender > 0 then + currChar = (characterTableRender[currCharRender] and characterTableRender[currCharRender].ogNum or characterTableRender[1].ogNum) + return true + else + return false + end +end + characterCaps = {} characterCelebrationStar = {} characterColorPresets = {} @@ -148,22 +231,27 @@ characterAnims = {} characterMovesets = {[1] = {}} characterUnlock = {} +tableRefNum = 0 +local function make_table_ref_num() + tableRefNum = tableRefNum + 1 + return tableRefNum +end + optionTableRef = { -- Menu - openInputs = 1, - notification = 2, - menuColor = 3, - anims = 4, - inputLatency = 5, - showLocked = 6, + openInputs = make_table_ref_num(), + notification = make_table_ref_num(), + menuColor = make_table_ref_num(), + anims = make_table_ref_num(), + inputLatency = make_table_ref_num(), -- Characters - localMoveset = 7, - localModels = 8, - localVoices = 9, + localMoveset = make_table_ref_num(), + localModels = make_table_ref_num(), + localVoices = make_table_ref_num(), -- CS - credits = 10, - debugInfo = 11, - resetSaveData = 12, + credits = make_table_ref_num(), + debugInfo = make_table_ref_num(), + resetSaveData = make_table_ref_num(), } optionTable = { @@ -183,7 +271,7 @@ optionTable = { toggleDefault = 1, toggleMax = 2, toggleNames = {"Off", "On", "Pop-ups Only"}, - description = {"Toggles wheather Pop-ups and", "Chat Messages display"} + description = {"Toggles whether Pop-ups and", "Chat Messages display"} }, [optionTableRef.menuColor] = { name = "Menu Color", @@ -212,14 +300,6 @@ optionTable = { toggleNames = {"Slow", "Normal", "Fast"}, description = {"Sets how fast you scroll", "throughout the Menu"} }, - [optionTableRef.showLocked] = { - name = "Show Locked Chars", - toggle = tonumber(mod_storage_load("showLocked")), - toggleSaveName = "showLocked", - toggleDefault = 1, - toggleMax = 1, - description = {"Toggles if Locked Characters", "Display In-Menu"} - }, [optionTableRef.localMoveset] = { name = "Character Moveset", toggle = tonumber(mod_storage_load("localMoveset")), @@ -329,6 +409,7 @@ local prefCharColor = {r = 255, g = 50, b = 50} local function load_preferred_char() local savedChar = mod_storage_load("PrefChar") local savedAlt = tonumber(mod_storage_load("PrefAlt")) + local savedPalette = tonumber(mod_storage_load("PrefPalette")) if savedChar == nil or savedChar == "" then mod_storage_save("PrefChar", "Default") savedChar = "Default" @@ -337,29 +418,38 @@ local function load_preferred_char() mod_storage_save("PrefAlt", "1") savedAlt = 1 end - if savedChar ~= nil and savedChar ~= "Default" then + if savedPalette == nil then + local paletteSave = savedChar ~= "Default" and 1 or 0 + mod_storage_save("PrefAlt", tostring(paletteSave)) + savedPalette = paletteSave + end + if savedChar ~= "Default" and optionTable[optionTableRef.localModels].toggle == 1 then for i = 2, #characterTable do local char = characterTable[i] if char.saveName == savedChar and not char.locked then currChar = i + currCharRender = i if savedAlt > 0 and savedAlt <= #char then char.currAlt = savedAlt end - if optionTable[optionTableRef.localModels].toggle == 1 then - if optionTable[optionTableRef.notification].toggle > 0 then - djui_popup_create('Character Select:\nYour Preferred Character\n"' .. string_underscore_to_space(char[char.currAlt].name) .. '"\nwas applied successfully!', 4) - end + local model = characterTable[currChar][savedAlt].model + if characterColorPresets[model] ~= nil then + gCSPlayers[0].presetPalette = savedPalette + characterColorPresets[model].currPalette = savedPalette + end + if optionTable[optionTableRef.notification].toggle > 0 then + djui_popup_create('Character Select:\nYour Preferred Character\n"' .. string_underscore_to_space(char[char.currAlt].name) .. '"\nwas applied successfully!', 4) end break end end end - + characterTable[1].currAlt = gNetworkPlayers[0].modelIndex + 1 local savedCharColors = mod_storage_load("PrefCharColor") if savedCharColors ~= nil and savedCharColors ~= "" then - local savedCharColorsTable = string_split(string_underscore_to_space(savedCharColors)) + local savedCharColorsTable = string_split(savedCharColors, "_") prefCharColor = { r = tonumber(savedCharColorsTable[1]), g = tonumber(savedCharColorsTable[2]), @@ -376,12 +466,14 @@ local function load_preferred_char() end TEXT_PREF_LOAD_NAME = savedChar TEXT_PREF_LOAD_ALT = savedAlt + update_character_render_table() end local function mod_storage_save_pref_char(charTable) mod_storage_save("PrefChar", charTable.saveName) mod_storage_save("PrefAlt", tostring(charTable.currAlt)) mod_storage_save("PrefCharColor", tostring(charTable[charTable.currAlt].color.r) .. "_" .. tostring(charTable[charTable.currAlt].color.g) .. "_" .. tostring(charTable[charTable.currAlt].color.b)) + mod_storage_save("PrefPalette", tostring(gCSPlayers[0].presetPalette)) TEXT_PREF_LOAD_NAME = charTable.saveName TEXT_PREF_LOAD_ALT = charTable.currAlt prefCharColor = charTable[charTable.currAlt].color @@ -467,6 +559,7 @@ local function menu_is_allowed(m) return true end +--[[ local function get_next_unlocked_char() for i = currChar, #characterTable do if not characterTable[i].locked then @@ -484,6 +577,7 @@ local function get_last_unlocked_char() end return 1 end +]] ------------------- -- Model Handler -- @@ -493,11 +587,6 @@ local stallFrame = 0 CUTSCENE_CS_MENU = 0xFA -local ignoredSurfaces = { - SURFACE_BURNING, SURFACE_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_INSTANT_MOVING_QUICKSAND, SURFACE_DEEP_MOVING_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_DEEP_QUICKSAND, SURFACE_SHALLOW_MOVING_QUICKSAND, - SURFACE_SHALLOW_QUICKSAND, SURFACE_WARP, SURFACE_LOOK_UP_WARP, SURFACE_WOBBLING_WARP, SURFACE_INSTANT_WARP_1B, SURFACE_INSTANT_WARP_1C, SURFACE_INSTANT_WARP_1D, SURFACE_INSTANT_WARP_1E -} - local TYPE_FUNCTION = "function" local TYPE_BOOLEAN = "boolean" local TYPE_STRING = "string" @@ -506,31 +595,6 @@ local TYPE_TABLE = "table" local MATH_PI = math.pi -local menuActBlacklist = { - -- Star Acts - [ACT_FALL_AFTER_STAR_GRAB] = true, - [ACT_STAR_DANCE_EXIT] = true, - [ACT_STAR_DANCE_NO_EXIT] = true, - [ACT_STAR_DANCE_WATER] = true, - -- Key Acts - [ACT_UNLOCKING_KEY_DOOR] = true, - [ACT_UNLOCKING_STAR_DOOR] = true, - -- Cutscene Acts - [ACT_INTRO_CUTSCENE] = true, - [ACT_CREDITS_CUTSCENE] = true, - [ACT_WARP_DOOR_SPAWN] = true, - [ACT_PULLING_DOOR] = true, - [ACT_PUSHING_DOOR] = true, - [ACT_UNLOCKING_KEY_DOOR] = true, - [ACT_UNLOCKING_STAR_DOOR] = true, - [ACT_IN_CANNON] = true, - -- Dialog Acts - [ACT_READING_NPC_DIALOG] = true, - [ACT_WAITING_FOR_DIALOG] = true, - [ACT_EXIT_LAND_SAVE_DIALOG] = true, - [ACT_READING_AUTOMATIC_DIALOG] = true, -} - local prevBaseCharFrame = gNetworkPlayers[0].modelIndex local prevAnim = 0 local animTimer = 0 @@ -565,24 +629,22 @@ local function mario_update(m) end prevBaseCharFrame = np.modelIndex - local defaultTable = characterTable[1] + if optionTable[optionTableRef.localModels].toggle == 0 then + currCategory = 1 + currChar = 1 + currCharRender = 1 + end + local charTable = characterTable[currChar] p.saveName = charTable.saveName p.currAlt = charTable.currAlt - - if optionTable[optionTableRef.localModels].toggle > 0 then - p.modelId = charTable[charTable.currAlt].model - if charTable[charTable.currAlt].forceChar ~= nil then - p.forceChar = charTable[charTable.currAlt].forceChar - end - p.modelEditOffset = charTable[charTable.currAlt].model - charTable[charTable.currAlt].ogModel - m.marioObj.hookRender = 1 - else - p.modelId = nil - p.forceChar = defaultTable.forceChar - p.modelEditOffset = 0 - currChar = 1 + + p.modelId = charTable[charTable.currAlt].model + if charTable[charTable.currAlt].forceChar ~= nil then + p.forceChar = charTable[charTable.currAlt].forceChar end + p.modelEditOffset = charTable[charTable.currAlt].model - charTable[charTable.currAlt].ogModel + m.marioObj.hookRender = 1 if menuAndTransition then --play_secondary_music(0, 0, 0.5, 0) @@ -603,7 +665,7 @@ local function mario_update(m) gLakituState.pos.x = m.pos.x + sins(faceAngle) * 500 * camScale gLakituState.pos.y = m.pos.y + 100 * camScale gLakituState.pos.z = m.pos.z + coss(faceAngle) * 500 * camScale - set_window_title("Character Select v".. MOD_VERSION_STRING .. " - " .. string_underscore_to_space(charTable[charTable.currAlt].name)) + set_window_title("Character Select v".. MOD_VERSION_STRING .. " - " .. string_underscore_to_space(charTable[charTable.currAlt].name) .. " (CoopDX)") p.inMenu = true else if p.inMenu then @@ -632,15 +694,18 @@ local function mario_update(m) if type(unlock) == TYPE_FUNCTION then if unlock() then currChar.locked = false - if stallFrame == 3 and notif then - if optionTable[optionTableRef.notification].toggle > 0 then - djui_popup_create('Character Select:\nUnlocked '..currChar.name..'\nas a Playable Character!', 3) - end - end end elseif type(unlock) == TYPE_BOOLEAN then currChar.locked = not unlock end + if not currChar.locked then -- Character was unlocked + update_character_render_table() + if stallFrame == 3 and notif then + if optionTable[optionTableRef.notification].toggle > 0 then + djui_popup_create('Character Select:\nUnlocked '..tostring(currChar[1].name)..'\nas a Playable Character!', 3) + end + end + end end end @@ -663,8 +728,10 @@ local function mario_update(m) p.movesetToggle = optionTable[optionTableRef.localMoveset].toggle ~= 0 end - if p.inMenu and m.forwardVel == 0 and m.pos.y == m.floorHeight and not ignoredSurfaces[m.floor.type] and m.health > 255 and not menuActBlacklist[m.action] then - set_mario_animation(m, MARIO_ANIM_FIRST_PERSON) + if p.inMenu and m.action & ACT_FLAG_ALLOW_FIRST_PERSON ~= 0 then + set_mario_animation(m, (characterAnims[p.modelId] and characterAnims[p.modelId][CS_ANIM_MENU]) and CS_ANIM_MENU or MARIO_ANIM_IDLE_HEAD_LEFT) + set_anim_to_frame(m, 0) + m.marioObj.header.gfx.angle.y = m.faceAngle.y end local marioGfx = m.marioObj.header.gfx @@ -674,12 +741,7 @@ local function mario_update(m) end animTimer = animTimer + 1 - - if p.forceChar ~= nil then - np.overrideModelIndex = p.forceChar - else - np.overrideModelIndex = CT_MARIO - end + np.overrideModelIndex = p.forceChar ~= nil and p.forceChar or CT_MARIO -- Character Animations if characterAnims[p.modelId] then @@ -709,12 +771,13 @@ local function on_star_or_key_grab(m, o, type) end end -local settingModel function set_model(o, model) - if settingModel then return end if optionTable[optionTableRef.localModels].toggle == 0 then return end + + -- Player Models if obj_has_behavior_id(o, id_bhvMario) ~= 0 then local i = network_local_index_from_global(o.globalPlayerIndex) + local prevModelData = obj_get_model_id_extended(o) local localModelData = nil for c = 1, #characterTable do if gCSPlayers[i].saveName == characterTable[c].saveName then @@ -725,27 +788,23 @@ function set_model(o, model) end if localModelData ~= nil then if obj_has_model_extended(o, localModelData) == 0 then - settingModel = true obj_set_model_extended(o, localModelData) - settingModel = false end else -- Original/Backup if gCSPlayers[i].modelId ~= nil and obj_has_model_extended(o, gCSPlayers[i].modelId) == 0 then - settingModel = true obj_set_model_extended(o, gCSPlayers[i].modelId) - settingModel = false end end return end + + -- Star Models if obj_has_behavior_id(o, id_bhvCelebrationStar) ~= 0 and o.parentObj ~= nil then local i = network_local_index_from_global(o.parentObj.globalPlayerIndex) local starModel = characterCelebrationStar[gCSPlayers[i].modelId] if gCSPlayers[i].modelId ~= nil and starModel ~= nil and obj_has_model_extended(o, starModel) == 0 and not BowserKey then - settingModel = true obj_set_model_extended(o, starModel) - settingModel = false end return end @@ -773,15 +832,14 @@ function set_model(o, model) capModel = capModels.metalWing end if capModel ~= E_MODEL_NONE and capModel ~= E_MODEL_ERROR_MODEL and capModel ~= nil then - settingModel = true obj_set_model_extended(o, capModel) - settingModel = false end end end end -hook_event(HOOK_MARIO_UPDATE, mario_update) +--hook_event(HOOK_MARIO_UPDATE, mario_update) +cs_hook_mario_update(mario_update) hook_event(HOOK_ON_INTERACT, on_star_or_key_grab) hook_event(HOOK_OBJECT_SET_MODEL, set_model) @@ -808,8 +866,9 @@ local yearsOfCS = get_date_and_time().year - 123 -- Zero years as of 2023 local TEXT_VERSION = "Version: " .. MOD_VERSION_STRING .. " | sm64coopdx" .. (seasonalEvent == SEASON_EVENT_BIRTHDAY and (" | " .. tostring(yearsOfCS) .. " year" .. (yearsOfCS > 1 and "s" or "") .. " of Character Select!") or "") local TEXT_RATIO_UNSUPPORTED = "Your Current Aspect-Ratio isn't Supported!" local TEXT_DESCRIPTION = "Character Description:" -local TEXT_PREF_SAVE = "Press A to Set as Preferred Character" -local TEXT_PREF_SAVE_AND_PALETTE = "A - Set Preference | Y - Toggle Palette" +local TEXT_PREF_SAVE = "Preferred Char (A)" +local TEXT_PREF_PALETTE = "Toggle Palette (Y)" +local TEXT_MOVESET_INFO = "Moveset Info (Z)" local TEXT_PAUSE_Z_OPEN = "Z Button - Character Select" local TEXT_PAUSE_UNAVAILABLE = "Character Select is Unavailable" local TEXT_PAUSE_CURR_CHAR = "Current Character: " @@ -839,6 +898,8 @@ local TEXT_MENU_CLOSE = "Press B to Exit Menu" local TEXT_OPTIONS_SELECT = "A - Select | B - Exit " local TEXT_LOCAL_MODEL_OFF = "Locally Display Models is Off" local TEXT_LOCAL_MODEL_OFF_OPTIONS = "You can turn it back on in the Options Menu" +local TEXT_LOCAL_MODEL_ERROR = "Failed to find a Character Model" +local TEXT_LOCAL_MODEL_ERROR_FIX = "Please Verify the Integrity of the Pack!" --Credit Text local TEXT_CREDITS_HEADER = "Credits" @@ -861,22 +922,34 @@ local targetMenuColor = {r = 0 , g = 0, b = 0} menuColor = targetMenuColor local menuColorHalf = menuColor local transSpeed = 0.1 +local prevBindText = "" +local bindText = 1 +local bindTextTimerLoop = 150 +local bindTextTimer = 0 +local bindTextOpacity = -255 function update_menu_color() - if optionTable[optionTableRef.menuColor].toggle > 1 then - targetMenuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1] - elseif optionTable[optionTableRef.menuColor].toggle == 1 then - optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") .. " (Pref)" - targetMenuColor = prefCharColor - elseif characterTable[currChar] ~= nil then - local char = characterTable[currChar] - targetMenuColor = char[char.currAlt].color + if optionTable[optionTableRef.menuColor].toggle == nil then return end + if optionTable[optionTableRef.localModels].toggle == 1 then + if optionTable[optionTableRef.menuColor].toggle > 1 then + targetMenuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1] + elseif optionTable[optionTableRef.menuColor].toggle == 1 then + optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") .. " (Pref)" + targetMenuColor = prefCharColor + elseif characterTable[currChar] ~= nil then + local char = characterTable[currChar] + targetMenuColor = char[char.currAlt].color + end + else + targetMenuColor = menuColorTable[9] end if optionTable[optionTableRef.anims].toggle > 0 then menuColor.r = lerp(menuColor.r, targetMenuColor.r, transSpeed) menuColor.g = lerp(menuColor.g, targetMenuColor.g, transSpeed) menuColor.b = lerp(menuColor.b, targetMenuColor.b, transSpeed) else - menuColor = targetMenuColor + menuColor.r = targetMenuColor.r + menuColor.g = targetMenuColor.g + menuColor.b = targetMenuColor.b end menuColorHalf = { r = menuColor.r * 0.5 + 127, @@ -893,20 +966,24 @@ end local buttonAltAnim = 0 local menuOpacity = 245 +local menuText = {} local function on_hud_render() local FONT_USER = djui_menu_get_font() - djui_hud_set_resolution(RESOLUTION_N64) djui_hud_set_font(FONT_ALIASED) - - local width = djui_hud_get_screen_width() + 1.4 + djui_hud_set_resolution(RESOLUTION_DJUI) + local djuiWidth = djui_hud_get_screen_width() + local djuiHeight = djui_hud_get_screen_height() + djui_hud_set_resolution(RESOLUTION_N64) + local width = djuiWidth * (240/djuiHeight) -- Get accurate, unrounded width local height = 240 local widthHalf = width * 0.5 local heightHalf = height * 0.5 - local widthScale = maxf(width, 321.4) * MATH_DIVIDE_320 + local widthScale = maxf(width, 320) * MATH_DIVIDE_320 update_menu_color() if menuAndTransition then + if optionTable[optionTableRef.localModels].toggle == 0 then djui_hud_set_color(0, 0, 0, 200) djui_hud_render_rect(0, 0, width, height) @@ -915,6 +992,14 @@ local function on_hud_render() djui_hud_print_text(TEXT_LOCAL_MODEL_OFF_OPTIONS, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF_OPTIONS) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale) end + if characterTable[currChar][characterTable[currChar].currAlt].model == E_MODEL_ARMATURE then + djui_hud_set_color(0, 0, 0, 200) + djui_hud_render_rect(0, 0, width, height) + djui_hud_set_color(255, 255, 255, 255) + djui_hud_print_text(TEXT_LOCAL_MODEL_ERROR, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_ERROR) * 0.15 * widthScale, heightHalf, 0.3 * widthScale) + djui_hud_print_text(TEXT_LOCAL_MODEL_ERROR_FIX, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_ERROR_FIX) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale) + end + local x = 135 * widthScale * 0.8 -- Render All Black Squares Behind Below API @@ -926,7 +1011,6 @@ local function on_hud_render() -- Header djui_hud_render_rect(2, 2, width - 4, 46) - -- API Rendering (Below Text) if #renderInMenuTable.back > 0 then for i = 1, #renderInMenuTable.back do @@ -953,16 +1037,7 @@ local function on_hud_render() local TEXT_NAME = string_underscore_to_space(character.name) local TEXT_CREDIT = "Credit: " .. character.credit local TEXT_DESCRIPTION_TABLE = character.description - local TEXT_PRESET = "Preset Character Palette: "..((paletteCount > 1 and "("..currPaletteTable.currPalette.."/"..paletteCount..")" or (currPaletteTable.currPalette > 0 and "On" or "Off")) or "Off") - local TEXT_PREF = "Preferred Character:" - local TEXT_PREF_LOAD_NAME = ' "' .. string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. '"' .. ((TEXT_PREF_LOAD_ALT ~= 1 and TEXT_PREF_LOAD_NAME ~= "Default" and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") - if djui_hud_measure_text(TEXT_PREF_LOAD_NAME) / widthScale > 110 then - TEXT_PREF = "Preferred Char:" - end - if djui_hud_measure_text(TEXT_PREF_LOAD_NAME) / widthScale > 164 then - TEXT_PREF = "Pref Char:" - end - TEXT_PREF = TEXT_PREF .. TEXT_PREF_LOAD_NAME + local TEXT_PREF_LOAD_NAME = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and TEXT_PREF_LOAD_NAME ~= "Default" and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") local textX = x * 0.5 djui_hud_print_text(TEXT_NAME, width - textX - djui_hud_measure_text(TEXT_NAME) * 0.3, 55, 0.6) @@ -989,17 +1064,46 @@ local function on_hud_render() end end + menuText = { + TEXT_PREF_SAVE .. " - " .. TEXT_PREF_LOAD_NAME + } local modelId = gCSPlayers[0].modelId - djui_hud_print_text(TEXT_PREF, width - textX - djui_hud_measure_text(TEXT_PREF) * 0.15, height - 22, 0.3) - local text = TEXT_PREF_SAVE + local TEXT_PRESET_TOGGLE = ((currPaletteTable[currPaletteTable.currPalette] ~= nil and currPaletteTable[currPaletteTable.currPalette].name ~= nil) and (currPaletteTable[currPaletteTable.currPalette].name .. " - ") or "") .. ((paletteCount > 1 and "("..currPaletteTable.currPalette.."/"..paletteCount..")" or (currPaletteTable.currPalette > 0 and "On" or "Off")) or "Off") if characterColorPresets[modelId] and not stopPalettes then - djui_hud_print_text(TEXT_PRESET, width - textX - djui_hud_measure_text(TEXT_PRESET) * 0.15, height - 31, 0.3) - text = TEXT_PREF_SAVE_AND_PALETTE + table_insert(menuText, TEXT_PREF_PALETTE .. " - " .. TEXT_PRESET_TOGGLE) elseif stopPalettes then - djui_hud_print_text(TEXT_PALETTE_RESTRICTED, width - textX - djui_hud_measure_text(TEXT_PALETTE_RESTRICTED) * 0.15, height - 31, 0.3) + table_insert(menuText, TEXT_PALETTE_RESTRICTED) end - djui_hud_set_font(FONT_TINY) - djui_hud_print_text(text, width - textX - djui_hud_measure_text(TEXT_PREF_SAVE) * 0.25, height - 13, 0.5) + if #menuText > 1 then + bindTextTimer = (bindTextTimer + 1)%(bindTextTimerLoop) + end + if bindTextTimer == 0 then + bindText = bindText + 1 + bindTextOpacity = -254 + end + if bindText > #menuText or not menuText[bindText] then + bindText = 1 + end + if menuText[bindText] ~= prevBindText and bindTextOpacity == -255 then + bindTextOpacity = -254 + end + if bindTextOpacity > -255 and bindTextOpacity < 255 then + bindTextOpacity = math.min(bindTextOpacity + 25, 255) + if bindTextOpacity == 255 then + bindTextOpacity = -255 + prevBindText = menuText[bindText] + end + end + --local bindTextOpacity = clamp(math.abs(math.sin(bindTextTimer*MATH_PI/bindTextTimerLoop)), 0, 0.2) * 5 * 255 + local fadeOut = math_abs(clamp(bindTextOpacity, -255, 0)) + local fadeIn = math_abs(clamp(bindTextOpacity, 0, 255)) + local bindTextScale = math.min((x - 10)/(djui_hud_measure_text(menuText[bindText]) * 0.3), 1)*0.3 + local prevBindTextScale = math.min((x - 10)/(djui_hud_measure_text(prevBindText) * 0.3), 1)*0.3 + djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, fadeOut) + djui_hud_print_text(prevBindText, width - textX - djui_hud_measure_text(prevBindText) * prevBindTextScale*0.5, height - 15, prevBindTextScale) + djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, fadeIn) + djui_hud_print_text(menuText[bindText], width - textX - djui_hud_measure_text(menuText[bindText]) * bindTextScale*0.5, height - 15, bindTextScale) + djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) else -- Debugging Info -- local TEXT_NAME = "Name: " .. character.name @@ -1129,24 +1233,8 @@ local function on_hud_render() local charNum = -1 for i = -1, 4 do -- Hide Locked Characters based on Toggle - charNum = currChar + i - local char = characterTable[charNum] - if optionTable[optionTableRef.showLocked].toggle == 0 and char ~= nil and char.locked then - if i < 0 then - repeat - charNum = charNum - 1 - until characterTable[charNum] == nil or (not characterTable[charNum].locked) - charNum = charNum + 1 - else - repeat - charNum = charNum + 1 - until characterTable[charNum] == nil or (not characterTable[charNum].locked) - charNum = charNum - 1 - end - charNum = charNum + i - end - - local char = characterTable[charNum] + charNum = currCharRender + i + local char = characterTableRender[charNum] if char ~= nil then if not char.locked then buttonColor = char[char.currAlt].color @@ -1189,7 +1277,7 @@ local function on_hud_render() end -- Scroll Bar - local MATH_DIVIDE_CHARACTERS = 1/#characterTable + local MATH_DIVIDE_CHARACTERS = 1/#characterTableRender local MATH_7_WIDTHSCALE = 7 * widthScale djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_render_rect(MATH_7_WIDTHSCALE, 55, 1, 170) @@ -1197,10 +1285,11 @@ local function on_hud_render() djui_hud_render_rect(MATH_7_WIDTHSCALE + 6, 55, 1, 170) djui_hud_render_rect(MATH_7_WIDTHSCALE, 224, 7, 1) djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) - djui_hud_render_rect(MATH_7_WIDTHSCALE + 2, 57 + 166 * ((currChar - 1) * MATH_DIVIDE_CHARACTERS) - (buttonScroll * MATH_DIVIDE_30) * (166 * MATH_DIVIDE_CHARACTERS), 3, 166 * MATH_DIVIDE_CHARACTERS) + djui_hud_render_rect(MATH_7_WIDTHSCALE + 2, 57 + 166 * ((currCharRender - 1) * MATH_DIVIDE_CHARACTERS) - (buttonScroll * MATH_DIVIDE_30) * (166 * MATH_DIVIDE_CHARACTERS), 3, 166 * MATH_DIVIDE_CHARACTERS) djui_hud_set_font(FONT_TINY) - local TEXT_CHAR_COUNT = currChar .. "/" .. #characterTable + local TEXT_CHAR_COUNT = currCharRender .. "/" .. #characterTableRender djui_hud_print_text(TEXT_CHAR_COUNT, (11 - djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4) + djui_hud_print_text("- "..characterCategories[currCategory] .. " (L/R)", (11 + djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4) --Character Select Header djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) @@ -1216,10 +1305,10 @@ local function on_hud_render() end djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) djui_hud_set_font(FONT_TINY) - djui_hud_print_text(TEXT_VERSION, 5, 3, 0.5) + djui_hud_print_text(optionTable[optionTableRef.debugInfo].toggle == 0 and TEXT_VERSION or MOD_VERSION_DEBUG, 5, 3, 0.5) --Unsupported Res Warning - if width < 321.2 or width > 575 then + if width < 319 or width > 575 then djui_hud_print_text(TEXT_RATIO_UNSUPPORTED, 5, 39, 0.5) end @@ -1393,7 +1482,7 @@ local function on_hud_render() local widthScaleLimited = minf(widthScale, 1.42) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 25 * widthScaleLimited, 100 * widthScale, 26 * widthScaleLimited) - djui_hud_set_color(0, 0, 0, menuOpacity) + djui_hud_set_color(menuColorHalf.r * 0.1, menuColorHalf.g * 0.1, menuColorHalf.b * 0.1, menuOpacity) djui_hud_render_rect(widthHalf - 50 * widthScale + 2, height - 25 * widthScaleLimited + 2, 100 * widthScale - 4, 22 * widthScaleLimited) djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 2, 100 * widthScale, 2) @@ -1430,6 +1519,7 @@ local function on_hud_render() optionAnimTimer = optionAnimTimerCap credits = false creditsCrossFade = 0 + bindTextTimer = 0 end -- Fade in/out of menu @@ -1507,6 +1597,8 @@ local function on_hud_render() djui_hud_render_rect(0, 0, width, height) end +local prevMouseScroll = 0 +local mouseScroll = 0 local function before_mario_update(m) if m.playerIndex ~= 0 then return end local controller = m.controller @@ -1533,55 +1625,12 @@ local function before_mario_update(m) return end + mouseScroll = mouseScroll + djui_hud_get_mouse_scroll_y() + local cameraToObject = m.marioObj.header.gfx.cameraToObject if menuAndTransition and not options then if menu then - if inputStallTimerDirectional == 0 and optionTable[optionTableRef.localModels].toggle ~= 0 and not charBeingSet then - if (controller.buttonPressed & D_JPAD) ~= 0 or (controller.buttonPressed & D_CBUTTONS) ~= 0 or controller.stickY < -60 then - currChar = currChar + 1 - local character = characterTable[currChar] - if character ~= nil and character.locked then - currChar = get_next_unlocked_char() - end - if (controller.buttonPressed & D_CBUTTONS) == 0 then - inputStallTimerDirectional = inputStallToDirectional - else - inputStallTimerDirectional = 3 -- C-Scrolling - end - if currChar > #characterTable then - buttonScroll = -buttonScrollCap * #characterTable - else - buttonScroll = buttonScrollCap - end - play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject) - if currChar > #characterTable then currChar = 1 end - if characterColorPresets[characterTable[currChar]] ~= nil then - characterColorPresets[characterTable[currChar]].currPalette = 0 - end - end - if (controller.buttonPressed & U_JPAD) ~= 0 or (controller.buttonPressed & U_CBUTTONS) ~= 0 or controller.stickY > 60 then - currChar = currChar - 1 - local character = characterTable[currChar] - if character ~= nil and character.locked then - currChar = get_last_unlocked_char() - end - if (controller.buttonPressed & U_CBUTTONS) == 0 then - inputStallTimerDirectional = inputStallToDirectional - else - inputStallTimerDirectional = 3 -- C-Scrolling - end - if currChar < 1 then - buttonScroll = buttonScrollCap * (#characterTable - 1) - else - buttonScroll = -buttonScrollCap - end - play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject) - if currChar < 1 then currChar = #characterTable end - if characterColorPresets[characterTable[currChar]] ~= nil then - characterColorPresets[characterTable[currChar]].currPalette = 0 - end - end - + if inputStallTimerDirectional == 0 and not charBeingSet then -- Alt switcher if #characterTable[currChar] > 1 then local character = characterTable[currChar] @@ -1600,6 +1649,83 @@ local function before_mario_update(m) if character.currAlt > #character then character.currAlt = 1 end if character.currAlt < 1 then character.currAlt = #character end end + + if optionTable[optionTableRef.localModels].toggle ~= 0 then + if (controller.buttonPressed & D_JPAD) ~= 0 or (controller.buttonPressed & D_CBUTTONS) ~= 0 or controller.stickY < -60 or prevMouseScroll < mouseScroll then + currCharRender = currCharRender + 1 + --[[ + local character = characterTableRender[currCharRender] + if character ~= nil and character.locked then + currCharRender = get_next_unlocked_char() + end + ]] + if (controller.buttonPressed & D_CBUTTONS) == 0 then + inputStallTimerDirectional = inputStallToDirectional + else + inputStallTimerDirectional = 3 -- C-Scrolling + end + if currCharRender > #characterTableRender then + buttonScroll = -buttonScrollCap * #characterTableRender + else + buttonScroll = buttonScrollCap + end + play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject) + if currCharRender > #characterTableRender then currCharRender = 1 end + currChar = characterTableRender[currCharRender].ogNum + if characterColorPresets[characterTable[currChar]] ~= nil then + characterColorPresets[characterTable[currChar]].currPalette = 0 + end + prevMouseScroll = mouseScroll + end + if (controller.buttonPressed & U_JPAD) ~= 0 or (controller.buttonPressed & U_CBUTTONS) ~= 0 or controller.stickY > 60 or prevMouseScroll > mouseScroll then + currCharRender = currCharRender - 1 + --[[ + local character = characterTableRender[currCharRender] + if character ~= nil and character.locked then + currCharRender = get_last_unlocked_char() + end + ]] + if (controller.buttonPressed & U_CBUTTONS) == 0 then + inputStallTimerDirectional = inputStallToDirectional + else + inputStallTimerDirectional = 3 -- C-Scrolling + end + if currCharRender < 1 then + buttonScroll = buttonScrollCap * (#characterTableRender - 1) + else + buttonScroll = -buttonScrollCap + end + play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject) + if currCharRender < 1 then currCharRender = #characterTableRender end + currChar = characterTableRender[currCharRender].ogNum + if characterColorPresets[characterTable[currChar]] ~= nil then + characterColorPresets[characterTable[currChar]].currPalette = 0 + end + prevMouseScroll = mouseScroll + end + + -- Tab Switcher + if (controller.buttonPressed & L_TRIG) ~= 0 then + local renderEmpty = true + while renderEmpty do + currCategory = currCategory - 1 + if currCategory < 1 then currCategory = #characterCategories end + renderEmpty = not update_character_render_table() + end + inputStallTimerDirectional = inputStallToDirectional + play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject) + end + if (controller.buttonPressed & R_TRIG) ~= 0 then + local renderEmpty = true + while renderEmpty do + currCategory = currCategory + 1 + if currCategory > #characterCategories then currCategory = 1 end + renderEmpty = not update_character_render_table() + end + inputStallTimerDirectional = inputStallToDirectional + play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject) + end + end end if inputStallTimerButton == 0 then @@ -1611,6 +1737,10 @@ local function before_mario_update(m) else play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject) end + + -- Set bottom right text + bindText = 1 + bindTextTimer = 1 end if (controller.buttonPressed & B_BUTTON) ~= 0 then menu = false @@ -1631,6 +1761,10 @@ local function before_mario_update(m) play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject) inputStallTimerButton = inputStallToButton end + + -- Set bottom right text + bindText = 2 + bindTextTimer = 1 end if characterColorPresets[gCSPlayers[0].modelId] ~= nil then if paletteCount < currPaletteTable.currPalette then currPaletteTable.currPalette = 0 end @@ -1764,7 +1898,9 @@ local function chat_command(msg) local saveName = string_underscore_to_space(string_lower(characterTable[i].saveName)) for a = 1, #characterTable[i] do if msg == string_lower(characterTable[i][a].name) or msg == saveName then + currCategory = 1 currChar = i + update_character_render_table() if msg ~= saveName then characterTable[i].currAlt = a end diff --git a/mods/character-select-coop/n-hud.lua b/mods/character-select-coop/n-hud.lua index e810ebdb7..96f5dc8d2 100644 --- a/mods/character-select-coop/n-hud.lua +++ b/mods/character-select-coop/n-hud.lua @@ -5,7 +5,7 @@ if incompatibleClient then return 0 end -- localize functions to improve performance - n-hud.lua -local hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math_ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open = hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math.ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open +local og_hud_get_value,og_hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math_ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open = hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math.ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open --[[ Some functions we need for the hud @@ -175,33 +175,66 @@ end -- Real HUD Stuffs -- --------------------- -local sHudElements = { - [HUD_DISPLAY_FLAG_LIVES] = true, - [HUD_DISPLAY_FLAG_STAR_COUNT] = true, - [HUD_DISPLAY_FLAG_CAMERA] = true -} +-- Modified Vanilla Functions -- +--[[ + These are `_G` on their own to replace vanilla functions +]] + +local sCharSelectHudDisplayFlags -- `local` because we aren't exposing this + +-- Here to make sure the flags are at the default state +hook_event(HOOK_UPDATE, function () + if not sCharSelectHudDisplayFlags or sCharSelectHudDisplayFlags == 0 then + sCharSelectHudDisplayFlags = og_hud_get_value(HUD_DISPLAY_FLAGS) | HUD_DISPLAY_DEFAULT + end +end) + +--- @param type HudDisplayValue +--- @return integer +function _G.hud_get_value(type) + if type == HUD_DISPLAY_FLAGS then + return sCharSelectHudDisplayFlags + else + return og_hud_get_value(type) + end +end + +--- @param type HudDisplayValue +--- @param value integer +--- Sets a HUD display value +function _G.hud_set_value(type, value) + if type == HUD_DISPLAY_FLAGS then + sCharSelectHudDisplayFlags = value + else + og_hud_set_value(type, value) + end +end + +-- Old CS Hud Functions -- ---Hides the specified custom hud element ---@param hudElement HUDDisplayFlag function hud_hide_element(hudElement) - if sHudElements[hudElement] == nil then return false end - sHudElements[hudElement] = false + --log_to_console("The `charSelect.hud_hide_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING) + hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~hudElement) return true end ---Shows the specified custom hud element ---@param hudElement HUDDisplayFlag function hud_show_element(hudElement) - if sHudElements[hudElement] == nil then return false end - sHudElements[hudElement] = true + --log_to_console("The `charSelect.hud_show_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING) + hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) | hudElement) return true end ---Gets the specified custom hud element's state ---@param hudElement HUDDisplayFlag +---@return boolean function hud_get_element(hudElement) - if sHudElements[hudElement] == nil then return false end - return sHudElements[hudElement] + --log_to_console("The `charSelect.hud_get_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING) + djui_chat_message_create(tostring(sCharSelectHudDisplayFlags)) + return (hud_get_value(HUD_DISPLAY_FLAGS) & hudElement) ~= 0 end local MATH_DIVIDE_16 = 1/16 @@ -299,6 +332,9 @@ function render_life_icon_from_local_index(localIndex, x, y, scale) end --- @param localIndex integer +--- @param prevX integer +--- @param prevY integer +--- @param prevScale integer --- @param x integer --- @param y integer --- @param scale integer @@ -341,6 +377,7 @@ function render_star_icon_from_local_index_interpolated(localIndex, prevX, prevY djui_hud_render_texture_interpolated(starIcon, prevX, prevY, prevScale / (starIcon.width * MATH_DIVIDE_16), prevScale / (starIcon.height * MATH_DIVIDE_16), x, y, scale / (starIcon.width * MATH_DIVIDE_16), scale / (starIcon.height * MATH_DIVIDE_16)) end +-- Health Meter -- local TEXT_DEFAULT_METER_PREFIX = "char-select-custom-meter-" local TEX_DEFAULT_METER_LEFT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."left") local TEX_DEFAULT_METER_RIGHT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."right") @@ -424,7 +461,7 @@ local pieTextureNames = { } local function render_hud_health() - if currChar == 1 then + if currChar == 1 and characterTable[1].currAlt == 1 then texture_override_reset("texture_power_meter_left_side") texture_override_reset("texture_power_meter_right_side") for i = 1, 8 do @@ -438,9 +475,9 @@ local function render_hud_health() texture_override_set("texture_power_meter_left_side", textureTable.label.left) texture_override_set("texture_power_meter_right_side", textureTable.label.right) end - for i = 1, 8 do - texture_override_set("texture_power_meter_" .. pieTextureNames[i], textureTable.pie[i]) - end + for i = 1, 8 do + texture_override_set("texture_power_meter_" .. pieTextureNames[i], (textureTable.pie and textureTable.pie[i]) and textureTable.pie[i] or defaultMeterInfo.pie[i]) + end else -- resets the health HUD texture_override_set("texture_power_meter_left_side", defaultMeterInfo.label.left) texture_override_set("texture_power_meter_right_side", defaultMeterInfo.label.right) @@ -469,9 +506,9 @@ local function render_hud_act_select_course() end local function render_hud_mario_lives() - hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES) + og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES) - if not hud_get_element(HUD_DISPLAY_FLAG_LIVES) then return end + if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_LIVES) == 0 then return end local x = 22 local y = 15 -- SCREEN_HEIGHT - 209 - 16 @@ -481,9 +518,9 @@ local function render_hud_mario_lives() end local function render_hud_stars() - hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT) + og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT) - if not hud_get_element(HUD_DISPLAY_FLAG_STAR_COUNT) then return end + if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_STAR_COUNT) == 0 then return end if hud_get_flash ~= nil then -- prevent star count from flashing outside of castle if gNetworkPlayers[0].currCourseNum ~= COURSE_NONE then hud_set_flash(0) end @@ -513,9 +550,9 @@ end local function render_hud_camera_status() if not HUD_DISPLAY_CAMERA_STATUS then return end - hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA) + og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA) - if not hud_get_element(HUD_DISPLAY_FLAG_CAMERA) then return end + if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_CAMERA) == 0 then return end local x = djui_hud_get_screen_width() - 54 local y = 205 diff --git a/mods/character-select-coop/o-api.lua b/mods/character-select-coop/o-api.lua index 4e1bef1bc..b939f5447 100644 --- a/mods/character-select-coop/o-api.lua +++ b/mods/character-select-coop/o-api.lua @@ -17,7 +17,9 @@ local table_insert,djui_hud_measure_text,smlua_model_util_get_id,type,tonumber = local characterVoices = {} local saveNameTable = {} -local E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo") +-- Here for functions below api +---@ignore +local function placeholder() end ---@ignore local function split_text_into_lines(text) @@ -48,7 +50,15 @@ local TYPE_TABLE = "table" local TYPE_TEX_INFO = "userdata" local TYPE_FUNCTION = "function" +------------------------- +-- Character Functions -- +------------------------- + +---@header +---@forcedoc Character_Functions + ---@description A function that adds a Character to the Character Table +---@added 1 ---@param name string|nil `"Custom Model"` ---@param description table|string|nil `{"string"}` ---@param credit string|nil `"You!"`, Credit the creators @@ -69,11 +79,14 @@ local function character_add(name, description, credit, color, modelInfo, forceC lifeIcon = lifeIcon:sub(1,1) end local addedModel = (modelInfo and modelInfo ~= E_MODEL_ERROR_MODEL) and modelInfo or E_MODEL_ARMATURE + local charNum = #characterTable + 1 table_insert(characterTable, { saveName = type(name) == TYPE_STRING and string_space_to_underscore(name) or "Untitled", currAlt = 1, hasMoveset = false, locked = false, + category = "All", + ogNum = charNum, [1] = { name = type(name) == TYPE_STRING and name or "Untitled", description = type(description) == TYPE_TABLE and description or {"No description has been provided"}, @@ -88,12 +101,13 @@ local function character_add(name, description, credit, color, modelInfo, forceC healthTexture = nil, }, }) - saveNameTable[#characterTable] = characterTable[#characterTable].saveName - characterMovesets[#characterTable] = {} - return #characterTable + saveNameTable[charNum] = characterTable[charNum].saveName + characterMovesets[charNum] = {} + return charNum end ---@description A function that adds a Costume to an Existing Character, all inputs mimic character_edit +---@added 1.11 ---@param charNum integer The number/table position of the Character you want to add a costume to ---@param name string|nil `"Custom Model"` ---@param description table|string|nil `{"string"}` @@ -134,6 +148,7 @@ local function character_add_costume(charNum, name, description, credit, color, end ---@description A function that Edits an existing Costume +---@added 1.11 ---@param charNum integer The number/table position of the Character you want to edit the costume of ---@param charAlt integer The number/table position of the Costume you want to edit, this can be found by making a variable equal ---@param name string|nil `"Custom Model"` @@ -171,13 +186,13 @@ local function character_edit_costume(charNum, charAlt, name, description, credi healthTexture = tableCache.healthTexture, } or nil - local ccp = characterColorPresets - if modelInfo ~= nil and ccp[modelInfo] ~= nil and ccp[tableCache.model] ~= nil and ccp[modelInfo].currPalette <= ccp[tableCache.model].currPalette then - ccp[modelInfo].currPalette = ccp[tableCache.model].currPalette + if modelInfo and characterColorPresets[modelInfo] and tableCache.model and characterColorPresets[tableCache.model] and #characterColorPresets[modelInfo] == #characterColorPresets[tableCache.model] then + characterColorPresets[modelInfo].currPalette = characterColorPresets[tableCache.model].currPalette end end ---@description A function that Edits an Existing Character +---@added 1 ---@param charNum integer The number/table position of the Character you want to edit ---@param name string|nil `"Custom Model"` ---@param description table|string|nil `{"string"}` @@ -188,40 +203,44 @@ end ---@param lifeIcon TextureInfo|string|nil Use get_texture_info ---@param camScale integer|nil Zooms the camera based on a multiplier (Default `1`) local function character_edit(charNum, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale) - character_edit_costume(charNum, 1, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale) + character_edit_costume(charNum, characterTable[charNum] and characterTable[charNum].currAlt or 1, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale) end ---@description A function that adds a voice table to a character +---@added 1.5 ---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id ---@param clips table A Table with your Character's Sound File Names +---@note In order for sound files to function, please run config_character_sounds in your pack +---@note +---@note Table Example: ---@note ```lua ---@note local VOICETABLE_CHAR = { ----@note [CHAR_SOUND_ATTACKED] = 'NES-Hit.ogg', ----@note [CHAR_SOUND_DOH] = 'NES-Bump.ogg', ----@note [CHAR_SOUND_DROWNING] = 'NES-Die.ogg', ----@note [CHAR_SOUND_DYING] = 'NES-Die.ogg', ----@note [CHAR_SOUND_GROUND_POUND_WAH] = 'NES-Squish.ogg', ----@note [CHAR_SOUND_HAHA] = 'NES-1up.ogg', ----@note [CHAR_SOUND_HAHA_2] = 'NES-1up.ogg', ----@note [CHAR_SOUND_HERE_WE_GO] = 'NES-Flagpole.ogg', ----@note [CHAR_SOUND_HOOHOO] = 'NES-Jump.ogg', ----@note [CHAR_SOUND_MAMA_MIA] = 'NES-Warp.ogg', ----@note [CHAR_SOUND_OKEY_DOKEY] = 'NES-1up.ogg', ----@note [CHAR_SOUND_ON_FIRE] = 'NES-Enemy_Fire.ogg', ----@note [CHAR_SOUND_OOOF] = 'NES-Hit.ogg', ----@note [CHAR_SOUND_OOOF2] = 'NES-Hit.ogg', ----@note [CHAR_SOUND_PUNCH_HOO] = 'NES-Kick.ogg', ----@note [CHAR_SOUND_PUNCH_WAH] = 'NES-Thwomp.ogg', ----@note [CHAR_SOUND_PUNCH_YAH] = 'NES-Thwomp.ogg', ----@note [CHAR_SOUND_SO_LONGA_BOWSER] = 'NES-Bowser_Die.ogg', ----@note [CHAR_SOUND_TWIRL_BOUNCE] = 'NES-Item.ogg', ----@note [CHAR_SOUND_WAAAOOOW] = 'NES-Vine.ogg', ----@note [CHAR_SOUND_WAH2] = 'NES-Kick.ogg', ----@note [CHAR_SOUND_WHOA] = 'NES-Item.ogg', ----@note [CHAR_SOUND_YAHOO] = 'NES-Jump.ogg', ----@note [CHAR_SOUND_YAHOO_WAHA_YIPPEE] = 'NES-Jump.ogg', ----@note [CHAR_SOUND_YAH_WAH_HOO] = 'NES-Big_Jump.ogg', ----@note [CHAR_SOUND_YAWNING] = 'NES-Pause.ogg', +---@note [CHAR_SOUND_ATTACKED] = 'NES-Hit.ogg', +---@note [CHAR_SOUND_DOH] = 'NES-Bump.ogg', +---@note [CHAR_SOUND_DROWNING] = 'NES-Die.ogg', +---@note [CHAR_SOUND_DYING] = 'NES-Die.ogg', +---@note [CHAR_SOUND_GROUND_POUND_WAH] = 'NES-Squish.ogg', +---@note [CHAR_SOUND_HAHA] = 'NES-1up.ogg', +---@note [CHAR_SOUND_HAHA_2] = 'NES-1up.ogg', +---@note [CHAR_SOUND_HERE_WE_GO] = 'NES-Flagpole.ogg', +---@note [CHAR_SOUND_HOOHOO] = 'NES-Jump.ogg', +---@note [CHAR_SOUND_MAMA_MIA] = 'NES-Warp.ogg', +---@note [CHAR_SOUND_OKEY_DOKEY] = 'NES-1up.ogg', +---@note [CHAR_SOUND_ON_FIRE] = 'NES-Enemy_Fire.ogg', +---@note [CHAR_SOUND_OOOF] = 'NES-Hit.ogg', +---@note [CHAR_SOUND_OOOF2] = 'NES-Hit.ogg', +---@note [CHAR_SOUND_PUNCH_HOO] = 'NES-Kick.ogg', +---@note [CHAR_SOUND_PUNCH_WAH] = 'NES-Thwomp.ogg', +---@note [CHAR_SOUND_PUNCH_YAH] = 'NES-Thwomp.ogg', +---@note [CHAR_SOUND_SO_LONGA_BOWSER] = 'NES-Bowser_Die.ogg', +---@note [CHAR_SOUND_TWIRL_BOUNCE] = 'NES-Item.ogg', +---@note [CHAR_SOUND_WAAAOOOW] = 'NES-Vine.ogg', +---@note [CHAR_SOUND_WAH2] = 'NES-Kick.ogg', +---@note [CHAR_SOUND_WHOA] = 'NES-Item.ogg', +---@note [CHAR_SOUND_YAHOO] = 'NES-Jump.ogg', +---@note [CHAR_SOUND_YAHOO_WAHA_YIPPEE] = 'NES-Jump.ogg', +---@note [CHAR_SOUND_YAH_WAH_HOO] = 'NES-Big_Jump.ogg', +---@note [CHAR_SOUND_YAWNING] = 'NES-Pause.ogg', ---@note } ---@note ``` local function character_add_voice(modelInfo, clips) @@ -229,14 +248,15 @@ local function character_add_voice(modelInfo, clips) end ---@description A function that adds a caps table to a character +---@added 1.6 ---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id ---@param caps table Cap ---@note ```lua ---@note local CAPTABLE_CHAR = { ----@note normal = smlua_model_util_get_id("custom_model_cap_normal_geo"), ----@note wing = smlua_model_util_get_id("custom_model_cap_wing_geo"), ----@note metal = smlua_model_util_get_id("custom_model_cap_metal_geo"), ----@note metalWing = smlua_model_util_get_id("custom_model_cap_wing_geo") +---@note normal = smlua_model_util_get_id("custom_model_cap_normal_geo"), +---@note wing = smlua_model_util_get_id("custom_model_cap_wing_geo"), +---@note metal = smlua_model_util_get_id("custom_model_cap_metal_geo"), +---@note metalWing = smlua_model_util_get_id("custom_model_cap_wing_geo") ---@note } ---@note ``` local function character_add_caps(modelInfo, caps) @@ -244,13 +264,15 @@ local function character_add_caps(modelInfo, caps) end ---@description A function that gets a model's cap table +---@added 1.13 ---@param modelInfo ModelExtendedId|integer|nil Model Information Received from smlua_model_util_get_id local function character_get_caps(modelInfo) if modelInfo == nil then modelInfo = characterTable[currChar][characterTable[currChar].currAlt].model end return characterCaps[modelInfo] end ----@description A function that adds health meter textures to a character +---@description A function that adds health meter textures to a costume +---@added 1.12 ---@param charNum integer The number/table position of the Character you want to add a meter to ---@param charAlt integer The number/table position of the Costume you want to add a meter to ---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown in character_add_health_meter) @@ -261,6 +283,7 @@ local function character_add_costume_health_meter(charNum, charAlt, healthTextur end ---@description A function that adds health meter textures to a character +---@added 1.9 ---@param charNum integer The number/table position of the Character you want to add a meter to ---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown Below) ---@note ```lua @@ -281,29 +304,37 @@ end ---@note } ---@note } ---@note ``` ----@note This method is restricted to the default meter format, you can refer to the Disassembled sections in the image below for how to format your health meter (Spriters Resource Page) ----@note