-- name: Checkpoints v2 -- description: Gives you a checkpoint that you can fall back\nto.\n\nDPAD+DOWN while stationary to place your checkpoint.\n\nDPAD+UP to teleport to it. local sFlagObj = nil local sCheckpointEnabled = false local sCheckpointX = 0 local sCheckpointY = 0 local sCheckpointZ = 0 local sHasPlaced = false local sHasUsed = false --- local function bhv_checkpoint_flag_init(obj) obj.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE obj.oAnimations = gObjectAnimations.koopa_flag_seg6_anims_06001028 obj_init_animation(obj, 0) cur_obj_scale(0.2) cur_obj_hide() end local function bhv_checkpoint_flag_loop(obj) if sCheckpointEnabled == false then cur_obj_hide() else obj_set_pos(obj, sCheckpointX, sCheckpointY, sCheckpointZ) cur_obj_unhide() end end id_bhvCheckpointFlag = hook_behavior(nil, OBJ_LIST_LEVEL, true, bhv_checkpoint_flag_init, bhv_checkpoint_flag_loop) --- function on_level_init() sFlagObj = nil sCheckpointEnabled = false end function on_sync_valid() local m = gMarioStates[0] sFlagObj = spawn_non_sync_object( id_bhvCheckpointFlag, E_MODEL_KOOPA_FLAG, m.pos.x, m.pos.y, m.pos.z, nil ) end function bind_place(m) if _G.OmmEnabled == true then return (m.controller.buttonDown & L_TRIG) ~= 0 and (m.controller.buttonPressed & D_JPAD) ~= 0 else return (m.controller.buttonPressed & D_JPAD) ~= 0 end end function bind_tp(m) if _G.OmmEnabled == true then return (m.controller.buttonDown & L_TRIG) ~= 0 and (m.controller.buttonPressed & U_JPAD) ~= 0 else return (m.controller.buttonPressed & U_JPAD) ~= 0 end end function mario_update(m) if m.playerIndex ~= 0 then return end if bind_tp(m) then if sCheckpointEnabled then m.pos.x = sCheckpointX m.pos.y = sCheckpointY m.pos.z = sCheckpointZ m.vel.x = 0 m.vel.y = 0 m.vel.z = 0 m.marioObj.oIntangibleTimer = 0 m.hurtCounter = 0 m.healCounter = 31 m.health = 0x100 m.invincTimer = 30 * 3 set_mario_action(m, ACT_IDLE, 0) m.statusForCamera.action = ACT_IDLE soft_reset_camera(m.area.camera) sHasUsed = true end elseif bind_place(m) then if (m.action & ACT_FLAG_STATIONARY) ~= 0 then sCheckpointEnabled = true sCheckpointX = m.pos.x sCheckpointY = m.pos.y sCheckpointZ = m.pos.z sHasPlaced = true end end end function place_text() if _G.OmmEnabled == true then return "Hold L and press DPAD-DOWN while stationary to place a checkpoint" else return "Press DPAD-DOWN while stationary to place a checkpoint" end end function tp_text() if _G.OmmEnabled == true then return "Hold L and press DPAD-UP to teleport to checkpoint" else return "Press DPAD-UP to teleport to checkpoint" end end function on_hud_render() -- set resolution and font djui_hud_set_resolution(RESOLUTION_N64) djui_hud_set_font(FONT_NORMAL) if sHasPlaced == false then djui_hud_set_color(0, 0, 0, 255) djui_hud_print_text(place_text(), 16, 4, 0.4) elseif sHasUsed == false then djui_hud_set_color(0, 0, 0, 255) djui_hud_print_text(tp_text(), 16, 4, 0.4) end end hook_event(HOOK_ON_LEVEL_INIT, on_level_init) hook_event(HOOK_ON_SYNC_VALID, on_sync_valid) hook_event(HOOK_MARIO_UPDATE, mario_update) hook_event(HOOK_ON_HUD_RENDER, on_hud_render)