Ru-MaNGOS

Ru-MaNGOS (http://mangos.ytdb.ru/index.php)
-   Патчи на рассмотрении (http://mangos.ytdb.ru/forumdisplay.php?f=49)
-   -   [patch] Check cast spells Disarm. (http://mangos.ytdb.ru/showthread.php?t=6333)

Den 13.10.2012 20:41

[patch] Check cast spells Disarm.
 
У близав нельзя обезоруживать цель, если она не вооружена, роговским и варовским дисармом, это 100%.

Хорошо бы проверить http://www.wowhead.com/spell=64058 и узнать, вешается дисарм на цель без оружия. Таких заклинаний еще два или три есть, которые срвзу выполняют какое-то действие, а потом вешают дисарм. С остальными понятно, из списка их выбрать и тоже проверять.

Код:

diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index d079a72..7806d66 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1392,6 +1392,13 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
        SetVirtualItem(VirtualItemSlot(i), einfo->equipentry[i]);
 }
 
+bool Creature::IsEquipmentWeapon()
+{
+    CreatureInfo const* creatureInfo = GetCreatureInfo();
+
+    return creatureInfo->equipmentId;
+}
+
 bool Creature::HasQuest(uint32 quest_id) const
 {
    QuestRelationsMapBounds bounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(GetEntry());
diff --git a/src/game/Creature.h b/src/game/Creature.h
index c2e99f9..8edc66c 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -484,6 +484,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
        void GetRespawnCoord(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
        uint32 GetEquipmentId() const { return m_equipmentId; }
 
+        virtual bool IsEquipmentWeapon();
+
        CreatureSubtype GetSubtype() const { return m_subtype; }
        bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
        bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 9bdcc79..a63d570 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -11471,6 +11471,18 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
    return pItem;
 }
 
+bool Player::IsEquipmentWeapon()
+{
+    if (GetTypeId() != TYPEID_PLAYER)
+        return false;
+
+    Item* mainHandWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
+    Item* offHandWeapon  = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
+    Item* rangedWeapon  = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED);
+
+    return mainHandWeapon || offHandWeapon || rangedWeapon;
+}
+
 void Player::QuickEquipItem(uint16 pos, Item* pItem)
 {
    if (pItem)
diff --git a/src/game/Player.h b/src/game/Player.h
index 8590d88..7b91b3f 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1263,6 +1263,9 @@ class MANGOS_DLL_SPEC Player : public Unit
            Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
            return offItem && ((mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) || offItem->GetProto()->InventoryType == INVTYPE_2HWEAPON);
        }
+
+        virtual bool IsEquipmentWeapon();
+
        void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false);
        bool BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
 
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 913f942..0c91b6a 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4985,6 +4985,14 @@ SpellCastResult Spell::CheckCast(bool strict)
                return SPELL_FAILED_CASTER_AURASTATE;
        }
 
+        // Disarm
+        if (m_spellInfo->IsFitToFamily(SPELLFAMILY_WARRIOR, UI64LIT(0x0000000000000200)) ||
+            m_spellInfo->IsFitToFamily(SPELLFAMILY_ROGUE, UI64LIT(0x0010000000000000)))
+        {
+            if (!((Player*)target)->IsEquipmentWeapon() || !((Creature*)target)->IsEquipmentWeapon())
+                return SPELL_FAILED_TARGET_NO_WEAPONS;
+        }
+
        // totem immunity for channeled spells(needs to be before spell cast)
        // spell attribs for player channeled spells
        if (m_spellInfo->HasAttribute(SPELL_ATTR_EX_UNK14)
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 2d3305c..960b8fd 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1118,6 +1118,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; }
        bool haveOffhandWeapon() const;
        bool UpdateMeleeAttackingState();
+
+        virtual bool IsEquipmentWeapon() { return true; }
+
        bool CanUseEquippedWeapon(WeaponAttackType attackType) const
        {
            if (IsInFeralForm())


Amaru 15.10.2012 09:38

http://www.wowhead.com/spell=64058 должен вешаться на цель без оружия

нужно не просто проверять, если ли любое оружие, а надо проверять в зависимости от ауры дизарма
мейн хенд дизарм - проверять мейн хенд, офф хенд дизарм - проверять оффхенд и тп


Текущее время: 17:52. Часовой пояс GMT +3.

ru-mangos.ru - Русское сообщество MaNGOS