当前位置:首页>>魔兽单机>>正文
TRINITY的禁止技能的系统代码
2013-07-05 17:21:09 作者:网络 来源: 浏览次数:0
摘要:TRINITY模拟器的禁止技能的系统代码
1、TrinityHG_rev1175-禁止技能之宠物
 # HG changeset patch
# User KingPin
# Date 1236430022 18000
# Branch trunk
# Node ID 7910c3719e17c362c5de005dbeacfaed2a21ea2a
# Parent  72b8c4aff658370035b4bb5a64602295b96696a7
Extend the spell_disabled table to have a seperate flag for pet spells from player spells, Patch by Koani
 
diff -r 72b8c4aff658 -r 7910c3719e17 src/game/ObjectMgr.cpp
--- a/src/game/ObjectMgr.cpp Sat Mar 07 09:04:27 2009 +0100
+++ b/src/game/ObjectMgr.cpp Sat Mar 07 07:47:02 2009 -0500
@@ -6289,6 +6289,7 @@
 {
     m_DisabledPlayerSpells.clear();                                // need for reload case
     m_DisabledCreatureSpells.clear();
+    m_DisabledPetSpells.clear();
     QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled");
 
     uint32 total_count = 0;
@@ -6321,6 +6322,8 @@
             m_DisabledPlayerSpells.insert(spellid);
         if(disable_mask & SPELL_DISABLE_CREATURE)
             m_DisabledCreatureSpells.insert(spellid);
+        if(disable_mask & SPELL_DISABLE_PET)
+            m_DisabledPetSpells.insert(spellid);
         ++total_count;
    } while ( result->NextRow() );
 
diff -r 72b8c4aff658 -r 7910c3719e17 src/game/ObjectMgr.h
--- a/src/game/ObjectMgr.h Sat Mar 07 09:04:27 2009 +0100
+++ b/src/game/ObjectMgr.h Sat Mar 07 07:47:02 2009 -0500
@@ -712,6 +712,7 @@
         void LoadSpellDisabledEntrys();
         bool IsPlayerSpellDisabled(uint32 spellid) { return (m_DisabledPlayerSpells.count(spellid) != 0); }
         bool IsCreatureSpellDisabled(uint32 spellid) { return (m_DisabledCreatureSpells.count(spellid) != 0); }
+        bool IsPetSpellDisabled(uint32 spellid) { return (m_DisabledPetSpells.count(spellid) != 0); }
 
         int GetIndexForLocale(LocaleConstant loc);
         LocaleConstant GetLocaleForIndex(int i);
@@ -831,6 +832,7 @@
 
         std::set<uint32>    m_DisabledPlayerSpells;
         std::set<uint32>    m_DisabledCreatureSpells;
+        std::set<uint32>    m_DisabledPetSpells;
 
         GraveYardMap        mGraveYardMap;
 
diff -r 72b8c4aff658 -r 7910c3719e17 src/game/Spell.cpp
--- a/src/game/Spell.cpp Sat Mar 07 09:04:27 2009 +0100
+++ b/src/game/Spell.cpp Sat Mar 07 07:47:02 2009 -0500
@@ -2048,9 +2048,18 @@
         return;
     }
 
