mob
rat
hp=5
maxhp=5
icon='ICONS.dmi'
icon_state="Rat"
attackable=1
xpgiven=1
New()
walkloop
var/mob/M
var/walky = rand(1,8)
for(M as mob in get_step(src,src.dir))
if(!M.client){goto nxt}
M.hp -= 1
if(M.hp <= 0) {
oview()<<"<font color=red>[src] has killed [M]!"
if(!M.client){del(M);goto nxt}
M.loc = locate(1,1,2)
M.hp = M.maxhp
}
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: Well, as long as you're right next to the enemy, they'll attack you, but they won't chase you. Anyone know why?
- Reduce your code by sharing variables and procs between mobs and especially your monsters.
- Use walk_rand to move your mobs around randomly
- Trigger monsters as players get near them. You can also improve performance by placing triggers around your world which let the player know when they should or shouldn't be looking for monsters. While in a safe town, there may be no need to look for monsters.
- If a monster is triggered but the player leaves the area, put the monster to sleep after a short time. This help with perf.