ID:267586
Jul 20 2003, 4:11 pm
|
|
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 |
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 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
|
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.
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.
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.
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.
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.