ID:171308
![]() Oct 15 2004, 11:31 am
|
|
How do i make a mob that can move around on its own like random?
|
![]() Oct 15 2004, 11:47 am
|
|
Yes, using step_rand().
|
I got this, my friend helped me its error free but the npcs dont move....
mob |
Firstly, put a sleep in that thing.
proc/Wander() Secondly, you need to call it in the object's New function. mob/Blue/New() |
Loduwijk wrote:
Firstly, put a sleep in that thing. > proc/Wander() Secondly, you need to call it in the object's New function. > mob/Blue/New() like tis? proc/Wander() while(src) step_rand(src) sleep(1) mob Blue icon = 'Ghostys.dmi' icon_state = "Blue" density = 0 spawn() Wander() </dm>cause that aint working |
Ok you don't seem to understand a KEY POINT.
mob NO! You can't do that! EVER! You can't call processes like you define variables(such as the icon, hp, icon state etc etc). You can do this however: mob That's how you make a proc with information to do something, the while(src) and sleep(10) mean as long as the mob exists, wait 1 second and then call step_rand for the mob. Now if you need a way to make the mob actually USE that proc, you need a way to call it. The most effective way in this case would be to do this: mob You need to understand you can't put commands where you define variables like icons. |
For NPC's, you'll need to use lists and the pick() proc to pick from the list and move the NPC in that chosen direction.
var/list/directions = list(NORTH,SOUTH,EAST,WEST) Look up lists, pick and the step commands instead of using copy and paste. As for the client, as soon as the diagnol proc is called, we'll end it. client Do the same for NE,SW and SE. |
I have not clocked both to see which is actually faster, but I assume that continually looping using while is faster than recusively calling a function from itself. Having it call itself creates a small amount of overhead, whereas continuously looping with while just keeps doing the same thing over without the extra calculations needed to call a function.
Byond needs a function that allows you to see exactly how long it is between two points in time. That would make it much easier to clock various code designs. In fact, I will go suggest that in the Q&A right now. That would be great. |