Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower

Port From (https://github.com/TrinityCore/TrinityCore/commit/c7306439e7004288fb85890d6a5f730cf1761d71)
This commit is contained in:
hondacrx
2020-06-18 12:39:39 -04:00
parent f0942a257e
commit d7954f4fc7
89 changed files with 1738 additions and 1893 deletions
+1 -1
View File
@@ -228,7 +228,7 @@ namespace Game.Chat
static bool CheckSpellExistsAndIsValid(CommandHandler handler, uint spellId)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
if (spellInfo == null)
{
handler.SendSysMessage(CypherStrings.CommandNospellfound);
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Game.Chat.Commands
{
case DisableType.Spell:
{
if (!Global.SpellMgr.HasSpellInfo(entry))
if (!Global.SpellMgr.HasSpellInfo(entry, Difficulty.None))
{
handler.SendSysMessage(CypherStrings.CommandNospellfound);
return false;
+8 -10
View File
@@ -41,13 +41,13 @@ namespace Game.Chat.Commands
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint spell = handler.ExtractSpellIdFromLink(args);
if (spell == 0 || !Global.SpellMgr.HasSpellInfo(spell))
if (spell == 0 || !Global.SpellMgr.HasSpellInfo(spell, Difficulty.None))
return false;
string all = args.NextString();
bool allRanks = !string.IsNullOrEmpty(all) && all == "all";
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell, Difficulty.None);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer()))
{
handler.SendSysMessage(CypherStrings.CommandSpellBroken, spell);
@@ -78,15 +78,13 @@ namespace Game.Chat.Commands
[Command("gm", RBACPermissions.CommandLearnAllGm)]
static bool HandleLearnAllGMCommand(StringArguments args, CommandHandler handler)
{
foreach (var spellInfo in Global.SpellMgr.GetSpellInfoStorage().Values)
foreach (var skillSpell in Global.SpellMgr.GetSkillLineAbilityMapBounds((uint)SkillType.Internal))
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(skillSpell.Spell, Difficulty.None);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer(), false))
continue;
if (!spellInfo.IsAbilityOfSkillType(SkillType.Internal))
continue;
handler.GetSession().GetPlayer().LearnSpell(spellInfo.Id, false);
handler.GetSession().GetPlayer().LearnSpell(skillSpell.Spell, false);
}
handler.SendSysMessage(CypherStrings.LearningGmSkills);
@@ -228,7 +226,7 @@ namespace Game.Chat.Commands
if (skillLine.ClassMask != 0 && (skillLine.ClassMask & classmask) == 0)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(skillLine.Spell);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(skillLine.Spell, Difficulty.None);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, player, false))
continue;
@@ -257,7 +255,7 @@ namespace Game.Chat.Commands
foreach (var entry in CliDB.SkillLineAbilityStorage.Values)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(entry.Spell);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(entry.Spell, Difficulty.None);
if (spellInfo == null)
continue;
@@ -295,7 +293,7 @@ namespace Game.Chat.Commands
if (playerClass != talentInfo.ClassID)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID, Difficulty.None);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer(), false))
continue;
+66 -63
View File
@@ -1065,84 +1065,87 @@ namespace Game.Chat
bool found = false;
uint count = 0;
// Search in Spell.dbc
foreach (var spellInfo in Global.SpellMgr.GetSpellInfoStorage().Values)
// Search in SpellName.dbc
foreach (SpellNameRecord spellName in CliDB.SpellNameStorage.Values)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
string name = spellInfo.SpellName[locale];
if (name.IsEmpty())
continue;
if (!name.Like(namePart))
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellName.Id, Difficulty.None);
if (spellInfo != null)
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
LocaleConstant locale = handler.GetSessionDbcLocale();
string name = spellInfo.SpellName[locale];
if (name.IsEmpty())
continue;
if (!name.Like(namePart))
{
if (locale == handler.GetSessionDbcLocale())
continue;
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
name = spellInfo.SpellName[locale];
if (name.IsEmpty())
continue;
name = spellInfo.SpellName[locale];
if (name.IsEmpty())
continue;
if (name.Like(namePart))
break;
}
}
if (locale < LocaleConstant.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup);
return true;
if (name.Like(namePart))
break;
}
}
bool known = target && target.HasSpell(spellInfo.Id);
SpellEffectInfo effect = spellInfo.GetEffect(0);
bool learn = (effect.Effect == SpellEffectName.LearnSpell);
if (locale < LocaleConstant.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup);
return true;
}
SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell);
bool known = target && target.HasSpell(spellInfo.Id);
SpellEffectInfo effect = spellInfo.GetEffect(0);
bool learn = (effect.Effect == SpellEffectName.LearnSpell);
bool talent = spellInfo.HasAttribute(SpellCustomAttributes.IsTalent);
bool passive = spellInfo.IsPassive();
bool active = target && target.HasAura(spellInfo.Id);
SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell, spellInfo.Difficulty);
// unit32 used to prevent interpreting public byte as char at output
// find rank of learned spell for learning spell, or talent rank
uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank();
bool talent = spellInfo.HasAttribute(SpellCustomAttributes.IsTalent);
bool passive = spellInfo.IsPassive();
bool active = target && target.HasAura(spellInfo.Id);
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
StringBuilder ss = new StringBuilder();
if (handler.GetSession() != null)
ss.Append(spellInfo.Id + " - |cffffffff|Hspell:" + spellInfo.Id + "|h[" + name);
else
ss.Append(spellInfo.Id + " - " + name);
// unit32 used to prevent interpreting public byte as char at output
// find rank of learned spell for learning spell, or talent rank
uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank();
// include rank in link name
if (rank != 0)
ss.Append(handler.GetCypherString(CypherStrings.SpellRank) + rank);
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
StringBuilder ss = new StringBuilder();
if (handler.GetSession() != null)
ss.Append(spellInfo.Id + " - |cffffffff|Hspell:" + spellInfo.Id + "|h[" + name);
else
ss.Append(spellInfo.Id + " - " + name);
if (handler.GetSession() != null)
ss.Append("]|h|r");
// include rank in link name
if (rank != 0)
ss.Append(handler.GetCypherString(CypherStrings.SpellRank) + rank);
if (talent)
ss.Append(handler.GetCypherString(CypherStrings.Talent));
if (passive)
ss.Append(handler.GetCypherString(CypherStrings.Passive));
if (learn)
ss.Append(handler.GetCypherString(CypherStrings.Learn));
if (known)
ss.Append(handler.GetCypherString(CypherStrings.Known));
if (active)
ss.Append(handler.GetCypherString(CypherStrings.Active));
if (handler.GetSession() != null)
ss.Append("]|h|r");
handler.SendSysMessage(ss.ToString());
if (talent)
ss.Append(handler.GetCypherString(CypherStrings.Talent));
if (passive)
ss.Append(handler.GetCypherString(CypherStrings.Passive));
if (learn)
ss.Append(handler.GetCypherString(CypherStrings.Learn));
if (known)
ss.Append(handler.GetCypherString(CypherStrings.Known));
if (active)
ss.Append(handler.GetCypherString(CypherStrings.Active));
if (!found)
found = true;
handler.SendSysMessage(ss.ToString());
if (!found)
found = true;
}
}
}
if (!found)
handler.SendSysMessage(CypherStrings.CommandNospellfound);
@@ -1161,7 +1164,7 @@ namespace Game.Chat
uint id = args.NextUInt32();
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(id);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(id, Difficulty.None);
if (spellInfo != null)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
@@ -1176,7 +1179,7 @@ namespace Game.Chat
SpellEffectInfo effect = spellInfo.GetEffect(0);
bool learn = (effect.Effect == SpellEffectName.LearnSpell);
SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell);
SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell, Difficulty.None);
bool talent = spellInfo.HasAttribute(SpellCustomAttributes.IsTalent);
bool passive = spellInfo.IsPassive();
+3 -3
View File
@@ -1009,7 +1009,7 @@ namespace Game.Chat
if (player.IsInFlight() || player.IsInCombat())
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SPELL_UNSTUCK_ID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SPELL_UNSTUCK_ID, Difficulty.None);
if (spellInfo == null)
return false;
@@ -2065,11 +2065,11 @@ namespace Game.Chat
if (spellid == 0)
return false;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid, attacker.GetMap().GetDifficultyID());
if (spellInfo == null)
return false;
SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(attacker, target, spellid, spellInfo.GetSpellXSpellVisualId(attacker), spellInfo.SchoolMask);
SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(attacker, target, spellInfo, spellInfo.GetSpellXSpellVisualId(attacker), spellInfo.SchoolMask);
damageInfo.damage = damage_;
attacker.DealDamageMods(damageInfo.target, ref damageInfo.damage, ref damageInfo.absorb);
target.DealSpellDamage(damageInfo, true);
+2 -2
View File
@@ -107,7 +107,7 @@ namespace Game.Chat
}
uint spellId = handler.ExtractSpellIdFromLink(args);
if (spellId == 0 || !Global.SpellMgr.HasSpellInfo(spellId))
if (spellId == 0 || !Global.SpellMgr.HasSpellInfo(spellId, Difficulty.None))
return false;
// Check if pet already has it
@@ -118,7 +118,7 @@ namespace Game.Chat
}
// Check if spell is valid
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo))
{
handler.SendSysMessage(CypherStrings.CommandSpellBroken, spellId);
+4 -4
View File
@@ -57,7 +57,7 @@ namespace Game.Chat
if (spellIid == 0)
return false;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellIid);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellIid, target.GetMap().GetDifficultyID());
if (spellInfo == null)
{
handler.SendSysMessage(CypherStrings.UnknownSpell, owner == handler.GetSession().GetPlayer() ? handler.GetCypherString(CypherStrings.You) : nameLink);
@@ -72,7 +72,7 @@ namespace Game.Chat
}
[CommandNonGroup("aura", RBACPermissions.CommandAura)]
static bool Auracommand(StringArguments args, CommandHandler handler)
static bool HandleAuraCommand(StringArguments args, CommandHandler handler)
{
Unit target = handler.GetSelectedUnit();
if (!target)
@@ -85,11 +85,11 @@ namespace Game.Chat
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint spellId = handler.ExtractSpellIdFromLink(args);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, target.GetMap().GetDifficultyID());
if (spellInfo != null)
{
ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, target.GetMapId(), spellId, target.GetMap().GenerateLowGuid(HighGuid.Cast));
Aura.TryRefreshStackOrCreate(spellInfo, castId, SpellConst.MaxEffectMask, target, target);
Aura.TryRefreshStackOrCreate(spellInfo, castId, SpellConst.MaxEffectMask, target, target, target.GetMap().GetDifficultyID());
}
return true;