为什么叫音乐盒子呢??这个说简单点,其实就是制作一个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 Tavernfour = 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内核中去,你就需要参考其他的资料了。这里就不说了!
T端音乐盒子-NPC脚本
时间: 2024-10-17 12:44:29
T端音乐盒子-NPC脚本的相关文章
T端无限制附魔NPC脚本
1.首先,这个是脚本代码.你需要知道Trinity-Core如何增加脚本 2.这个是一套NPC的脚本. 3.脚本功能就是通过NPC来给自己身上的物品附魔(附魔都知道吧?) 5.你需要在creature_template里面加上对应的NPC,然后使用npc_enchantment脚本名称,.然后进入游戏用.npc add 来增加该功能NPC 下面是代码 #include "ScriptPCH.h" class npc_enchantment : public CreatureScript
T端PVP头衔获得NPC脚本
次代码是一个T端的脚本.通过击杀的角色数量等级来获得不同的头衔. 下面的Ranks就是击杀的数量.根据你的击杀数量,你可以到NPC那里去领取对应的头衔等级 #include "ScriptPCH.h" enum Ranks { RANK_1 = 50, RANK_2 = 100, RANK_3 = 500, RANK_4 = 1000, RANK_5 = 2000, RANK_6 = 4000, RANK_7 = 5000, RANK_8 = 6000, RANK_9 = 8000,
T端大灾变版本传送大师(NPC 脚本)
#include "ScriptPCH.h" class npc_teleport : public CreatureScript{ public: npc_teleport() : CreatureScript("npc_teleport") { } bool OnGossipHello(Player *player, Creature *_creature) {
T端单机魔兽世界私服中的轮盘游戏(NPC脚本)
大概就是这个图的意思了~~~通过NPC来实现..应该是非常有趣的一种设置了!增加单机中的趣味然后我们来看看代码 #include "ScriptPCH.h" class gamble_npc : public CreatureScript { public: gamble_npc() : CreatureScript("gamble_npc") { } std::string colorstring(uint16 type) { switch(type) { def
T端多功能魔兽NPC脚本-Tools Npc脚本代码
已经有很多的功能性的NPC的Trinity-Core魔兽世界私服单机 的脚本代码.这里我在弄一个可能大家都会比较喜欢的NPC脚本代码1.适用于怀旧魔兽私服Trinity-Core 3.3.5版本最新2.此脚本是npc 的C++脚本,脚本名称要加到creature_template对应的NPC的脚本处3.你需要知道如何在T端中增加对应的脚本功能4.下面是一些该脚本的功能描述 NPC 功能包含: ? 恢复血量和法力值 ? 重置所有的副本进度 ? 重置所有的技能冷却时间 ? 重置战斗状态 ? 移除虚弱
T端PVP头衔购买脚本
这个是一套NPC脚本的功能代码.主要实现购买头衔下面是脚本代码, /**************************************** * Created by: Rochet2 * * Updated by: Asbert75 * * With help from: * * LilleCarl, Rochet2, Jamey * * *----- Title Vendor -----* * ****************************************/ #in
T端 GameObject上的T端魔兽私服传送脚本
1.实现魔兽中简单的Gameobeject传送.主要是方便初学者参考使用! 2.与上一篇不同的是.这篇主要是在Gameobeject上实现传送,而不是NPC上.. 例如:你需要在gameobject_template表中找一些模型ID.然后在scriptname这一列中增加脚本名称,本例的脚本名称是"gob_teleport" 比如选一些游戏目标来增加脚本.打开gameobject_template表,选一些物件:祖尔法拉克铁锣,拉瑟莱克之泪,阿尔萨斯之泪, 伊姆贝尔之焰,瑟玛普拉格的
Vue 2.0开发企业级移动端音乐WebAPP
第1章 课程内容介绍包括课程概述.课程安排.学习前提.讲授方式等方面的介绍,最后演示了整个音乐App的功能,让同学们对课程项目有一个直观的了解.1-1 导学1-2 课前必读(源码获取方式) 第2章 项目准备工作包括项目需求分析.脚手架初始化代码.项目目录介绍及图标字体.公共样式等资源的准备 .2-1 需求分析2-2 Vue-cli脚手架安装2-3 项目目录介绍及图标字体.公共样式等资源准备 第3章 页面骨架开发包括页面入口.header 组件的编写.路由配置及顶导 tab 组件开发.3-1 页面
Asp.net 中,在服务端向客户端写脚本的常用方法
在Asp.net 服务端处理脚本,一般都用 ClientScriptManager ,即web窗体服务端的this.ClientScript.该对象比较常用的方法: 1.RegisterArrayDeclaration:在服务端,向客户端生成一个数组定义 服务端代码: this.ClientScript.RegisterArrayDeclaration("aAry", "1,2,3"); 客户端“源文件”呈现 <script type="text