From 44e32f8bf253165a4cb3d9cbd2f12a52949c322e Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Tue, 24 Dec 2024 18:32:50 -0500 Subject: [PATCH] Star Road code overhaul --- mods/star-road/bhv_dupes.lua | 250 +++++++++++++++++-------------- mods/star-road/bhv_overrides.lua | 106 +++++++------ mods/star-road/course.lua | 4 +- mods/star-road/dialog.lua | 22 +-- mods/star-road/hardcoded.lua | 3 + mods/star-road/hardmode.lua | 104 ++++++------- mods/star-road/helpers.lua | 116 +++----------- mods/star-road/main.lua | 186 +++++++++++------------ 8 files changed, 363 insertions(+), 428 deletions(-) diff --git a/mods/star-road/bhv_dupes.lua b/mods/star-road/bhv_dupes.lua index 0dd77b161..03b6afd7d 100644 --- a/mods/star-road/bhv_dupes.lua +++ b/mods/star-road/bhv_dupes.lua @@ -1,71 +1,79 @@ --- We use this instead of o->oHiddenStarLastInteractedObject. -oHiddenStarLastInteractedPlayer = nil +E_MODEL_VCUTM_LIGHT = smlua_model_util_get_id("vcutm_light_geo") +COL_WF_SMALL_BOMP = smlua_collision_util_get("wf_seg7_collision_small_bomp") -function bhv_custom_hidden_star_trigger_init(obj) - network_init_object(obj, true, { 'activeFlags', 'oInteractStatus' }) +-- we use this instead of o->oHiddenStarLastInteractedObject +local oHiddenStarLastInteractedPlayer = nil + +--- @param o Object +function bhv_custom_hidden_star_trigger_init(o) + network_init_object(o, true, { "activeFlags", "oInteractStatus" }) end -function bhv_custom_hidden_star_trigger_loop(obj) - if not ((obj.oInteractStatus & INT_STATUS_INTERACTED) == 0) or obj_check_if_collided_with_object(obj, gMarioStates[0].marioObj) == 1 then - local hiddenStar = obj_get_nearest_object_with_behavior_id(obj, bhvSMSRHiddenStar) - if not (hiddenStar == nil) then - local count = (obj_count_objects_with_behavior_id(bhvSMSRHiddenStarTrigger) - 1) +--- @param o Object +function bhv_custom_hidden_star_trigger_loop(o) + if (o.oInteractStatus & INT_STATUS_INTERACTED) ~= 0 or obj_check_if_collided_with_object(o, gMarioStates[0].marioObj) ~= 0 then + local hiddenStar = obj_get_nearest_object_with_behavior_id(o, bhvSMSRHiddenStar) + if hiddenStar ~= nil then + local count = obj_count_objects_with_behavior_id(bhvSMSRHiddenStarTrigger) - 1 hiddenStar.oHiddenStarTriggerCounter = 5 - count - if not (hiddenStar.oHiddenStarTriggerCounter == 5) then + if hiddenStar.oHiddenStarTriggerCounter ~= 5 then spawn_orange_number(hiddenStar.oHiddenStarTriggerCounter, 0, 0, 0) end - -- Set the last person who interacted with a secret to the - -- parent so only they get the star cutscene. - player = nearest_mario_state_to_object(obj) - if not (player == nil) then + -- set the last person who interacted with a secret to the parent so only they get the star cutscene + player = nearest_mario_state_to_object(o) + if player ~= nil then oHiddenStarLastInteractedPlayer = player end cur_obj_play_sound_2(SOUND_MENU_COLLECT_SECRET + ((hiddenStar.oHiddenStarTriggerCounter - 1) << 16)) end - obj.activeFlags = ACTIVE_FLAG_DEACTIVATED + o.activeFlags = ACTIVE_FLAG_DEACTIVATED end end -------------- -function bhv_custom_hidden_star_init(obj) +--- @param o Object +function bhv_custom_hidden_star_init(o) local count = obj_count_objects_with_behavior_id(bhvSMSRHiddenStarTrigger) if count == 0 then - local star = spawn_object_abs_with_rot(obj, 0, E_MODEL_STAR, id_bhvStar, obj.oPosX, obj.oPosY, obj.oPosZ, 0, 0, 0) - if not (star == nil) then - star.oBehParams = obj.oBehParams + local star = spawn_object_abs_with_rot(o, 0, E_MODEL_STAR, id_bhvStar, o.oPosX, o.oPosY, o.oPosZ, 0, 0, 0) + if star ~= nil then + star.oBehParams = o.oBehParams end - obj.activeFlags = ACTIVE_FLAG_DEACTIVATED + o.activeFlags = ACTIVE_FLAG_DEACTIVATED end - obj.oHiddenStarTriggerCounter = 5 - count + o.oHiddenStarTriggerCounter = 5 - count - -- We haven't interacted with a player yet. + -- we haven't interacted with a player yet. -- We also don't sync this as not only is it not required -- but it also is only set for an interaction. -- Therefore this object must already be loaded for it to be set -- and if it wasn't. You couldn't of possibly been the one - -- who last interacted to begin with. + -- who last interacted to begin with + -- + -- coding™ oHiddenStarLastInteractedPlayer = nil - network_init_object(obj, false, { 'oAction', 'oHiddenStarTriggerCounter', 'oPosX', 'oPosY', 'oPosZ', 'oTimer' }) + network_init_object(o, false, { "oAction", "oHiddenStarTriggerCounter", "oPosX", "oPosY", "oPosZ", "oTimer" }) end -function bhv_custom_hidden_star_loop(obj) - switch(obj.oAction, { - [0] = function() -- for case 0 - if obj.oHiddenStarTriggerCounter == 5 then - obj.oAction = 1 +--- @param o Object +function bhv_custom_hidden_star_loop(o) + switch(o.oAction, { + [0] = function() -- for case 0 + if o.oHiddenStarTriggerCounter == 5 then + o.oAction = 1 end end, - [1] = function() -- for case 1 - if obj.oTimer > 2 then - star = spawn_red_coin_cutscene_star(obj.oPosX, obj.oPosY, obj.oPosZ) + [1] = function() -- for case 1 + if o.oTimer > 2 then + star = spawn_red_coin_cutscene_star(o.oPosX, o.oPosY, o.oPosZ) if not (star == nil) then if oHiddenStarLastInteractedPlayer == gMarioStates[0] then star.oStarSpawnExtCutsceneFlags = 1 @@ -74,7 +82,7 @@ function bhv_custom_hidden_star_loop(obj) end spawn_mist_particles() end - obj.activeFlags = ACTIVE_FLAG_DEACTIVATED + o.activeFlags = ACTIVE_FLAG_DEACTIVATED end end, }) @@ -82,195 +90,217 @@ end -------------- -function bhv_breakable_rock_init(obj) - network_init_object(obj, false, nil) +--- @param o Object +function bhv_breakable_rock_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_breakable_window_init(obj) - obj.collisionData = smlua_collision_util_get("wf_seg7_collision_small_bomp") - network_init_object(obj, false, { 'oFlags', 'oInteractStatus' }); +--- @param o Object +function bhv_breakable_window_init(o) + o.collisionData = COL_WF_SMALL_BOMP + network_init_object(o, false, { "oFlags", "oInteractStatus" }) end -function bhv_breakable_window_loop(obj) - if not (obj.oInteractStatus & INT_STATUS_INTERACTED) or not (obj.oInteractStatus & INT_STATUS_WAS_ATTACKED) then +--- @param o Object +function bhv_breakable_window_loop(o) + if (o.oInteractStatus & INT_STATUS_INTERACTED) == 0 or (o.oInteractStatus & INT_STATUS_WAS_ATTACKED) == 0 then return end - if not (check_local_mario_attacking(obj) == 0) then + if check_local_mario_attacking(o) ~= 0 then obj_explode_and_spawn_coins(80, 0) - create_sound_spawner(obj, SOUND_GENERAL_WALL_EXPLOSION) + create_sound_spawner(SOUND_GENERAL_WALL_EXPLOSION) - obj.oInteractStatus = 0; + o.oInteractStatus = 0 end end -------------- -function bhv_star_replica_init(obj) - despawn_if_stars_below_count(obj, 121) -- 121 star check +--- @param o Object +function bhv_star_replica_init(o) + despawn_if_stars_below_count(o, 121) -- 121 star check end -------------- -function bhv_red_sinking_platform_init(obj) +--- @param o Object +function bhv_red_sinking_platform_init(o) cur_obj_set_home_once() - network_init_object(obj, true, { 'oSinkWhenSteppedOnUnk104', 'oGraphYOffset', 'oHomeY' }) + network_init_object(o, true, { "oSinkWhenSteppedOnUnk104", "oGraphYOffset", "oHomeY" }) end -------------- -function bhv_star_door_wall_loop(obj) +--- @param o Object +function bhv_star_door_wall_loop(o) if get_star_count() >= 30 then - obj.activeFlags = ACTIVE_FLAG_DEACTIVATED + o.activeFlags = ACTIVE_FLAG_DEACTIVATED end end -------------- -function bhv_special_breakable_box_init(obj) - despawn_if_stars_below_count(obj, 121) -- 121 star check - network_init_object(obj, false, nil); +--- @param o Object +function bhv_special_breakable_box_init(o) + despawn_if_stars_below_count(o, 121) -- 121 star check + network_init_object(o, false, nil) end -------------- -function bhv_piranha_plant_wild_loop(obj) +-- why even make an init function +function bhv_piranha_plant_wild_loop() end -------------- -function bhv_big_leaves_init(obj) +-- why even make an init function +function bhv_big_leaves_init() end -------------- -function bhv_lily_pad_init(obj) - network_init_object(obj, true, { 'oSinkWhenSteppedOnUnk104', 'oGraphYOffset', 'oHomeY' }) +--- @param o Object +function bhv_lily_pad_init(o) + network_init_object(o, true, { "oSinkWhenSteppedOnUnk104", "oGraphYOffset", "oHomeY" }) end -------------- -function bhv_tambourine_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_tambourine_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_small_bee_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_small_bee_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_star_moving_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_star_moving_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_falling_domino_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_falling_domino_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_lava_lift_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_lava_lift_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_rotating_lava_platform_init(obj) - network_init_object(obj, false, nil); +--- @param o Object +function bhv_rotating_lava_platform_init(o) + network_init_object(o, false, nil) end -------------- -function bhv_sinking_donut_init(obj) - network_init_object(obj, true, { 'oSinkWhenSteppedOnUnk104', 'oGraphYOffset', 'oHomeY' }) +--- @param o Object +function bhv_sinking_donut_init(o) + network_init_object(o, true, { "oSinkWhenSteppedOnUnk104", "oGraphYOffset", "oHomeY" }) end -function bhv_sinking_donut_loop(obj) - sinking_perform_sink_check(obj) - sinking_perform_sink_check(obj) -- called twice +--- @param o Object +function bhv_sinking_donut_loop(o) + sinking_perform_sink_check(o) + sinking_perform_sink_check(o) -- called twice end -------------- -function bhv_floating_thwomp_init(obj) - network_init_object(obj, true, { 'oHomeX', 'oHomeY', 'oHomeZ', 'oAction', 'oPosX', 'oPosY', 'oPosZ', 'oVelX', 'oVelY', 'oVelZ' }) +--- @param o Object +function bhv_floating_thwomp_init(o) + network_init_object(o, true, { "oHomeX", "oHomeY", "oHomeZ", "oAction", "oPosX", "oPosY", "oPosZ", "oVelX", "oVelY", "oVelZ" }) end -------------- -function bhv_toxic_waste_platform_init(obj) - network_init_object(obj, true, { 'oSinkWhenSteppedOnUnk104', 'oGraphYOffset', 'oHomeY' }) +--- @param o Object +function bhv_toxic_waste_platform_init(o) + network_init_object(o, true, { "oSinkWhenSteppedOnUnk104", "oGraphYOffset", "oHomeY" }) end -function bhv_toxic_waste_platform_loop(obj) - sinking_perform_sink_check(obj) +--- @param o Object +function bhv_toxic_waste_platform_loop(o) + sinking_perform_sink_check(o) end -------------- -function bhv_pushable_tomb_init(obj) - network_init_object(obj, true, { 'oPosX', 'oPosY', 'oPosZ' }) +--- @param o Object +function bhv_pushable_tomb_init(o) + network_init_object(o, true, { "oPosX", "oPosY", "oPosZ" }) end -------------- -E_MODEL_VCUTM_LIGHT = smlua_model_util_get_id("vcutm_light_geo") +--- @param o Object +function bhv_lights_on_switch_init(o) + o.parentObj = cur_obj_nearest_object_with_behavior(get_behavior_from_id(id_bhvFloorSwitchAnimatesObject)) + obj_set_model_extended(o, E_MODEL_VCUTM_LIGHT) -function bhv_lights_on_switch_init(obj) - obj.parentObj = cur_obj_nearest_object_with_behavior(get_behavior_from_id(id_bhvFloorSwitchAnimatesObject)); - obj_set_model_extended(obj, E_MODEL_VCUTM_LIGHT) - - network_init_object(obj, true, { 'oFloorSwitchPressAnimationUnkF4', 'oFloorSwitchPressAnimationUnkF8', 'oFloorSwitchPressAnimationUnkFC' }) + network_init_object(o, true, { "oFloorSwitchPressAnimationUnkF4", "oFloorSwitchPressAnimationUnkF8", "oFloorSwitchPressAnimationUnkFC" }) end -function bhv_lights_on_switch_loop(obj) - if obj.oFloorSwitchPressAnimationUnk100 ~= 0 then - if obj.parentObj ~= nil and obj.parentObj.oAction ~= 2 then - obj.oFloorSwitchPressAnimationUnk100 = 0 +--- @param o Object +function bhv_lights_on_switch_loop(o) + if o.oFloorSwitchPressAnimationUnk100 ~= 0 then + if o.parentObj ~= nil and o.parentObj.oAction ~= 2 then + o.oFloorSwitchPressAnimationUnk100 = 0 end - if obj.oFloorSwitchPressAnimationUnkFC ~= 0 then - if obj.oBehParams2ndByte >= 0 and obj.oBehParams2ndByte <= 2 then - obj.oFloorSwitchPressAnimationUnkF4 = 200 + if o.oFloorSwitchPressAnimationUnkFC ~= 0 then + if o.oBehParams2ndByte >= 0 and o.oBehParams2ndByte <= 2 then + o.oFloorSwitchPressAnimationUnkF4 = 200 end else - obj.oFloorSwitchPressAnimationUnkF4 = 0 + o.oFloorSwitchPressAnimationUnkF4 = 0 end - elseif obj.parentObj ~= nil and obj.parentObj.oAction == 2 then - obj.oFloorSwitchPressAnimationUnkFC = obj.oFloorSwitchPressAnimationUnkFC ~ 1 - obj.oFloorSwitchPressAnimationUnk100 = 1 + elseif o.parentObj ~= nil and o.parentObj.oAction == 2 then + o.oFloorSwitchPressAnimationUnkFC = o.oFloorSwitchPressAnimationUnkFC ~ 1 + o.oFloorSwitchPressAnimationUnk100 = 1 end - if obj.oFloorSwitchPressAnimationUnkF4 ~= 0 then - if obj.oFloorSwitchPressAnimationUnkF4 < 60 then + if o.oFloorSwitchPressAnimationUnkF4 ~= 0 then + if o.oFloorSwitchPressAnimationUnkF4 < 60 then cur_obj_play_sound_1(SOUND_GENERAL2_SWITCH_TICK_SLOW) else cur_obj_play_sound_1(SOUND_GENERAL2_SWITCH_TICK_FAST) end - obj.oFloorSwitchPressAnimationUnkF4 = obj.oFloorSwitchPressAnimationUnkF4 - 1 - if obj.oFloorSwitchPressAnimationUnkF4 == 0 then - obj.oFloorSwitchPressAnimationUnkFC = 0 + o.oFloorSwitchPressAnimationUnkF4 = o.oFloorSwitchPressAnimationUnkF4 - 1 + if o.oFloorSwitchPressAnimationUnkF4 == 0 then + o.oFloorSwitchPressAnimationUnkFC = 0 end - if obj.oFloorSwitchPressAnimationUnkF8 < 9 then - obj.oFloorSwitchPressAnimationUnkF8 = obj.oFloorSwitchPressAnimationUnkF8 + 1 + if o.oFloorSwitchPressAnimationUnkF8 < 9 then + o.oFloorSwitchPressAnimationUnkF8 = o.oFloorSwitchPressAnimationUnkF8 + 1 end else - obj.oFloorSwitchPressAnimationUnkF8 = obj.oFloorSwitchPressAnimationUnkF8 - 2 - if obj.oFloorSwitchPressAnimationUnkF8 < 0 then - obj.oFloorSwitchPressAnimationUnkF8 = 0 - obj.oFloorSwitchPressAnimationUnkFC = 1 + o.oFloorSwitchPressAnimationUnkF8 = o.oFloorSwitchPressAnimationUnkF8 - 2 + if o.oFloorSwitchPressAnimationUnkF8 < 0 then + o.oFloorSwitchPressAnimationUnkF8 = 0 + o.oFloorSwitchPressAnimationUnkFC = 1 end end - local fType = math.floor(obj.oFloorSwitchPressAnimationUnkF8 / 2) + local fType = math.floor(o.oFloorSwitchPressAnimationUnkF8 / 2) if fType == 0 then cur_obj_hide() else diff --git a/mods/star-road/bhv_overrides.lua b/mods/star-road/bhv_overrides.lua index 687ee61f2..8394d1021 100644 --- a/mods/star-road/bhv_overrides.lua +++ b/mods/star-road/bhv_overrides.lua @@ -1,103 +1,119 @@ -function bhv_custom_koopa_the_quick_loop(obj) - if obj.oKoopaMovementType >= KOOPA_BP_KOOPA_THE_QUICK_BASE then +--- @param o Object +local function bhv_custom_koopa_the_quick_loop(o) + if o.oKoopaMovementType >= KOOPA_BP_KOOPA_THE_QUICK_BASE then if gNetworkPlayers[0].currLevelNum == 27 then - obj.oKoopaTheQuickRaceIndex = 1 + o.oKoopaTheQuickRaceIndex = 1 else - obj.oKoopaTheQuickRaceIndex = 0 + o.oKoopaTheQuickRaceIndex = 0 end end end --- hook the behavior -bhvKoopa = hook_behavior(id_bhvKoopa, OBJ_LIST_PUSHABLE, false, nil, bhv_custom_koopa_the_quick_loop) +id_bhvKoopa = hook_behavior(id_bhvKoopa, OBJ_LIST_PUSHABLE, false, nil, bhv_custom_koopa_the_quick_loop, "bhvKoopa") --------------------------------------------------- -function bhv_custom_castle_cannon_grate_init(obj) - obj.oFlags = (OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE) - obj.collisionData = smlua_collision_util_get("castle_grounds_seg7_collision_cannon_grill") - obj.oCollisionDistance = 4000 +--- @param o Object +local function bhv_custom_castle_cannon_grate_init(o) + o.oFlags = (OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE) + o.collisionData = smlua_collision_util_get("castle_grounds_seg7_collision_cannon_grill") + o.oCollisionDistance = 4000 load_object_collision_model() - if get_star_count() > 64 then -- 65 star check - obj.activeFlags = ACTIVE_FLAG_DEACTIVATED + if get_star_count() >= 65 then -- 65 star check + o.activeFlags = ACTIVE_FLAG_DEACTIVATED end end -function bhv_custom_castle_cannon_grate_loop(obj) +local function bhv_custom_castle_cannon_grate_loop() load_object_collision_model() end --- hook the behavior -bhvSMSRHiddenAt120Stars = hook_behavior(id_bhvHiddenAt120Stars, OBJ_LIST_SURFACE, true, bhv_custom_castle_cannon_grate_init, bhv_custom_castle_cannon_grate_loop) +id_bhvSMSRHiddenAt120Stars = hook_behavior(id_bhvHiddenAt120Stars, OBJ_LIST_SURFACE, true, bhv_custom_castle_cannon_grate_init, bhv_custom_castle_cannon_grate_loop, "bhvSMSRHiddenAt120Stars") --------------------------------------------------- -function bully_custom_act_level_death(obj) +local function bully_custom_act_level_death(o) if obj_lava_death() == 1 then spawn_mist_particles() - local m = get_mario_from_global_index(obj.oBullyLastNetworkPlayerIndex) - spawn_non_sync_object(id_bhvBowserKey, E_MODEL_BOWSER_KEY, m.pos.x, m.pos.y, m.pos.z, nil) + local m = get_mario_from_global_index(o.oBullyLastNetworkPlayerIndex) + spawn_non_sync_object( + id_bhvBowserKey, + E_MODEL_BOWSER_KEY, + m.pos.x, m.pos.y, m.pos.z, + nil + ) end end -function bhv_custom_big_bully_init(obj) - obj.oFlags = (OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE) - obj.oAnimations = gObjectAnimations.bully_seg5_anims_0500470C - object_drop_to_floor(obj) +local function bhv_custom_big_bully_init(o) + o.oFlags = (OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE) + o.oAnimations = gObjectAnimations.bully_seg5_anims_0500470C + object_drop_to_floor(o) cur_obj_set_home_once() - obj.oIntangibleTimer = 0 + o.oIntangibleTimer = 0 cur_obj_init_animation(0) bhv_big_bully_init() end -function bhv_custom_bully_loop(obj) - if obj.oAction == BULLY_ACT_LAVA_DEATH then - obj.oBullyPrevX = obj.oPosX - obj.oBullyPrevY = obj.oPosY - obj.oBullyPrevZ = obj.oPosZ +local function bhv_custom_big_bully_loop(o) + if o.oAction == BULLY_ACT_LAVA_DEATH then + o.oBullyPrevX = o.oPosX + o.oBullyPrevY = o.oPosY + o.oBullyPrevZ = o.oPosZ - bully_custom_act_level_death(obj) + bully_custom_act_level_death(o) - set_object_visibility(obj, 3000) + set_object_visibility(o, 3000) else bhv_bully_loop() end end --- hook the behavior -bhvBigBullyBoss = hook_behavior(id_bhvBigBully, OBJ_LIST_GENACTOR, true, bhv_custom_big_bully_init, bhv_custom_bully_loop) +id_bhvBigBully = hook_behavior(id_bhvBigBully, OBJ_LIST_GENACTOR, true, bhv_custom_big_bully_init, bhv_custom_big_bully_loop, "bhvBigBully") --------------------------------------------------- -function bhv_custom_bowser_loop(obj) +--- @param o Object +local function bhv_custom_bowser_loop(o) local np = gNetworkPlayers[0] if np.currAreaSyncValid and np.currLevelSyncValid and np.currLevelNum ~= LEVEL_BOWSER_3 then -- force bowser into do nothing action when not displaying cutscene - if obj.oAction ~= 5 and obj.oAction ~= 6 and obj.oAction ~= 20 then - obj.oAction = 4 - obj.oSubAction = 11 + -- magic number hell + if o.oAction ~= 5 and o.oAction ~= 6 and o.oAction ~= 20 then + o.oAction = 4 + o.oSubAction = 11 end end end --- hook the behavior -id_bhvBowserCustom = hook_behavior(id_bhvBowser, OBJ_LIST_GENACTOR, false, nil, bhv_custom_bowser_loop) +id_bhvBowser = hook_behavior(id_bhvBowser, OBJ_LIST_GENACTOR, false, nil, bhv_custom_bowser_loop, "bhvBowser") --------------------------------------------------- -function bhv_custom_grand_star_init(obj) - obj.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE - obj.oInteractType = INTERACT_WARP - obj.oIntangibleTimer = 0 +--- @param o Object +local function bhv_custom_grand_star_init(o) + o.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE + o.oInteractType = INTERACT_WARP + o.oIntangibleTimer = 0 cur_obj_set_home_once() end -function bhv_custom_grand_star_loop(obj) +local function bhv_custom_grand_star_loop() bhv_warp_loop() bhv_grand_star_loop() end --- hook the behavior -id_bhvGrandStar = hook_behavior(id_bhvGrandStar, OBJ_LIST_LEVEL, true, bhv_custom_grand_star_init, bhv_custom_grand_star_loop) +id_bhvGrandStar = hook_behavior(id_bhvGrandStar, OBJ_LIST_LEVEL, true, bhv_custom_grand_star_init, bhv_custom_grand_star_loop, "bhvGrandStar") + +--------------------------------------------------- + +--- @param o Object +local function bhv_custom_racing_penguin_update(o) + if o.oRacingPenguinReachedBottom == 1 then + o.oRacingPenguinWeightedNewTargetSpeed = 10 + end +end + +id_bhvRacingPenguin = hook_behavior(id_bhvRacingPenguin, OBJ_LIST_GENACTOR, false, nil, bhv_custom_racing_penguin_update, "bhvRacingPenguin") diff --git a/mods/star-road/course.lua b/mods/star-road/course.lua index 5cd3bfd46..1eefd3ba2 100644 --- a/mods/star-road/course.lua +++ b/mods/star-road/course.lua @@ -27,9 +27,9 @@ smlua_text_utils_secret_star_replace(COURSE_CAKE_END, " SECRET STARS") smlua_text_utils_castle_secret_stars_replace(" SECRET STARS") smlua_text_utils_extra_text_replace(0, "ONE OF THE SECRET STARS!") -smlua_text_utils_extra_text_replace(1, "TEST") +smlua_text_utils_extra_text_replace(1, "") smlua_text_utils_extra_text_replace(2, "") smlua_text_utils_extra_text_replace(3, "") smlua_text_utils_extra_text_replace(4, "") smlua_text_utils_extra_text_replace(5, "") -smlua_text_utils_extra_text_replace(6, "") +smlua_text_utils_extra_text_replace(6, "") \ No newline at end of file diff --git a/mods/star-road/dialog.lua b/mods/star-road/dialog.lua index 423c32a5e..89b9a66cc 100644 --- a/mods/star-road/dialog.lua +++ b/mods/star-road/dialog.lua @@ -1,8 +1,3 @@ -changed_dialogs = {} - - - - smlua_text_utils_dialog_replace(DIALOG_000, 1, 6, 30, 200, "--WARNING--\ FLOOR UNSTABLE. DO NOT\ GROUND-POUND UNDER \ @@ -1610,7 +1605,6 @@ their houses!") smlua_text_utils_dialog_replace(DIALOG_168, 1, 5, 30, 200, "Ack! Stop it or I'll\ make you stop!") -changed_dialogs[169] = 1 smlua_text_utils_dialog_replace(DIALOG_169, 1, 6, 30, 200, "Psst! Looking for\ a challenge? Try pressing\ [R] after pausing the\ @@ -1621,14 +1615,11 @@ SMSR veterans, try holding\ the L Button before you\ host a lobby with 'Super\ Mario Star Road' as the\ -active romhack! ") - - +active romhack!") function dialog_replace() if gGlobalSyncTable.hardMode then - changed_dialogs[169] = 1 -- thank you Emmi for being so cool and having this in MarioHunt so I could remember how to change dialog this way -smlua_text_utils_dialog_replace(DIALOG_169, 1, 4, 30, 200, "Welcome to HARD MODE!\ + smlua_text_utils_dialog_replace(DIALOG_169, 1, 4, 30, 200, "Welcome to HARD MODE!\ This challenge mode is an\ OHKO, which means that\ everything-- and I mean\ @@ -1637,8 +1628,7 @@ one hit! Do you have what\ it takes to complete this\ challenge?") else - changed_dialogs[169] = 1 -smlua_text_utils_dialog_replace(DIALOG_169, 1, 6, 30, 200, "Psst! Looking for\ + smlua_text_utils_dialog_replace(DIALOG_169, 1, 6, 30, 200, "Psst! Looking for\ a challenge? Try pressing\ [R] after pausing the\ game, and select the\ @@ -1648,10 +1638,8 @@ SMSR veterans, try holding\ the L Button before you\ host a lobby with 'Super\ Mario Star Road' as the\ -active romhack! ") +active romhack!") end end - - -hook_event(HOOK_ON_DIALOG, dialog_replace) +hook_event(HOOK_ON_DIALOG, dialog_replace) \ No newline at end of file diff --git a/mods/star-road/hardcoded.lua b/mods/star-road/hardcoded.lua index 798bd5b6d..991f5e1e0 100644 --- a/mods/star-road/hardcoded.lua +++ b/mods/star-road/hardcoded.lua @@ -21,6 +21,9 @@ gLevelValues.vanishCapDurationVcutm = 900 gLevelValues.wingCapLookUpReq = 120 +gLevelValues.fixCollisionBugs = true +gLevelValues.vanishCapSequence = 0x32 + -- Replace Stars starPositions = gLevelValues.starPositions diff --git a/mods/star-road/hardmode.lua b/mods/star-road/hardmode.lua index 54041db4b..c594626f8 100644 --- a/mods/star-road/hardmode.lua +++ b/mods/star-road/hardmode.lua @@ -1,24 +1,14 @@ -gGlobalSyncTable.hardMode = false - -function on_level_init() - local m = gMarioStates[0] - local np = gNetworkPlayers[0] - if gGlobalSyncTable.hardMode then - gMarioStates[0].numStars = save_file_get_total_star_count(get_current_save_file_num() - 1, COURSE_MIN - 1, - COURSE_MAX - 1) - gLevelValues.exitCastleArea = gNetworkPlayers[0].currAreaIndex - end -end - -burnActions = { --Accounting for when you are on fire since that type of damage is handled differently. +local sBurnActions = { --Accounting for when you are on fire since that type of damage is handled differently. [ACT_BURNING_FALL] = true, [ACT_BURNING_GROUND] = true, [ACT_BURNING_JUMP] = true } -seenPopup = false + local frameCounter = 10 -local function mario_update(m) - if m.playerIndex ~= 0 then return end +local seenPopup = false + +--- @param m MarioState +function mario_update_hardmode(m) if network_is_server() and frameCounter > 0 then if m.controller.buttonDown & L_TRIG ~= 0 then gGlobalSyncTable.hardMode = true -- Starts up "Hard Mode" on Hack Boot. Hold the L button within 10 frames of loading Star Road to activate it. @@ -30,7 +20,9 @@ local function mario_update(m) end frameCounter = frameCounter - 1 end + if not gGlobalSyncTable.hardMode then return end + if not seenPopup and not network_is_server() then save_file_set_using_backup_slot(gGlobalSyncTable.hardMode) save_file_reload(1) @@ -38,60 +30,56 @@ local function mario_update(m) play_sound(SOUND_MENU_MARIO_CASTLE_WARP + 1 << 0, { x = 0, y = 0, z = 0 }) seenPopup = true end - if m.hurtCounter > 0 or burnActions[m.action] then - m.hurtCounter = 64 -- Damage Check. Hard Mode is a OHKO mode. - m.healCounter = 0 -- Prevents you from healing from a coin or any health regen object via landing on one while dying. + + if m.hurtCounter > 0 or sBurnActions[m.action] then + m.hurtCounter = 64 -- Damage Check. Hard Mode is a OHKO mode + m.healCounter = 0 -- Prevents you from healing from a coin or any health regen object via landing on one while dying end - if not gGlobalSyncTable.hardMode then return false end end + ---@param m MarioState -function air(m) - if gGlobalSyncTable.hardMode then - if m.action & ACT_GROUP_MASK == ACT_GROUP_SUBMERGED and m.area.terrainType ~= TERRAIN_SNOW then - change = (m.pos.y < m.waterLevel - 140 and 1 or -0x1A) - m.health = m.health + change - end +function before_mario_update_hardmode(m) + if not gGlobalSyncTable.hardMode then return end + + if m.action & ACT_GROUP_MASK == ACT_GROUP_SUBMERGED and m.area.terrainType ~= TERRAIN_SNOW then + change = (m.pos.y < m.waterLevel - 140 and 1 or -0x1A) + m.health = m.health + change end end -function hard_mode_menu(_, value) - gGlobalSyncTable.hardMode = value - save_file_set_using_backup_slot(gGlobalSyncTable.hardMode) - save_file_reload(1) - djui_popup_create(value and "\\#ff0000\\HARD MODE\\#dcdcdc\\ Activated" or "You are currently in NORMAL MODE.", 1) - play_sound(SOUND_MENU_MARIO_CASTLE_WARP, { x = 0, y = 0, z = 0 }) - warp_to_warpnode(LEVEL_CASTLE_GROUNDS, 1, 0, 128) +function on_level_init_hardmode() + if gGlobalSyncTable.hardMode then + gMarioStates[0].numStars = save_file_get_total_star_count(get_current_save_file_num() - 1, COURSE_MIN - 1, + COURSE_MAX - 1) + gLevelValues.exitCastleArea = gNetworkPlayers[0].currAreaIndex + end end -function dialog_box_colors(id) - if changed_dialogs[id] and gGlobalSyncTable.hardMode then -- red dialog box (Thank you again Emmi) +function on_hud_render_hardmode() + if not is_game_paused() or not gGlobalSyncTable.hardMode then return end + + djui_hud_set_resolution(RESOLUTION_N64) + djui_hud_set_font(FONT_HUD) + + djui_hud_set_color(255, 255, 255, 255) + local height = djui_hud_get_screen_height() + djui_hud_print_text("HARD MODE", 10, height - 30, 1) +end + +function on_dialog_hardmode(dialogID) + if dialogID == DIALOG_169 and gGlobalSyncTable.hardMode then -- red dialog box (Thank you again Emmi) set_dialog_override_color(255, 100, 100, 180, 255, 255, 255, 255) else reset_dialog_override_color() end end -if network_is_server() then - hook_mod_menu_checkbox("Hard Mode", gGlobalSyncTable.hardMode, hard_mode_menu) -end -local function menu_hud_render() - if is_game_paused() and gGlobalSyncTable.hardMode then - djui_hud_set_font(FONT_CUSTOM_HUD) - djui_hud_set_color(0xdc, 0xdc, 0xdc, 255) - local height = djui_hud_get_screen_height() - djui_hud_print_text("Hard Mode", 40, height - 130, 4) - end -end --- Main loop -local function hud_render() - djui_hud_set_resolution(RESOLUTION_DJUI) - menu_hud_render() -end - - -hook_event(HOOK_ON_HUD_RENDER, hud_render) -hook_event(HOOK_ON_DIALOG, dialog_box_colors) -hook_event(HOOK_ON_LEVEL_INIT, on_level_init) -hook_event(HOOK_MARIO_UPDATE, mario_update) -hook_event(HOOK_BEFORE_MARIO_UPDATE, air) +function hard_mode_menu(_, value) + gGlobalSyncTable.hardMode = value + save_file_set_using_backup_slot(gGlobalSyncTable.hardMode) + save_file_reload(1) + djui_popup_create(value and "\\#ff0000\\HARD MODE\\#dcdcdc\\ enabled." or "\\#ff0000\\HARD MODE\\#dcdcdc\\ disabled.", 1) + play_sound(SOUND_MENU_MARIO_CASTLE_WARP, { x = 0, y = 0, z = 0 }) + warp_to_start_level() +end \ No newline at end of file diff --git a/mods/star-road/helpers.lua b/mods/star-road/helpers.lua index 86cf31598..e9786f59c 100644 --- a/mods/star-road/helpers.lua +++ b/mods/star-road/helpers.lua @@ -1,16 +1,15 @@ -_G.switch = function(param, case_table) - local case = case_table[param] +--- @param caseTable table +function switch(param, caseTable) + local case = caseTable[param] if case then return case() end - local def = case_table['default'] + local def = caseTable['default'] return def and def() or nil end -------------- function get_star_count() - local courseMax = 25 - local courseMin = 1 - return save_file_get_total_star_count(get_current_save_file_num() - 1, courseMin - 1, courseMax - 1) + return save_file_get_total_star_count(get_current_save_file_num() - 1, COURSE_MIN - 1, COURSE_MAX - 1) end function despawn_if_stars_below_count(obj, count) @@ -27,13 +26,12 @@ function get_mario_from_global_index(index) return marioState end end - + return gMarioStates[0] end function check_mario_attacking(obj, mario) local marioObject = mario.marioObj - if not (obj_check_if_collided_with_object(obj, marioObject) == 0) then if abs_angle_diff(obj.oMoveAngleYaw, marioObject.oMoveAngleYaw) > 0x6000 then if mario.action == ACT_SLIDE_KICK then @@ -68,7 +66,7 @@ end -- Replacement for lll_octagonal_mesh_find_y_offset() function find_y_offset_for_sinking_platform(obj, sinkOffset, a3) - if not (cur_obj_is_any_player_on_platform() == 0) then + if not (cur_obj_is_any_player_on_platform() == 0) then if obj.oSinkWhenSteppedOnUnk104 < 0x4000 then obj.oSinkWhenSteppedOnUnk104 = obj.oSinkWhenSteppedOnUnk104 + sinkOffset else @@ -81,7 +79,7 @@ function find_y_offset_for_sinking_platform(obj, sinkOffset, a3) obj.oSinkWhenSteppedOnUnk104 = 0 end end - + local yOffset = sins(obj.oSinkWhenSteppedOnUnk104) * a3 return yOffset end @@ -89,105 +87,25 @@ end -- Replacement for bhv_lll_sinking_rock_block_loop() function sinking_perform_sink_check(obj) local yOffset = find_y_offset_for_sinking_platform(obj, 124, -110) - + obj.oGraphYOffset = 0 obj.oPosY = obj.oHomeY + yOffset end --- Replacement for native create_sound_spawner() -function create_sound_spawner(obj, soundId) - local soundObj = spawn_non_sync_object(id_bhvSoundSpawner, 0, 0, 0, 0, nil); - if soundObj == nil then - return - end - obj_copy_pos_and_angle(soundObj, obj) - soundObj.oSoundEffectUnkF4 = soundId -end - -- Replacement for spawn_object_abs_with_rot() -function spawn_object_abs_with_rot(parent, uselessArg, modelId, bhvId, x, y, z, rx, ry, rz) - local childObj = spawn_non_sync_object(bhvId, modelId, 0, 0, 0, nil); +function spawn_object_abs_with_rot(parent, _, modelId, bhvId, x, y, z, rx, ry, rz) + local childObj = spawn_non_sync_object(bhvId, modelId, 0, 0, 0, nil) if childObj == nil then return nil end - + childObj.parentObj = parent childObj.header.gfx.areaIndex = parent.header.gfx.areaIndex childObj.header.gfx.activeAreaIndex = parent.header.gfx.areaIndex childObj.globalPlayerIndex = 0 - - obj_set_pos(childObj, x, y, z); - obj_set_angle(childObj, rx, ry, rz); - + + obj_set_pos(childObj, x, y, z) + obj_set_angle(childObj, rx, ry, rz) + return childObj -end - -function spawn_sync_object_abs_with_rot(parent, uselessArg, modelId, bhvId, x, y, z, rx, ry, rz) - local childObj = spawn_sync_object(bhvId, modelId, 0, 0, 0, nil); - if childObj == nil then - return nil - end - - childObj.parentObj = parent - childObj.header.gfx.areaIndex = parent.header.gfx.areaIndex - childObj.header.gfx.activeAreaIndex = parent.header.gfx.areaIndex - childObj.globalPlayerIndex = 0 - - obj_set_pos(childObj, x, y, z); - obj_set_angle(childObj, rx, ry, rz); - - return childObj -end - --------------- - --- Replacement for SET_HOME() -function object_set_home(obj) - obj.oHomeX = obj.oPosX; - obj.oHomeY = obj.oPosY; - obj.oHomeZ = obj.oPosZ; -end - --- Replacement for SET_OBJ_PHYSICS() -function object_set_physics(obj, hitboxRadius, gravity, bounciness, dragStrength, friction, buoyancy) - obj.oWallHitboxRadius = hitboxRadius; - obj.oGravity = gravity / 100; - obj.oBounciness = bounciness / 100; - obj.oDragStrength = dragStrength / 100; - obj.oFriction = friction / 100; - obj.oBuoyancy = buoyancy / 100; -end - --- Replacement for DROP_TO_FLOOR() -function object_drop_to_floor(obj) - local x = obj.oPosX; - local y = obj.oPosY; - local z = obj.oPosZ; - - local floorHeight = find_floor_height(x, y + 200, z); - obj.oPosY = floorHeight; - obj.oMoveFlags = (obj.oMoveFlags | OBJ_MOVE_ON_GROUND); -end - --- Replacement for SPAWN_CHILD_WITH_PARAM() -function spawn_child_with_param(obj, bhvParam, modelId, bhvId) - local childObj = spawn_non_sync_object(bhvId, modelId, 0, 0, 0, nil); - if childObj == nil then - --print("Failed to spawn child object with parameters.") - return nil - end - obj_copy_pos_and_angle(childObj, obj) - childObj.oBehParams2ndByte = bhvParam; - return childObj -end - -function spawn_sync_child_with_param(obj, bhvParam, modelId, bhvId) - local childObj = spawn_sync_object(bhvId, modelId, 0, 0, 0, nil); - if childObj == nil then - --print("Failed to spawn synced child object with parameters.") - return nil - end - obj_copy_pos_and_angle(childObj, obj) - childObj.oBehParams2ndByte = bhvParam; - return childObj -end +end \ No newline at end of file diff --git a/mods/star-road/main.lua b/mods/star-road/main.lua index bb9a10f8b..94fb4c0d5 100644 --- a/mods/star-road/main.lua +++ b/mods/star-road/main.lua @@ -1,61 +1,93 @@ --- name: Star Road Dev --- description: Romhack created by \\#FFD700\\SKELUX\\#DCDCDC\\\n\nwww.youtube.com/c/Skelux\n\nThere are 23 custom levels, with a total of 130 stars.\n\nPorted to PC by AloXado320,\n\\#FFAAFF\\PeachyPeach\\#DCDCDC\\, and \\#8C4AC7\\PrinceFrizzy\\#DCDCDC\\\n\nPorted to coop by \\#093614\\djoslin0\\#DCDCDC\\,\n\\#8C4AC7\\PrinceFrizzy\\#DCDCDC\\, and \\#141699\\Isaac\\#DCDCDC\\.\n\nAdditional Fixes and "\\#FF0000\\Hard Mode\\#DCDCDC\\" addition by \\#2D851C\\Mr.Needlemouse\\#DCDCDC\\. +-- name: Star Road -- incompatible: romhack +-- description: Star Road\nRomhack created by \\#ffd700\\SKELUX\\#dcdcdc\\\n\nwww.youtube.com/c/Skelux\n\nThere are 23 custom levels, with a total of 130 stars.\n\nPorted to PC by AloXado320,\n\\#ffaaff\\PeachyPeach\\#dcdcdc\\, and \\#8c4ac7\\PrinceFrizzy\\#dcdcdc\\\n\nPorted to coop by \\#093614\\djoslin0\\#dcdcdc\\,\n\\#8c4ac7\\PrinceFrizzy\\#dcdcdc\\, and \\#141699\\Isaac\\#dcdcdc\\.\n\nAdditional Fixes and "\\#ff0000\\Hard Mode\\#dcdcdc\\" addition by \\#2D851C\\Mr.Needlemouse\\#dcdcdc\\. --------------- --- movtexs -- --------------- +LEVEL_ZERO_LIFE = level_register("level_zerolife_entry", COURSE_NONE, "ZERO LIFE", "zl", 28000, 0x28, 0x28, 0x28) -movtexqc_register('bbh_1_Movtex_0', LEVEL_BBH, 1, 0) -movtexqc_register('ccm_1_Movtex_0', LEVEL_CCM, 1, 0) -movtexqc_register('hmc_1_Movtex_0', LEVEL_HMC, 1, 0) -movtexqc_register('ssl_1_Movtex_0', LEVEL_SSL, 1, 0) -movtexqc_register('bob_1_Movtex_0', LEVEL_BOB, 1, 0) -movtexqc_register('sl_1_Movtex_0', LEVEL_SL, 1, 0) -movtexqc_register('jrb_1_Movtex_0', LEVEL_JRB, 1, 0) -movtexqc_register('castle_grounds_1_Movtex_0', LEVEL_CASTLE_GROUNDS, 1, 0) -movtexqc_register('lll_1_Movtex_0', LEVEL_LLL, 1, 0) -movtexqc_register('wf_1_Movtex_0', LEVEL_WF, 1, 0) -movtexqc_register('ending_1_Movtex_0', LEVEL_ENDING, 1, 0) -movtexqc_register('castle_courtyard_1_Movtex_0', LEVEL_CASTLE_COURTYARD, 1, 0) -movtexqc_register('pss_1_Movtex_0', LEVEL_PSS, 1, 0) -movtexqc_register('cotmc_1_Movtex_0', LEVEL_COTMC, 1, 0) -movtexqc_register('totwc_1_Movtex_0', LEVEL_TOTWC, 1, 0) -movtexqc_register('wmotr_1_Movtex_0', LEVEL_WMOTR, 1, 0) +gGlobalSyncTable.hardMode = false ------------------- --- extra levels -- ------------------- +local startingLives = false +local zeroLife = false -LEVEL_ZERO_LIFE = level_register('level_zerolife_entry', COURSE_NONE, 'ZERO LIFE', 'zl', 28000, 0x28, 0x28, 0x28) +local function mario_update(m) + if m.playerIndex ~= 0 then return end ---------------------------- --- race character speed-- ---------------------------- ---- @param o Object -function bhv_tuxierace_init(o) - if o.oRacingPenguinReachedBottom == 1 then - o.oRacingPenguinWeightedNewTargetSpeed = 10 + if not startingLives then + m.numLives = 3 + startingLives = true + end + + if zeroLife then + warp_to_level(LEVEL_ZERO_LIFE, 1, 0) + zeroLife = false + startingLives = true + end + + mario_update_hardmode(m) +end + +local function before_mario_update(m) + before_mario_update_hardmode(m) +end + +local function on_hud_render() + on_hud_render_hardmode() +end + +-- 130 stars castle grounds music +local function on_warp() + if get_star_count() >= 130 and gNetworkPlayers[0].currLevelNum == LEVEL_CASTLE_GROUNDS then + play_music(SEQ_PLAYER_LEVEL, 0x2F, 1) end end -hook_behavior(id_bhvRacingPenguin, OBJ_LIST_GENACTOR, false, nil, bhv_tuxierace_init, "bhvRacingPenguin") +local function on_level_init() + on_warp() + on_level_init_hardmode() +end ---------------------------- --- force server settings -- ---------------------------- +local function on_death() + --- @type MarioState + local m = gMarioStates[0] + if m.numLives < 0 then + zeroLife = true + m.numLives = 3 + end +end + +local function on_screen_transition(transitionType) + local m = gMarioStates[0] + if m.numLives < 0 and transitionType == WARP_TRANSITION_FADE_INTO_BOWSER then + zeroLife = true + m.numLives = 3 + end +end + +local function on_dialog(dialogID) + on_dialog_hardmode(dialogID) +end -gLevelValues.fixCollisionBugs = true -gLevelValues.vanishCapSequence = 0x32 gServerSettings.skipIntro = 1 ------------ --- music -- ------------ - --- These have a custom entry in the Star road sequences.json patch. But aren't actually ripped. ---smlua_audio_utils_replace_sequence(0x01, 0x22, 80, "01_Seq_smsrdeluxe_custom") -- SEQ_EVENT_CUTSCENE_COLLECT_STAR +movtexqc_register('bbh_1_Movtex_0', LEVEL_BBH, 1, 0) +movtexqc_register('ccm_1_Movtex_0', LEVEL_CCM, 1, 0) +movtexqc_register('hmc_1_Movtex_0', LEVEL_HMC, 1, 0) +movtexqc_register('ssl_1_Movtex_0', LEVEL_SSL, 1, 0) +movtexqc_register('bob_1_Movtex_0', LEVEL_BOB, 1, 0) +movtexqc_register('sl_1_Movtex_0', LEVEL_SL, 1, 0) +movtexqc_register('jrb_1_Movtex_0', LEVEL_JRB, 1, 0) +movtexqc_register('castle_grounds_1_Movtex_0', LEVEL_CASTLE_GROUNDS, 1, 0) +movtexqc_register('lll_1_Movtex_0', LEVEL_LLL, 1, 0) +movtexqc_register('wf_1_Movtex_0', LEVEL_WF, 1, 0) +movtexqc_register('ending_1_Movtex_0', LEVEL_ENDING, 1, 0) +movtexqc_register('castle_courtyard_1_Movtex_0', LEVEL_CASTLE_COURTYARD, 1, 0) +movtexqc_register('pss_1_Movtex_0', LEVEL_PSS, 1, 0) +movtexqc_register('cotmc_1_Movtex_0', LEVEL_COTMC, 1, 0) +movtexqc_register('totwc_1_Movtex_0', LEVEL_TOTWC, 1, 0) +movtexqc_register('wmotr_1_Movtex_0', LEVEL_WMOTR, 1, 0) +-- these have a custom entry in the Star road sequences.json patch. But aren't actually ripped +-- smlua_audio_utils_replace_sequence(0x01, 0x22, 80, "01_Seq_smsrdeluxe_custom") -- SEQ_EVENT_CUTSCENE_COLLECT_STAR smlua_audio_utils_replace_sequence(0x02, 0x25, 80, "02_Seq_smsrdeluxe_custom") -- SEQ_MENU_TITLE_SCREEN smlua_audio_utils_replace_sequence(0x03, 0x25, 75, "03_Seq_smsrdeluxe_custom") -- SEQ_LEVEL_GRASS smlua_audio_utils_replace_sequence(0x04, 0x25, 70, "04_Seq_smsrdeluxe_custom") -- SEQ_LEVEL_INSIDE_CASTLE @@ -88,8 +120,7 @@ smlua_audio_utils_replace_sequence(0x1F, 0x25, 80, "1F_Seq_smsrdeluxe_custom") - smlua_audio_utils_replace_sequence(0x20, 0x25, 70, "20_Seq_smsrdeluxe_custom") -- SEQ_EVENT_CUTSCENE_ENDING smlua_audio_utils_replace_sequence(0x21, 0x25, 65, "21_Seq_smsrdeluxe_custom") -- SEQ_MENU_FILE_SELECT smlua_audio_utils_replace_sequence(0x22, 0x11, 80, "22_Seq_smsrdeluxe_custom") -- SEQ_EVENT_CUTSCENE_LAKITU - --- TODO: See if we can figure out the original volumes for the things below this point. +-- TODO: See if we can figure out the original volumes for the things below this point smlua_audio_utils_replace_sequence(0x23, 0x25, 80, "23_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x24, 0x11, 70, "24_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x25, 0x25, 85, "25_Seq_smsrdeluxe_custom") @@ -100,8 +131,7 @@ smlua_audio_utils_replace_sequence(0x29, 0x25, 70, "29_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x2A, 0x11, 80, "2A_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x2B, 0x1B, 80, "2B_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x2C, 0x25, 70, "2C_Seq_smsrdeluxe_custom") - --- We don't know the correct instruments for these. +-- we don't know the correct instruments for these smlua_audio_utils_replace_sequence(0x2D, 0x25, 75, "2D_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x2E, 0x12, 80, "2E_Seq_smsrdeluxe_custom") -- Final Boss Music smlua_audio_utils_replace_sequence(0x2F, 0x25, 70, "2F_Seq_smsrdeluxe_custom") @@ -109,56 +139,18 @@ smlua_audio_utils_replace_sequence(0x30, 0x25, 65, "30_Seq_smsrdeluxe_custom") - smlua_audio_utils_replace_sequence(0x31, 0x25, 80, "31_Seq_smsrdeluxe_custom") smlua_audio_utils_replace_sequence(0x32, 0x25, 80, "32_Seq_smsrdeluxe_custom") ------------- --- camera -- ------------- camera_set_romhack_override(RCO_ALL_EXCEPT_BOWSER) camera_set_use_course_specific_settings(false) -------------------------- --- zero life checks -- -------------------------- +hook_event(HOOK_MARIO_UPDATE, mario_update) +hook_event(HOOK_BEFORE_MARIO_UPDATE, before_mario_update) +hook_event(HOOK_ON_HUD_RENDER, on_hud_render) +hook_event(HOOK_ON_LEVEL_INIT, on_level_init) +hook_event(HOOK_ON_WARP, on_warp) +hook_event(HOOK_ON_DEATH, on_death) +hook_event(HOOK_ON_SCREEN_TRANSITION, on_screen_transition) +hook_event(HOOK_ON_DIALOG, on_dialog) -local zerolife = false -function on_death(transitionType) - local m = gMarioStates[0] - if m.numLives < 0 and transitionType == WARP_TRANSITION_FADE_INTO_BOWSER then - zerolife = true - m.numLives = 3 - end -end - -function void_death() - local m = gMarioStates[0] - if m.numLives < 0 then - zerolife = true - m.numLives = 3 - end -end - -local startingLives = true -local function lives(m) - if m.playerIndex ~= 0 then return end - if startingLives then - m.numLives = 3 - startingLives = false - end - if zerolife then - warp_to_level(LEVEL_ZERO_LIFE, 1, 0) - zerolife = false - startingLives = true - end -end - -function on_warp_and_init() -- 130 stars castle grounds music - local m = gMarioStates[0] - if m.numStars >= 130 and gNetworkPlayers[0].currLevelNum == LEVEL_CASTLE_GROUNDS then - play_music(0, 0x2F, 1) - end -end - -hook_event(HOOK_ON_SCREEN_TRANSITION, on_death) -hook_event(HOOK_ON_LEVEL_INIT, on_warp_and_init) -hook_event(HOOK_ON_WARP, on_warp_and_init) -hook_event(HOOK_MARIO_UPDATE, lives) -hook_event(HOOK_ON_DEATH, void_death) +if network_is_server() then + hook_mod_menu_checkbox("Hard Mode", gGlobalSyncTable.hardMode, hard_mode_menu) +end \ No newline at end of file