addHook("ThinkFrame", function()
for player in players.iterate do
if player.mo and player.mo.valid and player.mo.skin == "beggman" then
-- initialize custom variables properly
if player.beggmandove == nil then player.beggmandove = false end

-- reset jump when landing on the ground
if P_IsObjectOnGround(player.mo) then
player.beggmandove = false
end

if not P_IsObjectOnGround(player.mo) and (player.cmd.buttons & BT_CUSTOM1) ~= 0 and (player.cmd.buttons & BT_JUMP) == 0 and player.beggmandove == false then
-- perform dive
P_SetObjectMomZ(player.mo, -25 * FRACUNIT) 
P_InstaThrust(player.mo, player.mo.angle, FixedMul(2 * FRACUNIT, player.mo.scale))
player.mo.state = S_PLAY_FALL
P_SpawnThokMobj(player)
S_StartSound(player.mo, sfx_beki)
player.wowanotheruselesscheck = 1
player.beggmandove = true
end
end
end
end)