//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()
ID:147931
![]() Sep 21 2003, 11:48 am
|
|
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 |
//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 |
//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 |
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>