Jump to content

Spell Disabled


Guest llune

Recommended Posts

Proposal for something that will be very useful for appears bugs spell

stopping magic not working. After being repaired, you can resolve them. (Admin tools)

patch: Spell_disable.rar

spell_disable.rar contains 2 files Spell_disable.patch and mangos_spell_disable.sql. SQL file does mangos table in your database name spell_disabled. Each spell is not working well and want to stop is not used by the players you can add it there. After the restart can not be used.

Link to comment
Share on other sites

  • 4 weeks later...

this is spell disable patch

diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 3444776..2685798 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -454,6 +454,7 @@ ChatCommand * ChatHandler::getCommandTable()
        { "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 },

        { NULL,                          0,                 false, NULL,                                                     "", NULL }
    };
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 18ef9cc..08cb422 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -380,6 +380,7 @@ class ChatHandler
        bool HandleReloadSpellTargetPositionCommand(const char* args);
        bool HandleReloadSpellThreatsCommand(const char* args);
        bool HandleReloadSpellPetAurasCommand(const char* args);
+        bool HandleReloadSpellDisabledCommand(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 6eeaff4..1b1c243 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -162,6 +162,7 @@ bool ChatHandler::HandleReloadAllSpellCommand(const char*)
    HandleReloadSpellTargetPositionCommand("a");
    HandleReloadSpellThreatsCommand("a");
    HandleReloadSpellPetAurasCommand("a");
+    HandleReloadSpellDisabledCommand("a");
    return true;
}

@@ -812,6 +813,17 @@ bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
    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::HandleLoadScriptsCommand(const char* args)
{
    if(!LoadScriptingModule(args)) return true;
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 8f3e5e1..7ac4dea 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -6735,6 +6735,46 @@ const char *ObjectMgr::GetMangosString(int32 entry, int locale_idx) const
    return "<error>";
}

+void ObjectMgr::LoadSpellDisabledEntrys()
+{
+    m_spell_disabled.clear();                                // need for reload case
+    QueryResult *result = WorldDatabase.Query("SELECT entry, ischeat_spell FROM spell_disabled where active=1");
+
+    uint32 total_count = 0;
+    uint32 cheat_spell_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();
+        bool ischeater = fields[1].GetBool();
+        m_spell_disabled[spellid] = ischeater;
+        ++total_count;
+        if(ischeater)
+        ++cheat_spell_count;
+
+   } while ( result->NextRow() );
+
+    delete result;
+
+    sLog.outString();
+    sLog.outString( ">> Loaded %u disabled spells ( %u - is cheaters spells)", total_count, cheat_spell_count);
+}
+
void ObjectMgr::LoadFishingBaseSkillLevel()
{
    mFishingBaseForArea.clear();                            // for reload case
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index 7aa3e30..3a64f38 100644
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -694,7 +694,21 @@ class ObjectMgr

        static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);

-        int GetIndexForLocale(LocaleConstant loc);
+        void LoadSpellDisabledEntrys();
+        uint8 IsSpellDisabled(uint32 spellid)
+        {
+            uint8 result=0;
+            SpellDisabledMap::const_iterator itr = m_spell_disabled.find(spellid);
+            if(itr != m_spell_disabled.end())
+            {
+                result=1;
+                if(itr->second != 0)
+                    result=2;
+            }
+        return result;
+        }
+
+        int GetIndexForLocale(LocaleConstant loc);
        LocaleConstant GetLocaleForIndex(int i);

        uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
@@ -813,6 +827,9 @@ class ObjectMgr
        typedef std::set<std::wstring> ReservedNamesMap;
        ReservedNamesMap    m_ReservedNames;

+        typedef UNORDERED_MAP<uint32, uint32> SpellDisabledMap;
+        SpellDisabledMap  m_spell_disabled;
+
        GraveYardMap        mGraveYardMap;

        GameTeleMap         m_GameTeleMap;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 338c00e..b011eb1 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -2246,6 +2246,19 @@ void Spell::Prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
        return;
    }

+    if(uint8 result = objmgr.IsSpellDisabled(m_spellInfo->Id))
+    {
+        if(m_caster->GetTypeId() == TYPEID_PLAYER)
+        {
+            sLog.outDebug("Player %s cast a spell %u which was disabled by server administrator",   m_caster->GetName(), m_spellInfo->Id);
+            if(result == 2)
+            sLog.outChar("Player %s cast a spell %u which was disabled by server administrator and marked as CheatSpell",   m_caster->GetName(), m_spellInfo->Id);
+        }
+        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 1bfe545..8cca693 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1259,6 +1259,9 @@ void World::SetInitialWorldSettings()
    sLog.outString( "Loading Player Corpses..." );
    objmgr.LoadCorpses();

+    sLog.outString( "Loading Spell disabled..." );
+    objmgr.LoadSpellDisabledEntrys();
+
    sLog.outString( "Loading Loot Tables..." );
    sLog.outString();
    LoadLootTables();

sql part of this patch

CREATE TABLE spell_disabled (
 entry int(11) unsigned NOT NULL default '0' COMMENT 'spell entry',
 ischeat_spell tinyint(3) unsigned NOT NULL default '0' COMMENT 'mark spell as cheat',
 active tinyint(3) unsigned NOT NULL default '1' COMMENT 'enable check of this spell',
 PRIMARY KEY  (entry)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Dissabled Spell System';

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...
  • 8 months later...
  • 6 months later...

https://gist.github.com/1003390

Readme:

Apply sql/custom/mangos_spell_disabled.sql into your mangos world db

Insert SpellId (entry) and whether you would like to check the spell or not (active_check [bool 1/0])

If 1 then spell is disabled, 0 will reenable spell again

Changes:

complete rewrite, not compatible to old style, export old table remove 'cheat' row and reinsert structure

Authors:

Insider42

Darkknight900

Compiled under win32 VS2008 with VC90.

Not Tested ingame ;)

If you want a clean mangos with this patch here up to date go here. For a clean patch you can diff it against my master branch it has the same rev. as my patched branch or take the gist.

Up to date for current rev. 117xx

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use