aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
authorWyrserth <43747507+Wyrserth@users.noreply.github.com>2019-06-15 15:11:49 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-11 13:29:39 +0100
commit59da957165ef7d7529db30f90a30dc401d682052 (patch)
treedd9985c6f699edae30b123e7b965e43db1cd229c /src/server/game/Spells/SpellEffects.cpp
parent264373bb656352a0cdf9b18bad4f3929c7376a9c (diff)
Core/Spells: don't allow spells with SPELL_EFFECT_CREATE_LOOT to be cast if there isn't enough space in inventory (#23404)
* Core/Spells: don't allow spells with SPELL_EFFECT_CREATE_LOOT to be cast if there isn't enough space in inventory, * Move GetFreeInventorySpace() to a better place, thanks ccrs! (cherry picked from commit 218055280af4563f28643e2683eafe40808f90db)
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index a7bd4d21cb5..d5f4cac251d 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1437,32 +1437,22 @@ void Spell::EffectCreateItem2()
Player* player = unitTarget->ToPlayer();
- uint32 item_id = effectInfo->ItemType;
ItemContext context = m_spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) ? ItemContext::Trade_Skill : ItemContext::NONE;
- if (item_id)
- DoCreateItem(item_id, context);
-
- // special case: fake item replaced by generate using spell_loot_template
+ // Pick a random item from spell_loot_template
if (m_spellInfo->IsLootCrafting())
{
- if (item_id)
- {
- if (!player->HasItemCount(item_id))
- return;
-
- // remove reagent
- uint32 count = 1;
- player->DestroyItemCount(item_id, count, true);
-
- // create some random items
- player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell, context);
- }
- else
- player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell, context); // create some random items
-
+ player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell, context, false, true);
player->UpdateCraftSkill(m_spellInfo->Id);
}
+ else // If there's no random loot entries for this spell, pick the item associated with this spell
+ {
+ uint32 item_id = effectInfo->ItemType;
+
+ if (item_id)
+ DoCreateItem(item_id, context);
+ }
+
/// @todo ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType);
}