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();
|
||||||
@@ -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));
|
||||||
@@ -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 =>
|
||||||
|
|||||||
@@ -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