Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Item.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Common.h"
7#include "ConditionMgr.h"
8#include "DatabaseEnv.h"
9#include "Item.h"
10#include "ItemEnchantmentMgr.h"
11#include "ObjectMgr.h"
12#include "Opcodes.h"
13#include "Player.h"
14#include "ScriptMgr.h"
15#include "SpellInfo.h"
16#include "SpellMgr.h"
17#include "WorldPacket.h"
18#include "WorldSession.h"
19
20void AddItemsSetItem(Player* player, Item* item)
21{
22 ItemTemplate const* proto = item->GetTemplate();
23 uint32 setid = proto->ItemSet;
24
25 ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
26
27 if (!set)
28 {
29 SF_LOG_ERROR("sql.sql", "Item set %u for item (id %u) not found, mods not applied.", setid, proto->ItemId);
30 return;
31 }
32
34 return;
35
36 ItemSetEffect* eff = NULL;
37
38 for (size_t x = 0; x < player->ItemSetEff.size(); ++x)
39 {
40 if (player->ItemSetEff[x] && player->ItemSetEff[x]->setid == setid)
41 {
42 eff = player->ItemSetEff[x];
43 break;
44 }
45 }
46
47 if (!eff)
48 {
49 eff = new ItemSetEffect();
50 eff->setid = setid;
51
52 size_t x = 0;
53 for (; x < player->ItemSetEff.size(); ++x)
54 if (!player->ItemSetEff[x])
55 break;
56
57 if (x < player->ItemSetEff.size())
58 player->ItemSetEff[x] = eff;
59 else
60 player->ItemSetEff.push_back(eff);
61 }
62
63 ++eff->item_count;
64
65 for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; ++x)
66 {
67 if (!set->spells[x])
68 continue;
69 //not enough for spell
70 if (set->items_to_triggerspell[x] > eff->item_count)
71 continue;
72
73 uint32 z = 0;
74 for (; z < MAX_ITEM_SET_SPELLS; ++z)
75 if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
76 break;
77
78 if (z < MAX_ITEM_SET_SPELLS)
79 continue;
80
81 //new spell
82 for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; ++y)
83 {
84 if (!eff->spells[y]) // free slot
85 {
86 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(set->spells[x]);
87 if (!spellInfo)
88 {
89 SF_LOG_ERROR("entities.player.items", "WORLD: unknown spell id %u in items set %u effects", set->spells[x], setid);
90 break;
91 }
92
93 // spell casted only if fit form requirement, in other case will casted at form change
94 player->ApplyEquipSpell(spellInfo, NULL, true);
95 eff->spells[y] = spellInfo;
96 break;
97 }
98 }
99 }
100}
101
102void RemoveItemsSetItem(Player* player, ItemTemplate const* proto)
103{
104 uint32 setid = proto->ItemSet;
105
106 ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
107
108 if (!set)
109 {
110 SF_LOG_ERROR("sql.sql", "Item set #%u for item #%u not found, mods not removed.", setid, proto->ItemId);
111 return;
112 }
113
114 ItemSetEffect* eff = NULL;
115 size_t setindex = 0;
116 for (; setindex < player->ItemSetEff.size(); setindex++)
117 {
118 if (player->ItemSetEff[setindex] && player->ItemSetEff[setindex]->setid == setid)
119 {
120 eff = player->ItemSetEff[setindex];
121 break;
122 }
123 }
124
125 // can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough
126 if (!eff)
127 return;
128
129 --eff->item_count;
130
131 for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++)
132 {
133 if (!set->spells[x])
134 continue;
135
136 // enough for spell
137 if (set->items_to_triggerspell[x] <= eff->item_count)
138 continue;
139
140 for (uint32 z = 0; z < MAX_ITEM_SET_SPELLS; z++)
141 {
142 if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
143 {
144 // spell can be not active if not fit form requirement
145 player->ApplyEquipSpell(eff->spells[z], NULL, false);
146 eff->spells[z] = NULL;
147 break;
148 }
149 }
150 }
151
152 if (!eff->item_count) //all items of a set were removed
153 {
154 ASSERT(eff == player->ItemSetEff[setindex]);
155 delete eff;
156 player->ItemSetEff[setindex] = NULL;
157 }
158}
159
160bool ItemCanGoIntoBag(ItemTemplate const* pProto, ItemTemplate const* pBagProto)
161{
162 if (!pProto || !pBagProto)
163 return false;
164
165 switch (pBagProto->Class)
166 {
168 switch (pBagProto->SubClass)
169 {
171 return true;
173 if (!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS))
174 return false;
175 return true;
177 if (!(pProto->BagFamily & BAG_FAMILY_MASK_HERBS))
178 return false;
179 return true;
182 return false;
183 return true;
185 if (!(pProto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP))
186 return false;
187 return true;
190 return false;
191 return true;
193 if (!(pProto->BagFamily & BAG_FAMILY_MASK_GEMS))
194 return false;
195 return true;
198 return false;
199 return true;
202 return false;
203 return true;
206 return false;
207 return true;
210 return false;
211 return true;
212 default:
213 return false;
214 }
216 switch (pBagProto->SubClass)
217 {
219 if (!(pProto->BagFamily & BAG_FAMILY_MASK_ARROWS))
220 return false;
221 return true;
223 if (!(pProto->BagFamily & BAG_FAMILY_MASK_BULLETS))
224 return false;
225 return true;
226 default:
227 return false;
228 }
229 }
230 return false;
231}
232
235{
238
239 m_updateFlag = 0;
240
242
245 for (int i = 0; i < ITEM_DYNAMIC_END; i++)
246 {
247 m_dynamicTab[i] = new uint32[32];
248 m_dynamicChange[i] = new bool[32];
249 }
250}
251
252bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
253{
254 Object::_Create(guidlow, 0, HIGHGUID_ITEM);
255
256 SetEntry(itemid);
257 SetObjectScale(1.0f);
258
259 SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
260 SetUInt64Value(ITEM_FIELD_CONTAINED_IN, owner ? owner->GetGUID() : 0);
261
262 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
263 if (!itemProto)
264 return false;
265
269
270 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
271 SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
272
275 return true;
276}
277
278// Returns true if Item is a bag AND it is not empty.
279// Returns false if Item is not a bag OR it is an empty bag.
281{
282 if (Bag const* bag = ToBag())
283 return !bag->IsEmpty();
284 return false;
285}
286
288{
290 return;
291
292 SF_LOG_DEBUG("entities.player.items", "Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_EXPIRATION), diff);
293
295 {
296 sScriptMgr->OnItemExpire(owner, GetTemplate());
297 owner->DestroyItem(GetBagSlot(), GetSlot(), true);
298 return;
299 }
300
302 SetState(ITEM_CHANGED, owner); // save new time in database
303}
304
306{
307 bool isInTransaction = !(trans.null());
308 if (!isInTransaction)
309 trans = CharacterDatabase.BeginTransaction();
310
311 uint32 guid = GetGUIDLow();
312 switch (uState)
313 {
314 case ITEM_NEW:
315 case ITEM_CHANGED:
316 {
317 uint8 index = 0;
319 stmt->setUInt32(index, GetEntry());
320 stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
323 stmt->setUInt32(++index, GetCount());
325
326 std::ostringstream ssSpells;
327 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
328 ssSpells << GetSpellCharges(i) << ' ';
329 stmt->setString(++index, ssSpells.str());
330
332
333 std::ostringstream ssEnchants;
334 for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
335 {
336 ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
337 ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
338 ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
339 }
340 stmt->setString(++index, ssEnchants.str());
341
342 stmt->setInt16(++index, GetItemRandomPropertyId());
343 stmt->setUInt32(++index, GetDynamicUInt32Value(ITEM_DYNAMIC_MODIFIERS, 0)); // reforge Id
346 stmt->setString(++index, m_text);
347 stmt->setUInt32(++index, guid);
348
349 trans->Append(stmt);
350
352 {
353 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
355 stmt->setUInt32(1, guid);
356 trans->Append(stmt);
357 }
358
359 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_TRANSMOG);
360 stmt->setUInt32(0, guid);
361 trans->Append(stmt);
362
364 {
365 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_INSTANCE_TRANSMOG);
366 stmt->setUInt32(0, guid);
368 trans->Append(stmt);
369 }
370 break;
371 }
372 case ITEM_REMOVED:
373 {
374 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
375 stmt->setUInt32(0, guid);
376 trans->Append(stmt);
377
379 {
380 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
381 stmt->setUInt32(0, guid);
382 trans->Append(stmt);
383 }
384
385 if (!isInTransaction)
386 CharacterDatabase.CommitTransaction(trans);
387
388 // Delete the items if this is a container
389 if (!loot.isLooted())
391
392 delete this;
393 return;
394 }
395 case ITEM_UNCHANGED:
396 break;
397 }
398
400
401 if (!isInTransaction)
402 CharacterDatabase.CommitTransaction(trans);
403}
404
405bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
406{
407 // 0 1 2 3 4 5 6 7 8 9 10 11 12
408 //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, reforgeId, transmogrifyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
409
410 // create item before any checks for store correct guid
411 // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
413
414 // Set entry, MUST be before proto check
415 SetEntry(entry);
416 SetObjectScale(1.0f);
417
418 ItemTemplate const* proto = GetTemplate();
419 if (!proto)
420 return false;
421
422 // set owner (not if item is only loaded for gbank/auction/mail
423 if (owner_guid != 0)
424 SetOwnerGUID(owner_guid);
425
426 bool need_save = false; // need explicit save data at load fixes
429 SetCount(fields[2].GetUInt32());
430
431 uint32 duration = fields[3].GetUInt32();
433 // update duration if need, and remove if not need
434 if ((proto->Duration == 0) != (duration == 0))
435 {
437 need_save = true;
438 }
439
440 Tokenizer tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);
441 if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
442 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
443 SetSpellCharges(i, atoi(tokens[i]));
444
445 SetUInt32Value(ITEM_FIELD_DYNAMIC_FLAGS, fields[5].GetUInt32());
446 // Remove bind flag for items vs NO_BIND set
447 if (IsSoulBound() && proto->Bonding == NO_BIND)
448 {
450 need_save = true;
451 }
452
453 std::string enchants = fields[6].GetString();
455 SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
456 // recalculate suffix factor
457 if (GetItemRandomPropertyId() < 0)
459
460 if (uint32 reforgeEntry = fields[8].GetInt32())
461 {
464 }
465
466 if (uint32 transmogId = fields[9].GetInt32())
467 {
470 }
471
472 uint32 durability = fields[10].GetUInt16();
474 // update max durability (and durability) if need
476 if (durability > proto->MaxDurability)
477 {
479 need_save = true;
480 }
481
482 SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[11].GetUInt32());
483 SetText(fields[12].GetString());
484
485 if (need_save) // normal item changed state set not work at loading
486 {
491 stmt->setUInt32(3, guid);
492 CharacterDatabase.Execute(stmt);
493 }
494
495 return true;
496}
497
498/*static*/
500{
501 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
502 stmt->setUInt32(0, itemGuid);
503 trans->Append(stmt);
504}
505
507{
508 DeleteFromDB(trans, GetGUIDLow());
509
510 // Delete the items if this is a container
511 if (!loot.isLooted())
513}
514
515/*static*/
517{
519 stmt->setUInt32(0, itemGuid);
520 trans->Append(stmt);
521}
522
527
529{
530 return sObjectMgr->GetItemTemplate(GetEntry());
531}
532
537
539{
540 const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] =
541 {
547 };
548
549 const static uint32 item_armor_skills[MAX_ITEM_SUBCLASS_ARMOR] =
550 {
552 };
553
554 ItemTemplate const* proto = GetTemplate();
555
556 switch (proto->Class)
557 {
560 return 0;
561 else
562 return item_weapon_skills[proto->SubClass];
563
564 case ITEM_CLASS_ARMOR:
565 if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
566 return 0;
567 else
568 return item_armor_skills[proto->SubClass];
569
570 default:
571 return 0;
572 }
573}
574
576{
577 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id);
578
579 if (!itemProto)
580 return 0;
581
582 // item must have one from this field values not null if it can have random enchantments
583 if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
584 return 0;
585
586 // item can have not null only one from field values
587 if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
588 {
589 SF_LOG_ERROR("sql.sql", "Item template %u have RandomProperty == %u and RandomSuffix == %u, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
590 return 0;
591 }
592
593 // RandomProperty case
594 if (itemProto->RandomProperty)
595 {
596 uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
597 ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
598 if (!random_id)
599 {
600 SF_LOG_ERROR("sql.sql", "Enchantment id #%u used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId);
601 return 0;
602 }
603
604 return random_id->ID;
605 }
606 // RandomSuffix case
607 else
608 {
609 uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
610 ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
611 if (!random_id)
612 {
613 SF_LOG_ERROR("sql.sql", "Enchantment id #%u used but it doesn't have records in sItemRandomSuffixStore.", randomPropId);
614 return 0;
615 }
616
617 return -int32(random_id->ID);
618 }
619}
620
622{
623 if (!randomPropId)
624 return;
625
626 if (randomPropId > 0)
627 {
628 ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
629 if (item_rand)
630 {
632 {
635 }
638 }
639 }
640 else
641 {
642 ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
643 if (item_rand)
644 {
647 {
651 }
652
655 }
656 }
657}
658
660{
661 uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry());
662 if (GetItemSuffixFactor() == suffixFactor)
663 return;
665}
666
667void Item::SetState(ItemUpdateState state, Player* forplayer)
668{
669 if (uState == ITEM_NEW && state == ITEM_REMOVED)
670 {
671 // pretend the item never existed
672 RemoveFromUpdateQueueOf(forplayer);
673 forplayer->DeleteRefundReference(GetGUIDLow());
674 delete this;
675 return;
676 }
677 if (state != ITEM_UNCHANGED)
678 {
679 // new items must stay in new state until saved
680 if (uState != ITEM_NEW)
681 uState = state;
682
683 AddToUpdateQueueOf(forplayer);
684 }
685 else
686 {
687 // unset in queue
688 // the item must be removed from the queue manually
689 uQueuePos = -1;
691 }
692}
693
695{
696 if (IsInUpdateQueue())
697 return;
698
699 ASSERT(player != NULL);
700
701 if (player->GetGUID() != GetOwnerGUID())
702 {
703 SF_LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
704 return;
705 }
706
707 if (player->m_itemUpdateQueueBlocked)
708 return;
709
710 player->m_itemUpdateQueue.push_back(this);
711 uQueuePos = player->m_itemUpdateQueue.size() - 1;
712}
713
715{
716 if (!IsInUpdateQueue())
717 return;
718
719 ASSERT(player != NULL);
720
721 if (player->GetGUID() != GetOwnerGUID())
722 {
723 SF_LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
724 return;
725 }
726
727 if (player->m_itemUpdateQueueBlocked)
728 return;
729
730 player->m_itemUpdateQueue[uQueuePos] = NULL;
731 uQueuePos = -1;
732}
733
735{
736 return m_container ? m_container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
737}
738
740{
741 return !IsInBag() && m_slot < EQUIPMENT_SLOT_END;
742}
743
744bool Item::CanBeTraded(bool mail, bool trade) const
745{
746 if (m_lootGenerated)
747 return false;
748
750 return false;
751
752 if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
753 return false;
754
755 if (Player* owner = GetOwner())
756 {
757 if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
758 return false;
759 if (owner->GetLootGUID() == GetGUID())
760 return false;
761 }
762
763 if (IsBoundByEnchant())
764 return false;
765
766 return true;
767}
768
769bool Item::HasEnchantRequiredSkill(const Player* player) const
770{
771 // Check all enchants for required skill
772 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
773 {
774 if (enchant_slot > PRISMATIC_ENCHANTMENT_SLOT && enchant_slot < PROP_ENCHANTMENT_SLOT_0) // not holding enchantment id
775 continue;
776
777 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
778 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
779 if (enchantEntry->requiredSkill && player->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue)
780 return false;
781 }
782
783 return true;
784}
785
787{
788 // Check all enchants for soulbound
789 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
790 {
791 if (enchant_slot > PRISMATIC_ENCHANTMENT_SLOT && enchant_slot < PROP_ENCHANTMENT_SLOT_0) // not holding enchantment id
792 continue;
793
794 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
795 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
796 if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
797 return true;
798 }
799
800 return false;
801}
802
804{
805 // not allow merge looting currently items
806 if (m_lootGenerated)
807 return EQUIP_ERR_LOOT_GONE;
808
809 // check item type
810 if (GetEntry() != proto->ItemId)
812
813 // check free space (full stacks can't be target of merge
814 if (GetCount() >= proto->GetMaxStackSize())
816
817 return EQUIP_ERR_OK;
818}
819
820bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
821{
822 ItemTemplate const* proto = GetTemplate();
823
824 if (spellInfo->EquippedItemClass != -1) // -1 == any item class
825 {
826 // Special case - accept vellum for armor/weapon requirements
827 if ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR ||
828 spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON) && proto->IsVellum())
829 if (spellInfo->IsAbilityOfSkillType(SKILL_ENCHANTING)) // only for enchanting spells
830 return true;
831
832 if (spellInfo->EquippedItemClass != int32(proto->Class))
833 return false; // wrong item class
834
835 if (spellInfo->EquippedItemSubClassMask != 0) // 0 == any subclass
836 {
837 if ((spellInfo->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
838 return false; // subclass not present in mask
839 }
840 }
841
842 if (spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
843 {
844 // Special case - accept weapon type for main and offhand requirements
845 if (proto->InventoryType == INVTYPE_WEAPON &&
848 return true;
849 else if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
850 return false; // inventory type not present in mask
851 }
852
853 return true;
854}
855
856void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/)
857{
858 // Better lost small time at check in comparison lost time at item save to DB.
859 if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
860 return;
861
862 Player* owner = GetOwner();
864 {
865 if (uint32 oldEnchant = GetEnchantmentId(slot))
866 owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetGUID(), GetEntry(), oldEnchant, slot);
867
868 if (id)
869 owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetGUID(), GetEntry(), id, slot);
870 }
871
875 SetState(ITEM_CHANGED, owner);
876}
877
879{
880 if (GetEnchantmentDuration(slot) == duration)
881 return;
882
884 SetState(ITEM_CHANGED, owner);
885 // Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
886}
887
896
898{
899 if (!GetEnchantmentId(slot))
900 return;
901
902 for (uint8 x = 0; x < MAX_ITEM_ENCHANTMENT_EFFECTS; ++x)
905}
906
908{
909 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
910 {
912
913 if (!SocketColor) // no socket slot
914 continue;
915
916 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
917 if (!enchant_id) // no gems on this socket
918 return false;
919
920 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
921 if (!enchantEntry) // invalid gem id on this socket
922 return false;
923
924 uint8 GemColor = 0;
925
926 uint32 gemid = enchantEntry->GemID;
927 if (gemid)
928 {
929 ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemid);
930 if (gemProto)
931 {
932 GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties);
933 if (gemProperty)
934 GemColor = gemProperty->color;
935 }
936 }
937
938 if (!(GemColor & SocketColor)) // bad gem color on this socket
939 return false;
940 }
941 return true;
942}
943
945{
946 uint8 count = 0;
947 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
948 {
949 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
950 if (!enchant_id)
951 continue;
952
953 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
954 if (!enchantEntry)
955 continue;
956
957 if (GemID == enchantEntry->GemID)
958 ++count;
959 }
960 return count;
961}
962
964{
965 uint8 count = 0;
966 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
967 {
968 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
969 if (!enchant_id)
970 continue;
971
972 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
973 if (!enchantEntry)
974 continue;
975
976 ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID);
977 if (!gemProto)
978 continue;
979
980 if (gemProto->ItemLimitCategory == limitCategory)
981 ++count;
982 }
983 return count;
984}
985
986bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const
987{
988 ItemTemplate const* proto = GetTemplate();
989 return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId));
990}
991
992// Though the client has the information in the item's data field,
993// we have to send SMSG_ITEM_TIME_UPDATE to display the remaining
994// time.
996{
998
999 if (!duration)
1000 return;
1001
1002 ObjectGuid guid = GetGUID();
1003
1004 WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
1005 data.WriteGuidMask(guid, 5, 3, 4, 1, 2, 6, 0, 7);
1006 data.WriteGuidBytes(guid, 2, 6, 7, 4, 0, 3, 5, 1);
1007 data << uint32(duration);
1008
1009 owner->GetSession()->SendPacket(&data);
1010}
1011
1012Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player)
1013{
1014 if (count < 1)
1015 return NULL; //don't create item at zero count
1016
1017 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry);
1018 if (proto)
1019 {
1020 if (count > proto->GetMaxStackSize())
1021 count = proto->GetMaxStackSize();
1022
1023 ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
1024
1025 Item* item = NewItemOrBag(proto);
1026 if (item->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), itemEntry, player))
1027 {
1028 item->SetCount(count);
1029 return item;
1030 }
1031 else
1032 delete item;
1033 }
1034 else
1035 ASSERT(false);
1036 return NULL;
1037}
1038
1039Item* Item::CloneItem(uint32 count, Player const* player) const
1040{
1041 Item* newItem = CreateItem(GetEntry(), count, player);
1042 if (!newItem)
1043 return NULL;
1044
1049 // player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
1050 if (player)
1052 return newItem;
1053}
1054
1055bool Item::IsBindedNotWith(Player const* player) const
1056{
1057 // not binded item
1058 if (!IsSoulBound())
1059 return false;
1060
1061 // own item
1062 if (GetOwnerGUID() == player->GetGUID())
1063 return false;
1064
1066 if (allowedGUIDs.find(player->GetGUIDLow()) != allowedGUIDs.end())
1067 return false;
1068
1069 // BOA item case
1070 if (IsBoundAccountWide())
1071 return false;
1072
1073 return true;
1074}
1075
1077{
1078 if (Player* owner = GetOwner())
1079 BuildFieldsUpdate(owner, data_map);
1080 ClearUpdateMask(false);
1081}
1082
1084{
1085 SQLTransaction trans = CharacterDatabase.BeginTransaction();
1086
1088 stmt->setUInt32(0, GetGUIDLow());
1089 trans->Append(stmt);
1090
1091 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
1092 stmt->setUInt32(0, GetGUIDLow());
1093 stmt->setUInt32(1, GetRefundRecipient());
1094 stmt->setUInt32(2, GetPaidMoney());
1096 trans->Append(stmt);
1097
1098 CharacterDatabase.CommitTransaction(trans);
1099}
1100
1102{
1103 if (trans && !trans->null())
1104 {
1106 stmt->setUInt32(0, GetGUIDLow());
1107 (*trans)->Append(stmt);
1108 }
1109}
1110
1111void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransaction* trans /*=NULL*/)
1112{
1114 return;
1115
1117 // Following is not applicable in the trading procedure
1118 if (changestate)
1119 SetState(ITEM_CHANGED, owner);
1120
1122 SetPaidMoney(0);
1125
1127}
1128
1130{
1131 /* Here we update our played time
1132 We simply add a number to the current played time,
1133 based on the time elapsed since the last update hereof.
1134 */
1135 // Get current played time
1137 // Calculate time elapsed since last played time update
1138 time_t curtime = time(NULL);
1139 uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
1140 uint32 new_playtime = current_playtime + elapsed;
1141 // Check if the refund timer has expired yet
1142 if (new_playtime <= 2 * HOUR)
1143 {
1144 // No? Proceed.
1145 // Update the data field
1147 // Flag as changed to get saved to DB
1148 SetState(ITEM_CHANGED, owner);
1149 // Speaks for itself
1150 m_lastPlayedTimeUpdate = curtime;
1151 return;
1152 }
1153 // Yes
1154 SetNotRefundable(owner);
1155}
1156
1158{
1159 time_t curtime = time(NULL);
1160 uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
1162}
1163
1165{
1166 return (GetPlayedTime() > 2 * HOUR);
1167}
1168
1170{
1172 allowedGUIDs = allowedLooters;
1173}
1174
1176{
1178 if (allowedGUIDs.empty())
1179 return;
1180
1181 allowedGUIDs.clear();
1182 SetState(ITEM_CHANGED, currentOwner);
1183 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
1184 stmt->setUInt32(0, GetGUIDLow());
1185 CharacterDatabase.Execute(stmt);
1186}
1187
1189{
1190 // called from owner's update - GetOwner() MUST be valid
1191 if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2 * HOUR < GetOwner()->GetTotalPlayedTime())
1192 {
1194 return true; // remove from tradeable list
1195 }
1196
1197 return false;
1198}
1199
1201{
1202 ItemTemplate const* proto = GetTemplate();
1203
1204 if (!proto)
1205 return false;
1206
1207 if (proto->Quality == ITEM_QUALITY_LEGENDARY)
1208 return false;
1209
1210 if (proto->Class != ITEM_CLASS_ARMOR &&
1211 proto->Class != ITEM_CLASS_WEAPON)
1212 return false;
1213
1215 return false;
1216
1218 return false;
1219
1220 if (!HasStats())
1221 return false;
1222
1223 return true;
1224}
1225
1227{
1228 ItemTemplate const* proto = GetTemplate();
1229
1230 if (!proto)
1231 return false;
1232
1234 return false;
1235
1236 if (proto->Quality == ITEM_QUALITY_LEGENDARY)
1237 return false;
1238
1239 if (proto->Class != ITEM_CLASS_ARMOR &&
1240 proto->Class != ITEM_CLASS_WEAPON)
1241 return false;
1242
1244 return false;
1245
1247 return true;
1248
1249 if (!HasStats())
1250 return false;
1251
1252 return true;
1253}
1254
1255bool Item::CanTransmogrifyItemWithItem(Item const* transmogrified, Item const* transmogrifier)
1256{
1257 if (!transmogrifier || !transmogrified)
1258 return false;
1259
1260 ItemTemplate const* proto1 = transmogrifier->GetTemplate(); // source
1261 ItemTemplate const* proto2 = transmogrified->GetTemplate(); // dest
1262
1263 if (proto1->ItemId == proto2->ItemId)
1264 return false;
1265
1266 if (!transmogrified->CanTransmogrify() || !transmogrifier->CanBeTransmogrified())
1267 return false;
1268
1269 if (proto1->InventoryType == INVTYPE_BAG ||
1270 proto1->InventoryType == INVTYPE_RELIC ||
1271 proto1->InventoryType == INVTYPE_BODY ||
1272 proto1->InventoryType == INVTYPE_FINGER ||
1273 proto1->InventoryType == INVTYPE_TRINKET ||
1274 proto1->InventoryType == INVTYPE_AMMO ||
1275 proto1->InventoryType == INVTYPE_QUIVER)
1276 return false;
1277
1278 if (proto1->SubClass != proto2->SubClass && (proto1->Class != ITEM_CLASS_WEAPON || !proto2->IsRangedWeapon() || !proto1->IsRangedWeapon()))
1279 return false;
1280
1281 if (proto1->InventoryType != proto2->InventoryType &&
1283 (proto1->Class != ITEM_CLASS_ARMOR || (proto1->InventoryType != INVTYPE_CHEST && proto2->InventoryType != INVTYPE_ROBE && proto1->InventoryType != INVTYPE_ROBE && proto2->InventoryType != INVTYPE_CHEST)))
1284 return false;
1285
1286 return true;
1287}
1288
1289bool Item::HasStats() const
1290{
1291 if (GetItemRandomPropertyId() != 0)
1292 return true;
1293
1294 ItemTemplate const* proto = GetTemplate();
1295 for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1296 if (proto->ItemStat[i].ItemStatValue != 0)
1297 return true;
1298
1299 if (proto->ScalingStatDistribution != 0)
1300 return true;
1301
1302 return false;
1303}
1304
1305// used by mail items, transmog cost, stationeryinfo and others
1306uint32 Item::GetSellPrice(ItemTemplate const* proto, bool& normalSellPrice)
1307{
1308 normalSellPrice = true;
1309
1311 {
1312 return proto->BuyPrice;
1313 }
1314 else
1315 {
1316 ImportPriceQualityEntry const* qualityPrice = sImportPriceQualityStore.LookupEntry(proto->Quality + 1);
1317 ItemPriceBaseEntry const* basePrice = sItemPriceBaseStore.LookupEntry(proto->ItemLevel);
1318
1319 if (!qualityPrice || !basePrice)
1320 return 0;
1321
1322 float qualityFactor = qualityPrice->Factor;
1323 float baseFactor = 0.0f;
1324
1325 uint32 inventoryType = proto->InventoryType;
1326
1327 if (inventoryType == INVTYPE_WEAPON ||
1328 inventoryType == INVTYPE_2HWEAPON ||
1329 inventoryType == INVTYPE_WEAPONMAINHAND ||
1330 inventoryType == INVTYPE_WEAPONOFFHAND ||
1331 inventoryType == INVTYPE_RANGED ||
1332 inventoryType == INVTYPE_THROWN ||
1333 inventoryType == INVTYPE_RANGEDRIGHT)
1334 baseFactor = basePrice->WeaponFactor;
1335 else
1336 baseFactor = basePrice->ArmorFactor;
1337
1338 if (inventoryType == INVTYPE_ROBE)
1339 inventoryType = INVTYPE_CHEST;
1340
1341 float typeFactor = 0.0f;
1342 int8 weapType = -1;
1343
1344 switch (inventoryType)
1345 {
1346 case INVTYPE_HEAD:
1347 case INVTYPE_SHOULDERS:
1348 case INVTYPE_CHEST:
1349 case INVTYPE_WAIST:
1350 case INVTYPE_LEGS:
1351 case INVTYPE_FEET:
1352 case INVTYPE_WRISTS:
1353 case INVTYPE_HANDS:
1354 case INVTYPE_CLOAK:
1355 {
1356 ImportPriceArmorEntry const* armorPrice = sImportPriceArmorStore.LookupEntry(inventoryType);
1357 if (!armorPrice)
1358 return 0;
1359
1360 switch (proto->SubClass)
1361 {
1364 typeFactor = armorPrice->ClothFactor;
1365 break;
1367 typeFactor = armorPrice->LeatherFactor;
1368 break;
1370 typeFactor = armorPrice->MailFactor;
1371 break;
1373 typeFactor = armorPrice->PlateFactor;
1374 break;
1375 default:
1376 return 0;
1377 }
1378
1379 break;
1380 }
1381 case INVTYPE_SHIELD:
1382 {
1383 ImportPriceShieldEntry const* shieldPrice = sImportPriceShieldStore.LookupEntry(1); // it only has two rows, it's unclear which is the one used
1384 if (!shieldPrice)
1385 return 0;
1386
1387 typeFactor = shieldPrice->Factor;
1388 break;
1389 }
1391 weapType = 0;
1392 break;
1394 weapType = 1;
1395 break;
1396 case INVTYPE_WEAPON:
1397 weapType = 2;
1398 break;
1399 case INVTYPE_2HWEAPON:
1400 weapType = 3;
1401 break;
1402 case INVTYPE_RANGED:
1404 case INVTYPE_RELIC:
1405 weapType = 4;
1406 break;
1407 default:
1408 return proto->BuyPrice;
1409 }
1410
1411 if (weapType != -1)
1412 {
1413 ImportPriceWeaponEntry const* weaponPrice = sImportPriceWeaponStore.LookupEntry(weapType + 1);
1414 if (!weaponPrice)
1415 return 0;
1416
1417 typeFactor = weaponPrice->Factor;
1418 }
1419
1420 normalSellPrice = false;
1421 return uint32(qualityFactor * proto->Unk430_2 * proto->Unk430_1 * typeFactor * baseFactor);
1422 }
1423}
1424
1425uint32 Item::GetSpecialPrice(ItemTemplate const* proto, uint32 minimumPrice /*= 10000*/)
1426{
1427 uint32 cost = 0;
1428
1430 cost = proto->SellPrice;
1431 else
1432 {
1433 bool normalPrice;
1434 cost = Item::GetSellPrice(proto, normalPrice);
1435
1436 if (!normalPrice)
1437 {
1438 if (proto->BuyCount <= 1)
1439 {
1440 ItemClassEntry const* classEntry = sItemClassStore.LookupEntry(proto->Class);
1441 if (classEntry)
1442 cost *= classEntry->PriceFactor;
1443 else
1444 cost = 0;
1445 }
1446 else
1447 cost /= 4 * proto->BuyCount;
1448 }
1449 else
1450 cost = proto->SellPrice;
1451 }
1452
1453 if (cost < minimumPrice)
1454 cost = minimumPrice;
1455
1456 return cost;
1457}
1458
1460{
1461 ItemTemplate const* proto = GetTemplate();
1462 for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
1463 if (ItemModType(proto->ItemStat[i].ItemStatType) == statType)
1464 return proto->ItemStat[i].ItemStatValue;
1465
1466 int32 randomPropId = GetItemRandomPropertyId();
1467 if (!randomPropId)
1468 return 0;
1469
1470 if (randomPropId < 0)
1471 {
1472 ItemRandomSuffixEntry const* randomSuffix = sItemRandomSuffixStore.LookupEntry(-randomPropId);
1473 if (!randomSuffix)
1474 return 0;
1475
1478 for (uint32 f = 0; f < MAX_ITEM_ENCHANTMENT_EFFECTS; ++f)
1479 if (enchant->type[f] == ITEM_ENCHANTMENT_TYPE_STAT && ItemModType(enchant->spellid[f]) == statType)
1480 for (int k = 0; k < 5; ++k)
1481 if (randomSuffix->enchant_id[k] == enchant->ID)
1482 return int32((randomSuffix->prefix[k] * GetItemSuffixFactor()) / 10000);
1483 }
1484 else
1485 {
1486 ItemRandomPropertiesEntry const* randomProp = sItemRandomPropertiesStore.LookupEntry(randomPropId);
1487 if (!randomProp)
1488 return 0;
1489
1492 for (uint32 f = 0; f < MAX_ITEM_ENCHANTMENT_EFFECTS; ++f)
1493 if (enchant->type[f] == ITEM_ENCHANTMENT_TYPE_STAT && ItemModType(enchant->spellid[f]) == statType)
1494 for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
1495 if (randomProp->enchant_id[k] == enchant->ID)
1496 return int32(enchant->amount[k]);
1497 }
1498
1499 return 0;
1500}
1501
1503{
1504 // Saves the money and item loot associated with an openable item to the DB
1505 if (loot.isLooted()) // no money and no loot
1506 return;
1507
1508 uint32 container_id = GetGUIDLow();
1509 SQLTransaction trans = CharacterDatabase.BeginTransaction();
1510
1511 loot.containerID = container_id; // Save this for when a LootItem is removed
1512
1513 // Save money
1514 if (loot.gold > 0)
1515 {
1516 PreparedStatement* stmt_money = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY);
1517 stmt_money->setUInt32(0, container_id);
1518 trans->Append(stmt_money);
1519
1520 stmt_money = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_MONEY);
1521 stmt_money->setUInt32(0, container_id);
1522 stmt_money->setUInt32(1, loot.gold);
1523 trans->Append(stmt_money);
1524 }
1525
1526 // Save items
1527 if (!loot.isLooted())
1528 {
1529 PreparedStatement* stmt_items = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS);
1530 stmt_items->setUInt32(0, container_id);
1531 trans->Append(stmt_items);
1532
1533 // Now insert the items
1534 for (LootItemList::const_iterator _li = loot.items.begin(); _li != loot.items.end(); ++_li)
1535 {
1536 // When an item is looted, it doesn't get removed from the items collection
1537 // but we don't want to resave it.
1538 if (!_li->canSave)
1539 continue;
1540
1541 stmt_items = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_ITEMS);
1542
1543 // container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix
1544 stmt_items->setUInt32(0, container_id);
1545 stmt_items->setUInt32(1, _li->itemid);
1546 stmt_items->setUInt32(2, _li->count);
1547 stmt_items->setBool(3, _li->follow_loot_rules);
1548 stmt_items->setBool(4, _li->freeforall);
1549 stmt_items->setBool(5, _li->is_blocked);
1550 stmt_items->setBool(6, _li->is_counted);
1551 stmt_items->setBool(7, _li->is_underthreshold);
1552 stmt_items->setBool(8, _li->needs_quest);
1553 stmt_items->setInt32(9, _li->randomPropertyId);
1554 stmt_items->setUInt32(10, _li->randomSuffix);
1555 trans->Append(stmt_items);
1556 }
1557 }
1558
1559 CharacterDatabase.CommitTransaction(trans);
1560}
1561
1563{
1564 // Loads the money and item loot associated with an openable item from the DB
1565 // Default. If there are no records for this item then it will be rolled for in Player::SendLoot()
1566 m_lootGenerated = false;
1567
1568 uint32 container_id = GetGUIDLow();
1569
1570 // Save this for later use
1571 loot.containerID = container_id;
1572
1573 // First, see if there was any money loot. This gets added directly to the container.
1575 stmt->setUInt32(0, container_id);
1576 PreparedQueryResult money_result = CharacterDatabase.Query(stmt);
1577
1578 if (money_result)
1579 {
1580 Field* fields = money_result->Fetch();
1581 loot.gold = fields[0].GetUInt32();
1582 }
1583
1584 // Next, load any items that were saved
1585 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_ITEMS);
1586 stmt->setUInt32(0, container_id);
1587 PreparedQueryResult item_result = CharacterDatabase.Query(stmt);
1588
1589 if (item_result)
1590 {
1591 // Get a LootTemplate for the container item. This is where
1592 // the saved loot was originally rolled from, we will copy conditions from it
1593 LootTemplate const* lt = LootTemplates_Item.GetLootFor(GetEntry());
1594 if (lt)
1595 {
1596 do
1597 {
1598 // Create an empty LootItem
1599 LootItem loot_item = LootItem();
1600
1601 // Fill in the rest of the LootItem from the DB
1602 Field* fields = item_result->Fetch();
1603
1604 // item_id, itm_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix
1605 loot_item.itemid = fields[0].GetUInt32();
1606 loot_item.count = fields[1].GetUInt32();
1607 loot_item.follow_loot_rules = fields[2].GetBool();
1608 loot_item.freeforall = fields[3].GetBool();
1609 loot_item.is_blocked = fields[4].GetBool();
1610 loot_item.is_counted = fields[5].GetBool();
1611 loot_item.canSave = true;
1612 loot_item.is_underthreshold = fields[6].GetBool();
1613 loot_item.needs_quest = fields[7].GetBool();
1614 loot_item.randomPropertyId = fields[8].GetInt32();
1615 loot_item.randomSuffix = fields[9].GetUInt32();
1616
1617 // Copy the extra loot conditions from the item in the loot template
1618 lt->CopyConditions(&loot_item);
1619
1620 // If container item is in a bag, add that player as an allowed looter
1621 if (GetBagSlot())
1622 loot_item.allowedGUIDs.insert(GetOwner()->GetGUIDLow());
1623
1624 // Finally add the LootItem to the container
1625 loot.items.push_back(loot_item);
1626
1627 // Increment unlooted count
1628 loot.unlootedCount++;
1629 } while (item_result->NextRow());
1630 }
1631 }
1632
1633 // Mark the item if it has loot so it won't be generated again on open
1634 m_lootGenerated = !loot.isLooted();
1635
1636 return m_lootGenerated;
1637}
1638
1640{
1641 // Deletes items associated with an openable item from the DB
1642 uint32 containerId = GetGUIDLow();
1644 stmt->setUInt32(0, containerId);
1645 SQLTransaction trans = CharacterDatabase.BeginTransaction();
1646 trans->Append(stmt);
1647 CharacterDatabase.CommitTransaction(trans);
1648}
1649
1651{
1652 // Deletes a single item associated with an openable item from the DB
1653 uint32 containerId = GetGUIDLow();
1655 stmt->setUInt32(0, containerId);
1656 stmt->setUInt32(1, itemID);
1657 SQLTransaction trans = CharacterDatabase.BeginTransaction();
1658 trans->Append(stmt);
1659 CharacterDatabase.CommitTransaction(trans);
1660}
1661
1663{
1664 // Deletes the money loot associated with an openable item from the DB
1665 uint32 containerId = GetGUIDLow();
1667 stmt->setUInt32(0, containerId);
1668 SQLTransaction trans = CharacterDatabase.BeginTransaction();
1669 trans->Append(stmt);
1670 CharacterDatabase.CommitTransaction(trans);
1671}
1672
1674{
1675 // Deletes money and items associated with an openable item from the DB
1678}
Item * NewItemOrBag(ItemTemplate const *proto)
Definition Bag.h:53
@ CHAR_UPD_ITEM_INSTANCE
@ CHAR_UPD_ITEM_INSTANCE_ON_LOAD
@ CHAR_DEL_ITEM_INSTANCE_TRANSMOG
@ CHAR_DEL_ITEM_INSTANCE
@ CHAR_DEL_ITEMCONTAINER_MONEY
@ CHAR_DEL_CHAR_INVENTORY_BY_ITEM
@ CHAR_DEL_ITEMCONTAINER_ITEM
@ CHAR_DEL_ITEMCONTAINER_ITEMS
@ CHAR_SEL_ITEMCONTAINER_ITEMS
@ CHAR_DEL_ITEM_BOP_TRADE
@ CHAR_DEL_ITEM_REFUND_INSTANCE
@ CHAR_INS_ITEMCONTAINER_ITEMS
@ CHAR_INS_ITEMCONTAINER_MONEY
@ CHAR_INS_ITEM_INSTANCE_TRANSMOG
@ CHAR_SEL_ITEMCONTAINER_MONEY
@ CHAR_UPD_GIFT_OWNER
@ CHAR_DEL_GIFT
@ CHAR_REP_ITEM_INSTANCE
@ CHAR_INS_ITEM_REFUND_INSTANCE
@ HOUR
Definition Common.h:120
@ ITEM_ENCHANTMENT_TYPE_STAT
Definition DBCEnums.h:414
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
DBCStorage< ImportPriceShieldEntry > sImportPriceShieldStore(ImportPriceShieldfmt)
DBCStorage< ItemClassEntry > sItemClassStore(ItemClassfmt)
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< ImportPriceArmorEntry > sImportPriceArmorStore(ImportPriceArmorfmt)
DBCStorage< ItemPriceBaseEntry > sItemPriceBaseStore(ItemPriceBasefmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
DBCStorage< ImportPriceQualityEntry > sImportPriceQualityStore(ImportPriceQualityfmt)
DBCStorage< ImportPriceWeaponEntry > sImportPriceWeaponStore(ImportPriceWeaponfmt)
#define MAX_ITEM_SET_SPELLS
#define MAX_ITEM_ENCHANTMENT_EFFECTS
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
#define ASSERT
Definition Errors.h:29
void AddItemsSetItem(Player *player, Item *item)
Definition Item.cpp:20
bool ItemCanGoIntoBag(ItemTemplate const *pProto, ItemTemplate const *pBagProto)
Definition Item.cpp:160
void RemoveItemsSetItem(Player *player, ItemTemplate const *proto)
Definition Item.cpp:102
#define MAX_GEM_SOCKETS
Definition Item.h:170
#define MAX_ENCHANTMENT_OFFSET
Definition Item.h:179
EnchantmentSlot
Definition Item.h:149
@ PERM_ENCHANTMENT_SLOT
Definition Item.h:150
@ PROP_ENCHANTMENT_SLOT_0
Definition Item.h:160
@ MAX_ENCHANTMENT_SLOT
Definition Item.h:165
@ PRISMATIC_ENCHANTMENT_SLOT
Definition Item.h:156
@ PROP_ENCHANTMENT_SLOT_1
Definition Item.h:161
@ SOCK_ENCHANTMENT_SLOT
Definition Item.h:152
@ MAX_INSPECTED_ENCHANTMENT_SLOT
Definition Item.h:158
@ PROP_ENCHANTMENT_SLOT_4
Definition Item.h:164
@ ENCHANTMENT_CAN_SOULBOUND
Definition Item.h:183
InventoryResult
Definition Item.h:27
@ EQUIP_ERR_OK
Definition Item.h:28
@ EQUIP_ERR_LOOT_GONE
Definition Item.h:77
@ EQUIP_ERR_CANT_STACK
Definition Item.h:47
ItemUpdateState
Definition Item.h:190
@ ITEM_CHANGED
Definition Item.h:192
@ ITEM_REMOVED
Definition Item.h:194
@ ITEM_NEW
Definition Item.h:193
@ ITEM_UNCHANGED
Definition Item.h:191
@ ENCHANTMENT_ID_OFFSET
Definition Item.h:174
@ ENCHANTMENT_CHARGES_OFFSET
Definition Item.h:176
@ ENCHANTMENT_DURATION_OFFSET
Definition Item.h:175
uint32 GenerateEnchSuffixFactor(uint32 item_id)
uint32 GetItemEnchantMod(int32 entry)
@ ITEM_SUBCLASS_WEAPON_FISHING_POLE
@ INVTYPE_BODY
@ INVTYPE_FINGER
@ INVTYPE_HEAD
@ INVTYPE_CLOAK
@ INVTYPE_ROBE
@ INVTYPE_TRINKET
@ INVTYPE_RELIC
@ INVTYPE_RANGED
@ INVTYPE_THROWN
@ INVTYPE_WAIST
@ INVTYPE_RANGEDRIGHT
@ INVTYPE_WRISTS
@ INVTYPE_WEAPON
@ INVTYPE_WEAPONMAINHAND
@ INVTYPE_WEAPONOFFHAND
@ INVTYPE_2HWEAPON
@ INVTYPE_BAG
@ INVTYPE_SHOULDERS
@ INVTYPE_FEET
@ INVTYPE_AMMO
@ INVTYPE_QUIVER
@ INVTYPE_SHIELD
@ INVTYPE_LEGS
@ INVTYPE_CHEST
@ INVTYPE_HANDS
@ BAG_FAMILY_MASK_MINING_SUPP
@ BAG_FAMILY_MASK_HERBS
@ BAG_FAMILY_MASK_ENCHANTING_SUPP
@ BAG_FAMILY_MASK_SOUL_SHARDS
@ BAG_FAMILY_MASK_INSCRIPTION_SUPP
@ BAG_FAMILY_MASK_GEMS
@ BAG_FAMILY_MASK_ARROWS
@ BAG_FAMILY_MASK_BULLETS
@ BAG_FAMILY_MASK_ENGINEERING_SUPP
@ BAG_FAMILY_MASK_COOKING_SUPP
@ BAG_FAMILY_MASK_FISHING_SUPP
@ BAG_FAMILY_MASK_LEATHERWORKING_SUPP
@ ITEM_SUBCLASS_CONTAINER
@ ITEM_SUBCLASS_COOKING_CONTAINER
@ ITEM_SUBCLASS_INSCRIPTION_CONTAINER
@ ITEM_SUBCLASS_LEATHERWORKING_CONTAINER
@ ITEM_SUBCLASS_TACKLE_CONTAINER
@ ITEM_SUBCLASS_GEM_CONTAINER
@ ITEM_SUBCLASS_SOUL_CONTAINER
@ ITEM_SUBCLASS_ENCHANTING_CONTAINER
@ ITEM_SUBCLASS_MINING_CONTAINER
@ ITEM_SUBCLASS_HERB_CONTAINER
@ ITEM_SUBCLASS_ENGINEERING_CONTAINER
@ ITEM_SUBCLASS_QUIVER
@ ITEM_SUBCLASS_AMMO_POUCH
ItemModType
@ ITEM_SUBCLASS_ARMOR_MAIL
@ ITEM_SUBCLASS_ARMOR_CLOTH
@ ITEM_SUBCLASS_ARMOR_LEATHER
@ ITEM_SUBCLASS_ARMOR_PLATE
@ ITEM_SUBCLASS_ARMOR_MISCELLANEOUS
#define MAX_ITEM_SUBCLASS_ARMOR
@ ITEM_FLAGS_EXTRA_CANNOT_TRANSMOG
@ ITEM_FLAGS_EXTRA_HAS_NORMAL_PRICE
@ ITEM_FLAGS_EXTRA_CAN_TRANSMOG
@ ITEM_FLAGS_EXTRA_CANNOT_BE_TRANSMOG
SocketColor
#define MAX_ITEM_PROTO_SPELLS
@ NO_BIND
@ ITEM_CLASS_QUIVER
@ ITEM_CLASS_CONTAINER
@ ITEM_CLASS_ARMOR
@ ITEM_CLASS_WEAPON
@ ITEM_FLAG_BOP_TRADEABLE
@ ITEM_FLAG_WRAPPED
@ ITEM_FLAG_SOULBOUND
@ ITEM_FLAG_REFUNDABLE
#define MAX_ITEM_SUBCLASS_WEAPON
#define MAX_ITEM_PROTO_STATS
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
std::set< uint32 > AllowedLooterSet
Definition LootMgr.h:116
@ TYPEID_ITEM
Definition Object.h:52
UNORDERED_MAP< Player *, UpdateData > UpdateDataMapType
Definition Object.h:107
@ TYPEMASK_ITEM
Definition Object.h:38
uint32 GUID_LOPART(uint64 x)
@ HIGHGUID_PLAYER
@ HIGHGUID_ITEM
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
#define sObjectMgr
Definition ObjectMgr.h:1617
@ EQUIPMENT_SLOT_END
Definition Player.h:708
#define INVENTORY_SLOT_BAG_0
Definition Player.h:684
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Definition QueryResult.h:94
#define sScriptMgr
Definition ScriptMgr.h:764
@ ITEM_QUALITY_LEGENDARY
@ SKILL_BOWS
@ SKILL_MACES
@ SKILL_PLATE_MAIL
@ SKILL_LEATHER
@ SKILL_WANDS
@ SKILL_GUNS
@ SKILL_SHIELD
@ SKILL_CROSSBOWS
@ SKILL_FISHING
@ SKILL_SWORDS
@ SKILL_DAGGERS
@ SKILL_2H_AXES
@ SKILL_CLOTH
@ SKILL_POLEARMS
@ SKILL_2H_SWORDS
@ SKILL_MAIL
@ SKILL_FIST_WEAPONS
@ SKILL_2H_MACES
@ SKILL_AXES
@ SKILL_STAVES
@ SKILL_ENCHANTING
#define sSpellMgr
Definition SpellMgr.h:744
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
Definition Transaction.h:42
@ ITEM_FIELD_DURABILITY
@ ITEM_FIELD_CONTAINED_IN
@ ITEM_FIELD_STACK_COUNT
@ ITEM_FIELD_ENCHANTMENT
@ ITEM_END
@ ITEM_FIELD_MAX_DURABILITY
@ ITEM_FIELD_RANDOM_PROPERTIES_ID
@ ITEM_FIELD_CREATOR
@ ITEM_FIELD_MODIFIERS_MASK
@ ITEM_FIELD_OWNER
@ ITEM_FIELD_EXPIRATION
@ ITEM_FIELD_PROPERTY_SEED
@ ITEM_FIELD_GIFT_CREATOR
@ ITEM_FIELD_DYNAMIC_FLAGS
@ ITEM_FIELD_CREATE_PLAYED_TIME
@ ITEM_DYNAMIC_END
@ ITEM_DYNAMIC_MODIFIERS
Definition Bag.h:16
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
Definition Field.h:16
std::string GetString() const
Definition Field.h:228
uint16 GetUInt16() const
Definition Field.h:69
bool GetBool() const
Definition Field.h:21
uint32 GetUInt32() const
Definition Field.h:105
int32 GetInt32() const
Definition Field.h:123
Definition Item.h:202
uint32 GetPlayedTime()
Definition Item.cpp:1157
uint32 GetPaidExtendedCost() const
Definition Item.h:332
void BuildUpdate(UpdateDataMapType &)
Definition Item.cpp:1076
uint8 GetSlot() const
Definition Item.h:265
int32 GetReforgableStat(ItemModType statType) const
Definition Item.cpp:1459
void UpdateItemSuffixFactor()
Definition Item.cpp:659
void SetNotRefundable(Player *owner, bool changestate=true, SQLTransaction *trans=NULL)
Definition Item.cpp:1111
void SetSpellCharges(uint8 index, int32 value)
Definition Item.h:299
void SetText(std::string const &text)
Definition Item.h:292
void UpdateDuration(Player *owner, uint32 diff)
Definition Item.cpp:287
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster=0)
Definition Item.cpp:856
bool HasEnchantRequiredSkill(const Player *player) const
Definition Item.cpp:769
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const
Definition Item.cpp:986
Item()
Definition Item.cpp:233
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition Item.cpp:667
void AddToUpdateQueueOf(Player *player)
Definition Item.cpp:694
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition Item.h:287
void ItemContainerSaveLootToDB()
Definition Item.cpp:1502
int32 GetSpellCharges(uint8 index=0) const
Definition Item.h:298
void SetOwnerGUID(uint64 guid)
Definition Item.h:214
void RemoveFromUpdateQueueOf(Player *player)
Definition Item.cpp:714
Bag * m_container
Definition Item.h:367
void SetSoulboundTradeable(AllowedLooterSet const &allowedLooters)
Definition Item.cpp:1169
void SetItemRandomProperties(int32 randomPropId)
Definition Item.cpp:621
void SetPaidMoney(uint32 money)
Definition Item.h:327
uint8 GetGemCountWithID(uint32 GemID) const
Definition Item.cpp:944
bool IsBoundAccountWide() const
Definition Item.h:219
bool mb_in_trade
Definition Item.h:370
Bag * ToBag()
Definition Item.h:240
std::string m_text
Definition Item.h:365
Item * CloneItem(uint32 count, Player const *player=NULL) const
Definition Item.cpp:1039
bool HasStats() const
Definition Item.cpp:1289
bool CanBeTraded(bool mail=false, bool trade=false) const
Definition Item.cpp:744
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition Item.h:288
void ItemContainerDeleteLootMoneyAndLootItemsFromDB()
Definition Item.cpp:1673
virtual void SaveToDB(SQLTransaction &trans)
Definition Item.cpp:305
void SetCount(uint32 value)
Definition Item.h:259
int32 GetItemRandomPropertyId() const
Definition Item.h:278
ItemTemplate const * GetTemplate() const
Definition Item.cpp:528
bool IsInBag() const
Definition Item.h:272
bool IsSoulBound() const
Definition Item.h:218
void SaveRefundDataToDB()
Definition Item.cpp:1083
void SetRefundRecipient(uint32 pGuidLow)
Definition Item.h:326
uint32 GetItemSuffixFactor() const
Definition Item.h:279
bool IsBindedNotWith(Player const *player) const
Definition Item.cpp:1055
uint32 m_paidMoney
Definition Item.h:373
static uint32 GetSpecialPrice(ItemTemplate const *proto, uint32 minimumPrice=10000)
Definition Item.cpp:1425
bool CanBeTransmogrified() const
Definition Item.cpp:1200
bool IsEquipped() const
Definition Item.cpp:739
void SendTimeUpdate(Player *owner)
Definition Item.cpp:995
bool IsRefundExpired()
Definition Item.cpp:1164
void UpdatePlayedTime(Player *owner)
Definition Item.cpp:1129
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field *fields, uint32 entry)
Definition Item.cpp:405
static bool CanTransmogrifyItemWithItem(Item const *transmogrified, Item const *transmogrifier)
Definition Item.cpp:1255
Player * GetOwner() const
Definition Item.cpp:533
time_t m_lastPlayedTimeUpdate
Definition Item.h:371
uint32 GetSkill()
Definition Item.cpp:538
static Item * CreateItem(uint32 itemEntry, uint32 count, Player const *player=NULL)
Definition Item.cpp:1012
static uint32 GetSellPrice(ItemTemplate const *proto, bool &success)
Definition Item.cpp:1306
uint16 GetPos() const
Definition Item.h:269
bool GemsFitSockets() const
Definition Item.cpp:907
bool ItemContainerLoadLootFromDB()
Definition Item.cpp:1562
bool IsBoundByEnchant() const
Definition Item.cpp:786
void DeleteRefundDataFromDB(SQLTransaction *trans)
Definition Item.cpp:1101
int16 uQueuePos
Definition Item.h:369
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
Definition Item.cpp:888
uint32 m_paidExtendedCost
Definition Item.h:374
bool IsBag() const
Definition Item.h:244
void ClearEnchantment(EnchantmentSlot slot)
Definition Item.cpp:897
static void DeleteFromInventoryDB(SQLTransaction &trans, uint32 itemGuid)
Definition Item.cpp:516
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player *owner)
Definition Item.cpp:878
InventoryResult CanBeMergedPartlyWith(ItemTemplate const *proto) const
Definition Item.cpp:803
void SetPaidExtendedCost(uint32 iece)
Definition Item.h:328
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition Item.h:289
bool CanTransmogrify() const
Definition Item.cpp:1226
uint64 GetOwnerGUID() const
Definition Item.h:213
void ItemContainerDeleteLootItemFromDB(uint32 itemID)
Definition Item.cpp:1650
uint32 GetPaidMoney() const
Definition Item.h:331
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const
Definition Item.cpp:963
void ClearSoulboundTradeable(Player *currentOwner)
Definition Item.cpp:1175
bool IsNotEmptyBag() const
Definition Item.cpp:280
bool m_lootGenerated
Definition Item.h:302
uint32 GetCount() const
Definition Item.h:258
bool CheckSoulboundTradeExpire()
Definition Item.cpp:1188
Loot loot
Definition Item.h:301
uint8 GetBagSlot() const
Definition Item.cpp:734
void ItemContainerDeleteLootMoneyFromDB()
Definition Item.cpp:1662
uint32 m_refundRecipient
Definition Item.h:372
uint32 GetRefundRecipient() const
Definition Item.h:330
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition Item.cpp:575
virtual bool Create(uint32 guidlow, uint32 itemid, Player const *owner)
Definition Item.cpp:252
uint8 m_slot
Definition Item.h:366
bool IsInUpdateQueue() const
Definition Item.h:309
void ItemContainerDeleteLootItemsFromDB()
Definition Item.cpp:1639
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition Item.cpp:820
ItemUpdateState uState
Definition Item.h:368
AllowedLooterSet allowedGUIDs
Definition Item.h:375
static void DeleteFromDB(SQLTransaction &trans, uint32 itemGuid)
Definition Item.cpp:499
void CopyConditions(const ConditionList &conditions)
Definition LootMgr.cpp:1363
static Player * FindPlayer(uint64)
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
Definition Object.cpp:932
uint16 m_objectType
Definition Object.h:242
int32 GetInt32Value(uint16 index) const
Definition Object.cpp:319
void SetInt32Value(uint16 index, int32 value)
Definition Object.cpp:1021
uint64 GetGUID() const
Definition Object.h:119
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:325
void _LoadIntoDataField(std::string const &data, uint32 startOffset, uint32 count)
Definition Object.cpp:1004
uint32 GetGUIDLow() const
Definition Object.h:120
std::vector< uint32 * > m_dynamicTab
Definition Object.h:239
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:129
uint16 m_valuesCount
Definition Object.h:256
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
Definition Object.cpp:1317
void ClearUpdateMask(bool remove)
Definition Object.cpp:917
uint32 GetDynamicUInt32Value(uint32 tab, uint16 index) const
Definition Object.cpp:357
uint32 GetEntry() const
Definition Object.h:125
uint64 GetUInt64Value(uint16 index) const
Definition Object.cpp:331
void SetDynamicUInt32Value(uint32 tab, uint16 index, uint32 value)
Definition Object.cpp:1055
std::vector< bool * > m_dynamicChange
Definition Object.h:240
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:1309
void SetEntry(uint32 entry)
Definition Object.h:126
virtual void SetObjectScale(float scale)
Definition Object.h:129
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:1038
uint16 m_updateFlag
Definition Object.h:245
TypeID m_objectTypeId
Definition Object.h:244
void SetUInt64Value(uint16 index, uint64 value)
Definition Object.cpp:1079
std::vector< Item * > m_itemUpdateQueue
Definition Player.h:3382
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:6563
WorldSession * GetSession() const
Definition Player.h:2417
void DestroyItem(uint8 bag, uint8 slot, bool update)
std::vector< ItemSetEffect * > ItemSetEff
Definition Player.h:2681
static bool IsBagPos(uint16 pos)
void ApplyEquipSpell(SpellInfo const *spellInfo, Item *item, bool apply, bool form_change=false)
Definition Player.cpp:8848
void DeleteRefundReference(uint32 it)
Definition Player.cpp:22154
bool m_itemUpdateQueueBlocked
Definition Player.h:3383
void setBool(const uint8 index, const bool value)
void setString(const uint8 index, const std::string &value)
void setUInt16(const uint8 index, const uint16 value)
void setUInt32(const uint8 index, const uint32 value)
void setInt16(const uint8 index, const int16 value)
void setInt32(const uint8 index, const int32 value)
bool null() const
Definition AutoPtr.h:34
uint32 Id
Definition SpellInfo.h:160
int32 EquippedItemClass
Definition SpellInfo.h:215
bool IsAbilityOfSkillType(uint32 skillType) const
int32 EquippedItemSubClassMask
Definition SpellInfo.h:216
int32 EquippedItemInventoryTypeMask
Definition SpellInfo.h:217
size_type size() const
Definition Util.h:46
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
void SendEnchantmentLog(uint64 target, uint64 caster, uint64 itemGuid, uint32 itemId, uint32 enchantId, uint32 enchantmentSlot)
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition Main.cpp:41
@ SMSG_ITEM_TIME_UPDATE
Definition Opcodes.h:734
int32 ItemStatValue
uint32 ItemStatType
uint32 Color
int32 SpellCharges
uint32 color
float ClothFactor
float LeatherFactor
float PlateFactor
float MailFactor
float Factor
float Factor
float Factor
float PriceFactor
float WeaponFactor
float ArmorFactor
uint32 enchant_id[MAX_ITEM_ENCHANTMENT_EFFECTS]
uint32 ID
uint32 enchant_id[5]
uint32 prefix[5]
uint32 ID
uint32 item_count
Definition Item.h:22
uint32 setid
Definition Item.h:21
SpellInfo const * spells[8]
Definition Item.h:23
uint32 required_skill_value
uint32 items_to_triggerspell[MAX_ITEM_SET_SPELLS]
uint32 spells[MAX_ITEM_SET_SPELLS]
uint32 required_skill_id
bool IsVellum() const
uint32 GetMaxStackSize() const
bool IsRangedWeapon() const
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
uint32 GemProperties
uint32 ItemLimitCategory
uint32 ScalingStatDistribution
_ItemStat ItemStat[MAX_ITEM_PROTO_STATS]
uint32 MaxDurability
uint32 InventoryType
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]
uint32 itemid
Definition LootMgr.h:120
AllowedLooterSet allowedGUIDs
Definition LootMgr.h:124
bool is_blocked
Definition LootMgr.h:127
bool canSave
Definition LootMgr.h:133
bool needs_quest
Definition LootMgr.h:131
bool follow_loot_rules
Definition LootMgr.h:132
bool is_underthreshold
Definition LootMgr.h:129
int32 randomPropertyId
Definition LootMgr.h:122
uint8 count
Definition LootMgr.h:125
bool freeforall
Definition LootMgr.h:128
uint32 randomSuffix
Definition LootMgr.h:121
bool is_counted
Definition LootMgr.h:130
uint32 GemID