ID:142236
 
Code:
proc/Unique(speed) 
while(awake)
if (P in oview())
if(hasspells==0)
step_towards(src,P)
if(Unique==1)
step_towards(src,P)
step_towards(src,P)
else
var/V = rand(1,6)
switch(V)
if(1)
if(fireboltlevel>0)
FIREbolt()
else
step_towards(src,P)
if(2)
if(iceboltlevel>0)
ICEbolt()
else
step_towards(src,P)
if(3)
if(lightningboltlevel>0)
LITbolt()
else
step_towards(src,P)
if(4)
if(feedbacklevel>0)
FEEDBACK()
else
step_towards(src,P)
if(5)
if(poisonlevel>0)
POISON()
else
step_towards(src,P)
if(6)
if(darklevel>0)
DARK()
else
step_towards(src,P)

spawn(speed)
Unique(speed)


Problem description:

On the first part at the top, where it says "while(awake)" the awake var isnt being read for some reason. what im trying to do is, make it so all the monsters in the game are frozen, and then when monsters come in view to the player ONLY the monsters in view of the player come unfrozen while all the rest are still frozen. But the code i have for the monsters for when they come in view to turn the awake var on to 1. That "while(awake)" doesnt work, the monsters dont come unfrozen =/ even if the var is turned on. Help please??? I am doing this to reduce lag in my game.
Have you done checks to see if "awake" is actually being set to 1 correctly? Can you show us where that happens?

There isn't a case I can think of where a var won't be "read" correctly.

P.S. I'm assuming the proc isn't like...a world proc, right? Who is "src" in this? Who is "p"? Kinda in the dark here.
In response to K'ros Trikare
Yes, i have checked to see if the var has ben set to 1. I would use a edit verb on the monster and check that var and it will be set to 1. And here is the proc for setting the var to 1.

proc/mawake()
for(var/mob/enemies/e in oview())
e.awake=1



Also, I couldnt figure out how, but if you could, help me figure out how to make it so in that same proc after you kill all the monsters in view, the var is turned off, set back to 0.
In response to Yamikaiba1236
Still need a little more info about the original proc. I don't see where you define what P is.

Can you show me that, and also where you call the proc?
In response to K'ros Trikare
P is the user. That is defined in the code file. And the mamke proc is called with the stat so it calls alot to make sure so people arent killing the monsters while they are frozen. And the Unique(speed) proc is called by the monsters. its in the monster code. I'll give you a example.


scorpion
icon_state = "scorpion"
level = 2
Speed = 10
HP = 15
MAXHP = 15
MP = 3
MAXMP = 3
expgive = 4
goldgive = 10
Strength = 3
Intelligence = 2
firewk=15
hasspells = 10
poisonlevel=1
New()
.=..()
spawn(1)
Unique proc>>>> Unique(Speed)
Bump(mob/players/M)
if (istype(M,/mob/players))
Attack(M)
proc/Attack(mob/players/M)
flick("scorpion_attack",src)
sleep(2)
if (prob(M.tempevade))
view(src) << "[src] \red misses <font color = black>[M]"
else
HitPlayer(M)
Making all enemies in the world constantly have a loop going is not good. Instead, only have them do anything when they are actually in view of a player.
Unique(speed)
awake=1 //make them awake
for()//awake var not needed
if(!(locate(/mob) in view(src))) break //end if no mobs in view
//code
sleep(speed)//sleep for the delay
awake=null //make them not awake when it's over
turf/Entered(var/mob/O) //when something enters
if(istype(O,/mob)&&O.client) //make sure it's a mob with a player connected
for(var/mob/enemies/e in oview(src)) //get all enemies in oview()
if(e.awake) continue //skip if the enmy is already in action
spawn() e.Unique(1) //make them start with a delay of 1 tick
//spawn so the loop continues
In response to Naokohiro
Alright, ill test to see if it works. =] Thanks alot.
In response to Naokohiro
I tried it. And it still doesnt work. The monsters are frozen even when a player comes in view of them. And even tho they are frozen, i still get a bunch of lag. =/
In response to Yamikaiba1236
Show the relevant parts of your code.
In response to Naokohiro
if you got msn add me. would be easy to talk about it on there.

[email protected]