这个脚本包含了很多种的宠物驯化,你需要把脚本编译到你的脚本库里面。
支持T端335版本
更新日期:2013-5-15
至于怎么在你的代码里面增加脚本。你需要搜索一下资料
#include "ScriptPCH.h"#include "Pet.h"
class Npc_Beastmaster : public CreatureScript
{
public:
Npc_Beastmaster() : CreatureScript("Npc_Beastmaster") { }
void CreatePet(Player *player, Creature * m_creature, uint32 entry) {
if(player->getClass() != CLASS_HUNTER) {
m_creature->MonsterWhisper("You are not a Hunter!", player->GetGUID());
player->PlayerTalkClass->SendCloseGossip();
return;
}
if(player->GetPet()) {
m_creature->MonsterWhisper("First drop your current Pet!", player->GetGUID());
player->PlayerTalkClass->SendCloseGossip();
return;
}
Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
if(!creatureTarget) return;
Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
if(!pet) return;
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
pet->SetPower(POWER_HAPPINESS, 1048000);
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
pet->GetMap()->AddToMap(pet->ToCreature());
pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
if(!pet->InitStatsForLevel(player->getLevel()))
sLog->outError(LOG_FILTER_PETS, "Fail: no init stats for entry %u", entry);
pet->UpdateAllStats();
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
pet->InitTalentForLevel();
player->PetSpellInitialize();
player->PlayerTalkClass->SendCloseGossip();
m_creature->MonsterWhisper("Pet successfully added!", player->GetGUID());
}
bool OnGossipHello(Player *player, Creature * m_creature)
{
if(player->getClass() != CLASS_HUNTER)
{
m_creature->MonsterWhisper("You are not a Hunter!", player->GetGUID());
return true;
}
player->ADD_GOSSIP_ITEM(7, "Get a New Pet.", GOSSIP_SENDER_MAIN, 1000);
if (player->CanTameExoticPets())
{
player->ADD_GOSSIP_ITEM(7, "Get a New Exotic Pet.", GOSSIP_SENDER_MAIN, 50);
}
player->ADD_GOSSIP_ITEM(2, "Take me to the Stable.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_STABLEPET);
player->ADD_GOSSIP_ITEM(1, "Sell me some Food for my Pet.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_VENDOR);
player->ADD_GOSSIP_ITEM(4, "Close Beastmaster Window.", GOSSIP_SENDER_MAIN, 150);
player->SEND_GOSSIP_MENU(1, m_creature->GetGUID());
return true;
}
bool OnGossipSelect(Player *player, Creature * m_creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
case 100:
player->ADD_GOSSIP_ITEM(7, "Get a New Pet.", GOSSIP_SENDER_MAIN, 1000);
if (player->CanTameExoticPets())
{
player->ADD_GOSSIP_ITEM(7, "Get a New Exotic Pet.", GOSSIP_SENDER_MAIN, 50);
}
player->ADD_GOSSIP_ITEM(2, "Take me to the Stable.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_STABLEPET);
player->ADD_GOSSIP_ITEM(1, "Sell me some Food for my Pet.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_VENDOR);
player->ADD_GOSSIP_ITEM(4, "Close Beastmaster Window.", GOSSIP_SENDER_MAIN, 150);
player->SEND_GOSSIP_MENU(1, m_creature->GetGUID());
break;
case 150:
player->CLOSE_GOSSIP_MENU();
break;
case 1000: // Submenu
player->ADD_GOSSIP_ITEM(4, "<- [Main Menu]", GOSSIP_SENDER_MAIN, 100);
player->ADD_GOSSIP_ITEM(5, "[Next Page] ->", GOSSIP_SENDER_MAIN, 10000);
player->ADD_GOSSIP_ITEM(4, "Tame a Bat!", GOSSIP_SENDER_MAIN, 1001);
player->ADD_GOSSIP_ITEM(4, "Tame a Bear!", GOSSIP_SENDER_MAIN, 1002);
player->ADD_GOSSIP_ITEM(4, "Tame a Bird of Prey!", GOSSIP_SENDER_MAIN, 1003);
player->ADD_GOSSIP_ITEM(4, "Tame a Boar!", GOSSIP_SENDER_MAIN, 1004);
player->ADD_GOSSIP_ITEM(4, "Tame a Carrion Bird!", GOSSIP_SENDER_MAIN, 1005);
player->ADD_GOSSIP_ITEM(4, "Tame a Cat!", GOSSIP_SENDER_MAIN, 1006);
player->ADD_GOSSIP_ITEM(4, "Tame a Crab!", GOSSIP_SENDER_MAIN, 1007);
player->ADD_GOSSIP_ITEM(4, "Tame a Crocolisk!", GOSSIP_SENDER_MAIN, 1008);
player->ADD_GOSSIP_ITEM(4, "Tame a Dragonhawk!", GOSSIP_SENDER_MAIN, 1009);
player->ADD_GOSSIP_ITEM(4, "Tame a Gorilla!", GOSSIP_SENDER_MAIN, 1010);
player->ADD_GOSSIP_ITEM(4, "Tame a Hyena!", GOSSIP_SENDER_MAIN, 1011);
player->ADD_GOSSIP_ITEM(4, "Tame a Moth!", GOSSIP_SENDER_MAIN, 1012);
player->ADD_GOSSIP_ITEM(4, "Tame a Nether Ray!", GOSSIP_SENDER_MAIN, 1013);
player->ADD_GOSSIP_ITEM(4, "Tame a Raptor!", GOSSIP_SENDER_MAIN, 1014);
player->SEND_GOSSIP_MENU(1, m_creature->GetGUID());
break;
case 10000: // Submenu
上面是部分代码显示
下面是全部代码下载
|