diff options
| author | Shauren <shauren.trinity@gmail.com> | 2020-06-12 01:29:18 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2020-06-12 01:29:18 +0200 |
| commit | c7306439e7004288fb85890d6a5f730cf1761d71 (patch) | |
| tree | a1b6fd4af385923f321ff24ef4d66d09374397b9 /src/server/scripts/Commands | |
| parent | 1cdd1d0249ad49c860e117e1e39d451e1a3fbe43 (diff) | |
Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_cast.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_disable.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_learn.cpp | 19 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_lookup.cpp | 21 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 12 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_pet.cpp | 4 |
6 files changed, 28 insertions, 32 deletions
diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp index b35374a0dac..9b783e28634 100644 --- a/src/server/scripts/Commands/cs_cast.cpp +++ b/src/server/scripts/Commands/cs_cast.cpp @@ -56,7 +56,7 @@ public: static bool CheckSpellExistsAndIsValid(ChatHandler* handler, uint32 spellId) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE); if (!spellInfo) { handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 212f1ba20c8..837d64af9c4 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -98,7 +98,7 @@ public: { case DISABLE_TYPE_SPELL: { - if (!sSpellMgr->GetSpellInfo(entry)) + if (!sSpellMgr->GetSpellInfo(entry, DIFFICULTY_NONE)) { handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); handler->SetSentErrorMessage(true); diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index f0c6981f0f0..1de918cbc81 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -86,13 +86,13 @@ public: // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = handler->extractSpellIdFromLink((char*)args); - if (!spell || !sSpellMgr->GetSpellInfo(spell)) + if (!spell || !sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE)) return false; char const* all = strtok(NULL, " "); bool allRanks = all ? (strncmp(all, "all", strlen(all)) == 0) : false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) { handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); @@ -120,16 +120,13 @@ public: static bool HandleLearnAllGMCommand(ChatHandler* handler, char const* /*args*/) { - for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) + for (std::pair<uint32 const, SkillLineAbilityEntry const*> skillSpell : Trinity::Containers::MakeIteratorPair(sSpellMgr->GetSkillLineAbilityMapBounds(SKILL_INTERNAL))) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillSpell.second->Spell, DIFFICULTY_NONE); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer(), false)) continue; - if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL)) - continue; - - handler->GetSession()->GetPlayer()->LearnSpell(i, false); + handler->GetSession()->GetPlayer()->LearnSpell(skillSpell.second->Spell, false); } handler->SendSysMessage(LANG_LEARNING_GM_SKILLS); @@ -156,7 +153,7 @@ public: if (!entry) continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->Spell); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->Spell, DIFFICULTY_NONE); if (!spellInfo) continue; @@ -197,7 +194,7 @@ public: if (playerClass != talentInfo->ClassID) continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(talentInfo->SpellID); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(talentInfo->SpellID, DIFFICULTY_NONE); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer(), false)) continue; @@ -439,7 +436,7 @@ public: if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0) continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell, DIFFICULTY_NONE); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false)) continue; diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index e64c7161469..7db339d63c6 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -839,11 +839,10 @@ public: uint32 count = 0; uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); - // Search in Spell.dbc - for (uint32 id = 0; id < sSpellMgr->GetSpellInfoStoreSize(); id++) + // Search in SpellName.dbc + for (SpellNameEntry const* spellName : sSpellNameStore) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id); - if (spellInfo) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellName->ID, DIFFICULTY_NONE)) { int locale = handler->GetSessionDbcLocale(); std::string name = spellInfo->SpellName->Str[locale]; @@ -875,16 +874,16 @@ public: return true; } - bool known = target && target->HasSpell(id); + bool known = target && target->HasSpell(spellInfo->Id); SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0); bool learn = effect ? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false; - SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell) : NULL; + SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, spellInfo->Difficulty) : NULL; bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT); bool passive = spellInfo->IsPassive(); - bool active = target && target->HasAura(id); + bool active = target && target->HasAura(spellInfo->Id); // unit32 used to prevent interpreting uint8 as char at output // find rank of learned spell for learning spell, or talent rank @@ -893,9 +892,9 @@ public: // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format std::ostringstream ss; if (handler->GetSession()) - ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; + ss << spellInfo->Id << " - |cffffffff|Hspell:" << spellInfo->Id << "|h[" << name; else - ss << id << " - " << name; + ss << spellInfo->Id << " - " << name; // include rank in link name if (rank) @@ -938,7 +937,7 @@ public: uint32 id = atoi((char*)args); - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id)) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id, DIFFICULTY_NONE)) { int locale = handler->GetSessionDbcLocale(); std::string name = spellInfo->SpellName->Str[locale]; @@ -953,7 +952,7 @@ public: SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0); bool learn = effect? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false; - SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell) : NULL; + SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE) : NULL; bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT); bool passive = spellInfo->IsPassive(); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 23804a75a21..d35904921eb 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -322,10 +322,10 @@ public: // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, target->GetMap()->GetDifficultyID())) { ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, target->GetMapId(), spellId, target->GetMap()->GenerateLowGuid<HighGuid::Cast>()); - Aura::TryRefreshStackOrCreate(spellInfo, castId, MAX_EFFECT_MASK, target, target); + Aura::TryRefreshStackOrCreate(spellInfo, castId, MAX_EFFECT_MASK, target, target, target->GetMap()->GetDifficultyID()); } return true; @@ -795,7 +795,7 @@ public: if (!spellIid) return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellIid); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellIid, target->GetMap()->GetDifficultyID()); if (!spellInfo) { handler->PSendSysMessage(LANG_UNKNOWN_SPELL, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str()); @@ -1017,7 +1017,7 @@ public: if (player->IsInFlight() || player->IsInCombat()) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_UNSTUCK_ID); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_UNSTUCK_ID, DIFFICULTY_NONE); if (!spellInfo) return false; @@ -2426,11 +2426,11 @@ public: if (!spellid) return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid, attacker->GetMap()->GetDifficultyID()); if (!spellInfo) return false; - SpellNonMeleeDamage damageInfo(attacker, target, spellid, spellInfo->GetSpellXSpellVisualId(handler->GetSession()->GetPlayer()), spellInfo->SchoolMask); + SpellNonMeleeDamage damageInfo(attacker, target, spellInfo, spellInfo->GetSpellXSpellVisualId(handler->GetSession()->GetPlayer()), spellInfo->SchoolMask); damageInfo.damage = damage; attacker->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); target->DealSpellDamage(&damageInfo, true); diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp index 1e0cd4ab835..124d67fb722 100644 --- a/src/server/scripts/Commands/cs_pet.cpp +++ b/src/server/scripts/Commands/cs_pet.cpp @@ -148,7 +148,7 @@ public: uint32 spellId = handler->extractSpellIdFromLink((char*)args); - if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) + if (!spellId || !sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE)) return false; // Check if pet already has it @@ -160,7 +160,7 @@ public: } // Check if spell is valid - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo)) { handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); |
