From 50172faf5a6128f7fd2a33d4b34a7b634ac88a61 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Sun, 25 Jan 2009 09:57:40 +0100 Subject: *Updated FindCreature and FindGameObject function --HG-- branch : trunk --- src/bindings/scripts/include/sc_creature.cpp | 16 ++++++++++------ src/bindings/scripts/include/sc_creature.h | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/bindings/scripts/include') 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 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 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); -- cgit v1.2.3