EOSERV Forum > EOSERV > pet stuff/attack/spells/stats
Topic is locked.
Page: << 1 2 3 4 5 6 >>
pet stuff/attack/spells/stats
Author Message
Post #54995 pet stuff/attack/spells/stats

working attack on  monsters and characters pets will hunt and attack aggressive monsters,attack players in pk,attack passive monsters if distance is 1 and will fight each other in arena maps  will update later with more features

pre compiled petsrev189

In npc.cpp

near the top

mine looks like this

NPC::NPC(Map *map, short id, unsigned char x, unsigned char y, unsigned char spawn_type, short spawn_time, unsigned char index, bool temporary, bool pet, Character *owner)


find

 this->totaldamage = 0;

add these below it

this->owner = owner;
this->pet = pet;


in void NPC::Act()

find

  Character *attacker = 0;

and add this below


now find

if (this->Data()->type == ENF::Aggressive && !attacker)
    {

        Character *closest = 0;
        unsigned char closest_distance = static_cast<int>(this->map->world->config["NPCChaseDistance"]);

        UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character)
        {
            int distance = util::path_length(character->x, character->y, this->x, this->y);

            if (distance < closest_distance)
            {
                closest = *character;
                closest_distance = distance;
            }
        }

        if (closest)
        {
            attacker = closest;
    }
    }

and add this here


find

void NPC::Attack(Character *target)

and add these above it


void NPC::Pet(NPC *npc)
{
this->pet = npc;

}

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


now npc.hpp

add these in class NPC : public Shared
{
    public:
       

NPC *npc;


        bool pet;
      Character *owner;

        NPC(Map *map, short id, unsigned char x, unsigned char y, unsigned char spawn_type, short spawn_time, unsigned char index, bool temporary = false, bool pet = false, Character *owner = 0);

void SetOwner(Character *character);
void Pet(NPC *npc);


in eodata.hpp

find        

class ENF : public Shared
{
    public:
        enum Type
        {
            NPC,
            Passive,
            Aggressive,
add

Pet,


a little lower find

SCRIPT_REGISTER_ENUM_VALUE(Aggressive);
   

and add

     

SCRIPT_REGISTER_ENUM_VALUE(Pet);


in character.cpp

find

 this->login_time = std::time(0);

and add these above it

this->pet = 0;
 this->has_pet = false;

 this->pet_transfer = false;


find

void Character::Unhide()
{
    this->hidden = false;

    PacketBuilder builder(PACKET_ADMININTERACT, PACKET_AGREE);
    builder.AddShort(this->player->id);

    UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character)
    {
        character->player->client->SendBuilder(builder);
    }
}


and add this  here


void Character::PetTransfer()
{
if(this->has_pet && !this->pet_transfer)
{
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;

this->pet_transfer = true;
}
}
}

else if(this->pet_transfer)
{
if(pet_transfer)
{
unsigned char index = this->map->GenerateNPCIndex();
if (index > 250)
{
return;
}
this->pet = new NPC(this->map, this->pet->id, this->x, this->y, 1, 1, index, true, true);
this->pet->SetOwner(this);
this->map->npcs.push_back(this->pet);
this->pet->Spawn();
this->has_pet = true;
this->pet_transfer = false;
}
}
}


in character.hpp

under

class Character : public Shared
{
    public:

add
    
          bool has_pet;
        bool pet_transfer;

  NPC *pet;

 find

void Unhide();


and add this under


void PetTransfer();


in map.cpp


find bool Map::Walk(NPC *from, Direction direction)

and replace what looks like these with this 1


if (from->pet && from->Data()->type == ENF::Pet && (!this->Walkable(target_x, target_y, Map_Tile::Wall)))
{
return false;
}

    if (!from->pet && !from->Data()->type != ENF::Pet && (!this->Walkable(target_x, target_y, true)) || this->Occupied(target_x, target_y, Map::PlayerAndNPC))
    {
        return false;
    }


find  this

void Map::Attack(Character *from, Direction direction)


find what looks like this and replace with this 1


if ((npc->pet || npc->Data()->type == ENF::Pet || npc->Data()->type == ENF::Passive || npc->Data()->type == ENF::Aggressive || from->admin > static_cast<int>(this->world->admin_config["killnpcs"]))
                 && npc->alive && npc->x == target_x && npc->y == target_y)


now find

void Map::AttackSpell(Character *from, int spellid, int targetid)


find what looks like this and replace with this 1


