All pastes #386059 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-08 09:56 UTC
rendered paste body

objectdef ByteFlightPaths
{
	Property string SourceRegion=""
	Property string SourceFlightPath=""

	function IterateFlightpaths(string Callback, int MapID)
	{
		variable int Index = 1
		variable float X = 0
		variable float Y = 0
		variable float Z = 0
		variable string FlightPath
		variable lnavregionref Region
		variable int FMMapID

		do
		{
			if ${WoWDB[118].GetFloat[${Index},2](exists)}
			{
				FMMapID:Set[${WoWDB[118].GetInt[${Index},1]}]
				X:Set[${WoWDB[118].GetFloat[${Index},2]}]
				Y:Set[${WoWDB[118].GetFloat[${Index},3]}]
				Z:Set[${WoWDB[118].GetFloat[${Index},4]}]
				FlightPath:Set["${WoWDB[118].GetString[${Index},5]}"]

 				Region:SetRegion[${LNavRegionGroup["Flight master"].NearestRegion[${X},${Y},${Z}].ID}]
	
				if ${Region.ID}
				{
					if ${Math.Distance[${X},${Y},${Z},${Region.CenterPoint}]}<10 && ${FMMapID} == ${MapID}
					{
						This:Debug[">>> ${Region.Name}"]
						call ${Callback} "${Region.Name}" "${FlightPath}"
					}
				}	 
			}
		}
		while ${Index:Inc} <= 200
	}

	function ConnectFlightPathsCB(string Region, string FlightPath)
	{
		declare Connection lnavconnectionref	

		if ${Region.NotEqual["${This.SourceRegion}"]}
		{
			Connection:SetConnection[${LNavRegion[${This.SourceRegion}].Connect["${Region}"]}]
			Connection:SetCustom["FlightPath","${FlightPath}"]
			Connection:SetCustom["Method","Fly"]
			Connection:SetDistance[${Math.Calc[${Connection.ActualDistance}/2]}]

			Connection:SetConnection[${LNavRegion[${Region}].Connect["${This.SourceRegion}"]}]
			Connection:SetCustom["FlightPath","${This.SourceFlightPath}"]			
			Connection:SetDistance[${Math.Calc[${Connection.ActualDistance}/2]}]
			Connection:SetCustom["Method","Fly"]
		}
	}
	
	function ListFlightPathsCB(string Region, string FlightPath)
	{
		This.SourceRegion:Set["${Region}"]
		This.SourceFlightPath:Set["${FlightPath}"]
		call IterateFlightpaths "This.ConnectFlightPathsCB" ${Map.ID} 
	}

	function ConnectFlightPaths()
	{
		if ${LNavRegionGroup["Flight master"].Size} == 0
		{
			This:Debug["No flight masters found, not connecting paths."]
			return
		}

		call This.IterateFlightpaths "This.ListFlightPathsCB" ${Map.ID}
	}
}