EOSERV Forum > EOSERV > Pet system [tutorial] (outdated)
Topic is locked.
Page: << 1 2 3 4 5 6 7 8 >>
Pet system [tutorial] (outdated)
Author Message
Post #33350 Re: RELEASE: Pet system [tutorial]

I downloaded digit's source, but the $sp does nothing

---
Create your own destiny, don't let someone else do it for you.
15 years, 10 weeks ago
Post #33359 Re: RELEASE: Pet system [tutorial]

yeah i have the same problem can someone make a working source with the thing that players can spawn pets to

---
Live and let live. Hurt but do not kill. Finish what you start. NEVER GIVE UP!!!
15 years, 10 weeks ago
Post #33360 Re: RELEASE: Pet system [tutorial]

you must of done something wrong i downloaded it too worked fine.

15 years, 10 weeks ago
Post #33362 Re: RELEASE: Pet system [tutorial]
Klutz posted: (26th Feb 2010 08:46 am)

ReemDead posted: (26th Feb 2010 03:14 am)

Jimbo posted: (24th Feb 2010 02:29 am)

If anyone wants to let characters spawn a pet by using an item place this in item.cpp


Under this..

               

                EIF_Data *item = this->server->world->eif->Get(id);
                reply.SetID(PACKET_ITEM, PACKET_REPLY);
                reply.AddChar(item->type);
                reply.AddShort(id);


Code:


if(id == ItemID)
                {
                    if(!this->player->character->has_pet)
                    {
                        this->player->character->has_pet = true;
                        unsigned char index = this->player->character->map->GenerateNPCIndex();
                        if (index > 250)
                        {
                            break;
                        }
                        if (this->player->character->PetCounter > 1)
                        {
                            break;
                        }
                        this->player->character->pet =newNPC(this->player->character->map,NpcID,this->player->character->x+1,this->player->character->y, 1, 1, index, true, true);
                        this->player->character->pet->SetOwner(this->player->character);
                        this->player->character->map->npcs.push_back(this->player->character->pet);
                        this->player->character->pet->Spawn();
                        this->player->character->PetCounter = 1;
                    }
                }


Just replace NpcID / ItemID with the item / npc you wish to use.


Edit: Remove PetCounter if you don't want it.




This does not work, at all. Even after I put

#include npc.hpp

I tried modding this code in several different ways, but it just doesn't want to work. It compiles fine however, I can't seem to get my eggs to do anything.



Edit: tinkered with it, fixed it. put it where Jimbo said to put it. also make sure you 

#include npc.hpp


if(id == ItemID)
                {

                    if(!this->player->character->has_pet)
                    {
  
                        unsigned char index = this->player->character->map->GenerateNPCIndex();
                        if (index > 250)

                        {

                        break;

                        }

                        this->player->character->pet = new NPC(this->player->character->map, NpcID, this->player->character->x + 1,this->player->character->y, 1, 1, index, true, true);
                        this->player->character->pet->Spawn();
                        this->player->character->pet->SetOwner(this->player->character);
                        this->player->character->has_pet = true;
                        this->player->character->map->npcs.push_back(this->player->character->pet);


                    }
                }

I set the item type as reward in the pub, with exp bonus of 0.

If some one could tell me how to keep the item from removing itself, please share. thanks

Try an item that isn't usable, like a bat wing or something. :)

then it doesn't work. i mentioned earlier it doesn't work with static items.

Edit: Also the code i modified WORKS, if you guys would just try it instead of complaining that Jimbo's doesn't work, this topic could move on to improving this tutorial. Also here, i made a despawn command so users can despawn their own pets.. feel free to make this better..

Put this in Talk.cpp with your other # commands

if (usercmd.length() >= 3 && usercmd.compare(0,3,"pet") == 0 && userar.size() >= 0)
                {
if (this->player->character->has_pet = true);

{
this->player->character->pet->RemoveFromView(this->player->character);


erase_first(this->player->character->map->npcs, this->player->character->pet);
this->player->character->pet->Release();
this->player->character->has_pet = false;
}
                }
