/* * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef TRINITYCORE_UNIT_AI_COMMON_H #define TRINITYCORE_UNIT_AI_COMMON_H #include "Define.h" class SpellInfo; class Unit; enum Powers : int8; // EnumUtils: DESCRIBE THIS enum class EvadeReason { NoHostiles, // the creature's threat list is empty Boundary, // the creature has moved outside its evade boundary NoPath, // the creature was unable to reach its target for over 5 seconds SequenceBreak, // this is a boss and the pre-requisite encounters for engaging it are not defeated yet Other, // anything else }; // Selection method used by SelectTarget enum class SelectTargetMethod { Random, // just pick a random target MaxThreat, // prefer targets higher in the threat list MinThreat, // prefer targets lower in the threat list MaxDistance, // prefer targets further from us MinDistance // prefer targets closer to us }; // default predicate function to select target based on distance, player and/or aura criteria struct TC_GAME_API DefaultTargetSelector { // unit: the reference unit // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // withMainTank: allow current tank to be selected // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withMainTank, int32 aura); bool operator()(Unit const* target) const; private: Unit const* _me; float _dist; bool _playerOnly; Unit const* _exception; int32 _aura; }; // Target selector for spell casts checking range, auras and attributes /// @todo Add more checks from Spell::CheckCast struct TC_GAME_API SpellTargetSelector { SpellTargetSelector(Unit* caster, uint32 spellId); bool operator()(Unit const* target) const; private: Unit const* _caster; SpellInfo const* _spellInfo; }; // Very simple target selector, will just skip main target // NOTE: When passing to UnitAI::SelectTarget remember to use 0 as position for random selection // because tank will not be in the temporary list struct TC_GAME_API NonTankTargetSelector { NonTankTargetSelector(Unit* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { } bool operator()(Unit const* target) const; private: Unit* _source; bool _playerOnly; }; // Simple selector for units using mana struct TC_GAME_API PowerUsersSelector { PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { } bool operator()(Unit const* target) const; private: Unit const* _me; Powers const _power; float const _dist; bool const _playerOnly; }; struct TC_GAME_API FarthestTargetSelector { FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) { } bool operator()(Unit const* target) const; private: Unit const* _me; float _dist; bool _playerOnly; bool _inLos; }; #endif // TRINITYCORE_UNIT_AI_COMMON_H