Index: include/sc_grid_searchers.cpp =================================================================== --- include/sc_grid_searchers.cpp (revision 1804) +++ include/sc_grid_searchers.cpp (working copy) @@ -38,6 +38,14 @@ Cell::VisitGridObjects(pSource, searcher, fMaxSearchRange); } +void GetGameObjectListInGrid(std::list& lList , WorldObject* pSource, float fMaxSearchRange) +{ + AllGameObjectsInRange check(pSource, fMaxSearchRange); + MaNGOS::GameObjectListSearcher searcher(pSource, lList, check); + + Cell::VisitGridObjects(pSource, searcher, fMaxSearchRange); +} + void GetCreatureListWithEntryInGrid(std::list& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange) { AllCreaturesOfEntryInRange check(pSource, uiEntry, fMaxSearchRange); Index: include/sc_grid_searchers.h =================================================================== --- include/sc_grid_searchers.h (revision 1804) +++ include/sc_grid_searchers.h (working copy) @@ -41,6 +41,7 @@ Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange); void GetGameObjectListWithEntryInGrid(std::list& lList , WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange); +void GetGameObjectListInGrid(std::list& lList , WorldObject* pSource, float fMaxSearchRange); void GetCreatureListWithEntryInGrid(std::list& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange); //Used in: @@ -79,6 +80,23 @@ float m_fRange; }; +class AllGameObjectsInRange +{ + public: + AllGameObjectsInRange(const WorldObject* pObject, float fMaxRange) : m_pObject(pObject), m_fRange(fMaxRange) {} + bool operator() (GameObject* pGo) + { + if (m_pObject->IsWithinDist(pGo, m_fRange, false)) + return true; + + return false; + } + + private: + const WorldObject* m_pObject; + float m_fRange; +}; + class AllCreaturesOfEntryInRange { public: Index: scripts/northrend/borean_tundra.cpp =================================================================== --- scripts/northrend/borean_tundra.cpp (revision 1804) +++ scripts/northrend/borean_tundra.cpp (working copy) @@ -17,7 +17,7 @@ /* ScriptData SDName: Borean_Tundra SD%Complete: 100 -SDComment: Quest support: 11708, 11692, 11961. Taxi vendors. 11570 +SDComment: Quest support: 11708, 11692, 11961. Taxi vendors. 11570, 11865 SDCategory: Borean Tundra EndScriptData */ @@ -28,6 +28,8 @@ npc_surristrasz npc_tiare npc_lurgglbr +npc_nesingwary_trapper +go_high_quality_fur EndContentData */ #include "precompiled.h" @@ -396,6 +398,137 @@ return new npc_lurgglbrAI(pCreature); } +/*###### +## npc_nesingwary_trapper +######*/ + +struct MANGOS_DLL_DECL npc_nesingwary_trapperAI : public ScriptedAI +{ + npc_nesingwary_trapperAI(Creature* pCreature) : ScriptedAI(pCreature) { + Reset(); + } + + uint8 m_uiPhase; + uint32 m_uiPhaseTimer; + uint64 m_uiPlayerGUID; + uint64 m_uiGobjectTrapGUID; + + void Reset() + { + m_uiPhase = 0; + m_uiPhaseTimer = 0; + m_uiPlayerGUID = 0; + m_uiGobjectTrapGUID = 0; + } + + void StartAction(uint64 uiPlayerGUID, uint64 uiGoTrapGUID) + { + m_uiPhase = 1; + m_uiPhaseTimer = 2000; + m_uiPlayerGUID = uiPlayerGUID; + m_uiGobjectTrapGUID = uiGoTrapGUID; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->isInCombat() && m_uiPhase) + { + if(m_uiPhaseTimer <= uiDiff) + { + switch(m_uiPhase) + { + case 1: + if (GameObject* pTrap = m_creature->GetMap()->GetGameObject(m_uiGobjectTrapGUID)) + if (pTrap->isSpawned()) + { + m_creature->GetMotionMaster()->MovePoint(0, pTrap->GetPositionX(), pTrap->GetPositionY(), pTrap->GetPositionZ()); + m_uiPhaseTimer = 10000; + } + break; + case 2: + if (GameObject* pTrap = m_creature->GetMap()->GetGameObject(m_uiGobjectTrapGUID)) + if (pTrap->isSpawned()) + { + pTrap->Use(m_creature); + if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_uiPlayerGUID)) + if (pPlayer->isAlive()) + pPlayer->KilledMonsterCredit(m_creature->GetEntry()); + } + break; + } + } + else + m_uiPhaseTimer -= uiDiff; + } + } + + void MovementInform(uint32 uiType, uint32 uiPointId) + { + m_creature->HandleEmote(EMOTE_ONESHOT_LOOT); + m_uiPhaseTimer = 1000; + m_uiPhase = 2; + } +}; + +CreatureAI* GetAI_npc_nesingwary_trapper(Creature* pCreature) +{ + return new npc_nesingwary_trapperAI(pCreature); +} + +/*###### +## go_high_quality_fur +######*/ + +enum +{ + QUEST_UNFIT_FOR_DEATH = 11865, + NPC_NESINGWARY_TRAPPER = 25835, + SAY_PHRASE_1 = -1000006, + SAY_PHRASE_2 = -1000007, + SAY_PHRASE_3 = -1000008, + SAY_PHRASE_4 = -1000009 +}; + +static const uint32 a_uiGameobjects[] = {187982, 187995, 187996, 187997, 187998, 187999, 188000, 188001, 188002, 188003, 188004, 188005, 188006, 188007, 188008}; + +bool GOHello_go_high_quality_fur(Player* pPlayer, GameObject* pGo) +{ + if (pGo->isSpawned()) + return false; + + if (pPlayer->GetQuestStatus(QUEST_UNFIT_FOR_DEATH) == QUEST_STATUS_INCOMPLETE) + { + std::list lCaribouTraps; + GetGameObjectListInGrid(lCaribouTraps, pGo, INTERACTION_DISTANCE); + for (std::list::iterator iter = lCaribouTraps.begin(); iter != lCaribouTraps.end(); ++iter) + { + for (uint8 i = 0; iGetEntry() == a_uiGameobjects[i] && (*iter)->isSpawned()) + { + pGo->SetRespawnTime(8); + pGo->Refresh(); + float fX, fY, fZ; + (*iter)->GetRandomPoint((*iter)->GetPositionX(), (*iter)->GetPositionY(), (*iter)->GetPositionZ(), 2*INTERACTION_DISTANCE, fX, fY, fZ); + if (Creature* pCreature = (*iter)->SummonCreature(NPC_NESINGWARY_TRAPPER, fX, fY, fZ, (*iter)->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000)) + { + switch (urand(0, 3)){ + case 0: DoScriptText(SAY_PHRASE_1, pCreature); break; + case 1: DoScriptText(SAY_PHRASE_2, pCreature); break; + case 2: DoScriptText(SAY_PHRASE_3, pCreature); break; + case 3: DoScriptText(SAY_PHRASE_4, pCreature); break; + } + if (npc_nesingwary_trapperAI* pTrapperAI = dynamic_cast(pCreature->AI())) + pTrapperAI->StartAction(pPlayer->GetGUID(), (*iter)->GetGUID()); + } + return true; + } + } + } + } + return true; +} + void AddSC_borean_tundra() { Script *newscript; @@ -435,4 +568,14 @@ newscript->GetAI = &GetAI_npc_lurgglbr; newscript->pQuestAccept = &QuestAccept_npc_lurgglbr; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_nesingwary_trapper"; + newscript->GetAI = &GetAI_npc_nesingwary_trapper; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_high_quality_fur"; + newscript->pGOHello = &GOHello_go_high_quality_fur; + newscript->RegisterSelf(); }