Jump to content

[patch] Auras 254/278 disarm shield/ranged


Guest qsa

Recommended Posts

Description of the bug?

Implementing auras :

254 SPELL_AURA_MOD_DISARM_SHIELD

278 SPELL_AURA_MOD_DISARM_RANGED.

For which repository revision was the patch created?

8071

Well, basically title says it all, implementing two disarm related auras used in various spells.

I tried to keep the changes to minimal and use already defined methods.

IsUseEquipedWeapon() had to be used to Unit class ( from Player ), it just more logical place for it.

Some names are little bit misleading since SPELL_AURA_MOD_DISARM_SHIELD also effects off-hand weapons.

The aura flags are taken from some patch I've found on my hdd.

Not sure where it came from or who are the original creators. Thanks guys, guessing those flags is a nasty job :) you made my part so much easier .

commit b623c1b2113e269338fb01a114dc3930a05dce38
Author: sixsixnine <[email protected]>
Date:   Thu Jun 25 18:40:11 2009 +0300

   + Implementing auras : 254 SPELL_AURA_MOD_DISARM_SHIELD and 278 SPELL_AURA_MOD_DISARM_RANGED.
   + Moved IsUseEquipedWeapon() to Unit class. ( should be renamed )

   Signed-off-by: sixsixnine <[email protected]>

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 5f9d114..77477f9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -6683,7 +6683,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
            ApplyFeralAPBonus(feral_bonus, apply);
    }

-    if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))
+    if(!IsUseEquipedWeapon(attType))
        return;

    if (proto->Delay)
@@ -8524,7 +8524,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) cons
    if(!useable)
        return item;

-    if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) )
+    if( item->IsBroken() || !IsUseEquipedWeapon(attackType) )
        return NULL;

    return item;
@@ -8539,7 +8539,7 @@ Item* Player::GetShield(bool useable) const
    if(!useable)
        return item;

-    if( item->IsBroken())
+    if( item->IsBroken() || !IsUseEquipedWeapon(OFF_ATTACK))
        return NULL;

    return item;
diff --git a/src/game/Player.h b/src/game/Player.h
index 5da208a..67849a7 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1117,11 +1117,6 @@ class MANGOS_DLL_SPEC Player : public Unit
        void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
        uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
        uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
-        bool IsUseEquipedWeapon( bool mainhand ) const
-        {
-            // disarm applied only to mainhand weapon
-            return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) );
-        }
        bool IsTwoHandUsed() const
        {
            Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index b27873f..ad677c5 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -306,7 +306,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
    &Aura::HandleNULL,                                      //251 SPELL_AURA_MOD_ENEMY_DODGE
    &Aura::HandleNULL,                                      //252 haste all?
    &Aura::HandleNULL,                                      //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
-    &Aura::HandleNULL,                                      //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
+    &Aura::HandleAuraModDisarm,                             //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield/offhand
    &Aura::HandleNoImmediateEffect,                         //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT    implemented in Unit::SpellDamageBonus
    &Aura::HandleNoReagentUseAura,                          //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
    &Aura::HandleNULL,                                      //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
@@ -330,7 +330,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
    &Aura::HandleNoImmediateEffect,                         //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
    &Aura::HandleNULL,                                      //276 mod damage % mechanic?
    &Aura::HandleNoImmediateEffect,                         //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
-    &Aura::HandleNULL,                                      //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
+    &Aura::HandleAuraModDisarm,                             //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
    &Aura::HandleNULL,                                      //279 visual effects? 58836 and 57507
    &Aura::HandleNULL,                                      //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
    &Aura::HandleNULL,                                      //281 SPELL_AURA_MOD_HONOR_GAIN
@@ -3511,14 +3511,43 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real)
    if(!Real)
        return;

-    if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
+    if(!apply && m_target->HasAuraType(GetModifier()->m_auraname))
        return;

-    // not sure for it's correctness
+    uint32 flags = 0;
+    uint32 field = 0;
+    WeaponAttackType attack_type = BASE_ATTACK;
+    uint32 slot = EQUIPMENT_SLOT_OFFHAND;
+
+    switch (GetModifier()->m_auraname)
+    {
+    case SPELL_AURA_MOD_DISARM:
+        {
+            field = UNIT_FIELD_FLAGS;    
+            flags = UNIT_FLAG_DISARMED;
+            slot = EQUIPMENT_SLOT_MAINHAND;
+        }
+    break;
+    case SPELL_AURA_MOD_DISARM_SHIELD:
+        {
+            field = UNIT_FIELD_FLAGS_2;
+            flags = UNIT_FLAG2_DISARM_OFFHAND;
+            attack_type = OFF_ATTACK;
+        }
+    break;
+    case SPELL_AURA_MOD_DISARM_RANGED:
+        {
+            field = UNIT_FIELD_FLAGS_2;
+            flags = UNIT_FLAG2_DISARM_RANGED;
+            attack_type = OFF_ATTACK;
+        }
+    break;
+    }
+
    if(apply)
-        m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
+        m_target->SetFlag(field, flags);
    else
