下面是以个Trinity端的脚本代码。给猎人创建宠物什么的。姑且把它称为兽栏管理员的脚本吧。
你先得把脚本加到你的代码库里面,进行编译!
/* * * * * * * * * * * * * * * * * * By Marcus *
Heavily Edited by hL.Talis 4/30/13 *
Project: Incidia *
Beastmaster NPC *
*
* * * * * * * * * * * * * * * * * */
#include "ScriptPCH.h"
#define GOSSIP_ITEM_STABLE "Stable"
#define GOSSIP_ITEM_NEWPET "New pet"
#define GOSSIP_ITEM_BOAR "Boar"
#define GOSSIP_ITEM_SERPENT "Serpent"
#define GOSSIP_ITEM_SCRAB "Scrab"
#define GOSSIP_ITEM_LION "Lion"
#define GOSSIP_ITEM_WOLF "Wolf"
#define GOSSIP_ITEM_RAVAGER "Ravenger"
#define GOSSIP_ITEM_UNTRAINEPET "Restart Pet"
class beastmaster : public CreatureScript
{
public:
beastmaster() : CreatureScript("beastmaster"){ }
void CreatePet(Player *player, Creature * m_creature, uint32 entry)
{
if(player->getClass() != CLASS_HUNTER)
{
m_creature->MonsterWhisper("You're not a hunter.", player->GetGUID());
player->PlayerTalkClass->SendCloseGossip();
return;
}
if(player->GetPet())
{
m_creature->MonsterWhisper("First you must abandon 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;
// kill original creature
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0);
pet->SetPower(POWER_HAPPINESS, 1048000);
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
pet->GetMap()->AddToMap((Creature*)pet);
// visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
if(!pet->InitStatsForLevel(player->getLevel()))
sLog->outError ("Pet Create fail: no init stats for entry %u", entry);
pet->UpdateAllStats();
// caster have pet now
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
pet->InitTalentForLevel();
player->PetSpellInitialize();
//end
player->PlayerTalkClass->SendCloseGossip();
m_creature->MonsterWhisper("You now have a pet, you should probably feed it...", player->GetGUID());
}
bool OnGossipHello(Player *player, Creature * m_creature)
{
if(player->getClass() != CLASS_HUNTER)
{
m_creature->MonsterWhisper("You're not a hunter, and cannot tame pets.", player->GetGUID());
return true;
}
player->ADD_GOSSIP_ITEM(4, "Tame a new Pet!" GOSSIP_SENDER_MAIN, 100);
player->ADD_GOSSIP_ITEM(2, "Show me the stables.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_STABLEPET);
player->ADD_GOSSIP_ITEM(6, "Show me your food.", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_VENDOR);
player->ADD_GOSSIP_ITEM(5, "Nevermind", GOSSIP_SENDER_MAIN, 200);
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: // Submenu
player->ADD_GOSSIP_ITEM(4, "I want to tame a bear!" GOSSIP_SENDER_MAIN, 1001);
player->ADD_GOSSIP_ITEM(2, "I want to tame a boar!", GOSSIP_SENDER_MAIN, 1002);
player->ADD_GOSSIP_ITEM(6, "I want to tame a crab!", GOSSIP_SENDER_MAIN, 1003);
player->ADD_GOSSIP_ITEM(5, "I want to tame a spider!", GOSSIP_SENDER_MAIN, 1004);
player->ADD_GOSSIP_ITEM(5, "Main Menu.", GOSSIP_SENDER_MAIN, 1005);
break;
case 200: // Nevermind.
player->CLOSE_GOSSIP_MENU();
break;
case GOSSIP_OPTION_STABLEPET: // Stables
player->GetSession()->SendStablePet(m_creature->GetGUID());
break;
case GOSSIP_OPTION_VENDOR: // Food
player->GetSession()->SendListInventory(m_creature->GetGUID());
break;
case 1001: // Bear
player->ADD_GOSSIP_ITEM(4, "Tame a Light Brown Bear" GOSSIP_SENDER_MAIN, 2001);
player->ADD_GOSSIP_ITEM(2, "Tame a White Bear", GOSSIP_SENDER_MAIN, 2002);
player->ADD_GOSSIP_ITEM(4, "Tame a Black Bear" GOSSIP_SENDER_MAIN, 2003);
player->ADD_GOSSIP_ITEM(2, "Tame a Dark Brown Bear", GOSSIP_SENDER_MAIN, 2004);
player->ADD_GOSSIP_ITEM(4, "Tame an Infected Bear" GOSSIP_SENDER_MAIN, 2005);
break;
case 1002: // Boar
player->ADD_GOSSIP_ITEM(4, "Tame a Spiked Red Boar" GOSSIP_SENDER_MAIN, 3001);
player->ADD_GOSSIP_ITEM(2, "Tame a Spiked Blue Boar", GOSSIP_SENDER_MAIN, 3002);
player->ADD_GOSSIP_ITEM(4, "Tame a Spiked Green Boar" GOSSIP_SENDER_MAIN, 3003);
player->ADD_GOSSIP_ITEM(2, "Tame an Armored Boar", GOSSIP_SENDER_MAIN, 3004);
player->ADD_GOSSIP_ITEM(4, "Tame a Black Boar" GOSSIP_SENDER_MAIN, 3005);
player->ADD_GOSSIP_ITEM(4, "Tame a Tan Boar" GOSSIP_SENDER_MAIN, 3006);
break;
case 1003: // Crab
player->ADD_GOSSIP_ITEM(4, "Tame a Red Crab" GOSSIP_SENDER_MAIN, 4001);
player->ADD_GOSSIP_ITEM(2, "Tame a Blue Crab", GOSSIP_SENDER_MAIN, 4002);
player->ADD_GOSSIP_ITEM(4, "Tame a Green Crab" GOSSIP_SENDER_MAIN, 4003);
player->ADD_GOSSIP_ITEM(2, "Tame a Brown Crab", GOSSIP_SENDER_MAIN, 4004);
break;
case 1004: // Spider
player->ADD_GOSSIP_ITEM(4, "Tame a Crystal Spider" GOSSIP_SENDER_MAIN, 5001);
player->ADD_GOSSIP_ITEM(2, "Tame a Black Widow Spider", GOSSIP_SENDER_MAIN, 5002);
player->ADD_GOSSIP_ITEM(4, "Tame a Brown Furry Spider" GOSSIP_SENDER_MAIN, 5003);
player->ADD_GOSSIP_ITEM(2, "Tame a Red Furry Spider", GOSSIP_SENDER_MAIN, 5004);
player->ADD_GOSSIP_ITEM(4, "Tame a White Spider" GOSSIP_SENDER_MAIN, 5005);
player->ADD_GOSSIP_ITEM(2, "Tame a Brown Spider", GOSSIP_SENDER_MAIN, 5006);
player->ADD_GOSSIP_ITEM(4, "Tame a Red Spiky Spider" GOSSIP_SENDER_MAIN, 5007);
player->ADD_GOSSIP_ITEM(2, "Tame a Green Spider", GOSSIP_SENDER_MAIN, 5008);
player->ADD_GOSSIP_ITEM(4, "Tame a Multicolored Spiky Spider" GOSSIP_SENDER_MAIN, 5009);
break;
// Here is where the "giving pets" code begins.
case: 2001 // Light Brown Bear
CreatePet(player, m_creature, 1196);
break;
case: 2002 // White Bear
CreatePet(player, m_creature, 7444);
break;
case: 2003 // Black Bear
CreatePet(player, m_creature, 1128);
break;
case: 2004 // Dark Brown Bear
CreatePet(player, m_creature, 3809);
break;
case: 2005 // Infected Bear
CreatePet(player, m_creature, 17661);
break;
// Boars
case: 3001 // Spiky Red Boar
CreatePet(player, m_creature, 8303);
break;
case: 3002 // Spiky Blue Boar
CreatePet(player, m_creature, 22180);
break;
case: 3003 // Spiky Green Boar
CreatePet(player, m_creature, 16992);
break;
case: 3004 // Armored Boar
CreatePet(player, m_creature, 4511);
break;
case: 3005 // Black Boar
CreatePet(player, m_creature, 119);
break;
case: 3006 // Tan Boar
CreatePet(player, m_creature, 1985);
break;
// Crabs
case: 4001 // Red Crab
CreatePet(player, m_creature, 3106);
break;
case: 4002 // Blue Crab
CreatePet(player, m_creature, 26521);
break;
case: 4003 // Green Crab
CreatePet(player, m_creature, 922);
break;
case: 4004 // Brown Crab
CreatePet(player, m_creature, 3814);
break;
// Spiders
case: 5001 // Crystal Spider
CreatePet(player, m_creature, 10376);
break;
case: 5002 // Black Widow Spider
CreatePet(player, m_creature, 930);
break;
case: 5003 // Brown Furry Spider
CreatePet(player, m_creature, 30206);
break;
case: 5004 // Red Furry Spider
CreatePet(player, m_creature, 8933);
break;
case: 5005 // White Spider
CreatePet(player, m_creature, 4040);
break;
case: 5006 // Brown Spider
CreatePet(player, m_creature, 22044);
break;
case: 5007 // Red Spiky Spider
CreatePet(player, m_creature, 4380);
break;
case: 5008 // Green Spider
CreatePet(player, m_creature, 4376);
break;
case: 5009 // Multicolored Spiky Spider
CreatePet(player, m_creature, 26625);
break;
}
return true;
}
};
void AddSC_beastmaster()
{
new beastmaster();
}
回复下载Unique Beastmaster Script 脚本代码
|