Core/Items: PvP item levels basic implementation

This commit is contained in:
hondacrx
2018-03-06 11:34:28 -05:00
parent a596b3f1ea
commit ba8d4661fd
16 changed files with 97 additions and 26 deletions
+23 -4
View File
@@ -1975,10 +1975,16 @@ namespace Game.Entities
public uint GetItemLevel(Player owner)
{
return GetItemLevel(GetTemplate(), _bonusData, owner.getLevel(), GetModifier(ItemModifier.ScalingStatDistributionFixedLevel), GetModifier(ItemModifier.UpgradeId));
uint minItemLevel = owner.GetUInt32Value(UnitFields.MinItemLevel);
uint minItemLevelCutoff = owner.GetUInt32Value(UnitFields.MinItemLevelCutoff);
uint maxItemLevel = GetTemplate().GetFlags3().HasAnyFlag(ItemFlags3.IgnoreItemLevelCapInPvp) ? 0 : owner.GetUInt32Value(UnitFields.MaxItemlevel);
bool pvpBonus = owner.IsUsingPvpItemLevels();
return GetItemLevel(GetTemplate(), _bonusData, owner.getLevel(), GetModifier(ItemModifier.ScalingStatDistributionFixedLevel), GetModifier(ItemModifier.UpgradeId),
minItemLevel, minItemLevelCutoff, maxItemLevel, pvpBonus);
}
public static uint GetItemLevel(ItemTemplate itemTemplate, BonusData bonusData, uint level, uint fixedLevel, uint upgradeId)
public static uint GetItemLevel(ItemTemplate itemTemplate, BonusData bonusData, uint level, uint fixedLevel, uint upgradeId,
uint minItemLevel, uint minItemLevelCutoff, uint maxItemLevel, bool pvpBonus)
{
if (itemTemplate == null)
return 1;
@@ -2004,12 +2010,25 @@ namespace Game.Entities
itemLevel += (uint)bonusData.ItemLevelBonus;
for (uint i = 0; i < ItemConst.MaxGemSockets; ++i)
itemLevel += bonusData.GemItemLevelBonus[i];
uint itemLevelBeforeUpgrades = itemLevel;
ItemUpgradeRecord upgrade = CliDB.ItemUpgradeStorage.LookupByKey(upgradeId);
if (upgrade != null)
itemLevel += upgrade.ItemLevelBonus;
for (uint i = 0; i < ItemConst.MaxGemSockets; ++i)
itemLevel += bonusData.GemItemLevelBonus[i];
if (pvpBonus)
itemLevel += Global.DB2Mgr.GetPvpItemLevelBonus(itemTemplate.GetId());
if (itemTemplate.GetInventoryType() != InventoryType.NonEquip)
{
if (minItemLevel != 0 && (minItemLevelCutoff == 0 || itemLevelBeforeUpgrades >= minItemLevelCutoff) && itemLevel < minItemLevel)
itemLevel = minItemLevel;
if (maxItemLevel != 0 && itemLevel > maxItemLevel)
itemLevel = maxItemLevel;
}
return Math.Min(Math.Max(itemLevel, 1), 1300);
}
@@ -65,6 +65,7 @@ namespace Game.Entities
uint m_ArenaTeamIdInvited;
long m_lastHonorUpdateTime;
uint m_contestedPvPTimer;
bool _usePvpItemLevels;
//Groups/Raids
GroupReference m_group = new GroupReference();
@@ -6713,5 +6713,23 @@ namespace Game.Entities
return null;
}
//Misc
void UpdateItemLevelAreaBasedScaling()
{
// @todo Activate pvp item levels during world pvp
Map map = GetMap();
bool pvpActivity = map.IsBattlegroundOrArena() || ((int)map.GetEntry().Flags[1]).HasAnyFlag(0x40) || HasPvpRulesEnabled();
if (_usePvpItemLevels != pvpActivity)
{
float healthPct = GetHealthPct();
_RemoveAllItemMods();
ActivatePvpItemLevels(pvpActivity);
_ApplyAllItemMods();
SetHealth(MathFunctions.CalculatePct(GetMaxHealth(), healthPct));
}
// @todo other types of power scaling such as timewalking
}
}
}
@@ -334,6 +334,9 @@ namespace Game.Entities
public uint GetHonorLevel() { return GetUInt32Value(PlayerFields.HonorLevel); }
public bool IsMaxHonorLevelAndPrestige() { return IsMaxPrestige() && GetHonorLevel() == PlayerConst.MaxHonorLevel; }
public void ActivatePvpItemLevels(bool activate) { _usePvpItemLevels = activate; }
public bool IsUsingPvpItemLevels() { return _usePvpItemLevels; }
void ResetPvpTalents()
{
foreach (var talentInfo in CliDB.PvpTalentStorage.Values)
@@ -489,6 +492,8 @@ namespace Game.Entities
aura.SetDuration(-1);
}
}
UpdateItemLevelAreaBasedScaling();
}
void DisablePvpRules()
@@ -498,7 +503,10 @@ namespace Game.Entities
return;
if (GetCombatTimer() == 0)
{
RemoveAurasDueToSpell(PlayerConst.SpellPvpRulesEnabled);
UpdateItemLevelAreaBasedScaling();
}
else
{
Aura aura = GetAura(PlayerConst.SpellPvpRulesEnabled);
+2 -2
View File
@@ -651,7 +651,7 @@ namespace Game.Entities
if (pEnchant.ScalingClass != 0)
{
int scalingClass = pEnchant.ScalingClass;
if ((GetUInt32Value(UnitFields.MinItemLevel) != 0 || GetUInt32Value(UnitFields.Maxitemlevel) != 0) && pEnchant.ScalingClassRestricted != 0)
if ((GetUInt32Value(UnitFields.MinItemLevel) != 0 || GetUInt32Value(UnitFields.MaxItemlevel) != 0) && pEnchant.ScalingClassRestricted != 0)
scalingClass = pEnchant.ScalingClassRestricted;
uint minLevel = ((uint)(pEnchant.Flags)).HasAnyFlag(0x20u) ? 1 : 60u;
@@ -691,7 +691,7 @@ namespace Game.Entities
if (pEnchant.ScalingClass != 0)
{
int scalingClass = pEnchant.ScalingClass;
if ((GetUInt32Value(UnitFields.MinItemLevel) != 0 || GetUInt32Value(UnitFields.Maxitemlevel) != 0) && pEnchant.ScalingClassRestricted != 0)
if ((GetUInt32Value(UnitFields.MinItemLevel) != 0 || GetUInt32Value(UnitFields.MaxItemlevel) != 0) && pEnchant.ScalingClassRestricted != 0)
scalingClass = pEnchant.ScalingClassRestricted;
uint minLevel = ((uint)(pEnchant.Flags)).HasAnyFlag(0x20u) ? 1 : 60u;
+2
View File
@@ -5702,6 +5702,8 @@ namespace Game.Entities
if (_garrison != null)
_garrison.SendRemoteInfo();
UpdateItemLevelAreaBasedScaling();
}
public bool CanSpeak()