Author | Message | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ![]() 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 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; in void NPC::Act() find Character *attacker = 0; and add this below now find if (this->Data()->type == ENF::Aggressive && !attacker) and add this here find void NPC::Attack(Character *target) and add these above it void NPC::Pet(NPC *npc) now npc.hpp add these in class NPC : public Shared NPC *npc;
in eodata.hpp find class ENF : public Shared 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->pet_transfer = false; find void Character::Unhide() and add this here void Character::PetTransfer() in character.hpp under class Character : public Shared add 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))) 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"])) 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"])) 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) and in your pub set the NPC to 3
|
| ![]() Would this be the full pets code, or only half of it? Just to clear things up.
|
| ![]() It full! does it look like im missing somthing? unless i missed something it does everything i could want my pet to do
|
| ![]() Yeah. It looked like it was full. Just clearing up that answer incase someone else wants to know.
|
| ![]() 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|
|
| ![]() im 100% sure thats Quest.cpp?
|
| ![]() 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 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
|
| ![]() thanks its working now :)
|
| ![]() Is there any known bugs in this?
|
| ![]() 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.
|
| ![]() Ah, i/c. -- Compiling it right now. Although im probably gunna get errors, i dont have the void AttackSpell (forget what it was).
|
| ![]() i get 2 errors any ideas what i can do?
|
| ![]() 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
|
| ![]() 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.
|
| ![]() 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 |