ID:1130065
 
(See the best response by FIREking.)
Code:
//slime uses this ai
mob
proc
simpleAI()
while(src)
if(!target)
look()
else
if(!ability(target))
if(get_dist(src, target) > 1)
step_to(src, target)
else
dir = get_dir(src, target)
attack(target)
sleep(4 - speed)

//slime's ability
mob
slime
ability(mob/m)
if(prob(20) && get_dist(src,m) == 1)
m.getCondition(src, /Condition/poison)
return 1


Problem description:
After a slime poisons you he waits until the poison ends to move or do anything else.
I thought I could handle this problem alone, but I was reading F_A's Enemy AI demo and he says some things about call stack, and now I think this problem has something to do with.

One extra how-to question: How I make somthing only visible to the player? (this question probably was answered before, but I lazy...)
you'll probably need to show us m.getCondition

other wise, i'm assuming that function returns immediately and the loop should carry on (if the ability was successful the next step would be that sleep(4 - speed) call you have.

If speed becomes a negative number somewhere in m.getCondition, then your sleep will be unusually long (4 - -5 = 9)
In response to FIREking
mob
proc
getCondition(mob/agressor, Condition/c)
new c(src, agressor)

//and the condition object
Condition
var
active

notTemp

startAlert
overAlert
tickCount
duration
tickDelay

mob/target
owner

New(mob/alvo, mob/agressor)
target = alvo
target.conditions += src
owner = agressor
activate()

proc
activate()
active = 1
target << startAlert
checkEquals()
conditionLoop()

checkEquals()
for(var/Condition/c in target.conditions)
if(c != src && c.type == type)
if(notTemp) del c
else del src

tick()

conditionLoop()
while(active)
sleep(tickDelay)
if(duration)
tick()
tickCount += 1
duration -=1
else
finish()
del src

finish()
active = 0
target << overAlert
if(notTemp)
del src
Best response
your conditionloop sleeps, which is what causes it to wait

if you put spawn in front of a function call, processing will return immediately and that function call will be sent to the scheduler.

you should probably spawn the condition loop

    proc
activate()
active = 1
target << startAlert
checkEquals()
spawn conditionLoop()
In response to FIREking
It works now, thanks!