ID:140281
 
Code:
mob
proc
AI()
while(src.owner=="None")
if(src.Attacked==0)
step_rand(src)
sleep(20)
else
if(src.Attacker:Rank2=="Pokemon")
..()
else
spawn(100)
src.Attacker<<"[src] fleed."
del(src)
step_towards(src,src.Attacker)
for(var/mob/M in get_step(src,src.dir))
if(M==src.Attacker)
if(M.Rank2=="Pokemon")
if(src.First==1)
src.MHP=M.MHP
src.HP=M.MHP
src.First=0
var/damage = round(src.Attacker:Attack*2/8)
src.Attacker<<"The Pokemon has done [damage] damage."
src.Attacker:HP -= damage
if(src.Attacker:HP<=0)
src.Attacker:HP=0
src.Attacker<< output("Your Pokemon fainted. Please return it now.","default.BattleInfo")
src.Attacker:overlays+='pokeball2.dmi'
src.Attacker:Faint=1
src.Attacker:Faint2=1
src.Attacker<< output("The enemy Pokemon has fleed.","default.BattleInfo")
del(src)
sleep(10)
src.AI()
else
..()
else
..()
sleep(5)


Problem description:
See, if I catch a Pokemon, it still "flees" after a certain ammount of time, which means it disappears. How can I fix this? Sorry for being so vague. Oh, and by the way, after the Pokemon is caught, owner is changed to usr.key.

Check the conditions for whether it should be allowed to flee before it flees.
In response to Garthor
while(src.owner=="None")
is the condition
You shouldn't use :. Use . and typecasting.
In response to Xyphon101
The conditions of a while() statement are not checked continuously. They're only checked immediately before an iteration.
In response to Garthor
Yeah, Garthor, I realized what you meant the second after I posted my reply XD thanks.