mob
var/goldgive = 0
var/expgive = 0
icon = 'mob.dmi'
Lizard_Warrior
icon_state = "lizard"
expgive = 10
goldgive = 20
hp = 50
mhp = 50
name = "Lizard Warrior"
New()
..()
spawn() check()
spawn() walkR()
proc
check()
for(var/mob/M in view(10))
if(M.client)
step_to(src,M,10)
for(M in view(1))
if(M.client)
src.attack(M)
spawn(5) check()
walkR()
walk_rand(src,10)
spawn(5) check()
Siientx
ID:148369
![]() Mar 15 2003, 3:26 pm
|
|
I've never been good at understanding other people's code, but I can write something to replace it with that I'm pretty sure would work.
mob/yourmonster var/delay = 5 New() spawn(delay) SearchEnemy() proc/SearchEnemy() for(var/mob/M in view()) if(M.client) if(get_dist(src, M) > 1) step_to(src, M) spawn(delay) SearchEnemy() return else Attack(src, M) spawn(delay) SearchEnemy() return walk_rand(src) spawn(delay) SearchEnemy() return That should work. However, I have to recommend that you avoid using enemies that continually run the their program regardless of whether there is anything to attack or not. You might try having it so that whenever a player moves, it checks for any nearby monsters and activates their attack programs. That way you can have as many monsters as they want, and they won't be doing anything until there is something for them to interact with. |
New() I think that should do the same thing both of your procs do. If not just tell me, I wrote that out from memory so a few things might not check out. |
I like them, it makes the code nice and big, and readable. Becuase I noticed that I put the check for 10 before the check for 1.
|
Nobody managed to find your problems. One was that you were using walk_rand(), which will stop walking when you move it again. Another was that you were calling check() and walkR(), and then walkR() would call check(), which would result in two instances of check(). Another problem is you're using oview(), and not oview(src).
mob |
-GDT