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

that would be an awesome add on. please do release that. i wish i was good at programming.. i have awesome ideas but no skills to set them up. 

(sorry for going off topic)

15 years, 9 weeks ago
Post #34438 Re: RELEASE: Pet system [tutorial]

I made my own topic about a problem I was having but after playing with it for a bit more i've found a couple of more things i'm not sure if it's because of how I put it or I miss things or if that's just how limited this script actually is but


    * Pets mess up on relog
    * Pets mess up when warping
    * Pets are affected by NPC walls


The NPC walls problem isn't that big of a deal and the warping isn't also. It's not that hard to just double click the egg again to re-spawn it. The only one that really seems to be a problem is the relog problem.

15 years, 7 weeks ago
Post #34441 Re: RELEASE: Pet system [tutorial]
batmaso posted: (16th Mar 2010 07:16 pm)

I made my own topic about a problem I was having but after playing with it for a bit more i've found a couple of more things i'm not sure if it's because of how I put it or I miss things or if that's just how limited this script actually is but


    * Pets mess up on relog
    * Pets mess up when warping
    * Pets are affected by NPC walls


The NPC walls problem isn't that big of a deal and the warping isn't also. It's not that hard to just double click the egg again to re-spawn it. The only one that really seems to be a problem is the relog problem.




* Pets mess up on relog

Go to character.cpp and add the followed code on the Character::Logout()

Paste above the (this->online = false;)

UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character)
    {
        if (this->InRange(*character))
        {
            this->pet->RemoveFromView(*character);
        }
    }
    erase_first(this->map->npcs, this->pet);
    this->pet->Release();
    this->has_pet = false;



* Pets mess up when warping

If you would go through the code a bit you would notice the (PetTransfer) at character.cpp that warps a pet on walking through a warp.

As you can see it transfers before entering and after entering;

this->player->character->PetTransfer();
                                this->player->character->Warp(Map, X, Y, WARP_ANIMATION_NONE);
                                this->player->character->PetTransfer();

Use those warps also in lets say scrolls;

At item.cpp Case scrolls

this->player->character->PetTransfer();
       this->player->character->Warp(item->scrollmap, item->scrollx, item->scrolly, WARP_ANIMATION_SCROLL);
       this->player->character->PetTransfer();

Warps a player pet with him on a use of a scroll.



* Pets are affected by NPC walls

At map.hpp check out this part;

bool Walkable(bool npc = false)
 {
  if (this->warp && npc)
  {
   return false;
  }

  switch (this->tilespec)
  {
   case Wall:
   case ChairDown:
   case ChairLeft:
   case ChairRight:
   case ChairUp:
   case ChairDownRight:
   case ChairUpLeft:
   case ChairAll:
   case Chest:
   case BankVault:
   case MapEdge:
   case Board1:
   case Board2:
   case Board3:
   case Board4:
   case Board5:
   case Board6:
   case Board7:
   case Board8:
   case Jukebox:
    return false;
   case NPCBoundary: // Hmmm...
    return !npc; // Hmmm....
   default:
    return true;
  }
 }

---
"Pineapples and shit."
15 years, 7 weeks ago
Post #34447 Re: RELEASE: Pet system [tutorial]