---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33364 Re: RELEASE: Pet system [tutorial]

I used jimbos code and edit the thing reem said and it worked fine for me i was able to spawn a monster with an item now i tried the despawn cmd but i didnt work had many errors

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33365 Re: RELEASE: Pet system [tutorial]
epicnoob posted: (27th Feb 2010 12:21 am)

I used jimbos code and edit the thing reem said and it worked fine for me i was able to spawn a monster with an item now i tried the despawn cmd but i didnt work had many errors


My user despawn command? Where did you place it?
---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33366 Re: RELEASE: Pet system [tutorial]

Under the # comands but it gave me some erros like usercmd so i tried changing it but it still gave me errors

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33367 Re: RELEASE: Pet system [tutorial]
epicnoob posted: (27th Feb 2010 12:28 am)

Under the # comands but it gave me some erros like usercmd so i tried changing it but it still gave me errors


should look like this:

}
            else if (message[0] == '#')
            {
                std::string usercmd;
                std::vector<std::string> userar = util::explode(' ', message);
                usercmd = userar.front().substr(1);
                userar.erase(userar.begin());
                std::string command;
                std::vector<std::string> arguments = util::explode(' ', message);
                command = arguments.front().substr(1);
                arguments.erase(arguments.begin());


if (usercmd.length() >= 3 && usercmd.compare(0,3,"pet") == 0 && userar.size() >= 0)
                {


if (this->player->character->has_pet = true);




{
this->player->character->pet->RemoveFromView(this->player->character);


erase_first (this->player->character->map->npcs, this->player->character->pet);

this->player->character->pet->Release();
this->player->character->has_pet = false;

}

   }

---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33368 Re: RELEASE: Pet system [tutorial]

yea i added that but still got the same errors

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33369 Re: RELEASE: Pet system [tutorial]
epicnoob posted: (27th Feb 2010 12:33 am)

yea i added that but still got the same errors


Odd, this works fine for me. What revision of EOserv are you using?

Edit:

You may try changing the if statements to else if

dunno if it will work but it's worth a try
---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33370 Re: RELEASE: Pet system [tutorial]

Alright ill try that and im running on 187

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33371 Re: RELEASE: Pet system [tutorial]
epicnoob posted: (27th Feb 2010 12:38 am)

Alright ill try that and im running on 187


i use 184 but i coded in most of 187 to it myself and it runs on par with 187. I'd compile you my revision, but im not going thru and removing all my codes, so I can't. I have spells that I can't release because they aren't my original code, and there's too much to go through and remove lol.
---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33372 Re: RELEASE: Pet system [tutorial]

Its all good lol but yea ill try to make ur code work but im also busy on making pets atk npcs thats my goal

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33373 Re: RELEASE: Pet system [tutorial]
epicnoob posted: (27th Feb 2010 12:43 am)

Its all good lol but yea ill try to make ur code work but im also busy on making pets atk npcs thats my goal


 That's something I want to do as well, but I'm still a beginner at c++, which is obvious looking at my choppy coding lol. Hopefully some one will be kind enough to post it in this tutorial

Edit: What errors are you getting Epic? If i knew i might be of more assistance.
---
Do what thou wilt shall be the whole of the law. Love is the law, love under will. There is no law
beyond do what thou wilt. 93/93
15 years, 10 weeks ago
Post #33374 Re: RELEASE: Pet system [tutorial]

Yea that would be nice and did u get jimbos code working? cuz i tried it and worked fine then i made ananas spawn apozen now all i really need is ur despawn cmd to work

Edit:Ill post them in a sec

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Page: << 1 2 3 4 5 6 7 8 >>
Topic is locked.
EOSERV Forum > EOSERV > Pet system [tutorial] (outdated)