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.cpp96
-rw-r--r--src/bindings/scripts/include/sc_creature.h12
-rw-r--r--src/bindings/scripts/scripts/world/go_scripts.cpp2
-rw-r--r--src/bindings/scripts/scripts/world/item_scripts.cpp18
4 files changed, 34 insertions, 94 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index 9f643eae30d..bb4d3e68888 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -637,50 +637,50 @@ void BossAI::TeleportCheaters()
float x, y, z;
me->GetPosition(x, y, z);
std::list<HostilReference*> &m_threatlist = me->getThreatManager().getThreatList();
- for (std::list<HostilReference*>::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
+ for (std::list<HostilReference*>::iterator itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
if((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && !CheckBoundary((*itr)->getTarget()))
(*itr)->getTarget()->NearTeleportTo(x, y, z, 0);
}
bool BossAI::CheckBoundary(Unit *who)
{
- if(!boundary || !who)
+ if (!boundary || !who)
return true;
for (BossBoundaryMap::const_iterator itr = boundary->begin(); itr != boundary->end(); ++itr)
{
- switch(itr->first)
+ switch (itr->first)
{
case BOUNDARY_N:
- if(me->GetPositionX() > itr->second)
+ if (me->GetPositionX() > itr->second)
return false;
break;
case BOUNDARY_S:
- if(me->GetPositionX() < itr->second)
+ if (me->GetPositionX() < itr->second)
return false;
break;
case BOUNDARY_E:
- if(me->GetPositionY() < itr->second)
+ if (me->GetPositionY() < itr->second)
return false;
break;
case BOUNDARY_W:
- if(me->GetPositionY() > itr->second)
+ if (me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_NW:
- if(me->GetPositionX() + me->GetPositionY() > itr->second)
+ if (me->GetPositionX() + me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_SE:
- if(me->GetPositionX() + me->GetPositionY() < itr->second)
+ if (me->GetPositionX() + me->GetPositionY() < itr->second)
return false;
break;
case BOUNDARY_NE:
- if(me->GetPositionX() - me->GetPositionY() > itr->second)
+ if (me->GetPositionX() - me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_SW:
- if(me->GetPositionX() - me->GetPositionY() < itr->second)
+ if (me->GetPositionX() - me->GetPositionY() < itr->second)
return false;
break;
}
@@ -752,76 +752,20 @@ void LoadOverridenDBCData()
}
}
-//return closest GO in grid, with range from pSource
-GameObject* GetClosestGameObjectWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+// SD2 grid searchers.
+Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive)
{
- 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 pSource->FindNearestCreature(uiEntry, fMaxSearchRange, bAlive);
}
-
-//return closest creature alive in grid, with range from pSource
-Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
{
- Creature* pCreature = NULL;
-
- CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*pSource, uiEntry, true, fMaxSearchRange);
- MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pSource, pCreature, creature_check);
-
- TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, creature_searcher,*(pSource->GetMap()), *pSource, fMaxSearchRange);
-
- return pCreature;
+ return pSource->FindNearestGameObject(uiEntry, fMaxSearchRange);
}
-
-/*
-void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList , WorldObject* pSource, uint32 uiEntry, float 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();
-
- 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);
+ return pSource->GetCreatureListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
}
-
-void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+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();
-
- 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);
+ return pSource->GetGameObjectListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
}
-*/
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 4b461296775..fdeea02997c 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -221,13 +221,11 @@ struct TRINITY_DLL_DECL BossAI : public ScriptedAI
void TeleportCheaters();
};
-// 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 fMaxSearchRange);
+// SD2 grid searchers.
+Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive = true);
+GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange);
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
#endif
diff --git a/src/bindings/scripts/scripts/world/go_scripts.cpp b/src/bindings/scripts/scripts/world/go_scripts.cpp
index 9f6b90f6af0..052310ad057 100644
--- a/src/bindings/scripts/scripts/world/go_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/go_scripts.cpp
@@ -521,7 +521,7 @@ bool GOHello_go_matrix_punchograph(Player *pPlayer, GameObject *pGO)
if(pPlayer->HasItemCount(ITEM_RED_PUNCH_CARD, 1))
{
pPlayer->DestroyItemCount(ITEM_RED_PUNCH_CARD, 1, true);
- pPlayer->CastSpell(pPlayer,SPELL_PRISMATIC_PUNCH_CARD,true);
+ pPlayer->CastSpell(pPlayer, SPELL_PRISMATIC_PUNCH_CARD, true);
}
break;
default:
diff --git a/src/bindings/scripts/scripts/world/item_scripts.cpp b/src/bindings/scripts/scripts/world/item_scripts.cpp
index 0c3b470ce1d..04654be37b5 100644
--- a/src/bindings/scripts/scripts/world/item_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/item_scripts.cpp
@@ -148,7 +148,7 @@ bool ItemUse_item_flying_machine(Player* pPlayer, Item* pItem, SpellCastTargets
# item_gor_dreks_ointment
#####*/
-bool ItemUse_item_gor_dreks_ointment(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
+bool ItemUse_item_gor_dreks_ointment(Player *pPlayer, Item *pItem, SpellCastTargets const& targets)
{
if (targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId() == TYPEID_UNIT &&
targets.getUnitTarget()->GetEntry() == 20748 && !targets.getUnitTarget()->HasAura(32578))
@@ -162,7 +162,7 @@ bool ItemUse_item_gor_dreks_ointment(Player* pPlayer, Item* pItem, SpellCastTarg
# item_incendiary_explosives
#####*/
-bool ItemUse_item_incendiary_explosives(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
+bool ItemUse_item_incendiary_explosives(Player *pPlayer, Item *pItem, SpellCastTargets const &targets)
{
if (pPlayer->FindNearestCreature(26248,15) || pPlayer->FindNearestCreature(26249,15))
return false;
@@ -177,7 +177,7 @@ bool ItemUse_item_incendiary_explosives(Player* pPlayer, Item* pItem, SpellCastT
# item_mysterious_egg
#####*/
-bool ItemExpire_item_mysterious_egg(Player* pPlayer, ItemPrototype const * pItemProto)
+bool ItemExpire_item_mysterious_egg(Player *pPlayer, ItemPrototype const *pItemProto)
{
ItemPosCountVec dest;
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg
@@ -191,7 +191,7 @@ bool ItemExpire_item_mysterious_egg(Player* pPlayer, ItemPrototype const * pItem
# item_disgusting_jar
#####*/
-bool ItemExpire_item_disgusting_jar(Player* pPlayer, ItemPrototype const * pItemProto)
+bool ItemExpire_item_disgusting_jar(Player *pPlayer, ItemPrototype const *pItemProto)
{
ItemPosCountVec dest;
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar
@@ -226,8 +226,7 @@ bool ItemUse_item_harvesters_gift(Player* pPlayer, Item* pItem, SpellCastTargets
else
return false;
}
- else
- return true;
+ return true;
}
/*#####
@@ -254,7 +253,7 @@ enum ePileFakeFur
GO_HIGH_QUALITY_FUR = 187983,
NPC_NESINGWARY_TRAPPER = 25835
};
-bool ItemUse_item_pile_fake_furs(Player* pPlayer, Item* _Item, SpellCastTargets const& targets)
+bool ItemUse_item_pile_fake_furs(Player *pPlayer, Item *pItem, SpellCastTargets const &targets)
{
GameObject* pGo;
if ((pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_1, 5.0f)) ||
@@ -273,7 +272,7 @@ bool ItemUse_item_pile_fake_furs(Player* pPlayer, Item* _Item, SpellCastTargets
(pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_14, 5.0f)) ||
(pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f)))
{
- if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER,10.0f,true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER,10.0f,false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR,2.0f))
+ if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f))
return true;
float x, y, z;
pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f);
@@ -284,8 +283,7 @@ bool ItemUse_item_pile_fake_furs(Player* pPlayer, Item* _Item, SpellCastTargets
summon->SetReactState(REACT_PASSIVE);
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
}
- } else
- return true;
+ }
}
void AddSC_item_scripts()