-    if(m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet()))
+    if(m_caster->GetTypeId() == TYPEID_PLAYER)
     {
         if(objmgr.IsPlayerSpellDisabled(m_spellInfo->Id))
+        {
+            SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+            finish(false);
+            return;
+        }
+    }
+    else if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet())
+    {
+        if(objmgr.IsPetSpellDisabled(m_spellInfo->Id))
         {
             SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
             finish(false);
diff -r 72b8c4aff658 -r 7910c3719e17 src/game/SpellMgr.h
--- a/src/game/SpellMgr.h Sat Mar 07 09:04:27 2009 +0100
+++ b/src/game/SpellMgr.h Sat Mar 07 07:47:02 2009 -0500
@@ -230,7 +230,8 @@
 enum SpellDisableTypes
 {
     SPELL_DISABLE_PLAYER = 1,
-    SPELL_DISABLE_CREATURE = 2
+    SPELL_DISABLE_CREATURE = 2,
+    SPELL_DISABLE_PET = 4
 };
 
 enum SpellEffectTargetTypes

禁止对生物释放的技能

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 4ac76b6..2ef3a87 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -7368,6 +7368,7 @@ void ObjectMgr::LoadSpellDisabledEntrys() //
     m_DisabledPlayerSpells.clear();                                // need for reload case
     m_DisabledCreatureSpells.clear();
     m_DisabledPetSpells.clear();
+ m_DisabledToCreature.clear();
     QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled");
 
     uint32 total_count = 0;
@@ -7402,6 +7403,8 @@ void ObjectMgr::LoadSpellDisabledEntrys() //
             m_DisabledCreatureSpells.insert(spellid);
         if(disable_mask & SPELL_DISABLE_PET)
             m_DisabledPetSpells.insert(spellid);
+ if(disable_mask & SPELL_DISABLE_TOCREATURE)
+ m_DisabledToCreature.insert(spellid);
         ++total_count;
    } while ( result->NextRow() );
 
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index f8a0e55..593daab 100644
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -1175,6 +1175,7 @@ class ObjectMgr
         bool IsPlayerSpellDisabled(uint32 spellid) { return (m_DisabledPlayerSpells.count(spellid) != 0); }
         bool IsCreatureSpellDisabled(uint32 spellid) { return (m_DisabledCreatureSpells.count(spellid) != 0); }
         bool IsPetSpellDisabled(uint32 spellid) { return (m_DisabledPetSpells.count(spellid) != 0); }
+ bool IsPlayerSpellDisabledToCreature(uint32 spellid) { return (m_DisabledToCreature.count(spellid) != 0); }
 
         void LoadPlayerLootTemplate(); //重载玩家掉率
         uint32 PlayerLootItemid(uint32 entry)//获得物品ID号(要掉落的物品player_loot_template)
@@ -1394,6 +1395,7 @@ class ObjectMgr
         std::set<uint32>    m_DisabledPlayerSpells; //数据库中禁止某个技能
         std::set<uint32>    m_DisabledCreatureSpells; //数据库中禁止某个技能
         std::set<uint32>    m_DisabledPetSpells;//数据库中禁止某个技能
+ std::set<uint32>    m_DisabledToCreature;//禁止对生物释放的技能
 
         typedef UNORDERED_MAP<uint32, PlayerLootTemplate> PlayerLootTemplateMap;//玩家掉率系统的内存地图定义
  PlayerLootTemplateMap  m_Player_Loot_Template;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 161991c..c43b874 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4236,6 +4236,21 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar
 
     DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell %u Effect%d : %u", m_spellInfo->Id, i, eff);
 
+ if (sObjectMgr.IsPlayerSpellDisabledToCreature(m_spellInfo->Id) && unitTarget->GetTypeId() == TYPEID_UNIT)
+ {//禁止对生物释放的技能
+ sLog.outDebug("MgCore::Here is Crash IsPlayerSpellDisabledToCreature?");
+ uint32 TargetEntry = unitTarget->GetEntry();
+ if (TargetEntry != 0)
+ {
+    if (((Creature*)unitTarget)->isWorldBoss())
+    {
+    SendCastResult(SPELL_FAILED_BAD_TARGETS);
+                finish(false);
+                return;
+    }
+ }
+ }
+
     if(eff < TOTAL_SPELL_EFFECTS)
     {
         (*this.*SpellEffects[eff])(i);
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h
index b652013..29cd447 100644
--- a/src/game/SpellMgr.h
+++ b/src/game/SpellMgr.h
@@ -70,7 +70,8 @@ enum SpellDisableTypes  //
 {
     SPELL_DISABLE_PLAYER = 1,
     SPELL_DISABLE_CREATURE = 2,
-    SPELL_DISABLE_PET = 4
+    SPELL_DISABLE_PET = 4,
+ SPELL_DISABLE_TOCREATURE = 8
 };
 
 //Some SpellFamilyFlags
 

数据库中禁止某个技能

Index: src/game/Chat.cpp
===================================================================
--- src/game/Chat.cpp (revision 81)
+++ src/game/Chat.cpp (working copy)
@@ -310,6 +310,7 @@
         { "spell_scripts",               SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellScriptsCommand,            "", NULL },
         { "spell_target_position",       SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellTargetPositionCommand,     "", NULL },
         { "spell_threats",               SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellThreatsCommand,            "", NULL },
+        { "spell_disabled",              SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellDisabledCommand,           "", NULL }, //禁止某个技能,数据库重载
         { "locales_creature",            SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadLocalesCreatureCommand,         "", NULL },
         { "locales_gameobject",          SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadLocalesGameobjectCommand,       "", NULL },
         { "locales_item",                SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadLocalesItemCommand,             "", NULL },
Index: src/game/Chat.h
===================================================================
--- src/game/Chat.h (revision 81)
+++ src/game/Chat.h (working copy)
@@ -260,6 +260,7 @@
         bool HandleReloadSpellTargetPositionCommand(const char* args);
         bool HandleReloadSpellThreatsCommand(const char* args);
         bool HandleReloadSpellPetAurasCommand(const char* args);
+        bool HandleReloadSpellDisabledCommand(const char* args); //禁止某个技能数据库从载
         bool HandleReloadPageTextsCommand(const char* args);
         bool HandleReloadItemEnchantementsCommand(const char* args);
         bool HandleReloadLocalesCreatureCommand(const char* args);
Index: src/game/Level3.cpp
===================================================================
--- src/game/Level3.cpp (revision 81)
+++ src/game/Level3.cpp (working copy)
@@ -142,6 +142,7 @@
     HandleReloadSpellTargetPositionCommand("a");
     HandleReloadSpellThreatsCommand("a");
     HandleReloadSpellPetAurasCommand("a");
+    HandleReloadSpellDisabledCommand("a"); //禁止某个技能数据库重载
     return true;
 }
 
@@ -652,6 +653,17 @@
     return true;
 }
 
