The deathcheck:
mob/Pokemon/deathcheck(mob/M)
if(src.hp<=0)
src.wandering=0
src.following=0
src.happiness-=5
src.fainted=1
src.contd2=1
client.cont=null
client.eye=usr
if(src.owned)
src.loc=locate(src.owner)
oview(12) << "[src] fainted!"
else
del(src)
The proc:
mob/proc/deathcheck()
if(src.hp<=0)
..()
A return verb.
Return()
set category = "PokeCommands"
for(var/mob/Pokemon/P in oview(12)&usr.pokemonlist)
if(P.owner==usr&&P.returned==1)
usr<<"They are already in your bag!"
return
if(usr.PkmInInven==6)
usr << "You cant hold anymore pokemon in your pockets!"
return
else
walk(P,0)
P.loc=usr
P.returned=1
P.following=0
P.wandering=0
P.Training=0
P.contd2=1
client.cont=null
client.eye=usr
// Pmove=0
view(12) << "[usr]: [P] return!"
usr.PkmInInven+=1
return
Problem description:
Well, what I basicly want to do is when the pokemon faints, it goes back to his owner's backpack and put the fainted var on 1, and do the things that the return verb does like P.contd2=1
client.cont=null
client.eye=usr
But the pokemon doesn't seem to faint anymore after I changed the deathcheck like I thought it would work out.. Also I got a blackscreen before when the code was still working but I didn't add
P.contd2=1
client.cont=null
client.eye=usr
to it yet.
I can't seem to work this out by myself so any help would be greatly appreciated.
Additionally, you are using usr in procs, which you should not be. Namely, the line client.eye = usr is using usr, and oview(12) is implicitly using usr as it defaults to oview(12,usr). You should replace the first one with whatever it is you actually want to set the client's eye to (presumably, their actual mob, so that would be client.mob) and the second with oview(12,src).