当前位置:首页>>魔兽单机>>正文
模拟器:使用法术消耗物品,金币功能参考
2013-07-05 17:20:51 作者:网络 来源: 浏览次数:0
摘要:MANGOS魔兽服务端使用法术消耗物品,金币等功能系统参考
 diff --git a/sqlmgcore/V5.23_mangos_string(Spell_cost).sql b/sqlmgcore/V5.23_mangos_string(Spell_cost).sql
new file mode 100644
index 0000000..07e1fe3
--- /dev/null
+++ b/sqlmgcore/V5.23_mangos_string(Spell_cost).sql
@@ -0,0 +1,3 @@
+INSERT INTO `mangos_string` VALUES ('15026', '[娉曟湳]鎮ㄩ渶瑕侀噾甯?\'%u\'涓紝鎵嶈兘浣跨敤璇ユ妧鑳?, null, null, null, null, null, null, null, null);
+INSERT INTO `mangos_string` VALUES ('15027', '[娉曟湳]鎮ㄩ渶瑕佺墿鍝?\'%s\' 鏁伴噺 \'%u\'涓紝鎵嶈兘浣跨敤璇ユ妧鑳?, null, null, null, null, null, null, null, null);
+INSERT INTO `mangos_string` VALUES ('15028', '[娉曟湳]鎮ㄩ渶瑕?\'%u\'绉垎锛屾墠鑳戒娇鐢ㄨ鎶€鑳?, null, null, null, null, null, null, null, null);
diff --git a/sqlmgcore/V5.23_mangosd.conf b/sqlmgcore/V5.23_mangosd.conf
new file mode 100644
index 0000000..6e2e1c9
--- /dev/null
+++ b/sqlmgcore/V5.23_mangosd.conf
@@ -0,0 +1,11 @@
+############################[技能消费系统]########################################## 
+#    技能消费系统
+#        是指玩家在使用技能的时候,所消耗的玩家身上的物品,金币,积分等  
+#    Spell.Cost.On.Off = 0 
+#        是否开启技能消费系统(1,开启 ; 0,默认关闭) ,关闭则为官方设置
+#
+#    说明:对于设计哪些技能需要消耗物品,及消耗物品种类,和消耗的积分金币的数量请到
+#    Mangos库的spell_cost表中去增加修改。详细见论坛的教程区www.mgcore.com
+#####################################################################################################   
+
+Spell.Cost.On.Off = 0
\ No newline at end of file
diff --git a/sqlmgcore/V5.23_spell_cost.sql b/sqlmgcore/V5.23_spell_cost.sql
new file mode 100644
index 0000000..c5c535f
--- /dev/null
+++ b/sqlmgcore/V5.23_spell_cost.sql
@@ -0,0 +1,22 @@
+/*
+MySQL Data Transfer
+Source Host: localhost
+Source Database: mangos
+Target Host: localhost
+Target Database: mangos
+Date: 2009-9-21 17:33:12
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+-- ----------------------------
+-- Table structure for spell_cost
+-- ----------------------------
+CREATE TABLE `spell_cost` (
+  `entry` int(11) unsigned NOT NULL default '0' COMMENT 'Spell entry',
+  `cost_money` int(8) unsigned NOT NULL default '0' COMMENT 'Cast Money Of Gold',
+  `cost_integral` int(8) unsigned NOT NULL default '0' COMMENT 'Cast Integral',
+  `cost_itemid` int(8) NOT NULL default '0' COMMENT 'Cast Item_template Entry',
+  `cost_itemcount` int(3) NOT NULL default '0' COMMENT 'Cast Item Count',
+  PRIMARY KEY  (`entry`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Disabled Spell System';
+
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 491a9b9..374598a 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -466,6 +466,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "spell_disabled",              SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellDisabledCommand,           "", NULL }, //禁止某个技能,数据库重载
         { "player_loot_template",        SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadPlayerLootTemplateCommand,      "", NULL }, //重载玩家掉率
         { "creature_addtemp",            SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadCreatureAddtempCommand,         "", NULL }, //重载灾变系统
+        { "spell_cost",                  SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellCostCommand,               "", NULL }, //使用技能的消耗数据库从载
 
         { NULL,                          0,                 false, NULL,                                                     "", NULL }
     };
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 9827f8d..1f3d47e 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -392,6 +392,7 @@ class ChatHandler
         bool HandleReloadSpellDisabledCommand(const char* args); //禁止某个技能数据库从载
         bool HandleReloadPlayerLootTemplateCommand(const char* args); //重载玩家掉率
         bool HandleReloadCreatureAddtempCommand(const char* args); //重载灾变秒年2 2系统
+        bool HandleReloadSpellCostCommand(const char* args); //使用技能的消耗数据库从载
 
         bool HandleResetAchievementsCommand(const char * args);
         bool HandleResetAllCommand(const char * args);
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 53b4a19..946fd9a 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -166,6 +166,7 @@ bool ChatHandler::HandleReloadAllSpellCommand(const char*)
     HandleReloadSpellDisabledCommand("a"); //禁止某个技能数据库重载
     HandleReloadPlayerLootTemplateCommand("a"); //重载玩家掉率
     HandleReloadCreatureAddtempCommand("a"); //重载灾变系统
+    HandleReloadSpellCostCommand("a"); //使用技能的消耗数据库从载
     return true;
 }
 
@@ -785,6 +786,17 @@ bool ChatHandler::HandleReloadCreatureAddtempCommand(const char* /*arg*/) //
     return true;
 }
 
+bool ChatHandler::HandleReloadSpellCostCommand(const char* /*arg*/) //使用技能的消耗数据库从载
+{
+    sLog.outString( "Re-Loading spell cost table...");
+
+    objmgr.LoadSpellCostEntrys();
+
+    SendGlobalSysMessage("DB table `spell_cost` reloaded.");
+
+    return true;
+}
+
 bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*)
 {
     sLog.outString( "Re-Loading Locales Achievement Reward Data..." );
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 95befef..0cf13d1 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -7115,6 +7115,59 @@ void ObjectMgr::LoadCreatureAddtemp() //
     sLog.outString( ">> Loaded %u creature addtemp from `creature_addtemp`", total_count);
 }//重载灾变系统
 
