Jump to content

[11850] Add SELECT_FLAG_NOT_IN_MELEE_RANGE to SelectAttackingTarget


Recommended Posts

Posted

Add one more select flag to SelectAttackingTarget. SELECT_FLAG_NOT_IN_MELEE_RANGE - is used when you want to select ranged targets (which are not in melee range).

diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp

index 8929bf8..4c09923 100644

--- a/src/game/Creature.cpp

+++ b/src/game/Creature.cpp

@@ -2078,6 +2078,9 @@ bool Creature::MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const*

if (selectFlags & SELECT_FLAG_IN_MELEE_RANGE && !CanReachWithMeleeAttack(pTarget))

return false;

+ if (selectFlags & SELECT_FLAG_NOT_IN_MELEE_RANGE && CanReachWithMeleeAttack(pTarget))

+ return false;

+

if (selectFlags & SELECT_FLAG_IN_LOS && !IsWithinLOSInMap(pTarget))

return false;

diff --git a/src/game/Creature.h b/src/game/Creature.h

index 96a4a65..38ecf84 100644

--- a/src/game/Creature.h

+++ b/src/game/Creature.h

@@ -316,13 +316,14 @@ enum AttackingTarget

enum SelectFlags

{

- SELECT_FLAG_IN_LOS = 0x001, // Default Selection Requirement for Spell-targets

- SELECT_FLAG_PLAYER = 0x002,

- SELECT_FLAG_POWER_MANA = 0x004, // For Energy based spells, like manaburn

- SELECT_FLAG_POWER_RAGE = 0x008,

- SELECT_FLAG_POWER_ENERGY = 0x010,

- SELECT_FLAG_POWER_RUNIC = 0x020,

- SELECT_FLAG_IN_MELEE_RANGE = 0x040,

+ SELECT_FLAG_IN_LOS = 0x001, // Default Selection Requirement for Spell-targets

+ SELECT_FLAG_PLAYER = 0x002,

+ SELECT_FLAG_POWER_MANA = 0x004, // For Energy based spells, like manaburn

+ SELECT_FLAG_POWER_RAGE = 0x008,

+ SELECT_FLAG_POWER_ENERGY = 0x010,

+ SELECT_FLAG_POWER_RUNIC = 0x020,

+ SELECT_FLAG_IN_MELEE_RANGE = 0x040,

+ SELECT_FLAG_NOT_IN_MELEE_RANGE = 0x080,

};

// Vendors

P.S.: Btw, tag "[ code ]" is awful...

Posted

How are you going to use ! (not)?

Example:

SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, SPELL, !(SELECT_FLAG_NOT_IN_MELEE_RANGE));

May be I don't understand something, but I think that code, which handle SELECT_FLAG_NOT_IN_MELEE_RANGE -

if (selectFlags & SELECT_FLAG_IN_MELEE_RANGE && !CanReachWithMeleeAttack(pTarget))

return false;

will have no sense.

Posted
nope - zps solution is correct

~SELECT_FLAG_IN_MELEE is something different than SELECT_FLAG_NOT_IN_MELEE

in this case need another definition.

PS probably GoogleTranslate gives a very bad translation:) When I wrote about "at least 1 commit per week," not what I mean:)

Posted

well - this one was pretty clear that would be added fast - zps researched a strong case where he needed it - and the code is very clear.

It is just annoying to have simple and reasonable patches waiting for a long time.

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