-- name: \\#FF0000\\Mario\\#00FFFF\\mentum -- description: Changes the vannila physics and moveset to have momentum\nMade by ExploxionMach ACT_RUNNING = allocate_mario_action(ACT_GROUP_MOVING | ACT_FLAG_MOVING | ACT_FLAG_ALLOW_FIRST_PERSON) local wannaGoFast = true local function toggle_momentum(index, value) wannaGoFast = value end local function custom_approach_s16(current, target, step) local diff = (target - current + 0x8000) % 0x10000 - 0x8000 if diff > step then return current + step elseif diff < -step then return current - step else return target end end local function get_signed_slope(m) if not m.floor then return end local forwardX = sins(m.faceAngle.y) local forwardZ = coss(m.faceAngle.y) local dot = (forwardX * m.floor.normal.x) + (forwardZ * m.floor.normal.z) return dot end local keepSpeedActs = { [ACT_WALKING] = true, [ACT_RUNNING] = true, [ACT_JUMP_LAND] = true, [ACT_DOUBLE_JUMP_LAND] = true, [ACT_TRIPLE_JUMP_LAND] = true, [ACT_LONG_JUMP_LAND] = true, [ACT_BACKFLIP_LAND] = true, [ACT_FREEFALL_LAND] = true, [ACT_SIDE_FLIP_LAND] = true, [ACT_JUMP_LAND_STOP] = true, [ACT_DOUBLE_JUMP_LAND_STOP] = true, [ACT_TRIPLE_JUMP_LAND_STOP] = true, [ACT_LONG_JUMP_LAND_STOP] = true, [ACT_BACKFLIP_LAND_STOP] = true, [ACT_FREEFALL_LAND_STOP] = true, [ACT_SIDE_FLIP_LAND_STOP] = true } local preserveSpeedActs = { [ACT_JUMP] = true, [ACT_STEEP_JUMP] = true, [ACT_DOUBLE_JUMP] = true, [ACT_TRIPLE_JUMP] = true, [ACT_LONG_JUMP] = true, [ACT_DIVE] = true } local slideActs = { [ACT_CROUCH_SLIDE] = true, [ACT_DIVE_SLIDE] = true, [ACT_SLIDE_KICK_SLIDE] = true, [ACT_BUTT_SLIDE] = true, [ACT_STOMACH_SLIDE] = true } function act_running(m) if not wannaGoFast then return set_mario_action(m, ACT_WALKING, 0) end mario_drop_held_object(m) if m.action == 0 then m.marioObj.oMarioWalkingPitch = 0 m.marioBodyState.allowPartRotation = 0 end if (should_begin_sliding(m) ~= 0) then return set_mario_action(m, ACT_BEGIN_SLIDING, 0) end if (m.input & INPUT_FIRST_PERSON ~= 0) or (m.input & INPUT_ZERO_MOVEMENT ~= 0) then return begin_braking_action(m) end if (m.input & INPUT_A_PRESSED ~= 0) then return set_jump_from_landing(m) end if (check_ground_dive_or_punch(m) ~= 0) then return 1 end if analog_stick_held_back(m) ~= 0 then return set_mario_action(m, ACT_TURNING_AROUND, 0) end if (m.input & INPUT_Z_PRESSED ~= 0) then return set_mario_action(m, ACT_CROUCH_SLIDE, 0) end m.actionState = 0 local maxTargetSpeed local targetSpeed if m.floor ~= nil and m.floor.type == SURFACE_SLOW then maxTargetSpeed = 24 else maxTargetSpeed = 32 end targetSpeed = (m.intendedMag < maxTargetSpeed) and m.intendedMag or maxTargetSpeed if m.quicksandDepth > 10 then targetSpeed = targetSpeed * (6.25 / m.quicksandDepth) end if m.forwardVel <= 0 then m.forwardVel = m.forwardVel + 1.1 elseif m.forwardVel <= targetSpeed then m.forwardVel = m.forwardVel + 1.1 - m.forwardVel / 43 elseif m.floor ~= nil and m.floor.normal.y >= 0.95 then m.forwardVel = m.forwardVel - 1 end m.faceAngle.y = custom_approach_s16(m.faceAngle.y, m.intendedYaw, 0x800) apply_slope_accel(m) local stepResult = perform_ground_step(m) if (stepResult == GROUND_STEP_LEFT_GROUND) then set_mario_action(m, ACT_FREEFALL, 0) elseif (stepResult == GROUND_STEP_NONE) then anim_and_audio_for_walk(m) if ((m.intendedMag - m.forwardVel) > 16.0) then set_mario_particle_flags(m, PARTICLE_DUST, false) end elseif (stepResult == GROUND_STEP_HIT_WALL) then push_or_sidle_wall(m, m.pos) m.actionTimer = 0 end anim_and_audio_for_walk(m) check_ledge_climb_down(m) tilt_body_walking(m, m.faceAngle.y) m.marioBodyState.allowPartRotation = 1 end local function reset_running_stuff_idk(m) if not wannaGoFast then return end if m.action == ACT_HOLDING_POLE or m.action == ACT_CLIMBING_POLE or m.action == ACT_GRAB_POLE_SLOW or m.action == ACT_GRAB_POLE_FAST or m.action == ACT_TOP_OF_POLE_TRANSITION or m.action == ACT_TOP_OF_POLE then return end if m.action ~= ACT_RUNNING then m.marioObj.oMarioWalkingPitch = 0 m.marioBodyState.allowPartRotation = 0 end end local function fix_interactions(m, obj, interactType) if not wannaGoFast then return end if (m.action == ACT_RUNNING) then if (interactType == INTERACT_WARP_DOOR) then m.action = ACT_WALKING local interaction = interact_warp_door(m, INTERACT_WARP_DOOR, obj) if (interaction == 0 and m.action ~= ACT_READING_AUTOMATIC_DIALOG) then m.action = ACT_RUNNING end end if (interactType == INTERACT_DOOR) then m.action = ACT_WALKING local interaction = interact_door(m, INTERACT_DOOR, obj) if (interaction == 0 and m.action ~= ACT_READING_AUTOMATIC_DIALOG) then m.action = ACT_RUNNING end end if (interactType == INTERACT_KOOPA_SHELL) then m.action = ACT_WALKING local interaction = interact_koopa_shell(m, INTERACT_KOOPA_SHELL, obj) if (interaction == 0) then m.action = ACT_RUNNING end end end end local walkingSpeed = {} local preservedSpeed = {} local slideSpeedBonus = {} local function walking_momentum(m) if not wannaGoFast then return end local slope = get_signed_slope(m) local index = m.playerIndex if m.action == ACT_WALKING and m.forwardVel >= 33 then set_mario_action(m, ACT_RUNNING, 0) elseif m.action == ACT_RUNNING and m.forwardVel < 33 then set_mario_action(m, ACT_WALKING, 0) end if keepSpeedActs[m.action] then if walkingSpeed[index] == nil then walkingSpeed[index] = m.forwardVel end if preservedSpeed[index] == nil then preservedSpeed[index] = m.forwardVel end if m.wall ~= nil then walkingSpeed[index] = 0 end walkingSpeed[index] = walkingSpeed[index] + slope if m.forwardVel < walkingSpeed[index] and m.input & INPUT_NONZERO_ANALOG ~= 0 and analog_stick_held_back(m) == 0 then m.forwardVel = walkingSpeed[index] else walkingSpeed[index] = m.forwardVel end else walkingSpeed[index] = m.forwardVel end if not preserveSpeedActs[m.action] then preservedSpeed[index] = m.forwardVel end end local function moves_momentum(m) if not wannaGoFast then return end local index = m.playerIndex if (m.action == ACT_DIVE or m.action == ACT_LONG_JUMP) and preservedSpeed[index] > 32 then m.forwardVel = preservedSpeed[index] + 16 else if preserveSpeedActs[m.action] and not (m.action == ACT_DIVE or m.action == ACT_LONG_JUMP) then m.forwardVel = preservedSpeed[index] end end end local function slide_momentum(m) if not wannaGoFast then return end local slope = get_signed_slope(m) local index = m.playerIndex if slideActs[m.action] and m.forwardVel > 0 then if slideSpeedBonus[index] == nil then slideSpeedBonus[index] = 0 end if m.input & INPUT_NONZERO_ANALOG ~= 0 and analog_stick_held_back(m) == 0 then m.forwardVel = m.forwardVel + 3 m.slideVelX = m.slideVelX * (1.04 + (slideSpeedBonus[index] * 0.02)) m.slideVelZ = m.slideVelZ * (1.04 + (slideSpeedBonus[index] * 0.02)) end if mario_floor_is_slope(m) ~= 0 then slideSpeedBonus[index] = slideSpeedBonus[index] + slope else if slideSpeedBonus[index] > 0 then slideSpeedBonus[index] = slideSpeedBonus[index] - 1 end end else slideSpeedBonus[index] = 0 end end hook_event(HOOK_MARIO_UPDATE, walking_momentum) hook_event(HOOK_MARIO_UPDATE, slide_momentum) hook_event(HOOK_ON_SET_MARIO_ACTION, moves_momentum) hook_mario_action(ACT_RUNNING, { every_frame = act_running, gravity = nil } ) hook_event(HOOK_ON_SET_MARIO_ACTION, reset_running_stuff_idk) hook_event(HOOK_ALLOW_INTERACT, fix_interactions) hook_mod_menu_checkbox("Activate \\#FF0000\\Mario\\#00FFFF\\mentum", wannaGoFast, toggle_momentum)