aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximius <none@none>2009-11-21 05:01:03 -0800
committermaximius <none@none>2009-11-21 05:01:03 -0800
commitbd1065156ed29c3e10b6bef88ec4637d5eb8b243 (patch)
tree091fb24347692609f17c21937f60c48338c0a396
parent83fa9466defe8c2e551e7dc2bdbb836cadcd75ef (diff)
*Copy and paste woes D:
--HG-- branch : trunk
-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
-rw-r--r--src/game/CellImpl.h12
-rw-r--r--src/game/Player.cpp2
5 files changed, 105 insertions, 20 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();
diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h
index 617d567ce32..4f6bec82f8b 100644
--- a/src/game/CellImpl.h
+++ b/src/game/CellImpl.h
@@ -228,19 +228,19 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
//no jokes here... Actually placing ASSERT() here was good idea, but
//we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?)
//maybe it is better to just return when radius <= 0.0f?
- if(radius <= 0.0f)
+ if (radius <= 0.0f)
{
m.Visit(l, visitor);
return;
}
//lets limit the upper value for search radius
- if(radius > 333.0f)
+ if (radius > 333.0f)
radius = 333.0f;
//lets calculate object coord offsets from cell borders.
CellArea area = Cell::CalculateCellArea(obj, radius);
//if radius fits inside standing cell
- if(!area)
+ if (!area)
{
m.Visit(l, visitor);
return;
@@ -254,7 +254,7 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
//if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
//currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
- if(((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
+ if (((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
{
VisitCircle(l, visitor, m, begin_cell, end_cell);
return;
@@ -265,9 +265,9 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
m.Visit(l, visitor);
// loop the cell range
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
+ for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
+ for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
{
CellPair cell_pair(x,y);
//lets skip standing cell since we already visited it
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 1d86e6b45b2..ba1547b2219 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -3792,7 +3792,7 @@ bool Player::resetTalents(bool no_cost)
*/
PlayerTalentMap::iterator plrTalent = m_talents[m_activeSpec]->find(talentInfo->TalentID);
- if (plrTalent != m_talents[m_activeSpec]->end( || !m_talents[m_activeSpec]->empty())
+ if (plrTalent != m_talents[m_activeSpec]->end( || m_talents[m_activeSpec]->empty())
{
for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
{