How do I get Sonic to drop into a fall state at the end of his air dash?

So I'm trying to make a Adventure-like mod and one of those things is Sonic gaining a Homing Attack, so I used a modified version of the Final Demo Adventure Mode given that it's the most like the adventure games. The main problem is that I don't know how to make sonic drop into a vulnerable fall state at the end of his air dash.

Homing Attack:
addHook("AbilitySpecial", function(player)
    for player in players.iterate
        if player.charability == CA_THOK
            if not player.fdhoming and (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED)
                player.mo.tracer = P_LookForEnemies(player)
                if player.mo.tracer
                    player.fdhoming = 3*TICRATE
                end
            end
        end
    end
end)

addHook("PlayerThink", function(player)
    for player in players.iterate
        if player.charability == CA_THOK
            if player.fdhoming and player.mo.tracer
                P_SpawnThokMobj(player)
                P_HomingAttack(player.mo, player.mo.tracer)
                                if player.mo.tracer.health <= 0 or (player.mo.tracer.flags2 & MF2_FRET)
                    if (player.mo.eflags & MFE_UNDERWATER)
                        P_SetObjectMomZ(player.mo, (457*FRACUNIT)/72, false)
                    else
                        P_SetObjectMomZ(player.mo, 10*FRACUNIT/NEWTICRATERATIO, false)
                    end
                    player.mo.momx = 0
                    player.mo.momy = 0
                    player.fdhoming = 0
                    
                    if (player.mo.tracer.flags2 & MF2_FRET)
                        player.mo.angle = player.drawangle
                        P_InstaThrust(player.mo, player.mo.angle, -((player.speed/FRACUNIT) * (2^(FRACBITS-3))))
                    end
                    
                    if not (player.mo.tracer.flags & MF_BOSS)
                        player.pflags = $ & ~PF_THOKKED
                    end
                end
            end
            if not (player.pflags & PF_JUMPED)
                player.fdhoming = 0
            end
        end
    end
end)

addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo and player.mo.skin == "sonic"
        and not P_IsObjectOnGround(player.mo)
        and not (player.mo.state == S_PLAY_FLOAT)
        and not (player.mo.state == S_PLAY_FLOAT_RUN)
        and (player.pflags & PF_THOKKED)
            player.mo.state = S_PLAY_JUMP
            P_SpawnThokMobj(player)
        end
    end
end)
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top