diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 6743ffe80..0d9b47a9d 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -1273,7 +1273,7 @@ void LoadLootTemplates_Spell() continue; // possible cases - if(!IsExplicitDiscoverySpell (spellInfo)) + if( !IsLootCraftingSpell(spellInfo)) continue; if(!ids_set.count(spell_id)) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index aeaf1c838..720fec4b0 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -19413,7 +19413,7 @@ void Player::InitRunes() SetFloatValue(PLAYER_RUNE_REGEN_1 + i, 0.1f); } -void Player::AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store) +bool Player::AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store) { Loot loot; loot.FillLoot (loot_id,store,this); @@ -19430,7 +19430,8 @@ void Player::AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore if(msg != EQUIP_ERR_OK) return; - StoreNewItem (dest,lootItem->itemid,true,lootItem->randomPropertyId); + if(Item* pItem = StoreNewItem (dest,lootItem->itemid,true,lootItem->randomPropertyId)) + SendNewItem(pItem, lootItem->count, true, true); } uint32 Player::CalculateTalentsPoints() const diff --git a/src/game/Player.h b/src/game/Player.h index 25def0730..67b45e0ea 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1110,8 +1110,8 @@ class MANGOS_DLL_SPEC Player : public Unit Item* EquipItem( uint16 pos, Item *pItem, bool update ); void AutoUnequipOffhandIfNeed(); bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count); - void AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store); - void AutoStoreLootItem(uint32 loot_id, LootStore const& store) { AutoStoreLootItem(NULL_BAG,NULL_SLOT,loot_id,store); } + bool AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store); + bool AutoStoreLootItem(uint32 loot_id, LootStore const& store) { return AutoStoreLootItem(NULL_BAG,NULL_SLOT,loot_id,store); } uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const; diff --git a/src/game/Spell.h b/src/game/Spell.h index f858f2ad3..620d2c6a4 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -231,6 +231,7 @@ class Spell void EffectHealthLeech(uint32 i); void EffectQuestComplete(uint32 i); void EffectCreateItem(uint32 i); + void EffectCreateItem2(uint32 i); void EffectPersistentAA(uint32 i); void EffectEnergize(uint32 i); void EffectOpenLock(uint32 i); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index ca84744bf..2ba511802 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -215,7 +215,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectNULL, //154 unused &Spell::EffectTitanGrip, //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal. &Spell::EffectEnchantItemPrismatic, //156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC - &Spell::EffectCreateItem, //157 SPELL_EFFECT_CREATE_ITEM_2 create/learn item/spell for profession + &Spell::EffectCreateItem2, //157 SPELL_EFFECT_CREATE_ITEM_2 create/learn item/spell for profession &Spell::EffectMilling, //158 SPELL_EFFECT_MILLING milling &Spell::EffectRenamePet //159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again }; @@ -2682,6 +2682,22 @@ void Spell::EffectCreateItem(uint32 i) DoCreateItem(i,m_spellInfo->EffectItemType[i]); } +void Spell::EffectCreateItem2(uint32 i) +{ + // special case: generate using spell_loot_template + if(!m_spellInfo->EffectItemType[i]) + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + // create some random items + if(!((Player*)m_caster)->AutoStoreLootItem(m_spellInfo->Id,LootTemplates_Spell)) + player->SendEquipError( msg, NULL, NULL ); + return; + } + DoCreateItem(i,m_spellInfo->EffectItemType[i]); +} + void Spell::EffectPersistentAA(uint32 i) { float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 08557df2b..7a6c72437 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -317,6 +317,12 @@ inline bool IsExplicitDiscoverySpell(SpellEntry const *spellInfo) return spellInfo->Effect[0]==SPELL_EFFECT_CREATE_ITEM_2 && spellInfo->Effect[1]==SPELL_EFFECT_SCRIPT_EFFECT; } +inline bool IsLootCraftingSpell(SpellEntry const *spellInfo) +{ + return spellInfo->Effect[0]==SPELL_EFFECT_CREATE_ITEM_2 && + (spellInfo->Effect[1]==SPELL_EFFECT_SCRIPT_EFFECT || !spellInfo->EffectItemType[0]); +} + int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); bool IsPassiveSpell(uint32 spellId);