--Combat loop

core.spawn(function()
	while myHuman.Health > 0 do
		
		if target and target.Parent and target.Parent.Humanoid.Health>0 and core.checkSight(target) and engineRunning and core.checkDist(myRoot,target) < 300 then
			
			--Keeps track of our last attack so we don't update the target within 5 seconds of attacking
			lastAttack = tick()
			
			--Prioritizes weapon based on enemy type--
			if target.Parent:GetExtentsSize().Magnitude > 10 then
				munition = combat.engageVehicle(munition,target)
			else
				munition = combat.engageLight(munition,target)
			end
			
		else
			--Aims M230 and Hydra to a neutral position when not in combat
			combat.resetM230()
			combat.resetHydra()
		end
		wait(0.1)
	end
end)