Awesome everything is all fixed up. Thank you very much Ananas (:

I really don't wanna bug you but my pet seems to just stand there if the character is idle and I see where it says:


  1. // Random walking
  2.  
  3.         int act;
  4.         if (this->walk_idle_for == 0)
            etc etc etc

but I don't think it's really doing anything.
15 years, 7 weeks ago
Post #35887 Re: RELEASE: Pet system [tutorial]

Yes after compiling and i click rebuild and i get this


||=== eoserv, SQLITE ===|


ld.exe||cannot find -lpthreadGC2|
||=== Build finished: 1 errors, 7 warnings ===|

EDIT2: are pets suppose to attack people? becouse mine doesent or are they there for looks?

EDIT: nevermind im dumb, i was missing some linker settings in the compiler and debugger works perfect, very nice

15 years, 3 weeks ago
Post #36826 Re: RELEASE: Pet system [tutorial]

How do you get the pets to attack monsters

15 years, 5 days ago
Post #38179 Re: RELEASE: Pet system [tutorial]

Hello everyone, I was wondering if someone could tell me what this means.


C:\Documents and Settings\EOserv\Desktop\trunk\src\npc.hpp|169|error: no matching function for call to 'NPC::NPC(Map*&, short int&, unsigned char&, unsigned char&, unsigned char&, short int&, unsigned char&, bool&)'|
C:\Documents and Settings\EOserv\Desktop\trunk\src\npc.hpp|116|note: candidates are: NPC::NPC()|
C:\Documents and Settings\EOserv\Desktop\trunk\src\npc.hpp|116|note:                 NPC::NPC(const NPC&)|
C:\Documents and Settings\EOserv\Desktop\trunk\src\player.hpp||In member function 'void Character::PetTransfer()':|
C:\Documents and Settings\EOserv\Desktop\trunk\src\player.hpp|1192|error: no matching function for call to 'NPC::NPC(Map*&, short int&, unsigned char&, unsigned char&, int, int, unsigned char&, bool, bool)'||
||=== Build finished: 2 errors, 0 warnings ===|

14 years, 48 weeks ago
Post #38244 Re: RELEASE: Pet system [tutorial]

I downloaded the compiled version, just doesn't work the commands... #attack,#follow


and I dont know how to spawn a pet

14 years, 48 weeks ago
Post #38246 Re: RELEASE: Pet system [tutorial]

With that compiled source there's a typo on the first line of the player command code,it will say this;

if (this->player->character->admin && message[0] == '#')

Just change the word "admin" to "player" and it should work fine.Also as Digitx said in the previous pages, the commands are;

$sp (name) (npcid) - Spawning pet

$dp (name) - Dismissing a Pet

14 years, 48 weeks ago
Post #38247 Re: RELEASE: Pet system [tutorial]
Festa posted: (2nd Jun 2010 09:59 am)

With that compiled source there's a typo on the first line of the player command code,it will say this;

if (this->player->character->admin && message[0] == '#')

Just change the word "admin" to "player" and it should work fine.Also as Digitx said in the previous pages, the commands are;

$sp (name) (npcid) - Spawning pet

$dp (name) - Dismissing a Pet


Nope, remove "this->player->character->admin &&"
14 years, 48 weeks ago
Post #38250 Re: RELEASE: Pet system [tutorial]

ye, ty festa, it worked, but now the problem are : How to make a pet attack npcs / player and this command above, which was posted before on this topic :


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;
                    }
                }

I got these errors :


C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp||In member function 'bool EOClient::Handle_Item(PacketFamily, PacketAction, PacketReader&, int)':|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|32|error: 'ItemID' was not declared in this scope|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|42|error: 'class Character' has no member named 'PetCounter'|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|46|error: 'NpcID' was not declared in this scope|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|46|error: invalid use of incomplete type 'struct NPC'|
..\src\fwd\npc.hpp|10|error: forward declaration of 'struct NPC'|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|47|error: invalid use of incomplete type 'struct NPC'|
..\src\fwd\npc.hpp|10|error: forward declaration of 'struct NPC'|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|49|error: invalid use of incomplete type 'struct NPC'|
..\src\fwd\npc.hpp|10|error: forward declaration of 'struct NPC'|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|50|error: 'class Character' has no member named 'PetCounter'|
..\src\container\ptr_vector.hpp||In member function 'void PtrVector<T>::push_back(T*) [with T = NPC]':|
C:\Documents and Settings\felipe engine\Desktop\Malz\src\handlers\Item.cpp|48|instantiated from here|
..\src\container\ptr_vector.hpp|360|error: no matching function for call to 'PtrVector<NPC>::push_back(NPC*&)'|
..\src\container\ptr_vector.hpp|237|note: candidates are: virtual void GenericPtrVector::push_back(Shared*)|
||=== Build finished: 11 errors, 0 warnings ====||


14 years, 48 weeks ago
Post #40218 Re: RELEASE: Pet system [tutorial]

wait a minute does this tut only spawn pets, does it help pets attack, or heal u or just spawning and despawing cuz i have a compiled server tht does this 

14 years, 46 weeks ago
Post #40220 Re: RELEASE: Pet system [tutorial]
lance317 posted: (18th Jun 2010 12:51 am)

wait a minute does this tut only spawn pets, does it help pets attack, or heal u or just spawning and despawing cuz i have a compiled server tht does this 


This tutorial only has Two Admin commands and two player commands. It does not have healing/attacking monsters
14 years, 46 weeks ago
Post #40720 Re: RELEASE: Pet system [tutorial]


I'm confused... i'm in npc but where do I paste that first thing?

14 years, 45 weeks ago
Post #41041 Re: RELEASE: Pet system [tutorial]
  • Klutz posted: (27th Feb 2010 11:13 pm)
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 

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;
}
}
     wat sud i put in New NPC?

14 years, 45 weeks ago
Page: << 1 2 ... 4 5 6 7 8 >>
Topic is locked.
EOSERV Forum > EOSERV > Pet system [tutorial] (outdated)