ID:147931
 
//I cant seem to pass the target into the npcattacks proc....


mob/var
angry = 0
enemy
attackpic
attackdelay
mob/verb/Attack(mob/M as mob in get_step(src,src.dir))pcattacks(M)
mob/proc/pcattacks(mob/M)
var/mob/target = M
var/mob/attacker = src
target.enemy = attacker
target.angry = 1
flick("rogue attack",attacker)
target.dir = get_dir(target,attacker)
npcattacks(target)
mob/proc/npcattacks(mob/M as mob)
if(M.enemy)
flick("blue wyvern attack",M)
sleep(10)
npcattacks()
Took a bit of looking, but here's the problem. =)

sleep(10)
npcattacks()

Inside npcattacks(), you're calling npcattacks() again. That's fine, except for two things: Firstly, you're not passing the argument to it again; and secondly, it's much kinder to the computer if you use spawn() instead of sleep() in that kind of situation.

<code>spawn(10) npcattacks(target) //Note the extra indent on this line</code>
In response to Crispy
If you don't assign anything to something, it's value will be null, and you can't read or write variables to something that's null.

Try
var/continue=1
spawn while(continue)
flick() // Fill this in.
// More code...
// Set "continue" to 0 to stop the loop.
In response to Yota
//here is the complete coding... but it freezes up -_-

mob/var
angry = 0
enemy
chasedelay = 0
attackpic
attackdelay
mob/verb/Attack(mob/M as mob in get_step(src,src.dir))pcattacks(M)
mob/proc/pcattacks(mob/M)
var/mob/target = M
var/mob/attacker = src
target.enemy = attacker
target.angry = 1
flick("rogue attack",attacker)
npcattacks
target.dir = get_dir(target,attacker)
if(attacker in get_step(target,target.dir))
flick("blue wyvern attack",M)
spawn(attackdelay)
goto npcattacks
else
spawn(target.chasedelay)
walk_towards(target,attacker)
goto npcattacks
In response to Xallius
//I fixed it! but now I have another problem -_- ....
//When i attack back, the enemy attacks faster too
//Is there any way that i can seperate these?

//heres my coding...
mob/var
enemy
chasedelay = 0
attacking = 0
attackpic
attackdelay
delayattack = 0
mob/verb/Attack(mob/M as mob in get_step(src,src.dir))pcattacks(M)
mob/proc/pcattacks(mob/M)
var/mob/target = M
var/mob/attacker = src
src.delayattack = 1
target.enemy = attacker
flick("rogue attack",attacker)
npcattacks
target.dir = get_dir(target,attacker)
if(attacker in get_step(target,target.dir))
flick("blue wyvern attack",target)
flick("rogue damage",attacker)
spawn(10)
goto npcattacks
else
walk_towards(target,target.enemy,2)
spawn(10)
goto npcattacks
In response to Xallius
Yuck. WHY have you changed from using a proc to using goto? Goto is an absolutely terrible solution, when all you needed to do from your original post is to change a couple of lines. Delete that code, go back to what you had before, and implement my two suggestions. That's ALL you need to do.