TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BonusData Struct Reference

#include <Item.h>

Public Member Functions

void Initialize (ItemTemplate const *proto)
 
void Initialize (WorldPackets::Item::ItemInstance const &itemInstance)
 
void AddBonus (uint32 type, int32 const (&values)[2])
 

Public Attributes

uint32 Quality
 
int32 ItemLevel
 
int32 RequiredLevel
 
int32 ItemStatType [MAX_ITEM_PROTO_STATS]
 
int32 ItemStatValue [MAX_ITEM_PROTO_STATS]
 
int32 ItemStatAllocation [MAX_ITEM_PROTO_STATS]
 
float ItemStatSocketCostMultiplier [MAX_ITEM_PROTO_STATS]
 
uint32 SocketColor [MAX_ITEM_PROTO_SOCKETS]
 
uint32 AppearanceModID
 
float RepairCostMultiplier
 
uint32 ScalingStatDistribution
 

Member Function Documentation

void BonusData::AddBonus ( uint32  type,
int32 const (&)  values[2] 
)
1982 {
1983  switch (type)
1984  {
1985  case ITEM_BONUS_ITEM_LEVEL:
1986  ItemLevel += values[0];
1987  break;
1988  case ITEM_BONUS_STAT:
1989  {
1990  uint32 statIndex = 0;
1991  for (statIndex = 0; statIndex < MAX_ITEM_PROTO_STATS; ++statIndex)
1992  if (ItemStatType[statIndex] == values[0] || ItemStatType[statIndex] == -1)
1993  break;
1994 
1995  if (statIndex < MAX_ITEM_PROTO_STATS)
1996  {
1997  ItemStatType[statIndex] = values[0];
1998  ItemStatAllocation[statIndex] += values[1];
1999  }
2000  break;
2001  }
2002  case ITEM_BONUS_QUALITY:
2003  if (Quality < static_cast<uint32>(values[0]))
2004  Quality = static_cast<uint32>(values[0]);
2005  break;
2006  case ITEM_BONUS_SOCKET:
2007  {
2008  uint32 socketCount = values[0];
2009  for (uint32 i = 0; i < MAX_ITEM_PROTO_SOCKETS && socketCount; ++i)
2010  {
2011  if (!SocketColor[i])
2012  {
2013  SocketColor[i] = values[1];
2014  --socketCount;
2015  }
2016  }
2017  break;
2018  }
2019  case ITEM_BONUS_APPEARANCE:
2020  if (AppearanceModID < static_cast<uint32>(values[0]))
2021  AppearanceModID = static_cast<uint32>(values[0]);
2022  break;
2024  RequiredLevel += values[0];
2025  break;
2027  RepairCostMultiplier *= static_cast<float>(values[0]) * 0.01f;
2028  break;
2030  ScalingStatDistribution = static_cast<uint32>(values[0]);
2031  break;
2032  }
2033 }
Definition: DBCEnums.h:539
uint32 Quality
Definition: Item.h:242
int32 ItemStatAllocation[MAX_ITEM_PROTO_STATS]
Definition: Item.h:247
Definition: DBCEnums.h:542
int32 RequiredLevel
Definition: Item.h:244
float RepairCostMultiplier
Definition: Item.h:251
int32 ItemStatType[MAX_ITEM_PROTO_STATS]
Definition: Item.h:245
SocketColor
Definition: ItemTemplate.h:318
Definition: DBCEnums.h:532
#define MAX_ITEM_PROTO_STATS
Definition: DB2Structure.h:790
Definition: DBCEnums.h:534
uint32_t uint32
Definition: Define.h:150
Definition: DBCEnums.h:533
Definition: DBCEnums.h:541
uint32 AppearanceModID
Definition: Item.h:250
int32 ItemLevel
Definition: Item.h:243
#define MAX_ITEM_PROTO_SOCKETS
Definition: DB2Structure.h:789
uint32 ScalingStatDistribution
Definition: Item.h:252
Definition: DBCEnums.h:538
Definition: DBCEnums.h:537

