TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Item.cpp File Reference
#include "Common.h"
#include "Item.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "DatabaseEnv.h"
#include "ItemEnchantmentMgr.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "ScriptMgr.h"
#include "ConditionMgr.h"
#include "Player.h"
#include "Opcodes.h"
#include "WorldSession.h"
#include "ItemPackets.h"
#include "TradeData.h"
+ Include dependency graph for Item.cpp:

Enumerations

enum  ItemTransmogrificationWeaponCategory : uint8 {
  ItemTransmogrificationWeaponCategory::MELEE_2H, ItemTransmogrificationWeaponCategory::RANGED, ItemTransmogrificationWeaponCategory::AXE_MACE_SWORD_1H, ItemTransmogrificationWeaponCategory::DAGGER,
  ItemTransmogrificationWeaponCategory::FIST, ItemTransmogrificationWeaponCategory::INVALID
}
 

Functions

void AddItemsSetItem (Player *player, Item *item)
 
void RemoveItemsSetItem (Player *player, ItemTemplate const *proto)
 
bool ItemCanGoIntoBag (ItemTemplate const *pProto, ItemTemplate const *pBagProto)
 
static
ItemTransmogrificationWeaponCategory 
GetTransmogrificationWeaponCategory (ItemTemplate const *proto)
 

Variables

int32 const ItemTransmogrificationSlots [MAX_INVTYPE]
 

Enumeration Type Documentation

Enumerator
MELEE_2H 
RANGED 
AXE_MACE_SWORD_1H 
DAGGER 
FIST 
INVALID 

Function Documentation

void AddItemsSetItem ( Player *  player,
Item item 
)
36 {
37  ItemTemplate const* proto = item->GetTemplate();
38  uint32 setid = proto->GetItemSet();
39 
40  ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
41 
42  if (!set)
43  {
44  TC_LOG_ERROR("sql.sql", "Item set %u for item (id %u) not found, mods not applied.", setid, proto->GetId());
45  return;
46  }
47 
48  if (set->RequiredSkill && player->GetSkillValue(set->RequiredSkill) < set->RequiredSkillRank)
49  return;
50 
51  ItemSetEffect* eff = NULL;
52 
53  for (size_t x = 0; x < player->ItemSetEff.size(); ++x)
54  {
55  if (player->ItemSetEff[x] && player->ItemSetEff[x]->ItemSetID == setid)
56  {
57  eff = player->ItemSetEff[x];
58  break;
59  }
60  }
61 
62  if (!eff)
63  {
64  eff = new ItemSetEffect();
65  eff->ItemSetID = setid;
66  eff->EquippedItemCount = 0;
67 
68  size_t x = 0;
69  for (; x < player->ItemSetEff.size(); ++x)
70  if (!player->ItemSetEff[x])
71  break;
72 
73  if (x < player->ItemSetEff.size())
74  player->ItemSetEff[x] = eff;
75  else
76  player->ItemSetEff.push_back(eff);
77  }
78 
79  ++eff->EquippedItemCount;
80 
81  ItemSetSpells& spells = sItemSetSpellsStore[setid];
82 
83  for (ItemSetSpellEntry const* itemSetSpell : spells)
84  {
85  //not enough for spell
86  if (itemSetSpell->Threshold > eff->EquippedItemCount)
87  continue;
88 
89  if (eff->SetBonuses.count(itemSetSpell))
90  continue;
91 
92  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemSetSpell->SpellID);
93  if (!spellInfo)
94  {
95  TC_LOG_ERROR("entities.player.items", "WORLD: unknown spell id %u in items set %u effects", itemSetSpell->SpellID, setid);
96  continue;
97  }
98 
99  eff->SetBonuses.insert(itemSetSpell);
100  // spell cast only if fit form requirement, in other case will cast at form change
101  if (!itemSetSpell->ChrSpecID || itemSetSpell->ChrSpecID == player->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID))
102  player->ApplyEquipSpell(spellInfo, NULL, true);
103  }
104 }
std::vector< ItemSetSpellEntry const * > ItemSetSpells
Definition: DBCStores.h:49
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetfmt)
Definition: SpellInfo.h:326
Definition: DBCStructure.h:724
ItemSetSpellsStore sItemSetSpellsStore
Definition: DBCStores.cpp:106
uint32 EquippedItemCount
Definition: Item.h:42
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: UpdateFields.h:206
Definition: Item.h:39
uint32 ItemSetID
Definition: Item.h:41
uint32 GetItemSet() const
Definition: ItemTemplate.h:690
uint32 RequiredSkill
Definition: DBCStructure.h:729
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: DBCStructure.h:733
uint32_t uint32
Definition: Define.h:150
uint32 RequiredSkillRank
Definition: DBCStructure.h:730
Definition: ItemTemplate.h:647
uint32 GetId() const
Definition: ItemTemplate.h:652
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
std::unordered_set< ItemSetSpellEntry const * > SetBonuses
Definition: Item.h:43
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

