// Function to search for new tubber in range void DoFindNewTubber() { GameObjectList lTubbersInRange; GetGameObjectListWithEntryInGrid(lTubbersInRange, m_creature, GO_BLUELEAF_TUBBER, 40.0f); if (lTubbersInRange.empty()) return; lTubbersInRange.sort(ObjectDistanceOrder(m_creature)); GameObject* pNearestTubber = nullptr; // Always need to find new ones for (GameObjectList::const_iterator itr = lTubbersInRange.begin(); itr != lTubbersInRange.end(); ++itr) { if (!(*itr)->IsSpawned() && (*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND) && (*itr)->IsWithinLOSInMap(m_creature)) { pNearestTubber = *itr; break; } } if (!pNearestTubber) return; m_targetTubberGuid = pNearestTubber->GetObjectGuid(); float fX, fY, fZ; pNearestTubber->GetContactPoint(m_creature, fX, fY, fZ); m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ); m_bIsMovementActive = true; }
// Function to search for new rookery egg in range void DoFindNewEgg() { GameObjectList lEggsInRange; GetGameObjectListWithEntryInGrid(lEggsInRange, m_creature, GO_ROOKERY_EGG, 20.0f); if (lEggsInRange.empty()) // No GO found return; lEggsInRange.sort(ObjectDistanceOrder(m_creature)); GameObject* pNearestEgg = nullptr; // Always need to find new ones for (GameObjectList::const_iterator itr = lEggsInRange.begin(); itr != lEggsInRange.end(); ++itr) { if (!((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE))) { pNearestEgg = *itr; break; } } if (!pNearestEgg) return; float fX, fY, fZ; pNearestEgg->GetContactPoint(m_creature, fX, fY, fZ, 1.0f); m_creature->SetWalk(false); m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ); m_bIsMovementActive = true; }
// Function to search for new tubber in range void DoFindNewCrystal(Player* pMaster) { GameObjectList lCrystalsInRange; for (unsigned int i : aGOList) { GetGameObjectListWithEntryInGrid(lCrystalsInRange, m_creature, i, 40.0f); // If a crystal was found in range, stop the search here, else try with another GO if (!lCrystalsInRange.empty()) break; } if (lCrystalsInRange.empty()) // Definely no GO found { m_creature->PlayDirectSound(SOUND_GROWL); return; } lCrystalsInRange.sort(ObjectDistanceOrder(m_creature)); GameObject* pNearestCrystal = nullptr; // Always need to find new ones for (GameObjectList::const_iterator itr = lCrystalsInRange.begin(); itr != lCrystalsInRange.end(); ++itr) { if ((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND)) { pNearestCrystal = *itr; break; } } if (!pNearestCrystal) { m_creature->PlayDirectSound(SOUND_GROWL); return; } float fX, fY, fZ; pNearestCrystal->GetContactPoint(m_creature, fX, fY, fZ, 3.0f); m_creature->SetWalk(false); m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ); m_bIsMovementActive = true; }
// Function to respawn GOs void DoRespawnObjects(uint32 uiEntry, float fRange) { GameObjectList lBarrelsInRange; m_lExplosivesGuidsList.clear(); GetGameObjectListWithEntryInGrid(lBarrelsInRange, m_creature, uiEntry, fRange); if (lBarrelsInRange.empty()) { script_error_log("Bloodmyst Isle: ERROR Failed to find any gameobjects of entry %u in range.", uiEntry); return; } // respawn explosives and store for future use for (GameObjectList::const_iterator itr = lBarrelsInRange.begin(); itr != lBarrelsInRange.end(); ++itr) { (*itr)->SetRespawnTime(5 * MINUTE); (*itr)->Refresh(); m_lExplosivesGuidsList.push_back((*itr)->GetObjectGuid()); } }
// Function to respawn fire GOs void DoRespawnFires(bool bFirstEvent) { GameObjectList lFiresInRange; GetGameObjectListWithEntryInGrid(lFiresInRange, m_creature, GO_COIL_FIRE_L, 110.0f); GetGameObjectListWithEntryInGrid(lFiresInRange, m_creature, GO_COIL_FIRE_S, 110.0f); if (lFiresInRange.empty()) { script_error_log("Bloodmyst Isle: ERROR Failed to find any gameobjects of entry %u and %u in range.", GO_COIL_FIRE_L, GO_COIL_FIRE_S); return; } for (GameObjectList::const_iterator itr = lFiresInRange.begin(); itr != lFiresInRange.end(); ++itr) { if ((bFirstEvent && (*itr)->GetPositionZ() < 150.0f) || (!bFirstEvent && (*itr)->GetPositionZ() > 150.0f)) { (*itr)->SetRespawnTime(5 * MINUTE); (*itr)->Refresh(); } } }