+ Here is the caller graph for this function:

void BonusData::Initialize ( ItemTemplate const proto)
1942 {
1943  Quality = proto->GetQuality();
1944  ItemLevel = 0;
1945  RequiredLevel = proto->GetBaseRequiredLevel();
1946  for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1947  ItemStatType[i] = proto->GetItemStatType(i);
1948 
1949  for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1950  ItemStatValue[i] = proto->GetItemStatValue(i);
1951 
1952  for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1953  ItemStatAllocation[i] = proto->GetItemStatAllocation(i);
1954 
1955  for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1956  ItemStatSocketCostMultiplier[i] = proto->GetItemStatSocketCostMultiplier(i);
1957 
1958  for (uint32 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
1959  SocketColor[i] = proto->GetSocketColor(i);
1960 
1961  AppearanceModID = 0;
1962  RepairCostMultiplier = 1.0f;
1963  ScalingStatDistribution = proto->GetScalingStatDistribution();
1964 }
uint32 Quality
Definition: Item.h:242
int32 ItemStatAllocation[MAX_ITEM_PROTO_STATS]
Definition: Item.h:247
float ItemStatSocketCostMultiplier[MAX_ITEM_PROTO_STATS]
Definition: Item.h:248
int32 RequiredLevel
Definition: Item.h:244
float RepairCostMultiplier
Definition: Item.h:251
int32 ItemStatType[MAX_ITEM_PROTO_STATS]
Definition: Item.h:245
SocketColor
Definition: ItemTemplate.h:318
#define MAX_ITEM_PROTO_STATS
Definition: DB2Structure.h:790
uint32_t uint32
Definition: Define.h:150
uint32 AppearanceModID
Definition: Item.h:250
int32 ItemLevel
Definition: Item.h:243
#define MAX_ITEM_PROTO_SOCKETS
Definition: DB2Structure.h:789
uint32 ScalingStatDistribution
Definition: Item.h:252
int32 ItemStatValue[MAX_ITEM_PROTO_STATS]
Definition: Item.h:246

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BonusData::Initialize ( WorldPackets::Item::ItemInstance const itemInstance)
1967 {
1968  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemInstance.ItemID);
1969  if (!proto)
1970  return;
1971 
1972  Initialize(proto);
1973 
1974  if (itemInstance.ItemBonus)
1975  for (uint32 bonusListID : itemInstance.ItemBonus->BonusListIDs)
1976  if (DB2Manager::ItemBonusList const* bonuses = sDB2Manager.GetItemBonusList(bonusListID))
1977  for (ItemBonusEntry const* bonus : *bonuses)
1978  AddBonus(bonus->Type, bonus->Value);
1979 }
#define sDB2Manager
Definition: DB2Stores.h:224
void Initialize(ItemTemplate const *proto)
Definition: Item.cpp:1941
void AddBonus(uint32 type, int32 const (&values)[2])
Definition: Item.cpp:1981
std::vector< ItemBonusEntry const * > ItemBonusList
Definition: DB2Stores.h:147
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32_t uint32
Definition: Define.h:150
Definition: DB2Structure.h:653
Definition: ItemTemplate.h:647

+ Here is the call graph for this function:

Member Data Documentation

uint32 BonusData::AppearanceModID
int32 BonusData::ItemLevel
int32 BonusData::ItemStatAllocation[MAX_ITEM_PROTO_STATS]
float BonusData::ItemStatSocketCostMultiplier[MAX_ITEM_PROTO_STATS]
int32 BonusData::ItemStatType[MAX_ITEM_PROTO_STATS]
int32 BonusData::ItemStatValue[MAX_ITEM_PROTO_STATS]
uint32 BonusData::Quality
float BonusData::RepairCostMultiplier
int32 BonusData::RequiredLevel
uint32 BonusData::ScalingStatDistribution
uint32 BonusData::SocketColor[MAX_ITEM_PROTO_SOCKETS]

The documentation for this struct was generated from the following files: