Jimbo
Joined: 17th Mar 2009
Posts: 416
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
|
epicnoob

Joined: 19th Feb 2010
Posts: 166
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
|
Digitx

Joined: 10th Jul 2009
Posts: 250
Re: RELEASE: Pet system [tutorial]
I compiled it just fine..
Here's source with it link
Open with WinRAR
15 years, 10 weeks ago
|
Klutz

Joined: 14th Jul 2009
Posts: 1737
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
|
epicnoob

Joined: 19th Feb 2010
Posts: 166
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
|
techNo

Joined: 23rd Jan 2010
Posts: 126
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
|
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
|
|
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
|
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
|
Digitx

Joined: 10th Jul 2009
Posts: 250
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
|
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
|
batmaso
Joined: 30th Jan 2010
Posts: 21
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
|
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
|
ReemDead

Joined: 30th May 2009
Posts: 117
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
|
Klutz

Joined: 14th Jul 2009
Posts: 1737
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
| | | | | | | | | | | | | | |