ID:166198
 
I've tryed at least 4 diffrent libraries to learn off of and nothing has worked. The first time the monster spawned but did not follow the player, the second time the monster didnt spawn at all. I've tryed for awhile now. Could someone please show me how to make a system where you choose a verb, which then you choose a monster in you contents, then the monster follows you. Puting this in code rather than explaining in words helps me more.
Well... look up walk_to() ... call it upon the pet being created and the owner is known.... or something similar to that effect
mob/pet
var/mob/owner
New()
..()
if(owner) walk_to(src,owner,1)


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Well... look up walk_to() ... call it upon the pet being created and the owner is known.... or something similar to that effect
mob/pet
> var/mob/owner
> New()
> ..()
> if(owner) walk_to(src,owner,1)

- GhostAnime

well a few things.
1.wouldnt it be var/mob/monster due to the fact your making the monster spawn from your invintory and follow the player?
2.I've tryed it with New() and then the commands but it didnt work.(can't show you my code of it, because i deleted it)
3.Wouldn't the "if(owner) walk_to(src,owner,1) be under the verb that is releasing the monster to follow you?
In response to FriesOfDoom
It was just an example, trying to show you how to use it (walk_to) <.<

New() is called when the object is made, hence why it isn't working right now... which is why, as I said before, this is called an example.

Here's another example (Meaning learn from it, not to directly use it):
pet
Click()
if(src in usr.contents)
src.Move(get_step(usr,usr.dir))//Relocates pet to 1 step ahead of usr
walk_to(src,usr,1)
else if(src in oview(1))
walk_to(src,0)//to stop the walk_to proc... otherwise the pet would jump out of the inv
src.Move(usr)//moves it back to the inv


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Here's another example (Meaning learn from it, not to directly use it)

- GhostAnime

Geesh... bite my head off, all I did was look at the example you gave and asked those questions, I didnt use it at all.
But now how do i turn it into a proc so i dont have to keep putting it into every monster? below is what I have so far
        verb/havemonsterfollow(mob/monster/Dragon/M)
M.Follow()

mob/proc
Follow(mob/monster/M)
if(M in usr.contents)
src.Move(get_step(usr,usr.dir))
walk_to(src,usr,1)
else if(src in oview(1))
walk_to(src,0)
src.Move(usr)

I couldnt get the above to even show up in the usr's tab. I know, I know "no usr in proc ahhhh" but I couldnt think of how to arrange it. I cant figure out what I did wrong, but I probely hurt it with usr, but I can't figure out how to make it come from the usr. Oh.....Im so confused :(::::
In response to FriesOfDoom
Sorry for snapping but I am a near-sleep state...

The problem is, you did not looked/understood walk_to() in DM Reference...


it is as follows:

walk_to(Object, Target, Minimum steps away (0 is default...), Lag time (0 is default))


So what you did in the proc was made you walk to yourself...


also, I noticed you called the Follow proc as "M.Follow()" but the proc is defined as "Follow(mob/monster/M)" ... meaning that the proc will not work because you never defined what the pokemon was (M.Follow)

Revise the way you made your proc, because you kinda messed it up... as "X.Follow(A)" looks like you want the X (pokemon.. M in your example) following the A but "mob/proc/Follow(../M)" makes M (A) follow src (X)

- GhostAnime
One cool thing about BYOND is being able to store an entire datum inside of a variable of another datum. This can be used in many very useful ways, pets and whatnot are one of those ways. I'll give you a nice commented example since I'm in a pretty good mood ;). Just remember, it's only an example, you need to learn from it and adapt it to your needs.
mob
pets
dog
var
mob/pets
pet // Notice how I typecasted it as a mob above
verb
MakePet()
if(usr.pet)
usr << "You already have a pet."
return // Already have a pet, don't need another
usr.pet = new/mob/pets/dog(locate(usr.x,usr.y-1,usr.z)) //Makes a dog!


client // Best to do this in client so you don't have overhead from NPC's.
Move()
..()
if(mob.pet)
if(get_dist(mob,mob.pet) > 1) walk_to(mob.pet,mob,1,3) // Move the pet towards the player.


Nice and simple.
In response to GhostAnime
ok i fixed it finally :D
<font color=green>*edit* except now I cant recall them :(*</font>
Thank you for your help. Below is what i did to fix it, is there anything I should change to avoid problems?
        verb/Have_A_Monster_Follow()
set src in usr.contents
if(src in usr.contents)
src.Follow()


mob/proc
Follow()
if(src in usr.contents)
src.Move(get_step(usr,usr.dir))
walk_to(src,usr,1)
else if(src in oview(1))
walk_to(src,0)
src.Move(usr)
In response to FriesOfDoom
You seem to have misread me... your verb was okay, it's just that your Follow proc (mob/proc/Follow) that needs changing... I would show you what to do but I need to go to sleep now

- GhostAnime
In response to GhostAnime
me 2.....ill just get it tommarow....thx for your help, I did make another verb though to return the monster, so its not neccessary.
http://members.byond.com/SuperAntx/files/Pet_src.zip

I made it quite awhile ago but it's pretty much solid. If you need any explaining just ask, although there are comments on almost every line. =p
http://developer.byond.com/hub/RurouniDragon/FollowMe

It's a pretty straight-forward and simple demo on having one thing follow another. Excuse my nasty comments of old. :P

Hiead
In response to FriesOfDoom
Geesh... bite my head off, all I did was look at the example you gave and asked those questions, I didnt use it at all.

You're making it seem like he is flaming you, which is wrong.

I'd suggsest being nicer to people who are trying to help you.
In response to Nadrew
Nadrew, client.Move() needs to return ..(). By default, it returns 1 or 0 depending on whether it was successful, and the way you're doing it right now, you're overriding that behavior. So Fries, where Nadrew wrote ..(), you're going to want to write . = ..() instead.
In response to Wizkidd0123
Wizkidd0123 wrote:
Nadrew, client.Move() needs to return ..(). By default, it returns 1 or 0 depending on whether it was successful, and the way you're doing it right now, you're overriding that behavior. So Fries, where Nadrew wrote ..(), you're going to want to write . = ..() instead.

In extension to this, the if() check would probably also want to check the . variable, to avoid the function call if movement failed. Granted, the proc will merely return if within the minimum distance, but it would be more robust to assure that movement actually occurred before forcing the pet to respond. Something like
if( . && /* condition */)


Hiead
In response to DivineO'peanut
DivineO'peanut wrote:
Geesh... bite my head off, all I did was look at the example you gave and asked those questions, I didnt use it at all.

You're making it seem like he is flaming you, which is wrong.

I'd suggsest being nicer to people who are trying to help you.

I wasn't trying to make it seem like flaming, and I dont think GhostAnime thought so. I was just stating that I felt a snap, and that I didnt just copy and paste the code like many new people do, which is quite flusterating. If you look GhostAnime appologized and said he/she was sleepy. So I dont know where your coming from. Besides isnt this a little off topic?
In response to FriesOfDoom
Thank you all for the information! I've pretty much finished it, thanks to your help. If you have any suggestions for changes to the last code I posted above please tell me. Also I just made a proc to make the monster return to your inventory, so the fix is unneeded to make the code above work on the "else if" part.