Core/Items: Implement azerite essences
Port From (https://github.com/TrinityCore/TrinityCore/commit/ec9d624aec9e0a39b1bcee7d4077f46be358faad)
This commit is contained in:
@@ -38,10 +38,10 @@ namespace Game.Entities
|
||||
{
|
||||
public partial class Player
|
||||
{
|
||||
void _LoadInventory(SQLResult result, SQLResult artifactsResult, SQLResult azeriteResult, uint timeDiff)
|
||||
void _LoadInventory(SQLResult result, SQLResult artifactsResult, SQLResult azeriteResult, SQLResult azeriteItemMilestonePowersResult, SQLResult azeriteItemUnlockedEssencesResult, uint timeDiff)
|
||||
{
|
||||
Dictionary<ulong, ItemAdditionalLoadInfo> additionalData = new Dictionary<ulong, ItemAdditionalLoadInfo>();
|
||||
ItemAdditionalLoadInfo.Init(additionalData, artifactsResult, azeriteResult);
|
||||
ItemAdditionalLoadInfo.Init(additionalData, artifactsResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace Game.Entities
|
||||
{
|
||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
||||
if (azeriteItem != null)
|
||||
azeriteItem.LoadAzeriteItemData(addionalData.AzeriteItem);
|
||||
azeriteItem.LoadAzeriteItemData(this, addionalData.AzeriteItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1189,8 +1189,16 @@ namespace Game.Entities
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
SQLResult azeriteResult = DB.Characters.Query(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAILITEMS_AZERITE_MILESTONE_POWER);
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
SQLResult azeriteItemMilestonePowersResult = DB.Characters.Query(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAILITEMS_AZERITE_UNLOCKED_ESSENCE);
|
||||
stmt.AddValue(0, GetGUID().GetCounter());
|
||||
SQLResult azeriteItemUnlockedEssencesResult = DB.Characters.Query(stmt);
|
||||
|
||||
Dictionary<ulong, ItemAdditionalLoadInfo> additionalData = new Dictionary<ulong, ItemAdditionalLoadInfo>();
|
||||
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult);
|
||||
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1250,7 +1258,7 @@ namespace Game.Entities
|
||||
{
|
||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
||||
if (azeriteItem != null)
|
||||
azeriteItem.LoadAzeriteItemData(additionalLoadInfo.AzeriteItem);
|
||||
azeriteItem.LoadAzeriteItemData(this, additionalLoadInfo.AzeriteItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2898,7 +2906,8 @@ namespace Game.Entities
|
||||
// must be before inventory (some items required reputation check)
|
||||
reputationMgr.LoadFromDB(holder.GetResult(PlayerLoginQueryLoad.Reputation));
|
||||
|
||||
_LoadInventory(holder.GetResult(PlayerLoginQueryLoad.Inventory), holder.GetResult(PlayerLoginQueryLoad.Artifacts), holder.GetResult(PlayerLoginQueryLoad.LoadAzerite), time_diff);
|
||||
_LoadInventory(holder.GetResult(PlayerLoginQueryLoad.Inventory), holder.GetResult(PlayerLoginQueryLoad.Artifacts), holder.GetResult(PlayerLoginQueryLoad.LoadAzerite),
|
||||
holder.GetResult(PlayerLoginQueryLoad.LoadAzeriteMilestonePowers), holder.GetResult(PlayerLoginQueryLoad.LoadAzeriteUnlockedEssences), time_diff);
|
||||
|
||||
if (IsVoidStorageUnlocked())
|
||||
_LoadVoidStorage(holder.GetResult(PlayerLoginQueryLoad.VoidStorage));
|
||||
@@ -3846,6 +3855,14 @@ namespace Game.Entities
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEM_INSTANCE_AZERITE_MILESTONE_POWER_BY_OWNER);
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEM_INSTANCE_AZERITE_UNLOCKED_ESSENCE_BY_OWNER);
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEM_INSTANCE_BY_OWNER);
|
||||
stmt.AddValue(0, guid);
|
||||
trans.Append(stmt);
|
||||
|
||||
@@ -3948,6 +3948,7 @@ namespace Game.Entities
|
||||
if (updateItemAuras)
|
||||
ApplyItemDependentAuras(item, apply);
|
||||
ApplyArtifactPowers(item, apply);
|
||||
ApplyAzeritePowers(item, apply);
|
||||
ApplyEnchantment(item, apply);
|
||||
|
||||
Log.outDebug(LogFilter.Player, "_ApplyItemMods complete.");
|
||||
@@ -4366,6 +4367,7 @@ namespace Game.Entities
|
||||
|
||||
ApplyItemEquipSpell(m_items[i], false);
|
||||
ApplyEnchantment(m_items[i], false);
|
||||
ApplyAzeritePowers(m_items[i], false);
|
||||
ApplyArtifactPowers(m_items[i], false);
|
||||
}
|
||||
}
|
||||
@@ -4418,6 +4420,7 @@ namespace Game.Entities
|
||||
|
||||
ApplyItemEquipSpell(m_items[i], true);
|
||||
ApplyArtifactPowers(m_items[i], true);
|
||||
ApplyAzeritePowers(m_items[i], true);
|
||||
ApplyEnchantment(m_items[i], true);
|
||||
}
|
||||
}
|
||||
@@ -5462,6 +5465,96 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyAzeritePowers(Item item, bool apply)
|
||||
{
|
||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
||||
if (azeriteItem != null)
|
||||
{
|
||||
// milestone powers
|
||||
foreach (uint azeriteItemMilestonePowerId in azeriteItem.m_azeriteItemData.UnlockedEssenceMilestones)
|
||||
ApplyAzeriteItemMilestonePower(item, CliDB.AzeriteItemMilestonePowerStorage.LookupByKey(azeriteItemMilestonePowerId), apply);
|
||||
|
||||
// essences
|
||||
SelectedAzeriteEssences selectedEssences = azeriteItem.GetSelectedAzeriteEssences();
|
||||
if (selectedEssences != null)
|
||||
{
|
||||
for (byte slot = 0; slot < SharedConst.MaxAzeriteEssenceSlot; ++slot)
|
||||
if (selectedEssences.AzeriteEssenceID[slot] != 0)
|
||||
ApplyAzeriteEssence(item, selectedEssences.AzeriteEssenceID[slot], azeriteItem.GetEssenceRank(selectedEssences.AzeriteEssenceID[slot]),
|
||||
(AzeriteItemMilestoneType)Global.DB2Mgr.GetAzeriteItemMilestonePower(slot).Type == AzeriteItemMilestoneType.MajorEssence, apply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyAzeriteItemMilestonePower(Item item, AzeriteItemMilestonePowerRecord azeriteItemMilestonePower, bool apply)
|
||||
{
|
||||
AzeriteItemMilestoneType type = (AzeriteItemMilestoneType)azeriteItemMilestonePower.Type;
|
||||
if (type == AzeriteItemMilestoneType.BonusStamina)
|
||||
{
|
||||
AzeritePowerRecord azeritePower = CliDB.AzeritePowerStorage.LookupByKey(azeriteItemMilestonePower.AzeritePowerID);
|
||||
if (azeritePower != null)
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, azeritePower.SpellID, true, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyAzeriteEssence(Item item, uint azeriteEssenceId, uint rank, bool major, bool apply)
|
||||
{
|
||||
for (uint currentRank = 1; currentRank <= rank; ++currentRank)
|
||||
{
|
||||
AzeriteEssencePowerRecord azeriteEssencePower = Global.DB2Mgr.GetAzeriteEssencePower(azeriteEssenceId, currentRank);
|
||||
if (azeriteEssencePower != null)
|
||||
{
|
||||
ApplyAzeriteEssencePower(item, azeriteEssencePower, major, apply);
|
||||
if (major && currentRank == 1)
|
||||
{
|
||||
if (apply)
|
||||
CastCustomSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride, SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription, this, TriggerCastFlags.FullMask);
|
||||
else
|
||||
RemoveAurasDueToSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyAzeriteEssencePower(Item item, AzeriteEssencePowerRecord azeriteEssencePower, bool major, bool apply)
|
||||
{
|
||||
SpellInfo powerSpell = Global.SpellMgr.GetSpellInfo(azeriteEssencePower.MinorPowerDescription);
|
||||
if (powerSpell != null)
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, powerSpell, true, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID());
|
||||
}
|
||||
|
||||
if (major)
|
||||
{
|
||||
powerSpell = Global.SpellMgr.GetSpellInfo(azeriteEssencePower.MajorPowerDescription);
|
||||
if (powerSpell != null)
|
||||
{
|
||||
if (powerSpell.IsPassive())
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, powerSpell, true, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (apply)
|
||||
LearnSpell(powerSpell.Id, true, 0, true);
|
||||
else
|
||||
RemoveSpell(powerSpell.Id, false, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasItemOrGemWithIdEquipped(uint item, uint count, byte except_slot = ItemConst.NullSlot)
|
||||
{
|
||||
uint tempcount = 0;
|
||||
|
||||
@@ -2010,7 +2010,7 @@ namespace Game.Entities
|
||||
LearnSpellHighestRank(next);
|
||||
}
|
||||
|
||||
public void LearnSpell(uint spellId, bool dependent, uint fromSkill = 0)
|
||||
public void LearnSpell(uint spellId, bool dependent, uint fromSkill = 0, bool suppressMessaging = false)
|
||||
{
|
||||
PlayerSpell spell = m_spells.LookupByKey(spellId);
|
||||
|
||||
@@ -2024,6 +2024,7 @@ namespace Game.Entities
|
||||
{
|
||||
LearnedSpells packet = new LearnedSpells();
|
||||
packet.SpellID.Add(spellId);
|
||||
packet.SuppressMessaging = suppressMessaging;
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -2049,9 +2050,9 @@ namespace Game.Entities
|
||||
|
||||
}
|
||||
|
||||
public void RemoveSpell(uint spell_id, bool disabled = false, bool learn_low_rank = true)
|
||||
public void RemoveSpell(uint spellId, bool disabled = false, bool learnLowRank = true, bool suppressMessaging = false)
|
||||
{
|
||||
var pSpell = m_spells.LookupByKey(spell_id);
|
||||
var pSpell = m_spells.LookupByKey(spellId);
|
||||
if (pSpell == null)
|
||||
return;
|
||||
|
||||
@@ -2059,7 +2060,7 @@ namespace Game.Entities
|
||||
return;
|
||||
|
||||
// unlearn non talent higher ranks (recursive)
|
||||
uint nextSpell = Global.SpellMgr.GetNextSpellInChain(spell_id);
|
||||
uint nextSpell = Global.SpellMgr.GetNextSpellInChain(spellId);
|
||||
if (nextSpell != 0)
|
||||
{
|
||||
SpellInfo spellInfo1 = Global.SpellMgr.GetSpellInfo(nextSpell);
|
||||
@@ -2067,12 +2068,12 @@ namespace Game.Entities
|
||||
RemoveSpell(nextSpell, disabled, false);
|
||||
}
|
||||
//unlearn spells dependent from recently removed spells
|
||||
var spellsRequiringSpell = Global.SpellMgr.GetSpellsRequiringSpellBounds(spell_id);
|
||||
var spellsRequiringSpell = Global.SpellMgr.GetSpellsRequiringSpellBounds(spellId);
|
||||
foreach (var id in spellsRequiringSpell)
|
||||
RemoveSpell(id, disabled);
|
||||
|
||||
// re-search, it can be corrupted in prev loop
|
||||
pSpell = m_spells.LookupByKey(spell_id);
|
||||
pSpell = m_spells.LookupByKey(spellId);
|
||||
if (pSpell == null)
|
||||
return; // already unleared
|
||||
|
||||
@@ -2088,23 +2089,23 @@ namespace Game.Entities
|
||||
else
|
||||
{
|
||||
if (pSpell.State == PlayerSpellState.New)
|
||||
m_spells.Remove(spell_id);
|
||||
m_spells.Remove(spellId);
|
||||
else
|
||||
pSpell.State = PlayerSpellState.Removed;
|
||||
}
|
||||
|
||||
RemoveOwnedAura(spell_id, GetGUID());
|
||||
RemoveOwnedAura(spellId, GetGUID());
|
||||
|
||||
// remove pet auras
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
{
|
||||
PetAura petSpell = Global.SpellMgr.GetPetAura(spell_id, i);
|
||||
PetAura petSpell = Global.SpellMgr.GetPetAura(spellId, i);
|
||||
if (petSpell != null)
|
||||
RemovePetAura(petSpell);
|
||||
}
|
||||
|
||||
// update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning)
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell_id);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
|
||||
if (spellInfo != null && spellInfo.IsPrimaryProfessionFirstRank())
|
||||
{
|
||||
uint freeProfs = GetFreePrimaryProfessionPoints() + 1;
|
||||
@@ -2113,10 +2114,10 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// remove dependent skill
|
||||
var spellLearnSkill = Global.SpellMgr.GetSpellLearnSkill(spell_id);
|
||||
var spellLearnSkill = Global.SpellMgr.GetSpellLearnSkill(spellId);
|
||||
if (spellLearnSkill != null)
|
||||
{
|
||||
uint prev_spell = Global.SpellMgr.GetPrevSpellInChain(spell_id);
|
||||
uint prev_spell = Global.SpellMgr.GetPrevSpellInChain(spellId);
|
||||
if (prev_spell == 0) // first rank, remove skill
|
||||
SetSkill(spellLearnSkill.skill, 0, 0, 0);
|
||||
else
|
||||
@@ -2150,7 +2151,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// remove dependent spells
|
||||
var spell_bounds = Global.SpellMgr.GetSpellLearnSpellMapBounds(spell_id);
|
||||
var spell_bounds = Global.SpellMgr.GetSpellLearnSpellMapBounds(spellId);
|
||||
|
||||
foreach (var spellNode in spell_bounds)
|
||||
{
|
||||
@@ -2162,7 +2163,7 @@ namespace Game.Entities
|
||||
// activate lesser rank in spellbook/action bar, and cast it if need
|
||||
bool prev_activate = false;
|
||||
|
||||
uint prev_id = Global.SpellMgr.GetPrevSpellInChain(spell_id);
|
||||
uint prev_id = Global.SpellMgr.GetPrevSpellInChain(spellId);
|
||||
if (prev_id != 0)
|
||||
{
|
||||
// if ranked non-stackable spell: need activate lesser rank and update dendence state
|
||||
@@ -2181,12 +2182,12 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// now re-learn if need re-activate
|
||||
if (cur_active && !prevSpell.Active && learn_low_rank)
|
||||
if (cur_active && !prevSpell.Active && learnLowRank)
|
||||
{
|
||||
if (AddSpell(prev_id, true, false, prevSpell.Dependent, prevSpell.Disabled))
|
||||
{
|
||||
// downgrade spell ranks in spellbook and action bar
|
||||
SendSupercededSpell(spell_id, prev_id);
|
||||
SendSupercededSpell(spellId, prev_id);
|
||||
prev_activate = true;
|
||||
}
|
||||
}
|
||||
@@ -2194,7 +2195,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
m_overrideSpells.Remove(spell_id);
|
||||
m_overrideSpells.Remove(spellId);
|
||||
|
||||
if (m_canTitanGrip)
|
||||
{
|
||||
@@ -2217,9 +2218,10 @@ namespace Game.Entities
|
||||
// remove from spell book if not replaced by lesser rank
|
||||
if (!prev_activate)
|
||||
{
|
||||
UnlearnedSpells removedSpells = new UnlearnedSpells();
|
||||
removedSpells.SpellID.Add(spell_id);
|
||||
SendPacket(removedSpells);
|
||||
UnlearnedSpells unlearnedSpells = new UnlearnedSpells();
|
||||
unlearnedSpells.SpellID.Add(spellId);
|
||||
unlearnedSpells.SuppressMessaging = suppressMessaging;
|
||||
SendPacket(unlearnedSpells);
|
||||
}
|
||||
}
|
||||
bool IsNeedCastPassiveSpellAtLearn(SpellInfo spellInfo)
|
||||
|
||||
@@ -422,6 +422,24 @@ namespace Game.Entities
|
||||
activeGlyphs.IsFullUpdate = true;
|
||||
SendPacket(activeGlyphs);
|
||||
|
||||
Item item = GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
||||
if (item != null)
|
||||
{
|
||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
||||
if (azeriteItem != null)
|
||||
{
|
||||
if (azeriteItem.IsEquipped())
|
||||
ApplyAzeritePowers(azeriteItem, false);
|
||||
|
||||
azeriteItem.SetSelectedAzeriteEssences(spec.Id);
|
||||
|
||||
if (azeriteItem.IsEquipped())
|
||||
ApplyAzeritePowers(azeriteItem, true);
|
||||
|
||||
azeriteItem.SetState(ItemUpdateState.Changed, this);
|
||||
}
|
||||
}
|
||||
|
||||
var shapeshiftAuras = GetAuraEffectsByType(AuraType.ModShapeshift);
|
||||
foreach (AuraEffect aurEff in shapeshiftAuras)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user