mob
Pet
icon = 'Pet.dmi'
icon_state = "1"
var/mob/owner
proc/AI()
while(1)
step_towards(src,owner)
sleep(2)
mob
Login()
..()
src.icon = 'playerboy.dmi'
src.icon_state = "1"
var/mob/Pet/P = new(locate(src.x,src.y+1,src.z))
P.owner = src
P.AI()
The point is to get a pet to follow you around.
Oh and what do you guys think of this:
id:319976
Yup. Plenty:
Now, look at AI() for a second. First of all, since it isn't set in the background it will crash after 255 run throughs. The problem occurs when either the pet is deleted or the owner logs out. If there is no owner, then it will be walking towards null, and if the pet gets deleted, then since AI() keeps running as long as the world exists, it will keep running, and therefore, cause a runtime.
Finally, I think that with that proc, you'll find some diffculties. First and foremost, if the player gets teleoprted somewhere or switches z levels, it wouldn't work. Second, you'll probably find the pet's movement relatively erratic when the player is standing still.
Of course, all of these problems can be avoided by overriding mob/Player/Move(). However, if you're doing that, you'll find it much, much more convenient to have a list of a player's pets.
Finally, alot of the things you're doing in mob/Login() should probably be done in mob/Pet/New() instead.