mob
Unit
proc
Attack()
spawn(20)
src.Attack()
var/d=100
var/mob/Unit/E
for(var/mob/Unit/e in orange(4))
if(get_dist(src,e)<d)
if(e.owned!=src.owned&&src.dead==0)
if(e.dead==0)
d=get_dist(src,e)
e=E
if(E)
step_to(src,E)
flick("shoot",src)
E.hp-=src.dmg
if(E.hp<=0)
E.death(E)
src.kills++
if(!E)
var/obj/Buildings/b
for(var/obj/Buildings/B in orange(1))
if(B.owned!=src.owned)
if(src.dead==0)
b=B
if(b)
flick("shoot",src)
b.hp-=4
if(b.hp<=0)
b.dead(b)
Problem description:
The code above is supposed to make the Soldier who sees an enemy within 4 tiles, move towards him and attack him.
(I know, you may see that theres no way for the victim to dodge any bullets but thats how its intended.)
It also checks for buildings withing 1 tile, and then attacks it until it gets destroyed.
The problem: It doesn't do anything, the Soldiers stand there and look at each other.
Two, make sure Attack is called when the soldier is created.