How would I change the player's floorz variable to the top height of a Water FOF?

I've been trying to make the player hover over Water (and if possible Goop, Fog, and Quicksand) but it doesn't work well. The player hovers over the ground via floorz, seen below.

Hover:
if ElementObject and ElementObject.valid
    if (((player.mo.floorrover and player.mo.floorrover.valid) or (player.mo.subsector.sector.floorpic != skyflatnum
    and player.mo.subsector.sector.special != 6 and player.mo.subsector.sector.special != 7))
    and ElementObject.z - ElementObject.height/2 + player.mo.momz <= player.mo.floorz and not (player.mo.eflags & MFE_VERTICALFLIP))
    or (((player.mo.ceilingrover and player.mo.ceilingrover.valid) or player.mo.subsector.sector.ceilingpic != skyflatnum)
    and ElementObject.z + ElementObject.height*6 + player.mo.momz >= player.mo.ceilingz and (player.mo.eflags & MFE_VERTICALFLIP))
        if player.wiz.element != 0 and player.wiz.element != 2
            if not (player.mo.eflags & MFE_VERTICALFLIP)
                player.mo.z = player.mo.floorz + ElementObject.height/2
            else
                player.mo.z = player.mo.ceilingz - ElementObject.height*6
            end
        else
            player.wiz.banstate = true
        end
       
        if player.wiz.element == 1
            if abs(player.mo.momz) >= 10*FRACUNIT
                P_SetObjectMomZ(player.mo, player.mo.momz/2 * -P_MobjFlip(player.mo) - player.mo.subsector.sector.gravity)
                S_StartSound(player.mo, sfx_s3k44)
               
                player.wiz.mana = min($+10, 100)
            else
                P_SetObjectMomZ(player.mo, 0)
            end
        end
    elseif (player.wiz.element == 1 or player.wiz.element == 3)
    and ((((player.mo.ceilingrover and player.mo.ceilingrover.valid) or player.mo.subsector.sector.ceilingpic != skyflatnum)
    and ElementObject.z + ElementObject.height*6 + player.mo.momz > player.mo.ceilingz and not (player.mo.eflags & MFE_VERTICALFLIP))
    or (((player.mo.floorrover and player.mo.floorrover.valid) or (player.mo.subsector.sector.floorpic != skyflatnum
    and player.mo.subsector.sector.special != 6 and player.mo.subsector.sector.special != 7))
    and ElementObject.z - ElementObject.height/2 + player.mo.momz < player.mo.floorz and (player.mo.eflags & MFE_VERTICALFLIP)))
        if not (player.mo.eflags & MFE_VERTICALFLIP)
            player.mo.z = player.mo.ceilingz - ElementObject.height*6
        else
            player.mo.z = player.mo.floorz + ElementObject.height/2
        end
       
        if player.wiz.element == 1
            if abs(player.mo.momz) >= 10*FRACUNIT
                P_SetObjectMomZ(player.mo, player.mo.momz/2 * -P_MobjFlip(player.mo) - player.mo.subsector.sector.gravity)
                S_StartSound(player.mo, sfx_s3k44)
               
                player.wiz.mana = min($+10, 100)
            else
                P_SetObjectMomZ(player.mo, 0)
            end
        end
    end
end

If you know a method I could try, please let me know.
 

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

Back
Top