BFA Update (still lots of testing to do tho)

This commit is contained in:
hondacrx
2018-12-10 12:46:25 -05:00
parent 468b053946
commit 8e20114e10
256 changed files with 35613 additions and 10459 deletions
@@ -70,14 +70,14 @@ namespace Game.Entities
public void LoadToys()
{
foreach (var value in _toys.Keys)
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Toys, value);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Toys, value);
}
public bool AddToy(uint itemId, bool isFavourite = false)
{
if (UpdateAccountToys(itemId, isFavourite))
{
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Toys, itemId);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Toys, itemId);
return true;
}
@@ -198,8 +198,8 @@ namespace Game.Entities
{
foreach (var item in _heirlooms)
{
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Heirlooms, item.Key);
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.HeirloomsFlags, (uint)item.Value.flags);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Heirlooms, item.Key);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, (uint)item.Value.flags);
}
}
@@ -207,8 +207,8 @@ namespace Game.Entities
{
if (UpdateAccountHeirlooms(itemId, flags))
{
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Heirlooms, itemId);
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.HeirloomsFlags, (uint)flags);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Heirlooms, itemId);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, (uint)flags);
}
}
@@ -249,10 +249,10 @@ namespace Game.Entities
item.AddBonuses(bonusId);
// Get heirloom offset to update only one part of dynamic field
var fields = player.GetDynamicValues(PlayerDynamicFields.Heirlooms);
var fields = player.GetDynamicValues(ActivePlayerDynamicFields.Heirlooms);
ushort offset = (ushort)Array.IndexOf(fields, itemId);
player.SetDynamicValue(PlayerDynamicFields.HeirloomsFlags, offset, (uint)flags);
player.SetDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, offset, (uint)flags);
data.flags = flags;
data.bonusId = bonusId;
}
@@ -292,11 +292,11 @@ namespace Game.Entities
if (newItemId != 0)
{
var heirloomFields = player.GetDynamicValues(PlayerDynamicFields.Heirlooms);
var heirloomFields = player.GetDynamicValues(ActivePlayerDynamicFields.Heirlooms);
ushort offset = (ushort)Array.IndexOf(heirloomFields, item.GetEntry());
player.SetDynamicValue(PlayerDynamicFields.Heirlooms, offset, newItemId);
player.SetDynamicValue(PlayerDynamicFields.HeirloomsFlags, offset, 0);
player.SetDynamicValue(ActivePlayerDynamicFields.Heirlooms, offset, newItemId);
player.SetDynamicValue(ActivePlayerDynamicFields.HeirloomFlags, offset, 0);
_heirlooms.Remove(item.GetEntry());
_heirlooms[newItemId] = null;
@@ -432,11 +432,11 @@ namespace Game.Entities
{
foreach (uint blockValue in _appearances.ToBlockRange())
{
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Transmog, blockValue);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Transmog, blockValue);
}
foreach (var value in _temporaryAppearances.Keys)
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.ConditionalTransmog, value);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, value);
}
public void LoadAccountItemAppearances(SQLResult knownAppearances, SQLResult favoriteAppearances)
@@ -661,18 +661,18 @@ namespace Game.Entities
_appearances.Length = (int)itemModifiedAppearance.Id + 1;
numBlocks = (uint)(_appearances.Count << 2) - numBlocks;
while (numBlocks-- != 0)
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.Transmog, 0);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.Transmog, 0);
}
_appearances.Set((int)itemModifiedAppearance.Id, true);
uint blockIndex = itemModifiedAppearance.Id / 32;
uint bitIndex = itemModifiedAppearance.Id % 32;
uint currentMask = _owner.GetPlayer().GetDynamicValue(PlayerDynamicFields.Transmog, (ushort)blockIndex);
_owner.GetPlayer().SetDynamicValue(PlayerDynamicFields.Transmog, (ushort)blockIndex, (uint)((int)currentMask | (1 << (int)bitIndex)));
uint currentMask = _owner.GetPlayer().GetDynamicValue(ActivePlayerDynamicFields.Transmog, (ushort)blockIndex);
_owner.GetPlayer().SetDynamicValue(ActivePlayerDynamicFields.Transmog, (ushort)blockIndex, (uint)((int)currentMask | (1 << (int)bitIndex)));
var temporaryAppearance = _temporaryAppearances.LookupByKey(itemModifiedAppearance.Id);
if (!temporaryAppearance.Empty())
{
_owner.GetPlayer().RemoveDynamicValue(PlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
_owner.GetPlayer().RemoveDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
_temporaryAppearances.Remove(itemModifiedAppearance.Id);
}
@@ -694,7 +694,7 @@ namespace Game.Entities
{
var itemsWithAppearance = _temporaryAppearances[itemModifiedAppearance.Id];
if (itemsWithAppearance.Empty())
_owner.GetPlayer().AddDynamicValue(PlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
_owner.GetPlayer().AddDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
itemsWithAppearance.Add(itemGuid);
}
@@ -712,7 +712,7 @@ namespace Game.Entities
guid.Remove(item.GetGUID());
if (guid.Empty())
{
_owner.GetPlayer().RemoveDynamicValue(PlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
_owner.GetPlayer().RemoveDynamicValue(ActivePlayerDynamicFields.ConditionalTransmog, itemModifiedAppearance.Id);
_temporaryAppearances.Remove(itemModifiedAppearance.Id);
}
}
+3 -3
View File
@@ -118,7 +118,7 @@ namespace Game.Entities
}
public float GetRatingBonusValue(CombatRating cr)
{
float baseResult = GetFloatValue(PlayerFields.CombatRating1 + (int)cr) * GetRatingMultiplier(cr);
float baseResult = GetFloatValue(ActivePlayerFields.CombatRating + (int)cr) * GetRatingMultiplier(cr);
if (cr != CombatRating.ResiliencePlayerDamage)
return baseResult;
return (float)(1.0f - Math.Pow(0.99f, baseResult)) * 100.0f;
@@ -189,9 +189,9 @@ namespace Game.Entities
switch (attType)
{
case WeaponAttackType.BaseAttack:
return baseExpertise + GetUInt32Value(PlayerFields.Expertise) / 4.0f;
return baseExpertise + GetUInt32Value(ActivePlayerFields.Expertise) / 4.0f;
case WeaponAttackType.OffAttack:
return baseExpertise + GetUInt32Value(PlayerFields.OffhandExpertise) / 4.0f;
return baseExpertise + GetUInt32Value(ActivePlayerFields.OffhandExpertise) / 4.0f;
default:
break;
}
+83 -84
View File
@@ -348,7 +348,6 @@ namespace Game.Entities
}
void _LoadSkills(SQLResult result)
{
var professionCount = 0;
var count = 0;
Dictionary<uint, uint> loadedSkillValues = new Dictionary<uint, uint>();
if (!result.IsEmpty())
@@ -396,7 +395,7 @@ namespace Game.Entities
var field = (ushort)(count / 2);
var offset = (byte)(count & 1);
SetUInt16Value(PlayerFields.SkillLineId + field, offset, skill);
SetUInt16Value(ActivePlayerFields.SkillLineId + field, offset, skill);
ushort step = 0;
SkillLineRecord skillLine = CliDB.SkillLineStorage.LookupByKey(rcEntry.SkillID);
@@ -409,16 +408,20 @@ namespace Game.Entities
{
step = (ushort)(max / 75);
if (professionCount < 2)
SetUInt32Value(PlayerFields.ProfessionSkillLine1 + professionCount++, skill);
if (skillLine.ParentSkillLineID != 0 && skillLine.ParentTierIndex != 0)
{
int professionSlot = FindProfessionSlotFor(skill);
if (professionSlot != -1)
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine + professionSlot, skill);
}
}
}
SetUInt16Value(PlayerFields.SkillLineStep + field, offset, step);
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, value);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, max);
SetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset, 0);
SetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset, step);
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, value);
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, max);
SetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset, 0);
mSkillStatus.Add(skill, new SkillStatusData((uint)count, SkillState.Unchanged));
@@ -445,12 +448,12 @@ namespace Game.Entities
var field = (ushort)(count / 2);
var offset = (byte)(count & 1);
SetUInt16Value(PlayerFields.SkillLineId + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineStep + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset, 0);
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);
}
}
void _LoadSpells(SQLResult result)
@@ -846,7 +849,7 @@ namespace Game.Entities
if (quest == null)
continue;
AddDynamicValue(PlayerDynamicFields.DailyQuests, quest_id);
AddDynamicValue(ActivePlayerDynamicFields.DailyQuests, quest_id);
uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(quest_id);
if (questBit != 0)
SetQuestCompletedBit(questBit, true);
@@ -953,14 +956,17 @@ namespace Game.Entities
}
void _LoadPvpTalents(SQLResult result)
{
// "SELECT TalentID, TalentGroup FROM character_pvp_talent WHERE guid = ?"
// "SELECT talentID0, talentID1, talentID2, talentID3, talentGroup FROM character_pvp_talent WHERE guid = ?"
if (!result.IsEmpty())
{
do
{
PvpTalentRecord talent = CliDB.PvpTalentStorage.LookupByKey(result.Read<uint>(0));
if (talent != null)
AddPvpTalent(talent, result.Read<byte>(1), false);
for (byte slot = 0; slot < PlayerConst.MaxPvpTalentSlots; ++slot)
{
PvpTalentRecord talent = CliDB.PvpTalentStorage.LookupByKey(result.Read<uint>(slot));
if (talent != null)
AddPvpTalent(talent, result.Read<byte>(4), slot);
}
}
while (result.NextRow());
}
@@ -1000,7 +1006,7 @@ namespace Game.Entities
if (!result.IsEmpty() && !HasAtLoginFlag(AtLoginFlags.Resurrect))
{
_corpseLocation = new WorldLocation(result.Read<ushort>(0), result.Read<float>(1), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4));
ApplyModFlag(PlayerFields.LocalFlags, PlayerLocalFlags.ReleaseTimer, !CliDB.MapStorage.LookupByKey(_corpseLocation.GetMapId()).Instanceable());
ApplyModFlag(ActivePlayerFields.LocalFlags, PlayerLocalFlags.ReleaseTimer, !CliDB.MapStorage.LookupByKey(_corpseLocation.GetMapId()).Instanceable());
}
else
ResurrectPlayer(0.5f);
@@ -1576,8 +1582,8 @@ namespace Game.Entities
var field = (ushort)(skill.Value.Pos / 2);
var offset = (byte)(skill.Value.Pos & 1);
var value = GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
var max = GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
var value = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
var max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
switch (skill.Value.State)
{
@@ -1607,7 +1613,7 @@ namespace Game.Entities
{
PreparedStatement stmt = null;
foreach (var spell in m_spells)
foreach (var spell in m_spells.ToList())
{
if (spell.Value.State == PlayerSpellState.Removed || spell.Value.State == PlayerSpellState.Changed)
{
@@ -1884,7 +1890,7 @@ namespace Game.Entities
stmt.AddValue(0, GetGUID().GetCounter());
trans.Append(stmt);
var dailies = GetDynamicValues(PlayerDynamicFields.DailyQuests);
var dailies = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests);
foreach (var questId in dailies)
{
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_QUESTSTATUS_DAILY);
@@ -1976,7 +1982,7 @@ namespace Game.Entities
for (byte group = 0; group < PlayerConst.MaxSpecializations; ++group)
{
Dictionary<uint, PlayerSpellState> talents = GetTalentMap(group);
var talents = GetTalentMap(group);
foreach (var pair in talents.ToList())
{
if (pair.Value == PlayerSpellState.Removed)
@@ -1999,21 +2005,15 @@ namespace Game.Entities
for (byte group = 0; group < PlayerConst.MaxSpecializations; ++group)
{
Dictionary<uint, PlayerSpellState> talents = GetPvpTalentMap(group);
foreach (var pair in talents.ToList())
{
if (pair.Value == PlayerSpellState.Removed)
{
talents.Remove(pair.Key);
continue;
}
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHAR_PVP_TALENT);
stmt.AddValue(0, GetGUID().GetCounter());
stmt.AddValue(1, pair.Key);
stmt.AddValue(2, group);
trans.Append(stmt);
}
var talents = GetPvpTalentMap(group);
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHAR_PVP_TALENT);
stmt.AddValue(0, GetGUID().GetCounter());
stmt.AddValue(1, talents[0]);
stmt.AddValue(2, talents[1]);
stmt.AddValue(3, talents[2]);
stmt.AddValue(4, talents[3]);
stmt.AddValue(5, group);
trans.Append(stmt);
}
}
public void _SaveMail(SQLTransaction trans)
@@ -2102,18 +2102,18 @@ namespace Game.Entities
stmt.AddValue(index++, GetStat((Stats)i));
for (int i = 0; i < (int)SpellSchools.Max; ++i)
stmt.AddValue(index++, GetResistance((SpellSchools)i));
stmt.AddValue(index++, GetResistance((SpellSchools)i) + GetBonusResistanceMod((SpellSchools)i));
stmt.AddValue(index++, GetFloatValue(PlayerFields.BlockPercentage));
stmt.AddValue(index++, GetFloatValue(PlayerFields.DodgePercentage));
stmt.AddValue(index++, GetFloatValue(PlayerFields.ParryPercentage));
stmt.AddValue(index++, GetFloatValue(PlayerFields.CritPercentage));
stmt.AddValue(index++, GetFloatValue(PlayerFields.RangedCritPercentage));
stmt.AddValue(index++, GetFloatValue(PlayerFields.SpellCritPercentage1));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.BlockPercentage));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.DodgePercentage));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.ParryPercentage));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.CritPercentage));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.RangedCritPercentage));
stmt.AddValue(index++, GetFloatValue(ActivePlayerFields.SpellCritPercentage1));
stmt.AddValue(index++, GetUInt32Value(UnitFields.AttackPower));
stmt.AddValue(index++, GetUInt32Value(UnitFields.RangedAttackPower));
stmt.AddValue(index++, GetBaseSpellPowerBonus());
stmt.AddValue(index, GetUInt32Value(PlayerFields.CombatRating1 + (int)CombatRating.ResiliencePlayerDamage));
stmt.AddValue(index, GetUInt32Value(ActivePlayerFields.CombatRating + (int)CombatRating.ResiliencePlayerDamage));
trans.Append(stmt);
}
@@ -2408,8 +2408,8 @@ namespace Game.Entities
SetUInt32Value(UnitFields.Level, result.Read<uint>(6));
SetXP(result.Read<uint>(7));
_LoadIntoDataField(result.Read<string>(66), (int)PlayerFields.ExploredZones1, PlayerConst.ExploredZonesSize);
_LoadIntoDataField(result.Read<string>(67), (int)PlayerFields.KnownTitles, PlayerConst.KnowTitlesSize * 2);
_LoadIntoDataField(result.Read<string>(66), (int)ActivePlayerFields.ExploredZones, PlayerConst.ExploredZonesSize);
_LoadIntoDataField(result.Read<string>(67), (int)ActivePlayerFields.KnownTitles, PlayerConst.KnowTitlesSize * 2);
SetObjectScale(1.0f);
SetFloatValue(UnitFields.HoverHeight, 1.0f);
@@ -2441,7 +2441,7 @@ namespace Game.Entities
SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetInebriation, result.Read<byte>(55));
SetUInt32Value(PlayerFields.Flags, result.Read<uint>(20));
SetUInt32Value(PlayerFields.FlagsEx, result.Read<uint>(21));
SetInt32Value(PlayerFields.WatchedFactionIndex, (int)result.Read<uint>(54));
SetInt32Value(ActivePlayerFields.WatchedFactionIndex, (int)result.Read<uint>(54));
if (!ValidateAppearance((Race)result.Read<byte>(3), (Class)result.Read<byte>(4), (Gender)gender,
GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairStyleId),
@@ -2455,7 +2455,7 @@ namespace Game.Entities
}
// set which actionbars the client has active - DO NOT REMOVE EVER AGAIN (can be changed though, if it does change fieldwise)
SetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles, result.Read<byte>(68));
SetByteValue(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles, result.Read<byte>(68));
m_fishingSteps = result.Read<byte>(72);
@@ -2464,7 +2464,7 @@ namespace Game.Entities
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
for (byte slot = EquipmentSlot.Start; slot < EquipmentSlot.End; ++slot)
{
SetGuidValue(PlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
SetVisibleItemSlot(slot, null);
m_items[slot] = null;
@@ -2518,9 +2518,9 @@ namespace Game.Entities
}
_LoadCurrency(holder.GetResult(PlayerLoginQueryLoad.Currency));
SetUInt32Value(PlayerFields.LifetimeHonorableKills, result.Read<uint>(50));
SetUInt16Value(PlayerFields.Kills, PlayerFieldOffsets.FieldKillsOffsetTodayKills, result.Read<ushort>(51));
SetUInt16Value(PlayerFields.Kills, PlayerFieldOffsets.FieldKillsOffsetYesterdayKills, result.Read<ushort>(52));
SetUInt32Value(ActivePlayerFields.LifetimeHonorableKills, result.Read<uint>(50));
SetUInt16Value(ActivePlayerFields.Kills, PlayerFieldOffsets.FieldKillsOffsetTodayKills, result.Read<ushort>(51));
SetUInt16Value(ActivePlayerFields.Kills, PlayerFieldOffsets.FieldKillsOffsetYesterdayKills, result.Read<ushort>(52));
_LoadBoundInstances(holder.GetResult(PlayerLoginQueryLoad.BoundInstances));
_LoadInstanceTimeRestrictions(holder.GetResult(PlayerLoginQueryLoad.InstanceLockTimes));
@@ -2843,14 +2843,14 @@ namespace Game.Entities
SetGuidValue(UnitFields.CharmedBy, ObjectGuid.Empty);
SetGuidValue(UnitFields.Charm, ObjectGuid.Empty);
SetGuidValue(UnitFields.Summon, ObjectGuid.Empty);
SetGuidValue(PlayerFields.Farsight, ObjectGuid.Empty);
SetGuidValue(ActivePlayerFields.Farsight, ObjectGuid.Empty);
SetCreatorGUID(ObjectGuid.Empty);
RemoveFlag(UnitFields.Flags2, UnitFlags2.ForceMove);
// reset some aura modifiers before aura apply
SetUInt32Value(PlayerFields.TrackCreatures, 0);
SetUInt32Value(PlayerFields.TrackResources, 0);
SetUInt32Value(ActivePlayerFields.TrackCreatures, 0);
SetUInt32Value(ActivePlayerFields.TrackResources, 0);
// make sure the unit is considered out of combat for proper loading
ClearInCombat();
@@ -3061,7 +3061,7 @@ namespace Game.Entities
SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.ReferAFriend);
if (m_grantableLevels > 0)
SetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01);
SetByteValue(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01);
_LoadDeclinedNames(holder.GetResult(PlayerLoginQueryLoad.DeclinedNames));
@@ -3078,9 +3078,9 @@ namespace Game.Entities
holder.GetResult(PlayerLoginQueryLoad.GarrisonFollowerAbilities)))
_garrison = garrison;
_InitHonorLevelOnLoadFromDB(result.Read<uint>(73), result.Read<uint>(74), result.Read<uint>(75));
_InitHonorLevelOnLoadFromDB(result.Read<uint>(73), result.Read<uint>(74));
_restMgr.LoadRestBonus(RestTypes.Honor, (PlayerRestState)result.Read<byte>(76), result.Read<float>(77));
_restMgr.LoadRestBonus(RestTypes.Honor, (PlayerRestState)result.Read<byte>(75), result.Read<float>(76));
if (time_diff > 0)
{
//speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour)
@@ -3132,7 +3132,7 @@ namespace Game.Entities
stmt.AddValue(index++, (byte)GetClass());
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender));
stmt.AddValue(index++, getLevel());
stmt.AddValue(index++, GetUInt32Value(PlayerFields.Xp));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.Xp));
stmt.AddValue(index++, GetMoney());
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetSkinId));
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetFaceId));
@@ -3143,7 +3143,7 @@ namespace Game.Entities
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes2, (byte)(PlayerFieldOffsets.Bytes2OffsetCustomDisplayOption + i)));
stmt.AddValue(index++, GetInventorySlotCount());
stmt.AddValue(index++, GetBankBagSlotCount());
stmt.AddValue(index++, (byte)GetUInt32Value(PlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp));
stmt.AddValue(index++, (byte)GetUInt32Value(ActivePlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.Flags));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.FlagsEx));
stmt.AddValue(index++, (ushort)GetMapId());
@@ -3191,11 +3191,11 @@ namespace Game.Entities
ss.Append(m_taxi.SaveTaxiDestinationsToString());
stmt.AddValue(index++, ss.ToString());
stmt.AddValue(index++, GetUInt32Value(PlayerFields.LifetimeHonorableKills));
stmt.AddValue(index++, GetUInt16Value(PlayerFields.Kills, 0));
stmt.AddValue(index++, GetUInt16Value(PlayerFields.Kills, 1));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.LifetimeHonorableKills));
stmt.AddValue(index++, GetUInt16Value(ActivePlayerFields.Kills, 0));
stmt.AddValue(index++, GetUInt16Value(ActivePlayerFields.Kills, 1));
stmt.AddValue(index++, (uint)GetInt32Value(PlayerFields.ChosenTitle));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.WatchedFactionIndex));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.WatchedFactionIndex));
stmt.AddValue(index++, GetDrunkValue());
stmt.AddValue(index++, GetHealth());
@@ -3222,7 +3222,7 @@ namespace Game.Entities
ss.Clear();
for (var i = 0; i < PlayerConst.ExploredZonesSize; ++i)
ss.AppendFormat("{0} ", GetUInt32Value(PlayerFields.ExploredZones1 + i));
ss.AppendFormat("{0} ", GetUInt32Value(ActivePlayerFields.ExploredZones + i));
stmt.AddValue(index++, ss.ToString());
ss.Clear();
@@ -3248,10 +3248,10 @@ namespace Game.Entities
ss.Clear();
for (var i = 0; i < PlayerConst.KnowTitlesSize * 2; ++i)
ss.AppendFormat("{0} ", GetUInt32Value(PlayerFields.KnownTitles + i));
ss.AppendFormat("{0} ", GetUInt32Value(ActivePlayerFields.KnownTitles + i));
stmt.AddValue(index++, ss.ToString());
stmt.AddValue(index++, GetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles));
stmt.AddValue(index++, GetByteValue(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles));
stmt.AddValue(index++, m_grantableLevels);
stmt.AddValue(index++, Global.WorldMgr.GetRealm().Build);
}
@@ -3264,7 +3264,7 @@ namespace Game.Entities
stmt.AddValue(index++, (byte)GetClass());
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender));
stmt.AddValue(index++, getLevel());
stmt.AddValue(index++, GetUInt32Value(PlayerFields.Xp));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.Xp));
stmt.AddValue(index++, GetMoney());
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetSkinId));
stmt.AddValue(index++, GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetFaceId));
@@ -3276,7 +3276,7 @@ namespace Game.Entities
PlayerFieldOffsets.Bytes2OffsetCustomDisplayOption + i)));
stmt.AddValue(index++, GetInventorySlotCount());
stmt.AddValue(index++, GetBankBagSlotCount());
stmt.AddValue(index++, (byte)GetUInt32Value(PlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp));
stmt.AddValue(index++, (byte)GetUInt32Value(ActivePlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.Flags));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.FlagsEx));
@@ -3340,11 +3340,11 @@ namespace Game.Entities
ss.Append(m_taxi.SaveTaxiDestinationsToString());
stmt.AddValue(index++, ss.ToString());
stmt.AddValue(index++, GetUInt32Value(PlayerFields.LifetimeHonorableKills));
stmt.AddValue(index++, GetUInt16Value(PlayerFields.Kills, 0));
stmt.AddValue(index++, GetUInt16Value(PlayerFields.Kills, 1));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.LifetimeHonorableKills));
stmt.AddValue(index++, GetUInt16Value(ActivePlayerFields.Kills, 0));
stmt.AddValue(index++, GetUInt16Value(ActivePlayerFields.Kills, 1));
stmt.AddValue(index++, GetUInt32Value(PlayerFields.ChosenTitle));
stmt.AddValue(index++, (uint)GetInt32Value(PlayerFields.WatchedFactionIndex));
stmt.AddValue(index++, (uint)GetInt32Value(ActivePlayerFields.WatchedFactionIndex));
stmt.AddValue(index++, GetDrunkValue());
stmt.AddValue(index++, GetHealth());
@@ -3371,7 +3371,7 @@ namespace Game.Entities
ss.Clear();
for (var i = 0; i < PlayerConst.ExploredZonesSize; ++i)
ss.AppendFormat("{0} ", GetUInt32Value(PlayerFields.ExploredZones1 + i));
ss.AppendFormat("{0} ", GetUInt32Value(ActivePlayerFields.ExploredZones + i));
stmt.AddValue(index++, ss.ToString());
ss.Clear();
@@ -3397,17 +3397,16 @@ namespace Game.Entities
ss.Clear();
for (var i = 0; i < PlayerConst.KnowTitlesSize * 2; ++i)
ss.AppendFormat("{0} ", GetUInt32Value(PlayerFields.KnownTitles + i));
ss.AppendFormat("{0} ", GetUInt32Value(ActivePlayerFields.KnownTitles + i));
stmt.AddValue(index++, ss.ToString());
stmt.AddValue(index++, GetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles));
stmt.AddValue(index++, GetByteValue(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetActionBarToggles));
stmt.AddValue(index++, m_grantableLevels);
stmt.AddValue(index++, IsInWorld && !GetSession().PlayerLogout() ? 1 : 0);
stmt.AddValue(index++, GetUInt32Value(PlayerFields.Honor));
stmt.AddValue(index++, GetUInt32Value(ActivePlayerFields.Honor));
stmt.AddValue(index++, GetHonorLevel());
stmt.AddValue(index++, GetPrestigeLevel());
stmt.AddValue(index++, (byte)GetUInt32Value(PlayerFields.RestInfo + PlayerFieldOffsets.RestStateHonor));
stmt.AddValue(index++, (byte)GetUInt32Value(ActivePlayerFields.RestInfo + PlayerFieldOffsets.RestStateHonor));
stmt.AddValue(index++, _restMgr.GetRestBonus(RestTypes.Honor));
stmt.AddValue(index++, Global.WorldMgr.GetRealm().Build);
+3 -2
View File
@@ -237,6 +237,7 @@ namespace Game.Entities
ulong m_GuildIdInvited;
DeclinedName _declinedname;
Runes m_runes = new Runes();
uint m_hostileReferenceCheckTimer;
uint m_drunkTimer;
long m_logintime;
long m_Last_tick;
@@ -319,13 +320,13 @@ namespace Game.Entities
for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i)
{
Talents[i] = new Dictionary<uint, PlayerSpellState>();
PvpTalents[i] = new Dictionary<uint, PlayerSpellState>();
PvpTalents[i] = new Array<uint>(PlayerConst.MaxPvpTalentSlots);
Glyphs[i] = new List<uint>();
}
}
public Dictionary<uint, PlayerSpellState>[] Talents = new Dictionary<uint, PlayerSpellState>[PlayerConst.MaxSpecializations];
public Dictionary<uint, PlayerSpellState>[] PvpTalents = new Dictionary<uint, PlayerSpellState>[PlayerConst.MaxSpecializations];
public Array<uint>[] PvpTalents = new Array<uint>[PlayerConst.MaxSpecializations];
public List<uint>[] Glyphs = new List<uint>[PlayerConst.MaxSpecializations];
public uint ResetTalentsCost;
public long ResetTalentsTime;
@@ -233,6 +233,8 @@ namespace Game.Entities
return IsInSameRaidWith(p);
case 2:
return GetTeam() == p.GetTeam();
case 3:
return false;
}
}
public bool IsInSameGroupWith(Player p)
+26 -35
View File
@@ -1132,7 +1132,7 @@ namespace Game.Entities
if (pBag == null)
{
m_items[slot] = pItem;
SetGuidValue(PlayerFields.InvSlotHead + (slot * 4), pItem.GetGUID());
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), pItem.GetGUID());
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
pItem.SetGuidValue(ItemFields.Owner, GetGUID());
@@ -1975,7 +1975,7 @@ namespace Game.Entities
}
m_items[slot] = null;
SetGuidValue(PlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
if (slot < EquipmentSlot.End)
{
@@ -3399,7 +3399,7 @@ namespace Game.Entities
// if current back slot non-empty search oldest or free
if (m_items[slot] != null)
{
uint oldest_time = GetUInt32Value(PlayerFields.BuyBackTimestamp1);
uint oldest_time = GetUInt32Value(ActivePlayerFields.BuyBackTimestamp);
uint oldest_slot = InventorySlots.BuyBackStart;
for (byte i = InventorySlots.BuyBackStart + 1; i < InventorySlots.BuyBackEnd; ++i)
@@ -3411,7 +3411,7 @@ namespace Game.Entities
break;
}
uint i_time = GetUInt32Value(PlayerFields.BuyBackTimestamp1 + i - InventorySlots.BuyBackStart);
uint i_time = GetUInt32Value(ActivePlayerFields.BuyBackTimestamp + i - InventorySlots.BuyBackStart);
if (oldest_time > i_time)
{
@@ -3432,13 +3432,13 @@ namespace Game.Entities
uint etime = (uint)(time - m_logintime + (30 * 3600));
int eslot = (int)slot - InventorySlots.BuyBackStart;
SetGuidValue(PlayerFields.InvSlotHead + ((int)slot * 4), pItem.GetGUID());
SetGuidValue(ActivePlayerFields.InvSlotHead + ((int)slot * 4), pItem.GetGUID());
ItemTemplate proto = pItem.GetTemplate();
if (proto != null)
SetUInt32Value(PlayerFields.BuyBackPrice1 + eslot, proto.GetSellPrice() * pItem.GetCount());
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, proto.GetSellPrice() * pItem.GetCount());
else
SetUInt32Value(PlayerFields.BuyBackPrice1 + eslot, 0);
SetUInt32Value(PlayerFields.BuyBackTimestamp1 + eslot, etime);
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, 0);
SetUInt32Value(ActivePlayerFields.BuyBackTimestamp + eslot, etime);
// move to next (for non filled list is move most optimized choice)
if (m_currentBuybackSlot < InventorySlots.BuyBackEnd - 1)
@@ -3890,9 +3890,9 @@ namespace Game.Entities
m_items[slot] = null;
int eslot = (int)slot - InventorySlots.BuyBackStart;
SetGuidValue(PlayerFields.InvSlotHead + (int)(slot * 4), ObjectGuid.Empty);
SetUInt32Value(PlayerFields.BuyBackPrice1 + eslot, 0);
SetUInt32Value(PlayerFields.BuyBackTimestamp1 + eslot, 0);
SetGuidValue(ActivePlayerFields.InvSlotHead + (int)(slot * 4), ObjectGuid.Empty);
SetUInt32Value(ActivePlayerFields.BuyBackPrice + eslot, 0);
SetUInt32Value(ActivePlayerFields.BuyBackTimestamp + eslot, 0);
// if current backslot is filled set to now free slot
if (m_items[m_currentBuybackSlot])
@@ -4137,6 +4137,9 @@ namespace Game.Entities
case ItemModType.MasteryRating:
ApplyRatingMod(CombatRating.Mastery, (int)(val * combatRatingMultiplier), apply);
break;
case ItemModType.ExtraArmor:
HandleStatModifier(UnitMods.Armor, UnitModifierType.TotalValue, (float)val, apply);
break;
case ItemModType.FireResistance:
HandleStatModifier(UnitMods.ResistanceFire, UnitModifierType.BaseValue, (float)val, apply);
break;
@@ -4219,27 +4222,8 @@ namespace Game.Entities
uint armor = item.GetArmor(this);
if (armor != 0)
{
UnitModifierType modType = UnitModifierType.TotalValue;
if (proto.GetClass() == ItemClass.Armor)
{
switch ((ItemSubClassArmor)proto.GetSubClass())
{
case ItemSubClassArmor.Cloth:
case ItemSubClassArmor.Leather:
case ItemSubClassArmor.Mail:
case ItemSubClassArmor.Plate:
case ItemSubClassArmor.Shield:
modType = UnitModifierType.BaseValue;
break;
}
}
HandleStatModifier(UnitMods.Armor, modType, armor, apply);
}
HandleStatModifier(UnitMods.Armor, UnitModifierType.BaseValue, (float)armor, apply);
//if (proto.GetArmorDamageModifier() > 0)
// HandleStatModifier(UnitMods.Armor, UnitModifierType.TotalValue, (float)proto.GetArmorDamageModifier(), apply);
WeaponAttackType attType = WeaponAttackType.BaseAttack;
if (slot == EquipmentSlot.MainHand && (proto.GetInventoryType() == InventoryType.Ranged || proto.GetInventoryType() == InventoryType.RangedRight))
{
@@ -5617,7 +5601,7 @@ namespace Game.Entities
Log.outDebug(LogFilter.Player, "STORAGE: EquipItem slot = {0}, item = {1}", slot, pItem.GetEntry());
m_items[slot] = pItem;
SetGuidValue(PlayerFields.InvSlotHead + (int)(slot * 4), pItem.GetGUID());
SetGuidValue(ActivePlayerFields.InvSlotHead + (int)(slot * 4), pItem.GetGUID());
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
pItem.SetGuidValue(ItemFields.Owner, GetGUID());
pItem.SetSlot((byte)slot);
@@ -5661,7 +5645,7 @@ namespace Game.Entities
Bag pBag;
if (bag == InventorySlots.Bag0)
{
SetGuidValue(PlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
SetGuidValue(ActivePlayerFields.InvSlotHead + (slot * 4), ObjectGuid.Empty);
// equipment and equipped bags can have applied bonuses
if (slot < InventorySlots.BagEnd)
@@ -6031,7 +6015,7 @@ namespace Game.Entities
}
}
public byte GetInventorySlotCount() { return GetByteValue(PlayerFields.FieldBytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots); }
public byte GetInventorySlotCount() { return GetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots); }
public void SetInventorySlotCount(byte slots)
{
//ASSERT(slots <= (INVENTORY_SLOT_ITEM_END - INVENTORY_SLOT_ITEM_START));
@@ -6074,7 +6058,7 @@ namespace Game.Entities
}
}
SetByteValue(PlayerFields.FieldBytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots, slots);
SetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetNumBackpackSlots, slots);
}
public byte GetBankBagSlotCount() { return GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetBankBagSlots); }
@@ -6109,6 +6093,13 @@ namespace Game.Entities
return;
}
// dont allow protected item to be looted by someone else
if (!item.rollWinnerGUID.IsEmpty() && item.rollWinnerGUID != GetGUID())
{
SendLootRelease(GetLootGUID());
return;
}
List<ItemPosCount> dest = new List<ItemPosCount>();
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
if (msg == InventoryResult.Ok)
+5 -2
View File
@@ -305,7 +305,7 @@ namespace Game.Entities
if (save != null)
{
InstanceBind bind = new InstanceBind();
if (m_boundInstances[save.GetDifficultyID()].ContainsKey(save.GetMapId()))
if (m_boundInstances.ContainsKey(save.GetDifficultyID()) && m_boundInstances[save.GetDifficultyID()].ContainsKey(save.GetMapId()))
bind = m_boundInstances[save.GetDifficultyID()][save.GetMapId()];
if (extendState == BindExtensionState.Keep) // special flag, keep the player's current extend state when updating for new boss down
@@ -364,6 +364,9 @@ namespace Game.Entities
Global.ScriptMgr.OnPlayerBindToInstance(this, save.GetDifficultyID(), save.GetMapId(), permanent, extendState);
if (!m_boundInstances.ContainsKey(save.GetDifficultyID()))
m_boundInstances[save.GetDifficultyID()] = new Dictionary<uint, InstanceBind>();
m_boundInstances[save.GetDifficultyID()][save.GetMapId()] = bind;
return bind;
}
@@ -406,7 +409,7 @@ namespace Game.Entities
{
InstanceSave save = instanceBind.save;
InstanceLockInfos lockInfos;
InstanceLock lockInfos;
lockInfos.InstanceID = save.GetInstanceId();
lockInfos.MapID = save.GetMapId();
lockInfos.DifficultyID = (uint)save.GetDifficultyID();
+67 -109
View File
@@ -46,15 +46,15 @@ namespace Game.Entities
if (m_lastHonorUpdateTime >= yesterday)
{
// this is the first update today, reset today's contribution
ushort killsToday = GetUInt16Value(PlayerFields.Kills, 0);
SetUInt16Value(PlayerFields.Kills, 0, 0);
SetUInt16Value(PlayerFields.Kills, 1, killsToday);
ushort killsToday = GetUInt16Value(ActivePlayerFields.Kills, 0);
SetUInt16Value(ActivePlayerFields.Kills, 0, 0);
SetUInt16Value(ActivePlayerFields.Kills, 1, killsToday);
}
else
{
// no honor/kills yesterday or today, reset
SetUInt32Value(PlayerFields.Kills, 0);
SetUInt32Value(ActivePlayerFields.Kills, 0);
}
}
@@ -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(PlayerFields.Kills, 0, 1, true);
ApplyModUInt16Value(ActivePlayerFields.Kills, 0, 1, true);
// and those in a lifetime
ApplyModUInt32Value(PlayerFields.LifetimeHonorableKills, 1, true);
ApplyModUInt32Value(ActivePlayerFields.LifetimeHonorableKills, 1, true);
UpdateCriteria(CriteriaTypes.EarnHonorableKill);
UpdateCriteria(CriteriaTypes.HkClass, (uint)victim.GetClass());
UpdateCriteria(CriteriaTypes.HkRace, (uint)victim.GetRace());
@@ -215,15 +215,12 @@ namespace Game.Entities
return true;
}
void _InitHonorLevelOnLoadFromDB(uint honor, uint honorLevel, uint prestigeLevel)
void _InitHonorLevelOnLoadFromDB(uint honor, uint honorLevel)
{
SetUInt32Value(PlayerFields.HonorLevel, honorLevel);
SetUInt32Value(PlayerFields.Prestige, prestigeLevel);
UpdateHonorNextLevel();
AddHonorXP(honor);
if (CanPrestige())
Prestige();
}
void RewardPlayerWithRewardPack(uint rewardPackID)
@@ -253,12 +250,12 @@ namespace Game.Entities
public void AddHonorXP(uint xp)
{
uint currentHonorXP = GetUInt32Value(PlayerFields.Honor);
uint nextHonorLevelXP = GetUInt32Value(PlayerFields.HonorNextLevel);
uint currentHonorXP = GetUInt32Value(ActivePlayerFields.Honor);
uint nextHonorLevelXP = GetUInt32Value(ActivePlayerFields.HonorNextLevel);
uint newHonorXP = currentHonorXP + xp;
uint honorLevel = GetHonorLevel();
if (xp < 1 || getLevel() < PlayerConst.LevelMinHonor || IsMaxHonorLevelAndPrestige())
if (xp < 1 || getLevel() < PlayerConst.LevelMinHonor || IsMaxHonorLevel())
return;
while (newHonorXP >= nextHonorLevelXP)
@@ -269,72 +266,34 @@ namespace Game.Entities
SetHonorLevel((byte)(honorLevel + 1));
honorLevel = GetHonorLevel();
nextHonorLevelXP = GetUInt32Value(PlayerFields.HonorNextLevel);
nextHonorLevelXP = GetUInt32Value(ActivePlayerFields.HonorNextLevel);
}
SetUInt32Value(PlayerFields.Honor, IsMaxHonorLevelAndPrestige() ? 0 : newHonorXP);
SetUInt32Value(ActivePlayerFields.Honor, IsMaxHonorLevel() ? 0 : newHonorXP);
}
void SetHonorLevel(byte level)
{
byte oldHonorLevel = (byte)GetHonorLevel();
byte prestige = (byte)GetPrestigeLevel();
if (level == oldHonorLevel)
return;
uint rewardPackID = Global.DB2Mgr.GetRewardPackIDForPvpRewardByHonorLevelAndPrestige(level, prestige);
RewardPlayerWithRewardPack(rewardPackID);
SetUInt32Value(PlayerFields.HonorLevel, level);
UpdateHonorNextLevel();
UpdateCriteria(CriteriaTypes.HonorLevelReached);
// This code is here because no link was found between those items and this reward condition in the db2 files.
// Interesting CriteriaTree found: Tree ids: 51140, 51156 (criteria id 31773, modifier tree id 37759)
if (level == 50 && prestige == 1)
{
if (GetTeam() == Team.Alliance)
AddItem(138992, 1);
else
AddItem(138996, 1);
}
if (CanPrestige())
Prestige();
}
public void Prestige()
{
SetUInt32Value(PlayerFields.Prestige, GetPrestigeLevel() + 1);
SetUInt32Value(PlayerFields.HonorLevel, 1);
UpdateHonorNextLevel();
UpdateCriteria(CriteriaTypes.PrestigeReached);
}
public bool CanPrestige()
{
if (GetSession().GetExpansion() >= Expansion.Legion && getLevel() >= PlayerConst.LevelMinHonor && GetHonorLevel() >= PlayerConst.MaxHonorLevel && GetPrestigeLevel() < Global.DB2Mgr.GetMaxPrestige())
return true;
return false;
}
bool IsMaxPrestige()
{
return GetPrestigeLevel() == Global.DB2Mgr.GetMaxPrestige();
}
void UpdateHonorNextLevel()
{
uint prestige = Math.Min(16 - 1, GetPrestigeLevel());
SetUInt32Value(PlayerFields.HonorNextLevel, (uint)CliDB.HonorLevelGameTable.GetRow(GetHonorLevel()).Prestige[prestige]);
// 5500 at honor level 1
// no idea what between here
// 8800 at honor level ~14 (never goes above 8800)
SetUInt32Value(ActivePlayerFields.HonorNextLevel, 8800);
}
public uint GetPrestigeLevel() { return GetUInt32Value(PlayerFields.Prestige); }
public uint GetHonorLevel() { return GetUInt32Value(PlayerFields.HonorLevel); }
public bool IsMaxHonorLevelAndPrestige() { return IsMaxPrestige() && GetHonorLevel() == PlayerConst.MaxHonorLevel; }
public bool IsMaxHonorLevel() { return GetHonorLevel() == PlayerConst.MaxHonorLevel; }
public void ActivatePvpItemLevels(bool activate) { _usePvpItemLevels = activate; }
public bool IsUsingPvpItemLevels() { return _usePvpItemLevels; }
@@ -343,7 +302,7 @@ namespace Game.Entities
{
foreach (var talentInfo in CliDB.PvpTalentStorage.Values)
{
if (talentInfo.ClassID != 0 && talentInfo.ClassID != (int)GetClass())
if (talentInfo == null)
continue;
RemovePvpTalent(talentInfo);
@@ -355,62 +314,61 @@ namespace Game.Entities
DB.Characters.CommitTransaction(trans);
}
public TalentLearnResult LearnPvpTalent(uint talentID, ref uint spellOnCooldown)
public TalentLearnResult LearnPvpTalent(uint talentID, byte slot, ref uint spellOnCooldown)
{
if (slot >= PlayerConst.MaxPvpTalentSlots)
return TalentLearnResult.FailedUnknown;
if (IsInCombat())
return TalentLearnResult.FailedAffectingCombat;
if (getLevel() < PlayerConst.LevelMinHonor)
return TalentLearnResult.FailedUnknown;
if (IsDead())
return TalentLearnResult.FailedCantDoThatRightNow;
PvpTalentRecord talentInfo = CliDB.PvpTalentStorage.LookupByKey(talentID);
if (talentInfo == null)
return TalentLearnResult.FailedUnknown;
if (talentInfo.SpecID != 0)
{
if (talentInfo.SpecID != GetInt32Value(PlayerFields.CurrentSpecId))
return TalentLearnResult.FailedUnknown;
}
else if (talentInfo.Role < 7)
{
if (talentInfo.Role != CliDB.ChrSpecializationStorage.LookupByKey(GetUInt32Value(PlayerFields.CurrentSpecId)).Role)
return TalentLearnResult.FailedUnknown;
}
// prevent learn talent for different class (cheating)
if (talentInfo.ClassID != 0 && talentInfo.ClassID != (int)GetClass())
if (talentInfo.SpecID != GetInt32Value(PlayerFields.CurrentSpecId))
return TalentLearnResult.FailedUnknown;
if (GetPrestigeLevel() == 0)
if (Global.DB2Mgr.GetRequiredHonorLevelForPvpTalent(talentInfo) > GetHonorLevel())
if (talentInfo.LevelRequired > getLevel())
return TalentLearnResult.FailedUnknown;
if (Global.DB2Mgr.GetRequiredLevelForPvpTalentSlot(slot, GetClass()) > getLevel())
return TalentLearnResult.FailedUnknown;
PvpTalentCategoryRecord talentCategory = CliDB.PvpTalentCategoryStorage.LookupByKey(talentInfo.PvpTalentCategoryID);
if (talentCategory != null)
if (!Convert.ToBoolean(talentCategory.TalentSlotMask & (1 << slot)))
return TalentLearnResult.FailedUnknown;
// Check if player doesn't have any talent in current tier
for (uint c = 0; c < PlayerConst.MaxPvpTalentColumns; ++c)
// Check if player doesn't have this talent in other slot
if (HasPvpTalent(talentID, GetActiveTalentGroup()))
return TalentLearnResult.FailedUnknown;
PvpTalentRecord talent = CliDB.PvpTalentStorage.LookupByKey(GetPvpTalentMap(GetActiveTalentGroup())[slot]);
if (talent != null)
{
foreach (PvpTalentRecord talent in Global.DB2Mgr.GetPvpTalentsByPosition((uint)GetClass(), (uint)talentInfo.TierID, c))
if (!HasFlag(PlayerFields.Flags, PlayerFlags.Resting) && !HasFlag(UnitFields.Flags2, UnitFlags2.AllowChangingTalents))
return TalentLearnResult.FailedRestArea;
if (GetSpellHistory().HasCooldown(talent.SpellID))
{
if (HasPvpTalent(talent.Id, GetActiveTalentGroup()) && !HasFlag(PlayerFields.Flags, PlayerFlags.Resting) && HasFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc))
return TalentLearnResult.FailedRestArea;
if (GetSpellHistory().HasCooldown(talent.SpellID))
{
spellOnCooldown = talent.SpellID;
return TalentLearnResult.FailedCantRemoveTalent;
}
RemovePvpTalent(talent);
spellOnCooldown = talent.SpellID;
return TalentLearnResult.FailedCantRemoveTalent;
}
RemovePvpTalent(talent);
}
if (!AddPvpTalent(talentInfo, GetActiveTalentGroup(), true))
if (!AddPvpTalent(talentInfo, GetActiveTalentGroup(), slot))
return TalentLearnResult.FailedUnknown;
return TalentLearnResult.LearnOk;
}
bool AddPvpTalent(PvpTalentRecord talent, byte activeTalentGroup, bool learning)
bool AddPvpTalent(PvpTalentRecord talent, byte activeTalentGroup, byte slot)
{
//ASSERT(talent);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talent.SpellID);
@@ -433,10 +391,7 @@ namespace Game.Entities
if (talent.OverridesSpellID != 0)
AddOverrideSpell(talent.OverridesSpellID, talent.SpellID);
if (learning)
GetPvpTalentMap(activeTalentGroup)[talent.Id] = PlayerSpellState.New;
else
GetPvpTalentMap(activeTalentGroup)[talent.Id] = PlayerSpellState.Unchanged;
GetPvpTalentMap(activeTalentGroup)[slot] = talent.Id;
return true;
}
@@ -453,27 +408,30 @@ namespace Game.Entities
if (talent.OverridesSpellID != 0)
RemoveOverrideSpell(talent.OverridesSpellID, talent.SpellID);
//todo check this
// if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted
if (!GetPvpTalentMap(GetActiveTalentGroup()).ContainsKey(talent.Id))
GetPvpTalentMap(GetActiveTalentGroup())[talent.Id] = PlayerSpellState.Removed;
GetPvpTalentMap(GetActiveTalentGroup()).Remove(talent.Id);
}
public void TogglePvpTalents(bool enable)
{
var pvpTalents = GetPvpTalentMap(GetActiveTalentGroup());
foreach (var pair in pvpTalents)
foreach (uint pvpTalentId in pvpTalents)
{
PvpTalentRecord pvpTalentInfo = CliDB.PvpTalentStorage.LookupByKey(pair.Key);
if (enable && pair.Value != PlayerSpellState.Removed)
LearnSpell(pvpTalentInfo.SpellID, false);
else
RemoveSpell(pvpTalentInfo.SpellID, true);
PvpTalentRecord pvpTalentInfo = CliDB.PvpTalentStorage.LookupByKey(pvpTalentId);
if (pvpTalentInfo != null)
{
if (enable)
LearnSpell(pvpTalentInfo.SpellID, false);
else
RemoveSpell(pvpTalentInfo.SpellID, true);
}
}
}
bool HasPvpTalent(uint talentID, byte activeTalentGroup)
{
return GetPvpTalentMap(activeTalentGroup).ContainsKey(talentID) && GetPvpTalentMap(activeTalentGroup)[talentID] != PlayerSpellState.Removed;
return GetPvpTalentMap(activeTalentGroup).Contains(talentID);
}
public void EnablePvpRules(bool dueToCombat = false)
@@ -554,7 +512,7 @@ namespace Game.Entities
return false;
}
public Dictionary<uint, PlayerSpellState> GetPvpTalentMap(uint spec) { return _specializationInfo.PvpTalents[spec]; }
public Array<uint> GetPvpTalentMap(byte spec) { return _specializationInfo.PvpTalents[spec]; }
//BGs
public Battleground GetBattleground()
@@ -913,7 +871,7 @@ namespace Game.Entities
//Arenas
public void SetArenaTeamInfoField(byte slot, ArenaTeamInfoType type, uint value)
{
SetUInt32Value(PlayerFields.ArenaTeamInfo11 + (slot * (int)ArenaTeamInfoType.End) + (int)type, value);
SetUInt32Value(ActivePlayerFields.ArenaTeamInfo + (slot * (int)ArenaTeamInfoType.End) + (int)type, value);
}
public void SetInArenaTeam(uint ArenaTeamId, byte slot, byte type)
@@ -956,8 +914,8 @@ namespace Game.Entities
}
while (result.NextRow());
}
public uint GetArenaTeamId(byte slot) { return GetUInt32Value(PlayerFields.ArenaTeamInfo11 + (slot * (int)ArenaTeamInfoType.End) + (int)ArenaTeamInfoType.Id); }
public uint GetArenaPersonalRating(byte slot) { return GetUInt32Value(PlayerFields.ArenaTeamInfo11 + (slot * (int)ArenaTeamInfoType.End) + (int)ArenaTeamInfoType.PersonalRating); }
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 void SetArenaTeamIdInvited(uint ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
public uint GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
public uint GetRBGPersonalRating() { return 0; }
+40 -19
View File
@@ -44,6 +44,35 @@ namespace Game.Entities
public List<uint> getRewardedQuests() { return m_RewardedQuests; }
Dictionary<uint, QuestStatusData> getQuestStatusMap() { return m_QuestStatus; }
public int GetQuestMinLevel(Quest quest)
{
if (quest.Level == -1 && quest.ScalingFactionGroup != 0)
{
ChrRacesRecord race = CliDB.ChrRacesStorage.LookupByKey(GetRace());
FactionTemplateRecord raceFaction = CliDB.FactionTemplateStorage.LookupByKey(race.FactionID);
if (raceFaction == null || raceFaction.FactionGroup != quest.ScalingFactionGroup)
return quest.MaxScalingLevel;
}
return quest.MinLevel;
}
public int GetQuestLevel(Quest quest)
{
if (quest == null)
return 0;
if (quest.Level == -1)
{
int minLevel = GetQuestMinLevel(quest);
int maxLevel = quest.MaxScalingLevel;
int level = (int)getLevel();
if (level >= minLevel)
return Math.Min(level, maxLevel);
return minLevel;
}
return quest.Level;
}
public int GetRewardedQuestCount() { return m_RewardedQuests.Count; }
public void LearnQuestRewardedSpells(Quest quest)
@@ -116,7 +145,7 @@ namespace Game.Entities
public void DailyReset()
{
foreach (uint questId in GetDynamicValues(PlayerDynamicFields.DailyQuests))
foreach (uint questId in GetDynamicValues(ActivePlayerDynamicFields.DailyQuests))
{
uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(questId);
if (questBit != 0)
@@ -124,10 +153,10 @@ namespace Game.Entities
}
DailyQuestsReset dailyQuestsReset = new DailyQuestsReset();
dailyQuestsReset.Count = GetDynamicValues(PlayerDynamicFields.DailyQuests).Length;
dailyQuestsReset.Count = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests).Length;
SendPacket(dailyQuestsReset);
ClearDynamicValue(PlayerDynamicFields.DailyQuests);
ClearDynamicValue(ActivePlayerDynamicFields.DailyQuests);
m_DFQuests.Clear(); // Dungeon Finder Quests.
@@ -210,14 +239,6 @@ namespace Game.Entities
return false;
}
public uint GetQuestLevel(Quest quest)
{
if (quest == null)
return getLevel();
return (uint)(quest.Level > 0 ? quest.Level : Math.Min((int)getLevel(), quest.MaxScalingLevel));
}
public bool IsQuestRewarded(uint quest_id)
{
return m_RewardedQuests.Contains(quest_id);
@@ -389,7 +410,7 @@ namespace Game.Entities
SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) &&
SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false))
{
return getLevel() + WorldConfig.GetIntValue(WorldCfg.QuestHighLevelHideDiff) >= quest.MinLevel;
return getLevel() + WorldConfig.GetIntValue(WorldCfg.QuestHighLevelHideDiff) >= GetQuestMinLevel(quest);
}
return false;
@@ -796,7 +817,7 @@ namespace Game.Entities
public uint GetQuestMoneyReward(Quest quest)
{
return (uint)(quest.MoneyValue(getLevel()) * WorldConfig.GetFloatValue(WorldCfg.RateMoneyQuest));
return (uint)(quest.MoneyValue(this) * WorldConfig.GetFloatValue(WorldCfg.RateMoneyQuest));
}
public uint GetQuestXPReward(Quest quest)
@@ -807,7 +828,7 @@ namespace Game.Entities
if (rewarded && !quest.IsDFQuest())
return 0;
uint XP = (uint)(quest.XPValue(getLevel()) * WorldConfig.GetFloatValue(WorldCfg.RateXpQuest));
uint XP = (uint)(quest.XPValue(this) * WorldConfig.GetFloatValue(WorldCfg.RateXpQuest));
// handle SPELL_AURA_MOD_XP_QUEST_PCT auras
var ModXPPctAuras = GetAuraEffectsByType(AuraType.ModXpQuestPct);
@@ -1231,7 +1252,7 @@ namespace Game.Entities
public bool SatisfyQuestLevel(Quest qInfo, bool msg)
{
if (getLevel() < qInfo.MinLevel)
if (getLevel() < GetQuestMinLevel(qInfo))
{
if (msg)
{
@@ -1588,7 +1609,7 @@ namespace Game.Entities
return true;
}
var dailies = GetDynamicValues(PlayerDynamicFields.DailyQuests);
var dailies = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests);
foreach (var dailyQuestId in dailies)
if (dailyQuestId == qInfo.Id)
return false;
@@ -2018,7 +2039,7 @@ namespace Game.Entities
if (fieldOffset >= PlayerConst.QuestsCompletedBitsSize)
return;
ApplyModFlag(PlayerFields.QuestCompleted + fieldOffset, (uint)(1 << (((int)questBit - 1) & 31)), completed);
ApplyModFlag(ActivePlayerFields.QuestCompleted + fieldOffset, (uint)(1 << (((int)questBit - 1) & 31)), completed);
}
public void AreaExploredOrEventHappens(uint questId)
@@ -2993,7 +3014,7 @@ namespace Game.Entities
{
if (!qQuest.IsDFQuest())
{
AddDynamicValue(PlayerDynamicFields.DailyQuests, quest_id);
AddDynamicValue(ActivePlayerDynamicFields.DailyQuests, quest_id);
m_lastDailyQuestTime = Time.UnixTime; // last daily quest time
m_DailyQuestChanged = true;
@@ -3012,7 +3033,7 @@ namespace Game.Entities
bool found = false;
if (Global.ObjectMgr.GetQuestTemplate(quest_id) != null)
{
var dailies = GetDynamicValues(PlayerDynamicFields.DailyQuests);
var dailies = GetDynamicValues(ActivePlayerDynamicFields.DailyQuests);
foreach (uint dailyQuestId in dailies)
{
if (dailyQuestId == quest_id)
+161 -79
View File
@@ -48,20 +48,20 @@ namespace Game.Entities
if (Global.SpellMgr.GetSkillRangeType(rcEntry) == SkillRangeType.Level)
{
ushort max = GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
// update only level dependent max skill values
if (max != 1)
{
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, maxSkill);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, maxSkill);
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, maxSkill);
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, maxSkill);
if (pair.Value.State != SkillState.New)
pair.Value.State = SkillState.Changed;
}
}
// Update level dependent skillline spells
LearnSkillRewardedSpells(rcEntry.SkillID, GetUInt16Value(PlayerFields.SkillLineRank + field, offset));
LearnSkillRewardedSpells(rcEntry.SkillID, GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset));
}
}
@@ -86,10 +86,10 @@ namespace Game.Entities
ushort field = (ushort)(skill.Value.Pos / 2);
byte offset = (byte)(skill.Value.Pos & 1);
ushort max = GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
if (max > 1)
{
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, max);
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, max);
if (skill.Value.State != SkillState.New)
skill.Value.State = SkillState.Changed;
@@ -109,9 +109,9 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
int result = GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
result += GetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset);
result += GetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset);
int result = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
result += GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
return (ushort)(result < 0 ? 0 : result);
}
@@ -127,9 +127,9 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
int result = GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
result += GetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset);
result += GetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset);
int result = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
result += GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
return (ushort)(result < 0 ? 0 : result);
}
@@ -145,7 +145,7 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
return GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
return GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
}
public ushort GetSkillStep(SkillType skill)
@@ -160,7 +160,7 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
return GetUInt16Value(PlayerFields.SkillLineStep + field, offset);
return GetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset);
}
public ushort GetPureMaxSkillValue(SkillType skill)
@@ -175,7 +175,7 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
return GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
return GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
}
public ushort GetBaseSkillValue(SkillType skill)
@@ -190,8 +190,8 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
var result = (int)GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
result += GetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset);
var result = (int)GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
result += GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
return (ushort)(result < 0 ? 0 : result);
}
@@ -207,7 +207,7 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
return GetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset);
return GetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset);
}
public ushort GetSkillTempBonusValue(uint skill)
@@ -222,12 +222,12 @@ namespace Game.Entities
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
return GetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset);
return GetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset);
}
void InitializeSelfResurrectionSpells()
{
ClearDynamicValue(PlayerDynamicFields.SelfResSpells);
ClearDynamicValue(ActivePlayerDynamicFields.SelfResSpells);
uint[] spells = new uint[3];
@@ -248,7 +248,7 @@ namespace Game.Entities
foreach (uint selfResSpell in spells)
if (selfResSpell != 0)
AddDynamicValue(PlayerDynamicFields.SelfResSpells, selfResSpell);
AddDynamicValue(ActivePlayerDynamicFields.SelfResSpells, selfResSpell);
}
public void PetSpellInitialize()
@@ -415,8 +415,7 @@ namespace Game.Entities
// levels sync. with spell requirement for skill levels to learn
// bonus abilities in sSkillLineAbilityStore
// Used only to avoid scan DBC at each skill grow
uint[] bonusSkillLevels = { 75, 150, 225, 300, 375, 450, 525 };
int bonusSkillLevelsSize = bonusSkillLevels.Length / sizeof(uint);
uint[] bonusSkillLevels = { 75, 150, 225, 300, 375, 450, 525, 600, 700, 850 };
Log.outDebug(LogFilter.Player, "UpdateSkillPro(SkillId {0}, Chance {0:D3}%)", skillId, chance / 10.0f);
if (skillId == 0)
@@ -435,8 +434,8 @@ namespace Game.Entities
ushort field = (ushort)(skillStatusData.Pos / 2);
byte offset = (byte)(skillStatusData.Pos & 1);
ushort value = GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
ushort max = GetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset);
ushort value = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
ushort max = GetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset);
if (max == 0 || value == 0 || value >= max)
return false;
@@ -451,13 +450,12 @@ namespace Game.Entities
if (new_value > max)
new_value = max;
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, new_value);
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, new_value);
if (skillStatusData.State != SkillState.New)
skillStatusData.State = SkillState.Changed;
for (int i = 0; i < bonusSkillLevelsSize; ++i)
foreach (uint bsl in bonusSkillLevels)
{
uint bsl = bonusSkillLevels[i];
if (value < bsl && new_value >= bsl)
{
LearnSkillRewardedSpells(skillId, new_value);
@@ -941,7 +939,7 @@ namespace Game.Entities
if (skill == null || skill.State == SkillState.Deleted)
return;
int field = (int)(skill.Pos / 2 + (talent ? PlayerFields.SkillLinePermBonus : PlayerFields.SkillLineTempBonus));
int field = (int)(skill.Pos / 2 + (talent ? ActivePlayerFields.SkillLinePermBonus : ActivePlayerFields.SkillLineTempBonus));
byte offset = (byte)(skill.Pos & 1);
ushort bonus = GetUInt16Value(field, offset);
@@ -1125,7 +1123,7 @@ namespace Game.Entities
{
var field = (ushort)(skillStatusData.Pos / 2);
var offset = (byte)(skillStatusData.Pos & 1);
currVal = GetUInt16Value(PlayerFields.SkillLineRank + field, offset);
currVal = GetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset);
if (newVal != 0)
{
// if skill value is going down, update enchantments before setting the new value
@@ -1133,10 +1131,10 @@ namespace Game.Entities
UpdateSkillEnchantments(id, currVal, (ushort)newVal);
// update step
SetUInt16Value(PlayerFields.SkillLineStep + field, offset, (ushort)step);
SetUInt16Value(ActivePlayerFields.SkillLineStep + field, offset, (ushort)step);
// update value
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, (ushort)newVal);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, (ushort)maxVal);
SetUInt16Value(ActivePlayerFields.SkillLineRank + field, offset, (ushort)newVal);
SetUInt16Value(ActivePlayerFields.SkillLineMaxRank + field, offset, (ushort)maxVal);
if (skillStatusData.State != SkillState.New)
skillStatusData.State = SkillState.Changed;
@@ -1154,12 +1152,12 @@ namespace Game.Entities
//remove enchantments needing this skill
UpdateSkillEnchantments(id, currVal, 0);
// clear skill fields
SetUInt16Value(PlayerFields.SkillLineId + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineStep + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset, 0);
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);
// mark as deleted or simply remove from map if not saved yet
if (skillStatusData.State != SkillState.New)
@@ -1168,15 +1166,21 @@ namespace Game.Entities
mSkillStatus.Remove(id);
// remove all spells that related to this skill
foreach (var pAbility in CliDB.SkillLineAbilityStorage.Values)
if (pAbility.SkillLine == id)
RemoveSpell(Global.SpellMgr.GetFirstSpellInChain(pAbility.Spell));
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)
{
if (childSkillLine.ParentSkillLineID == id)
SetSkill(childSkillLine.Id, 0, 0, 0);
}
// Clear profession lines
if (GetUInt32Value(PlayerFields.ProfessionSkillLine1) == id)
SetUInt32Value(PlayerFields.ProfessionSkillLine1, 0);
else if (GetUInt32Value(PlayerFields.ProfessionSkillLine1 + 1) == id)
SetUInt32Value(PlayerFields.ProfessionSkillLine1 + 1, 0);
if (GetUInt32Value(ActivePlayerFields.ProfessionSkillLine) == id)
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine, 0);
else if (GetUInt32Value(ActivePlayerFields.ProfessionSkillLine + 1) == id)
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine + 1, 0);
}
}
else if (newVal != 0) //add
@@ -1186,7 +1190,7 @@ namespace Game.Entities
{
var field = (ushort)(i / 2);
var offset = (byte)(i & 1);
if (GetUInt16Value(PlayerFields.SkillLineId + field, offset) == 0)
if (GetUInt16Value(ActivePlayerFields.SkillLineId + field, offset) == 0)
{
var skillEntry = CliDB.SkillLineStorage.LookupByKey(id);
if (skillEntry == null)
@@ -1195,18 +1199,31 @@ namespace Game.Entities
return;
}
SetUInt16Value(PlayerFields.SkillLineId + field, offset, (ushort)id);
if (skillEntry.CategoryID == SkillCategory.Profession)
if (skillEntry.ParentSkillLineID != 0 && skillEntry.ParentTierIndex > 0)
{
if (GetUInt32Value(PlayerFields.ProfessionSkillLine1) == 0)
SetUInt32Value(PlayerFields.ProfessionSkillLine1, id);
else if (GetUInt32Value(PlayerFields.ProfessionSkillLine1 + 1) == 0)
SetUInt32Value(PlayerFields.ProfessionSkillLine1 + 1, id);
SkillRaceClassInfoRecord rcEntry = Global.DB2Mgr.GetSkillRaceClassInfo(skillEntry.ParentSkillLineID, GetRace(), GetClass());
if (rcEntry != null)
{
SkillTiersEntry tier = Global.ObjectMgr.GetSkillTier(rcEntry.SkillTierID);
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]);
}
}
if (skillEntry.CategoryID == SkillCategory.Profession)
{
int freeProfessionSlot = FindProfessionSlotFor(id);
if (freeProfessionSlot != -1)
SetUInt32Value(ActivePlayerFields.ProfessionSkillLine + freeProfessionSlot, id);
}
}
SetUInt16Value(PlayerFields.SkillLineStep + field, offset, (ushort)step);
SetUInt16Value(PlayerFields.SkillLineRank + field, offset, (ushort)newVal);
SetUInt16Value(PlayerFields.SkillLineMaxRank + field, offset, (ushort)maxVal);
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);
UpdateSkillEnchantments(id, currVal, (ushort)newVal);
UpdateCriteria(CriteriaTypes.ReachSkillLevel, id);
@@ -1222,8 +1239,8 @@ namespace Game.Entities
mSkillStatus.Add(id, new SkillStatusData((uint)i, SkillState.New));
// apply skill bonuses
SetUInt16Value(PlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(PlayerFields.SkillLinePermBonus + field, offset, 0);
SetUInt16Value(ActivePlayerFields.SkillLineTempBonus + field, offset, 0);
SetUInt16Value(ActivePlayerFields.SkillLinePermBonus + field, offset, 0);
// temporary bonuses
var mModSkill = GetAuraEffectsByType(AuraType.ModSkill);
@@ -1264,22 +1281,22 @@ namespace Game.Entities
foreach (var _spell_idx in bounds)
{
if (_spell_idx.SkillLine != 0)
if (_spell_idx.SkillupSkillLineID != 0)
{
uint SkillValue = GetPureSkillValue((SkillType)_spell_idx.SkillLine);
uint SkillValue = GetPureSkillValue((SkillType)_spell_idx.SkillupSkillLineID);
// Alchemy Discoveries here
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(spellid);
if (spellEntry != null && spellEntry.Mechanic == Mechanics.Discovery)
{
uint discoveredSpell = SkillDiscovery.GetSkillDiscoverySpell(_spell_idx.SkillLine, spellid, this);
uint discoveredSpell = SkillDiscovery.GetSkillDiscoverySpell(_spell_idx.SkillupSkillLineID, spellid, this);
if (discoveredSpell != 0)
LearnSpell(discoveredSpell, false);
}
uint craft_skill_gain = _spell_idx.NumSkillUps * WorldConfig.GetUIntValue(WorldCfg.SkillGainCrafting);
return UpdateSkillPro(_spell_idx.SkillLine, SkillGainChance(SkillValue, _spell_idx.TrivialSkillLineRankHigh,
return UpdateSkillPro(_spell_idx.SkillupSkillLineID, SkillGainChance(SkillValue, _spell_idx.TrivialSkillLineRankHigh,
(uint)(_spell_idx.TrivialSkillLineRankHigh + _spell_idx.TrivialSkillLineRankLow) / 2, _spell_idx.TrivialSkillLineRankLow), craft_skill_gain);
}
}
@@ -1299,15 +1316,39 @@ namespace Game.Entities
switch (SkillId)
{
case SkillType.Herbalism:
case SkillType.Herbalism2:
case SkillType.OutlandHerbalism:
case SkillType.NorthrendHerbalism:
case SkillType.CataclysmHerbalism:
case SkillType.PandariaHerbalism:
case SkillType.DraenorHerbalism:
case SkillType.LegionHerbalism:
case SkillType.KulTiranHerbalism:
case SkillType.Jewelcrafting:
case SkillType.Inscription:
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * (int)Multiplicator, gathering_skill_gain);
case SkillType.Skinning:
case SkillType.Skinning2:
case SkillType.OutlandSkinning:
case SkillType.NorthrendSkinning:
case SkillType.CataclysmSkinning:
case SkillType.PandariaSkinning:
case SkillType.DraenorSkinning:
case SkillType.LegionSkinning:
case SkillType.KulTiranSkinning:
if (WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * (int)Multiplicator, gathering_skill_gain);
else
return UpdateSkillPro(SkillId, (int)(SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (int)(SkillValue / WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps)), gathering_skill_gain);
case SkillType.Mining:
case SkillType.Mining2:
case SkillType.OutlandMining:
case SkillType.NorthrendMining:
case SkillType.CataclysmMining:
case SkillType.PandariaMining:
case SkillType.DraenorMining:
case SkillType.LegionMining:
case SkillType.KulTiranMining:
if (WorldConfig.GetIntValue(WorldCfg.SkillChanceMiningSteps) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * (int)Multiplicator, gathering_skill_gain);
else
@@ -1585,9 +1626,11 @@ namespace Game.Entities
void LearnSkillRewardedSpells(uint skillId, uint skillValue)
{
long raceMask = getRaceMask();
ulong raceMask = getRaceMask();
uint classMask = getClassMask();
foreach (var ability in CliDB.SkillLineAbilityStorage.Values)
List<SkillLineAbilityRecord> skillLineAbilities = Global.DB2Mgr.GetSkillLineAbilitiesBySkill(skillId);
foreach (var ability in skillLineAbilities)
{
if (ability.SkillLine != skillId)
continue;
@@ -1596,11 +1639,11 @@ namespace Game.Entities
if (spellInfo == null)
continue;
if (ability.AcquireMethod != AbilytyLearnType.OnSkillValue && ability.AcquireMethod != AbilytyLearnType.OnSkillLearn)
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).
if (skillId == (uint)SkillType.Riding && (ability.AcquireMethod != AbilytyLearnType.OnSkillLearn || ability.NumSkillUps != 1))
if (skillId == (uint)SkillType.Riding && (ability.AcquireMethod != AbilityLearnType.OnSkillLearn || ability.NumSkillUps != 1))
continue;
// Check race if set
@@ -1616,7 +1659,7 @@ namespace Game.Entities
continue;
// need unlearn spell
if (skillValue < ability.MinSkillLineRank && ability.AcquireMethod == AbilytyLearnType.OnSkillValue)
if (skillValue < ability.MinSkillLineRank && ability.AcquireMethod == AbilityLearnType.OnSkillValue)
RemoveSpell(ability.Spell);
// need learn
else if (!IsInWorld)
@@ -1627,6 +1670,49 @@ namespace Game.Entities
}
}
int FindProfessionSlotFor(uint skillId)
{
SkillLineRecord skillEntry = CliDB.SkillLineStorage.LookupByKey(skillId);
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;
}
// if there is no same profession, find any free slot
for (var slot = professionsBegin; slot < professionsEnd; ++slot)
if (GetUInt32Value(slot) == 0)
return slot - professionsBegin;
return -1;
}
void RemoveItemDependentAurasAndCasts(Item pItem)
{
foreach (var pair in GetOwnedAuras())
@@ -1920,19 +2006,15 @@ namespace Game.Entities
break;
case SkillRangeType.Rank:
{
ushort rank = 1;
if (GetClass() == Class.Deathknight && skillId == SkillType.FirstAid)
rank = 4;
SkillTiersEntry tier = Global.ObjectMgr.GetSkillTier(rcInfo.SkillTierID);
ushort maxValue = (ushort)tier.Value[Math.Max(rank - 1, 0)];
ushort maxValue = (ushort)tier.Value[0];
ushort skillValue = 1;
if (rcInfo.Flags.HasAnyFlag(SkillRaceClassInfoFlags.AlwaysMaxValue))
skillValue = maxValue;
else if (GetClass() == Class.Deathknight)
skillValue = (ushort)Math.Min(Math.Max(1, (getLevel() - 1) * 5), maxValue);
SetSkill(skillId, rank, skillValue, maxValue);
SetSkill(skillId, 1, skillValue, maxValue);
break;
}
default:
@@ -1945,7 +2027,7 @@ namespace Game.Entities
SendKnownSpells knownSpells = new SendKnownSpells();
knownSpells.InitialLogin = false; // @todo
foreach (var spell in m_spells)
foreach (var spell in m_spells.ToList())
{
if (spell.Value.State == PlayerSpellState.Removed)
continue;
@@ -2484,7 +2566,7 @@ namespace Game.Entities
continue;
// Runeforging special case
if ((_spell_idx.AcquireMethod == AbilytyLearnType.OnSkillLearn && !HasSkill((SkillType)_spell_idx.SkillLine))
if ((_spell_idx.AcquireMethod == AbilityLearnType.OnSkillLearn && !HasSkill((SkillType)_spell_idx.SkillLine))
|| ((_spell_idx.SkillLine == (int)SkillType.Runeforging) && _spell_idx.TrivialSkillLineRankHigh == 0))
{
SkillRaceClassInfoRecord rcInfo = Global.DB2Mgr.GetSkillRaceClassInfo(_spell_idx.SkillLine, GetRace(), GetClass());
@@ -3157,10 +3239,10 @@ namespace Game.Entities
// Check no reagent use mask
FlagArray128 noReagentMask = new FlagArray128();
noReagentMask[0] = GetUInt32Value(PlayerFields.NoReagentCost1);
noReagentMask[1] = GetUInt32Value(PlayerFields.NoReagentCost1 + 1);
noReagentMask[2] = GetUInt32Value(PlayerFields.NoReagentCost1 + 2);
noReagentMask[3] = GetUInt32Value(PlayerFields.NoReagentCost1 + 3);
noReagentMask[0] = GetUInt32Value(ActivePlayerFields.NoReagentCost);
noReagentMask[1] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 1);
noReagentMask[2] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 2);
noReagentMask[3] = GetUInt32Value(ActivePlayerFields.NoReagentCost + 3);
if (spellInfo.SpellFamilyFlags & noReagentMask)
return true;
+14 -53
View File
@@ -33,7 +33,7 @@ namespace Game.Entities
if (level < PlayerConst.MinSpecializationLevel)
ResetTalentSpecialization();
uint talentTiers = CalculateTalentsTiers();
uint talentTiers = (uint)Global.DB2Mgr.GetNumTalentsAtLevel(level, GetClass());
if (level < 15)
{
// Remove all talent points
@@ -50,7 +50,7 @@ namespace Game.Entities
}
}
SetUInt32Value(PlayerFields.MaxTalentTiers, talentTiers);
SetUInt32Value(ActivePlayerFields.MaxTalentTiers, talentTiers);
if (!GetSession().PlayerLoading())
SendTalentsInfoData(); // update at client
@@ -127,7 +127,7 @@ namespace Game.Entities
return TalentLearnResult.FailedUnknown;
// check if we have enough talent points
if (talentInfo.TierID >= GetUInt32Value(PlayerFields.MaxTalentTiers))
if (talentInfo.TierID >= GetUInt32Value(ActivePlayerFields.MaxTalentTiers))
return TalentLearnResult.FailedUnknown;
// TODO: prevent changing talents that are on cooldown
@@ -244,8 +244,8 @@ namespace Game.Entities
void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; }
// Loot Spec
public void SetLootSpecId(uint id) { SetUInt32Value(PlayerFields.LootSpecId, id); }
uint GetLootSpecId() { return GetUInt32Value(PlayerFields.LootSpecId); }
public void SetLootSpecId(uint id) { SetUInt32Value(ActivePlayerFields.LootSpecId, id); }
uint GetLootSpecId() { return GetUInt32Value(ActivePlayerFields.LootSpecId); }
public uint GetDefaultSpecId()
{
@@ -312,15 +312,6 @@ namespace Game.Entities
foreach (var talentInfo in CliDB.PvpTalentStorage.Values)
{
// unlearn only talents for character class
// some spell learned by one class as normal spells or know at creation but another class learn it as talent,
// to prevent unexpected lost normal learned spell skip another class talents
if (talentInfo.ClassID != 0 && talentInfo.ClassID != (int)GetClass())
continue;
if (talentInfo.SpellID == 0)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID);
if (spellInfo == null)
continue;
@@ -364,17 +355,16 @@ namespace Game.Entities
}
}
foreach (var talentInfo in CliDB.PvpTalentStorage.Values)
for (byte slot = 0; slot < PlayerConst.MaxPvpTalentSlots; ++slot)
{
// learn only talents for character class (or x-class talents)
if (talentInfo.ClassID != 0 && talentInfo.ClassID != (int)GetClass())
PvpTalentRecord talentInfo = CliDB.PvpTalentStorage.LookupByKey(GetPvpTalentMap(GetActiveTalentGroup())[slot]);
if (talentInfo == null)
continue;
if (talentInfo.SpellID == 0)
continue;
if (HasPvpTalent(talentInfo.Id, GetActiveTalentGroup()))
AddPvpTalent(talentInfo, GetActiveTalentGroup(), true);
AddPvpTalent(talentInfo, GetActiveTalentGroup(), slot);
}
LearnSpecializationSpells();
@@ -558,9 +548,6 @@ namespace Game.Entities
continue;
}
if (talentInfo.ClassID != (uint)GetClass())
continue;
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID);
if (spellEntry == null)
{
@@ -571,21 +558,18 @@ namespace Game.Entities
groupInfoPkt.TalentIDs.Add((ushort)pair.Key);
}
foreach (var pair in pvpTalents)
for (byte slot = 0; slot < PlayerConst.MaxPvpTalentSlots; ++slot)
{
if (pair.Value == PlayerSpellState.Removed)
if (pvpTalents[slot] == 0)
continue;
PvpTalentRecord talentInfo = CliDB.PvpTalentStorage.LookupByKey(pair.Key);
PvpTalentRecord talentInfo = CliDB.PvpTalentStorage.LookupByKey(pvpTalents[slot]);
if (talentInfo == null)
{
Log.outError(LogFilter.Player, $"Player.SendTalentsInfoData: Player '{GetName()}' ({GetGUID().ToString()}) has unknown pvp talent id: {pair.Key}");
Log.outError(LogFilter.Player, $"Player.SendTalentsInfoData: Player '{GetName()}' ({GetGUID().ToString()}) has unknown pvp talent id: {pvpTalents[slot]}");
continue;
}
if (talentInfo.ClassID != 0 && talentInfo.ClassID != (int)GetClass())
continue;
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID);
if (spellEntry == null)
{
@@ -593,7 +577,7 @@ namespace Game.Entities
continue;
}
groupInfoPkt.PvPTalentIDs.Add((ushort)pair.Key);
groupInfoPkt.PvPTalentIDs.Add((ushort)pvpTalents[slot]);
}
packet.Info.TalentGroups.Add(groupInfoPkt);
@@ -610,28 +594,5 @@ namespace Game.Entities
respecWipeConfirm.RespecType = SpecResetType.Talents;
SendPacket(respecWipeConfirm);
}
uint CalculateTalentsTiers()
{
uint[] rowLevels = new uint[0];
switch (GetClass())
{
case Class.Deathknight:
rowLevels = new uint[] { 57, 58, 59, 60, 75, 90, 100 };
break;
case Class.DemonHunter:
rowLevels = new uint[] { 99, 100, 102, 104, 106, 108, 110 };
break;
default:
rowLevels = new uint[] { 15, 30, 45, 60, 75, 90, 100 };
break;
}
for (uint i = PlayerConst.MaxTalentTiers; i != 0; --i)
if (getLevel() >= rowLevels[i - 1])
return i;
return 0;
}
}
}
+100 -102
View File
@@ -48,8 +48,8 @@ namespace Game.Entities
objectTypeMask |= TypeMask.Player;
objectTypeId = TypeId.Player;
valuesCount = (int)PlayerFields.End;
_dynamicValuesCount = (int)PlayerDynamicFields.End;
valuesCount = (int)ActivePlayerFields.End;
_dynamicValuesCount = (int)ActivePlayerDynamicFields.End;
Session = session;
// players always accept
@@ -214,7 +214,7 @@ namespace Game.Entities
SetFlag(UnitFields.Flags2, UnitFlags2.RegeneratePower);
SetFloatValue(UnitFields.HoverHeight, 1.0f); // default for players in 3.0.3
SetUInt32Value(PlayerFields.WatchedFactionIndex, 0xFFFFFFFF); // -1 is default value
SetUInt32Value(ActivePlayerFields.WatchedFactionIndex, 0xFFFFFFFF); // -1 is default value
SetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetSkinId, createInfo.Skin);
SetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetFaceId, createInfo.Face);
@@ -223,23 +223,23 @@ namespace Game.Entities
SetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle, createInfo.FacialHairStyle);
for (byte i = 0; i < PlayerConst.CustomDisplaySize; ++i)
SetByteValue(PlayerFields.Bytes2, (byte)(PlayerFieldOffsets.Bytes2OffsetCustomDisplayOption + i), createInfo.CustomDisplay[i]);
SetUInt32Value(PlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp, (uint)((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.NotRAFLinked));
SetUInt32Value(PlayerFields.RestInfo + PlayerFieldOffsets.RestStateHonor, (uint)PlayerRestState.NotRAFLinked);
SetUInt32Value(ActivePlayerFields.RestInfo + PlayerFieldOffsets.RestStateXp, (uint)((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.NotRAFLinked));
SetUInt32Value(ActivePlayerFields.RestInfo + PlayerFieldOffsets.RestStateHonor, (uint)PlayerRestState.NotRAFLinked);
SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender, (byte)createInfo.Sex);
SetByteValue(PlayerFields.Bytes4, PlayerFieldOffsets.Bytes4OffsetArenaFaction, 0);
SetInventorySlotCount(InventorySlots.DefaultSize);
SetGuidValue(ObjectFields.Data, ObjectGuid.Empty);
SetGuidValue(UnitFields.GuildGuid, ObjectGuid.Empty);
SetUInt32Value(PlayerFields.GuildRank, 0);
SetGuildLevel(0);
SetUInt32Value(PlayerFields.GuildTimestamp, 0);
for (int i = 0; i < PlayerConst.KnowTitlesSize; ++i)
SetUInt64Value(PlayerFields.KnownTitles + i, 0); // 0=disabled
SetUInt64Value(ActivePlayerFields.KnownTitles + i, 0); // 0=disabled
SetUInt32Value(PlayerFields.ChosenTitle, 0);
SetUInt32Value(PlayerFields.Kills, 0);
SetUInt32Value(PlayerFields.LifetimeHonorableKills, 0);
SetUInt32Value(ActivePlayerFields.Kills, 0);
SetUInt32Value(ActivePlayerFields.LifetimeHonorableKills, 0);
// set starting level
uint start_level = WorldConfig.GetUIntValue(WorldCfg.StartPlayerLevel);
@@ -274,7 +274,7 @@ namespace Game.Entities
InitRunes();
SetUInt64Value(PlayerFields.Coinage, WorldConfig.GetUIntValue(WorldCfg.StartPlayerMoney));
SetUInt64Value(ActivePlayerFields.Coinage, WorldConfig.GetUIntValue(WorldCfg.StartPlayerMoney));
SetCurrency(CurrencyTypes.ApexisCrystals, WorldConfig.GetUIntValue(WorldCfg.CurrencyStartApexisCrystals));
SetCurrency(CurrencyTypes.JusticePoints, WorldConfig.GetUIntValue(WorldCfg.CurrencyStartJusticePoints));
@@ -282,7 +282,7 @@ namespace Game.Entities
if (WorldConfig.GetBoolValue(WorldCfg.StartAllExplored))
{
for (ushort i = 0; i < PlayerConst.ExploredZonesSize; i++)
SetFlag(PlayerFields.ExploredZones1 + i, 0xFFFFFFFF);
SetFlag(ActivePlayerFields.ExploredZones + i, 0xFFFFFFFF);
}
//Reputations if "StartAllReputation" is enabled, -- TODO: Fix this in a better way
@@ -741,6 +741,18 @@ namespace Game.Entities
if (pet != null && !pet.IsWithinDistInMap(this, GetMap().GetVisibilityRange()) && !pet.isPossessed())
RemovePet(pet, PetSaveMode.NotInSlot, true);
if (IsAlive())
{
if (m_hostileReferenceCheckTimer <= diff)
{
m_hostileReferenceCheckTimer = 15 * Time.InMilliseconds;
if (!GetMap().IsDungeon())
getHostileRefManager().deleteReferencesOutOfRange(GetVisibilityRange());
}
else
m_hostileReferenceCheckTimer -= diff;
}
//we should execute delayed teleports only for alive(!) players
//because we don't want player's ghost teleported from graveyard
if (IsHasDelayedTeleport() && IsAlive())
@@ -783,7 +795,7 @@ namespace Game.Entities
if (IsAlive() && !oldIsAlive)
//clear aura case after resurrection by another way (spells will be applied before next death)
ClearDynamicValue(PlayerDynamicFields.SelfResSpells);
ClearDynamicValue(ActivePlayerDynamicFields.SelfResSpells);
}
public override void DestroyForPlayer(Player target)
@@ -1662,15 +1674,15 @@ namespace Game.Entities
continue;
if (quest.IsDaily())
rep = CalculateReputationGain(ReputationSource.DailyQuest, GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
rep = CalculateReputationGain(ReputationSource.DailyQuest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
else if (quest.IsWeekly())
rep = CalculateReputationGain(ReputationSource.WeeklyQuest, GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
rep = CalculateReputationGain(ReputationSource.WeeklyQuest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
else if (quest.IsMonthly())
rep = CalculateReputationGain(ReputationSource.MonthlyQuest, GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
rep = CalculateReputationGain(ReputationSource.MonthlyQuest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
else if (quest.IsRepeatable())
rep = CalculateReputationGain(ReputationSource.RepeatableQuest, GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
rep = CalculateReputationGain(ReputationSource.RepeatableQuest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
else
rep = CalculateReputationGain(ReputationSource.Quest, GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
rep = CalculateReputationGain(ReputationSource.Quest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus);
bool noSpillover = Convert.ToBoolean(quest.RewardReputationMask & (1 << i));
GetReputationMgr().ModifyReputation(factionEntry, rep, noSpillover);
@@ -4180,7 +4192,7 @@ namespace Game.Entities
if (m_unitMovedByMe == obj)
return true;
ObjectGuid guid = GetGuidValue(PlayerFields.Farsight);
ObjectGuid guid = GetGuidValue(ActivePlayerFields.Farsight);
if (!guid.IsEmpty())
if (obj.GetGUID() == guid)
return true;
@@ -4542,7 +4554,7 @@ namespace Game.Entities
setDeathState(DeathState.Corpse);
SetUInt32Value(ObjectFields.DynamicFlags, 0);
ApplyModFlag(PlayerFields.LocalFlags, PlayerLocalFlags.ReleaseTimer, !CliDB.MapStorage.LookupByKey(GetMapId()).Instanceable() && !HasAuraType(AuraType.PreventResurrection));
ApplyModFlag(ActivePlayerFields.LocalFlags, PlayerLocalFlags.ReleaseTimer, !CliDB.MapStorage.LookupByKey(GetMapId()).Instanceable() && !HasAuraType(AuraType.PreventResurrection));
// 6 minutes until repop at graveyard
m_deathTimer = 6 * Time.Minute * Time.InMilliseconds;
@@ -5009,6 +5021,7 @@ namespace Game.Entities
displayPlayerChoice.CloseChoiceFrame = false;
displayPlayerChoice.HideWarboardHeader = playerChoice.HideWarboardHeader;
displayPlayerChoice.KeepOpenAfterChoice = playerChoice.KeepOpenAfterChoice;
for (var i = 0; i < playerChoice.Responses.Count; ++i)
{
@@ -5017,6 +5030,9 @@ namespace Game.Entities
playerChoiceResponse.ResponseID = playerChoiceResponseTemplate.ResponseId;
playerChoiceResponse.ChoiceArtFileID = playerChoiceResponseTemplate.ChoiceArtFileId;
playerChoiceResponse.Flags = playerChoiceResponseTemplate.Flags;
playerChoiceResponse.WidgetSetID = playerChoiceResponseTemplate.WidgetSetID;
playerChoiceResponse.GroupID = playerChoiceResponseTemplate.GroupID;
playerChoiceResponse.Answer = playerChoiceResponseTemplate.Answer;
playerChoiceResponse.Header = playerChoiceResponseTemplate.Header;
playerChoiceResponse.Description = playerChoiceResponseTemplate.Description;
@@ -5173,7 +5189,7 @@ namespace Game.Entities
public int GetTeamId() { return m_team == Team.Alliance ? TeamId.Alliance : TeamId.Horde; }
//Money
public ulong GetMoney() { return GetUInt64Value(PlayerFields.Coinage); }
public ulong GetMoney() { return GetUInt64Value(ActivePlayerFields.Coinage); }
public bool HasEnoughMoney(ulong amount) { return GetMoney() >= amount; }
public bool HasEnoughMoney(long amount)
{
@@ -5205,7 +5221,7 @@ namespace Game.Entities
}
public void SetMoney(ulong value)
{
SetUInt64Value(PlayerFields.Coinage, value);
SetUInt64Value(ActivePlayerFields.Coinage, value);
MoneyChanged((uint)value);
UpdateCriteria(CriteriaTypes.HighestGoldValueOwned);
}
@@ -5246,19 +5262,18 @@ namespace Game.Entities
public void SetInGuild(ulong guildId)
{
if (guildId != 0)
SetGuidValue(ObjectFields.Data, ObjectGuid.Create(HighGuid.Guild, guildId));
SetGuidValue(UnitFields.GuildGuid, ObjectGuid.Create(HighGuid.Guild, guildId));
else
SetGuidValue(ObjectFields.Data, ObjectGuid.Empty);
SetGuidValue(UnitFields.GuildGuid, ObjectGuid.Empty);
ApplyModFlag(PlayerFields.Flags, PlayerFlags.GuildLevelEnabled, guildId != 0);
SetUInt16Value(ObjectFields.Type, 1, (ushort)(guildId != 0 ? 1 : 0));
}
public void SetGuildRank(uint rankId) { SetUInt32Value(PlayerFields.GuildRank, rankId); }
byte GetGuildRank() { return (byte)GetUInt32Value(PlayerFields.GuildRank); }
public void SetGuildLevel(uint level) { SetUInt32Value(PlayerFields.GuildLevel, level); }
uint GetGuildLevel() { return GetUInt32Value(PlayerFields.GuildLevel); }
public void SetGuildIdInvited(ulong GuildId) { m_GuildIdInvited = GuildId; }
public uint GetGuildId() { return GetUInt32Value(ObjectFields.Data); }
public uint GetGuildId() { return GetUInt32Value(UnitFields.GuildGuid); }
public Guild GetGuild()
{
uint guildId = GetGuildId();
@@ -5270,7 +5285,7 @@ namespace Game.Entities
return GetGuildId() != 0 ? Global.GuildMgr.GetGuildById(GetGuildId()).GetName() : "";
}
public void SetFreePrimaryProfessions(uint profs) { SetUInt32Value(PlayerFields.CharacterPoints, profs); }
public void SetFreePrimaryProfessions(uint profs) { SetUInt32Value(ActivePlayerFields.CharacterPoints, profs); }
public void GiveLevel(uint level)
{
var oldLevel = getLevel();
@@ -5301,13 +5316,12 @@ namespace Game.Entities
for (Stats i = Stats.Strength; i < Stats.Max; ++i)
packet.StatDelta[(int)i] = info.stats[(int)i] - (int)GetCreateStat(i);
uint[] rowLevels = (GetClass() != Class.Deathknight) ? PlayerConst.DefaultTalentRowLevels : PlayerConst.DKTalentRowLevels;
packet.Cp = rowLevels.Any(p => p == level) ? 1 : 0;
packet.NumNewTalents = (int)(Global.DB2Mgr.GetNumTalentsAtLevel(level, GetClass()) - Global.DB2Mgr.GetNumTalentsAtLevel(oldLevel, GetClass()));
packet.NumNewPvpTalentSlots = Global.DB2Mgr.GetPvpTalentNumSlotsAtLevel(level, GetClass()) - Global.DB2Mgr.GetPvpTalentNumSlotsAtLevel(oldLevel, GetClass());
SendPacket(packet);
SetUInt32Value(PlayerFields.NextLevelXp, Global.ObjectMgr.GetXPForLevel(level));
SetUInt32Value(ActivePlayerFields.NextLevelXp, Global.ObjectMgr.GetXPForLevel(level));
//update level, max level of skills
m_PlayedTimeLevel = 0; // Level Played Time reset
@@ -5377,8 +5391,8 @@ namespace Game.Entities
{
++m_grantableLevels;
if (!HasByteFlag(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01))
SetByteFlag(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01);
if (!HasByteFlag(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01))
SetByteFlag(ActivePlayerFields.Bytes, PlayerFieldOffsets.FieldBytesOffsetRafGrantableLevel, 0x01);
}
}
}
@@ -5449,6 +5463,8 @@ namespace Game.Entities
Log.outError(LogFilter.Player, "Player {0} ({1}) has invalid gender {2}", GetName(), GetGUID().ToString(), gender);
return;
}
SetUInt32Value(UnitFields.StateAnimId, (uint)CliDB.AnimationDataStorage.Count);
}
//Creature
@@ -5782,8 +5798,8 @@ namespace Game.Entities
PlayerLevelInfo info = Global.ObjectMgr.GetPlayerLevelInfo(GetRace(), GetClass(), getLevel());
SetUInt32Value(PlayerFields.MaxLevel, WorldConfig.GetUIntValue(WorldCfg.MaxPlayerLevel));
SetUInt32Value(PlayerFields.NextLevelXp, Global.ObjectMgr.GetXPForLevel(getLevel()));
SetUInt32Value(ActivePlayerFields.MaxLevel, WorldConfig.GetUIntValue(WorldCfg.MaxPlayerLevel));
SetUInt32Value(ActivePlayerFields.NextLevelXp, Global.ObjectMgr.GetXPForLevel(getLevel()));
// reset before any aura state sources (health set/aura apply)
SetUInt32Value(UnitFields.AuraState, 0);
@@ -5813,26 +5829,26 @@ namespace Game.Entities
//set create powers
SetCreateMana(basemana);
SetArmor((int)(GetCreateStat(Stats.Agility) * 2));
SetArmor((int)(GetCreateStat(Stats.Agility) * 2), 0);
InitStatBuffMods();
//reset rating fields values
for (var index = PlayerFields.CombatRating1; index < PlayerFields.CombatRating1 + (int)CombatRating.Max; ++index)
SetUInt32Value(index, 0);
for (var index = 0; index < (int)CombatRating.Max; ++index)
SetUInt32Value(ActivePlayerFields.CombatRating + index, 0);
SetUInt32Value(PlayerFields.ModHealingDonePos, 0);
SetFloatValue(PlayerFields.ModHealingPct, 1.0f);
SetFloatValue(PlayerFields.ModHealingDonePct, 1.0f);
SetFloatValue(PlayerFields.ModPeriodicHealingDonePercent, 1.0f);
SetUInt32Value(ActivePlayerFields.ModHealingDonePos, 0);
SetFloatValue(ActivePlayerFields.ModHealingPct, 1.0f);
SetFloatValue(ActivePlayerFields.ModHealingDonePct, 1.0f);
SetFloatValue(ActivePlayerFields.ModPeriodicHealingDonePercent, 1.0f);
for (byte i = 0; i < 7; ++i)
{
SetInt32Value(PlayerFields.ModDamageDoneNeg + i, 0);
SetInt32Value(PlayerFields.ModDamageDonePos + i, 0);
SetFloatValue(PlayerFields.ModDamageDonePct + i, 1.0f);
SetInt32Value(ActivePlayerFields.ModDamageDoneNeg + i, 0);
SetInt32Value(ActivePlayerFields.ModDamageDonePos + i, 0);
SetFloatValue(ActivePlayerFields.ModDamageDonePct + i, 1.0f);
}
SetFloatValue(PlayerFields.ModSpellPowerPct, 1.0f);
SetFloatValue(ActivePlayerFields.ModSpellPowerPct, 1.0f);
//reset attack power, damage and attack speed fields
for (byte i = 0; i < (int)WeaponAttackType.Max; ++i)
@@ -5846,8 +5862,8 @@ namespace Game.Entities
SetFloatValue(UnitFields.MaxRangedDamage, 0.0f);
for (var i = 0; i < 3; ++i)
{
SetFloatValue(PlayerFields.WeaponDmgMultipliers + i, 1.0f);
SetFloatValue(PlayerFields.WeaponAtkSpeedMultipliers + i, 1.0f);
SetFloatValue(ActivePlayerFields.WeaponDmgMultipliers + i, 1.0f);
SetFloatValue(ActivePlayerFields.WeaponAtkSpeedMultipliers + i, 1.0f);
}
SetInt32Value(UnitFields.AttackPower, 0);
@@ -5856,44 +5872,42 @@ namespace Game.Entities
SetFloatValue(UnitFields.RangedAttackPowerMultiplier, 0.0f);
// Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
SetFloatValue(PlayerFields.CritPercentage, 0.0f);
SetFloatValue(PlayerFields.OffhandCritPercentage, 0.0f);
SetFloatValue(PlayerFields.RangedCritPercentage, 0.0f);
SetFloatValue(ActivePlayerFields.CritPercentage, 0.0f);
SetFloatValue(ActivePlayerFields.OffhandCritPercentage, 0.0f);
SetFloatValue(ActivePlayerFields.RangedCritPercentage, 0.0f);
// Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
SetFloatValue(PlayerFields.SpellCritPercentage1, 0.0f);
SetFloatValue(ActivePlayerFields.SpellCritPercentage1, 0.0f);
SetFloatValue(PlayerFields.ParryPercentage, 0.0f);
SetFloatValue(PlayerFields.BlockPercentage, 0.0f);
SetFloatValue(ActivePlayerFields.ParryPercentage, 0.0f);
SetFloatValue(ActivePlayerFields.BlockPercentage, 0.0f);
// Static 30% damage blocked
SetUInt32Value(PlayerFields.ShieldBlock, 30);
SetUInt32Value(ActivePlayerFields.ShieldBlock, 30);
// Dodge percentage
SetFloatValue(PlayerFields.DodgePercentage, 0.0f);
SetFloatValue(ActivePlayerFields.DodgePercentage, 0.0f);
// set armor (resistance 0) to original value (create_agility*2)
SetArmor((int)(GetCreateStat(Stats.Agility) * 2));
SetResistanceBuffMods(SpellSchools.Normal, true, 0.0f);
SetResistanceBuffMods(SpellSchools.Normal, false, 0.0f);
SetArmor((int)(GetCreateStat(Stats.Agility) * 2), 0);
SetBonusResistanceMod(SpellSchools.Normal, 0);
// set other resistance to original value (0)
for (var spellSchool = SpellSchools.Holy; spellSchool < SpellSchools.Max; ++spellSchool)
{
SetResistance(spellSchool, 0);
SetResistanceBuffMods(spellSchool, true, 0.0f);
SetResistanceBuffMods(spellSchool, false, 0.0f);
SetBonusResistanceMod(spellSchool, 0);
}
SetUInt32Value(PlayerFields.ModTargetResistance, 0);
SetUInt32Value(PlayerFields.ModTargetPhysicalResistance, 0);
SetUInt32Value(ActivePlayerFields.ModTargetResistance, 0);
SetUInt32Value(ActivePlayerFields.ModTargetPhysicalResistance, 0);
for (var i = 0; i < (int)SpellSchools.Max; ++i)
{
SetUInt32Value(UnitFields.PowerCostModifier + i, 0);
SetFloatValue(UnitFields.PowerCostMultiplier + i, 0.0f);
}
// Reset no reagent cost field
for (byte i = 0; i < 3; ++i)
SetUInt32Value(PlayerFields.NoReagentCost1 + i, 0);
for (byte i = 0; i < 4; ++i)
SetUInt32Value(ActivePlayerFields.NoReagentCost + i, 0);
// Init data for form but skip reapply item mods for form
InitDataForForm(reapplyMods);
@@ -5925,9 +5939,9 @@ namespace Game.Entities
RemoveByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, (UnitBytes2Flags.FFAPvp | UnitBytes2Flags.Sanctuary));
// restore if need some important flags
SetByteValue(PlayerFields.FieldBytes2, PlayerFieldOffsets.FieldBytes2OffsetIgnorePowerRegenPredictionMask, 0);
SetByteValue(PlayerFields.FieldBytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, 0);
SetByteValue(PlayerFields.FieldBytes2, 3, 0);
SetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetIgnorePowerRegenPredictionMask, 0);
SetByteValue(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, 0);
SetByteValue(ActivePlayerFields.Bytes2, 3, 0);
if (reapplyMods) // reapply stats values only on .reset stats (level) command
_ApplyAllStatBonuses();
@@ -6258,11 +6272,11 @@ namespace Game.Entities
}
uint val = 1u << (areaEntry.AreaBit % 32);
uint currFields = GetUInt32Value(PlayerFields.ExploredZones1 + offset);
uint currFields = GetUInt32Value(ActivePlayerFields.ExploredZones + offset);
if (!Convert.ToBoolean(currFields & val))
{
SetUInt32Value(PlayerFields.ExploredZones1 + offset, currFields | val);
SetUInt32Value(ActivePlayerFields.ExploredZones + offset, currFields | val);
UpdateCriteria(CriteriaTypes.ExploreArea);
@@ -6488,15 +6502,15 @@ namespace Game.Entities
void SetXP(uint xp)
{
SetUInt32Value(PlayerFields.Xp, xp);
SetUInt32Value(ActivePlayerFields.Xp, xp);
int playerLevelDelta = 0;
// If XP < 50%, player should see scaling creature with -1 level except for level max
if (getLevel() < SharedConst.MaxLevel && xp < (GetUInt32Value(PlayerFields.NextLevelXp) / 2))
if (getLevel() < SharedConst.MaxLevel && xp < (GetUInt32Value(ActivePlayerFields.NextLevelXp) / 2))
playerLevelDelta = -1;
SetInt32Value(PlayerFields.ScalingLevelDelta, playerLevelDelta);
SetInt32Value(UnitFields.ScalingLevelDelta, playerLevelDelta);
}
public void GiveXP(uint xp, Unit victim, float group_rate = 1.0f)
@@ -6539,8 +6553,8 @@ namespace Game.Entities
packet.ReferAFriendBonusType = (byte)(recruitAFriend ? 1 : 0);
SendPacket(packet);
uint curXP = GetUInt32Value(PlayerFields.Xp);
uint nextLvlXP = GetUInt32Value(PlayerFields.NextLevelXp);
uint curXP = GetUInt32Value(ActivePlayerFields.Xp);
uint nextLvlXP = GetUInt32Value(ActivePlayerFields.NextLevelXp);
uint newXP = curXP + xp + bonus_xp;
while (newXP >= nextLvlXP && level < WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel))
@@ -6551,7 +6565,7 @@ namespace Game.Entities
GiveLevel(level + 1);
level = getLevel();
nextLvlXP = GetUInt32Value(PlayerFields.NextLevelXp);
nextLvlXP = GetUInt32Value(ActivePlayerFields.NextLevelXp);
}
SetXP(newXP);
@@ -6758,22 +6772,6 @@ namespace Game.Entities
return false;
}
// check node starting pos data set case if provided
if (node.Pos.X != 0.0f || node.Pos.Y != 0.0f || node.Pos.Z != 0.0f)
{
if (node.ContinentID != GetMapId() || !IsInDist(node.Pos.X, node.Pos.Y, node.Pos.Z, 2 * SharedConst.InteractionDistance))
{
GetSession().SendActivateTaxiReply(ActivateTaxiReply.TooFarAway);
return false;
}
}
// node must have pos if taxi master case (npc != NULL)
else if (npc != null)
{
GetSession().SendActivateTaxiReply(ActivateTaxiReply.UnspecifiedServerError);
return false;
}
// Prepare to flight start now
// stop combat at start taxi flight if any
@@ -7084,7 +7082,7 @@ namespace Game.Entities
}
public bool IsSpellFitByClassAndRace(uint spell_id)
{
long racemask = getRaceMask();
ulong racemask = getRaceMask();
uint classmask = getClassMask();
var bounds = Global.SpellMgr.GetSkillLineAbilityMapBounds(spell_id);
@@ -7113,8 +7111,8 @@ namespace Game.Entities
{
SetFreePrimaryProfessions(WorldConfig.GetUIntValue(WorldCfg.MaxPrimaryTradeSkill));
}
public uint GetFreePrimaryProfessionPoints() { return GetUInt32Value(PlayerFields.CharacterPoints); }
void SetFreePrimaryProfessions(ushort profs) { SetUInt32Value(PlayerFields.CharacterPoints, profs); }
public uint GetFreePrimaryProfessionPoints() { return GetUInt32Value(ActivePlayerFields.CharacterPoints); }
void SetFreePrimaryProfessions(ushort profs) { SetUInt32Value(ActivePlayerFields.CharacterPoints, profs); }
public bool HaveAtClient(WorldObject u)
{
bool one = u.GetGUID() == GetGUID();
@@ -7130,7 +7128,7 @@ namespace Game.Entities
int fieldIndexOffset = (int)bitIndex / 32;
uint flag = (uint)(1 << ((int)bitIndex % 32));
return HasFlag(PlayerFields.KnownTitles + fieldIndexOffset, flag);
return HasFlag(ActivePlayerFields.KnownTitles + fieldIndexOffset, flag);
}
public void SetTitle(CharTitlesRecord title, bool lost = false)
{
@@ -7139,17 +7137,17 @@ namespace Game.Entities
if (lost)
{
if (!HasFlag(PlayerFields.KnownTitles + fieldIndexOffset, flag))
if (!HasFlag(ActivePlayerFields.KnownTitles + fieldIndexOffset, flag))
return;
RemoveFlag(PlayerFields.KnownTitles + fieldIndexOffset, flag);
RemoveFlag(ActivePlayerFields.KnownTitles + fieldIndexOffset, flag);
}
else
{
if (HasFlag(PlayerFields.KnownTitles + fieldIndexOffset, flag))
if (HasFlag(ActivePlayerFields.KnownTitles + fieldIndexOffset, flag))
return;
SetFlag(PlayerFields.KnownTitles + fieldIndexOffset, flag);
SetFlag(ActivePlayerFields.KnownTitles + fieldIndexOffset, flag);
}
TitleEarned packet = new TitleEarned(lost ? ServerOpcodes.TitleLost : ServerOpcodes.TitleEarned);
@@ -7163,7 +7161,7 @@ namespace Game.Entities
{
Log.outDebug(LogFilter.Maps, "Player.CreateViewpoint: Player {0} create seer {1} (TypeId: {2}).", GetName(), target.GetEntry(), target.GetTypeId());
if (!AddGuidValue(PlayerFields.Farsight, target.GetGUID()))
if (!AddGuidValue(ActivePlayerFields.Farsight, target.GetGUID()))
{
Log.outFatal(LogFilter.Player, "Player.CreateViewpoint: Player {0} cannot add new viewpoint!", GetName());
return;
@@ -7181,7 +7179,7 @@ namespace Game.Entities
{
Log.outDebug(LogFilter.Maps, "Player.CreateViewpoint: Player {0} remove seer", GetName());
if (!RemoveGuidValue(PlayerFields.Farsight, target.GetGUID()))
if (!RemoveGuidValue(ActivePlayerFields.Farsight, target.GetGUID()))
{
Log.outFatal(LogFilter.Player, "Player.CreateViewpoint: Player {0} cannot remove current viewpoint!", GetName());
return;
@@ -7196,7 +7194,7 @@ namespace Game.Entities
}
public WorldObject GetViewpoint()
{
ObjectGuid guid = GetGuidValue(PlayerFields.Farsight);
ObjectGuid guid = GetGuidValue(ActivePlayerFields.Farsight);
if (!guid.IsEmpty())
return Global.ObjAccessor.GetObjectByTypeMask(this, guid, TypeMask.Seer);
return null;
+2 -2
View File
@@ -225,13 +225,13 @@ namespace Game.Entities
public bool IsTaximaskNodeKnown(uint nodeidx)
{
byte field = (byte)((nodeidx - 1) / 8);
uint field = (nodeidx - 1) / 8;
uint submask = (uint)(1 << (int)((nodeidx - 1) % 8));
return (m_taximask[field] & submask) == submask;
}
public bool SetTaximaskNode(uint nodeidx)
{
byte field = (byte)((nodeidx - 1) / 8);
uint field = (nodeidx - 1) / 8;
uint submask = (uint)(1 << (int)((nodeidx - 1) % 8));
if ((m_taximask[field] & submask) != submask)
{
+12 -12
View File
@@ -13,7 +13,7 @@ namespace Game.Entities
{
byte rest_rested_offset;
byte rest_state_offset;
PlayerFields next_level_xp_field;
ActivePlayerFields next_level_xp_field;
bool affectedByRaF = false;
switch (restType)
@@ -25,17 +25,17 @@ namespace Game.Entities
rest_rested_offset = PlayerFieldOffsets.RestRestedXp;
rest_state_offset = PlayerFieldOffsets.RestStateXp;
next_level_xp_field = PlayerFields.NextLevelXp;
next_level_xp_field = ActivePlayerFields.NextLevelXp;
affectedByRaF = true;
break;
case RestTypes.Honor:
// Reset restBonus (Honor only) for players with max honor level.
if (_player.IsMaxHonorLevelAndPrestige())
if (_player.IsMaxHonorLevel())
restBonus = 0;
rest_rested_offset = PlayerFieldOffsets.RestRestedHonor;
rest_state_offset = PlayerFieldOffsets.RestStateHonor;
next_level_xp_field = PlayerFields.HonorNextLevel;
next_level_xp_field = ActivePlayerFields.HonorNextLevel;
break;
default:
return;
@@ -53,17 +53,17 @@ namespace Game.Entities
// update data for client
if (affectedByRaF && _player.GetsRecruitAFriendBonus(true) && (_player.GetSession().IsARecruiter() || _player.GetSession().GetRecruiterId() != 0))
_player.SetUInt32Value(PlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.RAFLinked);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.RAFLinked);
else
{
if (_restBonus[(int)restType] > 10)
_player.SetUInt32Value(PlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.Rested);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.Rested);
else if (_restBonus[(int)restType] <= 1)
_player.SetUInt32Value(PlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.NotRAFLinked);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_state_offset, (uint)PlayerRestState.NotRAFLinked);
}
// RestTickUpdate
_player.SetUInt32Value(PlayerFields.RestInfo + rest_rested_offset, (uint)_restBonus[(int)restType]);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + rest_rested_offset, (uint)_restBonus[(int)restType]);
}
public void AddRestBonus(RestTypes restType, float restBonus)
@@ -135,8 +135,8 @@ namespace Game.Entities
public void LoadRestBonus(RestTypes restType, PlayerRestState state, float restBonus)
{
_restBonus[(int)restType] = restBonus;
_player.SetUInt32Value(PlayerFields.RestInfo + (int)restType * 2, (uint)state);
_player.SetUInt32Value(PlayerFields.RestInfo + (int)restType * 2 + 1, (uint)restBonus);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + (int)restType * 2, (uint)state);
_player.SetUInt32Value(ActivePlayerFields.RestInfo + (int)restType * 2 + 1, (uint)restBonus);
}
public float CalcExtraPerSec(RestTypes restType, float bubble)
@@ -144,9 +144,9 @@ namespace Game.Entities
switch (restType)
{
case RestTypes.Honor:
return (_player.GetUInt32Value(PlayerFields.HonorNextLevel)) / 72000.0f * bubble;
return (_player.GetUInt32Value(ActivePlayerFields.HonorNextLevel)) / 72000.0f * bubble;
case RestTypes.XP:
return (_player.GetUInt32Value(PlayerFields.NextLevelXp)) / 72000.0f * bubble;
return (_player.GetUInt32Value(ActivePlayerFields.NextLevelXp)) / 72000.0f * bubble;
default:
return 0.0f;
}