Core/Items: Addes support for calculating item level & cleanup iterating over items.
Based on https://github.com/TrinityCore/TrinityCore/pull/26276
This commit is contained in:
@@ -759,13 +759,13 @@ namespace Framework.Constants
|
|||||||
|
|
||||||
public enum ItemSearchLocation
|
public enum ItemSearchLocation
|
||||||
{
|
{
|
||||||
InEquipment = 0x01,
|
Equipment = 0x01,
|
||||||
InInventory = 0x02,
|
Inventory = 0x02,
|
||||||
InBank = 0x04,
|
Bank = 0x04,
|
||||||
InReagentBank = 0x08,
|
ReagentBank = 0x08,
|
||||||
|
|
||||||
Default = InEquipment | InInventory,
|
Default = Equipment | Inventory,
|
||||||
Everywhere = InEquipment | InInventory | InBank | InReagentBank
|
Everywhere = Equipment | Inventory | Bank | ReagentBank
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ZonePVPTypeOverride
|
public enum ZonePVPTypeOverride
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -302,7 +302,7 @@ namespace Game.Entities
|
|||||||
if (msg == InventoryResult.Ok)
|
if (msg == InventoryResult.Ok)
|
||||||
{
|
{
|
||||||
RemoveItem(InventorySlots.Bag0, i, true);
|
RemoveItem(InventorySlots.Bag0, i, true);
|
||||||
pItem = StoreItem(sDest, pItem, true);
|
StoreItem(sDest, pItem, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1854,7 +1854,7 @@ namespace Game.Entities
|
|||||||
public uint GetStartLevel(Race race, Class playerClass, Optional<uint> characterTemplateId = default)
|
public uint GetStartLevel(Race race, Class playerClass, Optional<uint> characterTemplateId = default)
|
||||||
{
|
{
|
||||||
uint startLevel = WorldConfig.GetUIntValue(WorldCfg.StartPlayerLevel);
|
uint startLevel = WorldConfig.GetUIntValue(WorldCfg.StartPlayerLevel);
|
||||||
if (CliDB.ChrRacesStorage.LookupByKey(race).GetFlags().HasFlag(ChrRacesFlag.AlliedRace))
|
if (CliDB.ChrRacesStorage.LookupByKey(race).GetFlags().HasAnyFlag(ChrRacesFlag.AlliedRace))
|
||||||
startLevel = WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel);
|
startLevel = WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel);
|
||||||
|
|
||||||
if (playerClass == Class.Deathknight)
|
if (playerClass == Class.Deathknight)
|
||||||
@@ -2345,8 +2345,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (canTalk)
|
if (canTalk)
|
||||||
{
|
{
|
||||||
string strOptionText = "";
|
string strOptionText;
|
||||||
string strBoxText = "";
|
string strBoxText;
|
||||||
BroadcastTextRecord optionBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(menuItems.OptionBroadcastTextId);
|
BroadcastTextRecord optionBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(menuItems.OptionBroadcastTextId);
|
||||||
BroadcastTextRecord boxBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(menuItems.BoxBroadcastTextId);
|
BroadcastTextRecord boxBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(menuItems.BoxBroadcastTextId);
|
||||||
Locale locale = GetSession().GetSessionDbLocaleIndex();
|
Locale locale = GetSession().GetSessionDbLocaleIndex();
|
||||||
@@ -4024,7 +4024,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsNeverVisibleFor(WorldObject seer)
|
public override bool IsNeverVisibleFor(WorldObject seer)
|
||||||
{
|
{
|
||||||
if (base.IsNeverVisibleFor(seer))
|
if (base.IsNeverVisibleFor(seer))
|
||||||
@@ -4807,7 +4807,7 @@ namespace Game.Entities
|
|||||||
if (pet != null)
|
if (pet != null)
|
||||||
pet.RemoveAurasDueToSpell(petSpell.GetAura(pet.GetEntry()));
|
pet.RemoveAurasDueToSpell(petSpell.GetAura(pet.GetEntry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InArena()
|
public bool InArena()
|
||||||
{
|
{
|
||||||
Battleground bg = GetBattleground();
|
Battleground bg = GetBattleground();
|
||||||
@@ -4955,7 +4955,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
reward.ItemChoices.Add(rewardEntry);
|
reward.ItemChoices.Add(rewardEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerChoiceResponse.Reward.Set(reward);
|
playerChoiceResponse.Reward.Set(reward);
|
||||||
displayPlayerChoice.Responses[i] = playerChoiceResponse;
|
displayPlayerChoice.Responses[i] = playerChoiceResponse;
|
||||||
}
|
}
|
||||||
@@ -6141,7 +6141,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
ushort areaLevel = (ushort)Math.Min(Math.Max((ushort)GetLevel(), areaLevels.Value.MinLevel), areaLevels.Value.MaxLevel);
|
ushort areaLevel = (ushort)Math.Min(Math.Max((ushort)GetLevel(), areaLevels.Value.MinLevel), areaLevels.Value.MaxLevel);
|
||||||
int diff = (int)(GetLevel()) - areaLevel;
|
int diff = (int)(GetLevel()) - areaLevel;
|
||||||
uint XP = 0;
|
uint XP;
|
||||||
if (diff < -5)
|
if (diff < -5)
|
||||||
{
|
{
|
||||||
XP = (uint)(Global.ObjectMgr.GetBaseXP(GetLevel() + 5) * WorldConfig.GetFloatValue(WorldCfg.RateXpExplore));
|
XP = (uint)(Global.ObjectMgr.GetBaseXP(GetLevel() + 5) * WorldConfig.GetFloatValue(WorldCfg.RateXpExplore));
|
||||||
@@ -6523,13 +6523,13 @@ namespace Game.Entities
|
|||||||
|
|
||||||
switch (modGroup)
|
switch (modGroup)
|
||||||
{
|
{
|
||||||
case BaseModGroup.CritPercentage:
|
case BaseModGroup.CritPercentage:
|
||||||
UpdateCritPercentage(WeaponAttackType.BaseAttack);
|
UpdateCritPercentage(WeaponAttackType.BaseAttack);
|
||||||
break;
|
break;
|
||||||
case BaseModGroup.RangedCritPercentage:
|
case BaseModGroup.RangedCritPercentage:
|
||||||
UpdateCritPercentage(WeaponAttackType.RangedAttack);
|
UpdateCritPercentage(WeaponAttackType.RangedAttack);
|
||||||
break;
|
break;
|
||||||
case BaseModGroup.OffhandCritPercentage:
|
case BaseModGroup.OffhandCritPercentage:
|
||||||
UpdateCritPercentage(WeaponAttackType.OffAttack);
|
UpdateCritPercentage(WeaponAttackType.OffAttack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -6558,7 +6558,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
return m_auraBaseFlatMod[(int)modGroup] * m_auraBasePctMod[(int)modGroup];
|
return m_auraBaseFlatMod[(int)modGroup] * m_auraBasePctMod[(int)modGroup];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddComboPoints(sbyte count, Spell spell = null)
|
public void AddComboPoints(sbyte count, Spell spell = null)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
@@ -7208,15 +7208,12 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
public static WeaponAttackType GetAttackBySlot(byte slot, InventoryType inventoryType)
|
public static WeaponAttackType GetAttackBySlot(byte slot, InventoryType inventoryType)
|
||||||
{
|
{
|
||||||
switch (slot)
|
return slot switch
|
||||||
{
|
{
|
||||||
case EquipmentSlot.MainHand:
|
EquipmentSlot.MainHand => inventoryType != InventoryType.Ranged && inventoryType != InventoryType.RangedRight ? WeaponAttackType.BaseAttack : WeaponAttackType.RangedAttack,
|
||||||
return inventoryType != InventoryType.Ranged && inventoryType != InventoryType.RangedRight ? WeaponAttackType.BaseAttack : WeaponAttackType.RangedAttack;
|
EquipmentSlot.OffHand => WeaponAttackType.OffAttack,
|
||||||
case EquipmentSlot.OffHand:
|
_ => WeaponAttackType.Max,
|
||||||
return WeaponAttackType.OffAttack;
|
};
|
||||||
default:
|
|
||||||
return WeaponAttackType.Max;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void AutoUnequipOffhandIfNeed(bool force = false)
|
public void AutoUnequipOffhandIfNeed(bool force = false)
|
||||||
{
|
{
|
||||||
@@ -7290,6 +7287,9 @@ namespace Game.Entities
|
|||||||
public void RemovePlayerFlagEx(PlayerFlagsEx flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PlayerFlagsEx), (uint)flags); }
|
public void RemovePlayerFlagEx(PlayerFlagsEx flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PlayerFlagsEx), (uint)flags); }
|
||||||
public void SetPlayerFlagsEx(PlayerFlagsEx flags) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PlayerFlagsEx), (uint)flags); }
|
public void SetPlayerFlagsEx(PlayerFlagsEx flags) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PlayerFlagsEx), (uint)flags); }
|
||||||
|
|
||||||
|
public void UpdateAverageItemLevelTotal(float newItemLevel) { SetUpdateFieldValue(ref m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.AvgItemLevel, 0), newItemLevel); }
|
||||||
|
public void UpdateAverageItemLevelEquipped(float newItemLevel) { SetUpdateFieldValue(ref m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.AvgItemLevel, 1), newItemLevel); }
|
||||||
|
|
||||||
public uint GetCustomizationChoice(uint chrCustomizationOptionId)
|
public uint GetCustomizationChoice(uint chrCustomizationOptionId)
|
||||||
{
|
{
|
||||||
int choiceIndex = m_playerData.Customizations.FindIndexIf(choice =>
|
int choiceIndex = m_playerData.Customizations.FindIndexIf(choice =>
|
||||||
@@ -7317,7 +7317,7 @@ namespace Game.Entities
|
|||||||
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.Customizations), newChoice);
|
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.Customizations), newChoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gender GetNativeSex() { return (Gender)(byte)m_playerData.NativeSex; }
|
public Gender GetNativeSex() { return (Gender)(byte)m_playerData.NativeSex; }
|
||||||
public void SetNativeSex(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.NativeSex), (byte)sex); }
|
public void SetNativeSex(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.NativeSex), (byte)sex); }
|
||||||
public void SetPvpTitle(byte pvpTitle) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PvpTitle), pvpTitle); }
|
public void SetPvpTitle(byte pvpTitle) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PvpTitle), pvpTitle); }
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace Game.Entities
|
|||||||
public float ModMeleeHitChance { get; set; }
|
public float ModMeleeHitChance { get; set; }
|
||||||
public float ModRangedHitChance { get; set; }
|
public float ModRangedHitChance { get; set; }
|
||||||
public float ModSpellHitChance { get; set; }
|
public float ModSpellHitChance { get; set; }
|
||||||
bool m_canDualWield;
|
public bool m_canDualWield;
|
||||||
public int BaseSpellCritChance { get; set; }
|
public int BaseSpellCritChance { get; set; }
|
||||||
public uint RegenTimer { get; set; }
|
public uint RegenTimer { get; set; }
|
||||||
uint combatTimer;
|
uint combatTimer;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Game
|
|||||||
ActivateEssenceFailed activateEssenceResult = new();
|
ActivateEssenceFailed activateEssenceResult = new();
|
||||||
activateEssenceResult.AzeriteEssenceID = azeriteEssenceActivateEssence.AzeriteEssenceID;
|
activateEssenceResult.AzeriteEssenceID = azeriteEssenceActivateEssence.AzeriteEssenceID;
|
||||||
|
|
||||||
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.InEquipment);
|
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Equipment);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
activateEssenceResult.Reason = AzeriteEssenceActivateResult.NotEquipped;
|
activateEssenceResult.Reason = AzeriteEssenceActivateResult.NotEquipped;
|
||||||
|
|||||||
@@ -1024,6 +1024,9 @@ namespace Game
|
|||||||
if (!pCurrChar.IsStandState() && !pCurrChar.HasUnitState(UnitState.Stunned))
|
if (!pCurrChar.IsStandState() && !pCurrChar.HasUnitState(UnitState.Stunned))
|
||||||
pCurrChar.SetStandState(UnitStandStateType.Stand);
|
pCurrChar.SetStandState(UnitStandStateType.Stand);
|
||||||
|
|
||||||
|
pCurrChar.UpdateAverageItemLevelTotal();
|
||||||
|
pCurrChar.UpdateAverageItemLevelEquipped();
|
||||||
|
|
||||||
m_playerLoading.Clear();
|
m_playerLoading.Clear();
|
||||||
|
|
||||||
Global.ScriptMgr.OnPlayerLogin(pCurrChar);
|
Global.ScriptMgr.OnPlayerLogin(pCurrChar);
|
||||||
|
|||||||
Reference in New Issue
Block a user