SceneObject* CreatureManagerImplementation::spawnLair(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size) { LairTemplate* lairTmpl = creatureTemplateManager->getLairTemplate(lairTemplate); if (lairTmpl == NULL || lairTmpl->getBuildingType() != LairTemplate::LAIR) return NULL; String buildingToSpawn; Vector<String>* mobiles = lairTmpl->getWeightedMobiles(); if (mobiles->size() == 0) return NULL; buildingToSpawn = lairTmpl->getBuilding((uint32)difficulty); if (buildingToSpawn.isEmpty()) { error("error spawning " + buildingToSpawn); return NULL; } ManagedReference<LairObject*> building = zoneServer->createObject(buildingToSpawn.hashCode(), 0).castTo<LairObject*>(); if (building == NULL) { error("error spawning " + buildingToSpawn); return NULL; } Locker blocker(building); building->setFaction(lairTmpl->getFaction()); building->setPvpStatusBitmask(CreatureFlag::ATTACKABLE); building->setOptionsBitmask(0, false); building->setMaxCondition(difficultyLevel * (900 + System::random(200))); building->setConditionDamage(0, false); building->initializePosition(x, z, y); building->setDespawnOnNoPlayersInRange(true); ManagedReference<LairObserver*> lairObserver = new LairObserver(); lairObserver->deploy(); lairObserver->setLairTemplate(lairTmpl); lairObserver->setDifficulty(difficulty); lairObserver->setObserverType(ObserverType::LAIR); lairObserver->setSize(size); building->registerObserver(ObserverEventType::OBJECTDESTRUCTION, lairObserver); building->registerObserver(ObserverEventType::DAMAGERECEIVED, lairObserver); building->registerObserver(ObserverEventType::AIMESSAGE, lairObserver); building->registerObserver(ObserverEventType::OBJECTREMOVEDFROMZONE, lairObserver); zone->transferObject(building, -1, false); lairObserver->checkForNewSpawns(building, NULL, true); return building; }
SceneObject* CreatureManagerImplementation::spawnTheater(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size) { LairTemplate* lairTmpl = creatureTemplateManager->getLairTemplate(lairTemplate); if (lairTmpl == NULL || lairTmpl->getBuildingType() != LairTemplate::THEATER) return NULL; Vector<String>* mobiles = lairTmpl->getWeightedMobiles(); if (mobiles->size() == 0) return NULL; String buildingToSpawn = lairTmpl->getBuilding((uint32)difficulty); if (buildingToSpawn.isEmpty()) { error("error spawning " + buildingToSpawn); return NULL; } ManagedReference<PoiBuilding*> building = zoneServer->createObject(buildingToSpawn.hashCode(), 0).castTo<PoiBuilding*>(); if (building == NULL) { error("error spawning " + buildingToSpawn); return NULL; } Locker blocker(building); building->initializePosition(x, z, y); building->setDespawnOnNoPlayersInRange(true); ManagedReference<DynamicSpawnObserver*> theaterObserver = new DynamicSpawnObserver(); theaterObserver->deploy(); theaterObserver->setLairTemplate(lairTmpl); theaterObserver->setDifficulty(difficulty); theaterObserver->setObserverType(ObserverType::LAIR); theaterObserver->setSize(size); building->registerObserver(ObserverEventType::CREATUREDESPAWNED, theaterObserver); building->registerObserver(ObserverEventType::OBJECTREMOVEDFROMZONE, theaterObserver); zone->transferObject(building, -1, false); theaterObserver->spawnInitialMobiles(building); return building; }