diff options
| author | Shauren <shauren.trinity@gmail.com> | 2021-10-10 19:12:17 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-10-10 19:12:17 +0200 |
| commit | 8492c273dd50227ca01ead785eda6c4de9361e74 (patch) | |
| tree | 32ee09dc18c37d9ec4e867e3dd69b27b1cee5253 /src/server/game/Spells/Spell.cpp | |
| parent | 8147a42aefb5c94fb70205141e611d3100cbd99d (diff) | |
Core/Spells: Implemented SpellReagentsCurrency.db2
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index bb1ab3c7333..dac726f2c56 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4152,7 +4152,6 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons packet.FailedArg1 = *param1; else { - uint32 missingItem = 0; for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++) { if (spellInfo->Reagent[i] <= 0) @@ -4163,12 +4162,27 @@ inline void FillSpellCastFailedArgs(T& packet, ObjectGuid castId, SpellInfo cons if (!caster->HasItemCount(itemid, itemcount)) { - missingItem = itemid; + packet.FailedArg1 = itemid; // first missing item break; } } - packet.FailedArg1 = missingItem; // first missing item } + + if (param2) + packet.FailedArg2 = *param2; + else if (!param1) + { + for (SpellReagentsCurrencyEntry const* reagentsCurrency : spellInfo->ReagentsCurrency) + { + if (!caster->HasCurrency(reagentsCurrency->CurrencyTypesID, reagentsCurrency->CurrencyCount)) + { + packet.FailedArg1 = -1; + packet.FailedArg2 = reagentsCurrency->CurrencyTypesID; + break; + } + } + } + break; } case SPELL_FAILED_CANT_UNTALENT: @@ -5019,6 +5033,9 @@ void Spell::TakeReagents() p_caster->DestroyItemCount(itemid, itemcount, true); } + + for (SpellReagentsCurrencyEntry const* reagentsCurrency : m_spellInfo->ReagentsCurrency) + p_caster->ModifyCurrency(reagentsCurrency->CurrencyTypesID, -int32(reagentsCurrency->CurrencyCount), false, true); } void Spell::HandleThreatSpells() @@ -6753,6 +6770,20 @@ SpellCastResult Spell::CheckItems(int32* param1 /*= nullptr*/, int32* param2 /*= return SPELL_FAILED_REAGENTS; } } + + for (SpellReagentsCurrencyEntry const* reagentsCurrency : m_spellInfo->ReagentsCurrency) + { + if (!player->HasCurrency(reagentsCurrency->CurrencyTypesID, reagentsCurrency->CurrencyCount)) + { + if (param1) + *param1 = -1; + + if (param2) + *param2 = reagentsCurrency->CurrencyTypesID; + + return SPELL_FAILED_REAGENTS; + } + } } // check totem-item requirements (items presence in inventory) |
