Jump to content

[Patch] Prefere Melee targets


Auntie Mangos

Recommended Posts

  • 41 years later...

What does the patch do?:

The patch adds a bool to the "Unit" class, which allows you to say if the boss should prefere melee targets or not.

The core doesn´t support standing bosses very well (the only way was to modify the aggro in the SD2 scripts).

I decided to make it not static for bosses which can´t move, because sometimes bosses (like alar) stand still (plattforme phase) and later they move around (second phase).

Who wrote this patch?:

me

For which rev is it?:

s1009

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index a914c0d..54b61cc 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -255,6 +255,8 @@ Unit::Unit()
    // remove aurastates allowing special moves
    for(int i=0; i < MAX_REACTIVE; ++i)
        m_reactiveTimer[i] = 0;
+
+    m_bPrefereMeleeTargets = false;
}

Unit::~Unit()
@@ -7670,6 +7672,27 @@ bool Unit::SelectHostileTarget()
            }while (aura != tauntAuras.begin());
        }
    }
+    
+    //get the melee target with most thread
+    if (m_bPrefereMeleeTargets)
+    {
+        ThreatList const& tList = m_ThreatManager.getThreatList();
+        uint32 UnitThread = 0;
+        if (!tList.empty())
+        {
+            for (ThreatList::const_iterator i = tList.begin(); i != tList.end(); ++i)
+            {
+                uint64 uiGuid = (*i)->getUnitGuid();
+                //If we are within range melee the target
+                Unit *pUnit = GetMap()->GetPlayer(uiGuid);
+                if (pUnit && pUnit->GetTypeId() == TYPEID_PLAYER && IsWithinDistInMap(pUnit, ATTACK_DISTANCE) && (*i)->getThreat() > UnitThread)
+                {
+                    UnitThread = (*i)->getThreat();
+                    target = pUnit;
+                }
+            }
+        }
+    }

    // No taunt aura or taunt aura caster is dead, standard target selection
    if (!target && !m_ThreatManager.isThreatListEmpty())
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 6ac79c4..890d0b2 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1779,6 +1779,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        void AddPetAura(PetAura const* petSpell);
        void RemovePetAura(PetAura const* petSpell);

+        //target selections
+        void SetPrefereMeleeTargets(bool bPrefere = true) { m_bPrefereMeleeTargets = bPrefere; }
+
    protected:
        explicit Unit ();

@@ -1857,6 +1860,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject

        uint64 m_TotemSlot[MAX_TOTEM_SLOT];

+        bool m_bPrefereMeleeTargets;
+
    private:                                                // Error traps for some wrong args using
        // this will catch and prevent build for any cases when all optional args skipped and instead triggered used non boolean type
        // no bodies expected for this declarations

Link to comment
Share on other sites

Why should a unit get aggro from the mob, when he is out of range? Range Targets CAN NOT get aggro (but taunt aura applys). In my oppinion it doesn´make sense.

Also I told you some points why I wont do it generel for non movement mobs. The manual change give you much more controle over your mob.

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