# Low stamina  [v1.0.4]
###############################################

 # Stamina until:
Stamina = "54:00"


###############################################


# Waypoints:
Set_Hunt = 0
Set_To_Safe_Zone = 1
Set_To_Hunt = 2

# Spots:
Spot_Hunt = (x, y, z)
Spot_Safe_Zone = (x, y, z)


###############################################


def onChangeLocation(x, y, z):
	way = script.GetWay()
	xyz = (x, y, z)

	if way in [Set_Hunt, Set_To_Hunt]:
		if script.IsOnScreen(Spot_Hunt[0], Spot_Hunt[1], Spot_Hunt[2], 2):
			if script.GetStaminaText() > Stamina:
				script.SetWay(Set_Hunt, 2)
			else:
				script.StatusMessage("Low stamina.")
				script.SetWay(Set_To_Safe_Zone, 2)

	elif (way == Set_To_Safe_Zone) and (xyz == Spot_Safe_Zone):
		logOut = (((3360 - script.GetStaminaTime()) * 60 ) * 2)
		script.LogoutFor(logOut)


def onDisconnect(info):
	if "Script" in info:
		script.SetWay(Set_To_Hunt, 2)