Jump to content

[9280] Working Scrolls of Enchantment


Auntie Mangos

Recommended Posts

  • 40 years later...

At the moment, when you cast a scroll on an item to enchant it, it won't work because you are missing the "reagents" of the enchant, even though it shouldn't require them.

This patch should fix items such as http://www.wowhead.com/?item=38772

(I'm not completely sure this patch is in the correct format, it's based off of multiple commits I made in a fork)

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a170554..08b8c8e 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -19503,7 +19503,7 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons
    return false;
}

-bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const
+bool Player::CanNoReagentCast(SpellEntry const* spellInfo, Item* pItemCaster) const
{
    // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP
    if (spellInfo->AttributesEx5 & SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP &&
@@ -19517,6 +19517,10 @@ bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const
        spellInfo->SpellFamilyFlags2 & noReagentMask_2)
        return true;

+    // Check if it's an enchant scroll. These have no required reagents even though their spell does.
+    if( pItemCaster && pItemCaster->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_ENCHANT_SCROLL) )
+        return true;
+
    return false;
}

diff --git a/src/game/Player.h b/src/game/Player.h
index d32f682..2d6a148 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1207,7 +1207,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
        bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const;
        bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL);
-        bool CanNoReagentCast(SpellEntry const* spellInfo) const;
+        bool CanNoReagentCast(SpellEntry const* spellInfo, Item* pItemCaster = NULL) const;
        bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
        bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
        uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 98b08b9..d794d09 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -3820,7 +3820,7 @@ void Spell::TakeReagents()
        return;

    Player* p_caster = (Player*)m_caster;
-    if (p_caster->CanNoReagentCast(m_spellInfo))
+    if (p_caster->CanNoReagentCast(m_spellInfo, m_CastItem) )
        return;

    for(uint32 x = 0; x < 8; ++x)
@@ -5498,8 +5498,7 @@ SpellCastResult Spell::CheckItems()
    }

    // check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case.
-    bool isScrollItemCasting = (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_ENCHANT_SCROLL);
-    if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo) && !isScrollItemCasting)
+    if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo, m_CastItem) )
    {        
        for(uint32 i = 0; i < 8; ++i)
        {
@@ -5545,7 +5544,7 @@ SpellCastResult Spell::CheckItems()
        }else
        totems -= 1;
    }
-    if(totems != 0)
+    if(totems != 0 && !p_caster->CanNoReagentCast(m_spellInfo, m_CastItem) )
        return SPELL_FAILED_TOTEMS;                         //0x7C

    // Check items for TotemCategory  (items presence in inventory)
@@ -5563,7 +5562,7 @@ SpellCastResult Spell::CheckItems()
        else
            TotemCategory -= 1;
    }
-    if(TotemCategory != 0)
+    if(TotemCategory != 0 && !p_caster->CanNoReagentCast(m_spellInfo, m_CastItem) )
        return SPELL_FAILED_TOTEM_CATEGORY;                 //0x7B

    // special checks for spell effects

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use