void BountyMissionObjectiveImplementation::updateWaypoint() { Locker locker(&syncMutex); ManagedReference<MissionObject* > mission = this->mission.get(); WaypointObject* waypoint = mission->getWaypointToMission(); if (waypoint == NULL) { Locker mlocker(mission); waypoint = mission->createWaypoint(); } Locker wplocker(waypoint); waypoint->setPlanetCRC(getTargetZoneName().hashCode()); Vector3 position = getTargetPosition(); waypoint->setPosition(position.getX(), 0, position.getY()); waypoint->setActive(true); mission->updateMissionLocation(); if (mission->getMissionLevel() == 1) { getPlayerOwner().get()->sendSystemMessage("@mission/mission_bounty_informant:target_location_received"); // Target Waypoint Received. } }
void ReconMissionObjectiveImplementation::activate() { MissionObjectiveImplementation::activate(); ManagedReference<MissionObject* > mission = this->mission.get(); if (mission == NULL) return; ManagedReference<ZoneServer*> zoneServer = Core::lookupObject<ZoneServer>("ZoneServer"); if (locationActiveArea == NULL) { locationActiveArea = ( zoneServer->createObject(String("object/mission_recon_area.iff").hashCode(), 1)).castTo<MissionReconActiveArea*>(); Locker locker(locationActiveArea); locationActiveArea->setMissionObjective(_this.get()); } if (!locationActiveArea->isInQuadTree()) { String planetName = mission->getStartPlanet(); Zone* zone = zoneServer->getZone(planetName); Locker locker(locationActiveArea); locationActiveArea->initializePosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); locationActiveArea->setRadius(32.f); if (zone != NULL) { zone->transferObject(locationActiveArea, -1, true); } else { error("Failed to insert recon location to zone."); abort(); return; } } ManagedReference<WaypointObject*> waypoint = mission->getWaypointToMission(); if (waypoint == NULL) waypoint = mission->createWaypoint(); waypoint->setPlanetCRC(mission->getStartPlanetCRC()); waypoint->setPosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); waypoint->setActive(true); mission->updateMissionLocation(); }
void DestroyMissionObjectiveImplementation::activate() { MissionObjectiveImplementation::activate(); ManagedReference<MissionObject* > mission = this->mission.get(); if ((hasObservers() && lairObject != NULL) || mission == NULL) { return; } if (spawnActiveArea == NULL) { spawnActiveArea = ( Core::lookupObject<ZoneServer>("ZoneServer")->createObject(String("object/mission_spawn_area.iff").hashCode(), 1)).castTo<MissionSpawnActiveArea*>(); Locker alocker(spawnActiveArea); spawnActiveArea->setMissionObjective(_this.get()); } if (spawnActiveArea->getZone() == NULL) { String planetName = mission->getStartPlanet(); Zone* zone = Core::lookupObject<ZoneServer>("ZoneServer")->getZone(planetName); if (zone == NULL) { abort(); return; } Locker alocker(spawnActiveArea); spawnActiveArea->initializePosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); spawnActiveArea->setRadius(128.f); zone->transferObject(spawnActiveArea, -1, false); //info("inserting to zone " + zone->getPlanetName(), true); } WaypointObject* waypoint = mission->getWaypointToMission(); if (waypoint == NULL) waypoint = mission->createWaypoint(); waypoint->setPlanetCRC(mission->getStartPlanet().hashCode()); waypoint->setPosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); waypoint->setActive(true); mission->updateMissionLocation(); }
void EntertainerMissionObjectiveImplementation::activate() { Locker _lock(_this.getReferenceUnsafeStaticCast()); ManagedReference<MissionObject* > mission = this->mission.get(); MissionObjectiveImplementation::activate(); if (hasObservers()) { return; } if (mission == NULL) return; ManagedReference<ZoneServer*> zoneServer = Core::lookupObject<ZoneServer>("ZoneServer"); if (locationActiveArea == NULL) { locationActiveArea = ( zoneServer->createObject(STRING_HASHCODE("object/active_area.iff"), 1)).castTo<ActiveArea*>(); } if (!locationActiveArea->isInQuadTree()) { String planetName = mission->getStartPlanet(); Zone* zone = zoneServer->getZone(planetName); Locker locker(locationActiveArea); locationActiveArea->initializePosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); locationActiveArea->setRadius(32.f); if (zone != NULL) { zone->transferObject(locationActiveArea, -1, true); } else { error("Failed to insert entertainer location to zone."); abort(); return; } } Locker locationLocker(locationActiveArea); ManagedReference<MissionObserver*> observer1 = new MissionObserver(_this.getReferenceUnsafeStaticCast()); addObserver(observer1, true); locationActiveArea->registerObserver(ObserverEventType::ENTEREDAREA, observer1); ManagedReference<MissionObserver*> observer2 = new MissionObserver(_this.getReferenceUnsafeStaticCast()); addObserver(observer2, true); locationActiveArea->registerObserver(ObserverEventType::EXITEDAREA, observer2); locationLocker.release(); WaypointObject* waypoint = mission->getWaypointToMission(); if (waypoint == NULL) { Locker mlocker(mission); waypoint = mission->createWaypoint(); } Locker wplocker(waypoint); waypoint->setPlanetCRC(mission->getStartPlanetCRC()); waypoint->setPosition(mission->getStartPositionX(), 0, mission->getStartPositionY()); waypoint->setActive(true); mission->updateMissionLocation(); }
void DestroyMissionObjectiveImplementation::spawnLair() { ManagedReference<MissionObject* > mission = this->mission.get(); ManagedReference<MissionSpawnActiveArea* > spawnActiveArea = this->spawnActiveArea; if (spawnActiveArea == NULL) return; if (lairObject != NULL && lairObject->getZone() != NULL) return; Zone* zone = spawnActiveArea->getZone(); Locker locker(spawnActiveArea); spawnActiveArea->destroyObjectFromWorld(true); Vector3 pos = findValidSpawnPosition(zone); ManagedReference<WaypointObject*> waypoint = mission->getWaypointToMission(); if (waypoint == NULL) { waypoint = mission->createWaypoint(); } waypoint->setPosition(pos.getX(), 0, pos.getY()); mission->updateMissionLocation(); mission->setStartPosition(pos.getX(), pos.getY()); //TODO: find correct string id ManagedReference<CreatureObject*> player = getPlayerOwner(); if (player != NULL) { player->sendSystemMessage("Transmission Received: Mission Target has been located. Mission waypoint has been updated to exact location"); } LairTemplate* lair = CreatureTemplateManager::instance()->getLairTemplate(lairTemplate.hashCode()); if (lair == NULL) { error("incorrect lair template in destroy mission objective " + lairTemplate); abort(); return; } if (lairObject == NULL) { String buildingToSpawn = lair->getMissionBuilding(difficulty); if (buildingToSpawn.isEmpty()) { error("error spawning " + buildingToSpawn); abort(); return; } lairObject = zone->getZoneServer()->createObject(buildingToSpawn.hashCode(), 0).castTo<LairObject*>(); if (lairObject == NULL) { error("error spawning " + buildingToSpawn); abort(); return; } Locker locker(lairObject); lairObject->setFaction(lair->getFaction()); lairObject->setPvpStatusBitmask(CreatureFlag::ATTACKABLE); lairObject->setOptionsBitmask(0, false); lairObject->setMaxCondition(difficultyLevel * (900 + System::random(200))); lairObject->setConditionDamage(0, false); lairObject->initializePosition(pos.getX(), pos.getZ(), pos.getY()); lairObject->setDespawnOnNoPlayersInRange(false); ManagedReference<MissionObserver*> observer = new MissionObserver(_this.get()); addObserver(observer, true); lairObject->registerObserver(ObserverEventType::OBJECTDESTRUCTION, observer); ManagedReference<DestroyMissionLairObserver*> lairObserver = new DestroyMissionLairObserver(); lairObserver->deploy(); lairObserver->setLairTemplate(lair); lairObserver->setDifficulty(difficulty); lairObserver->setObserverType(ObserverType::LAIR); lairObserver->setSize(mission->getSize()); lairObject->registerObserver(ObserverEventType::OBJECTDESTRUCTION, lairObserver); lairObject->registerObserver(ObserverEventType::DAMAGERECEIVED, lairObserver); lairObject->registerObserver(ObserverEventType::AIMESSAGE, lairObserver); lairObject->registerObserver(ObserverEventType::OBJECTREMOVEDFROMZONE, lairObserver); zone->transferObject(lairObject, -1, true); lairObserver->checkForNewSpawns(lairObject, NULL, true); } if (lairObject != NULL && lairObject->getZone() == NULL) { zone->transferObject(lairObject, -1, true); } }