| 712 | class NearestAssistCreatureInCreatureRangeCheck |
| 713 | { |
| 714 | public: |
| 715 | NearestAssistCreatureInCreatureRangeCheck(Creature* obj,Unit* enemy, float range) |
| 716 | : i_obj(obj), i_enemy(enemy), i_range(range) {} |
| 717 | |
| 718 | bool operator()(Creature* u) |
| 719 | { |
| 720 | if(u->getFaction() == i_obj->getFaction() && !u->isInCombat() && !u->GetCharmerOrOwnerGUID() && u->IsHostileTo(i_enemy) && u->isAlive()&& i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsWithinLOSInMap(u)) |
| 721 | { |
| 722 | i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check |
| 723 | return true; |
| 724 | } |
| 725 | return false; |
| 726 | } |
| 727 | float GetLastRange() const { return i_range; } |
| 728 | private: |
| 729 | Creature* const i_obj; |
| 730 | Unit* const i_enemy; |
| 731 | float i_range; |
| 732 | |
| 733 | // prevent clone this object |
| 734 | NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&); |
| 735 | }; |
| 736 | |
| 826 | }; |
| 827 | |
| 828 | // Searchers used by ScriptedAI |
| 829 | class MostHPMissingInRange |
| 830 | { |
| 831 | public: |
| 832 | MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {} |
| 833 | bool operator()(Unit* u) |
| 834 | { |
| 835 | if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp) |
| 836 | { |
| 837 | i_hp = u->GetMaxHealth() - u->GetHealth(); |
| 838 | return true; |
| 839 | } |
| 840 | return false; |
| 841 | } |
| 842 | private: |
| 843 | Unit const* i_obj; |
| 844 | float i_range; |
| 845 | uint32 i_hp; |
| 846 | }; |
| 847 | |
| 848 | class FriendlyCCedInRange |
| 849 | { |
| 850 | public: |
| 851 | FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) {} |
| 852 | bool operator()(Unit* u) |
| 853 | { |
| 854 | if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && |
| 855 | (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED))) |
| 856 | { |
| 857 | return true; |
| 858 | } |
| 859 | return false; |
| 860 | } |
| 861 | private: |
| 862 | Unit const* i_obj; |
| 863 | float i_range; |
| 864 | }; |
| 865 | |
| 866 | class FriendlyMissingBuffInRange |
| 867 | { |
| 868 | public: |
| 869 | FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {} |
| 870 | bool operator()(Unit* u) |
| 871 | { |
| 872 | if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && |
| 873 | !(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2))) |
| 874 | { |
| 875 | return true; |
| 876 | } |
| 877 | return false; |
| 878 | } |
| 879 | private: |
| 880 | Unit const* i_obj; |
| 881 | float i_range; |
| 882 | uint32 i_spell; |
| 883 | }; |
| 884 | |
| 885 | class AllFriendlyCreaturesInGrid |
| 886 | { |
| 887 | public: |
| 888 | AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {} |
| 889 | bool operator() (Unit* u) |
| 890 | { |
| 891 | if(u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit)) |
| 892 | return true; |
| 893 | |
| 894 | return false; |
| 895 | } |
| 896 | private: |
| 897 | Unit const* pUnit; |
| 898 | }; |
| 899 | |
| 900 | class AllGameObjectsWithEntryInGrid |
| 901 | { |
| 902 | public: |
| 903 | AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {} |
| 904 | bool operator() (GameObject* g) |
| 905 | { |
| 906 | if(g->GetEntry() == entry) |
| 907 | return true; |
| 908 | |
| 909 | return false; |
| 910 | } |
| 911 | private: |
| 912 | uint32 entry; |
| 913 | }; |
| 914 | |
| 915 | class AllCreaturesOfEntryInRange |
| 916 | { |
| 917 | public: |
| 918 | AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {} |
| 919 | bool operator() (Unit* u) |
| 920 | { |
| 921 | if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range)) |
| 922 | return true; |
| 923 | |
| 924 | return false; |
| 925 | } |
| 926 | private: |
| 927 | Unit const* pUnit; |
| 928 | uint32 entry; |
| 929 | float range; |