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

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 = 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->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.




---
I forgot what I was going to write...
15 years, 10 weeks ago
Post #33214 Re: RELEASE: Pet system [tutorial]

Idk i must really suck at compiling but can any 1 be nice enough to upload it compiled not just for me but for some ppl that have hard problems with it

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33218 Re: RELEASE: Pet system [tutorial]

I compiled it just fine..

Here's source with it link

Open with WinRAR

15 years, 10 weeks ago
Post #33222 Re: RELEASE: Pet system [tutorial]
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 = 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->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.





Thanks, but I got an error trying to do exactly as you said:
error: invalid use of incomplete type 'struct NPC'
---
Web developer, currently looking for graphic artists / designers.
15 years, 10 weeks ago
Post #33225 Re: RELEASE: Pet system [tutorial]

Same i get klutz error to any ideas on how to fix it

---
Fate-Gaming/Forgotten Memories Owner.
15 years, 10 weeks ago
Post #33242 Re: RELEASE: Pet system [tutorial]

Thx ill check if it works for me 

---
I noticed when I walked in the room went dark somebody better call the police there's a guy here
with no heart he said he goes by the name of TechNo he's on a war path and he said if anybody
touches the crown he's gonna tear them apart and a grime MC was telling me I kill them and i put
them in a cemetery!
15 years, 10 weeks ago
Post #33278 Re: RELEASE: Pet system [tutorial]


Hey, I did everything in your tutorial.

I got about 50 errors but im sure its just me.

15 years, 10 weeks ago
Post #33279 Re: RELEASE: Pet system [tutorial]
AwesomeEO posted: (25th Feb 2010 05:30 am)


Hey, I did everything in your tutorial, but i get the

target up to date nothing to be done error.

Can anyone maybe upload a compiled version?



Well if you read only a few posts above, then you would see that there is a compiled version for you. Geez some people just don't look.
15 years, 10 weeks ago
Post #33291 Re: RELEASE: Pet system [tutorial]

hey guys i use the compiled version of digitx now but how do i make and spawn pets???

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

The commands Are

#attack - set pet to attack closest player in range.

#follow - if pet is attacking someone, it will make it following you.

And for admin

$sp

$dp

15 years, 10 weeks ago
Post #33314 Re: RELEASE: Pet system [tutorial]

I can compile this no problem with the standard r187 but when i add all the code to Thehispanic's compiled revsion i get this error

C:\Users\\Desktop\Pets\trunk\src\player.hpp:1166: error: 'class NPC' has no member named 'SetOwner'

Does anyone know how i can fix this and please give as much info as you can because im only a beginner at c++.
15 years, 10 weeks ago
Post #33315 Re: RELEASE: Pet system [tutorial]
Soulstealer posted: (25th Feb 2010 06:43 pm)

I can compile this no problem with the standard r187 but when i add all the code to Thehispanic's compiled revsion i get this error

C:\Users\\Desktop\Pets\trunk\src\player.hpp:1166: error: 'class NPC' has no member named 'SetOwner'

Does anyone know how i can fix this and please give as much info as you can because im only a beginner at c++.

Have you remembered to add

This function will let you set new owner for pet:



void NPC::SetOwner(Character *character)
{
this->owner = character;
}


15 years, 10 weeks ago
Post #33323 Re: RELEASE: Pet system [tutorial]

Yes i have added all the code the exact same way as the normal r187 but i keep getting that same error

15 years, 10 weeks ago
Post #33328 Re: RELEASE: Pet system [tutorial]
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 = 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->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 

Edit: Figured out how to get the item to stay after use(choppy but works)

#include npc.hpp


if(id == ItemID)
                {


                     this->player->character->Save(); //this may be unnessasary
                     this->player->character->AddItem(id, 1);//adds back the item after it's use
                     this->player->character->Save();


                    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->AddItem(682, 1);
                        this->player->character->map->npcs.push_back(this->player->character->pet);


                        this->player->character->Save();

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


---
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 #33332 Re: RELEASE: Pet system [tutorial]
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 = 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->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. :)
---
Web developer, currently looking for graphic artists / designers.
15 years, 10 weeks ago
Page: << 1 2 3 4 5 ... 7 8 >>
Topic is locked.
EOSERV Forum > EOSERV > Pet system [tutorial] (outdated)