ID:320082
 
(See the best response by Gland Mopa.)
This one works:

mob/verb/CAttack()
for(var/mob/m as mob)
set src in view(1)
step_to(src,m)
if(get_dist(src,m)<=1)
m.hp-=10
else step_to(src,m)

mob/cassios
icon='cassios.dmi'

mob/cassios/
New()
FightingAI()
death()


mob/cassios/proc/death()
while(src)
for(var/mob/m as mob)
if(m.hp<=0)
new/obj/armor(locate(1,1,1,))
world << "Athena: Congratulations Seiya, you have earned the Pegasus Cloth!"
del src
sleep(5)
sleep(5)

mob/cassios/proc/FightingAI() // new shit learned!!
while(src)
for(var/mob/M in oview())
if(get_dist(src,M)<=1)
src.dir=get_dir(src,M)
spawn(10)
src.CAttack()
src.death()
else
step_to(src,M)
trg=2
sleep(10)


This one doesn't:

mob/shina/proc
come(var/mob/shina/S)
var/mob/m
if(m.trg==1)
step_to(src, m)
else return


mob/var/trg=1

mob/shina
icon='shina.dmi'
New()
come()


Problem description: I am trying to have Shina walk towards me but it doesn't work unlike the one above. What does the one above have that the below one doesn't?
Best response
mob/shina/proc
come(var/mob/shina/S)
var/mob/m
if(m.trg==1)
step_to(src, m)
else return

1- m is null so shina can't walk to him;
2- The proc doesn't loop, so when shina is created she will search one time and then stops.

You should make an AI proc like the Cassios AI, just make some changes.
In response to Gland Mopa (#1)
Gland Mopa wrote:
> mob/shina/proc
> come(var/mob/shina/S)
> var/mob/m
> if(m.trg==1)
> step_to(src, m)
> else return
>

1- m is null so shina can't walk to him;
2- The proc doesn't loop, so when shina is created she will search one time and then stops.

You should make an AI proc like the Cassios AI, just make some changes.

How do I make m not null? I thought I made it target the player?
You need to assign m to the player before use step_to.
Like this:
mob/shina
var/target
proc

look()
for(var/mob/m in oview(src)) //Look to every mob in src's oview
if(m.client) //if the mob is a player...
target = m //..now is her target

come() // Don't need to put anything here
while(src) // to loop
if(target)
step_to(src,target)
else
look()
sleep(10)
New()
..()
come()