+void ObjectMgr::LoadSpellCostEntrys() //法术使用消耗物品系统
+{                                        
+    m_Spell_Cost.clear();
+    QueryResult *result = WorldDatabase.Query("SELECT entry, cost_money, cost_integral, cost_itemid, cost_itemcount FROM spell_cost");
+
+    uint32 total_count = 0;
+
+    if( !result )
+    {
+        barGoLink bar( 1 );
+        bar.step();
+
+        sLog.outString();
+        sLog.outString( ">> Loaded %u spell cost", total_count );
+        return;
+    }
+
+    barGoLink bar( result->GetRowCount() );
+
+    Field* fields;
+    do
+    {
+        SpellCost temp; //定义内存
+ bar.step();
+        fields = result->Fetch();
+        uint32 entry = fields[0].GetUInt32();
+        if(!sSpellStore.LookupEntry(entry))
+        {
+            sLog.outErrorDb("Spell entry %u from `spell_cost` doesn't exist in dbc, ignoring.",entry);
+            continue;
+        }
+        temp.spellid = entry;
+ temp.money = fields[1].GetUInt32();
+        temp.integral = fields[2].GetUInt32();
+        temp.itemid = fields[3].GetUInt32();
+        if(!sItemStore.LookupEntry(temp.itemid))
+        {
+            sLog.outDebug("item entry %u from `spell_cost` is your custom items.",temp.itemid);
+            //continue;
+        }
+        temp.itemcount = fields[4].GetUInt32();
+
+ m_Spell_Cost[entry] = temp; //把值放到内存
+
+ ++total_count;
+   } while ( result->NextRow() );
+
+    delete result;
+
+    sLog.outString();
+    sLog.outString( ">> Loaded %u spell cost from `spell_cost`", total_count);
+}//重载技能消耗系统
+
 void ObjectMgr::LoadFishingBaseSkillLevel()
 {
     mFishingBaseForArea.clear();                            // for reload case
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index a343ff8..fafa4b8 100644
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -93,6 +93,16 @@ struct CreatureAddtemp //
  uint32 spawntimesecs;
 };
 
+struct SpellCost //技能消耗物品系统
+{
+    uint32 entry;
+    uint32 spellid;
+ uint32 money;
+ uint32 integral;
+ uint32 itemid;
+ uint32 itemcount;
+};
+
 struct ScriptInfo
 {
     uint32 id;
@@ -340,6 +350,8 @@ class ObjectMgr
 
         typedef UNORDERED_MAP<uint32, CreatureAddtemp> CreatureAddtempMap;//灾变系统
 
+        typedef UNORDERED_MAP<uint32, SpellCost> SpellCostMap;//法术使用消耗物品系统
+
         typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
 
         typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@@ -446,6 +458,15 @@ class ObjectMgr
         }
  CreatureAddtempMap const& GetCreatureAddtemp() const { return m_Creature_Addtemp; }
 
