[11203] Implement creating scrolls when enchanting vellum.

Thanks to Lightguard and timmons for original contribution.
This commit is contained in:
Lynx3d 2011-02-24 01:23:08 +01:00
parent fcc09483ad
commit 44fd108745
5 changed files with 60 additions and 6 deletions

View file

@ -5018,11 +5018,6 @@ void Spell::EffectEnchantItemPerm(SpellEffectIndex eff_idx)
if (!itemTarget)
return;
Player* p_caster = (Player*)m_caster;
// not grow at item use at item case
p_caster->UpdateCraftSkill(m_spellInfo->Id);
uint32 enchant_id = m_spellInfo->EffectMiscValue[eff_idx];
if (!enchant_id)
return;
@ -5036,6 +5031,25 @@ void Spell::EffectEnchantItemPerm(SpellEffectIndex eff_idx)
if (!item_owner)
return;
Player* p_caster = (Player*)m_caster;
// Enchanting a vellum requires special handling, as it creates a new item
// instead of modifying an existing one.
ItemPrototype const* targetProto = itemTarget->GetProto();
if (targetProto->IsVellum() && m_spellInfo->EffectItemType[eff_idx])
{
unitTarget = m_caster;
DoCreateItem(eff_idx,m_spellInfo->EffectItemType[eff_idx]);
// Vellum target case: Target becomes additional reagent, new scroll item created instead in Spell::EffectEnchantItemPerm()
// cannot already delete in TakeReagents() unfortunately
p_caster->DestroyItemCount(targetProto->ItemId, 1, true);
return;
}
// Using enchant stored on scroll does not increase enchanting skill! (Already granted on scroll creation)
if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAG_ENCHANT_SCROLL))
p_caster->UpdateCraftSkill(m_spellInfo->Id);
if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) )
{
sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",