Core/Items: fixed calculating shield block amount

This commit is contained in:
Ovahlord
2023-11-22 17:36:14 +01:00
parent 89d7ed3b9c
commit 40ddd29d03
5 changed files with 53 additions and 3 deletions

View File

@@ -39,6 +39,7 @@ GameTable<GtOCTRegenHPEntry> sOCTRegenHPGameTable;
GameTable<GtOCTRegenMPEntry> sOCTRegenMPGameTable;
GameTable<GtRegenHPPerSptEntry> sRegenHPPerSptGameTable;
GameTable<GtRegenMPPerSptEntry> sRegenMPPerSptGameTable;
GameTable<GtShieldBlockRegularEntry> sShieldBlockRegularGameTable;
GameTable<GtSpellScalingEntry> sSpellScalingGameTable;
GameTable<GtXpEntry> sXpGameTable;
@@ -129,6 +130,7 @@ void LoadGameTables(std::string const& dataPath)
LOAD_GT(sOCTRegenMPGameTable, "OCTRegenMP.txt");
LOAD_GT(sRegenHPPerSptGameTable, "RegenHPPerSpt.txt");
LOAD_GT(sRegenMPPerSptGameTable, "RegenMPPerSpt.txt");
LOAD_GT(sShieldBlockRegularGameTable, "ShieldBlockRegular.txt");
LOAD_GT(sSpellScalingGameTable, "SpellScaling.txt");
LOAD_GT(sXpGameTable, "xp.txt");

View File

@@ -181,6 +181,18 @@ struct GtRegenMPPerSptEntry
float Druid = 0.0f;
};
struct GtShieldBlockRegularEntry
{
float Poor = 0.0f;
float Standard = 0.0f;
float Good = 0.0f;
float Superior = 0.0f;
float Epic = 0.0f;
float Legendary = 0.0f;
float Artifact = 0.0f;
float ScalingStat = 0.0f;
};
struct GtSpellScalingEntry
{
float Rogue = 0.0f;
@@ -254,6 +266,7 @@ TC_GAME_API extern GameTable<GtOCTRegenHPEntry> sOCTRegenHPG
TC_GAME_API extern GameTable<GtOCTRegenMPEntry> sOCTRegenMPGameTable;
TC_GAME_API extern GameTable<GtRegenHPPerSptEntry> sRegenHPPerSptGameTable;
TC_GAME_API extern GameTable<GtRegenMPPerSptEntry> sRegenMPPerSptGameTable;
TC_GAME_API extern GameTable<GtShieldBlockRegularEntry> sShieldBlockRegularGameTable;
TC_GAME_API extern GameTable<GtSpellScalingEntry> sSpellScalingGameTable;
TC_GAME_API extern GameTable<GtXpEntry> sXpGameTable;
@@ -382,4 +395,31 @@ inline float GetBattlePetXPPerLevel(GtBattlePetXPEntry const* row)
return row->Wins * row->Xp;
}
inline float GetShieldBlockRegularColumnForQuality(GtShieldBlockRegularEntry const* row, ItemQualities quality)
{
switch (quality)
{
case ITEM_QUALITY_POOR:
return row->Poor;
case ITEM_QUALITY_NORMAL:
return row->Standard;
case ITEM_QUALITY_UNCOMMON:
return row->Good;
case ITEM_QUALITY_RARE:
return row->Superior;
case ITEM_QUALITY_EPIC:
return row->Epic;
case ITEM_QUALITY_LEGENDARY:
return row->Legendary;
case ITEM_QUALITY_ARTIFACT:
return row->Artifact;
case ITEM_QUALITY_HEIRLOOM:
return row->ScalingStat;
default:
break;
}
return 0.0f;
}
#endif // GameTables_h__

View File

@@ -16,9 +16,10 @@
*/
#include "DB2Stores.h"
#include "World.h"
#include "GameTables.h"
#include "ItemTemplate.h"
#include "Player.h"
#include "World.h"
int32 const SocketColorToGemTypeMask[26] =
{
@@ -232,3 +233,9 @@ std::size_t ItemTemplate::CalculateItemSpecBit(ChrSpecializationEntry const* spe
{
return (spec->ClassID - 1) * MAX_SPECIALIZATIONS + spec->OrderIndex;
}
int16 ItemTemplate::GetShieldBlockValue(uint32 itemLevel) const
{
GtShieldBlockRegularEntry const* blockEntry = sShieldBlockRegularGameTable.GetRow(itemLevel);
return static_cast<int16>(GetShieldBlockRegularColumnForQuality(blockEntry, static_cast<ItemQualities>(GetQuality())));
}

View File

@@ -824,7 +824,7 @@ struct TC_GAME_API ItemTemplate
uint8 GetArtifactID() const { return ExtendedData->ArtifactID; }
uint8 GetRequiredExpansion() const { return ExtendedData->ExpansionID; }
int16 GetResistance(SpellSchools school) const { return ExtendedData->Resistances[school]; }
int16 GetShieldBlockValue() const { return BasicData->Resistances[SPELL_SCHOOL_NORMAL]; }
int16 GetShieldBlockValue(uint32 itemLevel) const;
uint32 MaxDurability;
std::vector<ItemEffectEntry const*> Effects;

View File

@@ -7802,6 +7802,7 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply)
return;
uint32 itemLevel = item->GetItemLevel(this);
float combatRatingMultiplier = 1.0f;
//if (GtCombatRatingsMultByILvl const* ratingMult = sCombatRatingsMultByILvlGameTable.GetRow(itemLevel))
// combatRatingMultiplier = GetIlvlStatMultiplier(ratingMult, proto->GetInventoryType());
@@ -8041,7 +8042,7 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply)
if (int16 resistance = proto->GetResistance(SpellSchools(i)))
HandleStatFlatModifier(UnitMods(UNIT_MOD_ARMOR + i), BASE_VALUE, float(resistance), apply);
if (int16 shieldBlockValue = proto->GetShieldBlockValue())
if (int16 shieldBlockValue = proto->GetShieldBlockValue(itemLevel))
if (proto->GetClass() == ITEM_CLASS_ARMOR && proto->GetSubClass() == ITEM_SUBCLASS_ARMOR_SHIELD)
SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ShieldBlock), apply ? shieldBlockValue : 0);