function init()
	mainJ = FindJoint("mainjoint")
	propJ = FindJoint("propellerjoint")
	SetJointMotor(mainJ,mSpeed,30)
	SetJointMotor(propJ,pSpeed,30)
	change = math.random(5.0,10.0)
	time = 0.0
	
	Engin = FindBody("Engin")
	EnginGood = GetBodyTransform(Engin).pos[2]
	EnginOn = true
end

mSpeed = GetFloatParam("mSpeed")
pSpeed = GetFloatParam("pSpeed")
DamageDelta = GetFloatParam("DamageDelta")

function tick(dt)
	local EnginBad = GetBodyTransform(Engin).pos[2]
	local DamageShift = math.abs(EnginGood - EnginBad)
	
	if DamageShift > DamageDelta then
		EnginOn = false
		Delete(mainJ)
		Delete(propJ)
	end
	
	time = time + dt
	if time > change and EnginOn then
		newMVel = math.random(-mSpeed*100,mSpeed*100)/100
		newPVel = math.random(pSpeed*100,pSpeed*200)/100

		SetJointMotor(mainJ,newMVel,30)
		SetJointMotor(propJ,newPVel,30)
		change = time + math.random(5.0,20.0)
	end
end