-        m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
+        m_target->RemoveFlag(field, flags);

    // only at real add/remove aura
    if (m_target->GetTypeId() != TYPEID_PLAYER)
@@ -3529,11 +3558,14 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real)
        return;

    if (apply)
-        m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
+        m_target->SetAttackTime(attack_type, BASE_ATTACK_TIME);
    else
        ((Player *)m_target)->SetRegularAttackTime();

-    m_target->UpdateDamagePhysical(BASE_ATTACK);
+    if(Item *_item = ((Player*)m_target)->GetItemByPos( INVENTORY_SLOT_BAG_0, slot ))
+        ((Player*)m_target)->_ApplyItemMods(_item, slot, !apply);
+
+    m_target->UpdateDamagePhysical(attack_type);
}

void Aura::HandleAuraModStun(bool apply, bool Real)
diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp
index a37627f..cae5dc0 100644
--- a/src/game/StatSystem.cpp
+++ b/src/game/StatSystem.cpp
@@ -430,7 +430,7 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
        weapon_mindamage = lvl*0.85*att_speed;
        weapon_maxdamage = lvl*1.25*att_speed;
    }
-    else if(!IsUseEquipedWeapon(attType==BASE_ATTACK))      //check if player not in form but still can't use weapon (broken/etc)
+    else if(!IsUseEquipedWeapon(attType))      //check if player not in form but still can't use weapon (broken/etc)
    {
        weapon_mindamage = BASE_MINDAMAGE;
        weapon_maxdamage = BASE_MAXDAMAGE;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 636c3ff..31fa896 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -224,6 +224,9 @@ void Unit::Update( uint32 p_time )

bool Unit::haveOffhandWeapon() const
{
+    if (!IsUseEquipedWeapon(OFF_ATTACK))
+        return false;
+
    if(GetTypeId() == TYPEID_PLAYER)
        return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true);
    else
@@ -2918,7 +2921,7 @@ float Unit::GetUnitBlockChance() const
    if(GetTypeId() == TYPEID_PLAYER)
    {
        Player const* player = (Player const*)this;
-        if(player->CanBlock() )
+        if(player->CanBlock() && player->IsUseEquipedWeapon(OFF_ATTACK))
        {
            Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
            if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block)
@@ -11914,7 +11917,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry con
            else
                item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);

-            if (!((Player*)this)->IsUseEquipedWeapon(attType==BASE_ATTACK))
+            if (!IsUseEquipedWeapon(attType))
                return false;

            if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
@@ -11924,7 +11927,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry con
        {
            // Check if player is wearing shield
            Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
-            if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
+            if(!item || item->IsBroken() || !IsUseEquipedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
                return false;
        }
    }
diff --git a/src/game/Unit.h b/src/game/Unit.h
index cbfbde3..04d609b 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -531,6 +531,8 @@ enum UnitFlags2
    UNIT_FLAG2_UNK1             = 0x00000002,               // Hide unit model (show only player equip)
    UNIT_FLAG2_COMPREHEND_LANG  = 0x00000008,
    UNIT_FLAG2_FORCE_MOVE       = 0x00000040,
+    UNIT_FLAG2_DISARM_OFFHAND   = 0x00000080,
+    UNIT_FLAG2_DISARM_RANGED    = 0x00000400,
    UNIT_FLAG2_REGENERATE_POWER = 0x00000800
};

@@ -899,6 +901,24 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
        bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; }
        bool haveOffhandWeapon() const;
+        bool IsUseEquipedWeapon( WeaponAttackType attackType ) const
+        {
+            bool disarmed = false;
+            switch(attackType)
+            {
+                case BASE_ATTACK:
+                    disarmed = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
+                break;
+                case OFF_ATTACK:
+                    disarmed = HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_OFFHAND);
+                break;
+                case RANGED_ATTACK:
+                    disarmed = HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_RANGED);
+                break;
+            }
+
+            return !IsInFeralForm() && !disarmed;
+        }
        bool canReachWithAttack(Unit *pVictim) const;
        uint32 m_extraAttacks;

http://paste2.org/p/284693

Take care.

Link to comment
Share on other sites

  • 5 months later...
  • 4 weeks later...
  • 8 months later...
  • 2 months later...

    if (apply)
       target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
   else
       ((Player *)target)->SetRegularAttackTime();

This part and some other don't must be applied for main weapon only for any cases.

Other look good.

Some names are little bit misleading since SPELL_AURA_MOD_DISARM_SHIELD also effects off-hand weapons.

Agree, for consistence i rename to offhand and add comment related shield.

if(player->CanBlock() && player->IsUseEquipedWeapon(OFF_ATTACK))

this part unclear for me.

CanBlock used also in Player::UpdateBlockPercentage

If at disarm character stats window must show chance 0 then IsUseEquipedWeapon must be moved under CanBlock

with small other changes. I will not touch this in added version, but intresting any info about this case.

With this changes and notes in [10957]. Thank you for prepering and updating patch.

Link to comment
Share on other sites

×
×
  • 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