// 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 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 cleanup the world states and GO flags void DoEncounterCleanup() { // remove world state if (Player* pSummoner = m_creature->GetMap()->GetPlayer(m_summonerGuid)) pSummoner->SendUpdateWorldState(WORLD_STATE_TETHYR_SHOW, 0); // reset all cannons GameObjectList lCannonsInRange; GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f); for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr) (*itr)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); // despawn all marksmen CreatureList lMarksmenInRange; GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f); for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr) (*itr)->ForcedDespawn(30000); }
// 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(); } } }
void Ore::OnCollision(const GameObjectList& objects) { SmartPtr<GameObject> object; GameObjectType const* type = NULL; GameObjectList::const_iterator it = objects.begin(); GameObjectList::const_iterator end = objects.end(); for (; it != end; ++it) { object = *it; type = &(object->GetType()); // Compare Object type if((*type) == GameObjectType("Spaceship")) { mWorld->RemoveObject(this); cout << "ORE COLIDES WITH SPACESHIP\n"; } } }
// 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; }
void MovementInform(uint32 uiMotionType, uint32 uiPointId) override { if (uiMotionType == WAYPOINT_MOTION_TYPE) { // start attacking if (uiPointId == 12) { // make cannons usable GameObjectList lCannonsInRange; GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f); for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr) (*itr)->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); // attack all marksmen CreatureList lMarksmenInRange; GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f); for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr) { (*itr)->AI()->AttackStart(m_creature); AttackStart(*itr); } } } else if (uiMotionType == POINT_MOTION_TYPE) { // Spout on cannon point reach if (uiPointId) { if (DoCastSpellIfCan(m_creature, urand(0, 1) ? SPELL_SPOUT_LEFT : SPELL_SPOUT_RIGHT, CAST_INTERRUPT_PREVIOUS) == CAST_OK) { // Remove the target focus m_creature->SetTarget(nullptr); m_uiPhase = PHASE_SPOUT; } } } }
void Drone::OnCollision(const GameObjectList& objects) { SmartPtr<GameObject> object; GameObjectType const* type = NULL; GameObjectList::const_iterator it = objects.begin(); GameObjectList::const_iterator end = objects.end(); for (; it != end; ++it) { // const GameObjectType * type = &((*it)->GetType() ); object = *it; type = &(object->GetType()); // const char * type_name = object->GetType().GetTypeName(); // cout << type_name << ";" << endl; // Compare Object type if((*type) == GameObjectType("Bullet")) { // TODO add damage related stuff to GameObject which should allow you to bypass this whole awkward pointer stuff here... Bullet* b = (Bullet*) object.GetPtr(); // cout << "colision with bullet" << endl; // Bullet* b = dynamic_cast<Bullet*>(object.GetPtr()); int damage = b->GetDamage(); int health = mHealth; int newHealth = mHealth - damage; DealDamage(b->GetDamage()); //cout << "HEALTH " << mHealth << endl; // Check if alive if(mHealth <= 0) mWorld->RemoveObject(this); } } }
void Asteroid::OnCollision(const GameObjectList& objects) { SmartPtr<GameObject> object; GameObjectType const* type = NULL; GameObjectList::const_iterator it = objects.begin(); GameObjectList::const_iterator end = objects.end(); for (; it != end; ++it) { // const GameObjectType * type = &((*it)->GetType() ); object = *it; type = &(object->GetType()); // const char * type_name = object->GetType().GetTypeName(); // cout << type_name << ";" << endl; // Compare Object type if((*type) == GameObjectType("Bullet")) { mWorld->RemoveObject(this); // @todo mWorld-> see if you can do the spliting of asteroids from here rather than the asteroids.cpp } } }