aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts/include
diff options
context:
space:
mode:
authorBlaymoira <none@none>2009-01-25 09:57:40 +0100
committerBlaymoira <none@none>2009-01-25 09:57:40 +0100
commit50172faf5a6128f7fd2a33d4b34a7b634ac88a61 (patch)
tree65cc9b09de99b16457c760c9c07e06f019c5c76b /src/bindings/scripts/include
parentfff472c16b5fa2f57ae4f2f04ac4be840dfead53 (diff)
*Updated FindCreature and FindGameObject function
--HG-- branch : trunk
Diffstat (limited to 'src/bindings/scripts/include')
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp16
-rw-r--r--src/bindings/scripts/include/sc_creature.h12
2 files changed, 16 insertions, 12 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index cbbb574d253..82e7ab04ca9 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -761,21 +761,25 @@ void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
}
-Unit* ScriptedAI::FindCreature(uint32 entry, float range)
-{
+Unit* FindCreature(uint32 entry, float range, Unit* Finder)
+{
+ if(!Finder)
+ return NULL;
Creature* target = NULL;
- Trinity::AllCreaturesOfEntryInRange check(m_creature, entry, range);
+ Trinity::AllCreaturesOfEntryInRange check(Finder, entry, range);
Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(target, check);
- m_creature->VisitNearbyObject(range, searcher);
+ Finder->VisitNearbyObject(range, searcher);
return target;
}
-GameObject* ScriptedAI::FindGameObject(uint32 entry, float range)
+GameObject* FindGameObject(uint32 entry, float range, Unit* Finder)
{
+ if(!Finder)
+ return NULL;
GameObject* target = NULL;
Trinity::AllGameObjectsWithEntryInGrid go_check(entry);
Trinity::GameObjectSearcher<Trinity::AllGameObjectsWithEntryInGrid> searcher(target, go_check);
- m_creature->VisitNearbyGridObject(range, searcher);
+ Finder->VisitNearbyGridObject(range, searcher);
return target;
}
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index cf991baa301..6f60f8cf334 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -25,6 +25,12 @@ private:
Creature *m_creature;
};
+//Get a single creature of given entry
+Unit* FindCreature(uint32 entry, float range, Unit* Finder);
+
+//Get a single gameobject of given entry
+GameObject* FindGameObject(uint32 entry, float range, Unit* Finder);
+
struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
{
ScriptedAI(Creature* creature) : m_creature(creature), InCombat(false), IsFleeing(false) {}
@@ -153,12 +159,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
void DoTeleportAll(float x, float y, float z, float o);
- //Get a single creature of given entry
- Unit* FindCreature(uint32 entry, float range);
-
- //Get a single gameobject of given entry
- GameObject* FindGameObject(uint32 entry, float range);
-
//Returns friendly unit with the most amount of hp missing from max hp
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff = 1);