+        SpellCost const* GetSpellCost(uint32 id) const //技能消耗物品系统
+        {
+            SpellCostMap::const_iterator itr = m_Spell_Cost.find(id);
+            if( itr != m_Spell_Cost.end( ) )
+                return &itr->second;
+            return NULL;
+        }
+ SpellCostMap const& GetSpellCost() const { return m_Spell_Cost; }
+
         uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
         {
             QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
@@ -777,6 +798,8 @@ class ObjectMgr
 
         void LoadCreatureAddtemp(); //重载灾变系统
 
+        void LoadSpellCostEntrys(); //重载技能消耗物品系统
+
         int GetIndexForLocale(LocaleConstant loc);
         LocaleConstant GetLocaleForIndex(int i);
 
@@ -909,6 +932,8 @@ class ObjectMgr
  PlayerLootTemplateMap  m_Player_Loot_Template;
         
  CreatureAddtempMap  m_Creature_Addtemp;//灾变系统
+        
+ SpellCostMap  m_Spell_Cost;//技能消耗物品系统
 
         GraveYardMap        mGraveYardMap;
 
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 48534e5..c02ecaa 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -2284,6 +2284,64 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
         }
     }
 
+ //技能消耗物品的系统
+ if (sConfig.GetIntDefault("Spell.Cost.On.Off", 0) == 1 )
+ {
+ if (m_caster->GetTypeId() == TYPEID_PLAYER)
+    {
+ ObjectMgr::SpellCostMap const& cSpellCost = objmgr.GetSpellCost();
+
+        for (ObjectMgr::SpellCostMap::const_iterator itr = cSpellCost.begin(); itr != cSpellCost.end(); ++itr)
+            {
+ uint32 mSpellid = itr->second.spellid;
+        uint32 mMoney = itr->second.money;
+                uint32 mIntegral = itr->second.integral;
+                uint32 mItemid = itr->second.itemid;
+                uint32 mItemcount= itr->second.itemcount;
+
+    if (m_spellInfo->Id == mSpellid && mSpellid != 0)
+    {
+ //判断金币是否足够
+ if (((Player*)m_caster)->GetMoney() > mMoney*10000 && mMoney > 0 )
+    {
+ ((Player*)m_caster)->ModifyMoney(-int32(mMoney*10000));
+    }
+    else if (mMoney > 0)
+    {
+ ((Player*)m_caster)->GetSession()->SendAreaTriggerMessage(((Player*)m_caster)->GetSession()->GetMangosString(15026),mMoney*10000);
+    SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+                        finish(false);
+                        return;
+    }
+                    //判断物品是否足够
+    if (((Player*)m_caster)->HasItemCount(mItemid,mItemcount) && mItemid > 0 && mItemcount > 0 )
+    {
+    ((Player*)m_caster)->DestroyItemCount(mItemid, mItemcount, true);
+    }
+    else if (mItemid > 0 && mItemcount > 0)
+    {
+ ((Player*)m_caster)->GetSession()->SendAreaTriggerMessage(((Player*)m_caster)->GetSession()->GetMangosString(15027),((Player*)m_caster)->GetItemCharName(mItemid),mItemcount);
+    SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+                        finish(false);
+                        return;
+    }
+ //判断积分是否足够
+    if ( mIntegral > 0 && ((Player*)m_caster)->GetAccountJf(((Player*)m_caster)->GetSession()->GetAccountId())>mIntegral)
+    {
+    ((Player*)m_caster)->ModifyIntegral(mIntegral,((Player*)m_caster)->GetSession()->GetAccountId());
+    }
+    else if (mIntegral > 0)
+    {
+ ((Player*)m_caster)->GetSession()->SendAreaTriggerMessage(((Player*)m_caster)->GetSession()->GetMangosString(15028),mIntegral);
+    SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+                        finish(false);
+                        return;
+    }
+    }
+            }
+    }
+ }
+
     // Fill cost data
     m_powerCost = CalculatePowerCost();
 
diff --git a/src/game/World.cpp b/src/game/World.cpp
index a90d8ed..c013dcb 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1317,6 +1317,9 @@ void World::SetInitialWorldSettings()
  sLog.outString( "Loading Creature Addtemp..." );//灾变系统
     objmgr.LoadCreatureAddtemp();
 
+ sLog.outString( "Loading Spell Cost..." );//载入入技能消耗物品系统
+    objmgr.LoadSpellCostEntrys();
+
     sLog.outString( "Loading Loot Tables..." );
     sLog.outString();
     LoadLootTables();
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index a71ac62..a35f79e 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1696,3 +1696,15 @@ AutoGet.Special.Area.Money = 4
 AutoGet.Special.Area.Integral = 4
 AutoGet.Special.Area.Item.Entry = 0
 AutoGet.Special.Area.Item.Count = 0
+
+Spell.Cost.On.Off = 0
\ No newline at end of file
 


相关报道:

[关闭] [返回顶部]


  返回首页 | 最新资讯 | 资源下载 | 魔兽图片 | 单机文档 | 技术攻略 | 玩家视频
备案号:蜀ICP备2024062380号-1
免责声明:本网站为热爱怀旧WOW的玩家们建立的魔兽世界资料网站,仅供交流和学习使用,非盈利和商用.如有侵权之处,请联系我们,我们会在24小时内确认删除侵权内容,谢谢合作。
Copyright © 2024 - 2024 WOWAII.COM Corporation, All Rights Reserved

机器人国度