help with a script

Vitocock_

Newbie
May 26, 2025
4
0
80
im trying to make a script that replicates the beta cannon behavior "after launching from a cannon you start flying"
but i just cant do the landing part. any help?


local CANNONFLY_STATE = 0
function mario_cannon_action(m)
djui_chat_message_create("cfs: " .. tostring(CANNONFLY_STATE)) -- debug


if m.action == ACT_SHOT_FROM_CANNON then
m.flags = m.flags | MARIO_WING_CAP
---m.action = ACT_FLYING (test)
CANNONFLY_STATE = 1
end

if (CANNONFLY_STATE == 1) and (m.action == ACT_FLYING) then
CANNONFLY_STATE = 2
else
-- stop flying part. it should remove the flying cap as soon as mario lands on ground, performs a ground pound or bonks into a wall
end

end

hook_event(HOOK_MARIO_UPDATE, mario_cannon_action)
 
Old thread but is my first time and i did myself Here the code
local CANNONFLY_STATE = 0

---@param m MarioState
function mario_cannon_action(m)
djui_chat_message_create("cfs: " .. tostring(CANNONFLY_STATE)) -- debug


if m.action == ACT_SHOT_FROM_CANNON or m.action == ACT_FLYING then
m.flags = m.flags | MARIO_WING_CAP
m.marioBodyState.capState = MARIO_HAS_DEFAULT_CAP_ON -- no wings on cap remove it to test it but no cap sometimes adds it back the cap
CANNONFLY_STATE = 1
end

if CANNONFLY_STATE == 1 and m.action == ACT_FLYING or m.action == ACT_SHOT_FROM_CANNON then
CANNONFLY_STATE = 2
else
-- if mario is like ground pounding removes wing cap
m.flags = m.flags & ~MARIO_WING_CAP
end

end

hook_event(HOOK_MARIO_UPDATE, mario_cannon_action)
 

Users who are viewing this thread