Jump to content

[fix] Vellums


Auntie Mangos

Recommended Posts

"2"

- This patch would implement that enchanting vellums and the resulting items.

"2"

- 7812

"2"

- http://getmangos.eu/community/viewtopic.php?id=6201

diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 2d25b7f..f4acf34 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -740,6 +740,10 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
{
    ItemPrototype const* proto = GetProto();

+    if(spellInfo->Effect[0] == SPELL_EFFECT_ENCHANT_ITEM && ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && IsArmorVellum()) ||
+      (spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && IsWeaponVellum())))
+        return true;
+
    if (spellInfo->EquippedItemClass != -1)                 // -1 == any item class
    {
        if(spellInfo->EquippedItemClass != int32(proto->Class))
diff --git a/src/game/Item.h b/src/game/Item.h
index 2f7376a..e0694e6 100644
--- a/src/game/Item.h
+++ b/src/game/Item.h
@@ -221,6 +221,8 @@ class MANGOS_DLL_SPEC Item : public Object
        void DeleteFromInventoryDB();

        bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; }
+        bool IsArmorVellum() const { return (GetProto()->Class == ITEM_CLASS_TRADE_GOODS && GetProto()->SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT); }
+        bool IsWeaponVellum() const { return (GetProto()->Class == ITEM_CLASS_TRADE_GOODS && GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT); }
        bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
        bool CanBeTraded() const;
        void SetInTrade(bool b = true) { mb_in_trade = b; }
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 648552d..12448bf 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -3587,6 +3587,18 @@ void Spell::TakeReagents()
    if (p_caster->CanNoReagentCast(m_spellInfo))
        return;

+    if(m_CastItem)
+    {
+        for(int i=0; i<3; ++i)
+        {
+            if(m_spellInfo->EffectItemType[i] == m_CastItem->GetEntry())
+            {
+                p_caster->DestroyItemCount(m_CastItem->GetEntry(), 1, true);
+                return;
+            }
+        }
+    }
+
    for(uint32 x=0;x<8;x++)
    {
        if(m_spellInfo->Reagent[x] <= 0)
@@ -4397,6 +4409,23 @@ SpellCastResult Spell::CheckCast(bool strict)
                    return SPELL_FAILED_BAD_TARGETS;
                break;
            }
+            case SPELL_EFFECT_ENCHANT_ITEM:
+            {
+                if(m_spellInfo->EffectItemType[i] && m_targets.getItemTarget())
+                {
+                    if(m_targets.getItemTarget()->IsWeaponVellum() || m_targets.getItemTarget()->IsArmorVellum())
+                    {
+                         ItemPosCountVec dest;
+                         uint8 msg = ((Player*)m_caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
+                         if(msg != EQUIP_ERR_OK)
+                         {
+                            ((Player*)m_caster)->SendEquipError( msg, NULL, NULL );
+                            return SPELL_FAILED_DONT_REPORT;
+                         }
+                    }
+                }
+                break;
+            }
            default:break;
        }
    }
@@ -4866,11 +4895,13 @@ SpellCastResult Spell::CheckItems()

    Player* p_caster = (Player*)m_caster;

+    bool isNoReagentReqCast = m_CastItem ? m_CastItem->GetEntry() == m_spellInfo->EffectItemType[0] : false;
+
    // cast item checks
    if(m_CastItem)
    {
        uint32 itemid = m_CastItem->GetEntry();
-        if( !p_caster->HasItemCount(itemid,1) )
+        if( !p_caster->HasItemCount(itemid,1) && !isNoReagentReqCast)
            return SPELL_FAILED_ITEM_NOT_READY;

        ItemPrototype const *proto = m_CastItem->GetProto();
@@ -4943,7 +4974,7 @@ SpellCastResult Spell::CheckItems()
        if(!m_targets.getItemTarget())
            return SPELL_FAILED_ITEM_GONE;

-        if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo))
+        if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo) && !isNoReagentReqCast)
            return SPELL_FAILED_EQUIPPED_ITEM_CLASS;
    }
    // if not item target then required item must be equipped
@@ -4975,7 +5006,7 @@ SpellCastResult Spell::CheckItems()
    }

    // check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case.
