<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>The Dizzy Community Forums @ Yolkfolk.com - DizzyAGE Help</title>
		<link>http://www.yolkfolk.com/bb/</link>
		<description>Need help with using DizzyAGE then look here</description>
		<language>en</language>
		<lastBuildDate>Thu, 23 May 2013 23:03:57 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.yolkfolk.com/bb/images/misc/rss.png</url>
			<title>The Dizzy Community Forums @ Yolkfolk.com - DizzyAGE Help</title>
			<link>http://www.yolkfolk.com/bb/</link>
		</image>
		<item>
			<title>AI for Circular Motion</title>
			<link>http://www.yolkfolk.com/bb/showthread.php?2424-AI-for-Circular-Motion&amp;goto=newpost</link>
			<pubDate>Thu, 25 Apr 2013 19:19:22 GMT</pubDate>
			<description><![CDATA[Hi, I wanted to share with you all a little thing I've been working on. This is a bit of AI for moving an object in a circle. 
 
It works much like...]]></description>
			<content:encoded><![CDATA[<div>Hi, I wanted to share with you all a little thing I've been working on. This is a bit of AI for moving an object in a circle.<br />
<br />
It works much like AIUpdateTrain. You use one waypoint, which goes at the centre of the circle. O_WAYPOINTSPEED is the same as usual, but I've used O_WAYPOINTFLIP to set the direction of motion (0 = clockwise, 1 = anti) - try setting an Action Object to switch it!<br />
<br />
I've also added another variable O_WAYPOINTRADIUS, which you'll have to add a #def for. It does what it says on the tin. You'll probably want to set it to the same as the seperation between the starting positions on the map, but the AI will correct it anyway. Again, try changing it with an Action object.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">func AIUpdateCircle( idx )<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(idx==-1) return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(ObjGet(idx,O_DISABLE)) return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!IsUpdate(ObjGet(idx,O_DELAY))) return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(ObjGet(idx,O_STATUS)!=1) return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; id2 = ObjGet(idx,O_TARGET);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(id2==0) return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; idx2 = ObjFind(id2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(idx2==-1) return;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; speed = ObjGet(idx2,O_WAYPOINTSPEED);<br />
&nbsp; &nbsp; &nbsp; &nbsp; clock = ObjGet(idx2,O_WAYPOINTFLIP);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; radius = ObjGet(idx2,O_WAYPOINTRADIUS);<br />
&nbsp; &nbsp; &nbsp; &nbsp; rad = (float)radius;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x2 = ObjGet(idx2,O_X);<br />
&nbsp; &nbsp; &nbsp; &nbsp; y2 = ObjGet(idx2,O_Y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; x = ObjGet(idx,O_X);<br />
&nbsp; &nbsp; &nbsp; &nbsp; y = ObjGet(idx,O_Y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; label:<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(speed - count==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ObjSet(idx,O_X,x);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ObjSet(idx,O_Y,y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(clock==0){&nbsp; &nbsp; &nbsp; &nbsp; if(y>y2){ xt = x - 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(y<=y2){ xt = x + 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(x>=x2){ yt = y + 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(x<x2){ yt = y - 1;} }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(clock==1){&nbsp; &nbsp; &nbsp; &nbsp; if(y>=y2){ xt = x + 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(y<y2){ xt = x - 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(x>x2){ yt = y - 1;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(x<=x2){ yt = y + 1;} }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; dis1 = (float)(((xt - x2)*(xt - x2)) + ((y - y2)*(y -y2)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; rad1 = gs_sqrt(dis1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; dis2 = (float)(((x - x2)*(x - x2)) + ((yt - y2)*(yt -y2)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; rad2 = gs_sqrt(dis2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(gs_abs(rad1 - rad) < gs_abs(rad2 - rad))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {x = xt;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(gs_abs(rad1 - rad) > gs_abs(rad2 - rad))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {y = yt;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; goto label;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>So, please give it a go and let me know what you think. :)</div>

]]></content:encoded>
			<category domain="http://www.yolkfolk.com/bb/forumdisplay.php?26-DizzyAGE-Help">DizzyAGE Help</category>
			<dc:creator>Noggin the Nog</dc:creator>
			<guid isPermaLink="true">http://www.yolkfolk.com/bb/showthread.php?2424-AI-for-Circular-Motion</guid>
		</item>
	</channel>
</rss>
