All pastes #953745 Raw Edit

Someone

public text v1 · immutable
#953745 ·published 2008-03-23 09:28 UTC
rendered paste body
/* Hello World */

objectdef oMapper inherits oBase
{
	variable string ConfigDir = "${Script.CurrentDirectory}/map/"
	variable string ConfigFile = "map.xml"
	variable lnavregionref CurrentZone
	variable lnavregionref PreviousZone
	variable lnavregionref CurrentRegion
	variable lnavregionref PreviousRegion
	variable int LastMapRend = ${LavishScript.RunningTime}
	variable oTopography Topography

	variable bool MappingDisabled = FALSE
	variable bool MapPathway = FALSE
	variable bool MapPathwayReverse = FALSE

	variable bool MapPathwayOld = FALSE
	variable bool FOUND = FALSE
	variable objectref MyElevator

	variable float el_X
	variable float el_Y
	variable float el_TZ
	variable float el_BZ
	variable float el_TEX
	variable float el_TEY
	variable float el_TEZ
	variable float el_BEX
	variable float el_BEY
	variable float el_BEZ
	; Jump Tracker
	variable bool SetJump = FALSE
	variable lnavregionref JumpStartRegion
	variable int JumpStartTime = ${LavishScript.RunningTime}
	variable float JumpXStart = 0
	variable float JumpYStart = 0
	variable float JumpZStart = 0
	variable float SteadyZ = 0
	variable float LastFallZ = 0
	method Initialize()
	{
		LavishSettings:AddSet[Instances]
		LavishSettings[Instances]:Import["config/instances.xml"]
	}

	method OnGUIChange()
	{
		This.MappingDisabled:Set[${UIElement[chkMappingOff@Overview@Pages@openbot].Checked}]
		This.MapPathway:Set[${UIElement[chkMapPathway@Overview@Pages@openbot].Checked}]
		This.MapPathwayReverse:Set[${UIElement[chkMapPathwayReverse@Overview@Pages@openbot].Checked}]
	}

	method SetJump()
	{
		if ${UIElement[chkSetJump@Overview@Pages@openbot].Checked}
		{
			This:Output[Jump - Set - Please Jump 5 to 40 yards]
			This:Output[Jump - Set - Wait at landing spot JUMP COMPLETE]
			JumpStartRegion:SetRegion[${This.CurrentRegion}]
			JumpStartTime:Set[${LavishScript.RunningTime}]
			JumpXStart:Set[${Me.X}]
			JumpYStart:Set[${Me.Y}]
			JumpZStart:Set[${Me.Z}]
			SetJump:Set[TRUE]
		}
		else
		{
			This:ClearJump
			This:Output[Jump - Cancled]
		}
	}

	member ShouldClearJump()
	{
		if ${Math.Calc[${LavishScript.RunningTime} - ${This.JumpStartTime}]} > 6000
		{
			This:Output[Jump - Timed Out]
			return TRUE
		}
		variable int FallDistance = ${Math.Calc[${This.JumpZStart} - ${Me.Z}]}
		if ${FallDistance} > 40
		{
			This:Output[Jump - Fell Too Far]
			return TRUE
		}
		if ${FallDistance} > 5
		{
			if ${FallDistance} < ${Math.Abs[${Me.X} - ${JumpXStart}]}
			{
				This:Output["Jump - Moved too Far, Cancled Jump - X"]
				return TRUE
			}
			if ${FallDistance} < ${Math.Abs[${Me.Y} - ${JumpYStart}]}
			{
				This:Output["Jump - Moved too Far, Cancled Jump - Y"]
				return TRUE
			}
		}
		return FALSE
	}

	method ClearJump()
	{
		; Changes the Gui to unchecked
		UIElement[chkSetJump@Overview@Pages@openbot]:UnsetChecked
		This.SetJump:Set[FALSE]
	}

	member CheckJumpFalling()
	{
		if ${Math.Abs[${This.LastFallZ} - ${Me.Z}]} < 0.005
		{
			This.SteadyZ:Inc
			if ${This.SteadyZ} == 3
			{
				This.SteadyZ:Set[2]
				return FALSE
			}
		}
		else
		{
			This.SteadyZ:Set[0]
			This.LastFallZ:Set[${Me.Z}]
		}
		return TRUE
	}

	/* moved map loading out of intialize to allow LSO setting to load */
	method LoadMapper()
	{
		This:Output["Starting Mapping System"]
		call Mapper.Load
		This:ZoneChanged
	}

	method Shutdown()
	{
		This:Output["Shutting down"]
		This:Save
		LavishSettings[Instances]:Export["config/instances.xml"]
	}

	method ZoneChanged()
	{
		if !${LNavRegion[${This.ZoneText}](exists)}
		{
			LavishSettings[Instances]:AddSetting[${This.ZoneText},1]
			LNavRegion[${This.Continent}]:AddChild[universe,${This.ZoneText},-unique]
		}
		PreviousZone:Set[${CurrentZone}]
		CurrentZone:SetRegion[${LNavRegion[${This.ZoneText}].FQN}]
	}

	method Save1()
	{
		This:Debug["Saving Map file ${ConfigDir}${ConfigFile}"]
		LNavRegion[Azeroth]:Export[-lso,"${ConfigDir}new${ConfigFile}"]
		This:Debug["Saved"]
	}

	method BackupZone()
	{
		variable bool UseLSO = ${Config.Xboxx.Element["chkLSOFormat"]}
		if ${UseLSO}
		{
			LNavRegion[${This.ZoneText}]:Export[-lso,${ConfigDir}/bak/${This.ZoneText}]
		}
		else
		{
			LNavRegion[${This.ZoneText}]:Export[${ConfigDir}/bak/${This.ZoneText}]
		}
	}

	method Save()
	{
		variable string Continent
		variable int INDEX_Continent
		variable string Zone
		variable int INDEX_Zone
		variable bool UseLSO = ${Config.Xboxx.Element["chkLSOFormat"]}

		variable iterator InstanceIterator
		; Save Instance Files

		LavishSettings[Instances]:GetSettingIterator[InstanceIterator]
		if ${InstanceIterator:First(exists)}
		{
			do
			{
				if ${UseLSO}
				{
					LNavRegion[${InstanceIterator.Key}]:Export[-lso,${ConfigDir}/Instances/${InstanceIterator.Key}]
				}
				else
				{
					LNavRegion[${InstanceIterator.Key}]:Export[${ConfigDir}/Instances/${InstanceIterator.Key}]
				}
			}
			while ${InstanceIterator:Next(exists)}
		}

		INDEX_Continent:Set[1]
		do
		{
			Continent:Set[${WoWScript[GetMapContinents(),${INDEX_Continent}]}]
			INDEX_Zone:Set[1]
			do
			{
				Zone:Set[${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}]}]
				if ${UseLSO}
				{
					LNavRegion[${Zone}]:Export[-lso,${ConfigDir}${Zone}]
				}
				else
				{
					LNavRegion[${Zone}]:Export[${ConfigDir}${Zone}]
				}
				INDEX_Zone:Inc
			}
			while ${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}](exists)}
			INDEX_Continent:Inc
		}
		while ${WoWScript[GetMapContinents(),${INDEX_Continent}](exists)}
	}

	function Load()
	{
		variable string Continent
		variable int INDEX_Continent
		variable string Zone
		variable int INDEX_Zone
		variable lnavregionref LoadZoneRegion
		variable lnavregionref LoadedZoneRegion
		variable bool UseLSO = ${Config.Xboxx.Element["chkLSOFormat"]}

		;Clear out the map information
		LavishNav:Clear
		; Add tree structure for the loading
		This:InitializeRegions

		;Add in a default Intance as a catch all for any zone we dont know about
		LoadZoneRegion:SetRegion[${LavishNav.FindRegion["Instance"].FQN}]
		LoadedZoneRegion:SetRegion[${LoadZoneRegion.Parent}]

		echo "Loading ${Zone} into ${LoadedZoneRegion.FQN} P: ${LoadedZoneRegion.Parent.FQN}"

		variable iterator InstanceIterator
		; Load Instance Files

		LavishSettings[Instances]:GetSettingIterator[InstanceIterator]
		if ${InstanceIterator:First(exists)}
		{
			do
			{
				if ${UseLSO}
				{
					LNavRegion[Instance]:Import[-lso,${ConfigDir}Instances/${InstanceIterator.Key}]
				}
				else
				{
					LNavRegion[Instance]:Import[${ConfigDir}Instances/${InstanceIterator.Key}]
				}
				waitframe
			}
			while ${InstanceIterator:Next(exists)}
		}

		INDEX_Continent:Set[1]
		do
		{
			Continent:Set[${WoWScript[GetMapContinents(),${INDEX_Continent}]}]
			INDEX_Zone:Set[1]
			do
			{
				Zone:Set[${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}]}]
				LoadZoneRegion:SetRegion[${LavishNav.FindRegion[${Zone}].FQN}]
				LoadedZoneRegion:SetRegion[${LoadZoneRegion.Parent}]
				if ${UseLSO}
				{
					LoadedZoneRegion:Import[-lso,"${ConfigDir}${Zone}"]
				}
				else
				{
					LoadedZoneRegion:Import["${ConfigDir}${Zone}"]
				}
				INDEX_Zone:Inc
			}
			while ${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}](exists)}
			INDEX_Continent:Inc
			waitframe
		}
		while ${WoWScript[GetMapContinents(),${INDEX_Continent}](exists)}
	}

	method InitializeRegions()
	{
		variable string Continent
		variable int INDEX_Continent
		variable string Zone
		variable int INDEX_Zone

		This:Output["Initializing Regions"]
		LavishNav.Tree:AddChild[universe,Azeroth,-unique]

		;Add in a default Intance as a catch all for any zone we dont know about
		LNavRegion[Azeroth]:AddChild[universe,"Instance",-unique,-coordinatesystem]
		INDEX_Continent:Set[1]
		do
		{
			Continent:Set[${WoWScript[GetMapContinents(),${INDEX_Continent}]}]
			LNavRegion[Azeroth]:AddChild[universe,${Continent},-unique,-coordinatesystem]
			INDEX_Zone:Set[1]
			do
			{
				Zone:Set[${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}]}]
				LNavRegion[${Continent}]:AddChild[universe,${Zone},-unique]
				INDEX_Zone:Inc
			}
			while ${WoWScript[GetMapZones(${INDEX_Continent}),${INDEX_Zone}](exists)}
			INDEX_Continent:Inc
		}
		while ${WoWScript[GetMapContinents(),${INDEX_Continent}](exists)}
	}

	method Pulse()
	{
		This.PreviousRegion:SetRegion[${This.CurrentRegion}]
		This.CurrentRegion:SetRegion[${This.CurrentZone.BestContainer[${Me.Location}].ID}]

		if (${This.CurrentZone.ID} != ${LNavRegion[${This.ZoneText}].ID})
		{
			This:Output["Zone Changed Updating!"]
			This:ZoneChanged
		}

		; Do we have this mapped? If not map it
		if !${This.IsMapped[${Me.Location}]} && !${Me.Flying} && !${This.Falling} && ${Topography.IsFlat}
		{
			This:MapLocation[${Me.Location}]
		}

		if ${This.MapPathway} != ${This.MapPathwayOld}
		{
			This.MapPathwayOld:Set[${This.MapPathway}]

			if ${This.MapPathway}
			{
				variable guidlist list
				variable int Index = 0
				variable objectref o
				list:Search[-gameobjects]
				while ${list.GUID[${Index:Inc}](exists)} && !${This.FOUND}
				{
					o:Set[${list.GUID[${Index}]}]
					if ${o.SubType.Equal[Transport]}
					{
						if ${Math.Calc[${o.X} - ${Me.X}]} < 10 && ${Math.Calc[${o.X} - ${Me.X}]} > -10 && ${Math.Calc[${o.Y} - ${Me.Y}]} < 10 && ${Math.Calc[${o.Y} - ${Me.Y}]} > -10
						{
							This.MyElevator:Set[${list.GUID[${Index}]}]
							This.FOUND:Set[TRUE]
							This:Output[START Creating Pathway for Transport: ${This.MyElevator.Name} ${This.MyElevator.GUID}]
							This.el_TZ:Set[${o.Z}]
							This.el_BZ:Set[${o.Z}]
							This.el_X:Set[${o.X}]
							This.el_Y:Set[${o.Y}]
							This.el_TEX:Set[${Me.X}]
							This.el_TEY:Set[${Me.Y}]
							This.el_TEZ:Set[${Me.Z}]
							This.el_BEX:Set[${Me.X}]
							This.el_BEY:Set[${Me.Y}]
							This.el_BEZ:Set[${Me.Z}]
						}
					}
				}
			}
			else
			{
				if ${This.FOUND}
				{
					This:Output[FINISHED Creating Pathway for Transport: ${This.MyElevator.Name} ${This.MyElevator.GUID}]
					if ${Me.Z} > ${This.el_TEZ}
					{
						This:Output[You went from Bottom to Top]
						This.el_TEX:Set[${Me.X}]
						This.el_TEY:Set[${Me.Y}]
						This.el_TEZ:Set[${Me.Z}]
					}
					else
					{
						This:Output[You went from Top to Bottom]
						This.el_BEX:Set[${Me.X}]
						This.el_BEY:Set[${Me.Y}]
						This.el_BEZ:Set[${Me.Z}]
					}
					Navigator:TransportMapped[${This.MyElevator.GUID}, ${This.el_X}, ${This.el_Y}, ${This.el_TZ}, ${This.el_BZ}, ${This.el_TEX}, ${This.el_TEY}, ${This.el_TEZ}, ${This.el_BEX}, ${This.el_BEY}, ${This.el_BEZ}]
					This.FOUND:Set[FALSE]
					This.MyElevator:Set[NULL]
				}
			}
		}
		else
		{
			if ${This.FOUND}
			{
				if ${MyElevator.Z} > ${This.el_TZ}
				{
					This.el_TZ:Set[${MyElevator.Z}]
				}
				if ${MyElevator.Z} < ${This.el_BZ}
				{
					This.el_BZ:Set[${MyElevator.Z}]
				}
			}
		}

		if ${This.SetJump} && !${This.Falling}
		{
			if !${This.CheckJumpFalling}
			{
				if ${This.ShouldClearJump}
				{
					This:ClearJump
				}
				elseif ${This.IsMapped[${Me.Location}]} && ${Math.Calc[${This.JumpZStart} - ${Me.Z}]} > 5
				{
					JumpStartRegion:Connect[${CurrentRegion.FQN}]
					JumpStartRegion.GetConnection[${CurrentRegion.FQN}]:SetCustom[SPECIAL,JUMP]
					This:ClearJump
					This:Output["Jump - JUMP COMPLETE"]
				}
			}
		}

		if ${CurrentRegion.FQN.NotEqual[${PreviousRegion.FQN}]}
		{
			if ${This.MapPathway}
			{
				This:Output["Marking Preferred Path from ${CurrentRegion.FQN} to ${PreviousRegion.FQN}"]
				PreviousRegion.GetConnection[${CurrentRegion.FQN}]:SetDistance[1]
			}
			if ${This.PathwayReverse}
			{
				This:Output["Marking Preferred Path (reverse) from ${PreviousRegion.FQN} to ${CurrentRegion.FQN}"]
				CurrentRegion.GetConnection[${PreviousRegion.FQN}]:SetDistance[1]
			}
		}

		if ${Math.Calc[${LavishScript.RunningTime} - ${This.LastMapRend}]} > 100
		{
			MapEditor:MapRend
		}
		; Add in additional mapping items here
	}

	variable int LastFell = 0
	member Falling()
	{
		if ${Me.Falling}
		{
			This.LastFell:Set[${LavishScript.RunningTime}]
			return TRUE
		}
		if ${Math.Calc[${LavishScript.RunningTime}-${This.LastFell}]} < 1000
		{
			return TRUE
		}
		return FALSE
	}

	member IsMapped(float X, float Y, float Z)
	{
		if (${This.CurrentZone.ID} == ${This.CurrentRegion.ID})
		{
			return FALSE
		}
		return TRUE
	}

	method MapLocation(float X, float Y, float Z)
	{
		variable float X1
		variable float X2
		variable float Y1
		variable float Y2
		variable float Z1
		variable float Z2
		variable string RegionName

		; Dont map if we are flying (On a flight path)
		if ${Me.Flying} || ${This.MappingDisabled}
		{
			return
		}
		X1:Set[${Math.Calc[${X}-2.5]}]
		X2:Set[${Math.Calc[${X}+2.5]}]
		Y1:Set[${Math.Calc[${Y}-2.5]}]
		Y2:Set[${Math.Calc[${Y}+2.5]}]
		Z1:Set[${Math.Calc[${Z}-3]}]
		Z2:Set[${Math.Calc[${Z}+3]}]

		RegionName:Set["${CurrentZone.FQN}${Time.Timestamp}${CurrentZone.ChildCount}"]
		CurrentZone:AddChild[box,${RegionName},-unique,${X1},${X2},${Y1},${Y2},${Z1},${Z2}]
		This:Output["Area not found, Mapping!  Added (${RegionName} ${X}, ${Y}, ${Z}"]
		;Connect To Previous and Current
		This:ConnectNeighbours[${RegionName}]
	}

	method ConnectNeighbours(string RegionName)
	{
		variable index:lnavregionref SurroundingRegions
		variable int RegionsFound
		variable int Shouldconnect = 0
		variable int Index = 1
		variable int Connected_To = 0
		variable int Connected_From = 0

		CurrentRegion:SetRegion[${RegionName}]

		if ${This.ShouldConnect[${CurrentRegion.FQN},${PreviousRegion.FQN}]}
		{
			This:Debug["Connecting ${CurrentRegion.FQN} to ${PreviousRegion.FQN}"]
			Region:Connect[${PreviousRegion.FQN}]
		}
		if ${This.ShouldConnect[${PreviousRegion.FQN},${CurrentRegion.FQN}]}
		{
			This:Debug["Connecting ${PreviousRegion.FQN} to ${CurrentRegion.FQN}"]
			PreviousRegion:Connect[${CurrentRegion.FQN}]
		}

		; Need to add in Connect to Previous spot to current spot and current spot to previous spot if no collisions
		; Scan all descendants within 5 feet of this area
		RegionsFound:Set[${CurrentZone.ChildrenWithin[SurroundingRegions,10,${CurrentRegion.CenterPoint.X},${CurrentRegion.CenterPoint.Y},${CurrentRegion.CenterPoint.Z}]}]
		if ${RegionsFound} > 0
		{
			do
			{
				if ${This.ShouldConnect[${CurrentRegion.FQN},${SurroundingRegions.Get[${Index}].FQN}]} && ${This.ShouldConnect[${SurroundingRegions.Get[${Index}].FQN},${CurrentRegion.FQN}]}
				{
					Connected_To:Inc
					Connected_From:Inc
					CurrentRegion:Connect[${SurroundingRegions.Get[${Index}].FQN}]
					SurroundingRegions.Get[${Index}]:Connect[${CurrentRegion.FQN}]
				}
			}
			while ${SurroundingRegions.Get[${Index:Inc}](exists)}
			This:Output["Connections TO: ${Connected_To} and From: ${Connected_From}"]
		}
	}

	member ShouldConnect(string RegionA, string RegionB)
	{
		variable lnavregionref RegionRefA
		variable lnavregionref RegionRefB

		if !${RegionA(exists)} || !${RegionB(exists)}
		{
			return FALSE
		}

		; If they are the same Region.. Dont connect them
		if ${RegionA.Equal[${RegionB}]}
		{
			return FALSE
		}

		RegionRefA:SetRegion[${RegionA}]
		RegionRefB:SetRegion[${RegionB}]

		if !${This.RegionsIntersect[${RegionA},${RegionB}]}
		{
			return FALSE
		}

		if ${This.MapPathway}
		{
			if (${Math.Calc[${RegionRefA.CenterPoint.X} - ${RegionRefB.CenterPoint.X}]} == 0) && (${Math.Calc[${RegionRefA.CenterPoint.Y} - ${RegionRefB.CenterPoint.Y}]} == 0)
			{
				echo "Pathway, Moving vertically -- Go Go Map it !"
				return TRUE
			}
			if !${This.CollisionTest[${RegionRefA.CenterPoint.X}, ${RegionRefA.CenterPoint.Y}, ${RegionRefA.CenterPoint.Z}, ${RegionRefB.CenterPoint.X}, ${RegionRefB.CenterPoint.Y}, ${RegionRefB.CenterPoint.Z}]}
			{
				echo "Pathway (smooth way) -- Go Go Map it !"
				return TRUE
			}
			if !${This.CollisionTest[${RegionRefA.CenterPoint.X}, ${RegionRefA.CenterPoint.Y}, ${Math.Calc[${RegionRefA.CenterPoint.Z}+1.6]}, ${RegionRefB.CenterPoint.X}, ${RegionRefB.CenterPoint.Y}, ${Math.Calc[${RegionRefA.CenterPoint.Z}+1.6]}]}
			{
				echo "Pathway (rough way) -- Go Go Map it !"
				return TRUE
			}
		}

		if ${This.CollisionTest[${RegionRefA.CenterPoint.X}, ${RegionRefA.CenterPoint.Y}, ${RegionRefA.CenterPoint.Z}, ${RegionRefB.CenterPoint.X}, ${RegionRefB.CenterPoint.Y}, ${RegionRefB.CenterPoint.Z}]}
		{
			echo "Something in da way ! -- Not Connected"
			return FALSE
		}

		if ${Topography.IsSteep[${RegionRefA.CenterPoint.X}, ${RegionRefA.CenterPoint.Y}, ${RegionRefA.CenterPoint.Z}, ${RegionRefB.CenterPoint.X}, ${RegionRefB.CenterPoint.Y}, ${RegionRefB.CenterPoint.Z}]}
		{
			echo "Too Fucking Steep! -- Not Connected"
			return FALSE
		}
		return TRUE
	}

	member CollisionTest(float FromX, float FromY, float FromZ, float ToX, float ToY, float ToZ)
	{
		return ${Me.IsPathObstructed[${FromX},${FromY},${FromZ},20,${ToX},${ToY},${ToZ}]}
	}

	member RegionsIntersect(string RegionA, string RegionB)
	{
		variable lnavregionref RA
		variable lnavregionref RB

		RA:SetRegion[${RegionA}]
		RB:SetRegion[${RegionB}]

		if ${RA.Type.NotEqual["Box"]} || ${RB.Type.NotEqual["Box"]}
		{
			return FALSE
		}

		; Check Distance between if > 10 then it shouldnt connect
		if ${Math.Distance[${RA.CenterPoint.X}, ${RA.CenterPoint.Y}, ${RB.CenterPoint.X}, ${RB.CenterPoint.Y}]}>10
		{
			return FALSE
		}
		return TRUE
	}

	member SubZoneText()
	{
		return ${ISXWoW.MinimapZoneText}
	}

	member ZoneText()
	{
		return ${ISXWoW.RealZoneText}
	}

	member Continent()
	{
		if ${WoWScript[IsInInstance(), 1]}
		{
			return "Instance"
		}
		WoWScript SetMapToCurrentZone()
		if ${WoWScript[GetMapContinents(),${WoWScript[GetCurrentMapContinent()]}](exists)}
		{
			return ${WoWScript[GetMapContinents(),${WoWScript[GetCurrentMapContinent()]}]}
		}
		return "Instance"
	}

	method MapRend()
	{
		variable index:lnavregionref Regions
		variable lnavregionref R
		variable int Idx = 1

		if !${UIElement["MapGUI"].Visible}
		{
			return
		}

		UIElement[rend@MapGUI]:SetMapSize[15,15]
		UIElement[rend@MapGUI]:SetOrigin[${Me.X},${Me.Y},${Me.Z}]
		UIElement[rend@MapGUI]:SetRotation[${Me.Heading}]
		if ${This.CurrentZone.DescendantsWithin[Regions,25,${Me.X},${Me.Y},${Me.Z}]}
		{
			do
			{
				R:SetRegion[${Regions.Get[${Idx}].FQN}]
				UIElement[rend@MapGUI]:AddBlip[${R.Name},${R.CenterPoint.X},${Math.Calc[((${R.CenterPoint.Y}-${Me.Y}) * -1) + ${Me.Y}]},${R.CenterPoint.Z},2,${R.Name},"mapped_blip",""]
				This.LastMapRend:Set[${LavishScript.RunningTime}]
			}
			while ${Idx:Inc} <= ${Regions.Used}
		}
		UIElement[rend@MapGUI]:AddBlip[${Me.Name},${Me.X},${Me.Y},${Me.Z},2,${Me.Name},"me_blip",""]
	}
}