-    if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo))
+    if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo) && !isNoReagentReqCast)
    {
        for(uint32 i=0;i<8;++i)
        {
@@ -5039,7 +5070,7 @@ SpellCastResult Spell::CheckItems()
        else
            TotemCategory -= 1;
    }
-    if(TotemCategory != 0)
+    if(TotemCategory != 0 && !isNoReagentReqCast)
        return SPELL_FAILED_TOTEM_CATEGORY;                 //0x7B

    // special checks for spell effects
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 10ab438..a5337a6 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -3804,6 +3804,19 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
    if(!pEnchant)
        return;

+    ItemPrototype const* targetProto = itemTarget->GetProto();
+    // EffectItemType serves as the entry of the item to be created.
+    if(m_spellInfo->EffectItemType[effect_idx])
+    {
+        if((m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && itemTarget->IsArmorVellum()) ||
+           (m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && itemTarget->IsWeaponVellum()))
+        {
+             unitTarget = m_caster;
+             DoCreateItem(effect_idx,m_spellInfo->EffectItemType[effect_idx]);
+             return;
+        }
+    }
+    
    // item can be in trade slot and have owner diff. from caster
    Player* item_owner = itemTarget->GetOwner();
    if(!item_owner)
@@ -6579,4 +6592,4 @@ void Spell::EffectRenamePet(uint32 /*eff_idx*/)
        return;

    unitTarget->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_ALLOWED);
-}
\\ No newline at end of file
+}

Patchfile

The patch looks really hacky. It was posted here to get more _constructive_ suggestions.

Link to comment
Share on other sites

  • 39 years later...
  • Replies 125
  • Created
  • Last Reply

Top Posters In This Topic

I missed that, it says that to me too. If you do a .save the logs says:

::_SaveInventory - the bag(255) and slot(255) values for the item with guid 9070 are incorrect, the player doesn't have an item at that position!

Is this a DB or patch problem you think? My flags seem correct to me.. Also, it shouldn't be a cache problem because mangos itself complaints. On a last note, when you logout/login you lose the enchant on the item and re-gain the scroll.

Link to comment
Share on other sites

When i use a scroll, that created from vellum, and logout, i've get a errors in console

GameEvent 34 "L70ETC Concert" removed.
Player(GUID: 12 Name: Pristyag)::_SaveInventory - the bag(255) and slot(255) val
ues for the item with guid 302 are incorrect, the player doesn't have an item at
that position!
Player::_SaveInventory - one or more errors occurred save aborted!

and sometimes (if player equip item, enchanted from that scroll) server crashes

Revision: * * 7859 68c9688307709667d5bcb94b2eb3021ce9f4b789
Date 21:5:2009. Time 0:2 
//=====================================================
*** Hardware ***
Processor: Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
Number Of Processors: 2
Physical Memory: 4192460 KB (Available: 1795428 KB)
Commit Charge Limit: 4194303 KB

*** Operation System ***
Microsoft Windows Server 2003 Professional Service Pack 2 (Version 5.2, Build 3790)

//=====================================================
Exception code: C0000005 ACCESS_VIOLATION
Fault address:  004010B9 01:000000B9 C:\\EmulatorX\\wotlk\\mangosd.exe

Registers:
EAX:3CFF8200
EBX:1A9C0820
ECX:3CFF8200
EDX:00000000
ESI:00000000
EDI:00922A40
CS:EIP:0023:004010B9
SS:ESP:002B:06A7F3A4  EBP:06A7F3B8
DS:002B  ES:002B  FS:0053  GS:002B
Flags:00010293

Call stack:
Address   Frame     Function      SourceFile
004010B9  00000000  Object::GetGUIDLow+19
0050484E  00000000  Player::_SaveInventory+2EE
00503C61  00000000  Player::SaveToDB+1081
00613500  00000000  WorldSession::LogoutPlayer+A10
008E4DF6  00000000  WorldSession::HandleLogoutRequestOpcode+286
0061283C  00000000  WorldSession::Update+18C
0063D86B  00000000  World::UpdateSessions+11B
0063992A  00000000  World::Update+36A
004385CE  00000000  WorldRunnable::run+8E
00922A57  00000000  ACE_Based::Thread::ThreadTask+17
100514D4  00000000  ?invoke@ACE_OS_Thread_Adapter@@UAEKXZ+74
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7D4DFE21  00000000  FlsSetValue+136

Call stack:
Address   Frame     Function      SourceFile
7D61C828  00000000  ZwWaitForSingleObject+15
7D4D8BF1  00000000  WaitForSingleObject+12

Call stack:
Address   Frame     Function      SourceFile
7D61CCA8  00000000  ZwDelayExecution+15
7D4D14EF  00000000  Sleep+F
00922C30  00000000  ACE_Based::Thread::Sleep+30
0092A8B0  00000000  SqlDelayThread::run+20
00922A57  00000000  ACE_Based::Thread::ThreadTask+17
100514D4  00000000  ?invoke@ACE_OS_Thread_Adapter@@UAEKXZ+74
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7D4DFE21  00000000  FlsSetValue+136

