mob
AI
New()
..()
spawn() Wander()
NPC = 0
Enemy = 1
Resting = 0
target = null
stamina = 10
icon = 'icons.dmi'
var/Race_Alignment
Goblin
Race_Alignment = .Goblin
Archer
attack = 10
defense = 5
icon_state = "mob-2"
proc
Wander()
if(target)
if(get_dist(src, target) > 1)
step_to(src, target)
sleep(5)
else
Attack(target)
sleep(10)
else
get_target()
if(target)
sleep(5)
else
step_rand(src)
sleep(20)
spawn() Wander()
get_target()
for(var/mob/m in oview(2,src))
if(m==src.Race_Alignment) return
target = m
return
Problem description:
Basically the problem is this.
I have two npcs and they're from the same race (in this example goblin), they shouldn't attack each other. But in my code they attack each other and ignore me. What am i doing wrong?
One problem is here:
You're using "return" in a for loop. That's not good unless you want to kill the loop entirely, because it kills the whole proc. Perhaps what you meant to use was "continue".
Another problem is that I don't think var/mob/m is compatible with var/Race_Alignment for a direct comparison like that. You might want to set var/Race_Alignment on all mobs and do a comparison of m.Race_Alignment instead.