Changeset 85

Show
Ignore:
Timestamp:
11/19/08 13:32:53 (17 years ago)
Author:
yumileroy
Message:

[svn] Implement a new table (spell_disabled) to allow disabling some spells for players and / or creatures. To disable a spell for a players and pets, set 20 in the disable_mask, to disable for creatures, set 21. The comment field is optional. Original patch provided by Craker.

Original author: w12x
Date: 2008-10-21 03:58:38-05:00

Location:
trunk
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/sql/world.sql

    r45 r85  
    29482948 
    29492949-- 
     2950-- Table structure for table `spell_disabled` 
     2951-- 
     2952 
     2953DROP TABLE IF EXISTS `spell_disabled`; 
     2954CREATE TABLE `spell_disabled` ( 
     2955  `entry` int(11) unsigned NOT NULL default '0' COMMENT 'Spell entry', 
     2956  `disable_mask` int(8) unsigned NOT NULL default '0', 
     2957  `comment` varchar(64) NOT NULL default '', 
     2958  PRIMARY KEY  (`entry`) 
     2959) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Disabled Spell System'; 
     2960 
     2961-- 
     2962-- Dumping data for table `spell_disabled` 
     2963-- 
     2964 
     2965LOCK TABLES `spell_disabled` WRITE; 
     2966/*!40000 ALTER TABLE `spell_disabled` DISABLE KEYS */; 
     2967/*!40000 ALTER TABLE `spell_disabled` ENABLE KEYS */; 
     2968UNLOCK TABLES; 
     2969 
     2970-- 
    29502971-- Table structure for table `spell_elixir` 
    29512972-- 
  • trunk/src/game/Chat.cpp

    r83 r85  
    198198        { "spell_target_position",       SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTargetPositionCommand,     "", NULL }, 
    199199        { "spell_threats",               SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellThreatsCommand,            "", NULL }, 
     200        { "spell_disabled",              SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellDisabledCommand,           "", NULL }, 
    200201        { "locales_creature",            SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesCreatureCommand,         "", NULL }, 
    201202        { "locales_gameobject",          SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesGameobjectCommand,       "", NULL }, 
  • trunk/src/game/Chat.h

    r79 r85  
    194194        bool HandleReloadSpellThreatsCommand(const char* args); 
    195195        bool HandleReloadSpellPetAurasCommand(const char* args); 
     196        bool HandleReloadSpellDisabledCommand(const char* args); 
    196197        bool HandleReloadPageTextsCommand(const char* args); 
    197198        bool HandleReloadItemEnchantementsCommand(const char* args); 
  • trunk/src/game/Level3.cpp

    r79 r85  
    151151    HandleReloadSpellThreatsCommand("a"); 
    152152    HandleReloadSpellPetAurasCommand("a"); 
     153    HandleReloadSpellDisabledCommand("a"); 
    153154    return true; 
    154155} 
     
    610611 
    611612    SendGlobalSysMessage("DB table `game_tele` reloaded."); 
     613 
     614    return true; 
     615} 
     616 
     617bool ChatHandler::HandleReloadSpellDisabledCommand(const char* /*arg*/) 
     618{ 
     619    sLog.outString( "Re-Loading spell disabled table..."); 
     620 
     621    objmgr.LoadSpellDisabledEntrys(); 
     622 
     623    SendGlobalSysMessage("DB table `spell_disabled` reloaded."); 
    612624 
    613625    return true; 
     
    55775589    { 
    55785590        player = getSelectedPlayer(); 
    5579                 if (player) //prevent crash with creature as target 
     5591        if (player) //prevent crash with creature as target 
    55805592        {    
    55815593           name = player->GetName(); 
     
    56105622        player->setFaction(35); 
    56115623        player->CombatStop(); 
    5612                 if(player->IsNonMeleeSpellCasted(true)) 
     5624        if(player->IsNonMeleeSpellCasted(true)) 
    56135625        player->InterruptNonMeleeSpells(true); 
    56145626        player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
    56155627        player->SetUInt32Value(PLAYER_DUEL_TEAM, 1); 
    56165628 
    5617                 //if player class = hunter || warlock remove pet if alive 
     5629        //if player class = hunter || warlock remove pet if alive 
    56185630        if((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK)) 
    56195631        { 
     
    56625674    { 
    56635675        player = getSelectedPlayer(); 
    5664                 if (player) //prevent crash with creature as target 
     5676        if (player) //prevent crash with creature as target 
    56655677        {    
    56665678           name = player->GetName(); 
     
    56975709        {         
    56985710            //check for offline players 
    5699                     QueryResult *result = CharacterDatabase.PQuery("SELECT characters.guid FROM `characters` WHERE characters.name = '%s'",name.c_str()); 
     5711            QueryResult *result = CharacterDatabase.PQuery("SELECT characters.guid FROM `characters` WHERE characters.name = '%s'",name.c_str()); 
    57005712            if(!result) 
    5701                     { 
    5702                             SendSysMessage(LANG_COMMAND_FREEZE_WRONG); 
     5713            { 
     5714                SendSysMessage(LANG_COMMAND_FREEZE_WRONG); 
    57035715                return true; 
    5704                     } 
    5705                     //if player found: delete his freeze aura 
    5706                     Field *fields=result->Fetch(); 
     5716            } 
     5717            //if player found: delete his freeze aura 
     5718            Field *fields=result->Fetch(); 
    57075719            uint64 pguid = fields[0].GetUInt64(); 
    5708                     delete result; 
     5720            delete result; 
    57095721            CharacterDatabase.PQuery("DELETE FROM `character_aura` WHERE character_aura.spell = 9454 AND character_aura.guid = '%u'",pguid); 
    57105722            PSendSysMessage(LANG_COMMAND_UNFREEZE,name.c_str()); 
    57115723            return true; 
    5712                 } 
    5713                 else 
    5714         { 
    5715                 SendSysMessage(LANG_COMMAND_FREEZE_WRONG); 
     5724        } 
     5725        else 
     5726        { 
     5727            SendSysMessage(LANG_COMMAND_FREEZE_WRONG); 
    57165728            return true; 
    5717                 } 
     5729        } 
    57185730    } 
    57195731 
  • trunk/src/game/ObjectMgr.cpp

    r83 r85  
    62926292} 
    62936293 
     6294void ObjectMgr::LoadSpellDisabledEntrys() 
     6295{ 
     6296    m_DisabledPlayerSpells.clear();                                // need for reload case 
     6297    m_DisabledCreatureSpells.clear(); 
     6298    QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled"); 
     6299 
     6300    uint32 total_count = 0; 
     6301 
     6302    if( !result ) 
     6303    { 
     6304        barGoLink bar( 1 ); 
     6305        bar.step(); 
     6306 
     6307        sLog.outString(); 
     6308        sLog.outString( ">> Loaded %u disabled spells", total_count ); 
     6309        return; 
     6310    } 
     6311 
     6312    barGoLink bar( result->GetRowCount() ); 
     6313 
     6314    Field* fields; 
     6315    do 
     6316    { 
     6317        bar.step(); 
     6318        fields = result->Fetch(); 
     6319        uint32 spellid = fields[0].GetUInt32(); 
     6320        if(!sSpellStore.LookupEntry(spellid)) 
     6321        { 
     6322            sLog.outErrorDb("Spell entry %u from `spell_disabled` doesn't exist in dbc, ignoring.",spellid); 
     6323            continue; 
     6324        } 
     6325        uint32 disable_mask = fields[1].GetUInt32(); 
     6326        if(disable_mask & SPELL_DISABLE_PLAYER) 
     6327            m_DisabledPlayerSpells.insert(spellid); 
     6328        if(disable_mask & SPELL_DISABLE_CREATURE) 
     6329            m_DisabledCreatureSpells.insert(spellid); 
     6330        ++total_count; 
     6331   } while ( result->NextRow() ); 
     6332 
     6333    delete result; 
     6334 
     6335    sLog.outString(); 
     6336    sLog.outString( ">> Loaded %u disabled spells from `spell_disabled`", total_count); 
     6337} 
     6338 
    62946339void ObjectMgr::LoadFishingBaseSkillLevel() 
    62956340{ 
  • trunk/src/game/ObjectMgr.h

    r79 r85  
    690690        static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); 
    691691 
     692        void LoadSpellDisabledEntrys(); 
     693        bool IsPlayerSpellDisabled(uint32 spellid) { return (m_DisabledPlayerSpells.count(spellid) != 0); } 
     694        bool IsCreatureSpellDisabled(uint32 spellid) { return (m_DisabledCreatureSpells.count(spellid) != 0); } 
     695 
    692696        int GetIndexForLocale(LocaleConstant loc); 
    693697        LocaleConstant GetLocaleForIndex(int i); 
     
    798802        typedef std::set<std::string> ReservedNamesMap; 
    799803        ReservedNamesMap    m_ReservedNames; 
     804 
     805        std::set<uint32>    m_DisabledPlayerSpells; 
     806        std::set<uint32>    m_DisabledCreatureSpells; 
    800807 
    801808        GraveYardMap        mGraveYardMap; 
  • trunk/src/game/Spell.cpp

    r69 r85  
    20332033    } 
    20342034 
     2035    if(m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet())) 
     2036    { 
     2037        if(objmgr.IsPlayerSpellDisabled(m_spellInfo->Id)) 
     2038        { 
     2039            SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE); 
     2040            finish(false); 
     2041            return; 
     2042        } 
     2043    } 
     2044    else 
     2045    { 
     2046        if(objmgr.IsCreatureSpellDisabled(m_spellInfo->Id)) 
     2047        { 
     2048            finish(false); 
     2049            return; 
     2050        } 
     2051    } 
     2052 
    20352053    // Fill cost data 
    20362054    m_powerCost = CalculatePowerCost(); 
  • trunk/src/game/SpellMgr.h

    r44 r85  
    228228}; 
    229229 
     230enum SpellDisableTypes 
     231{ 
     232    SPELL_DISABLE_PLAYER = 1, 
     233    SPELL_DISABLE_CREATURE = 2 
     234}; 
     235 
    230236//Some SpellFamilyFlags 
    231237#define SPELLFAMILYFLAG_ROGUE_VANISH            0x000000800LL 
  • trunk/src/game/World.cpp

    r83 r85  
    11101110    objmgr.LoadCorpses(); 
    11111111 
     1112    sLog.outString( "Loading Disabled Spells..." ); 
     1113    objmgr.LoadSpellDisabledEntrys(); 
     1114 
    11121115    sLog.outString( "Loading Loot Tables..." ); 
    11131116    LoadLootTables();