objectdef oTopography inherits oBase
{
	variable point3f TempLoc
	variable int SlopeCheck = ${LavishScript.RunningTime}

	method UpdateTemp()
	{
		if ${Math.Calc[${LavishScript.RunningTime}-${This.SlopeCheck}]} > 500
		{
			This.TempLoc:Set[${Me.X},${Me.Y},${Me.Z}]
			This.SlopeCheck:Set[${LavishScript.RunningTime}]
		}
	}

	member IsFlat()
	{
		if ${This.IsSteep[${This.TempLoc.X},${This.TempLoc.Y},${This.TempLoc.Z},${Me.X},${Me.Y},${Me.Z}]}
		{
			This:Debug["LIKE THE CLIFFS OF DOVER!!!!!!!"]
			This:UpdateTemp
			return FALSE
		}
		This:UpdateTemp
		return TRUE
	}

	/* check slope to determine if two points should connect - assumes anything more than 45 degrees is impassable */
	member IsSteep(float FromX, float FromY, float FromZ, float ToX, float ToY, float ToZ)
	{
		variable float slope = 0
		variable float horizontal = ${Math.Distance[${FromX}, ${FromY}, ${ToZ},${ToX}, ${ToY},${ToZ}]}
		variable float vertical = ${Math.Distance[${ToX}, ${ToY}, ${FromZ}, ${ToX}, ${ToY}, ${ToZ}]}

		/* did we move? */
		if ${horizontal} < 1.5
		{
			return FALSE
		}
		slope:Set[${Math.Atan[${vertical}/${horizontal}]}]
		if ${slope} > 50
		{
			return TRUE
		}
		return FALSE
	}
}