-- name: \\#00BEFF\\Tiny QoL \\#E7E7E7\\Pack -- description: Adds some QoL features to make the gameplay a bit more enjoyable. \nMade by ExploxionMach -- category: qol local qolFeatures = { coyoteTime = true, starHeal = true, longerMetalVanish = true, betterLanding = true, assBurn = true, deathSaver = true, } local function toggle_coyote_time(index, value) qolFeatures.coyoteTime = value end local function toggle_star_heal(index, value) qolFeatures.starHeal = value end local function toggle_longer_metal_and_vanish(index, value) qolFeatures.longerMetalVanish = value end local function toggle_better_landing(index, value) qolFeatures.betterLanding = value end local function toggle_ass_burn(index, value) qolFeatures.assBurn = value end local function toggle_death_saver(index, value) qolFeatures.deathSaver = value end local coyoteTimeVars = {} local function get_coyote_time_vars(i) if not coyoteTimeVars[i] then coyoteTimeVars[i] = {frames = 0, start = true, wasFloorSteep = false, cant = false} end return coyoteTimeVars[i] end local coyoteTimeActs = { [ACT_FREEFALL] = true, [ACT_HOLD_FREEFALL] = true, [ACT_BURNING_FALL] = true, [ACT_BUTT_SLIDE_AIR] = true } local function coyote_time(m) local i = m.playerIndex local c = get_coyote_time_vars(i) if not qolFeatures.coyoteTime then return end if m.action & ACT_FLAG_AIR == 0 then c.frames = 0 c.start = true if mario_floor_is_steep(m) ~= 0 then c.wasFloorSteep = true else c.wasFloorSteep = false end if m.floor.normal.y < 0.95 then c.cant = true else c.cant = false end end if c.frames > 0 then c.frames = c.frames - 1 if m.controller.buttonPressed & A_BUTTON ~= 0 and c.cant == false then if m.prevAction == ACT_IDLE or m.prevAction == ACT_WALKING or m.prevAction == ACT_BRAKING or m.prevAction == ACT_DECELERATING or m.prevAction == ACT_AIR_THROW_LAND then if c.wasFloorSteep == true then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_JUMP, 0) end end if m.prevAction == ACT_HOLD_IDLE or m.prevAction == ACT_HOLD_WALK or m.prevAction == ACT_HOLD_JUMP_LAND or m.prevAction == ACT_HOLD_FREEFALL_LAND then set_mario_action(m, ACT_HOLD_JUMP, 0) end if m.prevAction == ACT_BURNING_GROUND then set_mario_action(m, ACT_BURNING_JUMP, 0) end if m.prevAction == ACT_CROUCHING or m.prevAction == ACT_START_CROUCHING then if c.wasFloorSteep == true then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_BACKFLIP, 0) end end if m.prevAction == ACT_TURNING_AROUND or m.prevAction == ACT_FINISH_TURNING_AROUND then if c.wasFloorSteep == true then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_SIDE_FLIP, 0) end end if m.prevAction == ACT_JUMP_LAND or m.prevAction == ACT_FREEFALL_LAND or m.prevAction == ACT_SIDE_FLIP_LAND then if c.wasFloorSteep == true then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_DOUBLE_JUMP, 0) end end if m.prevAction == ACT_DOUBLE_JUMP_LAND then if m.forwardVel > 20 then if (m.flags & MARIO_WING_CAP) ~= 0 then set_mario_action(m, ACT_FLYING_TRIPLE_JUMP, 0) else set_mario_action(m, ACT_TRIPLE_JUMP, 0) end else if c.wasFloorSteep == true then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_JUMP, 0) end end end if m.prevAction == ACT_LONG_JUMP_LAND and m.input & INPUT_Z_DOWN ~= 0 and m.forwardVel > 11 then set_mario_action(m, ACT_LONG_JUMP, 0) end if m.prevAction == ACT_CROUCH_SLIDE then if m.forwardVel > 11 then set_mario_action(m, ACT_LONG_JUMP, 0) else set_mario_action(m, ACT_JUMP, 0) end end if m.prevAction == ACT_BUTT_SLIDE then if m.forwardVel < 0 then set_mario_action(m, ACT_STEEP_JUMP, 0) else set_mario_action(m, ACT_JUMP, 0) end end if (m.prevAction == ACT_DIVE_SLIDE or m.prevAction == ACT_STOMACH_SLIDE or m.prevAction == ACT_SLIDE_KICK_SLIDE) and c.wasFloorSteep == false then if m.forwardVel < 0 then set_mario_action(m, ACT_BACKWARD_ROLLOUT, 0) else set_mario_action(m, ACT_FORWARD_ROLLOUT, 0) end end c.frames = 0 end end if c.start == true and m.action & ACT_FLAG_AIR ~= 0 then if coyoteTimeActs[m.action] then c.frames = 5 end c.start = false end end local function star_heal(m, o, interactType) if not qolFeatures.starHeal then return end if interactType == INTERACT_STAR_OR_KEY and m.health ~= 0x000 then m.healCounter = 28 end end local hadMetalVanish = {} local function longer_metal_and_vanish(m) local i = m.playerIndex if not qolFeatures.longerMetalVanish then return end if (m.flags & MARIO_METAL_CAP ~= 0 or m.flags & MARIO_VANISH_CAP ~= 0) and not hadMetalVanish[i] then hadMetalVanish[i] = true m.capTimer = m.capTimer * 2 elseif m.flags & MARIO_METAL_CAP == 0 and m.flags & MARIO_VANISH_CAP == 0 then hadMetalVanish[i] = false end end local metalLandActs = { [ACT_TRIPLE_JUMP_LAND] = true, [ACT_BACKFLIP_LAND] = true, [ACT_BACKFLIP_LAND_STOP] = true, [ACT_HOLD_METAL_WATER_JUMP_LAND] = true } local cantJumpLandActs = { [ACT_METAL_WATER_FALL_LAND] = true, [ACT_HOLD_METAL_WATER_FALL_LAND] = true, [ACT_METAL_WATER_JUMP_LAND] = true, [ACT_HOLD_METAL_WATER_JUMP_LAND] = true } local function better_landing(m) local i = m.playerIndex if not qolFeatures.betterLanding then return end if m.action == ACT_JUMP_LAND or m.action == ACT_LONG_JUMP_LAND or m.action == ACT_FREEFALL_LAND or m.action == ACT_DOUBLE_JUMP_LAND or m.action == ACT_SIDE_FLIP_LAND or m.action == ACT_HOLD_JUMP_LAND or m.action == ACT_HOLD_FREEFALL_LAND or m.action == ACT_TRIPLE_JUMP_LAND or m.action == ACT_BACKFLIP_LAND or m.action == ACT_JUMP_LAND_STOP or m.action == ACT_LONG_JUMP_LAND_STOP or m.action == ACT_FREEFALL_LAND_STOP or m.action == ACT_DOUBLE_JUMP_LAND_STOP or m.action == ACT_SIDE_FLIP_LAND_STOP or m.action == ACT_HOLD_JUMP_LAND_STOP or m.action == ACT_HOLD_FREEFALL_LAND_STOP or m.action == ACT_TRIPLE_JUMP_LAND_STOP or m.action == ACT_BACKFLIP_LAND_STOP or metalLandActs[m.action] then if (m.forwardVel < 0 or (metalLandActs[m.action] and m.forwardVel < 2)) and analog_stick_held_back(m) ~= 0 and not (m.action == ACT_LONG_JUMP_LAND or m.action == ACT_LONG_JUMP_LAND_STOP) then m.forwardVel = -m.forwardVel m.faceAngle.y = m.faceAngle.y + 0x8000 end if check_ground_dive_or_punch(m) ~= 0 then return 1 end if m.input & INPUT_Z_DOWN ~= 0 and not metalLandActs[m.action] then if (m.forwardVel < -4 and not (m.action == ACT_LONG_JUMP_LAND or m.action == ACT_LONG_JUMP_LAND_STOP)) or m.forwardVel > 4 then set_mario_action(m, ACT_CROUCH_SLIDE, 0) mario_drop_held_object(m) else if not (m.action == ACT_LONG_JUMP_LAND or m.action == ACT_LONG_JUMP_LAND_STOP) then set_mario_action(m, ACT_START_CROUCHING, 0) mario_drop_held_object(m) end end end end end local function less_annoying_ass_burn(m) if not qolFeatures.assBurn then return end if m.action == ACT_BURNING_JUMP or m.action == ACT_BURNING_GROUND or m.action == ACT_BURNING_FALL then set_mario_action(m, ACT_LAVA_BOOST, 0) m.hurtCounter = 12 m.vel.y = m.vel.y * 0.5 end end -- Big ass code for one feature local ACT_VOID_FADE = allocate_mario_action(ACT_GROUP_CUTSCENE | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) local ACT_SKY_DROP = allocate_mario_action(ACT_GROUP_CUTSCENE | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) local sandSurfaces = { [SURFACE_INSTANT_QUICKSAND] = true, [SURFACE_INSTANT_MOVING_QUICKSAND] = true, [SURFACE_DEEP_QUICKSAND] = true, [SURFACE_DEEP_MOVING_QUICKSAND] = true, [SURFACE_SHALLOW_QUICKSAND] = true, [SURFACE_SHALLOW_MOVING_QUICKSAND] = true, [SURFACE_QUICKSAND] = true, [SURFACE_MOVING_QUICKSAND] = true } local saverVars = {history = {}, lastPos = nil, frame = 0, lastRescue = -9999, target = nil, offset = 0, vel = 0, timer = 0, anim = nil, cooldown = 0, lastLevel = -1, lastArea = -1, camFrozen = false, opacityDirty = false} local function clear_safe_pos() saverVars.history = {} saverVars.lastPos = nil end local function reset_saver_vars() saverVars.target = nil saverVars.offset = 0 saverVars.vel = 0 saverVars.timer = 0 saverVars.anim = nil end local function unfreeze_saver_camera() if saverVars.camFrozen == true then camera_unfreeze() saverVars.camFrozen = false end end local ALPHA_FLAG = MODEL_STATE_ALPHA or 0x100 local function set_saver_alpha(m, alpha) alpha = math.floor(math.max(0, math.min(255, alpha))) m.marioBodyState.modelState = ALPHA_FLAG | alpha m.marioObj.oOpacity = alpha saverVars.opacityDirty = true end local function set_saver_model_pos(m, yOffset) local g = m.marioObj.header.gfx g.pos.x = m.pos.x g.pos.y = m.pos.y + yOffset g.pos.z = m.pos.z g.angle.x = 0 g.angle.y = m.faceAngle.y g.angle.z = 0 end local function start_sky_drop(m) local t = saverVars.target m.pos.x = t.x m.pos.y = t.y m.pos.z = t.z m.vel.x = 0 m.vel.z = 0 m.forwardVel = 0 m.quicksandDepth = 0 m.squishTimer = 0 saverVars.offset = 1800 m.vel.y = 0 saverVars.vel = 0 unfreeze_saver_camera() set_mario_action(m, ACT_SKY_DROP, 0) set_saver_model_pos(m, saverVars.offset) set_saver_alpha(m, 0) end local function is_spot_safe(x, y, z) local radii = {30, 70} for _, r in ipairs(radii) do for i = 0, 7 do local ang = i * 0x2000 local px = x + sins(ang) * r local pz = z + coss(ang) * r local h, f = find_floor(px, y + 100, pz) if f == nil or h == nil or h < y - 350 then return false end if sandSurfaces[f.type] or f.type == SURFACE_DEATH_PLANE or f.type == SURFACE_BURNING or f.type == SURFACE_VERTICAL_WIND then return false end end end return true end local function begin_rescue(m, hazard) local s = saverVars if s.frame - s.lastRescue < 300 and #s.history > 1 then table.remove(s.history) end s.lastRescue = s.frame local p = s.history[#s.history] s.target = {x = p.x, y = p.y, z = p.z, yaw = p.yaw} s.timer = 0 s.offset = 0 s.vel = 0 s.cooldown = 45 if hazard == 1 then s.anim = m.marioObj.header.gfx.animInfo.animID set_mario_action(m, ACT_VOID_FADE, 0) camera_freeze() s.camFrozen = true else start_sky_drop(m) local cam = m.area.camera cam.cutscene = 0 soft_reset_camera(cam) set_camera_mode(cam, cam.defMode, 1) end end local function act_void_fade(m) if saverVars.target == nil then unfreeze_saver_camera() set_mario_action(m, ACT_IDLE, 0) return end if saverVars.anim ~= nil then set_mario_animation(m, saverVars.anim) end m.vel.y = math.max(m.vel.y - 4, -75) m.vel.x = m.vel.x * 0.97 m.vel.z = m.vel.z * 0.97 m.pos.x = m.pos.x + m.vel.x m.pos.y = m.pos.y + m.vel.y m.pos.z = m.pos.z + m.vel.z saverVars.timer = saverVars.timer + 1 set_saver_model_pos(m, 0) set_saver_alpha(m, 255 * (1 - saverVars.timer / 25)) if saverVars.timer >= 25 then start_sky_drop(m) end end local function act_sky_drop(m) if saverVars.target == nil then set_mario_action(m, ACT_IDLE, 0) return end set_mario_animation(m, MARIO_ANIM_GENERAL_FALL) local t = saverVars.target m.pos.x = t.x m.pos.y = t.y m.pos.z = t.z m.vel.x = 0 m.vel.y = 0 m.vel.z = 0 m.forwardVel = 0 m.faceAngle.y = m.intendedYaw saverVars.vel = math.min(saverVars.vel + 4, 75) saverVars.offset = saverVars.offset - saverVars.vel if saverVars.offset <= 0 then saverVars.offset = 0 set_mario_action(m, ACT_HARD_FORWARD_GROUND_KB, 0) m.hurtCounter = 16 m.forwardVel = 0 m.invincTimer = 30 set_saver_model_pos(m, 0) set_saver_alpha(m, 255) play_sound(SOUND_ACTION_TERRAIN_BODY_HIT_GROUND, m.marioObj.header.gfx.cameraToObject) set_camera_shake_from_hit(SHAKE_FALL_DAMAGE) reset_saver_vars() end set_saver_model_pos(m, saverVars.offset) set_saver_alpha(m, 255 * (1 - saverVars.offset / 1800)) end local function before_pit_quicksand_saver(m) if not qolFeatures.deathSaver then return end if m.playerIndex ~= 0 then return end local np = gNetworkPlayers[0] local s = saverVars s.frame = s.frame + 1 if np.currLevelNum ~= s.lastLevel or np.currAreaIndex ~= s.lastArea then s.lastLevel = np.currLevelNum s.lastArea = np.currAreaIndex clear_safe_pos() s.cooldown = 0 s.lastRescue = -9999 reset_saver_vars() unfreeze_saver_camera() if m.action == ACT_VOID_FADE or m.action == ACT_SKY_DROP then set_mario_action(m, ACT_IDLE, 0) end return end if s.cooldown > 0 then s.cooldown = s.cooldown - 1 end local rescuing = (m.action == ACT_VOID_FADE or m.action == ACT_SKY_DROP) if not rescuing and s.lastPos ~= nil then local dx = m.pos.x - s.lastPos.x local dz = m.pos.z - s.lastPos.z if dx * dx + dz * dz > 1500 * 1500 then s.history = {} end end s.lastPos = {x = m.pos.x, y = m.pos.y, z = m.pos.z} if rescuing then return end if m.health < 0x100 then s.history = {} return end local last = s.history[#s.history] if s.cooldown == 0 and last ~= nil then local hazard = nil if m.action == ACT_QUICKSAND_DEATH and m.quicksandDepth + 5 >= 180 then hazard = 0 elseif m.floorHeight < -80000 and m.action & ACT_FLAG_AIR ~= 0 and m.vel.y < 0 and m.pos.y < last.y - 1500 then hazard = 1 elseif m.floor ~= nil and m.floor.type == SURFACE_DEATH_PLANE and m.pos.y + math.min(m.vel.y, 0) - 4 < m.floorHeight + 2048 then hazard = 1 end if hazard ~= nil then begin_rescue(m, hazard) return end end local floor = m.floor if s.frame % 5 == 0 and floor ~= nil and m.action & ACT_FLAG_AIR == 0 and m.action & ACT_FLAG_SWIMMING == 0 and m.action & ACT_FLAG_METAL_WATER == 0 and m.pos.y - m.floorHeight <= 20 and not sandSurfaces[floor.type] and floor.type ~= SURFACE_DEATH_PLANE and floor.type ~= SURFACE_BURNING and floor.type ~= SURFACE_VERTICAL_WIND and floor.normal.y >= 0.8 and is_spot_safe(m.pos.x, m.pos.y, m.pos.z) and not m.marioObj.platform then table.insert(s.history, {x = m.pos.x, y = m.pos.y, z = m.pos.z, yaw = m.faceAngle.y}) if #s.history > 30 then table.remove(s.history, 1) end end end local function death_pit_quicksand_saver(m) if not qolFeatures.deathSaver then return end if m.playerIndex ~= 0 then return end clear_safe_pos() reset_saver_vars() unfreeze_saver_camera() return true end local function pit_quicksand_saver(m) if not qolFeatures.deathSaver then return end if m.playerIndex ~= 0 then return end if saverVars.camFrozen == true and m.action ~= ACT_VOID_FADE then unfreeze_saver_camera() end if saverVars.opacityDirty == true and m.action ~= ACT_VOID_FADE and m.action ~= ACT_SKY_DROP then m.marioObj.oOpacity = 255 saverVars.opacityDirty = false end end hook_mod_menu_checkbox("Coyote Time", qolFeatures.coyoteTime, toggle_coyote_time) hook_mod_menu_checkbox("Star Heal", qolFeatures.starHeal, toggle_star_heal) hook_mod_menu_checkbox("Longer Metal/Vanish Cap", qolFeatures.longerMetalVanish, toggle_longer_metal_and_vanish) hook_mod_menu_checkbox("Better Landing", qolFeatures.betterLanding, toggle_better_landing) hook_mod_menu_checkbox("Less Annoying Ass Burn", qolFeatures.assBurn, toggle_ass_burn) hook_mod_menu_checkbox("Pit And Quicksand Saver", qolFeatures.deathSaver, toggle_death_saver) hook_mario_action(ACT_VOID_FADE, act_void_fade) hook_mario_action(ACT_SKY_DROP, act_sky_drop) hook_event(HOOK_BEFORE_MARIO_UPDATE, coyote_time) hook_event(HOOK_ON_INTERACT, star_heal) hook_event(HOOK_MARIO_UPDATE, longer_metal_and_vanish) hook_event(HOOK_MARIO_UPDATE, better_landing) hook_event(HOOK_ON_SET_MARIO_ACTION, less_annoying_ass_burn) hook_event(HOOK_BEFORE_MARIO_UPDATE, before_pit_quicksand_saver) hook_event(HOOK_ON_DEATH, death_pit_quicksand_saver) hook_event(HOOK_MARIO_UPDATE, pit_quicksand_saver)