//AAAAAAA
freeslot(
	"MT_JAWS"
)

local SWIM_TIMER = 104

//I'm proud of this and I dont even know how lua works
addHook("MobjThinker", function(mo)
	if mo and mo.valid
		if (mo.eflags & MFE_UNDERWATER)
		mo.flags = $1|MF_NOGRAVITY
		//except this because...
		//Original by Gaber and MIDIman
		//thank you so much
		//heeavily(??????) modified by me
		//apparently it works this way so...
		if not mo.target
			if mo.tgftimer
				mo.tgftimer = $-1
				//put the instathrust thing here because it works
				P_InstaThrust(mo, mo.angle, 6*FRACUNIT)
				else
				mo.tgftimer = SWIM_TIMER
				mo.angle = $1+ANGLE_180
				end
			end
		else
		//holy shit i didnt expect it to be this good at parkour
		mo.flags = $1 & ~MF_NOGRAVITY
			if P_IsObjectOnGround(mo)
				if mo.target
				and mo.target.valid
				mo.angle = R_PointToAngle2(mo.x, mo.y, mo.target.x, mo.target.y)
				P_InstaThrust(mo, mo.angle, 3*FRACUNIT)
				P_SetObjectMomZ(mo, 6*FRACUNIT)
				else
				if not mo.target
				mo.angle = $+ANGLE_45*(P_RandomChance(FRACUNIT>>1) and 1 or -1)
					P_InstaThrust(mo, mo.angle, 3*FRACUNIT)
					P_SetObjectMomZ(mo, 6*FRACUNIT)
					end
				end
			end
		end
	end
end, MT_JAWS)
//I need to take a break from this one it was a pain trying to make this work