Jump to content

[fix]weapon enchantment procs


Auntie Mangos

Recommended Posts

What bug does the patch fix? What features does the patch add?

fixes weapon enchantment procs from weapon based spells (like mutilate)

For which repository revision was the patch created?

9362

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

http://getmangos.eu/community/showthread.php?11743-%5BBUG%5D-Mutilate

http://getmangos.eu/community/showthread.php?11761-%5BBUG%5D-%5B9061%5D-Rogue-Poisons

Who has been writing this patch? Please include either forum user names or email addresses.

me, thx to maly32167 for deadloop fix

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 7ba9448..4a46c7f 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -1297,6 +1297,29 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
    // Call default DealDamage (send critical in hit info for threat calculation)
    CleanDamage cleanDamage(damageInfo->cleanDamage, BASE_ATTACK, damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT ? MELEE_HIT_CRIT : MELEE_HIT_NORMAL);
    DealDamage(pVictim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss);
+
+    // Check if effect can trigger anything actually (is this a right ATTR ?)
+    if( spellProto->AttributesEx3 & SPELL_ATTR_EX3_UNK16 )
+        return;
+
+    bool hasWeaponDmgEffect = false;
+
+    for (uint32 i = 0; i < 3; ++i)
+    {
+        if (spellProto->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || spellProto->Effect[i] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || spellProto->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE || spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
+        {    
+            hasWeaponDmgEffect = true;
+            break;
+        }
+    }
+
+    if (!(damageInfo->HitInfo & HITINFO_MISS) && hasWeaponDmgEffect) 
+    {
+        WeaponAttackType attType = GetWeaponAttackType(spellProto);
+        // on weapon hit casts
+        if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive())
+            ((Player*)this)->CastItemCombatSpell(pVictim, attType);
+    }
}

//TODO for melee need create structure as in

haven't found a better way to check for Effect Weapon Dmg -_-, attribs won't work cause spells like "envenom" have them, and dmg class is too wide

Link to comment
Share on other sites

  • 40 years later...

Hy guys,

I am still learning the guts of Mangos, but the iteration, why does it use ++i? Doesn't it pre-crement, ignoring 0, taking into consideration only 1st and 2nd positions of the array? Or the array spellProto->Effect[] has the 0 position null?

Thanks and i am waiting for a reply,

DFT

Link to comment
Share on other sites

Hy guys,

I am still learning the guts of Mangos, but the iteration, why does it use ++i? Doesn't it pre-crement, ignoring 0, taking into consideration only 1st and 2nd positions of the array? Or the array spellProto->Effect[] has the 0 position null?

Thanks and i am waiting for a reply,

DFT

no, if you do i++ or ++i doesn't matter in a for(), only in java they have that weird shit that this changes the for()...

the diff is, that with i++, you've to create a copy of i, increment the original i and then return the copy of i in order to get the original number, and with ++i you just increment i and then return it :)

Link to comment
Share on other sites

It is really unsafe to check only these effects... i mean, it causes proc things on spells triggered from random things like Unfair Advantage dodge-proc

Also causes (deadly)deadloop :P from enchants that have effects specified here

if (spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || spellProto->Effect == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE || spellProto->Effect == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)

So for example http://www.wowhead.com/?spell=50401 procced by Rune of Razorice, as effect is SPELL_EFFECT_WEAPON_PERCENT_DAMAGE it procs DealSpellDamage and then again CastItemCombatSpell for itself, and here we go, a nice deadloop ready

Link to comment
Share on other sites

I checked all spells that cause deadloop (enchant has same effect triggered to trigger DealSpellDamage again)

it seems to make the thing, its unknown attr but seems its set for all spells that shouldnt trigger anything other than what they have in SpellEffect

// Check if effect can trigger anything actually (is this a right ATTR ?)
   if( spellProto->AttributesEx3 & SPELL_ATTR_EX3_UNK16 )
       hasWeaponDmgEffect = false;

Link to comment
Share on other sites

I am using it for a bit of time already with dead-lock fix i posted up there, seems to work ok, rogues are happy so, its fine

if you could post it with the fix you made i would be really gratefull cause i dont know where to add the check you posted, or you could tell me in what part of the code is it suposed to be.

is it inside

if (spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || spellProto->Effect == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE || spellProto->Effect == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) ???????????

Link to comment
Share on other sites

if you could post it with the fix you made i would be really gratefull cause i dont know where to add the check you posted, or you could tell me in what part of the code is it suposed to be.

is it inside

if (spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || spellProto->Effect == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || spellProto->Effect == SPELL_EFFECT_WEAPON_DAMAGE || spellProto->Effect == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) ???????????

maybe it is after the loop

+    bool hasWeaponDmgEffect = false;
+    for (uint32 i = 0; i < 3; ++i)
+    {
+        if (spellProto->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || spellProto->Effect[i] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || spellProto->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE || spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
+        {    
+            hasWeaponDmgEffect = true;
+            break;
+        }
+    }
+// Check if effect can trigger anything actually (is this a right ATTR ?)
+    if( spellProto->AttributesEx3 & SPELL_ATTR_EX3_UNK16 )
+        hasWeaponDmgEffect = false;
+    if (!(damageInfo->HitInfo & HITINFO_MISS) && hasWeaponDmgEffect) 
+    {
+        WeaponAttackType attType = GetWeaponAttackType(spellProto);
+        // on weapon hit casts
+        if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive())
+            ((Player*)this)->CastItemCombatSpell(pVictim, attType);
+    }

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
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