ID:162820
 
How would i code a mob to move around like wander around the game?? Im new to doing this.
Simply, walk_rand(). Look it up in the reference.
In response to Kaiochao2536
Thanks
In response to Trane5
Im havin a bit trouble understanding can you show example
In response to Trane5
mob/New()
..()
walk_rand(src,10)

That would make the mob start walking randomly after being created, taking one step a second.
In response to Kaiochao2536
k thanks a lot. So.. i was thinkin how would i add if some thing in oview that is a diffrent race it attacks it.
In response to Trane5
If it's an AI battle system you're looking for, start looking.
wandering NPCs are always fun =D
mob/NPCs/
Dude
name = "Dude"
icon = 'base.dmi'
icon_state = ""
New()
Wander()
proc/Wander(mob/P)
while(src)
step_rand(src) //if no NPC is 5 blocks or less away walk around
sleep(20) //stop for 1 second
for(P in oview(5)) //.......
break
sleep(1)
spawn(1)
Wander()//Wonder again...
In response to Lt. Pain
If you make a while look and then spawn itself, you're gonna get two Wander procs, which will eventually crash the game.

And apparently you should insert the attack proc where "break" is.
In response to Lt. Pain
                for(P in oview(5)) //.......


For the five BILLIONTH time, NO! oview(5) defaults to oview(usr,5). usr in any proc is flat-out WRONG. You should be using oview(src,5) instead.

As for KaioChao's comment: he's totally wrong. Ignore what he says, though he does bring up the point that the mob doesn't actually do anything but wander around. His suggestion, of course, is totally wrong: the call to Wander() at the end of Wander() should be changed to a call to another proc, such as Attack(P), which will follow P until it no longer can, at which point Wander() is called again.

Oh, and while Wander(mob/P) will technically work... it's not written in a proper manner. mob/P shouldn't be defined as an argument (as it's not something you'd ever pass to the Wander() proc. Either make it a variable of the mob, or define it within the Wander() proc. This is one of those fun little mistakes that make code incredibly obtuse while, at the same time, still work perfectly and perpetuate themselves, generally sowing confusion in their wake.
If an AI system is what you are trying to do check this one out http://developer.byond.com/hub/XstreamSage/MonsterAI is pretty handi you can then edit it to fit what you are trying to do
In response to Nidaime Hokage
I'd advise against that. That demo is horribly convoluted and broken.