diff options
author | Kudlaty <none@none> | 2009-06-29 06:31:05 +0200 |
---|---|---|
committer | Kudlaty <none@none> | 2009-06-29 06:31:05 +0200 |
commit | 0df76804c4ce30133ec611f574c75b51b8240cdc (patch) | |
tree | cc07fa8d1169c38ae47d74a4c49ac16869b86310 /src | |
parent | 229dbd814f591cbbbd472f3b8fdb0b4c4f54912d (diff) |
Merge [SD2]
r1086 Add long time needed grid search functions for closest creature and gameobject - skip, we have better function in core
r1087 Remove no longer needed grid search code and use functions instead.
--HG--
branch : trunk
Diffstat (limited to 'src')
6 files changed, 28 insertions, 136 deletions
diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index 0c0303b0f40..15ac2aef462 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -1648,30 +1648,15 @@ struct TRINITY_DLL_DECL cage_trap_triggerAI : public ScriptedAI } }; -bool GOHello_cage_trap(Player* plr, GameObject* go) +bool GOHello_cage_trap(Player* pPlayer, GameObject* pGo) { float x, y, z; - plr->GetPosition(x, y, z); - - Creature* trigger = NULL; - - CellPair pair(Trinity::ComputeCellPair(x, y)); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); + pPlayer->GetPosition(x, y, z); // Grid search for nearest live creature of entry 23304 within 10 yards - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck check(*plr, 23304, true, 10); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(plr, trigger, check); - - TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> cSearcher(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, cSearcher, *(plr->GetMap())); - - if(trigger) - CAST_AI(cage_trap_triggerAI, trigger->AI())->Active = true; - go->SetGoState(GO_STATE_ACTIVE); + if(Creature* pTrigger = pGo->FindNearestCreature(23304, 10.0f)) + CAST_AI(cage_trap_triggerAI, pTrigger->AI())->Active = true; + pGo->SetGoState(GO_STATE_ACTIVE); return true; } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp index a832cc1c938..5a73a93f386 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp @@ -133,26 +133,6 @@ struct TRINITY_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI } } - Creature* SelectCreatureInGrid(uint32 entry, float range) - { - Creature* pCreature = NULL; - - CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(m_creature, pCreature, creature_check); - - TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); - - return pCreature; - } - void SpellHit(Unit *caster, const SpellEntry *spell) { //hack :( @@ -177,8 +157,7 @@ struct TRINITY_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI if (Rage_Timer < diff) { - Creature* distiller = SelectCreatureInGrid(17954, 100); - if (distiller) + if (Creature* distiller = me->FindNearestCreature(17954, 100.0f)) { DoScriptText(SAY_REGEN, m_creature); DoCast(m_creature,SPELL_WARLORDS_RAGE); diff --git a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp index e195929408e..07b9179b9af 100644 --- a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp +++ b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp @@ -497,24 +497,11 @@ CreatureAI* GetAI_npc_secondTrial(Creature *_Creature) ## go_second_trial ######*/ -bool GOHello_go_second_trial(Player *player, GameObject* _GO) +bool GOHello_go_second_trial(Player *player, GameObject* pGO) { // find spawn :: master_kelerun_bloodmourn - CellPair p(Trinity::ComputeCellPair(_GO->GetPositionX(), _GO->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - CellLock<GridReadGuard> cell_lock(cell, p); - - Creature* event_controller = NULL; - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*_GO, MASTER_KELERUN_BLOODMOURN, true, 30); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(player, event_controller, u_check); - TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); - //cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(_GO->GetMap(), _GO)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *(_GO->GetMap())); - - if ( event_controller ) - CAST_AI(master_kelerun_bloodmournAI, event_controller->AI())->StartEvent(); + if (Creature* pCreature = pGO->FindNearestCreature(MASTER_KELERUN_BLOODMOURN, 30.0f)) + CAST_AI(master_kelerun_bloodmournAI, pCreature->AI())->StartEvent(); return true; } diff --git a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp index e2283c638e7..32e0d5dcee9 100644 --- a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp +++ b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp @@ -169,8 +169,7 @@ struct TRINITY_DLL_DECL npc_ranger_lilathaAI : public npc_escortAI case 0: { m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20); - if(Cage) + if(GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20)) Cage->SetGoState(GO_STATE_ACTIVE); DoScriptText(SAY_START, m_creature, player); break; diff --git a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp index e1e6ba011e6..500e1251fce 100644 --- a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp +++ b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp @@ -391,27 +391,6 @@ struct TRINITY_DLL_DECL npc_commander_dawnforgeAI : public ScriptedAI void EnterCombat(Unit *who) { } - //Select any creature in a grid - Creature* SelectCreatureInGrid(uint32 entry, float range) - { - Creature* pCreature = NULL; - - CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(m_creature, pCreature, creature_check); - - TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); - - return pCreature; - } - void JustSummoned(Creature *summoned) { pathaleonGUID = summoned->GetGUID(); @@ -473,7 +452,7 @@ struct TRINITY_DLL_DECL npc_commander_dawnforgeAI : public ScriptedAI { if (!isEvent) { - Creature *ardonis = SelectCreatureInGrid(CreatureEntry[0], 10.0f); + Creature* ardonis = me->FindNearestCreature(CreatureEntry[0], 10.0f); if (!ardonis) return false; @@ -627,26 +606,6 @@ CreatureAI* GetAI_npc_commander_dawnforge(Creature* _Creature) return new npc_commander_dawnforgeAI(_Creature); } -Creature* SearchDawnforge(Player *source, uint32 entry, float range) -{ - Creature* pCreature = NULL; - - CellPair pair(Trinity::ComputeCellPair(source->GetPositionX(), source->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*source, entry, true, range); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(source, pCreature, creature_check); - - TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, creature_searcher,*(source->GetMap())); - - return pCreature; -} - bool AreaTrigger_at_commander_dawnforge(Player *player, AreaTriggerEntry *at) { //if player lost aura or not have at all, we should not try start event. @@ -655,7 +614,7 @@ bool AreaTrigger_at_commander_dawnforge(Player *player, AreaTriggerEntry *at) if (player->isAlive() && player->GetQuestStatus(QUEST_INFO_GATHERING) == QUEST_STATUS_INCOMPLETE) { - Creature* Dawnforge = SearchDawnforge(player, CreatureEntry[1], 30.0f); + Creature* Dawnforge = player->FindNearestCreature(CreatureEntry[1], 30.0f); if (!Dawnforge) return false; diff --git a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp index fb558dc31a3..1078a740a89 100644 --- a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp +++ b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp @@ -85,55 +85,38 @@ bool QuestAccept_npc_calvin_montague(Player* player, Creature* creature, Quest c ## go_mausoleum_trigger ######*/ -#define QUEST_ULAG 1819 -#define C_ULAG 6390 -#define GO_TRIGGER 104593 -#define GO_DOOR 176594 - -GameObject* SearchMausoleumGo(Unit *source, uint32 entry, float range) +enum { - GameObject* pGo = NULL; - - CellPair pair(Trinity::ComputeCellPair(source->GetPositionX(), source->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*source, entry, range); - Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(source, pGo, go_check); - - TypeContainerVisitor<Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer> go_searcher(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, go_searcher,*(source->GetMap())); - - return pGo; -} + QUEST_ULAG = 1819, + NPC_ULAG = 6390, + GO_TRIGGER = 104593, + GO_DOOR = 176594 +}; -bool GOHello_go_mausoleum_door(Player *player, GameObject* _GO) +bool GOHello_go_mausoleum_door(Player* pPlayer, GameObject* pGo) { - if (player->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE) + if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE) return false; - if (GameObject *trigger = SearchMausoleumGo(player, GO_TRIGGER, 30)) + if (GameObject* pTrigger = pPlayer->FindNearestGameObject(GO_TRIGGER, 30.0f)) { - trigger->SetGoState(GO_STATE_READY); - player->SummonCreature(C_ULAG, 2390.26, 336.47, 40.01, 2.26, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 300000); + pTrigger->SetGoState(GO_STATE_READY); + pPlayer->SummonCreature(NPC_ULAG, 2390.26, 336.47, 40.01, 2.26, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 300000); return false; } return false; } -bool GOHello_go_mausoleum_trigger(Player *player, GameObject* _GO) +bool GOHello_go_mausoleum_trigger(Player* pPlayer, GameObject* pGo) { - if (player->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE) + if (pPlayer->GetQuestStatus(QUEST_ULAG) != QUEST_STATUS_INCOMPLETE) return false; - if (GameObject *door = SearchMausoleumGo(player, GO_DOOR, 30)) + if (GameObject* pDoor = pPlayer->FindNearestGameObject(GO_DOOR, 30.0f)) { - _GO->SetGoState(GO_STATE_ACTIVE); - door->RemoveFlag(GAMEOBJECT_FLAGS,GO_FLAG_INTERACT_COND); + pGo->SetGoState(GO_STATE_ACTIVE); + pDoor->RemoveFlag(GAMEOBJECT_FLAGS,GO_FLAG_INTERACT_COND); return true; } |