+bool ChatHandler::HandleReloadSpellDisabledCommand(const char* /*arg*/) //禁止某个技能数据库重载
+{
+    sLog.outString( "Re-Loading spell disabled table...");
+
+    objmgr.LoadSpellDisabledEntrys();
+
+    SendGlobalSysMessage("DB table `spell_disabled` reloaded.");
+
+    return true;
+}
+
 bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/)
 {
     sLog.outString( "Re-Loading Locales Creature ...");
Index: src/game/ObjectMgr.cpp
===================================================================
--- src/game/ObjectMgr.cpp (revision 81)
+++ src/game/ObjectMgr.cpp (working copy)
@@ -6754,6 +6754,51 @@
     return "<error>";
 }
 
+void ObjectMgr::LoadSpellDisabledEntrys() //数据库中禁止某个技能
+{
+    m_DisabledPlayerSpells.clear();                                // need for reload case
+    m_DisabledCreatureSpells.clear();
+    QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled");
+
+    uint32 total_count = 0;
+
+    if( !result )
+    {
+        barGoLink bar( 1 );
+        bar.step();
+
+        sLog.outString();
+        sLog.outString( ">> Loaded %u disabled spells", total_count );
+        return;
+    }
+
+    barGoLink bar( result->GetRowCount() );
+
+    Field* fields;
+    do
+    {
+        bar.step();
+        fields = result->Fetch();
+        uint32 spellid = fields[0].GetUInt32();
+        if(!sSpellStore.LookupEntry(spellid))
+        {
+            sLog.outErrorDb("Spell entry %u from `spell_disabled` doesn't exist in dbc, ignoring.",spellid);
+            continue;
+        }
+        uint32 disable_mask = fields[1].GetUInt32();
+        if(disable_mask & SPELL_DISABLE_PLAYER)
+            m_DisabledPlayerSpells.insert(spellid);
+        if(disable_mask & SPELL_DISABLE_CREATURE)
+            m_DisabledCreatureSpells.insert(spellid);
+        ++total_count;
+   } while ( result->NextRow() );
+
+    delete result;
+
+    sLog.outString();
+    sLog.outString( ">> Loaded %u disabled spells from `spell_disabled`", total_count);
+}//数据库中禁止某个技能
+
 void ObjectMgr::LoadFishingBaseSkillLevel()
 {
     mFishingBaseForArea.clear();                            // for reload case
Index: src/game/ObjectMgr.h
===================================================================
--- src/game/ObjectMgr.h (revision 81)
+++ src/game/ObjectMgr.h (working copy)
@@ -711,6 +711,10 @@
 
         static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);
 
