Updated to 8.2.0.31429 (scripts disabled atm, they still need updated)
Code Port from TrinityCore https://github.com/TrinityCore/TrinityCore Casc from WoW-Tools https://github.com/WoW-Tools/CASCExplorer
This commit is contained in:
@@ -69,15 +69,15 @@ namespace Game.Entities
|
||||
|
||||
public void LoadToys()
|
||||
{
|
||||
foreach (var value in _toys.Keys)
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Toys, value);
|
||||
foreach (var pair in _toys)
|
||||
_owner.GetPlayer().AddToy(pair.Key, (uint)pair.Value);
|
||||
}
|
||||
|
||||
public bool AddToy(uint itemId, bool isFavourite, bool hasFanfare)
|
||||
{
|
||||
if (UpdateAccountToys(itemId, isFavourite, hasFanfare))
|
||||
{
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Toys, itemId);
|
||||
_owner.GetPlayer().AddToy(itemId, (uint)GetToyFlags(isFavourite, hasFanfare));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,8 +92,7 @@ namespace Game.Entities
|
||||
do
|
||||
{
|
||||
uint itemId = result.Read<uint>(0);
|
||||
|
||||
_toys[itemId] = GetToyFlags(result.Read<bool>(1), result.Read<bool>(2));
|
||||
_toys.Add(itemId, GetToyFlags(result.Read<bool>(1), result.Read<bool>(2)));
|
||||
} while (result.NextRow());
|
||||
}
|
||||
|
||||
@@ -175,7 +174,9 @@ namespace Game.Entities
|
||||
|
||||
uint bonusId = 0;
|
||||
|
||||
if (flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel110))
|
||||
if (flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel120))
|
||||
bonusId = heirloom.UpgradeItemBonusListID[3];
|
||||
else if (flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel110))
|
||||
bonusId = heirloom.UpgradeItemBonusListID[2];
|
||||
else if (flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel100))
|
||||
bonusId = heirloom.UpgradeItemBonusListID[1];
|
||||
@@ -220,19 +221,13 @@ namespace Game.Entities
|
||||
public void LoadHeirlooms()
|
||||
{
|
||||
foreach (var item in _heirlooms)
|
||||
{
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Heirlooms, item.Key);
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, (uint)item.Value.flags);
|
||||
}
|
||||
_owner.GetPlayer().AddHeirloom(item.Key, (uint)item.Value.flags);
|
||||
}
|
||||
|
||||
public void AddHeirloom(uint itemId, HeirloomPlayerFlags flags)
|
||||
{
|
||||
if (UpdateAccountHeirlooms(itemId, flags))
|
||||
{
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Heirlooms, itemId);
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, (uint)flags);
|
||||
}
|
||||
_owner.GetPlayer().AddHeirloom(itemId, (uint)flags);
|
||||
}
|
||||
|
||||
public void UpgradeHeirloom(uint itemId, uint castItem)
|
||||
@@ -267,15 +262,20 @@ namespace Game.Entities
|
||||
flags |= HeirloomPlayerFlags.BonusLevel110;
|
||||
bonusId = heirloom.UpgradeItemBonusListID[2];
|
||||
}
|
||||
if (heirloom.UpgradeItemID[3] == castItem)
|
||||
{
|
||||
flags |= HeirloomPlayerFlags.BonusLevel120;
|
||||
bonusId = heirloom.UpgradeItemBonusListID[3];
|
||||
}
|
||||
|
||||
foreach (Item item in player.GetItemListByEntry(itemId, true))
|
||||
item.AddBonuses(bonusId);
|
||||
|
||||
// Get heirloom offset to update only one part of dynamic field
|
||||
var fields = player.GetDynamicValues(ActivePlayerDynamicFields.Heirlooms);
|
||||
ushort offset = (ushort)Array.IndexOf(fields, itemId);
|
||||
List<uint> heirlooms = player.m_activePlayerData.Heirlooms;
|
||||
int offset = heirlooms.IndexOf(itemId);
|
||||
|
||||
player.SetDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, offset, (uint)flags);
|
||||
player.SetHeirloomFlags(offset, (uint)flags);
|
||||
data.flags = flags;
|
||||
data.bonusId = bonusId;
|
||||
}
|
||||
@@ -315,11 +315,11 @@ namespace Game.Entities
|
||||
|
||||
if (newItemId != 0)
|
||||
{
|
||||
var heirloomFields = player.GetDynamicValues(ActivePlayerDynamicFields.Heirlooms);
|
||||
ushort offset = (ushort)Array.IndexOf(heirloomFields, item.GetEntry());
|
||||
List<uint> heirlooms = player.m_activePlayerData.Heirlooms;
|
||||
int offset = heirlooms.IndexOf(item.GetEntry());
|
||||
|
||||
player.SetDynamicValue(ActivePlayerDynamicFields.Heirlooms, offset, newItemId);
|
||||
player.SetDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, offset, 0);
|
||||
player.SetHeirloom(offset, newItemId);
|
||||
player.SetHeirloomFlags(offset, 0);
|
||||
|
||||
_heirlooms.Remove(item.GetEntry());
|
||||
_heirlooms[newItemId] = null;
|
||||
@@ -327,12 +327,17 @@ namespace Game.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
var fields = item.GetDynamicValues(ItemDynamicFields.BonusListIds);
|
||||
foreach (uint bonusId in fields)
|
||||
List<uint> bonusListIDs = item.m_itemData.BonusListIDs;
|
||||
foreach (uint bonusId in bonusListIDs)
|
||||
{
|
||||
if (bonusId != data.bonusId)
|
||||
item.ClearDynamicValue(ItemDynamicFields.BonusListIds);
|
||||
{
|
||||
item.ClearBonuses();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fields.Contains(data.bonusId))
|
||||
if (!bonusListIDs.Contains(data.bonusId))
|
||||
item.AddBonuses(data.bonusId);
|
||||
}
|
||||
}
|
||||
@@ -346,6 +351,8 @@ namespace Game.Entities
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
if (data.flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel120))
|
||||
return level <= 120;
|
||||
if (data.flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel110))
|
||||
return level <= 110;
|
||||
if (data.flags.HasAnyFlag(HeirloomPlayerFlags.BonusLevel100))
|
||||
@@ -453,13 +460,12 @@ namespace Game.Entities
|
||||
|
||||
public void LoadItemAppearances()
|
||||
{
|
||||
Player owner = _owner.GetPlayer();
|
||||
foreach (uint blockValue in _appearances.ToBlockRange())
|
||||
{
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Transmog, blockValue);
|
||||
}
|
||||
owner.AddTransmogBlock(blockValue);
|
||||
|
||||
foreach (var value in _temporaryAppearances.Keys)
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, value);
|
||||
owner.AddConditionalTransmog(value);
|
||||
}
|
||||
|
||||
public void LoadAccountItemAppearances(SQLResult knownAppearances, SQLResult favoriteAppearances)
|
||||
@@ -578,7 +584,7 @@ namespace Game.Entities
|
||||
if (!CanAddAppearance(itemModifiedAppearance))
|
||||
return;
|
||||
|
||||
if (Convert.ToBoolean(item.GetUInt32Value(ItemFields.Flags) & (uint)(ItemFieldFlags.BopTradeable | ItemFieldFlags.Refundable)))
|
||||
if (item.HasItemFlag(ItemFieldFlags.BopTradeable | ItemFieldFlags.Refundable))
|
||||
{
|
||||
AddTemporaryAppearance(item.GetGUID(), itemModifiedAppearance);
|
||||
return;
|
||||
@@ -678,24 +684,24 @@ namespace Game.Entities
|
||||
//todo check this
|
||||
void AddItemAppearance(ItemModifiedAppearanceRecord itemModifiedAppearance)
|
||||
{
|
||||
Player owner = _owner.GetPlayer();
|
||||
if (_appearances.Count <= itemModifiedAppearance.Id)
|
||||
{
|
||||
uint numBlocks = (uint)(_appearances.Count << 2);
|
||||
_appearances.Length = (int)itemModifiedAppearance.Id + 1;
|
||||
numBlocks = (uint)(_appearances.Count << 2) - numBlocks;
|
||||
while (numBlocks-- != 0)
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Transmog, 0);
|
||||
owner.AddTransmogBlock(0);
|
||||
}
|
||||
|
||||
_appearances.Set((int)itemModifiedAppearance.Id, true);
|
||||
uint blockIndex = itemModifiedAppearance.Id / 32;
|
||||
uint bitIndex = itemModifiedAppearance.Id % 32;
|
||||
uint currentMask = _owner.GetPlayer().GetDynamicValue(ActivePlayerDynamicFields.Transmog, (ushort)blockIndex);
|
||||
_owner.GetPlayer().SetDynamicValue(ActivePlayerDynamicFields.Transmog, (ushort)blockIndex, (uint)((int)currentMask | (1 << (int)bitIndex)));
|
||||
owner.AddTransmogFlag((int)blockIndex, 1u << (int)bitIndex);
|
||||
var temporaryAppearance = _temporaryAppearances.LookupByKey(itemModifiedAppearance.Id);
|
||||
if (!temporaryAppearance.Empty())
|
||||
{
|
||||
_owner.GetPlayer().RemoveDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
|
||||
owner.RemoveConditionalTransmog(itemModifiedAppearance.Id);
|
||||
_temporaryAppearances.Remove(itemModifiedAppearance.Id);
|
||||
}
|
||||
|
||||
@@ -717,7 +723,7 @@ namespace Game.Entities
|
||||
{
|
||||
var itemsWithAppearance = _temporaryAppearances[itemModifiedAppearance.Id];
|
||||
if (itemsWithAppearance.Empty())
|
||||
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
|
||||
_owner.GetPlayer().AddConditionalTransmog(itemModifiedAppearance.Id);
|
||||
|
||||
itemsWithAppearance.Add(itemGuid);
|
||||
}
|
||||
@@ -735,7 +741,7 @@ namespace Game.Entities
|
||||
guid.Remove(item.GetGUID());
|
||||
if (guid.Empty())
|
||||
{
|
||||
_owner.GetPlayer().RemoveDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
|
||||
_owner.GetPlayer().RemoveConditionalTransmog(itemModifiedAppearance.Id);
|
||||
_temporaryAppearances.Remove(itemModifiedAppearance.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,21 +88,9 @@ namespace Game.Entities
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
bool CanTitanGrip() { return m_canTitanGrip; }
|
||||
public override uint GetBlockPercent() { return m_activePlayerData.ShieldBlock; }
|
||||
|
||||
public override bool CanUseAttackType(WeaponAttackType attacktype)
|
||||
{
|
||||
switch (attacktype)
|
||||
{
|
||||
case WeaponAttackType.BaseAttack:
|
||||
return !HasFlag(UnitFields.Flags, UnitFlags.Disarmed);
|
||||
case WeaponAttackType.OffAttack:
|
||||
return !HasFlag(UnitFields.Flags2, UnitFlags2.DisarmOffhand);
|
||||
case WeaponAttackType.RangedAttack:
|
||||
return !HasFlag(UnitFields.Flags2, UnitFlags2.DisarmRanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CanTitanGrip() { return m_canTitanGrip; }
|
||||
|
||||
float GetRatingMultiplier(CombatRating cr)
|
||||
{
|
||||
@@ -118,7 +106,7 @@ namespace Game.Entities
|
||||
}
|
||||
public float GetRatingBonusValue(CombatRating cr)
|
||||
{
|
||||
float baseResult = GetFloatValue(ActivePlayerFields.CombatRating + (int)cr) * GetRatingMultiplier(cr);
|
||||
float baseResult = m_activePlayerData.CombatRatings[(int)cr] * GetRatingMultiplier(cr);
|
||||
if (cr != CombatRating.ResiliencePlayerDamage)
|
||||
return baseResult;
|
||||
return (float)(1.0f - Math.Pow(0.99f, baseResult)) * 100.0f;
|
||||
@@ -189,9 +177,9 @@ namespace Game.Entities
|
||||
switch (attType)
|
||||
{
|
||||
case WeaponAttackType.BaseAttack:
|
||||
return baseExpertise + GetUInt32Value(ActivePlayerFields.Expertise) / 4.0f;
|
||||
return baseExpertise + m_activePlayerData.MainhandExpertise / 4.0f;
|
||||
case WeaponAttackType.OffAttack:
|
||||
return baseExpertise + GetUInt32Value(ActivePlayerFields.OffhandExpertise) / 4.0f;
|
||||
return baseExpertise + m_activePlayerData.OffhandExpertise / 4.0f;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -201,7 +189,7 @@ namespace Game.Entities
|
||||
public bool IsUseEquipedWeapon(bool mainhand)
|
||||
{
|
||||
// disarm applied only to mainhand weapon
|
||||
return !IsInFeralForm() && (!mainhand || !HasFlag(UnitFields.Flags, UnitFlags.Disarmed));
|
||||
return !IsInFeralForm() && (!mainhand || !HasUnitFlag(UnitFlags.Disarmed));
|
||||
}
|
||||
|
||||
public void SetCanTitanGrip(bool value, uint penaltySpellId = 0)
|
||||
@@ -321,8 +309,8 @@ namespace Game.Entities
|
||||
|
||||
Global.ScriptMgr.OnPlayerDuelStart(this, duel.opponent);
|
||||
|
||||
SetUInt32Value(PlayerFields.DuelTeam, 1);
|
||||
duel.opponent.SetUInt32Value(PlayerFields.DuelTeam, 2);
|
||||
SetDuelTeam(1);
|
||||
duel.opponent.SetDuelTeam(2);
|
||||
|
||||
duel.startTimer = 0;
|
||||
duel.startTime = currTime;
|
||||
@@ -335,7 +323,7 @@ namespace Game.Entities
|
||||
if (duel == null)
|
||||
return;
|
||||
|
||||
ObjectGuid duelFlagGUID = GetGuidValue(PlayerFields.DuelArbiter);
|
||||
ObjectGuid duelFlagGUID = m_playerData.DuelArbiter;
|
||||
GameObject obj = GetMap().GetGameObject(duelFlagGUID);
|
||||
if (!obj)
|
||||
return;
|
||||
@@ -439,7 +427,7 @@ namespace Game.Entities
|
||||
duel.opponent.CastSpell(duel.opponent, 52852, true);
|
||||
|
||||
//Remove Duel Flag object
|
||||
GameObject obj = GetMap().GetGameObject(GetGuidValue(PlayerFields.DuelArbiter));
|
||||
GameObject obj = GetMap().GetGameObject(m_playerData.DuelArbiter);
|
||||
if (obj)
|
||||
duel.initiator.RemoveGameObject(obj, true);
|
||||
|
||||
@@ -465,14 +453,16 @@ namespace Game.Entities
|
||||
duel.opponent.ClearComboPoints();
|
||||
|
||||
//cleanups
|
||||
SetGuidValue(PlayerFields.DuelArbiter, ObjectGuid.Empty);
|
||||
SetUInt32Value(PlayerFields.DuelTeam, 0);
|
||||
duel.opponent.SetGuidValue(PlayerFields.DuelArbiter, ObjectGuid.Empty);
|
||||
duel.opponent.SetUInt32Value(PlayerFields.DuelTeam, 0);
|
||||
SetDuelArbiter(ObjectGuid.Empty);
|
||||
SetDuelTeam(0);
|
||||
duel.opponent.SetDuelArbiter(ObjectGuid.Empty);
|
||||
duel.opponent.SetDuelTeam(0);
|
||||
|
||||
duel.opponent.duel = null;
|
||||
duel = null;
|
||||
}
|
||||
public void SetDuelArbiter(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.DuelArbiter), guid); }
|
||||
void SetDuelTeam(uint duelTeam) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.DuelTeam), duelTeam); }
|
||||
|
||||
//PVP
|
||||
public void SetPvPDeath(bool on)
|
||||
@@ -488,7 +478,7 @@ namespace Game.Entities
|
||||
public void ResetContestedPvP()
|
||||
{
|
||||
ClearUnitState(UnitState.AttackPlayer);
|
||||
RemoveFlag(PlayerFields.Flags, PlayerFlags.ContestedPVP);
|
||||
RemovePlayerFlag(PlayerFlags.ContestedPVP);
|
||||
m_contestedPvPTimer = 0;
|
||||
}
|
||||
void UpdateAfkReport(long currTime)
|
||||
@@ -547,16 +537,16 @@ namespace Game.Entities
|
||||
{
|
||||
if (!IsFFAPvP())
|
||||
{
|
||||
SetByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.FFAPvp);
|
||||
AddPvpFlag(UnitPVPStateFlags.FFAPvp);
|
||||
foreach (var unit in m_Controlled)
|
||||
unit.SetByteValue(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, (byte)UnitBytes2Flags.FFAPvp);
|
||||
unit.AddPvpFlag(UnitPVPStateFlags.FFAPvp);
|
||||
}
|
||||
}
|
||||
else if (IsFFAPvP())
|
||||
{
|
||||
RemoveByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.FFAPvp);
|
||||
RemovePvpFlag(UnitPVPStateFlags.FFAPvp);
|
||||
foreach (var unit in m_Controlled)
|
||||
unit.RemoveByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.FFAPvp);
|
||||
unit.RemovePvpFlag(UnitPVPStateFlags.FFAPvp);
|
||||
}
|
||||
|
||||
if (onlyFFA)
|
||||
@@ -569,7 +559,7 @@ namespace Game.Entities
|
||||
}
|
||||
else // in friendly area
|
||||
{
|
||||
if (IsPvP() && !HasFlag(PlayerFields.Flags, PlayerFlags.InPVP) && pvpInfo.EndTimer == 0)
|
||||
if (IsPvP() && !HasPlayerFlag(PlayerFlags.InPVP) && pvpInfo.EndTimer == 0)
|
||||
pvpInfo.EndTimer = Time.UnixTime; // start toggle-off
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -184,6 +184,10 @@ namespace Game.Entities
|
||||
|
||||
//Core
|
||||
WorldSession Session;
|
||||
|
||||
public PlayerData m_playerData;
|
||||
public ActivePlayerData m_activePlayerData;
|
||||
|
||||
uint m_nextSave;
|
||||
byte m_cinematic;
|
||||
|
||||
@@ -330,7 +334,6 @@ namespace Game.Entities
|
||||
public List<uint>[] Glyphs = new List<uint>[PlayerConst.MaxSpecializations];
|
||||
public uint ResetTalentsCost;
|
||||
public long ResetTalentsTime;
|
||||
public uint PrimarySpecialization;
|
||||
public byte ActiveGroup;
|
||||
}
|
||||
|
||||
@@ -442,13 +445,12 @@ namespace Game.Entities
|
||||
|
||||
public class VoidStorageItem
|
||||
{
|
||||
public VoidStorageItem(ulong id, uint entry, ObjectGuid creator, ItemRandomEnchantmentId randomPropertyId, uint suffixFactor, uint upgradeId, uint fixedScalingLevel, uint artifactKnowledgeLevel, byte context, ICollection<uint> bonuses)
|
||||
public VoidStorageItem(ulong id, uint entry, ObjectGuid creator, uint randomBonusListId, uint upgradeId, uint fixedScalingLevel, uint artifactKnowledgeLevel, byte context, List<uint> bonuses)
|
||||
{
|
||||
ItemId = id;
|
||||
ItemEntry = entry;
|
||||
CreatorGuid = creator;
|
||||
ItemRandomPropertyId = randomPropertyId;
|
||||
ItemSuffixFactor = suffixFactor;
|
||||
RandomBonusListId = randomBonusListId;
|
||||
ItemUpgradeId = upgradeId;
|
||||
FixedScalingLevel = fixedScalingLevel;
|
||||
ArtifactKnowledgeLevel = artifactKnowledgeLevel;
|
||||
@@ -461,8 +463,7 @@ namespace Game.Entities
|
||||
public ulong ItemId;
|
||||
public uint ItemEntry;
|
||||
public ObjectGuid CreatorGuid;
|
||||
public ItemRandomEnchantmentId ItemRandomPropertyId;
|
||||
public uint ItemSuffixFactor;
|
||||
public uint RandomBonusListId;
|
||||
public uint ItemUpgradeId;
|
||||
public uint FixedScalingLevel;
|
||||
public uint ArtifactKnowledgeLevel;
|
||||
|
||||
@@ -165,10 +165,10 @@ namespace Game.Entities
|
||||
public void SetPartyType(GroupCategory category, GroupType type)
|
||||
{
|
||||
Cypher.Assert(category < GroupCategory.Max);
|
||||
byte value = GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType);
|
||||
byte value = m_playerData.PartyType;
|
||||
value &= (byte)~((byte)0xFF << ((byte)category * 4));
|
||||
value |= (byte)((byte)type << ((byte)category * 4));
|
||||
SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType, value);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PartyType), value);
|
||||
}
|
||||
|
||||
public void ResetGroupUpdateSequenceIfNeeded(Group group)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Game.Entities
|
||||
}
|
||||
public void RefundItem(Item item)
|
||||
{
|
||||
if (!item.HasFlag(ItemFields.Flags, ItemFieldFlags.Refundable))
|
||||
if (!item.HasItemFlag(ItemFieldFlags.Refundable))
|
||||
{
|
||||
Log.outDebug(LogFilter.Player, "Item refund: item not refundable!");
|
||||
return;
|
||||
@@ -152,7 +152,7 @@ namespace Game.Entities
|
||||
// This function call unsets ITEM_FLAGS_REFUNDABLE if played time is over 2 hours.
|
||||
item.UpdatePlayedTime(this);
|
||||
|
||||
if (!item.HasFlag(ItemFields.Flags, ItemFieldFlags.Refundable))
|
||||
if (!item.HasItemFlag(ItemFieldFlags.Refundable))
|
||||
{
|
||||
Log.outDebug(LogFilter.Player, "Item refund: item not refundable!");
|
||||
return;
|
||||
@@ -301,7 +301,7 @@ namespace Game.Entities
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
uint pMaxDurability = item.GetUInt32Value(ItemFields.MaxDurability);
|
||||
uint pMaxDurability = item.m_itemData.MaxDurability;
|
||||
|
||||
if (pMaxDurability == 0)
|
||||
return;
|
||||
@@ -352,14 +352,14 @@ namespace Game.Entities
|
||||
if (HasAuraType(AuraType.PreventDurabilityLoss))
|
||||
return;
|
||||
|
||||
int pMaxDurability = item.GetInt32Value(ItemFields.MaxDurability);
|
||||
int pOldDurability = item.GetInt32Value(ItemFields.Durability);
|
||||
int pNewDurability = pOldDurability - points;
|
||||
uint pMaxDurability = item.m_itemData.MaxDurability;
|
||||
uint pOldDurability = item.m_itemData.Durability;
|
||||
int pNewDurability = (int)(pOldDurability - points);
|
||||
|
||||
if (pNewDurability < 0)
|
||||
pNewDurability = 0;
|
||||
else if (pNewDurability > pMaxDurability)
|
||||
pNewDurability = pMaxDurability;
|
||||
pNewDurability = (int)pMaxDurability;
|
||||
|
||||
if (pOldDurability != pNewDurability)
|
||||
{
|
||||
@@ -367,7 +367,7 @@ namespace Game.Entities
|
||||
if (pNewDurability == 0 && pOldDurability > 0 && item.IsEquipped())
|
||||
_ApplyItemMods(item, item.GetSlot(), false);
|
||||
|
||||
item.SetInt32Value(ItemFields.Durability, pNewDurability);
|
||||
item.SetDurability((uint)pNewDurability);
|
||||
|
||||
// modify item stats _after_ restore durability to pass _ApplyItemMods internal check
|
||||
if (pNewDurability > 0 && pOldDurability == 0 && item.IsEquipped())
|
||||
@@ -407,11 +407,11 @@ namespace Game.Entities
|
||||
if (item == null)
|
||||
return TotalCost;
|
||||
|
||||
uint maxDurability = item.GetUInt32Value(ItemFields.MaxDurability);
|
||||
uint maxDurability = item.m_itemData.MaxDurability;
|
||||
if (maxDurability == 0)
|
||||
return TotalCost;
|
||||
|
||||
uint curDurability = item.GetUInt32Value(ItemFields.Durability);
|
||||
uint curDurability = item.m_itemData.Durability;
|
||||
|
||||
if (cost)
|
||||
{
|
||||
@@ -474,7 +474,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
item.SetUInt32Value(ItemFields.Durability, maxDurability);
|
||||
item.SetDurability(maxDurability);
|
||||
item.SetState(ItemUpdateState.Changed, this);
|
||||
|
||||
// reapply mods for total broken and repaired item if equipped
|
||||
@@ -644,7 +644,7 @@ namespace Game.Entities
|
||||
// search free slot in bag for place to
|
||||
if (bag == InventorySlots.Bag0) // inventory
|
||||
{
|
||||
if (pItem && pItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child))
|
||||
if (pItem && pItem.HasItemFlag(ItemFieldFlags.Child))
|
||||
{
|
||||
res = CanStoreItem_InInventorySlots(InventorySlots.ChildEquipmentStart, InventorySlots.ChildEquipmentEnd, dest, pProto, ref count, false, pItem, bag, slot);
|
||||
if (res != InventoryResult.Ok)
|
||||
@@ -662,7 +662,7 @@ namespace Game.Entities
|
||||
return InventoryResult.ItemMaxCount;
|
||||
}
|
||||
}
|
||||
else if (pProto.IsCraftingReagent() && HasFlag(PlayerFields.FlagsEx, PlayerFlagsEx.ReagentBankUnlocked))
|
||||
else if (pProto.IsCraftingReagent() && HasPlayerFlagEx(PlayerFlagsEx.ReagentBankUnlocked))
|
||||
{
|
||||
res = CanStoreItem_InInventorySlots(InventorySlots.ReagentStart, InventorySlots.ReagentEnd, dest, pProto, ref count, false, pItem, bag, slot);
|
||||
if (res != InventoryResult.Ok)
|
||||
@@ -832,7 +832,7 @@ namespace Game.Entities
|
||||
if (pItem != null && pItem.IsNotEmptyBag())
|
||||
return InventoryResult.BagInBag;
|
||||
|
||||
if (pItem && pItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child))
|
||||
if (pItem && pItem.HasItemFlag(ItemFieldFlags.Child))
|
||||
{
|
||||
res = CanStoreItem_InInventorySlots(InventorySlots.ChildEquipmentStart, InventorySlots.ChildEquipmentEnd, dest, pProto, ref count, false, pItem, bag, slot);
|
||||
if (res != InventoryResult.Ok)
|
||||
@@ -850,7 +850,7 @@ namespace Game.Entities
|
||||
return InventoryResult.ItemMaxCount;
|
||||
}
|
||||
}
|
||||
else if (pProto.IsCraftingReagent() && HasFlag(PlayerFields.FlagsEx, PlayerFlagsEx.ReagentBankUnlocked))
|
||||
else if (pProto.IsCraftingReagent() && HasPlayerFlagEx(PlayerFlagsEx.ReagentBankUnlocked))
|
||||
{
|
||||
res = CanStoreItem_InInventorySlots(InventorySlots.ReagentStart, InventorySlots.ReagentEnd, dest, pProto, ref count, false, pItem, bag, slot);
|
||||
if (res != InventoryResult.Ok)
|
||||
@@ -1132,9 +1132,9 @@ namespace Game.Entities
|
||||
if (pBag == null)
|
||||
{
|
||||
m_items[slot] = pItem;
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), pItem.GetGUID());
|
||||
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
|
||||
pItem.SetGuidValue(ItemFields.Owner, GetGUID());
|
||||
SetInvSlot(slot, pItem.GetGUID());
|
||||
pItem.SetContainedIn(GetGUID());
|
||||
pItem.SetOwnerGUID(GetGUID());
|
||||
|
||||
pItem.SetSlot(slot);
|
||||
pItem.SetContainer(null);
|
||||
@@ -1251,7 +1251,7 @@ namespace Game.Entities
|
||||
msg = CanStoreNewItem(InventorySlots.Bag0, ItemConst.NullSlot, sDest, titem_id, titem_amount);
|
||||
if (msg == InventoryResult.Ok)
|
||||
{
|
||||
StoreNewItem(sDest, titem_id, true, ItemEnchantment.GenerateItemRandomPropertyId(titem_id));
|
||||
StoreNewItem(sDest, titem_id, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(titem_id));
|
||||
return true; // stored
|
||||
}
|
||||
|
||||
@@ -1259,7 +1259,7 @@ namespace Game.Entities
|
||||
Log.outError(LogFilter.Player, "STORAGE: Can't equip or store initial item {0} for race {1} class {2}, error msg = {3}", titem_id, GetRace(), GetClass(), msg);
|
||||
return false;
|
||||
}
|
||||
public Item StoreNewItem(List<ItemPosCount> pos, uint itemId, bool update, ItemRandomEnchantmentId randomPropertyId = default(ItemRandomEnchantmentId), List<ObjectGuid> allowedLooters = null, byte context = 0, List<uint> bonusListIDs = null, bool addToCollection = true)
|
||||
public Item StoreNewItem(List<ItemPosCount> pos, uint itemId, bool update, uint randomPropertyId = 0, List<ObjectGuid> allowedLooters = null, byte context = 0, List<uint> bonusListIDs = null, bool addToCollection = true)
|
||||
{
|
||||
uint count = 0;
|
||||
foreach (var itemPosCount in pos)
|
||||
@@ -1272,28 +1272,24 @@ namespace Game.Entities
|
||||
UpdateCriteria(CriteriaTypes.ReceiveEpicItem, itemId, count);
|
||||
UpdateCriteria(CriteriaTypes.OwnItem, itemId, 1);
|
||||
|
||||
item.SetFlag(ItemFields.Flags, ItemFieldFlags.NewItem);
|
||||
item.AddItemFlag(ItemFieldFlags.NewItem);
|
||||
|
||||
uint upgradeID = Global.DB2Mgr.GetRulesetItemUpgrade(itemId);
|
||||
if (upgradeID != 0)
|
||||
item.SetModifier(ItemModifier.UpgradeId, upgradeID);
|
||||
|
||||
item.SetUInt32Value(ItemFields.Context, context);
|
||||
if (bonusListIDs != null)
|
||||
{
|
||||
foreach (uint bonusListID in bonusListIDs)
|
||||
item.AddBonuses(bonusListID);
|
||||
}
|
||||
item.SetContext(context);
|
||||
item.SetBonuses(bonusListIDs);
|
||||
|
||||
item = StoreItem(pos, item, update);
|
||||
|
||||
item.SetFixedLevel(getLevel());
|
||||
item.SetItemRandomProperties(randomPropertyId);
|
||||
item.SetItemRandomBonusList(randomPropertyId);
|
||||
|
||||
if (allowedLooters != null && allowedLooters.Count > 1 && item.GetTemplate().GetMaxStackSize() == 1 && item.IsSoulBound())
|
||||
{
|
||||
item.SetSoulboundTradeable(allowedLooters);
|
||||
item.SetUInt32Value(ItemFields.CreatePlayedTime, GetTotalPlayedTime());
|
||||
item.SetCreatePlayedTime(GetTotalPlayedTime());
|
||||
AddTradeableItem(item);
|
||||
|
||||
// save data
|
||||
@@ -1318,11 +1314,11 @@ namespace Game.Entities
|
||||
{
|
||||
List<ItemPosCount> childDest = new List<ItemPosCount>();
|
||||
CanStoreItem_InInventorySlots(InventorySlots.ChildEquipmentStart, InventorySlots.ChildEquipmentEnd, childDest, childTemplate, ref count, false, null, ItemConst.NullBag, ItemConst.NullSlot);
|
||||
Item childItem = StoreNewItem(childDest, childTemplate.GetId(), update, ItemRandomEnchantmentId.Empty, null, context, null, addToCollection);
|
||||
Item childItem = StoreNewItem(childDest, childTemplate.GetId(), update, 0, null, context, null, addToCollection);
|
||||
if (childItem)
|
||||
{
|
||||
childItem.SetGuidValue(ItemFields.Creator, item.GetGUID());
|
||||
childItem.SetFlag(ItemFields.Flags, ItemFieldFlags.Child);
|
||||
childItem.SetCreator(item.GetGUID());
|
||||
childItem.AddItemFlag(ItemFieldFlags.Child);
|
||||
item.SetChildItem(childItem.GetGUID());
|
||||
}
|
||||
}
|
||||
@@ -1505,7 +1501,7 @@ namespace Game.Entities
|
||||
|
||||
ArtifactRecord artifact = CliDB.ArtifactStorage.LookupByKey(proto.GetArtifactID());
|
||||
if (artifact != null)
|
||||
if (artifact.ChrSpecializationID != GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (artifact.ChrSpecializationID != GetPrimarySpecialization())
|
||||
return InventoryResult.CantUseItem;
|
||||
|
||||
return InventoryResult.Ok;
|
||||
@@ -1907,7 +1903,7 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = StoreNewItem(dest, itemId, true, ItemEnchantment.GenerateItemRandomPropertyId(itemId));
|
||||
Item item = StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId));
|
||||
if (item != null)
|
||||
SendNewItem(item, count, true, false);
|
||||
else
|
||||
@@ -1947,20 +1943,7 @@ namespace Game.Entities
|
||||
{
|
||||
// remove held enchantments, update expertise
|
||||
if (slot == EquipmentSlot.MainHand)
|
||||
{
|
||||
if (pItem.GetItemSuffixFactor() != 0)
|
||||
{
|
||||
pItem.ClearEnchantment(EnchantmentSlot.Prop3);
|
||||
pItem.ClearEnchantment(EnchantmentSlot.Prop4);
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem.ClearEnchantment(EnchantmentSlot.Prop0);
|
||||
pItem.ClearEnchantment(EnchantmentSlot.Prop1);
|
||||
}
|
||||
|
||||
UpdateExpertise(WeaponAttackType.BaseAttack);
|
||||
}
|
||||
else if (slot == EquipmentSlot.OffHand)
|
||||
UpdateExpertise(WeaponAttackType.OffAttack);
|
||||
// update armor penetration - passive auras may need it
|
||||
@@ -1975,7 +1958,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
m_items[slot] = null;
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
|
||||
SetInvSlot(slot, ObjectGuid.Empty);
|
||||
|
||||
if (slot < EquipmentSlot.End)
|
||||
{
|
||||
@@ -1988,7 +1971,7 @@ namespace Game.Entities
|
||||
if (pBag != null)
|
||||
pBag.RemoveItem(slot, update);
|
||||
|
||||
pItem.SetGuidValue(ItemFields.Contained, ObjectGuid.Empty);
|
||||
pItem.SetContainedIn(ObjectGuid.Empty);
|
||||
pItem.SetSlot(ItemConst.NullSlot);
|
||||
if (IsInWorld && update)
|
||||
pItem.SendUpdateToPlayer(this);
|
||||
@@ -2122,9 +2105,9 @@ namespace Game.Entities
|
||||
if (pSrcItem == null)
|
||||
return;
|
||||
|
||||
if (pSrcItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child))
|
||||
if (pSrcItem.HasItemFlag(ItemFieldFlags.Child))
|
||||
{
|
||||
Item parentItem = GetItemByGuid(pSrcItem.GetGuidValue(ItemFields.Creator));
|
||||
Item parentItem = GetItemByGuid(pSrcItem.m_itemData.Creator);
|
||||
if (parentItem)
|
||||
{
|
||||
if (IsEquipmentPos(src))
|
||||
@@ -2136,9 +2119,9 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pDstItem && pDstItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child))
|
||||
else if (pDstItem && pDstItem.HasItemFlag(ItemFieldFlags.Child))
|
||||
{
|
||||
Item parentItem = GetItemByGuid(pDstItem.GetGuidValue(ItemFields.Creator));
|
||||
Item parentItem = GetItemByGuid(pDstItem.m_itemData.Creator);
|
||||
if (parentItem)
|
||||
{
|
||||
if (IsEquipmentPos(dst))
|
||||
@@ -2529,7 +2512,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantment.GenerateItemRandomPropertyId(item), null, 0, crItem.BonusListIDs, false) : EquipNewItem(uiDest, item, true);
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(item), null, 0, crItem.BonusListIDs, false) : EquipNewItem(uiDest, item, true);
|
||||
if (it != null)
|
||||
{
|
||||
uint new_count = pVendor.UpdateVendorItemCurrentCount(crItem, count);
|
||||
@@ -2548,7 +2531,7 @@ namespace Game.Entities
|
||||
|
||||
if (pProto.GetFlags().HasAnyFlag(ItemFlags.ItemPurchaseRecord) && crItem.ExtendedCost != 0 && pProto.GetMaxStackSize() == 1)
|
||||
{
|
||||
it.SetFlag(ItemFields.Flags, ItemFieldFlags.Refundable);
|
||||
it.AddItemFlag(ItemFieldFlags.Refundable);
|
||||
it.SetRefundRecipient(GetGUID());
|
||||
it.SetPaidMoney((uint)price);
|
||||
it.SetPaidExtendedCost(crItem.ExtendedCost);
|
||||
@@ -2604,7 +2587,7 @@ namespace Game.Entities
|
||||
}
|
||||
void AddItemDurations(Item item)
|
||||
{
|
||||
if (item.GetUInt32Value(ItemFields.Duration) != 0)
|
||||
if (item.m_itemData.Expiration != 0)
|
||||
{
|
||||
m_itemDuration.Add(item);
|
||||
item.SendTimeUpdate(this);
|
||||
@@ -3399,7 +3382,7 @@ namespace Game.Entities
|
||||
// if current back slot non-empty search oldest or free
|
||||
if (m_items[slot] != null)
|
||||
{
|
||||
uint oldest_time = GetUInt32Value(ActivePlayerFields.BuyBackTimestamp);
|
||||
uint oldest_time = m_activePlayerData.BuybackTimestamp[0];
|
||||
uint oldest_slot = InventorySlots.BuyBackStart;
|
||||
|
||||
for (byte i = InventorySlots.BuyBackStart + 1; i < InventorySlots.BuyBackEnd; ++i)
|
||||
@@ -3411,7 +3394,7 @@ namespace Game.Entities
|
||||
break;
|
||||
}
|
||||
|
||||
uint i_time = GetUInt32Value(ActivePlayerFields.BuyBackTimestamp + i - InventorySlots.BuyBackStart);
|
||||
uint i_time = m_activePlayerData.BuybackTimestamp[i - InventorySlots.BuyBackStart];
|
||||
|
||||
if (oldest_time > i_time)
|
||||
{
|
||||
@@ -3430,15 +3413,16 @@ namespace Game.Entities
|
||||
m_items[slot] = pItem;
|
||||
var time = Time.UnixTime;
|
||||
uint etime = (uint)(time - m_logintime + (30 * 3600));
|
||||
int eslot = (int)slot - InventorySlots.BuyBackStart;
|
||||
uint eslot = slot - InventorySlots.BuyBackStart;
|
||||
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + ((int)slot * 4), pItem.GetGUID());
|
||||
SetInvSlot(slot, pItem.GetGUID());
|
||||
ItemTemplate proto = pItem.GetTemplate();
|
||||
if (proto != null)
|
||||
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, proto.GetSellPrice() * pItem.GetCount());
|
||||
SetBuybackPrice(eslot, proto.GetSellPrice() * pItem.GetCount());
|
||||
else
|
||||
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, 0);
|
||||
SetUInt32Value(ActivePlayerFields.BuyBackTimestamp + eslot, etime);
|
||||
SetBuybackPrice(eslot, 0);
|
||||
|
||||
SetBuybackTimestamp(eslot, etime);
|
||||
|
||||
// move to next (for non filled list is move most optimized choice)
|
||||
if (m_currentBuybackSlot < InventorySlots.BuyBackEnd - 1)
|
||||
@@ -3462,7 +3446,7 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
Creature creature = GetNPCIfCanInteractWith(vendorGuid, NPCFlags.Vendor);
|
||||
Creature creature = GetNPCIfCanInteractWith(vendorGuid, NPCFlags.Vendor, NPCFlags2.None);
|
||||
if (!creature)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: BuyCurrencyFromVendorSlot - {0} not found or you can't interact with him.", vendorGuid.ToString());
|
||||
@@ -3629,7 +3613,7 @@ namespace Game.Entities
|
||||
if (!IsGameMaster() && ((pProto.GetFlags2().HasAnyFlag(ItemFlags2.FactionHorde) && GetTeam() == Team.Alliance) || (pProto.GetFlags2().HasAnyFlag(ItemFlags2.FactionAlliance) && GetTeam() == Team.Horde)))
|
||||
return false;
|
||||
|
||||
Creature creature = GetNPCIfCanInteractWith(vendorguid, NPCFlags.Vendor);
|
||||
Creature creature = GetNPCIfCanInteractWith(vendorguid, NPCFlags.Vendor, NPCFlags2.None);
|
||||
if (!creature)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: BuyItemFromVendor - {0} not found or you can't interact with him.", vendorguid.ToString());
|
||||
@@ -3866,6 +3850,8 @@ namespace Game.Entities
|
||||
draft.SendMailTo(trans, new MailReceiver(this, GetGUID().GetCounter()), sender);
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
}
|
||||
public void SetBuybackPrice(uint slot, uint price) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BuybackPrice, (int)slot), price); }
|
||||
public void SetBuybackTimestamp(uint slot, uint timestamp) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BuybackTimestamp, (int)slot), timestamp); }
|
||||
|
||||
public Item GetItemFromBuyBackSlot(uint slot)
|
||||
{
|
||||
@@ -3889,10 +3875,10 @@ namespace Game.Entities
|
||||
|
||||
m_items[slot] = null;
|
||||
|
||||
int eslot = (int)slot - InventorySlots.BuyBackStart;
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + (int)(slot * 4), ObjectGuid.Empty);
|
||||
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, 0);
|
||||
SetUInt32Value(ActivePlayerFields.BuyBackTimestamp + eslot, 0);
|
||||
uint eslot = slot - InventorySlots.BuyBackStart;
|
||||
SetInvSlot(slot, ObjectGuid.Empty);
|
||||
SetBuybackPrice(eslot, 0);
|
||||
SetBuybackTimestamp(eslot, 0);
|
||||
|
||||
// if current backslot is filled set to now free slot
|
||||
if (m_items[m_currentBuybackSlot])
|
||||
@@ -4268,7 +4254,7 @@ namespace Game.Entities
|
||||
&& Global.DB2Mgr.GetHeirloomByItemId(item.GetEntry()) != null)
|
||||
continue;
|
||||
|
||||
if (spellData.ChrSpecializationID != 0 && spellData.ChrSpecializationID != GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (spellData.ChrSpecializationID != 0 && spellData.ChrSpecializationID != GetPrimarySpecialization())
|
||||
continue;
|
||||
|
||||
ApplyEquipSpell(spellproto, item, apply, formChange);
|
||||
@@ -4559,10 +4545,10 @@ namespace Game.Entities
|
||||
if (pSrcItem.IsNotEmptyBag() && !IsBagPos((ushort)((ushort)bag << 8 | slot)))
|
||||
return InventoryResult.DestroyNonemptyBag;
|
||||
|
||||
if (pSrcItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child) && !IsEquipmentPos(bag, slot) && !IsChildEquipmentPos(bag, slot))
|
||||
if (pSrcItem.HasItemFlag(ItemFieldFlags.Child) && !IsEquipmentPos(bag, slot) && !IsChildEquipmentPos(bag, slot))
|
||||
return InventoryResult.WrongBagType3;
|
||||
|
||||
if (!pSrcItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child) && IsChildEquipmentPos(bag, slot))
|
||||
if (!pSrcItem.HasItemFlag(ItemFieldFlags.Child) && IsChildEquipmentPos(bag, slot))
|
||||
return InventoryResult.WrongBagType3;
|
||||
}
|
||||
|
||||
@@ -4655,7 +4641,7 @@ namespace Game.Entities
|
||||
// in case trade we already have item in other player inventory
|
||||
pLastItem.SetState(in_characterInventoryDB ? ItemUpdateState.Changed : ItemUpdateState.New, this);
|
||||
|
||||
if (pLastItem.HasFlag(ItemFields.Flags, ItemFieldFlags.BopTradeable))
|
||||
if (pLastItem.HasItemFlag(ItemFieldFlags.BopTradeable))
|
||||
AddTradeableItem(pLastItem);
|
||||
}
|
||||
}
|
||||
@@ -4903,7 +4889,7 @@ namespace Game.Entities
|
||||
if (pSrcItem.IsNotEmptyBag())
|
||||
return InventoryResult.DestroyNonemptyBag;
|
||||
|
||||
if (pSrcItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Child))
|
||||
if (pSrcItem.HasItemFlag(ItemFieldFlags.Child))
|
||||
return InventoryResult.WrongBagType3;
|
||||
}
|
||||
|
||||
@@ -5305,7 +5291,7 @@ namespace Game.Entities
|
||||
return res;
|
||||
|
||||
// check unique-equipped on gems
|
||||
foreach (ItemDynamicFieldGems gemData in pItem.GetGems())
|
||||
foreach (SocketedGem gemData in pItem.m_itemData.Gems)
|
||||
{
|
||||
ItemTemplate pGem = Global.ObjectMgr.GetItemTemplate(gemData.ItemId);
|
||||
if (pGem == null)
|
||||
@@ -5400,7 +5386,7 @@ namespace Game.Entities
|
||||
//Artifact
|
||||
void ApplyArtifactPowers(Item item, bool apply)
|
||||
{
|
||||
foreach (ItemDynamicFieldArtifactPowers artifactPower in item.GetArtifactPowers())
|
||||
foreach (ArtifactPower artifactPower in item.m_itemData.ArtifactPowers)
|
||||
{
|
||||
byte rank = artifactPower.CurrentRankWithBonus;
|
||||
if (rank == 0)
|
||||
@@ -5573,16 +5559,18 @@ namespace Game.Entities
|
||||
//Visual
|
||||
public void SetVisibleItemSlot(uint slot, Item pItem)
|
||||
{
|
||||
var itemField = m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.VisibleItems, (int)slot);
|
||||
if (pItem != null)
|
||||
{
|
||||
SetUInt32Value(PlayerFields.VisibleItem + (int)(slot * 2), pItem.GetVisibleEntry(this));
|
||||
SetUInt16Value(PlayerFields.VisibleItem + 1 + (int)(slot * 2), 0, pItem.GetVisibleAppearanceModId(this));
|
||||
SetUInt16Value(PlayerFields.VisibleItem + 1 + (int)(slot * 2), 1, pItem.GetVisibleItemVisual(this));
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemID), pItem.GetVisibleEntry(this));
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemAppearanceModID), pItem.GetVisibleAppearanceModId(this));
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemVisual), pItem.GetVisibleItemVisual(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetUInt32Value(PlayerFields.VisibleItem + (int)(slot * 2), 0);
|
||||
SetUInt32Value(PlayerFields.VisibleItem + 1 + (int)(slot * 2), 0);
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemID), 0u);
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemAppearanceModID), (ushort)0);
|
||||
SetUpdateFieldValue(itemField.ModifyValue(itemField.ItemVisual), (ushort)0);
|
||||
}
|
||||
}
|
||||
void VisualizeItem(uint slot, Item pItem)
|
||||
@@ -5601,9 +5589,9 @@ namespace Game.Entities
|
||||
Log.outDebug(LogFilter.Player, "STORAGE: EquipItem slot = {0}, item = {1}", slot, pItem.GetEntry());
|
||||
|
||||
m_items[slot] = pItem;
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + (int)(slot * 4), pItem.GetGUID());
|
||||
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
|
||||
pItem.SetGuidValue(ItemFields.Owner, GetGUID());
|
||||
SetInvSlot(slot, pItem.GetGUID());
|
||||
pItem.SetContainedIn(GetGUID());
|
||||
pItem.SetOwnerGUID(GetGUID());
|
||||
pItem.SetSlot((byte)slot);
|
||||
pItem.SetContainer(null);
|
||||
|
||||
@@ -5625,7 +5613,7 @@ namespace Game.Entities
|
||||
for (byte i = 0; i < ItemConst.MaxBagSize; ++i)
|
||||
DestroyItem(slot, i, update);
|
||||
|
||||
if (pItem.HasFlag(ItemFields.Flags, ItemFieldFlags.Wrapped))
|
||||
if (pItem.HasItemFlag(ItemFieldFlags.Wrapped))
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GIFT);
|
||||
stmt.AddValue(0, pItem.GetGUID().GetCounter());
|
||||
@@ -5645,7 +5633,7 @@ namespace Game.Entities
|
||||
Bag pBag;
|
||||
if (bag == InventorySlots.Bag0)
|
||||
{
|
||||
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
|
||||
SetInvSlot(slot, ObjectGuid.Empty);
|
||||
|
||||
// equipment and equipped bags can have applied bonuses
|
||||
if (slot < InventorySlots.BagEnd)
|
||||
@@ -5699,7 +5687,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
//pItem.SetOwnerGUID(ObjectGuid.Empty);
|
||||
pItem.SetGuidValue(ItemFields.Contained, ObjectGuid.Empty);
|
||||
pItem.SetContainedIn(ObjectGuid.Empty);
|
||||
pItem.SetSlot(ItemConst.NullSlot);
|
||||
pItem.SetState(ItemUpdateState.Removed, this);
|
||||
}
|
||||
@@ -6010,12 +5998,12 @@ namespace Game.Entities
|
||||
continue;
|
||||
}
|
||||
|
||||
Item pItem = StoreNewItem(dest, lootItem.itemid, true, lootItem.randomPropertyId, null, lootItem.context, lootItem.BonusListIDs);
|
||||
Item pItem = StoreNewItem(dest, lootItem.itemid, true, lootItem.randomBonusListId, null, lootItem.context, lootItem.BonusListIDs);
|
||||
SendNewItem(pItem, lootItem.count, false, false, broadcast);
|
||||
}
|
||||
}
|
||||
|
||||
public byte GetInventorySlotCount() { return GetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots); }
|
||||
public byte GetInventorySlotCount() { return m_activePlayerData.NumBackpackSlots; }
|
||||
public void SetInventorySlotCount(byte slots)
|
||||
{
|
||||
//ASSERT(slots <= (INVENTORY_SLOT_ITEM_END - INVENTORY_SLOT_ITEM_START));
|
||||
@@ -6058,15 +6046,15 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
SetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots, slots);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumBackpackSlots), slots);
|
||||
}
|
||||
|
||||
public byte GetBankBagSlotCount() { return GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetBankBagSlots); }
|
||||
public void SetBankBagSlotCount(byte count) { SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetBankBagSlots, count); }
|
||||
public byte GetBankBagSlotCount() { return m_activePlayerData.NumBankSlots; }
|
||||
public void SetBankBagSlotCount(byte count) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumBankSlots), count); }
|
||||
|
||||
//Loot
|
||||
public ObjectGuid GetLootGUID() { return GetGuidValue(PlayerFields.LootTargetGuid); }
|
||||
public void SetLootGUID(ObjectGuid guid) { SetGuidValue(PlayerFields.LootTargetGuid, guid); }
|
||||
public ObjectGuid GetLootGUID() { return m_playerData.LootTargetGUID; }
|
||||
public void SetLootGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.LootTargetGUID), guid); }
|
||||
public void StoreLootItem(byte lootSlot, Loot loot, AELootResult aeResult = null)
|
||||
{
|
||||
NotNormalLootItem qitem = null;
|
||||
@@ -6104,7 +6092,7 @@ namespace Game.Entities
|
||||
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
|
||||
if (msg == InventoryResult.Ok)
|
||||
{
|
||||
Item newitem = StoreNewItem(dest, item.itemid, true, item.randomPropertyId, item.GetAllowedLooters(), item.context, item.BonusListIDs);
|
||||
Item newitem = StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs);
|
||||
if (qitem != null)
|
||||
{
|
||||
qitem.is_looted = true;
|
||||
@@ -6196,7 +6184,7 @@ namespace Game.Entities
|
||||
return;
|
||||
|
||||
// Now we must make bones lootable, and send player loot
|
||||
bones.SetFlag(CorpseFields.DynamicFlags, 0x01);
|
||||
bones.AddCorpseDynamicFlag(CorpseDynFlags.Lootable);
|
||||
|
||||
// We store the level of our player in the gold field
|
||||
// We retrieve this information at Player.SendLoot()
|
||||
@@ -6571,7 +6559,7 @@ namespace Game.Entities
|
||||
SendLootError(loot.GetGUID(), guid, LootError.DidntKill);
|
||||
|
||||
if (loot_type == LootType.Corpse && !guid.IsItem())
|
||||
SetFlag(UnitFields.Flags, UnitFlags.Looting);
|
||||
AddUnitFlag(UnitFlags.Looting);
|
||||
}
|
||||
|
||||
public void SendLootError(ObjectGuid lootObj, ObjectGuid owner, LootError error)
|
||||
@@ -6663,9 +6651,9 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
//Void Storage
|
||||
public bool IsVoidStorageUnlocked() { return HasFlag(PlayerFields.Flags, PlayerFlags.VoidUnlocked); }
|
||||
public void UnlockVoidStorage() { SetFlag(PlayerFields.Flags, PlayerFlags.VoidUnlocked); }
|
||||
public void LockVoidStorage() { RemoveFlag(PlayerFields.Flags, PlayerFlags.VoidUnlocked); }
|
||||
public bool IsVoidStorageUnlocked() { return HasPlayerFlag(PlayerFlags.VoidUnlocked); }
|
||||
public void UnlockVoidStorage() { AddPlayerFlag(PlayerFlags.VoidUnlocked); }
|
||||
public void LockVoidStorage() { RemovePlayerFlag(PlayerFlags.VoidUnlocked); }
|
||||
|
||||
public byte GetNextVoidStorageFreeSlot()
|
||||
{
|
||||
|
||||
@@ -125,13 +125,13 @@ namespace Game.Entities
|
||||
pvpInfo.IsInNoPvPArea = false;
|
||||
if (area != null && area.IsSanctuary()) // in sanctuary
|
||||
{
|
||||
SetByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.Sanctuary);
|
||||
AddPvpFlag(UnitPVPStateFlags.Sanctuary);
|
||||
pvpInfo.IsInNoPvPArea = true;
|
||||
if (duel == null)
|
||||
CombatStopWithPets();
|
||||
}
|
||||
else
|
||||
RemoveByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.Sanctuary);
|
||||
RemovePvpFlag(UnitPVPStateFlags.Sanctuary);
|
||||
|
||||
AreaFlags areaRestFlag = (GetTeam() == Team.Alliance) ? AreaFlags.RestZoneAlliance : AreaFlags.RestZoneHorde;
|
||||
if (area != null && area.Flags[0].HasAnyFlag(areaRestFlag))
|
||||
|
||||
@@ -46,16 +46,15 @@ namespace Game.Entities
|
||||
if (m_lastHonorUpdateTime >= yesterday)
|
||||
{
|
||||
// this is the first update today, reset today's contribution
|
||||
ushort killsToday = GetUInt16Value(ActivePlayerFields.Kills, 0);
|
||||
SetUInt16Value(ActivePlayerFields.Kills, 0, 0);
|
||||
SetUInt16Value(ActivePlayerFields.Kills, 1, killsToday);
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.YesterdayHonorableKills), m_activePlayerData.TodayHonorableKills);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no honor/kills yesterday or today, reset
|
||||
SetUInt32Value(ActivePlayerFields.Kills, 0);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.YesterdayHonorableKills), (ushort)0);
|
||||
}
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.TodayHonorableKills), (ushort)0);
|
||||
}
|
||||
|
||||
m_lastHonorUpdateTime = now;
|
||||
@@ -116,7 +115,8 @@ namespace Game.Entities
|
||||
// [15..28] Horde honor titles and player name
|
||||
// [29..38] Other title and player name
|
||||
// [39+] Nothing
|
||||
uint victim_title = victim.GetUInt32Value(PlayerFields.ChosenTitle);
|
||||
// this is all wrong, should be going off PvpTitle, not PlayerTitle
|
||||
uint victim_title = plrVictim.m_playerData.PlayerTitle;
|
||||
// Get Killer titles, CharTitlesEntry.bit_index
|
||||
// Ranks:
|
||||
// title[1..14] . rank[5..18]
|
||||
@@ -134,9 +134,9 @@ namespace Game.Entities
|
||||
honor_f = (float)Math.Ceiling(Formulas.hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
|
||||
|
||||
// count the number of playerkills in one day
|
||||
ApplyModUInt16Value(ActivePlayerFields.Kills, 0, 1, true);
|
||||
ApplyModUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.TodayHonorableKills), (ushort)1, true);
|
||||
// and those in a lifetime
|
||||
ApplyModUInt32Value(ActivePlayerFields.LifetimeHonorableKills, 1, true);
|
||||
ApplyModUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LifetimeHonorableKills), 1u, true);
|
||||
UpdateCriteria(CriteriaTypes.EarnHonorableKill);
|
||||
UpdateCriteria(CriteriaTypes.HkClass, (uint)victim.GetClass());
|
||||
UpdateCriteria(CriteriaTypes.HkRace, (uint)victim.GetRace());
|
||||
@@ -215,9 +215,16 @@ namespace Game.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ResetHonorStats()
|
||||
{
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.TodayHonorableKills), (ushort)0);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.YesterdayHonorableKills), (ushort)0);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LifetimeHonorableKills), 0u);
|
||||
}
|
||||
|
||||
void _InitHonorLevelOnLoadFromDB(uint honor, uint honorLevel)
|
||||
{
|
||||
SetUInt32Value(PlayerFields.HonorLevel, honorLevel);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.HonorLevel), honorLevel);
|
||||
UpdateHonorNextLevel();
|
||||
|
||||
AddHonorXP(honor);
|
||||
@@ -250,8 +257,8 @@ namespace Game.Entities
|
||||
|
||||
public void AddHonorXP(uint xp)
|
||||
{
|
||||
uint currentHonorXP = GetUInt32Value(ActivePlayerFields.Honor);
|
||||
uint nextHonorLevelXP = GetUInt32Value(ActivePlayerFields.HonorNextLevel);
|
||||
uint currentHonorXP = m_activePlayerData.Honor;
|
||||
uint nextHonorLevelXP = m_activePlayerData.HonorNextLevel;
|
||||
uint newHonorXP = currentHonorXP + xp;
|
||||
uint honorLevel = GetHonorLevel();
|
||||
|
||||
@@ -266,10 +273,10 @@ namespace Game.Entities
|
||||
SetHonorLevel((byte)(honorLevel + 1));
|
||||
|
||||
honorLevel = GetHonorLevel();
|
||||
nextHonorLevelXP = GetUInt32Value(ActivePlayerFields.HonorNextLevel);
|
||||
nextHonorLevelXP = m_activePlayerData.HonorNextLevel;
|
||||
}
|
||||
|
||||
SetUInt32Value(ActivePlayerFields.Honor, IsMaxHonorLevel() ? 0 : newHonorXP);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Honor), IsMaxHonorLevel() ? 0 : newHonorXP);
|
||||
}
|
||||
|
||||
void SetHonorLevel(byte level)
|
||||
@@ -278,7 +285,7 @@ namespace Game.Entities
|
||||
if (level == oldHonorLevel)
|
||||
return;
|
||||
|
||||
SetUInt32Value(PlayerFields.HonorLevel, level);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.HonorLevel), level);
|
||||
UpdateHonorNextLevel();
|
||||
|
||||
UpdateCriteria(CriteriaTypes.HonorLevelReached);
|
||||
@@ -289,10 +296,10 @@ namespace Game.Entities
|
||||
// 5500 at honor level 1
|
||||
// no idea what between here
|
||||
// 8800 at honor level ~14 (never goes above 8800)
|
||||
SetUInt32Value(ActivePlayerFields.HonorNextLevel, 8800);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.HonorNextLevel), 8800u);
|
||||
}
|
||||
|
||||
public uint GetHonorLevel() { return GetUInt32Value(PlayerFields.HonorLevel); }
|
||||
public uint GetHonorLevel() { return m_playerData.HonorLevel; }
|
||||
public bool IsMaxHonorLevel() { return GetHonorLevel() == PlayerConst.MaxHonorLevel; }
|
||||
|
||||
public void ActivatePvpItemLevels(bool activate) { _usePvpItemLevels = activate; }
|
||||
@@ -329,7 +336,7 @@ namespace Game.Entities
|
||||
if (talentInfo == null)
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.SpecID != GetInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (talentInfo.SpecID != GetPrimarySpecialization())
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.LevelRequired > getLevel())
|
||||
@@ -350,7 +357,7 @@ namespace Game.Entities
|
||||
PvpTalentRecord talent = CliDB.PvpTalentStorage.LookupByKey(GetPvpTalentMap(GetActiveTalentGroup())[slot]);
|
||||
if (talent != null)
|
||||
{
|
||||
if (!HasFlag(PlayerFields.Flags, PlayerFlags.Resting) && !HasFlag(UnitFields.Flags2, UnitFlags2.AllowChangingTalents))
|
||||
if (!HasPlayerFlag(PlayerFlags.Resting) && !HasUnitFlag2(UnitFlags2.AllowChangingTalents))
|
||||
return TalentLearnResult.FailedRestArea;
|
||||
|
||||
if (GetSpellHistory().HasCooldown(talent.SpellID))
|
||||
@@ -638,7 +645,7 @@ namespace Game.Entities
|
||||
if (gameobject)
|
||||
{
|
||||
FactionTemplateRecord playerFaction = GetFactionTemplateEntry();
|
||||
FactionTemplateRecord faction = CliDB.FactionTemplateStorage.LookupByKey(gameobject.GetUInt32Value(GameObjectFields.Faction));
|
||||
FactionTemplateRecord faction = CliDB.FactionTemplateStorage.LookupByKey(gameobject.GetFaction());
|
||||
|
||||
if (playerFaction != null && faction != null && !playerFaction.IsFriendlyTo(faction))
|
||||
return false;
|
||||
@@ -705,7 +712,7 @@ namespace Game.Entities
|
||||
public void SetBGTeam(Team team)
|
||||
{
|
||||
m_bgData.bgTeam = (uint)team;
|
||||
SetByteValue(PlayerFields.Bytes4, PlayerFieldOffsets.Bytes4OffsetArenaFaction, (byte)(team == Team.Alliance ? 1 : 0));
|
||||
SetArenaFaction((byte)(team == Team.Alliance ? 1 : 0));
|
||||
}
|
||||
|
||||
public Team GetBGTeam()
|
||||
@@ -871,7 +878,7 @@ namespace Game.Entities
|
||||
//Arenas
|
||||
public void SetArenaTeamInfoField(byte slot, ArenaTeamInfoType type, uint value)
|
||||
{
|
||||
SetUInt32Value(ActivePlayerFields.ArenaTeamInfo + (slot * (int)ArenaTeamInfoType.End) + (int)type, value);
|
||||
|
||||
}
|
||||
|
||||
public void SetInArenaTeam(uint ArenaTeamId, byte slot, byte type)
|
||||
@@ -914,11 +921,11 @@ namespace Game.Entities
|
||||
}
|
||||
while (result.NextRow());
|
||||
}
|
||||
public uint GetArenaTeamId(byte slot) { return GetUInt32Value(ActivePlayerFields.ArenaTeamInfo + (slot * (int)ArenaTeamInfoType.End) + (int)ArenaTeamInfoType.Id); }
|
||||
public uint GetArenaPersonalRating(byte slot) { return GetUInt32Value(ActivePlayerFields.ArenaTeamInfo + (slot * (int)ArenaTeamInfoType.End) + (int)ArenaTeamInfoType.PersonalRating); }
|
||||
public uint GetArenaTeamId(byte slot) { return 0; }
|
||||
public uint GetArenaPersonalRating(byte slot) { return m_activePlayerData.PvpInfo[slot].Rating; }
|
||||
public void SetArenaTeamIdInvited(uint ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
|
||||
public uint GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
|
||||
public uint GetRBGPersonalRating() { return 0; }
|
||||
public uint GetRBGPersonalRating() { return m_activePlayerData.PvpInfo[3].Rating; }
|
||||
|
||||
//OutdoorPVP
|
||||
public bool IsOutdoorPvPActive()
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Game.Entities
|
||||
|
||||
public void DailyReset()
|
||||
{
|
||||
foreach (uint questId in GetDynamicValues(ActivePlayerDynamicFields.DailyQuests))
|
||||
foreach (uint questId in m_activePlayerData.DailyQuestsCompleted)
|
||||
{
|
||||
uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(questId);
|
||||
if (questBit != 0)
|
||||
@@ -153,10 +153,10 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
DailyQuestsReset dailyQuestsReset = new DailyQuestsReset();
|
||||
dailyQuestsReset.Count = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests).Length;
|
||||
dailyQuestsReset.Count = m_activePlayerData.DailyQuestsCompleted.Size();
|
||||
SendPacket(dailyQuestsReset);
|
||||
|
||||
ClearDynamicValue(ActivePlayerDynamicFields.DailyQuests);
|
||||
ClearDynamicUpdateFieldValues(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.DailyQuestsCompleted));
|
||||
|
||||
m_DFQuests.Clear(); // Dungeon Finder Quests.
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Game.Entities
|
||||
switch (questGiver.GetTypeId())
|
||||
{
|
||||
case TypeId.Unit:
|
||||
return GetNPCIfCanInteractWith(questGiver.GetGUID(), NPCFlags.QuestGiver) != null;
|
||||
return GetNPCIfCanInteractWith(questGiver.GetGUID(), NPCFlags.QuestGiver, NPCFlags2.None) != null;
|
||||
case TypeId.GameObject:
|
||||
return GetGameObjectIfCanInteractWith(questGiver.GetGUID(), GameObjectTypes.QuestGiver) != null;
|
||||
case TypeId.Player:
|
||||
@@ -331,7 +331,7 @@ namespace Game.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.IsTypeId(TypeId.Unit) || source.HasFlag64(UnitFields.NpcFlags, NPCFlags.Gossip))
|
||||
if (!source.IsTypeId(TypeId.Unit) || source.ToUnit().HasNpcFlag(NPCFlags.Gossip))
|
||||
{
|
||||
if (quest.IsAutoAccept() && CanAddQuest(quest, true) && CanTakeQuest(quest, true))
|
||||
AddQuestAndCheckCompletion(quest, source);
|
||||
@@ -880,7 +880,7 @@ namespace Game.Entities
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemQuantity) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemQuantity, true, false);
|
||||
}
|
||||
}
|
||||
@@ -900,7 +900,7 @@ namespace Game.Entities
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemQuantity) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemQuantity, true, false);
|
||||
}
|
||||
}
|
||||
@@ -954,7 +954,7 @@ namespace Game.Entities
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, reward, quest.RewardChoiceItemCount[i]) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, reward, true, ItemEnchantment.GenerateItemRandomPropertyId(reward));
|
||||
Item item = StoreNewItem(dest, reward, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(reward));
|
||||
SendNewItem(item, quest.RewardChoiceItemCount[i], true, false);
|
||||
}
|
||||
}
|
||||
@@ -975,7 +975,7 @@ namespace Game.Entities
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemId, quest.RewardItemCount[i]) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, itemId, true, ItemEnchantment.GenerateItemRandomPropertyId(itemId));
|
||||
Item item = StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId));
|
||||
SendNewItem(item, quest.RewardItemCount[i], true, false);
|
||||
}
|
||||
else if (quest.IsDFQuest())
|
||||
@@ -1609,12 +1609,7 @@ namespace Game.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
var dailies = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests);
|
||||
foreach (var dailyQuestId in dailies)
|
||||
if (dailyQuestId == qInfo.Id)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return m_activePlayerData.DailyQuestsCompleted.FindIndex(qInfo.Id) == -1;
|
||||
}
|
||||
|
||||
public bool SatisfyQuestWeek(Quest qInfo, bool msg)
|
||||
@@ -1977,34 +1972,37 @@ namespace Game.Entities
|
||||
|
||||
public uint GetQuestSlotQuestId(ushort slot)
|
||||
{
|
||||
return GetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.Id);
|
||||
return m_playerData.QuestLog[slot].QuestID;
|
||||
}
|
||||
|
||||
public uint GetQuestSlotState(ushort slot, byte counter)
|
||||
{
|
||||
return GetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.State);
|
||||
return m_playerData.QuestLog[slot].StateFlags;
|
||||
}
|
||||
|
||||
public ushort GetQuestSlotCounter(ushort slot, byte counter)
|
||||
{
|
||||
if (counter < SharedConst.MaxQuestCounts)
|
||||
return GetUInt16Value(PlayerFields.QuestLog + slot * QuestSlotOffsets.Max + QuestSlotOffsets.Counts + counter /2, (byte)(counter % 2));
|
||||
return m_playerData.QuestLog[slot].ObjectiveProgress[counter];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public uint GetQuestSlotTime(ushort slot)
|
||||
{
|
||||
return GetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.Time);
|
||||
return m_playerData.QuestLog[slot].EndTime;
|
||||
}
|
||||
|
||||
public void SetQuestSlot(ushort slot, uint quest_id, uint timer = 0)
|
||||
{
|
||||
SetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.Id, quest_id);
|
||||
SetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.State, 0);
|
||||
for (int i = 0; i < SharedConst.MaxQuestCounts / 2; ++i)
|
||||
SetUInt32Value(PlayerFields.QuestLog + slot * QuestSlotOffsets.Max + QuestSlotOffsets.Counts + i, 0);
|
||||
SetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.Time, timer);
|
||||
var questLogField = m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.QuestLog, slot);
|
||||
SetUpdateFieldValue(questLogField.ModifyValue(questLogField.QuestID), quest_id);
|
||||
SetUpdateFieldValue(questLogField.ModifyValue(questLogField.StateFlags), 0u);
|
||||
|
||||
for (int i = 0; i < SharedConst.MaxQuestCounts; ++i)
|
||||
SetUpdateFieldValue(ref questLogField.ModifyValue(questLogField.ObjectiveProgress, i), (ushort)0);
|
||||
|
||||
SetUpdateFieldValue(questLogField.ModifyValue(questLogField.EndTime), timer);
|
||||
}
|
||||
|
||||
public void SetQuestSlotCounter(ushort slot, byte counter, ushort count)
|
||||
@@ -2012,22 +2010,24 @@ namespace Game.Entities
|
||||
if (counter >= SharedConst.MaxQuestCounts)
|
||||
return;
|
||||
|
||||
SetUInt16Value(PlayerFields.QuestLog + slot * QuestSlotOffsets.Max + QuestSlotOffsets.Counts + counter / 2, (byte)(counter % 2), count);
|
||||
SetUpdateFieldValue(ref m_playerData.ModifyValue(m_playerData.QuestLog, slot).ModifyValue((QuestLog questLogField) => questLogField.ObjectiveProgress, counter), count);
|
||||
}
|
||||
|
||||
public void SetQuestSlotState(ushort slot, QuestSlotStateMask state)
|
||||
{
|
||||
SetFlag(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.State, state);
|
||||
QuestLog questLogField = m_playerData.ModifyValue(m_playerData.QuestLog, slot);
|
||||
SetUpdateFieldFlagValue(questLogField.ModifyValue(questLogField.StateFlags), (uint)state);
|
||||
}
|
||||
|
||||
public void RemoveQuestSlotState(ushort slot, QuestSlotStateMask state)
|
||||
{
|
||||
RemoveFlag(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.State, state);
|
||||
QuestLog questLogField = m_playerData.ModifyValue(m_playerData.QuestLog, slot);
|
||||
RemoveUpdateFieldFlagValue(questLogField.ModifyValue(questLogField.StateFlags), (uint)state);
|
||||
}
|
||||
|
||||
public void SetQuestSlotTimer(ushort slot, uint timer)
|
||||
{
|
||||
SetUInt32Value(PlayerFields.QuestLog + (slot * QuestSlotOffsets.Max) + QuestSlotOffsets.Time, timer);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.QuestLog, slot).ModifyValue((QuestLog questLog) => questLog.EndTime), timer);
|
||||
}
|
||||
|
||||
void SetQuestCompletedBit(uint questBit, bool completed)
|
||||
@@ -2035,11 +2035,15 @@ namespace Game.Entities
|
||||
if (questBit == 0)
|
||||
return;
|
||||
|
||||
int fieldOffset = ((int)questBit - 1) >> 5;
|
||||
uint fieldOffset = (questBit - 1) >> 6;
|
||||
if (fieldOffset >= PlayerConst.QuestsCompletedBitsSize)
|
||||
return;
|
||||
|
||||
ApplyModFlag(ActivePlayerFields.QuestCompleted + fieldOffset, (uint)(1 << (((int)questBit - 1) & 31)), completed);
|
||||
ulong flag = 1ul << (((int)questBit - 1) & 63);
|
||||
if (completed)
|
||||
SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.QuestCompleted, (int)fieldOffset), flag);
|
||||
else
|
||||
RemoveUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.QuestCompleted, (int)fieldOffset), flag);
|
||||
}
|
||||
|
||||
public void AreaExploredOrEventHappens(uint questId)
|
||||
@@ -2885,7 +2889,7 @@ namespace Game.Entities
|
||||
if (!questgiver || questgiver.IsHostileTo(this))
|
||||
continue;
|
||||
|
||||
if (!questgiver.HasFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver))
|
||||
if (!questgiver.HasNpcFlag(NPCFlags.QuestGiver))
|
||||
continue;
|
||||
|
||||
response.QuestGiver.Add(new QuestGiverInfo(questgiver.GetGUID(), GetQuestDialogStatus(questgiver)));
|
||||
@@ -2978,7 +2982,7 @@ namespace Game.Entities
|
||||
continue;
|
||||
|
||||
// check if this unit requires quest specific flags
|
||||
if (!obj.HasFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick))
|
||||
if (!obj.HasNpcFlag(NPCFlags.SpellClick))
|
||||
continue;
|
||||
|
||||
var clickPair = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry());
|
||||
@@ -3014,7 +3018,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (!qQuest.IsDFQuest())
|
||||
{
|
||||
AddDynamicValue(ActivePlayerDynamicFields.DailyQuests, quest_id);
|
||||
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.DailyQuestsCompleted), quest_id);
|
||||
m_lastDailyQuestTime = Time.UnixTime; // last daily quest time
|
||||
m_DailyQuestChanged = true;
|
||||
|
||||
@@ -3030,21 +3034,7 @@ namespace Game.Entities
|
||||
|
||||
public bool IsDailyQuestDone(uint quest_id)
|
||||
{
|
||||
bool found = false;
|
||||
if (Global.ObjectMgr.GetQuestTemplate(quest_id) != null)
|
||||
{
|
||||
var dailies = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests);
|
||||
foreach (uint dailyQuestId in dailies)
|
||||
{
|
||||
if (dailyQuestId == quest_id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
return m_activePlayerData.DailyQuestsCompleted.FindIndex(quest_id) >= 0;
|
||||
}
|
||||
|
||||
void SetWeeklyQuestStatus(uint quest_id)
|
||||
|
||||
@@ -32,10 +32,11 @@ namespace Game.Entities
|
||||
void UpdateSkillsForLevel()
|
||||
{
|
||||
ushort maxSkill = GetMaxSkillValueForLevel();
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
foreach (var pair in mSkillStatus)
|
||||
{
|
||||
if (pair.Value.State == SkillState.Deleted)
|
||||
if (pair.Value.State == SkillState.Deleted || skillInfoField.SkillRank[pair.Value.Pos] == 0)
|
||||
continue;
|
||||
|
||||
uint pskill = pair.Key;
|
||||
@@ -43,36 +44,35 @@ namespace Game.Entities
|
||||
if (rcEntry == null)
|
||||
continue;
|
||||
|
||||
ushort field = (ushort)(pair.Value.Pos / 2);
|
||||
byte offset = (byte)(pair.Value.Pos & 1);
|
||||
|
||||
if (Global.SpellMgr.GetSkillRangeType(rcEntry) == SkillRangeType.Level)
|
||||
{
|
||||
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
|
||||
ushort max = skillInfoField.SkillMaxRank[pair.Value.Pos];
|
||||
|
||||
// update only level dependent max skill values
|
||||
if (max != 1)
|
||||
{
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, maxSkill);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, maxSkill);
|
||||
SetSkillRank(pair.Value.Pos, maxSkill);
|
||||
SetSkillMaxRank(pair.Value.Pos, maxSkill);
|
||||
if (pair.Value.State != SkillState.New)
|
||||
pair.Value.State = SkillState.Changed;
|
||||
}
|
||||
}
|
||||
|
||||
// Update level dependent skillline spells
|
||||
LearnSkillRewardedSpells(rcEntry.SkillID, GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset));
|
||||
LearnSkillRewardedSpells(rcEntry.SkillID, skillInfoField.SkillRank[pair.Value.Pos]);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSkillsToMaxSkillsForLevel()
|
||||
{
|
||||
foreach (var skill in mSkillStatus)
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
foreach (var pair in mSkillStatus)
|
||||
{
|
||||
if (skill.Value.State == SkillState.Deleted)
|
||||
if (pair.Value.State == SkillState.Deleted || skillInfoField.SkillRank[pair.Value.Pos] == 0)
|
||||
continue;
|
||||
|
||||
uint pskill = skill.Key;
|
||||
uint pskill = pair.Key;
|
||||
SkillRaceClassInfoRecord rcEntry = Global.DB2Mgr.GetSkillRaceClassInfo(pskill, GetRace(), GetClass());
|
||||
if (rcEntry == null)
|
||||
continue;
|
||||
@@ -83,16 +83,13 @@ namespace Game.Entities
|
||||
if (Global.SpellMgr.IsWeaponSkill(rcEntry.SkillID))
|
||||
continue;
|
||||
|
||||
ushort field = (ushort)(skill.Value.Pos / 2);
|
||||
byte offset = (byte)(skill.Value.Pos & 1);
|
||||
|
||||
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
|
||||
ushort max = skillInfoField.SkillMaxRank[pair.Value.Pos];
|
||||
if (max > 1)
|
||||
{
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, max);
|
||||
SetSkillRank(pair.Value.Pos, max);
|
||||
|
||||
if (skill.Value.State != SkillState.New)
|
||||
skill.Value.State = SkillState.Changed;
|
||||
if (pair.Value.State != SkillState.New)
|
||||
pair.Value.State = SkillState.Changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,16 +99,15 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
int result = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
|
||||
result += GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
|
||||
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
|
||||
int result = skillInfo.SkillRank[skillStatusData.Pos];
|
||||
result += skillInfo.SkillTempBonus[skillStatusData.Pos];
|
||||
result += skillInfo.SkillPermBonus[skillStatusData.Pos];
|
||||
return (ushort)(result < 0 ? 0 : result);
|
||||
}
|
||||
|
||||
@@ -120,16 +116,15 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
int result = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
|
||||
result += GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
|
||||
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
|
||||
int result = skillInfo.SkillMaxRank[skillStatusData.Pos];
|
||||
result += skillInfo.SkillTempBonus[skillStatusData.Pos];
|
||||
result += skillInfo.SkillPermBonus[skillStatusData.Pos];
|
||||
return (ushort)(result < 0 ? 0 : result);
|
||||
}
|
||||
|
||||
@@ -138,14 +133,13 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey((uint)skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
return GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
|
||||
return skillInfo.SkillRank[skillStatusData.Pos];
|
||||
}
|
||||
|
||||
public ushort GetSkillStep(SkillType skill)
|
||||
@@ -153,14 +147,16 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
return GetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset);
|
||||
return skillInfo.SkillStep[skillStatusData.Pos];
|
||||
}
|
||||
|
||||
public ushort GetPureMaxSkillValue(SkillType skill)
|
||||
@@ -168,14 +164,13 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
return GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
|
||||
return skillInfo.SkillMaxRank[skillStatusData.Pos];
|
||||
}
|
||||
|
||||
public ushort GetBaseSkillValue(SkillType skill)
|
||||
@@ -183,15 +178,14 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
var result = (int)GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
|
||||
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
|
||||
int result = skillInfo.SkillRank[skillStatusData.Pos];
|
||||
result += skillInfo.SkillPermBonus[skillStatusData.Pos];
|
||||
return (ushort)(result < 0 ? 0 : result);
|
||||
}
|
||||
|
||||
@@ -200,14 +194,13 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
return GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
|
||||
return skillInfo.SkillPermBonus[skillStatusData.Pos];
|
||||
}
|
||||
|
||||
public ushort GetSkillTempBonusValue(uint skill)
|
||||
@@ -215,19 +208,18 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return 0;
|
||||
|
||||
SkillInfo skillInfo = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skill);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfo.SkillRank[skillStatusData.Pos] == 0)
|
||||
return 0;
|
||||
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
|
||||
return GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
|
||||
return skillInfo.SkillTempBonus[skillStatusData.Pos];
|
||||
}
|
||||
|
||||
void InitializeSelfResurrectionSpells()
|
||||
{
|
||||
ClearDynamicValue(ActivePlayerDynamicFields.SelfResSpells);
|
||||
ClearSelfResSpell();
|
||||
|
||||
uint[] spells = new uint[3];
|
||||
|
||||
@@ -248,7 +240,7 @@ namespace Game.Entities
|
||||
|
||||
foreach (uint selfResSpell in spells)
|
||||
if (selfResSpell != 0)
|
||||
AddDynamicValue(ActivePlayerDynamicFields.SelfResSpells, selfResSpell);
|
||||
AddSelfResSpell(selfResSpell);
|
||||
}
|
||||
|
||||
public void PetSpellInitialize()
|
||||
@@ -294,7 +286,7 @@ namespace Game.Entities
|
||||
|
||||
public bool CanSeeSpellClickOn(Creature creature)
|
||||
{
|
||||
if (!creature.HasFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick))
|
||||
if (!creature.HasNpcFlag(NPCFlags.SpellClick))
|
||||
return false;
|
||||
|
||||
var clickPair = Global.ObjectMgr.GetSpellClickInfoMapBounds(creature.GetEntry());
|
||||
@@ -329,19 +321,21 @@ namespace Game.Entities
|
||||
return base.GetCastSpellInfo(spellInfo);
|
||||
}
|
||||
|
||||
void AddOverrideSpell(uint overridenSpellId, uint newSpellId)
|
||||
public void SetOverrideSpellsId(uint overrideSpellsId) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.OverrideSpellsID), overrideSpellsId); }
|
||||
|
||||
public void AddOverrideSpell(uint overridenSpellId, uint newSpellId)
|
||||
{
|
||||
m_overrideSpells.Add(overridenSpellId, newSpellId);
|
||||
}
|
||||
|
||||
void RemoveOverrideSpell(uint overridenSpellId, uint newSpellId)
|
||||
public void RemoveOverrideSpell(uint overridenSpellId, uint newSpellId)
|
||||
{
|
||||
m_overrideSpells.Remove(overridenSpellId, newSpellId);
|
||||
}
|
||||
|
||||
void LearnSpecializationSpells()
|
||||
{
|
||||
var specSpells = Global.DB2Mgr.GetSpecializationSpells(GetUInt32Value(PlayerFields.CurrentSpecId));
|
||||
var specSpells = Global.DB2Mgr.GetSpecializationSpells(GetPrimarySpecialization());
|
||||
if (specSpells != null)
|
||||
{
|
||||
for (int j = 0; j < specSpells.Count; ++j)
|
||||
@@ -406,6 +400,23 @@ namespace Game.Entities
|
||||
SendPacket(cooldowns);
|
||||
}
|
||||
|
||||
void InitializeSkillFields()
|
||||
{
|
||||
uint i = 0;
|
||||
foreach (SkillLineRecord skillLine in CliDB.SkillLineStorage.Values)
|
||||
{
|
||||
SkillRaceClassInfoRecord rcEntry = Global.DB2Mgr.GetSkillRaceClassInfo(skillLine.Id, GetRace(), GetClass());
|
||||
if (rcEntry != null)
|
||||
{
|
||||
SetSkillLineId(i, (ushort)skillLine.Id);
|
||||
SetSkillStartingRank(i, 1);
|
||||
mSkillStatus.Add(skillLine.Id, new SkillStatusData(i, SkillState.Unchanged));
|
||||
if (++i >= SkillConst.MaxPlayerSkills)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateSkillPro(SkillType skillId, int chance, uint step)
|
||||
{
|
||||
return UpdateSkillPro((uint)skillId, chance, step);
|
||||
@@ -431,11 +442,10 @@ namespace Game.Entities
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted)
|
||||
return false;
|
||||
|
||||
ushort field = (ushort)(skillStatusData.Pos / 2);
|
||||
byte offset = (byte)(skillStatusData.Pos & 1);
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
ushort value = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
|
||||
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
|
||||
ushort value = skillInfoField.SkillRank[skillStatusData.Pos];
|
||||
ushort max = skillInfoField.SkillMaxRank[skillStatusData.Pos];
|
||||
|
||||
if (max == 0 || value == 0 || value >= max)
|
||||
return false;
|
||||
@@ -450,7 +460,7 @@ namespace Game.Entities
|
||||
if (new_value > max)
|
||||
new_value = max;
|
||||
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, new_value);
|
||||
SetSkillRank(skillStatusData.Pos, new_value);
|
||||
if (skillStatusData.State != SkillState.New)
|
||||
skillStatusData.State = SkillState.Changed;
|
||||
|
||||
@@ -577,7 +587,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// Cogwheel gems dont have requirement data set in SpellItemEnchantment.dbc, but they do have it in Item-sparse.db2
|
||||
ItemDynamicFieldGems gem = item.GetGem((ushort)(slot - EnchantmentSlot.Sock1));
|
||||
SocketedGem gem = item.GetGem((ushort)(slot - EnchantmentSlot.Sock1));
|
||||
if (gem != null)
|
||||
{
|
||||
ItemTemplate gemTemplate = Global.ObjectMgr.GetItemTemplate(gem.ItemId);
|
||||
@@ -617,31 +627,7 @@ namespace Game.Entities
|
||||
if (enchant_spell_id != 0)
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
int basepoints = 0;
|
||||
// Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor)
|
||||
if (item.GetItemRandomPropertyId() < 0)
|
||||
{
|
||||
ItemRandomSuffixRecord item_rand = CliDB.ItemRandomSuffixStorage.LookupByKey(Math.Abs(item.GetItemRandomPropertyId()));
|
||||
if (item_rand != null)
|
||||
{
|
||||
// Search enchant_amount
|
||||
for (int k = 0; k < ItemConst.MaxItemRandomProperties; ++k)
|
||||
{
|
||||
if (item_rand.Enchantment[k] == enchant_id)
|
||||
{
|
||||
basepoints = (int)((item_rand.AllocationPct[k] * item.GetItemSuffixFactor()) / 10000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cast custom spell vs all equal basepoints got from enchant_amount
|
||||
if (basepoints != 0)
|
||||
CastCustomSpell(this, enchant_spell_id, basepoints, basepoints, basepoints, true, item);
|
||||
else
|
||||
CastSpell(this, enchant_spell_id, true, item);
|
||||
}
|
||||
CastSpell(this, enchant_spell_id, true, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(enchant_spell_id, item.GetGUID());
|
||||
}
|
||||
@@ -650,7 +636,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 ((m_unitData.MinItemLevel != 0 || m_unitData.MaxItemLevel != 0) && pEnchant.ScalingClassRestricted != 0)
|
||||
scalingClass = pEnchant.ScalingClassRestricted;
|
||||
|
||||
uint minLevel = ((uint)(pEnchant.Flags)).HasAnyFlag(0x20u) ? 1 : 60u;
|
||||
@@ -667,22 +653,7 @@ namespace Game.Entities
|
||||
enchant_amount = (uint)(pEnchant.EffectScalingPoints[s] * CliDB.GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
}
|
||||
|
||||
if (enchant_amount == 0)
|
||||
{
|
||||
ItemRandomSuffixRecord item_rand = CliDB.ItemRandomSuffixStorage.LookupByKey(Math.Abs(item.GetItemRandomPropertyId()));
|
||||
if (item_rand != null)
|
||||
{
|
||||
for (int k = 0; k < ItemConst.MaxItemRandomProperties; ++k)
|
||||
{
|
||||
if (item_rand.Enchantment[k] == enchant_id)
|
||||
{
|
||||
enchant_amount = (item_rand.AllocationPct[k] * item.GetItemSuffixFactor()) / 10000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enchant_amount = Math.Max(enchant_amount, 1u);
|
||||
HandleStatModifier((UnitMods)((uint)UnitMods.ResistanceStart + enchant_spell_id), UnitModifierType.TotalValue, enchant_amount, apply);
|
||||
break;
|
||||
case ItemEnchantmentType.Stat:
|
||||
@@ -690,7 +661,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 ((m_unitData.MinItemLevel != 0 || m_unitData.MaxItemLevel != 0) && pEnchant.ScalingClassRestricted != 0)
|
||||
scalingClass = pEnchant.ScalingClassRestricted;
|
||||
|
||||
uint minLevel = ((uint)(pEnchant.Flags)).HasAnyFlag(0x20u) ? 1 : 60u;
|
||||
@@ -707,21 +678,7 @@ namespace Game.Entities
|
||||
enchant_amount = (uint)(pEnchant.EffectScalingPoints[s] * CliDB.GetSpellScalingColumnForClass(spellScaling, scalingClass));
|
||||
}
|
||||
|
||||
if (enchant_amount == 0)
|
||||
{
|
||||
ItemRandomSuffixRecord item_rand_suffix = CliDB.ItemRandomSuffixStorage.LookupByKey(Math.Abs(item.GetItemRandomPropertyId()));
|
||||
if (item_rand_suffix != null)
|
||||
{
|
||||
for (int k = 0; k < ItemConst.MaxItemRandomProperties; ++k)
|
||||
{
|
||||
if (item_rand_suffix.Enchantment[k] == enchant_id)
|
||||
{
|
||||
enchant_amount = (item_rand_suffix.AllocationPct[k] * item.GetItemSuffixFactor()) / 10000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
enchant_amount = Math.Max(enchant_amount, 1u);
|
||||
|
||||
Log.outDebug(LogFilter.Player, "Adding {0} to stat nb {1}", enchant_amount, enchant_spell_id);
|
||||
switch ((ItemModType)enchant_spell_id)
|
||||
@@ -914,7 +871,9 @@ namespace Game.Entities
|
||||
|
||||
// visualize enchantment at player and equipped items
|
||||
if (slot == EnchantmentSlot.Perm)
|
||||
SetUInt16Value(PlayerFields.VisibleItem + 1 + (item.GetSlot() * 2), 1, item.GetVisibleItemVisual(this));
|
||||
{
|
||||
SetUpdateFieldValue(m_playerData.ModifyValue(m_playerData.VisibleItems, item.GetSlot()).ModifyValue((VisibleItem visibleItemField) => visibleItemField.ItemVisual), item.GetVisibleItemVisual(this));
|
||||
}
|
||||
|
||||
if (apply_dur)
|
||||
{
|
||||
@@ -935,16 +894,16 @@ namespace Game.Entities
|
||||
|
||||
public void ModifySkillBonus(SkillType skillid, int val, bool talent)
|
||||
{
|
||||
var skill = mSkillStatus.LookupByKey(skillid);
|
||||
if (skill == null || skill.State == SkillState.Deleted)
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey(skillid);
|
||||
if (skillStatusData == null || skillStatusData.State == SkillState.Deleted || skillInfoField.SkillRank[skillStatusData.Pos] == 0)
|
||||
return;
|
||||
|
||||
int field = (int)(skill.Pos / 2 + (talent ? ActivePlayerFields.SkillLinePermBonus : ActivePlayerFields.SkillLineTempBonus));
|
||||
byte offset = (byte)(skill.Pos & 1);
|
||||
|
||||
ushort bonus = GetUInt16Value(field, offset);
|
||||
|
||||
SetUInt16Value(field, offset, (ushort)(bonus + val));
|
||||
if (talent)
|
||||
SetSkillPermBonus(skillStatusData.Pos, (ushort)(skillInfoField.SkillPermBonus[skillStatusData.Pos] + val));
|
||||
else
|
||||
SetSkillTempBonus(skillStatusData.Pos, (ushort)(skillInfoField.SkillTempBonus[skillStatusData.Pos] + val));
|
||||
}
|
||||
|
||||
public void StopCastingBindSight()
|
||||
@@ -1091,7 +1050,7 @@ namespace Game.Entities
|
||||
|
||||
public bool CanUseMastery()
|
||||
{
|
||||
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetUInt32Value(PlayerFields.CurrentSpecId));
|
||||
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization());
|
||||
if (chrSpec != null)
|
||||
return HasSpell(chrSpec.MasterySpellID[0]) || HasSpell(chrSpec.MasterySpellID[1]);
|
||||
|
||||
@@ -1103,8 +1062,10 @@ namespace Game.Entities
|
||||
if (skill == 0)
|
||||
return false;
|
||||
|
||||
var _skill = mSkillStatus.LookupByKey((uint)skill);
|
||||
return _skill != null && _skill.State != SkillState.Deleted;
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
var skillStatusData = mSkillStatus.LookupByKey((uint)skill);
|
||||
return skillStatusData != null && skillStatusData.State != SkillState.Deleted && skillInfoField.SkillRank[skillStatusData.Pos] != 0;
|
||||
}
|
||||
public void SetSkill(SkillType skill, uint step, uint newVal, uint maxVal)
|
||||
{
|
||||
@@ -1117,13 +1078,12 @@ namespace Game.Entities
|
||||
|
||||
ushort currVal;
|
||||
var skillStatusData = mSkillStatus.LookupByKey(id);
|
||||
SkillInfo skillInfoField = m_activePlayerData.Skill;
|
||||
|
||||
//has skill
|
||||
if (skillStatusData != null && skillStatusData.State != SkillState.Deleted)
|
||||
{
|
||||
var field = (ushort)(skillStatusData.Pos / 2);
|
||||
var offset = (byte)(skillStatusData.Pos & 1);
|
||||
currVal = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
|
||||
currVal = skillInfoField.SkillRank[skillStatusData.Pos];
|
||||
if (newVal != 0)
|
||||
{
|
||||
// if skill value is going down, update enchantments before setting the new value
|
||||
@@ -1131,10 +1091,10 @@ namespace Game.Entities
|
||||
UpdateSkillEnchantments(id, currVal, (ushort)newVal);
|
||||
|
||||
// update step
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset, (ushort)step);
|
||||
SetSkillStep(skillStatusData.Pos, (ushort)step);
|
||||
// update value
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, (ushort)newVal);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, (ushort)maxVal);
|
||||
SetSkillRank(skillStatusData.Pos, (ushort)newVal);
|
||||
SetSkillMaxRank(skillStatusData.Pos, (ushort)maxVal);
|
||||
|
||||
if (skillStatusData.State != SkillState.New)
|
||||
skillStatusData.State = SkillState.Changed;
|
||||
@@ -1152,45 +1112,45 @@ namespace Game.Entities
|
||||
//remove enchantments needing this skill
|
||||
UpdateSkillEnchantments(id, currVal, 0);
|
||||
// clear skill fields
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineId + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset, 0);
|
||||
SetSkillStep(skillStatusData.Pos, 0);
|
||||
SetSkillRank(skillStatusData.Pos, 0);
|
||||
SetSkillStartingRank(skillStatusData.Pos, 1);
|
||||
SetSkillMaxRank(skillStatusData.Pos, 0);
|
||||
SetSkillTempBonus(skillStatusData.Pos, 0);
|
||||
SetSkillPermBonus(skillStatusData.Pos, 0);
|
||||
|
||||
// mark as deleted or simply remove from map if not saved yet
|
||||
if (skillStatusData.State != SkillState.New)
|
||||
skillStatusData.State = SkillState.Deleted;
|
||||
else
|
||||
mSkillStatus.Remove(id);
|
||||
|
||||
// remove all spells that related to this skill
|
||||
List<SkillLineAbilityRecord> skillLineAbilities = Global.DB2Mgr.GetSkillLineAbilitiesBySkill(id);
|
||||
foreach (SkillLineAbilityRecord skillLineAbility in skillLineAbilities)
|
||||
RemoveSpell(Global.SpellMgr.GetFirstSpellInChain(skillLineAbility.Spell));
|
||||
|
||||
foreach (SkillLineRecord childSkillLine in CliDB.SkillLineStorage.Values)
|
||||
List<SkillLineRecord> childSkillLines = Global.DB2Mgr.GetSkillLinesForParentSkill(id);
|
||||
if (childSkillLines != null)
|
||||
{
|
||||
if (childSkillLine.ParentSkillLineID == id)
|
||||
SetSkill(childSkillLine.Id, 0, 0, 0);
|
||||
foreach (SkillLineRecord childSkillLine in childSkillLines)
|
||||
{
|
||||
if (childSkillLine.ParentSkillLineID == id)
|
||||
SetSkill(childSkillLine.Id, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear profession lines
|
||||
if (GetUInt32Value(ActivePlayerFields.ProfessionSkillLine) == id)
|
||||
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine, 0);
|
||||
else if (GetUInt32Value(ActivePlayerFields.ProfessionSkillLine + 1) == id)
|
||||
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine + 1, 0);
|
||||
if (m_activePlayerData.ProfessionSkillLine[0] == id)
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ProfessionSkillLine, 0), 0u);
|
||||
else if (m_activePlayerData.ProfessionSkillLine[1] == id)
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ProfessionSkillLine, 1), 0u);
|
||||
}
|
||||
}
|
||||
else if (newVal != 0) //add
|
||||
else //add
|
||||
{
|
||||
currVal = 0;
|
||||
for (int i = 0; i < SkillConst.MaxPlayerSkills; ++i)
|
||||
for (uint i = 0; i < SkillConst.MaxPlayerSkills; ++i)
|
||||
{
|
||||
var field = (ushort)(i / 2);
|
||||
var offset = (byte)(i & 1);
|
||||
if (GetUInt16Value(ActivePlayerFields.SkillLineId + field, offset) == 0)
|
||||
if (skillInfoField.SkillLineID[(int)i] == 0)
|
||||
{
|
||||
var skillEntry = CliDB.SkillLineStorage.LookupByKey(id);
|
||||
if (skillEntry == null)
|
||||
@@ -1200,7 +1160,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
|
||||
if (skillEntry.ParentSkillLineID != 0 && skillEntry.ParentTierIndex > 0)
|
||||
if (skillEntry.ParentSkillLineID != 0)
|
||||
{
|
||||
SkillRaceClassInfoRecord rcEntry = Global.DB2Mgr.GetSkillRaceClassInfo(skillEntry.ParentSkillLineID, GetRace(), GetClass());
|
||||
if (rcEntry != null)
|
||||
@@ -1209,25 +1169,38 @@ namespace Game.Entities
|
||||
if (tier != null)
|
||||
{
|
||||
ushort skillval = GetPureSkillValue((SkillType)skillEntry.ParentSkillLineID);
|
||||
SetSkill((SkillType)skillEntry.ParentSkillLineID, (uint)skillEntry.ParentTierIndex, Math.Max(skillval, (ushort)1), tier.Value[skillEntry.ParentTierIndex - 1]);
|
||||
SetSkill(skillEntry.ParentSkillLineID, (uint)skillEntry.ParentTierIndex, Math.Max(skillval, (ushort)1), tier.Value[skillEntry.ParentTierIndex - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // also learn missing child skills at 0 value
|
||||
List<SkillLineRecord> childSkillLines = Global.DB2Mgr.GetSkillLinesForParentSkill(id);
|
||||
if (childSkillLines != null)
|
||||
foreach (SkillLineRecord childSkillLine in childSkillLines)
|
||||
if (!HasSkill((SkillType)childSkillLine.Id))
|
||||
SetSkill(childSkillLine.Id, 0, 0, 0);
|
||||
|
||||
if (skillEntry.CategoryID == SkillCategory.Profession)
|
||||
{
|
||||
int freeProfessionSlot = FindProfessionSlotFor(id);
|
||||
if (freeProfessionSlot != -1)
|
||||
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine + freeProfessionSlot, id);
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ProfessionSkillLine, freeProfessionSlot), id);
|
||||
}
|
||||
}
|
||||
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineId + field, offset, (ushort)id);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset, (ushort)step);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, (ushort)newVal);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, (ushort)maxVal);
|
||||
SetSkillLineId(i, (ushort)id);
|
||||
|
||||
SetSkillStep(i, (ushort)step);
|
||||
SetSkillRank(i, (ushort)newVal);
|
||||
SetSkillStartingRank(i, 1);
|
||||
SetSkillMaxRank(i, (ushort)maxVal);
|
||||
|
||||
// apply skill bonuses
|
||||
SetSkillTempBonus(i, 0);
|
||||
SetSkillPermBonus(i, 0);
|
||||
|
||||
UpdateSkillEnchantments(id, currVal, (ushort)newVal);
|
||||
UpdateCriteria(CriteriaTypes.ReachSkillLevel, id);
|
||||
UpdateCriteria(CriteriaTypes.LearnSkillLevel, id);
|
||||
|
||||
// insert new entry or update if not deleted old entry yet
|
||||
if (skillStatusData != null)
|
||||
@@ -1238,35 +1211,31 @@ namespace Game.Entities
|
||||
else
|
||||
mSkillStatus.Add(id, new SkillStatusData((uint)i, SkillState.New));
|
||||
|
||||
// apply skill bonuses
|
||||
SetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset, 0);
|
||||
SetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset, 0);
|
||||
|
||||
// temporary bonuses
|
||||
var mModSkill = GetAuraEffectsByType(AuraType.ModSkill);
|
||||
foreach (var j in mModSkill)
|
||||
if (newVal != 0)
|
||||
{
|
||||
if (j.GetMiscValue() == id)
|
||||
j.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
}
|
||||
UpdateCriteria(CriteriaTypes.ReachSkillLevel, id);
|
||||
UpdateCriteria(CriteriaTypes.LearnSkillLevel, id);
|
||||
|
||||
var mModSkill2 = GetAuraEffectsByType(AuraType.ModSkill2);
|
||||
foreach (var j in mModSkill2)
|
||||
{
|
||||
if (j.GetMiscValue() == id)
|
||||
j.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
}
|
||||
// temporary bonuses
|
||||
var mModSkill = GetAuraEffectsByType(AuraType.ModSkill);
|
||||
foreach (var auraEffect in mModSkill)
|
||||
if (auraEffect.GetMiscValue() == id)
|
||||
auraEffect.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
|
||||
// permanent bonuses
|
||||
var mModSkillTalent = GetAuraEffectsByType(AuraType.ModSkillTalent);
|
||||
foreach (var eff in mModSkillTalent)
|
||||
{
|
||||
if (eff.GetMiscValue() == id)
|
||||
eff.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
}
|
||||
var mModSkill2 = GetAuraEffectsByType(AuraType.ModSkill2);
|
||||
foreach (var auraEffect in mModSkill2)
|
||||
if (auraEffect.GetMiscValue() == id)
|
||||
auraEffect.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
|
||||
// Learn all spells for skill
|
||||
LearnSkillRewardedSpells(id, newVal);
|
||||
// permanent bonuses
|
||||
var mModSkillTalent = GetAuraEffectsByType(AuraType.ModSkillTalent);
|
||||
foreach (var auraEffect in mModSkillTalent)
|
||||
if (auraEffect.GetMiscValue() == id)
|
||||
auraEffect.HandleEffect(this, AuraEffectHandleModes.Skill, true);
|
||||
|
||||
// Learn all spells for skill
|
||||
LearnSkillRewardedSpells(id, newVal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1424,7 +1393,7 @@ namespace Game.Entities
|
||||
Item pItem2 = GetItemByPos(InventorySlots.Bag0, i);
|
||||
if (pItem2 != null && !pItem2.IsBroken())
|
||||
{
|
||||
foreach (ItemDynamicFieldGems gemData in pItem2.GetGems())
|
||||
foreach (SocketedGem gemData in pItem2.m_itemData.Gems)
|
||||
{
|
||||
ItemTemplate gemProto = Global.ObjectMgr.GetItemTemplate(gemData.ItemId);
|
||||
if (gemProto == null)
|
||||
@@ -1642,7 +1611,7 @@ namespace Game.Entities
|
||||
if (ability.AcquireMethod != AbilityLearnType.OnSkillValue && ability.AcquireMethod != AbilityLearnType.OnSkillLearn)
|
||||
continue;
|
||||
|
||||
// AcquireMethod == 2 && NumSkillUps == 1 --> automatically learn riding skill spell, else we skip it (client shows riding in spellbook as trainable).
|
||||
// AcquireMethod == 2 && NumSkillUps == 1 -. automatically learn riding skill spell, else we skip it (client shows riding in spellbook as trainable).
|
||||
if (skillId == (uint)SkillType.Riding && (ability.AcquireMethod != AbilityLearnType.OnSkillLearn || ability.NumSkillUps != 1))
|
||||
continue;
|
||||
|
||||
@@ -1676,39 +1645,15 @@ namespace Game.Entities
|
||||
if (skillEntry == null)
|
||||
return -1;
|
||||
|
||||
// both free, return first slot
|
||||
if (GetUInt32Value(ActivePlayerFields.ProfessionSkillLine) == 0 && GetUInt32Value(ActivePlayerFields.ProfessionSkillLine + 1) == 0)
|
||||
return 0;
|
||||
|
||||
ActivePlayerFields professionsBegin = ActivePlayerFields.ProfessionSkillLine;
|
||||
ActivePlayerFields professionsEnd = professionsBegin + 2;
|
||||
|
||||
// when any slot is filled we need to check both - one of them might be earlier step of the same profession
|
||||
ActivePlayerFields sameProfessionSlot = professionsEnd;
|
||||
for (var slot = professionsBegin; slot < professionsEnd; ++slot)
|
||||
{
|
||||
SkillLineRecord slotProfession = CliDB.SkillLineStorage.LookupByKey(GetUInt32Value(slot));
|
||||
if (slotProfession != null)
|
||||
{
|
||||
if (slotProfession.ParentSkillLineID == skillEntry.ParentSkillLineID)
|
||||
{
|
||||
sameProfessionSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sameProfessionSlot != professionsEnd)
|
||||
{
|
||||
if (CliDB.SkillLineStorage.LookupByKey(sameProfessionSlot).ParentTierIndex < skillEntry.ParentTierIndex)
|
||||
return sameProfessionSlot - professionsBegin;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
// if there is no same profession, find any free slot
|
||||
for (var slot = professionsBegin; slot < professionsEnd; ++slot)
|
||||
if (GetUInt32Value(slot) == 0)
|
||||
return slot - professionsBegin;
|
||||
foreach (var b in m_activePlayerData.ProfessionSkillLine)
|
||||
{
|
||||
if (b == 0)
|
||||
return index;
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -2288,7 +2233,7 @@ namespace Game.Entities
|
||||
|
||||
public bool IsCurrentSpecMasterySpell(SpellInfo spellInfo)
|
||||
{
|
||||
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetUInt32Value(PlayerFields.CurrentSpecId));
|
||||
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization());
|
||||
if (chrSpec != null)
|
||||
return spellInfo.Id == chrSpec.MasterySpellID[0] || spellInfo.Id == chrSpec.MasterySpellID[1];
|
||||
|
||||
@@ -3107,7 +3052,7 @@ namespace Game.Entities
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemSetSpell.SpellID);
|
||||
|
||||
if (itemSetSpell.ChrSpecID != 0 && itemSetSpell.ChrSpecID != GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (itemSetSpell.ChrSpecID != 0 && itemSetSpell.ChrSpecID != GetPrimarySpecialization())
|
||||
ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec
|
||||
else
|
||||
{
|
||||
@@ -3197,7 +3142,7 @@ namespace Game.Entities
|
||||
if (GetClass() != Class.Deathknight)
|
||||
return;
|
||||
|
||||
int runeIndex = (int)GetPowerIndex(PowerType.Runes);
|
||||
uint runeIndex = GetPowerIndex(PowerType.Runes);
|
||||
if (runeIndex == (int)PowerType.Max)
|
||||
return;
|
||||
|
||||
@@ -3208,8 +3153,8 @@ namespace Game.Entities
|
||||
SetRuneCooldown(i, 0); // reset cooldowns
|
||||
|
||||
// set a base regen timer equal to 10 sec
|
||||
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, 0.0f);
|
||||
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, 0.0f);
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.PowerRegenFlatModifier, (int)runeIndex), 0.0f);
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.PowerRegenInterruptedFlatModifier, (int)runeIndex), 0.0f);
|
||||
}
|
||||
|
||||
public void UpdateAllRunesRegen()
|
||||
@@ -3217,15 +3162,15 @@ namespace Game.Entities
|
||||
if (GetClass() != Class.Deathknight)
|
||||
return;
|
||||
|
||||
int runeIndex = (int)GetPowerIndex(PowerType.Runes);
|
||||
uint runeIndex = GetPowerIndex(PowerType.Runes);
|
||||
if (runeIndex == (int)PowerType.Max)
|
||||
return;
|
||||
|
||||
PowerTypeRecord runeEntry = Global.DB2Mgr.GetPowerTypeEntry(PowerType.Runes);
|
||||
|
||||
uint cooldown = GetRuneBaseCooldown();
|
||||
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / (float)cooldown - runeEntry.RegenPeace);
|
||||
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / (float)cooldown - runeEntry.RegenCombat);
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.PowerRegenFlatModifier, (int)runeIndex), (float)(1 * Time.InMilliseconds) / cooldown - runeEntry.RegenPeace);
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.PowerRegenInterruptedFlatModifier, (int)runeIndex), (float)(1 * Time.InMilliseconds) / cooldown - runeEntry.RegenCombat);
|
||||
}
|
||||
|
||||
public uint GetRuneCooldown(byte index) { return m_runes.Cooldown[index]; }
|
||||
@@ -3234,20 +3179,25 @@ namespace Game.Entities
|
||||
{
|
||||
// don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP
|
||||
if (spellInfo.HasAttribute(SpellAttr5.NoReagentWhilePrep) &&
|
||||
HasFlag(UnitFields.Flags, UnitFlags.Preparation))
|
||||
HasUnitFlag(UnitFlags.Preparation))
|
||||
return true;
|
||||
|
||||
// Check no reagent use mask
|
||||
FlagArray128 noReagentMask = new FlagArray128();
|
||||
noReagentMask[0] = GetUInt32Value(ActivePlayerFields.NoReagentCost);
|
||||
noReagentMask[1] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 1);
|
||||
noReagentMask[2] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 2);
|
||||
noReagentMask[3] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 3);
|
||||
noReagentMask[0] = m_activePlayerData.NoReagentCostMask[0];
|
||||
noReagentMask[1] = m_activePlayerData.NoReagentCostMask[1];
|
||||
noReagentMask[2] = m_activePlayerData.NoReagentCostMask[2];
|
||||
noReagentMask[3] = m_activePlayerData.NoReagentCostMask[3];
|
||||
if (spellInfo.SpellFamilyFlags & noReagentMask)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public void SetNoRegentCostMask(FlagArray128 mask)
|
||||
{
|
||||
for (byte i = 0; i < 4; ++i)
|
||||
SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NoReagentCostMask, i), mask[i]);
|
||||
}
|
||||
|
||||
public void CastItemCombatSpell(DamageInfo damageInfo)
|
||||
{
|
||||
@@ -3469,6 +3419,16 @@ namespace Game.Entities
|
||||
LearnCustomSpells();
|
||||
LearnQuestRewardedSpells();
|
||||
}
|
||||
|
||||
public void SetPetSpellPower(uint spellPower) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.PetSpellPower), spellPower); }
|
||||
|
||||
public void SetSkillLineId(uint pos, ushort skillLineId) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillLineID, (int)pos), skillLineId); }
|
||||
public void SetSkillStep(uint pos, ushort step) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillStep, (int)pos), step); }
|
||||
public void SetSkillRank(uint pos, ushort rank) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillRank, (int)pos), rank); }
|
||||
public void SetSkillStartingRank(uint pos, ushort starting) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillStartingRank, (int)pos), starting); }
|
||||
public void SetSkillMaxRank(uint pos, ushort max) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillMaxRank, (int)pos), max); }
|
||||
public void SetSkillTempBonus(uint pos, ushort bonus) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillTempBonus, (int)pos), bonus); }
|
||||
public void SetSkillPermBonus(uint pos, ushort bonus) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Skill)._value.ModifyValue((SkillInfo skillInfo) => skillInfo.SkillPermBonus, (int)pos), bonus); }
|
||||
}
|
||||
|
||||
public class PlayerSpell
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Game.Entities
|
||||
if (level < PlayerConst.MinSpecializationLevel)
|
||||
ResetTalentSpecialization();
|
||||
|
||||
uint talentTiers = (uint)Global.DB2Mgr.GetNumTalentsAtLevel(level, GetClass());
|
||||
uint talentTiers = Global.DB2Mgr.GetNumTalentsAtLevel(level, GetClass());
|
||||
if (level < 15)
|
||||
{
|
||||
// Remove all talent points
|
||||
@@ -50,7 +50,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
SetUInt32Value(ActivePlayerFields.MaxTalentTiers, talentTiers);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.MaxTalentTiers), talentTiers);
|
||||
|
||||
if (!GetSession().PlayerLoading())
|
||||
SendTalentsInfoData(); // update at client
|
||||
@@ -112,14 +112,14 @@ namespace Game.Entities
|
||||
if (IsDead())
|
||||
return TalentLearnResult.FailedCantDoThatRightNow;
|
||||
|
||||
if (GetUInt32Value(PlayerFields.CurrentSpecId) == 0)
|
||||
if (GetPrimarySpecialization() == 0)
|
||||
return TalentLearnResult.FailedNoPrimaryTreeSelected;
|
||||
|
||||
TalentRecord talentInfo = CliDB.TalentStorage.LookupByKey(talentId);
|
||||
if (talentInfo == null)
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
if (talentInfo.SpecID != 0 && talentInfo.SpecID != GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (talentInfo.SpecID != 0 && talentInfo.SpecID != GetPrimarySpecialization())
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
// prevent learn talent for different class (cheating)
|
||||
@@ -127,7 +127,7 @@ namespace Game.Entities
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
// check if we have enough talent points
|
||||
if (talentInfo.TierID >= GetUInt32Value(ActivePlayerFields.MaxTalentTiers))
|
||||
if (talentInfo.TierID >= m_activePlayerData.MaxTalentTiers)
|
||||
return TalentLearnResult.FailedUnknown;
|
||||
|
||||
// TODO: prevent changing talents that are on cooldown
|
||||
@@ -144,7 +144,7 @@ namespace Game.Entities
|
||||
if (talent.SpecID == 0)
|
||||
bestSlotMatch = talent;
|
||||
|
||||
else if (talent.SpecID == GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
else if (talent.SpecID == GetPrimarySpecialization())
|
||||
{
|
||||
bestSlotMatch = talent;
|
||||
break;
|
||||
@@ -159,13 +159,13 @@ namespace Game.Entities
|
||||
{
|
||||
foreach (TalentRecord talent in Global.DB2Mgr.GetTalentsByPosition(GetClass(), talentInfo.TierID, c))
|
||||
{
|
||||
if (talent.SpecID != 0 && talent.SpecID != GetUInt32Value(PlayerFields.CurrentSpecId))
|
||||
if (talent.SpecID != 0 && talent.SpecID != GetPrimarySpecialization())
|
||||
continue;
|
||||
|
||||
if (!HasTalent(talent.Id, GetActiveTalentGroup()))
|
||||
continue;
|
||||
|
||||
if (!HasFlag(PlayerFields.Flags, PlayerFlags.Resting) && HasFlag(UnitFields.Flags2, UnitFlags2.AllowChangingTalents))
|
||||
if (!HasPlayerFlag(PlayerFlags.Resting) && HasUnitFlag2(UnitFlags2.AllowChangingTalents))
|
||||
return TalentLearnResult.FailedRestArea;
|
||||
|
||||
if (GetSpellHistory().HasCooldown(talent.SpellID))
|
||||
@@ -221,7 +221,6 @@ namespace Game.Entities
|
||||
ChrSpecializationRecord defaultSpec = Global.DB2Mgr.GetDefaultChrSpecializationForClass(GetClass());
|
||||
SetPrimarySpecialization(defaultSpec.Id);
|
||||
SetActiveTalentGroup(defaultSpec.OrderIndex);
|
||||
SetUInt32Value(PlayerFields.CurrentSpecId, defaultSpec.Id);
|
||||
|
||||
LearnSpecializationSpells();
|
||||
|
||||
@@ -238,14 +237,14 @@ namespace Game.Entities
|
||||
void SetTalentResetCost(uint cost) { _specializationInfo.ResetTalentsCost = cost; }
|
||||
long GetTalentResetTime() { return _specializationInfo.ResetTalentsTime; }
|
||||
void SetTalentResetTime(long time_) { _specializationInfo.ResetTalentsTime = time_; }
|
||||
uint GetPrimarySpecialization() { return _specializationInfo.PrimarySpecialization; }
|
||||
void SetPrimarySpecialization(uint spec) { _specializationInfo.PrimarySpecialization = spec; }
|
||||
public uint GetPrimarySpecialization() { return m_playerData.CurrentSpecID; }
|
||||
void SetPrimarySpecialization(uint spec) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.CurrentSpecID), spec); }
|
||||
public byte GetActiveTalentGroup() { return _specializationInfo.ActiveGroup; }
|
||||
void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; }
|
||||
|
||||
// Loot Spec
|
||||
public void SetLootSpecId(uint id) { SetUInt32Value(ActivePlayerFields.LootSpecId, id); }
|
||||
uint GetLootSpecId() { return GetUInt32Value(ActivePlayerFields.LootSpecId); }
|
||||
public void SetLootSpecId(uint id) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LootSpecID), (ushort)id); }
|
||||
public uint GetLootSpecId() { return m_activePlayerData.LootSpecID; }
|
||||
|
||||
public uint GetDefaultSpecId()
|
||||
{
|
||||
@@ -334,9 +333,7 @@ namespace Game.Entities
|
||||
RemoveAurasDueToSpell(CliDB.GlyphPropertiesStorage.LookupByKey(glyphId).SpellID);
|
||||
|
||||
SetActiveTalentGroup(spec.OrderIndex);
|
||||
SetUInt32Value(PlayerFields.CurrentSpecId, spec.Id);
|
||||
if (GetPrimarySpecialization() == 0)
|
||||
SetPrimarySpecialization(spec.Id);
|
||||
SetPrimarySpecialization(spec.Id);
|
||||
|
||||
foreach (var talentInfo in CliDB.TalentStorage.Values)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,9 +11,7 @@ namespace Game.Entities
|
||||
|
||||
public void SetRestBonus(RestTypes restType, float restBonus)
|
||||
{
|
||||
byte rest_rested_offset;
|
||||
byte rest_state_offset;
|
||||
ActivePlayerFields next_level_xp_field;
|
||||
uint next_level_xp;
|
||||
bool affectedByRaF = false;
|
||||
|
||||
switch (restType)
|
||||
@@ -23,9 +21,7 @@ namespace Game.Entities
|
||||
if (_player.getLevel() >= WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel))
|
||||
restBonus = 0;
|
||||
|
||||
rest_rested_offset = PlayerFieldOffsets.RestRestedXp;
|
||||
rest_state_offset = PlayerFieldOffsets.RestStateXp;
|
||||
next_level_xp_field = ActivePlayerFields.NextLevelXp;
|
||||
next_level_xp = _player.m_activePlayerData.NextLevelXP;
|
||||
affectedByRaF = true;
|
||||
break;
|
||||
case RestTypes.Honor:
|
||||
@@ -33,37 +29,39 @@ namespace Game.Entities
|
||||
if (_player.IsMaxHonorLevel())
|
||||
restBonus = 0;
|
||||
|
||||
rest_rested_offset = PlayerFieldOffsets.RestRestedHonor;
|
||||
rest_state_offset = PlayerFieldOffsets.RestStateHonor;
|
||||
next_level_xp_field = ActivePlayerFields.HonorNextLevel;
|
||||
next_level_xp = _player.m_activePlayerData.HonorNextLevel;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
float rest_bonus_max = next_level_xp * 1.5f / 2;
|
||||
|
||||
if (restBonus < 0)
|
||||
restBonus = 0;
|
||||
|
||||
float rest_bonus_max = (float)(_player.GetUInt32Value(next_level_xp_field)) * 1.5f / 2;
|
||||
|
||||
if (restBonus > rest_bonus_max)
|
||||
_restBonus[(int)restType] = rest_bonus_max;
|
||||
else
|
||||
_restBonus[(int)restType] = restBonus;
|
||||
restBonus = rest_bonus_max;
|
||||
|
||||
_restBonus[(int)restType] = restBonus;
|
||||
|
||||
uint oldBonus = (uint)_restBonus[(int)restType];
|
||||
if (oldBonus == restBonus)
|
||||
return;
|
||||
|
||||
// update data for client
|
||||
if (affectedByRaF && _player.GetsRecruitAFriendBonus(true) && (_player.GetSession().IsARecruiter() || _player.GetSession().GetRecruiterId() != 0))
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.RAFLinked);
|
||||
_player.SetRestState(restType, PlayerRestState.RAFLinked);
|
||||
else
|
||||
{
|
||||
if (_restBonus[(int)restType] > 10)
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.Rested);
|
||||
_player.SetRestState(restType, PlayerRestState.Rested);
|
||||
else if (_restBonus[(int)restType] <= 1)
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.NotRAFLinked);
|
||||
_player.SetRestState(restType, PlayerRestState.NotRAFLinked);
|
||||
}
|
||||
|
||||
// RestTickUpdate
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_rested_offset, (uint)_restBonus[(int)restType]);
|
||||
_player.SetRestThreshold(restType, (uint)_restBonus[(int)restType]);
|
||||
}
|
||||
|
||||
public void AddRestBonus(RestTypes restType, float restBonus)
|
||||
@@ -84,7 +82,7 @@ namespace Game.Entities
|
||||
if (oldRestMask == 0 && _restFlagMask != 0) // only set flag/time on the first rest state
|
||||
{
|
||||
_restTime = Time.UnixTime;
|
||||
_player.SetFlag(PlayerFields.Flags, PlayerFlags.Resting);
|
||||
_player.AddPlayerFlag(PlayerFlags.Resting);
|
||||
}
|
||||
|
||||
if (triggerId != 0)
|
||||
@@ -99,7 +97,7 @@ namespace Game.Entities
|
||||
if (oldRestMask != 0 && _restFlagMask == 0) // only remove flag/time on the last rest state remove
|
||||
{
|
||||
_restTime = 0;
|
||||
_player.RemoveFlag(PlayerFields.Flags, PlayerFlags.Resting);
|
||||
_player.RemovePlayerFlag(PlayerFlags.Resting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +133,8 @@ namespace Game.Entities
|
||||
public void LoadRestBonus(RestTypes restType, PlayerRestState state, float restBonus)
|
||||
{
|
||||
_restBonus[(int)restType] = restBonus;
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + (int)restType * 2, (uint)state);
|
||||
_player.SetUInt32Value(ActivePlayerFields.RestInfo + (int)restType * 2 + 1, (uint)restBonus);
|
||||
_player.SetRestState(restType, state);
|
||||
_player.SetRestThreshold(restType, (uint)restBonus);
|
||||
}
|
||||
|
||||
public float CalcExtraPerSec(RestTypes restType, float bubble)
|
||||
@@ -144,9 +142,9 @@ namespace Game.Entities
|
||||
switch (restType)
|
||||
{
|
||||
case RestTypes.Honor:
|
||||
return (_player.GetUInt32Value(ActivePlayerFields.HonorNextLevel)) / 72000.0f * bubble;
|
||||
return _player.m_activePlayerData.HonorNextLevel / 72000.0f * bubble;
|
||||
case RestTypes.XP:
|
||||
return (_player.GetUInt32Value(ActivePlayerFields.NextLevelXp)) / 72000.0f * bubble;
|
||||
return _player.m_activePlayerData.NextLevelXP / 72000.0f * bubble;
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user