吾爱尚玩资源基地

标题: 魔兽世界sf模拟器服务端修改玩家姓名的NPC脚本(M端TBC) [打印本页]

作者: admin    时间: 2016-4-20 23:00
标题: 魔兽世界sf模拟器服务端修改玩家姓名的NPC脚本(M端TBC)
diff -Nuar oregoncore-current/src/game/ScriptLoader.cpp oregoncore-pq/src/game/ScriptLoader.cpp--- oregoncore-current/src/game/ScriptLoader.cpp        2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/ScriptLoader.cpp        2011-01-01 10:20:42.000000000 -0500
@@ -11,6 +11,9 @@

#ifdef SCRIPTS

+//custom
+void AddSC_npc_rename();
+
//examples
//void AddSC_custom_example();
//void AddSC_custom_gossip_codebox();
@@ -379,6 +382,10 @@
void AddScripts()
{
#ifdef SCRIPTS
+
+    // Custom
+    AddSC_npc_rename();
+
//    AddSC_custom_example();
//    AddSC_custom_gossip_codebox();
//    AddSC_test();
diff -Nuar oregoncore-current/src/oregoncore/oregoncore.conf.dist oregoncore-pq/src/oregoncore/oregoncore.conf.dist
--- oregoncore-current/src/oregoncore/oregoncore.conf.dist        2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/oregoncore/oregoncore.conf.dist        2011-01-01 10:20:42.000000000 -0500
@@ -1981,6 +1981,15 @@
#       Default: 0 (Disabled)
#                1 - Enabled
#
+#   RenameNPC.Enable
+#       Enable the Rename NPC.
+#       Default: 1 - Enabled
+#                0 (Disabled)
+#
+#   RenameNPC.CostInGold
+#       Cost to rename character in gold.
+#       Default: 100
+#
###############################################################################

PlayerStart.AllReputation = 0
@@ -2000,6 +2009,8 @@
PlayerStart.String = ""
DuelMod.Enable = 0
DuelMod.Cooldowns = 0
+RenameNPC.Enable = 1
+RenameNPC.CostInGold = 100

###############################################################################
# MOVEMENT ANTICHEAT
diff -Nuar oregoncore-current/src/scripts/Custom/npc_rename.cpp oregoncore-pq/src/scripts/Custom/npc_rename.cpp
--- oregoncore-current/src/scripts/Custom/npc_rename.cpp        1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/src/scripts/Custom/npc_rename.cpp        2011-01-01 10:20:42.000000000 -0500
@@ -0,0 +1,68 @@
+#include "ScriptPCH.h"
+#include "Config/Config.h"
+
+enum ActNpcRename
+{
+    ACT_RENAME   = 1001,
+    ACT_CONFIRM  = 1002
+};
+
+#define GOSSIP_RENAME_HELLO        "I want to change my name and hide a terrible deed."
+#define GOSSIP_RENAME_CONFIRM      "Are you sure?"
+#define MSG_NOT_ENOUGH_MONEY       "Get out, you are wasting my time!  Come back if you can pay me!"
+#define MSG_COMPLETE_RENAME        "Done!  Now log out of the game and sign in again.  Your secret will die with you!"
+
+bool GossipHello_npc_rename(Player* pPlayer, Creature* pCreature)
+{
+    bool EnableRename = sConfig.GetBoolDefault("RenameNPC.Enable", true);
+
+    if (EnableRename)
+    {
+        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_RENAME_HELLO, GOSSIP_SENDER_MAIN, ACT_RENAME);
+        pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
+    }
+    return true;
+}
+
+bool GossipSelect_npc_rename(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
+{
+    if (uiSender != GOSSIP_SENDER_MAIN)
+        return false;
+
+        uint32 RenameCost = sConfig.GetIntDefault("RenameNPC.CostInGold", 100);
+        uint32 RenameCopper = RenameCost * 10000;
+
+    switch (uiAction)
+    {
+        case ACT_RENAME:
+            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_RENAME_CONFIRM, GOSSIP_SENDER_MAIN, ACT_CONFIRM);
+            pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
+            break;
+        case ACT_CONFIRM:
+            if (pPlayer->GetMoney() < RenameCopper)
+            {
+                pCreature->MonsterWhisper(MSG_NOT_ENOUGH_MONEY, pPlayer->GetGUID());
+            } else {
+                pCreature->MonsterWhisper(MSG_COMPLETE_RENAME, pPlayer->GetGUID());
+                pPlayer->ModifyMoney(-RenameCopper);
+                pPlayer->SetAtLoginFlag(AT_LOGIN_RENAME);
+            }
+            pPlayer->CLOSE_GOSSIP_MENU();
+            break;
+        default:
+            pPlayer->CLOSE_GOSSIP_MENU();
+    }
+    return true;
+}
+
+void AddSC_npc_rename()
+{
+    Script *newscript;
+
+    newscript = new Script;
+    newscript->Name="npc_rename";
+    newscript->pGossipHello = &GossipHello_npc_rename;
+    newscript->pGossipSelect = &GossipSelect_npc_rename;
+    newscript->RegisterSelf();
+}
+

回复下载完整代码









欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/) Powered by Discuz! X3.4