| 
ReemDead  
Joined: 30th May 2009Posts: 117
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
epicnoob posted: (27th Feb 2010 12:50 am)
 
 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 
I posted a reply to Jimbo's code with a version I modified, that works. I updated it so that eggs or whatever other item you have to summon pets don't dissapear when used. 
 
 
 ---
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 |  
		| 
epicnoob  
Joined: 19th Feb 2010Posts: 166
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoYea i still dont know how to do that make the item not dissapear 1s u used it already ---
Fate-Gaming/Forgotten Memories Owner. |  
		| 
ReemDead  
Joined: 30th May 2009Posts: 117
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
epicnoob posted: (27th Feb 2010 12:54 am)
 
 Yea i still dont know how to do that make the item not dissapear 1s u used it already 
put this code below this "if(id == ItemID)
 {" 
 
 and above "if(this->player->character->has_pet)" 
 
 
 code: 
 
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(); 
 Edit: you don't have to modify anything in the AddItem code, just leave it the way it is, it already knows what item ID to change because it's an if statement for a particular item 
---
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 |  
		| 
epicnoob  
Joined: 19th Feb 2010Posts: 166
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoAlright thx man im still trying to add ur cmd ill let u know when i got it ---
Fate-Gaming/Forgotten Memories Owner. |  
		| 
ReemDead  
Joined: 30th May 2009Posts: 117
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
epicnoob posted: (27th Feb 2010 01:00 am)
 
 Alright thx man im still trying to add ur cmd ill let u know when i got it 
well like i said, if you show me what errors you're getting i may be able to help more ---
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 |  
		| 
epicnoob  
Joined: 19th Feb 2010Posts: 166
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoHere are the errors C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp||In member function 'bool EOClient::Handle_Talk(PacketFamily, PacketAction, PacketReader&, int)':| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'usercmd' was not declared in this scope| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'userar' was not declared in this scope| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|139|warning: suggest parentheses around assignment used as truth value| ||=== Build finished: 2 errors, 1 warnings ===| Edit: I Narrowed it down to only 1 error 
 
C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp||In member function 'bool EOClient::Handle_Talk(PacketFamily, PacketAction, PacketReader&, int)':| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'command' was not declared in this scope| ||=== Build finished: 1 errors, 0 warnings ===| 
 ---
Fate-Gaming/Forgotten Memories Owner. |  
		| 
ReemDead  
Joined: 30th May 2009Posts: 117
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
epicnoob posted: (27th Feb 2010 01:15 am)
 
 Here are the errors C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp||In member function 'bool EOClient::Handle_Talk(PacketFamily, PacketAction, PacketReader&, int)':| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'usercmd' was not declared in this scope| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'userar' was not declared in this scope| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|139|warning: suggest parentheses around assignment used as truth value| ||=== Build finished: 2 errors, 1 warnings ===| Edit: I Narrowed it down to only 1 error 
 
C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp||In member function 'bool EOClient::Handle_Talk(PacketFamily, PacketAction, PacketReader&, int)':| C:\Documents and Settings\Mando\Escritorio\trunk\trunk\src\handlers\Talk.cpp|135|error: 'command' was not declared in this scope| ||=== Build finished: 1 errors, 0 warnings ===| 
 
ok if at some point you changed usercmd to command that could be the issue. Other than that I don't really know what the problem could be, because I never got any errors when i wrote the command
 ---
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 |  
		| 
epicnoob  
Joined: 19th Feb 2010Posts: 166
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoYea cuz if i use urscmd it gives me the errors ---
Fate-Gaming/Forgotten Memories Owner. |  
		| 
Ananas
 Moderator 
Joined: 22nd Apr 2009Posts: 2190
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoHere is my command of a pet being dismissed using (Command) etc.
 
 Just write #dismiss and it will leave.
 The server message is only showable to the player using the command.
 You could just erase the line.
 
 else if (command.length() >= 7 && command.compare(0,7,"dismiss") == 0 && this->player->character->has_pet)
 {
 UTIL_PTR_LIST_FOREACH(this->player->character->map->characters, Character, character)
 {
 if (this->player->character->InRange(*character))
 {
 this->player->character->pet->RemoveFromView(*character);
 }
 }
 erase_first(this->player->character->map->npcs, this->player->character->pet);
 this->player->character->pet->Release();
 this->player->character->has_pet = false;
 this->player->character->ServerMsg("NPC left!");
 }
 ---
"Pineapples and shit." |  
		| 
epicnoob  
Joined: 19th Feb 2010Posts: 166
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoI tried the code ananas but it only worked for admin and i put it under the # cmds cuz players tried it and it didnt work ---
Fate-Gaming/Forgotten Memories Owner. |  
		| 
Klutz  
Joined: 14th Jul 2009Posts: 1737
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
ReemDead posted: (26th Feb 2010 03:14 am)
 
 
Jimbo posted: (24th Feb 2010 02:29 am)This does not work, at all. Even after I put
 
 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.
 
 
 
 
 #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. 
 
 I edited your code to dismiss the pet if the item is used again, the pet can be summoned and dismissed as many times as needed by clicking the reward item. Now there's no need to type either command to summon or dismiss. 
 
 in "npc.cpp" ; 
 #include "npc.hpp" 
 under: 
 if (this->player->character->HasItem(id))
 {
 EIF_Data *item = this->server->world->eif->Get(id);
 reply.SetID(PACKET_ITEM, PACKET_REPLY);
 reply.AddChar(item->type);
 reply.AddShort(id);
 
 Add:
 
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(); } 
 
else if(this->player->character->has_pet = true) 
{ 
UTIL_PTR_LIST_FOREACH(this->player->character->map->characters, Character, character) 
{ 
if (this->player->character->InRange(*character)) 
{ 
this->player->character->pet->RemoveFromView(*character); 
} 
} 
erase_first(this->player->character->map->npcs, this->player->character->pet); 
this->player->character->pet->Release(); 
this->player->character->has_pet = false; 
} 
}
 ---
