ID:146820
 
i have been working on this bit of code for a long time and im really frustrated on how to get this to work. the purpose is to make NPC's attack each other by running toward each other and call the Bump proc, which calls the attack proc. HELP!!

mob/NPC
var/mob/NPC/m
verb/charge()
while(src)
for(var/mob/NPC/ptarget in oview(5,src))
if(src.colorofwar == ptarget.colorofwar)
continue
else
m = ptarget
break
if(m.colorofwar == src.colorofwar)
WalkAround(src)
else
Wander(src)
proc/Wander()
if(m in oview(5))
step_towards(src,m)
Bump(mob,n)
if(istype(n,/mob/NPC))
attack(n)
proc/attack()
sleep(2)
var/damage = Strength - m.Vitality
m.HP -= damage
view(src) << "[src] attacks [m]!"
view(src) << "[damage] damage."
if(m.HP < 0)
del(src)
proc/WalkAround()
step(src, pick(NORTH,NORTHEAST,NORTHWEST,SOUTH,SOUTHEAST,SOUTHWEST,EAST,WEST))<\DM>
Well, you call your attack proc like this : attack(n). That means the Attack proc is trying to use that arguement...but can't. Try making the attack proc look for an argument like mob/npc/M and then use M instead of src. Also I just noticed that var/mob/NPC/M is at the top, It is better to defien it for the proc I think.
It helps a lot if you say what the problem is. What error messages are you getting? If you're not getting any error messages, what exactly is the problem?
In response to N1ghtW1ng
woops, forgot to say whats wrong. There are no errors or warnings, its just that when i run the game, the NPC's do nothing, they just stay still. Whether it has an NPC in oview(5) or not, some bug is making them stand still when they should be randomly stepping or running towards the NPC. I hope this helps.