Core/Achievements: Defined all modifier tree types and implemented many of them

Port From (https://github.com/TrinityCore/TrinityCore/commit/d0be92ec0ad0334c38b4073a7e24a571982b17da)
This commit is contained in:
hondacrx
2021-06-07 13:13:46 -04:00
parent 9c58042e07
commit 1941148d8f
18 changed files with 1677 additions and 674 deletions
+24
View File
@@ -2089,6 +2089,30 @@ namespace Game.Entities
}
}
public uint GetTotalUnlockedArtifactPowers()
{
uint purchased = GetTotalPurchasedArtifactPowers();
ulong artifactXp = m_itemData.ArtifactXP;
uint currentArtifactTier = GetModifier(ItemModifier.ArtifactTier);
uint extraUnlocked = 0;
do
{
ulong xpCost = 0;
var cost = CliDB.ArtifactLevelXPGameTable.GetRow(purchased + extraUnlocked + 1);
if (cost != null)
xpCost = (ulong)(currentArtifactTier == PlayerConst.MaxArtifactTier ? cost.XP2 : cost.XP);
if (artifactXp < xpCost)
break;
artifactXp -= xpCost;
++extraUnlocked;
} while (true);
return purchased + extraUnlocked;
}
public uint GetTotalPurchasedArtifactPowers()
{
uint purchasedRanks = 0;
@@ -728,7 +728,7 @@ namespace Game.Entities
{
int transmogSlot = Item.ItemTransmogrificationSlots[(int)item.inventoryType];
if (transmogSlot >= 0)
_owner.GetPlayer().UpdateCriteria(CriteriaTypes.AppearanceUnlockedBySlot, (ulong)transmogSlot, 1);
_owner.GetPlayer().UpdateCriteria(CriteriaTypes.AppearanceUnlockedBySlot, (ulong)transmogSlot, itemModifiedAppearance.Id);
}
var sets = Global.DB2Mgr.GetTransmogSetsForItemModifiedAppearance(itemModifiedAppearance.Id);
@@ -20,6 +20,7 @@ using Game.Achievements;
using Game.DataStorage;
using Game.Guilds;
using Game.Scenarios;
using System.Collections.Generic;
namespace Game.Entities
{
@@ -39,6 +40,12 @@ namespace Game.Entities
{
return m_achievementSys.GetAchievementPoints();
}
public ICollection<uint> GetCompletedAchievementIds()
{
return m_achievementSys.GetCompletedAchievementIds();
}
public bool HasAchieved(uint achievementId)
{
return m_achievementSys.HasAchieved(achievementId);
+71 -25
View File
@@ -1511,7 +1511,7 @@ namespace Game.Entities
InventoryResult res = InventoryResult.Ok;
uint tempcount = 0;
bool result = ForEachStorageItem(ItemSearchLocation.Equipment, pItem =>
bool result = ForEachItem(ItemSearchLocation.Equipment, pItem =>
{
if (pItem.GetEntry() == item)
{
@@ -2615,7 +2615,7 @@ namespace Game.Entities
public Item GetItemByGuid(ObjectGuid guid)
{
Item result = null;
ForEachStorageItem(ItemSearchLocation.Everywhere, item =>
ForEachItem(ItemSearchLocation.Everywhere, item =>
{
if (item.GetGUID() == guid)
{
@@ -2637,7 +2637,7 @@ namespace Game.Entities
location |= ItemSearchLocation.Bank;
uint count = 0;
ForEachStorageItem(location, pItem =>
ForEachItem(location, pItem =>
{
if (pItem != skipItem)
{
@@ -2684,7 +2684,7 @@ namespace Game.Entities
public Item GetItemByEntry(uint entry, ItemSearchLocation where = ItemSearchLocation.Default)
{
Item result = null;
ForEachStorageItem(where, item =>
ForEachItem(where, item =>
{
if (item.GetEntry() == entry)
{
@@ -2704,7 +2704,7 @@ namespace Game.Entities
location |= ItemSearchLocation.Bank;
List<Item> itemList = new();
ForEachStorageItem(location, item =>
ForEachItem(location, item =>
{
if (item.GetEntry() == entry)
itemList.Add(item);
@@ -2721,7 +2721,7 @@ namespace Game.Entities
location |= ItemSearchLocation.Bank;
uint currentCount = 0;
return !ForEachStorageItem(location, pItem =>
return !ForEachItem(location, pItem =>
{
if (pItem && pItem.GetEntry() == item && !pItem.IsInTrade())
{
@@ -2791,7 +2791,7 @@ namespace Game.Entities
public Item GetChildItemByGuid(ObjectGuid guid)
{
Item result = null;
ForEachStorageItem(ItemSearchLocation.Equipment | ItemSearchLocation.Inventory, item =>
ForEachItem(ItemSearchLocation.Equipment | ItemSearchLocation.Inventory, item =>
{
if (item.GetGUID() == guid)
{
@@ -2807,7 +2807,7 @@ namespace Game.Entities
uint GetItemCountWithLimitCategory(uint limitCategory, Item skipItem)
{
uint count = 0;
ForEachStorageItem(ItemSearchLocation.Everywhere, item =>
ForEachItem(ItemSearchLocation.Everywhere, item =>
{
if (item != skipItem)
{
@@ -3428,23 +3428,16 @@ namespace Game.Entities
return false;
}
uint GetMaxPersonalArenaRatingRequirement(uint minarenaslot)
public uint GetMaxPersonalArenaRatingRequirement(uint minarenaslot)
{
// returns the maximal personal arena rating that can be used to purchase items requiring this condition
// the personal rating of the arena team must match the required limit as well
// so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype]))
// so return max[in arenateams](personalrating[teamtype])
uint max_personal_rating = 0;
for (byte i = (byte)minarenaslot; i < SharedConst.MaxArenaSlot; ++i)
{
ArenaTeam at = Global.ArenaTeamMgr.GetArenaTeamById(GetArenaTeamId(i));
if (at != null)
{
uint p_rating = GetArenaPersonalRating(i);
uint t_rating = at.GetRating();
p_rating = p_rating < t_rating ? p_rating : t_rating;
if (max_personal_rating < p_rating)
max_personal_rating = p_rating;
}
uint p_rating = GetArenaPersonalRating(i);
if (max_personal_rating < p_rating)
max_personal_rating = p_rating;
}
return max_personal_rating;
}
@@ -4469,7 +4462,60 @@ namespace Game.Entities
{
return StoreItem(dest, pItem, update);
}
public uint GetFreeInventorySlotCount(ItemSearchLocation location = ItemSearchLocation.Inventory)
{
uint freeSlotCount = 0;
if (location.HasFlag(ItemSearchLocation.Equipment))
for (byte i = EquipmentSlot.Start; i < EquipmentSlot.End; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
if (location.HasFlag(ItemSearchLocation.Inventory))
{
int inventoryEnd = InventorySlots.ItemStart + GetInventorySlotCount();
for (byte i = InventorySlots.ItemStart; i < inventoryEnd; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
for (byte i = InventorySlots.BagStart; i < InventorySlots.BagEnd; ++i)
{
Bag bag = GetBagByPos(i);
if (bag != null)
{
for (byte j = 0; j < bag.GetBagSize(); ++j)
if (bag.GetItemByPos(j) == null)
++freeSlotCount;
}
}
}
if (location.HasFlag(ItemSearchLocation.Bank))
{
for (byte i = InventorySlots.BankItemStart; i < InventorySlots.BankItemEnd; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; ++i)
{
Bag bag = GetBagByPos(i);
if (bag != null)
{
for (byte j = 0; j < bag.GetBagSize(); ++j)
if (bag.GetItemByPos(j) == null)
++freeSlotCount;
}
}
}
if (location.HasFlag(ItemSearchLocation.ReagentBank))
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ReagentEnd; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
return freeSlotCount;
}
//Bags
public Bag GetBagByPos(byte bag)
{
@@ -5242,7 +5288,7 @@ namespace Game.Entities
ItemTemplate pProto = Global.ObjectMgr.GetItemTemplate(item);
bool includeGems = pProto?.GetGemProperties() != 0;
return !ForEachStorageItem(ItemSearchLocation.Equipment, pItem =>
return !ForEachItem(ItemSearchLocation.Equipment, pItem =>
{
if (pItem.GetSlot() != except_slot)
{
@@ -5261,7 +5307,7 @@ namespace Game.Entities
bool HasItemWithLimitCategoryEquipped(uint limitCategory, uint count, byte except_slot)
{
uint tempcount = 0;
return !ForEachStorageItem(ItemSearchLocation.Equipment, pItem =>
return !ForEachItem(ItemSearchLocation.Equipment, pItem =>
{
if (pItem.GetSlot() == except_slot)
return true;
@@ -5280,7 +5326,7 @@ namespace Game.Entities
bool HasGemWithLimitCategoryEquipped(uint limitCategory, uint count, byte except_slot)
{
uint tempcount = 0;
return !ForEachStorageItem(ItemSearchLocation.Equipment, pItem =>
return !ForEachItem(ItemSearchLocation.Equipment, pItem =>
{
if (pItem.GetSlot() == except_slot)
return true;
@@ -6555,7 +6601,7 @@ namespace Game.Entities
// @todo other types of power scaling such as timewalking
}
bool ForEachStorageItem(ItemSearchLocation location, Func<Item, bool> callback)
public bool ForEachItem(ItemSearchLocation location, Func<Item, bool> callback)
{
if (location.HasAnyFlag(ItemSearchLocation.Equipment))
{
@@ -6720,7 +6766,7 @@ namespace Game.Entities
(InventoryType inventoryType, uint itemLevel, ObjectGuid guid)[] bestItemLevels = new (InventoryType inventoryType, uint itemLevel, ObjectGuid guid)[EquipmentSlot.End];
float sum = 0;
ForEachStorageItem(ItemSearchLocation.Everywhere, item =>
ForEachItem(ItemSearchLocation.Everywhere, item =>
{
ItemTemplate itemTemplate = item.GetTemplate();
if (itemTemplate != null)
+17 -7
View File
@@ -5015,7 +5015,7 @@ namespace Game.Entities
return true;
}
bool CanEnableWarModeInArea()
public bool CanEnableWarModeInArea()
{
var area = CliDB.AreaTableStorage.LookupByKey(GetAreaId());
if (area == null || !IsFriendlyArea(area))
@@ -5878,6 +5878,16 @@ namespace Game.Entities
return reputationMgr;
}
public void SetReputation(uint factionentry, int value)
{
GetReputationMgr().SetReputation(CliDB.FactionStorage.LookupByKey(factionentry), value);
}
public int GetReputation(uint factionentry)
{
return GetReputationMgr().GetReputation(CliDB.FactionStorage.LookupByKey(factionentry));
}
#region Sends / Updates
void BeforeVisibilityDestroy(WorldObject obj, Player p)
{
@@ -6423,12 +6433,12 @@ namespace Game.Entities
SendMovementSetCollisionHeight(scale * GetCollisionHeight(), UpdateCollisionHeightReason.Scale);
}
bool HasRaceChanged() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.HasRaceChanged); }
void SetHasRaceChanged() { m_ExtraFlags |= PlayerExtraFlags.HasRaceChanged; }
bool HasBeenGrantedLevelsFromRaF() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.GrantedLevelsFromRaf); }
void SetBeenGrantedLevelsFromRaF() { m_ExtraFlags |= PlayerExtraFlags.GrantedLevelsFromRaf; }
bool HasLevelBoosted() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.LevelBoosted); }
void SetHasLevelBoosted() { m_ExtraFlags |= PlayerExtraFlags.LevelBoosted; }
public bool HasRaceChanged() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.HasRaceChanged); }
public void SetHasRaceChanged() { m_ExtraFlags |= PlayerExtraFlags.HasRaceChanged; }
public bool HasBeenGrantedLevelsFromRaF() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.GrantedLevelsFromRaf); }
public void SetBeenGrantedLevelsFromRaF() { m_ExtraFlags |= PlayerExtraFlags.GrantedLevelsFromRaf; }
public bool HasLevelBoosted() { return m_ExtraFlags.HasFlag(PlayerExtraFlags.LevelBoosted); }
public void SetHasLevelBoosted() { m_ExtraFlags |= PlayerExtraFlags.LevelBoosted; }
public uint GetXP() { return m_activePlayerData.XP; }
public uint GetXPForNextLevel() { return m_activePlayerData.NextLevelXP; }