Targeting functions - allfoxwy/UnitXP_SP3 GitHub Wiki
This mod adds a few targeting functions to help you have a better TAB key.
Currently when continuously trigger these functions, you may experience a small lag between switching target. I believe this is because game needs a server communication to obtain Target of Target information. I wish I could find a better way in future.
Functions could be accessed via Key Bindings menu, or via macro.
Nearest targeting
/script UnitXP("target", "nearestEnemy");
Return TRUE when found a target.
Target nearest enemy. It is the one and the only one nearest enemy. No bullshit. And it follows rules:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in line of sight.
- Only target enemy in front of player camera.
- Maximum range is 150 yards.
- In PvP, it ignores Pets and Totems.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
The mob with most HP
/script UnitXP("target", "mostHP");
Return TRUE when found a target.
Target the enemy with most hit points. And it follows rules:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in line of sight.
- Only target enemy in front of player camera.
- Maximum range is 41 yards. Could be adjusted
- In PvP, it ignores Pets and Totems.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
Raid mark targeting
/script UnitXP("target", "nextMarkedEnemyInCycle");
/script UnitXP("target", "previousMarkedEnemyInCycle");
Return TRUE when found a target.
These functions only target mobs with a mark icon in order:
- Skull
- Red X cross
- Blue square
- Moon
- Green triangle
- Purple diamond
- Orange circle
- Yellow star
With following rules:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in front of player camera.
- In PvP, it ignores Pets and Totems.
- Maximum range is game's rendering range.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
- When continuously triggered, it guarantees that every marked mob in range would be targeted for once.
Melee targeting
/script UnitXP("target", "nextEnemyConsideringDistance");
/script UnitXP("target", "previousEnemyConsideringDistance");
Return TRUE when found a target.
These functions are designed for melee:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in line of sight.
- Only target enemy in front of player camera.
- In PvP, it ignores Pets and Totems.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
- Max range is 41 yards. Enemy further than that is ignored. Could be adjusted
- Attack range is divided into 3 parts (0-8, 8-25, 25-farRange). If there is enemy in near range part, further range parts would be ignored.
- In 0 to 8 yards. It cycles all enemies.
- In 8 to 25 yards. Only the nearest 3 enemies would be cycled.
- In 25 to 41 yards. Only the nearest 5 enemies would be cycled.
- When no target, it selects the nearest.
Ranged targeting
/script UnitXP("target", "nextEnemyInCycle");
/script UnitXP("target", "previousEnemyInCycle");
Return TRUE when found a target.
These functions are designed for ranged:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in line of sight.
- Only target enemy in front of player camera.
- In PvP, it ignores Pets and Totems.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
- Max range is 41 yards. Enemy further than that is ignored. Could be adjusted
- When continuously triggered, it guarantees that every mob in range would be targeted for once.
- When no target, it selects the nearest.
World boss targeting
/script UnitXP("target", "worldBoss");
Return TRUE when found a world boss.
World boss needs special attention:
- Only target attackable enemy.
- Only target livings.
- Only target enemy in front of player camera.
- Maximum range is game's rendering range.
- In PvE, when player is in-combat, it only target in-combat enemy. Could be lifted.
- When continuously triggered, it guarantees that every world boss in range would be targeted for once.
Range cone
"In front of player camera" is defined by a factor which could be adjusted with:
/script UnitXP("target","rangeCone", 2.2);
When this range cone factor in its minimum value 2, the cone is same as game's Field of View.
By default it's 2.2 . Increasing the factor would narrow the cone, so that only mobs in the center of vision would be targeted.
Far range
Some of the targeting functions have a default far range of 41 yards. They could be adjusted:
/script UnitXP("target","farRange", 41.0);
The acceptable value is range from 26 yards to 60 yards.
Lift in-combat filter
By default when player is in-combat, all targeting function would only target in-combat enemy. However this restriction could be lifted.
/script UnitXP("target","disableInCombatFilter");
/script UnitXP("target","enableInCombatFilter");
Using multiple targeting function together
For example: "We target raid mark first. However when no mark, we cycle in magic range":
/script local _=(UnitXP("target","nextMarkedEnemyInCycle") or UnitXP("target","nextEnemyInCycle"));
This code works because targeting functions return TRUE or FALSE indicating if they got a target. Lua logic operators support short-cut evaluation, that is, they evaluate their second operand only when necessary.