Boss
name = "Evil Frog"
hp = 1000
strength = 60
defense = 36
icon_state="boss"
level=6
GOOGLEPLEX=1
isplayer=0
var/mob/character/Player
New()
src.sx=src.x
src.sy=src.y
src.sz=src.z
var/mob/M
for(M as mob in get_step(src,src.dir))
if(!M.client){goto nxt}
for(M as mob in oview(1))
if(usr.canattack==1)
var/damage = rand(1,strength)
sleep(10)
damage -= M.defense
if(damage<=0)
M<<"[src] missed you!"
goto nxt
return
M.hp -= damage
M <<"You are being attacked for [damage] by [src]!"
src.exp += rand(5,10)
src.level_up()
M.death_check(src)
goto nxt
nxt
step_rand(8)
Old Functional Code:
Boss
name = "Evil Frog"
hp = 1000
strength = 60
defense = 36
icon_state="boss"
level=6
GOOGLEPLEX=1
isplayer=0
var/mob/character/Player
New()
src.sx=src.x
src.sy=src.y
src.sz=src.z
walkloop
var/walky = rand(1,8)
var/mob/M
for(M as mob in get_step(src,src.dir))
if(!M.client){goto nxt}
for(M as mob in oview(1))
if(usr.canattack==1)
var/damage = rand(1,strength)
sleep(10)
damage -= M.defense
if(damage<=0)
M<<"[src] missed you!"
goto nxt
return
M.hp -= damage
M <<"You are being attacked for [damage] by [src]!"
src.exp += rand(5,10)
src.level_up()
M.death_check(src)
goto nxt
nxt
var/mob/P
for(P in oview(1))
if(P.client) {
dir = get_dir(src,P)
sleep(4)
goto walkloop
}
for(P in view())
if(P.client) {
step_to(src,P)
sleep(3)
goto walkloop
}
if(walky == 1) {
step(src,NORTH)
sleep(10)
goto walkloop
}
if(walky == 2) {
step(src,SOUTH)
sleep(10)
goto walkloop
}
if(walky == 3) {
step(src,EAST)
sleep(10)
goto walkloop
}
if(walky == 4) {
step(src,WEST)
sleep(10)
goto walkloop
}
if(walky == 5) {
step(src,NORTHWEST)
sleep(10)
goto walkloop
}
if(walky == 6) {
step(src,NORTHEAST)
sleep(10)
goto walkloop
}
if(walky == 7) {
step(src,SOUTHWEST)
sleep(10)
goto walkloop
}
if(walky == 8) {
step(src,SOUTHEAST)
sleep(10)
goto walkloop
}
Problem description:
With the old code in place, the Boss will follow you and attack you. But with the new code, it just stands there frozen.
Now to answer your question. You go through the search & destroy-ish code one time at start up. So it finishes and then when it would actually see you, it's not trying to kill you.
Use a while loop, but don't forget to use spawn() or else your game will freeze.