static ItemTransmogrificationWeaponCategory GetTransmogrificationWeaponCategory ( ItemTemplate const proto)
static
1428 {
1429  if (proto->GetClass() == ITEM_CLASS_WEAPON)
1430  {
1431  switch (proto->GetSubClass())
1432  {
1451  default:
1452  break;
1453  }
1454  }
1455 
1457 }
Definition: ItemTemplate.h:437
Definition: ItemTemplate.h:435
Definition: ItemTemplate.h:432
Definition: ItemTemplate.h:428
Definition: ItemTemplate.h:426
Definition: ItemTemplate.h:424
Definition: ItemTemplate.h:430
Definition: ItemTemplate.h:425
Definition: ItemTemplate.h:440
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:422
Definition: ItemTemplate.h:429
Definition: ItemTemplate.h:423
Definition: ItemTemplate.h:427

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ItemCanGoIntoBag ( ItemTemplate const pProto,
ItemTemplate const pBagProto 
)
158 {
159  if (!pProto || !pBagProto)
160  return false;
161 
162  switch (pBagProto->GetClass())
163  {
165  switch (pBagProto->GetSubClass())
166  {
168  return true;
170  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_SOUL_SHARDS))
171  return false;
172  return true;
174  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_HERBS))
175  return false;
176  return true;
178  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_ENCHANTING_SUPP))
179  return false;
180  return true;
182  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_MINING_SUPP))
183  return false;
184  return true;
186  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_ENGINEERING_SUPP))
187  return false;
188  return true;
190  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_GEMS))
191  return false;
192  return true;
194  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_LEATHERWORKING_SUPP))
195  return false;
196  return true;
198  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_INSCRIPTION_SUPP))
199  return false;
200  return true;
202  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_FISHING_SUPP))
203  return false;
204  return true;
206  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_COOKING_SUPP))
207  return false;
208  return true;
209  default:
210  return false;
211  }
212  case ITEM_CLASS_QUIVER:
213  switch (pBagProto->GetSubClass())
214  {
216  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_ARROWS))
217  return false;
218  return true;
220  if (!(pProto->GetBagFamily() & BAG_FAMILY_MASK_BULLETS))
221  return false;
222  return true;
223  default:
224  return false;
225  }
226  }
227  return false;
228 }
Definition: ItemTemplate.h:411
Definition: ItemTemplate.h:410
Definition: ItemTemplate.h:315
Definition: ItemTemplate.h:405
Definition: ItemTemplate.h:309
Definition: ItemTemplate.h:303
Definition: ItemTemplate.h:563
Definition: ItemTemplate.h:304
Definition: ItemTemplate.h:299
Definition: ItemTemplate.h:414
Definition: ItemTemplate.h:409
Definition: ItemTemplate.h:308
Definition: ItemTemplate.h:406
Definition: ItemTemplate.h:412
Definition: ItemTemplate.h:300
Definition: ItemTemplate.h:368
Definition: ItemTemplate.h:408
Definition: ItemTemplate.h:301
Definition: ItemTemplate.h:306
Definition: ItemTemplate.h:378
Definition: ItemTemplate.h:302
Definition: ItemTemplate.h:413
Definition: ItemTemplate.h:415
Definition: ItemTemplate.h:305
Definition: ItemTemplate.h:314
Definition: ItemTemplate.h:562
Definition: ItemTemplate.h:407

+ Here is the call graph for this function:

void RemoveItemsSetItem ( Player *  player,
ItemTemplate const proto 
)
107 {
108  uint32 setid = proto->GetItemSet();
109 
110  ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
111 
112  if (!set)
113  {
114  TC_LOG_ERROR("sql.sql", "Item set #%u for item #%u not found, mods not removed.", setid, proto->GetId());
115  return;
116  }
117 
118  ItemSetEffect* eff = NULL;
119  size_t setindex = 0;
120  for (; setindex < player->ItemSetEff.size(); setindex++)
121  {
122  if (player->ItemSetEff[setindex] && player->ItemSetEff[setindex]->ItemSetID == setid)
123  {
124  eff = player->ItemSetEff[setindex];
125  break;
126  }
127  }
128 
129  // can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough
130  if (!eff)
131  return;
132 
133  --eff->EquippedItemCount;
134 
135  ItemSetSpells const& spells = sItemSetSpellsStore[setid];
136  for (ItemSetSpellEntry const* itemSetSpell : spells)
137  {
138  // enough for spell
139  if (itemSetSpell->Threshold <= eff->EquippedItemCount)
140  continue;
141 
142  if (!eff->SetBonuses.count(itemSetSpell))
143  continue;
144 
145  player->ApplyEquipSpell(sSpellMgr->AssertSpellInfo(itemSetSpell->SpellID), nullptr, false);
146  eff->SetBonuses.erase(itemSetSpell);
147  }
148 
149  if (!eff->EquippedItemCount) //all items of a set were removed
150  {
151  ASSERT(eff == player->ItemSetEff[setindex]);
152  delete eff;
153  player->ItemSetEff[setindex] = NULL;
154  }
155 }
std::vector< ItemSetSpellEntry const * > ItemSetSpells
Definition: DBCStores.h:49
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetfmt)
Definition: DBCStructure.h:724
ItemSetSpellsStore sItemSetSpellsStore
Definition: DBCStores.cpp:106
uint32 EquippedItemCount
Definition: Item.h:42
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Item.h:39
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: DBCStructure.h:733
uint32_t uint32
Definition: Define.h:150
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::unordered_set< ItemSetSpellEntry const * > SetBonuses
Definition: Item.h:43

+ Here is the call graph for this function:

Variable Documentation

int32 const ItemTransmogrificationSlots[MAX_INVTYPE]