aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/scripts')
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp66
-rw-r--r--src/bindings/scripts/include/sc_creature.h5
-rw-r--r--src/bindings/scripts/scripts/world/areatrigger_scripts.cpp40
3 files changed, 98 insertions, 13 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index e790304fb33..9f643eae30d 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -752,22 +752,76 @@ void LoadOverridenDBCData()
}
}
-Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange)
+//return closest GO in grid, with range from pSource
+GameObject* GetClosestGameObjectWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+{
+ GameObject* pGo = NULL;
+
+ CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*pSource, uiEntry, fMaxSearchRange);
+ MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> searcher(pSource, pGo, go_check);
+
+ TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer> go_searcher(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, go_searcher, *pSource->GetMap(), *pSource, fMaxSearchRange);
+
+ return pGo;
+}
+
+//return closest creature alive in grid, with range from pSource
+Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
{
Creature* pCreature = NULL;
- CellPair pair(Trinity::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
+ CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
Cell cell(pair);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*pSource, Entry, true, MaxSearchRange);
- Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pSource, pCreature, creature_check);
+ MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*pSource, uiEntry, true, fMaxSearchRange);
+ MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pSource, pCreature, creature_check);
- TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher);
+ TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, creature_searcher,*(pSource->GetMap()));
+ cell_lock->Visit(cell_lock, creature_searcher,*(pSource->GetMap()), *pSource, fMaxSearchRange);
return pCreature;
}
+
+/*
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList , WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+{
+ CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ AllGameObjectsWithEntryInRange check(pSource, uiEntry, fMaxSearchRange);
+ MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInRange> searcher(pSource, lList, check);
+ TypeContainerVisitor<MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(pSource->GetMap()), *pSource, fMaxSearchRange);
+}
+
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+{
+ CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
+ Cell cell(pair);
+ cell.data.Part.reserved = ALL_DISTRICT;
+ cell.SetNoCreate();
+
+ AllCreaturesOfEntryInRange check(pSource, uiEntry, fMaxSearchRange);
+ MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange> searcher(pSource, lList, check);
+ TypeContainerVisitor<MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(pSource->GetMap()), *pSource, fMaxSearchRange);
+}
+*/
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 19d386c7f3e..4b461296775 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -223,8 +223,11 @@ struct TRINITY_DLL_DECL BossAI : public ScriptedAI
// SD2's grid searchers
+//return closest gameobject in grid, with range from pSource
+GameObject* GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange);
+
//return closest creature alive in grid, with range from pSource
-Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 Entry, float MaxSearchRange);
+Creature* GetClosestCreatureWithEntry(WorldObject *pSource, uint32 Entry, float fMaxSearchRange);
#endif
diff --git a/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp b/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
index 5aa7ecb7f04..07bc0a27049 100644
--- a/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/areatrigger_scripts.cpp
@@ -22,11 +22,34 @@ SDCategory: Areatrigger
EndScriptData */
/* ContentData
-at_legion_teleporter 4560 Teleporter TO Invasion Point: Cataclysm
+at_coilfang_waterfall 4591
+at_legion_teleporter 4560 Teleporter TO Invasion Point: Cataclysm
+at_ravenholdt
+at_warsong_slaughterhouse
+at_warsong_grainery
+at_torp_farm
EndContentData */
#include "precompiled.h"
+/*######
+## at_coilfang_waterfall
+######*/
+
+enum eCoilfangGOs
+{
+ GO_COILFANG_WATERFALL = 184212
+};
+
+bool AreaTrigger_at_coilfang_waterfall(Player *pPlayer, AreaTriggerEntry *pAt)
+{
+ if (GameObject* pGo = GetClosestGameObjectWithEntry(pPlayer, GO_COILFANG_WATERFALL, 35.0f))
+ if (pGo->getLootState() == GO_READY)
+ pGo->UseDoorOrButton();
+
+ return false;
+}
+
/*#####
## at_legion_teleporter
#####*/
@@ -40,19 +63,19 @@ enum eLegionTeleporter
QUEST_GAINING_ACCESS_H = 10604
};
-bool AreaTrigger_at_legion_teleporter(Player* pPlayer, AreaTriggerEntry* pAt)
+bool AreaTrigger_at_legion_teleporter(Player *pPlayer, AreaTriggerEntry *pAt)
{
if (pPlayer->isAlive() && !pPlayer->isInCombat())
{
- if (pPlayer->GetTeam()== ALLIANCE && pPlayer->GetQuestRewardStatus(QUEST_GAINING_ACCESS_A))
+ if (pPlayer->GetTeam() == ALLIANCE && pPlayer->GetQuestRewardStatus(QUEST_GAINING_ACCESS_A))
{
- pPlayer->CastSpell(pPlayer,SPELL_TELE_A_TO,false);
+ pPlayer->CastSpell(pPlayer, SPELL_TELE_A_TO, false);
return true;
}
- if (pPlayer->GetTeam()== HORDE && pPlayer->GetQuestRewardStatus(QUEST_GAINING_ACCESS_H))
+ if (pPlayer->GetTeam() == HORDE && pPlayer->GetQuestRewardStatus(QUEST_GAINING_ACCESS_H))
{
- pPlayer->CastSpell(pPlayer,SPELL_TELE_H_TO,false);
+ pPlayer->CastSpell(pPlayer, SPELL_TELE_H_TO, false);
return true;
}
@@ -80,6 +103,11 @@ void AddSC_areatrigger_scripts()
Script *newscript;
newscript = new Script;
+ newscript->Name = "at_coilfang_waterfall";
+ newscript->pAreaTrigger = &AreaTrigger_at_coilfang_waterfall;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
newscript->Name = "at_legion_teleporter";
newscript->pAreaTrigger = &AreaTrigger_at_legion_teleporter;
newscript->RegisterSelf();