BFA Update (still lots of testing to do tho)
This commit is contained in:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user