T端音乐盒子-NPC脚本
生活随笔
收集整理的這篇文章主要介紹了
T端音乐盒子-NPC脚本
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
為什么叫音樂盒子呢??這個(gè)說簡(jiǎn)單點(diǎn),其實(shí)就是制作一個(gè)NPC,然后讓玩家可以在游戲中有選則性的播放游戲音樂!有趣吧?其實(shí)主要用到了PlayDirectSound函數(shù)和SendPlaySound函數(shù)。
這兩個(gè)函數(shù)都是用來播放聲音的。。聲音當(dāng)然是在每個(gè)玩家的客戶端存儲(chǔ)著呢!這個(gè)就是Trinity-Core 端3.3.5懷舊魔獸世界私服中能用到的播放音樂的NPC腳本,大家可以試試// By Asbert75 (Help from Jameyboor) //
// Jukebox //
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Player.h"
#include <cstring>enum Sounds
{one = 11803, // Power of the Hordetwo = 9801, // Silvermoon Citythree = 5234, // Horde Tavern
four = 11810, // Dwarf Musicfive = 2532, // Stormwind Citysix = 4516 // Alliance Tavern
};#define GOSSIP_ITEM_1 "I would like to play a song server-wide!" // Gamemasters only option
#define GOSSIP_ITEM_2 "I would like to play a song."
#define GOSSIP_ITEM_3 "I'm not interested"class Jukebox : public CreatureScript
{public:Jukebox(): CreatureScript("Jukebox"){}bool OnGossipHello(Player* player, Creature* creature){uint32 security = player->GetSession()->GetSecurity();if (security > SEC_PLAYER) // Checks to see if player is GM or not, if he is, below option is added.player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);player->PlayerTalkClass->SendGossipMenu(31023, creature->GetGUID());return true;}bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action){player->PlayerTalkClass->ClearMenus();switch (action){case GOSSIP_ACTION_INFO_DEF+3 :player->CLOSE_GOSSIP_MENU(); // Nevermind option, closes menu.break;// Below options is GM options only.case GOSSIP_ACTION_INFO_DEF+1 :player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Power of the Horde\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Silvermoon City\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Horde Tavern\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Dwarf Music\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Stormwind City\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Alliance Tavern\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9);player->PlayerTalkClass->SendGossipMenu(3, creature->GetGUID());break;// Below options is player & GM options.case GOSSIP_ACTION_INFO_DEF+2 :player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Power of the Horde\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Silvermoon City\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Horde Tavern\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+12);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Dwarf Music\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+13);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Stormwind City\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+14);player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Play \"Alliance Tavern\"", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+15);player->PlayerTalkClass->SendGossipMenu(3, creature->GetGUID());break;case GOSSIP_ACTION_INFO_DEF+4 :player->SendPlaySound(one, false);break;case GOSSIP_ACTION_INFO_DEF+5 :player->SendPlaySound(two, false);break;case GOSSIP_ACTION_INFO_DEF+6 :player->SendPlaySound(three, false);break;case GOSSIP_ACTION_INFO_DEF+7 :player->SendPlaySound(four, false);break;case GOSSIP_ACTION_INFO_DEF+8 :player->SendPlaySound(five, false);break;case GOSSIP_ACTION_INFO_DEF+9 :player->SendPlaySound(six, false);break;case GOSSIP_ACTION_INFO_DEF+10 :player->PlayDirectSound(one, player->GetSession()->GetPlayer());break;case GOSSIP_ACTION_INFO_DEF+11 :player->PlayDirectSound(two, player->GetSession()->GetPlayer());break;case GOSSIP_ACTION_INFO_DEF+12 :player->PlayDirectSound(three, player->GetSession()->GetPlayer());break;case GOSSIP_ACTION_INFO_DEF+13 :player->PlayDirectSound(four, player->GetSession()->GetPlayer());break;case GOSSIP_ACTION_INFO_DEF+14 :player->PlayDirectSound(five, player->GetSession()->GetPlayer());break;case GOSSIP_ACTION_INFO_DEF+15 :player->PlayDirectSound(six, player->GetSession()->GetPlayer());break;}return true;}};void AddSC_Jukebox()
{new Jukebox();
}下面是SQL的代碼。記得是3.3.5版本的哦INSERT INTO `npc_text` (`ID`, `text0_0`, `text0_1`, `lang0`, `prob0`, `em0_0`, `em0_1`, `em0_2`, `em0_3`, `em0_4`, `em0_5`, `text1_0`, `text1_1`, `lang1`, `prob1`, `em1_0`, `em1_1`, `em1_2`, `em1_3`, `em1_4`, `em1_5`, `text2_0`, `text2_1`, `lang2`, `prob2`, `em2_0`, `em2_1`, `em2_2`, `em2_3`, `em2_4`, `em2_5`, `text3_0`, `text3_1`, `lang3`, `prob3`, `em3_0`, `em3_1`, `em3_2`, `em3_3`, `em3_4`, `em3_5`, `text4_0`, `text4_1`, `lang4`, `prob4`, `em4_0`, `em4_1`, `em4_2`, `em4_3`, `em4_4`, `em4_5`, `text5_0`, `text5_1`, `lang5`, `prob5`, `em5_0`, `em5_1`, `em5_2`, `em5_3`, `em5_4`, `em5_5`, `text6_0`, `text6_1`, `lang6`, `prob6`, `em6_0`, `em6_1`, `em6_2`, `em6_3`, `em6_4`, `em6_5`, `text7_0`, `text7_1`, `lang7`, `prob7`, `em7_0`, `em7_1`, `em7_2`, `em7_3`, `em7_4`, `em7_5`, `WDBVerified`) VALUES (3, 'What song would you like to play?', 'What song would you like to play?', 0, 0, 0, 0, 0, 0, 0, 0, 'What song would you like to play?', 'What song would you like to play?', 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 1);OK,代碼就這些,至于如何把代碼加到Trinity內(nèi)核中去,你就需要參考其他的資料了。這里就不說了!
?
轉(zhuǎn)載于:https://www.cnblogs.com/needly/p/3752603.html
總結(jié)
以上是生活随笔為你收集整理的T端音乐盒子-NPC脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: How to consume AIF s
- 下一篇: Beaglebone Back学习七(U