Advertisement
Guest User

Untitled

a guest
Aug 7th, 2010
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. #include "Object.h"
  2.  
  3. class npc_pet_vendor : public CreatureScript
  4. {
  5.  public:
  6.     npc_pet_vendor() : CreatureScript("npc_pet_vendor") { }
  7.  
  8.     void TameCreature(Player *pPlayer, Creature *pVendor, uint32 npcid)
  9.     {
  10.             if (pPlayer->GetPetGUID())
  11.             return;
  12.  
  13.             if (pPlayer->GetCharmGUID())
  14.             return;
  15.  
  16.             TempSummon* npc = pVendor->SummonCreature(npcid, pVendor->GetPositionX(), pVendor->GetPositionY(), pVendor->GetPositionZ(), 0,TEMPSUMMON_CORPSE_DESPAWN, 40000);
  17.         npc->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, pVendor->GetGUID());
  18.  
  19.         if (pPlayer->getClass() != CLASS_HUNTER)
  20.             return;
  21.    
  22.         Pet* pet = pPlayer->CreateTamedPetFrom(npc, 13481);
  23.         if (!pet)                                               // in very specific state like near world end/etc.
  24.             return;
  25.  
  26.             npc->ForcedDespawn();
  27.             uint8 level = (npc->getLevel() < (pPlayer->getLevel() - 5)) ? (pPlayer->getLevel() - 5) : npc->getLevel();
  28.             pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
  29.             pet->GetMap()->Add(pet->ToCreature());
  30.         pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
  31.             pPlayer->SetMinion(pet, true);
  32.             pet->InitTalentForLevel();
  33.             if (pPlayer->GetTypeId() == TYPEID_PLAYER)
  34.             {  
  35.                 pet->SavePetToDB(PET_SAVE_AS_CURRENT);
  36.                 pPlayer->ToPlayer()->PetSpellInitialize();
  37.             }
  38.     }
  39.  
  40.     bool OnGossipHello_npc_pet_vendor(Player *pPlayer, Creature *pCreature)
  41.     {
  42.             pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT,"Boar", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  43.             pPlayer->SEND_GOSSIP_MENU(9978, pCreature->GetGUID());
  44.             return true;
  45.     }
  46.  
  47.     bool OnGossipSelect_npc_pet_vendor(Player *pPlayer, Creature *pCreature, uint32 /*uiSender*/, uint32 uiAction)
  48.     {
  49.             switch(uiAction)
  50.             {
  51.                 case GOSSIP_ACTION_INFO_DEF + 1:
  52.                         TameCreature(pPlayer,pCreature,3098);
  53.                     break;
  54.             }
  55.             return true;
  56.     }
  57.  
  58. void AddSC_npc_pet_vendor()
  59. {
  60.     new npc_pet_vendor;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement