ID:263421
 
Code:
mob/NPC

New()
..()
Wander()

proc/Wander()
walk_rand(src,movedelay)
// Search()

proc/Search()
for(var/mob/M in oview(6))
walk(src,0)
walk_to(src,M,0,movedelay)

Move()
..()
Search()

Bump(mob/M in get_step(M,src.dir))
..()
if(!istype(M,/mob/NPC))
if(M.safe)
return
else
flick("attack",src)
var/extra = rand(1,4)
var/damage = src.strength + extra - M.endurance
M.HP -= damage
if(M.HP <= 0)
world << "[M] has been killed by [src]!"
M.loc=locate(0,0,0)


Problem description:
I want to make a wandering and attack proc for NPCs, but it doesn't work, why?
Please explain in detail what you're trying to accomplish.

You know only one walk()/walk_rand() etc proc can be running at a time? If you attempt to run 2, the first one will get cancelled.
In response to Kaioken (#1)
Actually, I think I fixed it -_- I put the // behind Search(), so it never started.

Also, it approaches me and moves around me, but it doesn't hurt me. And I don't want him to move around me like that..
Would I be able to make a Attack verb for the NPC and initiate it once he bumps into me?
In response to Masuko Shintaro (#2)
Masuko Shintaro wrote:
Also, it approaches me and moves around me, but it doesn't hurt me. And I don't want him to move around me like that..

Pff...Re-read my previous post. Explain what you do want...

Would I be able to make a Attack verb for the NPC and initiate it once he bumps into me?

Yes, why not? Though making a new verb for an NPC only would be pretty silly, mind you, just make it a proc (verbs are types of proc BTW).

You can even make the NPC use the Attack verb for players... you can call verbs like procs.
So if you have:
mob/verb/Attack()
var/mob/M = locate() in get_step(src,src.dir)
...

//===========================
//===========================

mob/NPC/proc/AI()
...
src.dir = get_dir(src,mob_to_attack)
src.Attack() //call the attack verb


NOTE: For this to work, when coding mob/verb's, you MUST use 'src' instead of 'usr'.
'usr' will only work when a player runs the verb and won't work if you call it manually (without taking care to set usr first).
However, if you use 'src' in the verb, it will work for both cases.