Web developer, currently looking for graphic artists / designers. |  
		| 
ReemDead  
Joined: 30th May 2009Posts: 117
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks ago
Klutz posted: (27th Feb 2010 11:13 pm)
 
 
ReemDead posted: (26th Feb 2010 03:14 am)
 
 
Jimbo posted: (24th Feb 2010 02:29 am)This does not work, at all. Even after I put
 
 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.
 
 
 
 
 #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. 
 
 I edited your code to dismiss the pet if the item is used again, the pet can be summoned and dismissed as many times as needed by clicking the reward item. Now there's no need to type either command to summon or dismiss. 
 
 in "npc.cpp" ; 
 #include "npc.hpp" 
 under: 
 if (this->player->character->HasItem(id))
 {
 EIF_Data *item = this->server->world->eif->Get(id);
 reply.SetID(PACKET_ITEM, PACKET_REPLY);
 reply.AddChar(item->type);
 reply.AddShort(id);
 
 Add: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();
 
 
 } else if(this->player->character->has_pet = true)
 {
 UTIL_PTR_LIST_FOREACH(this->player->character->map->characters, Character, character)
 {
 if (this->player->character->InRange(*character))
 {
 this->player->character->pet->RemoveFromView(*character);
 }
 }
 erase_first(this->player->character->map->npcs, this->player->character->pet);
 this->player->character->pet->Release();
 this->player->character->has_pet = false;
 }
 }
 
 
I was actually trying to do this lol. Thanks Klutz, I'll test this immediately 
 
 Edit: Epic Win dude, works perfectly ---
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 |  
		| 
Addison  
Joined: 24th Mar 2009Posts: 1380
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoNice job man. Your code is similar to the pets I coded in FE. Great minds think alike. ---
http://www.addipop.com |  
		| 
 
 |  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agosweet coding. how do you make it attack npc now? also.. anyone want to upload a project file with the items added in too? i'm nub to the extreme with this coding. |   
		| 
Ananas
 Moderator 
Joined: 22nd Apr 2009Posts: 2190
 
  Re: RELEASE: Pet system [tutorial] 
15 years, 37 weeks agoIt only attacks if a player attacks the pet.
 
 By typing #attack a bool turns from false to true.
 The #follow button changes it back to false but most of the time the pets don't listen to it. It just turn the players damage to the pet to false but the pet keeps on attacking. I'm almost finished with an #attack <player> script. Might of releasing it here.
 ---
"Pineapples and shit." |  |  |  |  |  |  |  |  |  |  |  |  |  |  |