• T端音乐盒子-NPC脚本


    为什么叫音乐盒子呢??这个说简单点,其实就是制作一个NPC,然后让玩家可以在游戏中有选则性的播放游戏音乐!有趣吧?
    
    其实主要用到了PlayDirectSound函数和SendPlaySound函数。
    这两个函数都是用来播放声音的。。声音当然是在每个玩家的客户端存储着呢!
    
    这个就是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 Horde
        two = 9801, // Silvermoon City
        three = 5234, // Horde Tavern
     
        four = 11810, // Dwarf Music
        five = 2532, // Stormwind City
        six = 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内核中去,你就需要参考其他的资料了。这里就不说了!
  • 相关阅读:
    论url
    jquery send(data) 对data的处理
    jquery ajax 对异步队列defer与XMLHttprequest.onload的依赖
    requirejs解决异步模块加载方案
    vue 解决display与 transition冲突
    node exports与 module.exports的区别
    node js 模块分类
    写在入职初期
    入职前要学习的一些知识
    论文实验 云平台压力测试及服务器性能测试
  • 原文地址:https://www.cnblogs.com/needly/p/3752603.html
Copyright © 2020-2023  润新知