 if ((npc->pet || npc->Data()->type == ENF::Pet || npc->Data()->type == ENF::Passive || npc->Data()->type == ENF::Aggressive || from->admin > static_cast<int>(this->world->admin_config["killnpcs"]))
                && npc->alive)
               

i think thats it if not ill check back later and see if any one needs help

I will also post some pet commands later and some other cool stuff for pets


update!


my item.cpp includes spawned pets with add stats  and pet spells if you choose to use this stuff in here!!  Go In character.cpp  and replace your void Character::Logout()  with this1


for a pet inventory change your locker.cpp to this

and add this to talk.cpp in player commands


here is a follow command


else if (command.length() >= 1 && command.compare(0,1,"f") == 0 && this->player->character->has_pet)
{
this->player->character->PetTransfer();
this->player->character->PetTransfer();
}


and in your pub set the NPC to 3





13 years, 22 weeks ago
Post #54998 Re: heres my pet stuff/attack/spells/stats

Would this be the full pets code, or only half of it? Just to clear things up.

13 years, 22 weeks ago
Post #54999 Re: heres my pet stuff/attack/spells/stats

It full! does it look like im missing somthing? unless i missed something it does everything i could want my pet to do

13 years, 22 weeks ago
Post #55000 Re: heres my pet stuff/attack/spells/stats

Yeah.  It looked like it was full.  Just clearing up that answer incase someone else wants to know.

13 years, 22 weeks ago
Post #55001 Re: heres my pet stuff/attack/spells/stats

i got 2 errors in map.cpp


C:\Documents and Settings\Aboy\Desktop\Eoserv\src\quest.hpp|1464|error: 'target_x' was not declared in this scope|

C:\Documents and Settings\Aboy\Desktop\Eoserv\src\quest.hpp|1464|error: 'target_y' was not declared in this scope|

13 years, 22 weeks ago
Post #55002 Re: heres my pet stuff/attack/spells/stats

im 100% sure thats Quest.cpp?

13 years, 22 weeks ago
Post #55003 Re: heres my pet stuff/attack/spells/stats

ok this is my complete bool Map::Walk(NPC *from, Direction direction)

and my void Map::Attack(Character *from, Direction direction)

and void Map::AttackSpell(Character *from, int spellid, int targetid)

 int target_x = from->x; is near the top of each of these
 int target_y = from->y; is near the top of each of these


ok im srry look at the void Map::AttackSpell(Character *from, int spellid, int targetid) i think thats what i posted wrong!

if u get the errors again post your map.cpp so i can look
 

13 years, 22 weeks ago
Post #55010 Re: heres my pet stuff/attack/spells/stats

thanks its working now :)

13 years, 22 weeks ago
Post #55016 Re: heres my pet stuff/attack/spells/stats

Is there any known bugs in this?

13 years, 22 weeks ago
Post #55018 Re: heres my pet stuff/attack/spells/stats

if u spawn a pet that doesnt have an owner... It will cause the server to crash. Ex: don't #snpc pet ID amount. Rarely,  If  there are multiple aggressive NPC's within attack distance, the pet will get confused on the target its attacking.

13 years, 22 weeks ago
Post #55019 Re: heres my pet stuff/attack/spells/stats

Ah, i/c. --  Compiling it right now.  Although im probably gunna get errors, i dont have the void AttackSpell (forget what it was).

13 years, 22 weeks ago
Post #55031 Re: heres my pet stuff/attack/spells/stats

i get 2 errors any ideas what i can do?

C:\Documents and Settings\Desktop\trunk\src\map.cpp||In member function 'bool Map::Walk(Character*, Direction, bool)':|
C:\Documents and Settings\Desktop\trunk\src\map.cpp|769|error: 'class Character' has no member named 'Data'|
C:\Documents and Settings\Desktop\trunk\src\map.cpp|774|error: 'class Character' has no member named 'Data'|
C:\Documents and Settings\Desktop\trunk\src\map.cpp|774|warning: suggest parentheses around '&&' within '||'|
C:\Documents and Settings\Desktop\trunk\src\map.cpp||In member function 'bool Map::AttackPKSpell(Character*, int, int)':|
C:\Documents and Settings\Desktop\trunk\src\map.cpp|1786|warning: comparison between signed and unsigned integer expressions|
||=== Build finished: 2 errors, 2 warnings ===|

13 years, 22 weeks ago
Post #55037 Re: heres my pet stuff/attack/spells/stats

you added the walk to character walk  add to npc walk instead


find bool Map::Walk(NPC *from, Direction direction) and add in there


if you dont have working attack spells then you dont need to worry about trying to add that part ,and also dont use the pet spells in item.cpp

13 years, 22 weeks ago
Post #55043 Re: heres my pet stuff/attack/spells/stats

I fixed all the errors i got, but they still don't attack NPCs, this code doesn't work.

---
Create your own destiny, don't let someone else do it for you.
13 years, 22 weeks ago
Post #55044 Re: heres my pet stuff/attack/spells/stats

WOW dont tell me what i post doesnt work i always test what i post many times i have worked hard on this for over 2 months and tested every feature many times over! What is the pet doing?  What is the NPCID in your pub set to ? if you want to see it in action look here or maybe i missed somthing


What ill do is compile this in a fresh rev 189

and post it!!  i added pre compiled rev 189 for you guys at the top

13 years, 22 weeks ago
Page: << 1 2 3 4 5 6 >>
Topic is locked.
EOSERV Forum > EOSERV > pet stuff/attack/spells/stats