Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Object.h"
- class npc_pet_vendor : public CreatureScript
- {
- public:
- npc_pet_vendor() : CreatureScript("npc_pet_vendor") { }
- void TameCreature(Player *pPlayer, Creature *pVendor, uint32 npcid)
- {
- if (pPlayer->GetPetGUID())
- return;
- if (pPlayer->GetCharmGUID())
- return;
- TempSummon* npc = pVendor->SummonCreature(npcid, pVendor->GetPositionX(), pVendor->GetPositionY(), pVendor->GetPositionZ(), 0,TEMPSUMMON_CORPSE_DESPAWN, 40000);
- npc->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, pVendor->GetGUID());
- if (pPlayer->getClass() != CLASS_HUNTER)
- return;
- Pet* pet = pPlayer->CreateTamedPetFrom(npc, 13481);
- if (!pet) // in very specific state like near world end/etc.
- return;
- npc->ForcedDespawn();
- uint8 level = (npc->getLevel() < (pPlayer->getLevel() - 5)) ? (pPlayer->getLevel() - 5) : npc->getLevel();
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
- pet->GetMap()->Add(pet->ToCreature());
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
- pPlayer->SetMinion(pet, true);
- pet->InitTalentForLevel();
- if (pPlayer->GetTypeId() == TYPEID_PLAYER)
- {
- pet->SavePetToDB(PET_SAVE_AS_CURRENT);
- pPlayer->ToPlayer()->PetSpellInitialize();
- }
- }
- bool OnGossipHello_npc_pet_vendor(Player *pPlayer, Creature *pCreature)
- {
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT,"Boar", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- pPlayer->SEND_GOSSIP_MENU(9978, pCreature->GetGUID());
- return true;
- }
- bool OnGossipSelect_npc_pet_vendor(Player *pPlayer, Creature *pCreature, uint32 /*uiSender*/, uint32 uiAction)
- {
- switch(uiAction)
- {
- case GOSSIP_ACTION_INFO_DEF + 1:
- TameCreature(pPlayer,pCreature,3098);
- break;
- }
- return true;
- }
- void AddSC_npc_pet_vendor()
- {
- new npc_pet_vendor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement