ID:138713
 
I am trying to make an NPC walk towards me but it doesn't work.

mob/shina/proc/move()
while(src)
src.Move(usr,usr)
sleep(10)

mob/shina/
icon='shina.dmi'
New()
move()


I make a proc for move with infinite loop of as long as shina exists it will move towards me. Then I used the predefined New() proc giving it the special initialization that when it is created it will begin moving towards me. But nothing happens! What did I do wrong?
It says step_towards is an unidentified proc, why?
I fixed what you said and it still doesn't work

mob/shina/proc/come()
while(src)
step_towards(src,src.target)
sleep(10)

mob/shina/
var/target
icon='shina.dmi'
New()
come()
In response to TheDarkChakra
If it isn't moving it's because you haven't defined a target.
Medicator wrote:
First of all, I suggest not using built-in proc names, even if the casing is different.

go2who() is not a built in proc so far as I know...
In response to Kaigne
Yes, you can define the target in the use of the New() proc.

One thing I'm surprised anyone has failed to mention if that when calling New(), make sure you call the parent proc ..() or else the basic creation won't even happen!
In response to El Wookie
El Wookie wrote:
Medicator wrote:
First of all, I suggest not using built-in proc names, even if the casing is different.

go2who() is not a built in proc so far as I know...
She used move() as her proc name. I changed it to Go2Who
In response to Speedro
Speedro wrote:
One thing I'm surprised anyone has failed to mention if that when calling New(), make sure you call the parent proc ..() or else the basic creation won't even happen!

This is wrong. New() is called after an object has been created.

- Hashir
In response to Hashir
No one has helped yet!
In response to TheDarkChakra
I think you didn't pay attention to what others said.

Your NPC isn't moving towards you because it has no target. Its target variable should contain a reference to a mob it has to move to.

Example:

mob/npc

var/mob/target

New()
..()
spawn() AI()

proc/AI()
while(src)
if(!src.target) find_target() // if our npc doesn't have a target, find one.
else step_to(src, src.target) // otherwise, move towards them.
sleep(15)

proc/find_target()
var/mob/M = locate() in oview()
if(M) src.target = M // if found a mob in our npc's view, make that mob our npc's target.
In response to Hashir
Well. That's embarrasing. Time to cover my tracks...:

Maybe I was thinking of client based things like so:

client
New()
world << "trolol"
In response to Hashir
Why doesn't my target work:

mob/verb/PM(mob/m as mob in world, PM as text)
src << "[usr]:[PM]"

mob/shina/proc/come()
for(var/mob/m as mob in world)
if(m==src)
return
else if(m==usr)
step_towards(m,src.target)
sleep(10)

mob/shina/
var/target
icon='shina.dmi'
New()
come()


?
In response to Speedro
client/New() has a default action unlike atom/New() or datum/New() if you read it up in the reference. Not calling . . ( ) in client/New() is going to cause some problems.
In response to TheDarkChakra
I don't see your target var holding a reference to a mob anywhere.
In response to Hashir
mind fixing my code up?