addHook("MobjSpawn", function(mo) mo.recoiling = 0 end, MT_PLAYER)

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin == "lepori"
                        if (player.cmd.buttons & BT_CUSTOM1)
			and not (player.exiting)
			and not (player.pflags & PF_SLIDING)
			and not (player.pflags & PF_JUMPED)
			and not (player.pflags & PF_JUMPDOWN)
			and not (player.mo.state == S_PLAY_DEAD)
			and not (player.mo.state == S_PLAY_PAIN)
			and not (player.mo.state == S_PLAY_ROLL)
			and not (player.weapondelay)
			and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
                        and not P_IsObjectOnGround(player.mo)
			and (player.mo.recoiling == 0)
				player.mo.state = S_PLAY_ROLL
				player.pflags = $1|PF_JUMPED
			player.mo.recoiling = 1
                        end
			if player.mo.recoiling == 1
			and not (player.cmd.buttons & BT_CUSTOM1)
			player.mo.recoiling = 0
			end
		end
	end
end)