+        void LoadSpellDisabledEntrys(); //数据库中禁止某个技能
+        bool IsPlayerSpellDisabled(uint32 spellid) { return (m_DisabledPlayerSpells.count(spellid) != 0); }
+        bool IsCreatureSpellDisabled(uint32 spellid) { return (m_DisabledCreatureSpells.count(spellid) != 0); }
+
         int GetIndexForLocale(LocaleConstant loc);
         LocaleConstant GetLocaleForIndex(int i);
         // guild bank tabs
@@ -834,6 +838,9 @@
         typedef std::set<std::wstring> ReservedNamesMap;
         ReservedNamesMap    m_ReservedNames;
 
+        std::set<uint32>    m_DisabledPlayerSpells; //数据库中禁止某个技能
+        std::set<uint32>    m_DisabledCreatureSpells; //数据库中禁止某个技能
+
         GraveYardMap        mGraveYardMap;
 
         GameTeleMap         m_GameTeleMap;
Index: src/game/Spell.cpp
===================================================================
--- src/game/Spell.cpp (revision 81)
+++ src/game/Spell.cpp (working copy)
@@ -2131,6 +2131,24 @@
         finish(false);
         return;
     }
+    //数据库中禁止某个技能
+    if(m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet()))
+    {
+        if(objmgr.IsPlayerSpellDisabled(m_spellInfo->Id))
+        {
+            SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+            finish(false);
+            return;
+        }
+    }
+    else
+    {
+        if(objmgr.IsCreatureSpellDisabled(m_spellInfo->Id))
+        {
+            finish(false);
+            return;
+        }
+    }
 
     // Fill cost data
     m_powerCost = CalculatePowerCost();
Index: src/game/SpellMgr.h
===================================================================
--- src/game/SpellMgr.h (revision 81)
+++ src/game/SpellMgr.h (working copy)
@@ -245,6 +245,12 @@
     SPELLFAMILY_PET         = 17
 };
 
+enum SpellDisableTypes  //数据库中禁止某个技能
+{
+    SPELL_DISABLE_PLAYER = 1,
+    SPELL_DISABLE_CREATURE = 2
+};
+
 //Some SpellFamilyFlags
 #define SPELLFAMILYFLAG_ROGUE_VANISH            0x000000800LL
 #define SPELLFAMILYFLAG_ROGUE_STEALTH           0x000400000LL
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp (revision 81)
+++ src/game/World.cpp (working copy)
@@ -1238,6 +1238,9 @@
     sLog.outString( "Loading Player Corpses..." );
     objmgr.LoadCorpses();
 
+    sLog.outString( "Loading Disabled Spells..." );//数据库中禁止某个技能
+    objmgr.LoadSpellDisabledEntrys();
+
     sLog.outString( "Loading Loot Tables..." );
     sLog.outString();
     LoadLootTables();
 


相关报道:

[关闭] [返回顶部]


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

机器人国度