addHook("PreThinkFrame", function() for player in players.iterate() local mo = player.mo if not (mo and player.charability == CA_TWINSPIN and player.charability2 == CA2_MELEE) then player.airswap = 0 continue end //Initialize if player.airswap == nil then player.airswap = 0 end local jump = player.cmd.buttons&BT_JUMP local spin = player.cmd.buttons&BT_USE local jumplast = player.pflags&PF_JUMPDOWN local spinlast = player.pflags&PF_USEDOWN local lastswap = player.airswap local shieldtype = player.powers[pw_shield]&~(SH_PITY|SH_PINK|SH_STACK) //Convert spring/fall frames to jump frames if mo.state == S_PLAY_FALL or mo.state == S_PLAY_SPRING then player.pflags = ($|PF_JUMPED|PF_NOJUMPDAMAGE) end if P_IsObjectOnGround(mo) then player.airswap = 0 end if player.pflags&PF_JUMPED //Holding jump key if (jumplast) and not(spin) player.airswap = 0 end //Pressing a new key while in the air if (spin and not spinlast) or (jump and not jumplast) player.airswap = 1 end end //Perform swap if player.airswap == 1 then if jump then player.cmd.buttons = $|BT_USE else player.cmd.buttons = $&~BT_USE end if spin then player.cmd.buttons = $|BT_JUMP else player.cmd.buttons = $&~BT_JUMP end end //Change history if this is our first swap if lastswap != player.airswap then player.pflags = $&~(PF_USEDOWN|PF_JUMPDOWN) if jumplast then player.pflags = $|PF_USEDOWN end if spinlast then player.pflags = $|PF_JUMPDOWN end end //Deny jump hammers if not(shieldtype) and not(jumplast) and (jump) and player.pflags&PF_JUMPED player.pflags = $|PF_USEDOWN end end end)