ID:148142
 
Well im messing around with pets and pet control. I made the movement proc which works but can't seem to stop it, tried using break or return but maybe im not using it correctly. Heres the code:


Pet_Movement(mob/M)
set background=1
while(src)
for(M in view())
if(M.name==src.owner)
if(src.mode=="Follow")
if(get_dist(src,M)>=1)
walk_to(src,M,1,1)
sleep(10)
Pet_Movement()
else
return


Then i would like to have this proc end so if can run this proc:

Pet_Attack(mob/M)
for(M in view())
if(M.name==src.target)
if(src.mode=="Attack Target")
if(get_dist(src,M)>=1)
walk_to(src,M,1,1)
else
return
else
return

So i changed the first proc to:


Pet_Movement(mob/M)
set background=1
while(src)
for(M in view())
if(M.name==src.owner)
if(src.mode=="Follow")
if(get_dist(src,M)>=1)
walk_to(src,M,1,1)
sleep(10)
Pet_Movement()
else if(src.mode=="Attack Target")
break Pet_Movement()
src.Pet_Attack()
else
return

but then the pet no longer follows the usr even if its mode is set on follow. Pet coding is something new to me so would appreciate any help thanks in advance.


[EDIT ADD]
Now the pet movements not even working hmmm im not sure why that is either, it was working not 2minutes ago arrgh.--Wait it works but seems i have ot tell it to follow without it doing it auto like it did before.

-Kalzimere
One problem in there is that view() needs to be view(src). By default view() uses usr as a frame of reference, which isn't really valid here and will have unpredictable results.

Lummox JR
In response to Lummox JR
thanks for the info Lummox, changed that in code so should help, its still not working really and im not sure why, but thanks again for help.

-Kalzimere
In response to Kalzimere
hey,

Mind if I try to make the code work? I'm trying to create a "Summoner" class in my code that uses pets and pet strengthening spells as a main part of attacking and I'm not having much luck coming up with a way to "control" the pet.. I was hoping to create a Panel which would host several commands, Follow, stay, attack, guard, protect, Die etc that would be used to control each creature that you summon.