mob
Enemy
var/mob/Target
Type_1
New()
..()
spawn(5) src.Wander()
proc
Wander()
set background = 1
if(src)
sleep(5)
while(src)
sleep(5)
for(var/mob/Player/P in oview(src,7))
src.Target = P
if(src.Target)
if(src.Target.x >= src.x)
src.icon_state = "Left"
step(src,EAST)
if(src.Target.x <= src.x)
src.icon_state = "Right"
step(src,WEST)
else
sleep(10)
ID:265501
![]() Oct 16 2005, 1:47 pm
|
|
I am worried that this is going to bring alot of lag to my game, and/or crash it. Can someone look over it and tell me anything, if at all, is wrong or that can be done better or more efficent?
|
![]() Oct 16 2005, 2:32 pm
|
|
Sniper Joe wrote:
|
I'm not too familar with while loops, but yesterday I used a while loop and a for loop consecutively in one of my procs and that crashed my game. I had to take out the while loop, and make a few tweaks to get it how I wanted it to work. Although, I only wanted it to be called once, you probably want it your Wander() proc to be called multiple times or to initiate multiple moves.
|
[EDIT] Ok I just check reference and your code looks good. Im not sure if it will cause lag or not. Only runtime testing will probley tell that. Inless you want to get into C++ and Programming Algorithm Anylasis. Speeking of which. O.o Lummox JR should make such an artical for the byond community. Since some might not fully understand it.
|
while(src)
That means, as long as src is not DELETED from the game, it will run that proc, so all you really need to do is end the battle by saying del(Monster) Doubt it would lag your game that much, but put some sleeps in there just to be safe. |