Call stack:
Address   Frame     Function      SourceFile
7D61CCA8  00000000  ZwDelayExecution+15
7D4D14EF  00000000  Sleep+F
00922C30  00000000  ACE_Based::Thread::Sleep+30
0092A8B0  00000000  SqlDelayThread::run+20
00922A57  00000000  ACE_Based::Thread::ThreadTask+17
100514D4  00000000  ?invoke@ACE_OS_Thread_Adapter@@UAEKXZ+74
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7D4DFE21  00000000  FlsSetValue+136

Call stack:
Address   Frame     Function      SourceFile
7D61CCA8  00000000  ZwDelayExecution+15
7D4D14EF  00000000  Sleep+F
00922C30  00000000  ACE_Based::Thread::Sleep+30
0092A8B0  00000000  SqlDelayThread::run+20
00922A57  00000000  ACE_Based::Thread::ThreadTask+17
100514D4  00000000  ?invoke@ACE_OS_Thread_Adapter@@UAEKXZ+74
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7D4DFE21  00000000  FlsSetValue+136

Call stack:
Address   Frame     Function      SourceFile
7D61D6C6  00000000  ZwGetContextThread+12
06A7E3A8  00000000  0000:00000000 
FF50D845  FFFFFFFF  

Link to comment
Share on other sites

Don't use this part because if you use a scroll, the scroll is delete 2 times instead of once and so if you have only one scroll in your bag this causes error or crash.

diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 648552d..12448bf 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -3587,6 +3587,18 @@ void Spell::TakeReagents()
    if (p_caster->CanNoReagentCast(m_spellInfo))
        return;

+    if(m_CastItem)
+    {
+        for(int i=0; i<3; ++i)
+        {
+            if(m_spellInfo->EffectItemType[i] == m_CastItem->GetEntry())
+            {
+                p_caster->DestroyItemCount(m_CastItem->GetEntry(), 1, true);
+                return;
+            }
+        }
+    }
+
    for(uint32 x=0;x<8;x++)
    {
        if(m_spellInfo->Reagent[x] <= 0)

with this part

Before-------------------->After

before.png ---use scroll-->after1.png

without this part

Before-------------------->After

before.png ---use scroll-->after2.png

Link to comment
Share on other sites

Titanguard (+75 STA) was removed before or at 3.0.8

I forget if it actually made it to live servers

Sorry, you linked the +50 sta one not the 75..

EDIT: Looks like it started at 75, got nuked down to 50...and still never made it to live servers.

Great Patch BTW.

Link to comment
Share on other sites

  • 1 month later...

That patch have one exploit, you can cheat with item changing with ArtMoney program. For example if you want to enchant Mongoose to Helm you can change some values in memory with artmoney for using it on any item ID that you set as new value.

I know my english is bad, if you can't understand me you can read original bugreport, it is here http://getmangos.ru/forum/showpost.php?p=275177&postcount=8 but you need 250 post to read it xD . Maybe author of patch should ask to Wowka321 with "how to reproduce"

Link to comment
Share on other sites

Sounds pretty nice... I'm sorry for lating this much but i cannot compile a new version of mangos for a while now. Anyways, probably this should solve this nice cheat...

From d20622dc9cb298eca1ca3bcdf601025764612dae Mon Sep 17 00:00:00 2001
From: Lightguard <[email="[email protected]"][email protected][/email]>
Date: Sat, 11 Jul 2009 09:09:32 +0200
Subject: [PATCH] - Make our beloved cheaters happy
---
src/game/Spell.cpp |   10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 4cd2aaf..603e6cb 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4360,6 +4360,16 @@ SpellCastResult Spell::CheckCast(bool strict)
                    return SPELL_FAILED_BAD_TARGETS;
                break;
            }
+            case SPELL_EFFECT_ENCHANT_ITEM:
+            {
+                if(Item* targetItem = m_targets.getItemTarget())
+                {
+                    if(targetItem->GetProto()->Class != m_spellInfo->EquippedItemClass ||
+                       ((1<<targetItem->GetProto()->SubClass) & m_spellInfo->EquippedItemSubClassMask)==0)
+                       return SPELL_FAILED_BAD_TARGETS;
+                }
+                break;
+            }
            default:break;
        }
    }
-- 
1.6.3.2.1299.gee46c


I couldn't test it, so please be careful, but it should solve the problem mentioned now also here and on mangos.ru. Hopefully.

::Edit::

I hope it covers the part on mangos.ru too (for some reaason i have only 2 posts so i couldn't read it:D)

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