ID:262868
 
Code:
mob
TSO
name = "TSO (AI)"
Health = 150
maxHealth = 150
icon = 'TSO.dmi'
var/mob/Target
New()
..()
spawn(5)
src.Wander()
proc
Wander()
while(src)
sleep(5)
for(var/mob/Army/M in oview(10))
src.Target = M
break
if(src.Target)
//var/mob/Army/
if(src.Health<Target.Health)
var/Rand = rand(1,10)
if(Rand>=8)
step_away(src,Target)
sleep(1)
step_away(src,Target)
sleep(1)
step_away(src,Target)
else
step_towards(src,Target)
if(get_dist(src,Target) <= 1)
Target<<"[src] punched you for 20 damage."
Target.Health-=20
if(Target.Health<=0)
world<<"<font color = yellow>*[src] killed [Target]*"
usr.Kills+=1
Target.loc=locate(0,0,0)
if(Target.name =="TSO (AI)")
ai-=1
CheckIfGameOver()



else
step_towards(src,Target)
if(get_dist(src,Target) <= 1)
Target<<"[src] punched you for 20 damage."
Target.Health-=20
if(Target.Health<=0)
world<<"<font color = yellow>*[src] killed [Target]*"
usr.Kills+=1
Target.loc=locate(0,0,0)
if(Target.name =="TSO (AI)")
ai-=1
CheckIfGameOver()



else
step_rand(src)


Problem description:
The TSO AI always comes by me but never attacks. I need to make it attack me and I have tried a lot of things to get it to work. Maybe it is a typo or I am just doing it all wrong.

->Calus CoRPS<-

Well, this may not or may be a solution, but here is a suggestion. They way I usuall do AI for melee combat, is to call the damage from the Bump() proc.
In response to Sniper Joe
I did put bump and it still will not work. Here is new code but it wont work either.

mob
TSO
name = "TSO (AI)"
icon = 'TSO.dmi'
Health = 100
maxHealth = 100
var/mob/Army/P
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
if(P in oview(5))
step_towards(src,P)
for(P in oview(1))
break
for(P in oview(2))
break
for(P in oview(3))
break
for(P in oview(4))
break
else
step_rand(src)
sleep(10)
for(P in oview(5))
break
sleep(5)
spawn(5)
Wander()
Bump(mob/M)
if(M.team == "Army")
Fight(M)
else
return

proc/Fight(mob/M)
M.Health -= 20
M << "*<font color = yellow>[src] attacks you*"
Dcheck(M)
mob
proc/Dcheck(mob/M)
if(M.Health <= 0)
M<<"*<font color = red>[M] Died*"
M.loc = locate(0,0,0)

The TSO still will not attack the army.


->Calus CoRPS<-
In response to Calus CoRPS
I doubt step_toward() actually bumps. Try using step_to()