[svn] * Moved Script grid_searchers to core
* Moved an enum from sc_creature.h to CreatureAI.h --HG-- branch : trunk
This commit is contained in:
@@ -40,7 +40,6 @@ include/precompiled.h \
|
|||||||
include/sc_creature.cpp \
|
include/sc_creature.cpp \
|
||||||
include/sc_creature.h \
|
include/sc_creature.h \
|
||||||
include/sc_gossip.h \
|
include/sc_gossip.h \
|
||||||
include/sc_grid_searchers.h \
|
|
||||||
include/sc_instance.h \
|
include/sc_instance.h \
|
||||||
include/sc_item.h \
|
include/sc_item.h \
|
||||||
scripts/areatrigger/areatrigger_scripts.cpp \
|
scripts/areatrigger/areatrigger_scripts.cpp \
|
||||||
@@ -419,3 +418,4 @@ install-data-hook:
|
|||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1567,9 +1567,6 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\include\sc_gossip.h">
|
RelativePath="..\include\sc_gossip.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\include\sc_grid_searchers.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\sc_instance.h">
|
RelativePath="..\include\sc_instance.h">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@@ -2308,10 +2308,6 @@
|
|||||||
RelativePath="..\include\sc_gossip.h"
|
RelativePath="..\include\sc_gossip.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\include\sc_grid_searchers.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\sc_instance.h"
|
RelativePath="..\include\sc_instance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2306,10 +2306,6 @@
|
|||||||
RelativePath="..\include\sc_gossip.h"
|
RelativePath="..\include\sc_gossip.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\include\sc_grid_searchers.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\sc_instance.h"
|
RelativePath="..\include\sc_instance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -6,9 +6,14 @@
|
|||||||
#define SC_PRECOMPILED_H
|
#define SC_PRECOMPILED_H
|
||||||
|
|
||||||
#include "../ScriptMgr.h"
|
#include "../ScriptMgr.h"
|
||||||
|
#include "Cell.h"
|
||||||
|
#include "CellImpl.h"
|
||||||
|
#include "GridNotifiers.h"
|
||||||
|
#include "GridNotifiersImpl.h"
|
||||||
|
#include "Unit.h"
|
||||||
|
#include "GameObject.h"
|
||||||
#include "sc_creature.h"
|
#include "sc_creature.h"
|
||||||
#include "sc_gossip.h"
|
#include "sc_gossip.h"
|
||||||
#include "sc_grid_searchers.h"
|
|
||||||
#include "sc_instance.h"
|
#include "sc_instance.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
@@ -513,14 +513,14 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
|
|||||||
|
|
||||||
Unit* pUnit = NULL;
|
Unit* pUnit = NULL;
|
||||||
|
|
||||||
MostHPMissingInRange u_check(m_creature, range, MinHPDiff);
|
MaNGOS::MostHPMissingInRange u_check(m_creature, range, MinHPDiff);
|
||||||
MaNGOS::UnitLastSearcher<MostHPMissingInRange> searcher(pUnit, u_check);
|
MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange> searcher(pUnit, u_check);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes;
|
typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes;
|
||||||
This means that if we only search grid then we cannot possibly return pets or players so this is safe
|
This means that if we only search grid then we cannot possibly return pets or players so this is safe
|
||||||
*/
|
*/
|
||||||
TypeContainerVisitor<MaNGOS::UnitLastSearcher<MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher);
|
TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher);
|
||||||
|
|
||||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||||
cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap()));
|
cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap()));
|
||||||
@@ -536,10 +536,10 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range)
|
|||||||
|
|
||||||
std::list<Creature*> pList;
|
std::list<Creature*> pList;
|
||||||
|
|
||||||
FriendlyCCedInRange u_check(m_creature, range);
|
MaNGOS::FriendlyCCedInRange u_check(m_creature, range);
|
||||||
MaNGOS::CreatureListSearcher<FriendlyCCedInRange> searcher(pList, u_check);
|
MaNGOS::CreatureListSearcher<MaNGOS::FriendlyCCedInRange> searcher(pList, u_check);
|
||||||
|
|
||||||
TypeContainerVisitor<MaNGOS::CreatureListSearcher<FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||||
|
|
||||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||||
cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap()));
|
cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap()));
|
||||||
@@ -556,10 +556,10 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 s
|
|||||||
|
|
||||||
std::list<Creature*> pList;
|
std::list<Creature*> pList;
|
||||||
|
|
||||||
FriendlyMissingBuffInRange u_check(m_creature, range, spellid);
|
MaNGOS::FriendlyMissingBuffInRange u_check(m_creature, range, spellid);
|
||||||
MaNGOS::CreatureListSearcher<FriendlyMissingBuffInRange> searcher(pList, u_check);
|
MaNGOS::CreatureListSearcher<MaNGOS::FriendlyMissingBuffInRange> searcher(pList, u_check);
|
||||||
|
|
||||||
TypeContainerVisitor<MaNGOS::CreatureListSearcher<FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||||
|
|
||||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||||
cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap()));
|
cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap()));
|
||||||
|
|||||||
@@ -8,39 +8,6 @@
|
|||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
#include "Creature.h"
|
#include "Creature.h"
|
||||||
|
|
||||||
//Spell targets used by SelectSpell
|
|
||||||
enum SelectTarget
|
|
||||||
{
|
|
||||||
SELECT_TARGET_DONTCARE = 0, //All target types allowed
|
|
||||||
|
|
||||||
SELECT_TARGET_SELF, //Only Self casting
|
|
||||||
|
|
||||||
SELECT_TARGET_SINGLE_ENEMY, //Only Single Enemy
|
|
||||||
SELECT_TARGET_AOE_ENEMY, //Only AoE Enemy
|
|
||||||
SELECT_TARGET_ANY_ENEMY, //AoE or Single Enemy
|
|
||||||
|
|
||||||
SELECT_TARGET_SINGLE_FRIEND, //Only Single Friend
|
|
||||||
SELECT_TARGET_AOE_FRIEND, //Only AoE Friend
|
|
||||||
SELECT_TARGET_ANY_FRIEND, //AoE or Single Friend
|
|
||||||
};
|
|
||||||
|
|
||||||
//Spell Effects used by SelectSpell
|
|
||||||
enum SelectEffect
|
|
||||||
{
|
|
||||||
SELECT_EFFECT_DONTCARE = 0, //All spell effects allowed
|
|
||||||
SELECT_EFFECT_DAMAGE, //Spell does damage
|
|
||||||
SELECT_EFFECT_HEALING, //Spell does healing
|
|
||||||
SELECT_EFFECT_AURA, //Spell applies an aura
|
|
||||||
};
|
|
||||||
|
|
||||||
//Selection method used by SelectTarget
|
|
||||||
enum SelectAggroTarget
|
|
||||||
{
|
|
||||||
SELECT_TARGET_RANDOM = 0, //Just selects a random target
|
|
||||||
SELECT_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
|
|
||||||
SELECT_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
|
struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
|
||||||
{
|
{
|
||||||
ScriptedAI(Creature* creature) : m_creature(creature), InCombat(false) {}
|
ScriptedAI(Creature* creature) : m_creature(creature), InCombat(false) {}
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
|
||||||
* This program is free software licensed under GPL version 2
|
|
||||||
* Please see the included DOCS/LICENSE.TXT for more information */
|
|
||||||
|
|
||||||
#ifndef SC_GRIDSEARCH_H
|
|
||||||
#define SC_GRIDSEARCH_H
|
|
||||||
|
|
||||||
#include "Unit.h"
|
|
||||||
#include "GameObject.h"
|
|
||||||
|
|
||||||
#include "Cell.h"
|
|
||||||
#include "CellImpl.h"
|
|
||||||
#include "GridNotifiers.h"
|
|
||||||
#include "GridNotifiersImpl.h"
|
|
||||||
|
|
||||||
//Used in:
|
|
||||||
//sc_creature.cpp - DoSelectLowestHpFriendly()
|
|
||||||
class MostHPMissingInRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {}
|
|
||||||
bool operator()(Unit* u)
|
|
||||||
{
|
|
||||||
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
|
|
||||||
{
|
|
||||||
i_hp = u->GetMaxHealth() - u->GetHealth();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Unit const* i_obj;
|
|
||||||
float i_range;
|
|
||||||
uint32 i_hp;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Used in:
|
|
||||||
//sc_creature.cpp - DoFindFriendlyCC()
|
|
||||||
class FriendlyCCedInRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) {}
|
|
||||||
bool operator()(Unit* u)
|
|
||||||
{
|
|
||||||
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
|
||||||
(u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Unit const* i_obj;
|
|
||||||
float i_range;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Used in:
|
|
||||||
//sc_creature.cpp - DoFindFriendlyMissingBuff()
|
|
||||||
class FriendlyMissingBuffInRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {}
|
|
||||||
bool operator()(Unit* u)
|
|
||||||
{
|
|
||||||
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
|
||||||
!(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Unit const* i_obj;
|
|
||||||
float i_range;
|
|
||||||
uint32 i_spell;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Used in:
|
|
||||||
//hyjalAI.cpp
|
|
||||||
class AllFriendlyCreaturesInGrid
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {}
|
|
||||||
bool operator() (Unit* u)
|
|
||||||
{
|
|
||||||
if(u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Unit const* pUnit;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Used in:
|
|
||||||
//hyjalAI.cpp
|
|
||||||
class AllGameObjectsWithEntryInGrid
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
|
|
||||||
bool operator() (GameObject* g)
|
|
||||||
{
|
|
||||||
if(g->GetEntry() == entry)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
uint32 entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AllCreaturesOfEntryInRange
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
|
|
||||||
bool operator() (Unit* u)
|
|
||||||
{
|
|
||||||
if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Unit const* pUnit;
|
|
||||||
uint32 entry;
|
|
||||||
float range;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -23,7 +23,6 @@ EndScriptData */
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
#include "def_black_temple.h"
|
#include "def_black_temple.h"
|
||||||
#include "sc_grid_searchers.h"
|
|
||||||
|
|
||||||
struct Location
|
struct Location
|
||||||
{
|
{
|
||||||
@@ -327,9 +326,9 @@ struct MANGOS_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
|
|||||||
|
|
||||||
std::list<Creature*> ChannelerList;
|
std::list<Creature*> ChannelerList;
|
||||||
|
|
||||||
AllCreaturesOfEntryInRange check(m_creature, CREATURE_CHANNELER, 50);
|
MaNGOS::AllCreaturesOfEntryInRange check(m_creature, CREATURE_CHANNELER, 50);
|
||||||
MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange> searcher(ChannelerList, check);
|
MaNGOS::CreatureListSearcher<MaNGOS::AllCreaturesOfEntryInRange> searcher(ChannelerList, check);
|
||||||
TypeContainerVisitor<MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
|
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
|
||||||
|
|
||||||
CellLock<GridReadGuard> cell_lock(cell, pair);
|
CellLock<GridReadGuard> cell_lock(cell, pair);
|
||||||
cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap()));
|
cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap()));
|
||||||
|
|||||||
@@ -316,18 +316,18 @@ void hyjalAI::Retreat()
|
|||||||
|
|
||||||
// First get all creatures.
|
// First get all creatures.
|
||||||
std::list<Creature*> creatures;
|
std::list<Creature*> creatures;
|
||||||
AllFriendlyCreaturesInGrid creature_check(m_creature);
|
MaNGOS::AllFriendlyCreaturesInGrid creature_check(m_creature);
|
||||||
MaNGOS::CreatureListSearcher<AllFriendlyCreaturesInGrid> creature_searcher(creatures, creature_check);
|
MaNGOS::CreatureListSearcher<MaNGOS::AllFriendlyCreaturesInGrid> creature_searcher(creatures, creature_check);
|
||||||
TypeContainerVisitor
|
TypeContainerVisitor
|
||||||
<MaNGOS::CreatureListSearcher<AllFriendlyCreaturesInGrid>,
|
<MaNGOS::CreatureListSearcher<MaNGOS::AllFriendlyCreaturesInGrid>,
|
||||||
GridTypeMapContainer> creature_visitor(creature_searcher);
|
GridTypeMapContainer> creature_visitor(creature_searcher);
|
||||||
|
|
||||||
// Then get all Ancient Gem Veins. NOTE: Grid Search will only be able to find those in the grid.
|
// Then get all Ancient Gem Veins. NOTE: Grid Search will only be able to find those in the grid.
|
||||||
std::list<GameObject*> goList;
|
std::list<GameObject*> goList;
|
||||||
AllGameObjectsWithEntryInGrid go_check(185557);
|
MaNGOS::AllGameObjectsWithEntryInGrid go_check(185557);
|
||||||
MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInGrid> go_search(goList, go_check);
|
MaNGOS::GameObjectListSearcher<MaNGOS::AllGameObjectsWithEntryInGrid> go_search(goList, go_check);
|
||||||
TypeContainerVisitor
|
TypeContainerVisitor
|
||||||
<MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInGrid>, GridTypeMapContainer> go_visit(go_search);
|
<MaNGOS::GameObjectListSearcher<MaNGOS::AllGameObjectsWithEntryInGrid>, GridTypeMapContainer> go_visit(go_search);
|
||||||
|
|
||||||
CellLock<GridReadGuard> cell_lock(cell, pair);
|
CellLock<GridReadGuard> cell_lock(cell, pair);
|
||||||
// Get Creatures
|
// Get Creatures
|
||||||
|
|||||||
@@ -32,6 +32,39 @@ struct SpellEntry;
|
|||||||
#define TIME_INTERVAL_LOOK 5000
|
#define TIME_INTERVAL_LOOK 5000
|
||||||
#define VISIBILITY_RANGE 10000
|
#define VISIBILITY_RANGE 10000
|
||||||
|
|
||||||
|
//Spell targets used by SelectSpell
|
||||||
|
enum SelectTarget
|
||||||
|
{
|
||||||
|
SELECT_TARGET_DONTCARE = 0, //All target types allowed
|
||||||
|
|
||||||
|
SELECT_TARGET_SELF, //Only Self casting
|
||||||
|
|
||||||
|
SELECT_TARGET_SINGLE_ENEMY, //Only Single Enemy
|
||||||
|
SELECT_TARGET_AOE_ENEMY, //Only AoE Enemy
|
||||||
|
SELECT_TARGET_ANY_ENEMY, //AoE or Single Enemy
|
||||||
|
|
||||||
|
SELECT_TARGET_SINGLE_FRIEND, //Only Single Friend
|
||||||
|
SELECT_TARGET_AOE_FRIEND, //Only AoE Friend
|
||||||
|
SELECT_TARGET_ANY_FRIEND, //AoE or Single Friend
|
||||||
|
};
|
||||||
|
|
||||||
|
//Spell Effects used by SelectSpell
|
||||||
|
enum SelectEffect
|
||||||
|
{
|
||||||
|
SELECT_EFFECT_DONTCARE = 0, //All spell effects allowed
|
||||||
|
SELECT_EFFECT_DAMAGE, //Spell does damage
|
||||||
|
SELECT_EFFECT_HEALING, //Spell does healing
|
||||||
|
SELECT_EFFECT_AURA, //Spell applies an aura
|
||||||
|
};
|
||||||
|
|
||||||
|
//Selection method used by SelectTarget
|
||||||
|
enum SelectAggroTarget
|
||||||
|
{
|
||||||
|
SELECT_TARGET_RANDOM = 0, //Just selects a random target
|
||||||
|
SELECT_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
|
||||||
|
SELECT_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
|
||||||
|
};
|
||||||
|
|
||||||
class MANGOS_DLL_SPEC CreatureAI
|
class MANGOS_DLL_SPEC CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -709,6 +709,31 @@ namespace MaNGOS
|
|||||||
Unit* const i_funit;
|
Unit* const i_funit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NearestAssistCreatureInCreatureRangeCheck
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NearestAssistCreatureInCreatureRangeCheck(Creature* obj,Unit* enemy, float range)
|
||||||
|
: i_obj(obj), i_enemy(enemy), i_range(range) {}
|
||||||
|
|
||||||
|
bool operator()(Creature* u)
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
float GetLastRange() const { return i_range; }
|
||||||
|
private:
|
||||||
|
Creature* const i_obj;
|
||||||
|
Unit* const i_enemy;
|
||||||
|
float i_range;
|
||||||
|
|
||||||
|
// prevent clone this object
|
||||||
|
NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&);
|
||||||
|
};
|
||||||
|
|
||||||
class AnyAssistCreatureInRangeCheck
|
class AnyAssistCreatureInRangeCheck
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -800,6 +825,110 @@ namespace MaNGOS
|
|||||||
float i_range;
|
float i_range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Searchers used by ScriptedAI
|
||||||
|
class MostHPMissingInRange
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {}
|
||||||
|
bool operator()(Unit* u)
|
||||||
|
{
|
||||||
|
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
|
||||||
|
{
|
||||||
|
i_hp = u->GetMaxHealth() - u->GetHealth();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Unit const* i_obj;
|
||||||
|
float i_range;
|
||||||
|
uint32 i_hp;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FriendlyCCedInRange
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) {}
|
||||||
|
bool operator()(Unit* u)
|
||||||
|
{
|
||||||
|
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
||||||
|
(u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Unit const* i_obj;
|
||||||
|
float i_range;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FriendlyMissingBuffInRange
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {}
|
||||||
|
bool operator()(Unit* u)
|
||||||
|
{
|
||||||
|
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
||||||
|
!(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Unit const* i_obj;
|
||||||
|
float i_range;
|
||||||
|
uint32 i_spell;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AllFriendlyCreaturesInGrid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {}
|
||||||
|
bool operator() (Unit* u)
|
||||||
|
{
|
||||||
|
if(u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Unit const* pUnit;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AllGameObjectsWithEntryInGrid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
|
||||||
|
bool operator() (GameObject* g)
|
||||||
|
{
|
||||||
|
if(g->GetEntry() == entry)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
uint32 entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AllCreaturesOfEntryInRange
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
|
||||||
|
bool operator() (Unit* u)
|
||||||
|
{
|
||||||
|
if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Unit const* pUnit;
|
||||||
|
uint32 entry;
|
||||||
|
float range;
|
||||||
|
};
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||||
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||||
|
|||||||
Reference in New Issue
Block a user