ID:267586
 


I need a proc for animals.. For example a Cow, I need it where the Cow has random movements.. I also need to know where to put the proc into the mob. Thx


--John
The proc your after is step_rand(), check it out in the reference (F1 in Dream Maker) for how to use it.
The second part of your question is you have to put it in a looping proc.
I'll run through a basic AI proc but you should check out the tutorials.
First, we need to create a proc for all the mobs.
mob
proc/AI() //Define a new proc called AI.

Now we have a proc. We need to fill it. Well throw in step_rand(src), that will make src step in a random direction every time the proc is called.
mob
proc/AI() //Define a new proc called AI.
step_rand(src)

Now we have a proc that when called steps src in a random direction. What next? We want to make it so that the proc keeps on repeating (Known as looping).
To do this we have to introduce you to the spawn proc. spawn() is pretty simple. You just put a number in the ()'s, and then it will do what ever you indented after that amount of time. Unlike sleep() it will finish the rest of the proc while waiting.
mob
proc/AI() //Define a new proc called AI.
step_rand(src) //Tell src to step in a random direction.
spawn(20)//After 2 seconds (Aka 20 ticks) "spawn" the following stuff.
AI()//Call AI() again.

Ok, now when you call AI() every two seconds it will call AI() again, aswell as move the mob in a random direction.
Now we just need a way to make each mob call this when it starts.
We'll use the built in New() proc that everything has. We basically want to tack a little bit on the end, that calls AI() when ever a new mob is made.
Remember, when you use a built in proc there is no need to put proc/ before its name.
mob
New() //The built in proc that is called when you make a new mob.
..() //..() tells it to do the normal new stuff.
spawn(5)//After 5 tenths of a second "spawn" the following stuff.
AI()//Call the mobs AI proc.

Pay special attention to ..(). That bit tell a proc to do what ever the original proc did. Its very important.

Ok, now you have a basic AI() system. It wont work in your game, but Ive given you everything you need to know in order to make a similar system that will work for you.
In response to DarkView


Cool thx man it works but theres 1 BUG whenever I login it thinks im the new mob and makes me do the random movement.. and the cow just sits there..
mob/animal/cow
var
minIQ;maxIQ //Movement variables
New()
..()
minIQ=rand(10,15);maxIQ=minIQ*rand(1.5,3)
AI() //Call the AI proc
proc/AI()
sleep(rand(minIQ,maxIQ))
step_rand(src) //This will allow them to step randomly
AI() //loop the proc


This isn't the most efficient way, but it works.

~;)\)3();~
In response to Crossfire_96
Make sure AI() isnt in called by your player or else hell be stuck moving around forever