Heres my code:
mob
Move()
for(var/mob/monster/M in oview(5)) if(!M.woken) spawn() AI(M,src)
..()
Login()
client.view=8
..()
monster
New()
for(var/client/M in oview(5)) AI(src,M)
..()
Turtle
icon='turtle.dmi'
icon_state="strong turtle"
Level = 1
strenght = 10
defence = 10
var
woken
attacking
proc
Attack(mob/monster/T)
for(var/mob/M in get_step(T,T.dir))
var/damage = T.strenght - usr.defence
M.power -= damage
view(6)<<"[T] attacks [M] for [damage] damage!"
M:deathcheck()
AI(mob/monster/T,mob/M)
if(!T||T.client||!M.client) return
T.woken=10
while(T&&T.woken)
sleep(10)
if(T.woken>0&&get_dist(T,M)>5&&T&&M)
step_rand(T)
T.woken-=1
else if(get_dist(T,M)<6&&T&&M)
step_towards(T,M)
if(get_dist(T,M)<=1)
T.dir=get_dir(T,M)
Attack(T)
That was the AI code and here my Deathcheck
mob
proc
deathcheck()
if(src.power <= 0)
view() << "[src] dies!"
src.power = src.maxpower
src.Move(locate(42,22,3))
I would also wish to find out how to make it that if i kill a lvl 1 monster i receive less exp that killing a lvl 10 monster