Core/Player: Implement PvP Talents
This commit is contained in:
@@ -183,6 +183,8 @@ namespace Game.DataStorage
|
||||
PrestigeLevelInfoStorage = DBReader.Read<PrestigeLevelInfoRecord>("PrestigeLevelInfo.db2", HotfixStatements.SEL_PRESTIGE_LEVEL_INFO, HotfixStatements.SEL_PRESTIGE_LEVEL_INFO_LOCALE);
|
||||
PVPDifficultyStorage = DBReader.Read<PVPDifficultyRecord>("PVPDifficulty.db2", HotfixStatements.SEL_PVP_DIFFICULTY);
|
||||
PvpRewardStorage = DBReader.Read<PvpRewardRecord>("PvpReward.db2", HotfixStatements.SEL_PVP_REWARD);
|
||||
PvpTalentStorage = DBReader.Read<PvpTalentRecord>("PvpTalent.db2", HotfixStatements.SEL_PVP_TALENT, HotfixStatements.SEL_PVP_TALENT_LOCALE);
|
||||
PvpTalentUnlockStorage = DBReader.Read<PvpTalentUnlockRecord>("PvpTalentUnlock.db2", HotfixStatements.SEL_PVP_TALENT_UNLOCK);
|
||||
QuestFactionRewardStorage = DBReader.Read<QuestFactionRewardRecord>("QuestFactionReward.db2", HotfixStatements.SEL_QUEST_FACTION_REWARD);
|
||||
QuestMoneyRewardStorage = DBReader.Read<QuestMoneyRewardRecord>("QuestMoneyReward.db2", HotfixStatements.SEL_QUEST_MONEY_REWARD);
|
||||
QuestPackageItemStorage = DBReader.Read<QuestPackageItemRecord>("QuestPackageItem.db2", HotfixStatements.SEL_QUEST_PACKAGE_ITEM);
|
||||
@@ -512,6 +514,8 @@ namespace Game.DataStorage
|
||||
public static DB6Storage<PrestigeLevelInfoRecord> PrestigeLevelInfoStorage;
|
||||
public static DB6Storage<PVPDifficultyRecord> PVPDifficultyStorage;
|
||||
public static DB6Storage<PvpRewardRecord> PvpRewardStorage;
|
||||
public static DB6Storage<PvpTalentRecord> PvpTalentStorage;
|
||||
public static DB6Storage<PvpTalentUnlockRecord> PvpTalentUnlockStorage;
|
||||
public static DB6Storage<QuestFactionRewardRecord> QuestFactionRewardStorage;
|
||||
public static DB6Storage<QuestMoneyRewardRecord> QuestMoneyRewardStorage;
|
||||
public static DB6Storage<QuestPackageItemRecord> QuestPackageItemStorage;
|
||||
|
||||
@@ -48,78 +48,30 @@ namespace Game.DataStorage
|
||||
return result;
|
||||
}
|
||||
|
||||
public ulong ReadUInt64(int numBits)
|
||||
public ulong ReadUInt64(int bitWidth, int bitOffset)
|
||||
{
|
||||
ulong result = FastStruct<ulong>.ArrayToStructure(ref m_array[m_readOffset + (m_readPos >> 3)]) << (64 - numBits - (m_readPos & 7)) >> (64 - numBits);
|
||||
m_readPos += numBits;
|
||||
int bitsToRead = bitOffset & 7;
|
||||
ulong result = FastStruct<ulong>.ArrayToStructure(ref m_array[m_readOffset + (m_readPos >> 3)]) << (64 - bitsToRead - bitWidth) >> (64 - bitWidth);
|
||||
m_readPos += bitWidth;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Value32 ReadValue32(int numBits)
|
||||
public Value64 ReadValue64(int bitWidth, int bitOffset = 0, bool isSigned = false)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
ulong result = ReadUInt32(numBits);
|
||||
return *(Value32*)&result;
|
||||
}
|
||||
}
|
||||
ulong result = ReadUInt64(bitWidth, bitOffset);
|
||||
if (isSigned)
|
||||
{
|
||||
ulong mask = 1ul << (bitWidth - 1);
|
||||
result = (result ^ mask) - mask;
|
||||
}
|
||||
|
||||
public Value64 ReadValue64(int numBits)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
ulong result = ReadUInt64(numBits);
|
||||
return *(Value64*)&result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct Value32
|
||||
{
|
||||
unsafe fixed byte Value[4];
|
||||
|
||||
public T GetValue<T>() where T : struct
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* ptr = Value)
|
||||
return FastStruct<T>.ArrayToStructure(ref ptr[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetBytes(int bitSize)
|
||||
{
|
||||
if (((bitSize + 7) / 8) != NextPow2((bitSize + 7) / 8))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
byte[] data = new byte[NextPow2((bitSize + 7) / 8)];
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* ptr = Value)
|
||||
{
|
||||
for (var i = 0; i < data.Length; ++i)
|
||||
data[i] = ptr[i];
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private int NextPow2(int v)
|
||||
{
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
return Math.Max(v, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public struct Value64
|
||||
{
|
||||
unsafe fixed byte Value[8];
|
||||
@@ -135,9 +87,6 @@ namespace Game.DataStorage
|
||||
|
||||
public byte[] GetBytes(int bitSize)
|
||||
{
|
||||
var val = ((bitSize + 7) / 8);
|
||||
var val1 = NextPow2((bitSize + 7) / 8);
|
||||
|
||||
byte[] data = new byte[NextPow2((bitSize + 7) / 8)];
|
||||
unsafe
|
||||
{
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Game.DataStorage
|
||||
|
||||
if (!Copies.ContainsKey(idcopy))
|
||||
Copies.Add(idcopy, new List<int>());
|
||||
|
||||
|
||||
Copies[idcopy].Add(id);
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,7 @@ namespace Game.DataStorage
|
||||
}
|
||||
else
|
||||
{
|
||||
data.AddRange(bitReader.ReadValue64(bitWidth).GetBytes(bitWidth));
|
||||
data.AddRange(bitReader.ReadValue64(bitWidth, ColumnMeta[f].BitOffset, ColumnMeta[f].Cardinality == 1).GetBytes(bitWidth));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -350,6 +350,41 @@ namespace Game.DataStorage
|
||||
|
||||
CliDB.PvpRewardStorage.Clear();
|
||||
|
||||
for (var x = 0; x < (int)Class.Max; ++x)
|
||||
{
|
||||
_pvpTalentsByPosition[x] = new List<PvpTalentRecord>[PlayerConst.MaxPvpTalentTiers][];
|
||||
for (var y = 0; y < PlayerConst.MaxPvpTalentTiers; ++y)
|
||||
{
|
||||
_pvpTalentsByPosition[x][y] = new List<PvpTalentRecord>[PlayerConst.MaxPvpTalentColumns];
|
||||
for (var z = 0; z < PlayerConst.MaxPvpTalentColumns; ++z)
|
||||
_pvpTalentsByPosition[x][y][z] = new List<PvpTalentRecord>();
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < PlayerConst.MaxPvpTalentTiers; ++i)
|
||||
_pvpTalentUnlock[i] = new uint[PlayerConst.MaxPvpTalentColumns];
|
||||
|
||||
foreach (PvpTalentRecord talentInfo in CliDB.PvpTalentStorage.Values)
|
||||
{
|
||||
//ASSERT(talentInfo->ClassID < MAX_CLASSES);
|
||||
//ASSERT(talentInfo->TierID < MAX_PVP_TALENT_TIERS, "MAX_PVP_TALENT_TIERS must be at least %u", talentInfo.TierID + 1);
|
||||
//ASSERT(talentInfo->ColumnIndex < MAX_PVP_TALENT_COLUMNS, "MAX_PVP_TALENT_COLUMNS must be at least %u", talentInfo.ColumnIndex + 1);
|
||||
if (talentInfo.ClassID == 0)
|
||||
{
|
||||
for (uint i = 1; i < (int)Class.Max; ++i)
|
||||
_pvpTalentsByPosition[i][talentInfo.TierID][talentInfo.ColumnIndex].Add(talentInfo);
|
||||
}
|
||||
else
|
||||
_pvpTalentsByPosition[talentInfo.ClassID][talentInfo.TierID][talentInfo.ColumnIndex].Add(talentInfo);
|
||||
}
|
||||
|
||||
foreach (PvpTalentUnlockRecord talentUnlock in CliDB.PvpTalentUnlockStorage.Values)
|
||||
{
|
||||
//ASSERT(talentUnlock->TierID < MAX_PVP_TALENT_TIERS, "MAX_PVP_TALENT_TIERS must be at least %u", talentUnlock->TierID + 1);
|
||||
//ASSERT(talentUnlock->ColumnIndex < MAX_PVP_TALENT_COLUMNS, "MAX_PVP_TALENT_COLUMNS must be at least %u", talentUnlock->ColumnIndex + 1);
|
||||
_pvpTalentUnlock[talentUnlock.TierID][talentUnlock.ColumnIndex] = (uint)talentUnlock.HonorLevel;
|
||||
}
|
||||
|
||||
foreach (QuestPackageItemRecord questPackageItem in CliDB.QuestPackageItemStorage.Values)
|
||||
{
|
||||
if (!_questPackages.ContainsKey(questPackageItem.QuestPackageID))
|
||||
@@ -1146,6 +1181,17 @@ namespace Game.DataStorage
|
||||
return value;
|
||||
}
|
||||
|
||||
public uint GetRequiredHonorLevelForPvpTalent(PvpTalentRecord talentInfo)
|
||||
{
|
||||
//ASSERT(talentInfo);
|
||||
return _pvpTalentUnlock[talentInfo.TierID][talentInfo.ColumnIndex];
|
||||
}
|
||||
|
||||
public List<PvpTalentRecord> GetPvpTalentsByPosition(uint classId, uint tier, uint column)
|
||||
{
|
||||
return _pvpTalentsByPosition[classId][tier][column];
|
||||
}
|
||||
|
||||
public List<QuestPackageItemRecord> GetQuestPackageItems(uint questPackageID)
|
||||
{
|
||||
if( _questPackages.ContainsKey(questPackageID))
|
||||
@@ -1468,6 +1514,8 @@ namespace Game.DataStorage
|
||||
MultiMap<uint, uint> _phasesByGroup = new MultiMap<uint, uint>();
|
||||
Dictionary<PowerType, PowerTypeRecord> _powerTypes = new Dictionary<PowerType, PowerTypeRecord>();
|
||||
Dictionary<Tuple<uint /*prestige level*/, uint /*honor level*/>, uint> _pvpRewardPack = new Dictionary<Tuple<uint, uint>, uint>();
|
||||
List<PvpTalentRecord>[][][] _pvpTalentsByPosition = new List<PvpTalentRecord>[(int)Class.Max][][];
|
||||
uint[][] _pvpTalentUnlock = new uint[PlayerConst.MaxPvpTalentTiers][];
|
||||
Dictionary<uint, Tuple<List<QuestPackageItemRecord>, List<QuestPackageItemRecord>>> _questPackages = new Dictionary<uint, Tuple<List<QuestPackageItemRecord>, List<QuestPackageItemRecord>>>();
|
||||
MultiMap<uint, RewardPackXItemRecord> _rewardPackItems = new MultiMap<uint, RewardPackXItemRecord>();
|
||||
Dictionary<uint, uint> _rulesetItemUpgrade = new Dictionary<uint, uint>();
|
||||
|
||||
@@ -175,4 +175,27 @@ namespace Game.DataStorage
|
||||
public byte Prestige;
|
||||
public ushort RewardPackID;
|
||||
}
|
||||
|
||||
public sealed class PvpTalentRecord
|
||||
{
|
||||
public uint Id;
|
||||
public LocalizedString Description;
|
||||
public uint SpellID;
|
||||
public uint OverridesSpellID;
|
||||
public int ExtraSpellID;
|
||||
public int TierID;
|
||||
public byte ColumnIndex;
|
||||
public byte Flags;
|
||||
public byte ClassID;
|
||||
public ushort SpecID;
|
||||
public byte Role;
|
||||
}
|
||||
|
||||
public sealed class PvpTalentUnlockRecord
|
||||
{
|
||||
public uint Id;
|
||||
public byte TierID;
|
||||
public byte ColumnIndex;
|
||||
public byte HonorLevel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user