#include plot.iss
function plotCircle()
{
;== WoW doesn't use a standard X Y axis, it is flipped 90degrees.
;== Heading due west (270deg.) Y will increase
;== Heading due north (0deg.) X will increase
;== X+
;== |
;== |
;== |
;== |
;== |
;== Y+----------|----------
;== |
;== |
;== |
;== |
;== |
declare debug int local 0
;== right triangle. a=adjacent, b=opposite, c=hypotenuse
if (!${Variable[a](exists)})
declare a float script 0
;== this is the radius of the circle
declare c int local 40
;== center of a circle. h is x axis, k is y axis
if (!${Variable[h](exists)})
declare h float script
if (!${Variable[k](exists)})
declare k float script
;== Which part of the graph we are in. Circle starts at 0, or Y
;== 0=between 270 and 0 deg., 1=0-90, 2=90-180, 3=180-270
if (!${Variable[NESW](exists)})
declare NESW int script 0
;== Where we are facing
if (!${Variable[toX](exists)})
declare toX float script
if (!${Variable[toY](exists)})
declare toY float script
;== Distance to check ahead for obstacles
if (!${Variable[obsDis](exists)})
declare obsDis int script 30
;== The circle will always begin at 270degrees because it is our Y axis.
;== Get the center of the circle. h = my X, k = my Y minus hypotenuse c
if (!${h})
h:Set[${Me.X}]
if (!${k})
k:Set[${Math.Calc[${Me.Y}-${c}]}]
if (${debug}==1)
echo Center (h,k): ${h},${k}
;== Add to side b and calc the new adj. side a.
;== First round a is X axis, b is Y axis. Solve for Y
;== Second round a is Y axis, b is X axis. Solve for X
;== Third round a is X. Solve Y
;== Fourth a is a is Y. Solve X
;== r^2 = (x - h)^2 + (y - k)^2
;== y = k +/- Sqrt( r^2 - (x - h)^2 )
;== x = h +/- Sqrt( r^2 - (y - k)^2 )
if (${NESW}==0)
{
call incAdj ${a} ${c}
a:Set[${Return}]
toX:Set[${Math.Calc[${a}+${h}]}]
toY:Set[${Math.Calc[${c}^^2 - (${toX} - ${h})^^2]}]
toY:Set[${Math.Abs[${toY}]}]
toY:Set[${Math.Sqrt[${toY}]}]
toY:Set[${Math.Calc[${k} + ${toY}]}]
if (${debug}==1)
{
echo After Inc and calc. (a) (NESW): ${a} ${NESW}
echo toX,toY: ${toX},${toY}
}
}
elseif (${NESW}==1)
{
call incAdj ${a} ${c}
a:Set[${Return}]
toY:Set[${Math.Calc[${k}-${a}]}]
toX:Set[${Math.Calc[${c}^^2 - (${toY} - ${k})^^2]}]
toX:Set[${Math.Abs[${toY}]}]
toX:Set[${Math.Sqrt[${toX}]}]
toX:Set[${Math.Calc[${h} + ${toX}]}]
if (${debug}==1)
{
echo After Inc and calc. (a) (NESW): ${a} ${NESW}
echo toX,toY: ${toX},${toY}
}
}
elseif (${NESW}==2)
{
call incAdj ${a} ${c}
a:Set[${Return}]
toX:Set[${Math.Calc[${h}-${a}]}]
toY:Set[${Math.Calc[${c}^^2 - (${toX} - ${h})^^2]}]
toY:Set[${Math.Abs[${toY}]}]
toY:Set[${Math.Sqrt[${toY}]}]
toY:Set[${Math.Calc[${k} - ${toY}]}]
if (${debug}==1)
{
echo After Inc and calc. (a) (NESW): ${a} ${NESW}
echo toX,toY: ${toX},${toY}
}
}
elseif (${NESW}==3)
{
call incAdj ${a} ${c}
a:Set[${Return}]
toY:Set[${Math.Calc[${a}+${k}]}]
toX:Set[${Math.Calc[${c}^^2 - (${toY} - ${k})^^2]}]
toY:Set[${Math.Abs[${toY}]}]
toX:Set[${Math.Sqrt[${toX}]}]
toX:Set[${Math.Calc[${h} - ${toX}]}]
if (${debug}==1)
{
echo After Inc and calc. (a) (NESW): ${a} ${NESW}
echo toX,toY: ${toX},${toY}
}
}
;if adj. side = hypot. then we need to increment NESW
if (${a}==${c})
{
if (${debug}==2)
{
echo Made it to an axis. (NESW): ${NESW}
;wait 20
}
if (${NESW}==3)
NESW:Set[0]
else
NESW:Inc
;== b=c and a=0
a:Set[0]
}
}
function:float incAdj(float a, float c)
{
;== how much the opposite side of the triangle is increased
declare abInc int local 7
;== increment a. If a+abInc < c add abInc, else a=c
if (${Math.Calc[${a}+${abInc}]} < ${c})
a:Set[${Math.Calc[${a}+${abInc}]}]
else
a:Set[${c}]
return ${a}
}
;== Get's the next point in the circle and moves me to it.
function moveInACircle()
{
declare debug int local 0
if (!${Variable[madeIt](exists)})
declare madeIt bool script TRUE
;get the new coords and face them
if (${madeIt})
{
if (${debug}==1)
echo getting new coords
call plotCircle
if (${debug}==1)
echo new coords ${toX} ${toY}
face ${toX} ${toY}
call plotXY ${obsDis}
madeIt:Set[FALSE]
}
;check for obstacles
if (${debug}==2)
echo Obstructed: ${Me.IsPathObstructed[${plotX},${plotY},${Math.Calc[${Me.Z}+5]},${obsDis},${Me.X},${Me.Y},${Me.Z}]}
;if I haven't made it to the plotted points and my path isn't obstructed.
if (${Math.Distance[${Me.X},${Me.Y},${toX},${toY}]} > 3 && !${Me.IsPathObstructed[${plotX},${plotY},${Math.Calc[${Me.Z}+5]},${obsDis},${Me.X},${Me.Y},${Me.Z}]})
{
face ${toX} ${toY}
wowpress -hold moveforward
call plotXY ${obsDis}
if (${debug}==2)
echo Obstructed: ${Me.IsPathObstructed[${plotX},${plotY},${Math.Calc[${Me.Z}+5]},${obsDis},${Me.X},${Me.Y},${Me.Z}]}
wait 1
}
else
{
if (${debug}==1)
{
echo Made it to ${toX} ${toY} or obstructed
echo Distance: ${Math.Distance[${Me.X},${Me.Y},${toX},${toY}]} Obstructed: ${Me.IsPathObstructed[${plotX},${plotY},${Math.Calc[${Me.Z}+5]},${obsDis},${Me.X},${Me.Y},${Me.Z}]}
}
madeIt:Set[TRUE]
if (${Me.IsPathObstructed[${plotX},${plotY},${Math.Calc[${Me.Z}+5]},${obsDis},${Me.X},${Me.Y},${Me.Z}]})
wowpress -release moveforward
}
}