Instructions Jenkins Doxygen

[Added] dynamic spawn functionality 37/2037/4
authorIvojedi <ivojedi@swgemu.com>
Sat, 12 Jul 2014 00:21:55 +0000 (17:21 -0700)
committerIvojedi <ivojedi@swgemu.com>
Sat, 12 Jul 2014 02:04:10 +0000 (19:04 -0700)
[Changed] /createspawningelement admin command to require fewer
arguments be smarter

Change-Id: I9276ffa2873e4f543815c2400db1895730222497

MMOCoreORB/src/Makefile.am
MMOCoreORB/src/server/zone/managers/creature/CreatureManager.idl
MMOCoreORB/src/server/zone/managers/creature/CreatureManagerImplementation.cpp
MMOCoreORB/src/server/zone/managers/creature/DynamicSpawnObserver.idl [moved from MMOCoreORB/src/server/zone/managers/creature/TheaterSpawnObserver.idl with 84% similarity]
MMOCoreORB/src/server/zone/managers/creature/DynamicSpawnObserverImplementation.cpp [moved from MMOCoreORB/src/server/zone/managers/creature/TheaterSpawnObserverImplementation.cpp with 76% similarity]
MMOCoreORB/src/server/zone/managers/creature/SpawnObserver.idl
MMOCoreORB/src/server/zone/objects/creature/commands/CreateSpawningElementCommand.h
MMOCoreORB/src/server/zone/objects/creature/events/DespawnDynamicSpawnTask.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/objects/creature/events/DespawnTheaterTask.h [deleted file]
MMOCoreORB/src/server/zone/objects/scene/ObserverType.h
MMOCoreORB/src/server/zone/objects/tangible/components/CampKitMenuComponent.cpp

index c9edddb..5a79620 100644 (file)
@@ -97,7 +97,7 @@ core3_TESTS =         server/zone/objects/area/areashapes/tests/CircularAreaShapeTest.c
                                server/zone/tests/ZoneTest.cpp \
                                server/zone/managers/objectcontroller/command/tests/CommandLuaTest.cpp
 
-core3_IDLS =   autogen/server/zone/managers/creature/TheaterSpawnObserver.cpp \
+core3_IDLS =   autogen/server/zone/managers/creature/DynamicSpawnObserver.cpp \
                                autogen/server/zone/managers/creature/SpawnObserver.cpp \
                                autogen/server/zone/objects/player/sessions/VeteranRewardSession.cpp \
                                autogen/server/zone/objects/player/sessions/ProposeUnitySession.cpp \
@@ -390,7 +390,7 @@ core3_SOURCES =     $(core3_IDLS) \
                server/zone/objects/area/LuaActiveArea.cpp \
                server/zone/objects/tangible/LuaTangibleObject.cpp \
                server/zone/managers/creature/LairObserverImplementation.cpp \
-               server/zone/managers/creature/TheaterSpawnObserverImplementation.cpp \
+               server/zone/managers/creature/DynamicSpawnObserverImplementation.cpp \
                server/zone/managers/customization/CustomizationIdManager.cpp \
                server/zone/managers/director/ScreenPlayObserverImplementation.cpp \
                server/zone/managers/director/PersistentEventImplementation.cpp \
index f2b0c71..cd9938a 100644 (file)
@@ -62,11 +62,13 @@ class CreatureManager extends ZoneManager {
                loadSpawnAreas();
        }
 
-       public native TangibleObject spawn(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size);
+       public native SceneObject spawn(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size);
 
-       public native TangibleObject spawnLair(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size = 20);
+       public native SceneObject spawnLair(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size = 20);
 
-       public native TangibleObject spawnTheater(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size = 10);
+       public native SceneObject spawnTheater(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size = 10);
+
+       public native SceneObject spawnDynamicSpawn(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size = 10);
 
        /**
         * Spawns the specified creature into zone
index 6f87469..88d7d8f 100644 (file)
@@ -39,7 +39,7 @@
 #include "server/zone/packets/chat/ChatSystemMessage.h"
 #include "server/zone/objects/tangible/threat/ThreatMap.h"
 #include "server/zone/managers/creature/LairObserver.h"
-#include "server/zone/managers/creature/TheaterSpawnObserver.h"
+#include "server/zone/managers/creature/DynamicSpawnObserver.h"
 #include "server/zone/packets/object/SpatialChat.h"
 #include "server/zone/objects/intangible/PetControlDevice.h"
 
@@ -70,7 +70,7 @@ void CreatureManagerImplementation::spawnRandomCreaturesAround(SceneObject* crea
        spawnRandomCreature(1, newX, zone->getHeight(newX, newY), newY);
 }
 
-TangibleObject* CreatureManagerImplementation::spawn(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size) {
+SceneObject* CreatureManagerImplementation::spawn(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size) {
        LairTemplate* lairTmpl = creatureTemplateManager->getLairTemplate(lairTemplate);
 
        if (lairTmpl == NULL)
@@ -80,11 +80,13 @@ TangibleObject* CreatureManagerImplementation::spawn(unsigned int lairTemplate,
                return spawnLair(lairTemplate, difficultyLevel, difficulty, x, z, y, size);
        else if (lairTmpl->getBuildingType() == LairTemplate::THEATER)
                return spawnTheater(lairTemplate, difficulty, x, z, y, size);
+       else if (lairTmpl->getBuildingType() == LairTemplate::NONE)
+               return spawnDynamicSpawn(lairTemplate, difficulty, x, z, y, size);
 
        return NULL;
 }
 
-TangibleObject* CreatureManagerImplementation::spawnLair(unsigned int lairTemplate, int difficultyLevel, int difficulty, float x, float z, float y, float size) {
+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)
@@ -138,7 +140,7 @@ TangibleObject* CreatureManagerImplementation::spawnLair(unsigned int lairTempla
        return building;
 }
 
-TangibleObject* CreatureManagerImplementation::spawnTheater(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size) {
+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)
@@ -167,11 +169,11 @@ TangibleObject* CreatureManagerImplementation::spawnTheater(unsigned int lairTem
 
        building->initializePosition(x, z, y);
 
-       ManagedReference<TheaterSpawnObserver*> theaterObserver = new TheaterSpawnObserver();
+       ManagedReference<DynamicSpawnObserver*> theaterObserver = new DynamicSpawnObserver();
        theaterObserver->deploy();
        theaterObserver->setLairTemplate(lairTmpl);
        theaterObserver->setDifficulty(difficulty);
-       theaterObserver->setObserverType(ObserverType::THEATER);
+       theaterObserver->setObserverType(ObserverType::LAIR);
        theaterObserver->setSize(size);
 
        building->registerObserver(ObserverEventType::CREATUREDESPAWNED, theaterObserver);
@@ -184,6 +186,47 @@ TangibleObject* CreatureManagerImplementation::spawnTheater(unsigned int lairTem
        return building;
 }
 
+SceneObject* CreatureManagerImplementation::spawnDynamicSpawn(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size) {
+       LairTemplate* lairTmpl = creatureTemplateManager->getLairTemplate(lairTemplate);
+
+       if (lairTmpl == NULL || lairTmpl->getBuildingType() != LairTemplate::NONE)
+               return NULL;
+
+       Vector<String>* mobiles = lairTmpl->getWeightedMobiles();
+
+       if (mobiles->size() == 0)
+               return NULL;
+
+       ManagedReference<ActiveArea*> area = zoneServer->createObject(String("object/active_area.iff").hashCode(), 0).castTo<ActiveArea*>();
+
+       if (area == NULL) {
+               error("error creating active area");
+               return NULL;
+       }
+
+       Locker blocker(area);
+
+       area->initializePosition(x, z, y);
+       area->setRadius(64);
+       area->setNoSpawnArea(true);
+       area->setNoBuildArea(true);
+
+       ManagedReference<DynamicSpawnObserver*> dynamicObserver = new DynamicSpawnObserver();
+       dynamicObserver->deploy();
+       dynamicObserver->setLairTemplate(lairTmpl);
+       dynamicObserver->setDifficulty(difficulty);
+       dynamicObserver->setObserverType(ObserverType::LAIR);
+       dynamicObserver->setSize(size);
+
+       area->registerObserver(ObserverEventType::CREATUREDESPAWNED, dynamicObserver);
+
+       zone->transferObject(area, -1, false);
+
+       dynamicObserver->spawnInitialMobiles(area);
+
+       return area;
+}
+
 void CreatureManagerImplementation::spawnRandomCreature(int number, float x, float z, float y, uint64 parentID) {
        Locker locker(_this.get());
 
@@ -48,20 +48,25 @@ import engine.util.Observable;
 import server.zone.managers.creature.SpawnObserver;
 import server.zone.objects.tangible.TangibleObject;
 import server.zone.objects.creature.AiAgent;
+include server.zone.templates.mobile.LairTemplate;
 
-class TheaterSpawnObserver extends SpawnObserver {
+class DynamicSpawnObserver extends SpawnObserver {
 
-       public TheaterSpawnObserver() {
+       public DynamicSpawnObserver() {
                super();
 
-               Logger.setLoggingName("TheaterSpawnObserver");
+               Logger.setLoggingName("DynamicSpawnObserver");
        }
 
        public native int notifyObserverEvent(unsigned int eventType, Observable observable, ManagedObject arg1, long arg2);
 
-       public native void spawnInitialMobiles(TangibleObject theater);
+       public native void spawnInitialMobiles(SceneObject building);
 
        public boolean isTheaterSpawnObserver() {
-               return true;
+               return super.lairTemplate.getBuildingType() == LairTemplate.THEATER;
+       }
+
+       public boolean isDynamicSpawnObserver() {
+               return super.lairTemplate.getBuildingType() == LairTemplate.NONE;
        }
 }
@@ -1,18 +1,18 @@
-#include "server/zone/managers/creature/TheaterSpawnObserver.h"
+#include "server/zone/managers/creature/DynamicSpawnObserver.h"
 #include "server/zone/objects/creature/events/RespawnCreatureTask.h"
-#include "server/zone/objects/creature/events/DespawnTheaterTask.h"
+#include "server/zone/objects/creature/events/DespawnDynamicSpawnTask.h"
 #include "server/zone/templates/mobile/CreatureTemplate.h"
 #include "server/zone/managers/creature/CreatureManager.h"
 #include "server/zone/managers/creature/CreatureTemplateManager.h"
 
-int TheaterSpawnObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
+int DynamicSpawnObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
        if (eventType != ObserverEventType::CREATUREDESPAWNED)
                return 0;
 
        Reference<AiAgent*> ai = cast<AiAgent*>(arg1);
-       Reference<TangibleObject*> theater = cast<TangibleObject*>(observable);
+       Reference<SceneObject*> spawn = cast<SceneObject*>(observable);
 
-       if (ai == NULL || theater == NULL)
+       if (ai == NULL || spawn == NULL)
                return 0;
 
        if (ai->getRespawnCounter() > 1) {
@@ -22,7 +22,7 @@ int TheaterSpawnObserverImplementation::notifyObserverEvent(unsigned int eventTy
 
                if (spawnedCreatures.isEmpty()) {
 
-                       Reference<Task*> task = new DespawnTheaterTask(theater);
+                       Reference<Task*> task = new DespawnDynamicSpawnTask(spawn);
                        task->schedule(2 * 60 * 1000);
 
                        return 1;
@@ -31,7 +31,7 @@ int TheaterSpawnObserverImplementation::notifyObserverEvent(unsigned int eventTy
                return 0;
        }
 
-       Zone* zone = theater->getZone();
+       Zone* zone = spawn->getZone();
 
        if (zone == NULL)
                return 0;
@@ -42,8 +42,8 @@ int TheaterSpawnObserverImplementation::notifyObserverEvent(unsigned int eventTy
        return 0;
 }
 
-void TheaterSpawnObserverImplementation::spawnInitialMobiles(TangibleObject* theater) {
-       if (theater->getZone() == NULL)
+void DynamicSpawnObserverImplementation::spawnInitialMobiles(SceneObject* building) {
+       if (building->getZone() == NULL)
                return;
 
        int spawnLimitAdjustment = difficulty - 2;
@@ -80,13 +80,13 @@ void TheaterSpawnObserverImplementation::spawnInitialMobiles(TangibleObject* the
 
                float tamingChance = creatureTemplate->getTame();
 
-               CreatureManager* creatureManager = theater->getZone()->getCreatureManager();
+               CreatureManager* creatureManager = building->getZone()->getCreatureManager();
 
                for (int j = 0; j < numberToSpawn; j++) {
 
-                       float x = theater->getPositionX() + (size - System::random(size * 20) / 10.0f);
-                       float y = theater->getPositionY() + (size - System::random(size * 20) / 10.0f);
-                       float z = theater->getZone()->getHeight(x, y);
+                       float x = building->getPositionX() + (size - System::random(size * 20) / 10.0f);
+                       float y = building->getPositionY() + (size - System::random(size * 20) / 10.0f);
+                       float z = building->getZone()->getHeight(x, y);
 
                        ManagedReference<CreatureObject*> creo = NULL;
 
@@ -110,7 +110,7 @@ void TheaterSpawnObserverImplementation::spawnInitialMobiles(TangibleObject* the
                                ai->setHomeLocation(x, z, y);
                                ai->setRespawnTimer(0);
                                ai->resetRespawnCounter();
-                               ai->setHomeObject(theater);
+                               ai->setHomeObject(building);
 
                                spawnedCreatures.add(creo);
 
index 5175cdc..5e9d585 100644 (file)
@@ -115,4 +115,8 @@ class SpawnObserver extends Observer implements Logger {
        public boolean isTheaterSpawnObserver() {
                return false;
        }
+
+       public boolean isDynamicSpawnObserver() {
+               return false;
+       }
 }
index 509c1a5..a503aca 100755 (executable)
@@ -89,15 +89,13 @@ public:
                        return GENERALERROR;
 
                if (!args.hasMoreTokens()) {
-                       creature->sendSystemMessage("Spawn: /createSpawningElement spawn path/to/object.iff");
+                       creature->sendSystemMessage("Spawn: /createSpawningElement spawn lairTemplate/IffObjectPath <level>");
                        creature->sendSystemMessage("Delete: /createSpawningElement delete oid");
-                       creature->sendSystemMessage("Lair: /createSpawningElement lair lair_template level");
-                       creature->sendSystemMessage("Theater: /createSpawningElement theater lair_template level");
                        return INVALIDPARAMETERS;
                }
 
-               String itemtype;
-               args.getStringToken(itemtype);
+               String action;
+               args.getStringToken(action);
 
                ZoneServer* zserv = server->getZoneServer();
 
@@ -105,14 +103,46 @@ public:
                        return GENERALERROR;
 
                try {
-                       if (itemtype.toLowerCase() == "spawn") {
+                       if (action.toLowerCase() == "spawn") {
                                String objectTemplate;
                                args.getStringToken(objectTemplate);
-
                                float x = creature->getPositionX();
                                float y = creature->getPositionY();
                                float z = creature->getPositionZ();
 
+                               LairTemplate* lair = CreatureTemplateManager::instance()->getLairTemplate(objectTemplate.hashCode());
+
+                               if (lair != NULL) {
+                                       if (creature->getParent() != NULL) {
+                                               creature->sendSystemMessage("You need to be outside and unmounted to spawn that");
+
+                                               return GENERALERROR;
+                                       }
+
+                                       CreatureManager* creatureManager = creature->getZone()->getCreatureManager();
+
+                                       int level = 10;
+                                       if (args.hasMoreTokens()) {
+                                               level = args.getIntToken();
+                                       }
+
+                                       if (level < 1)
+                                               level = 1;
+                                       else if (level > 300)
+                                               level = 300;
+
+                                       SceneObject* sceno = creatureManager->spawn(objectTemplate.hashCode(), level, 2, x, z, y, 25);
+
+                                               if (sceno != NULL) {
+                                               creature->sendSystemMessage("lair spawned");
+                                               return SUCCESS;
+                                       } else {
+                                               creature->sendSystemMessage("error spawning lair");
+                                               return GENERALERROR;
+                                       }
+
+                               }
+
                                SharedStructureObjectTemplate* serverTemplate = dynamic_cast<SharedStructureObjectTemplate*>(TemplateManager::instance()->getTemplate(objectTemplate.hashCode()));
                                if (serverTemplate != NULL) {
                                        if (creature->getParent() != NULL) {
@@ -149,13 +179,10 @@ public:
 
                                object->createChildObjects();
 
-                               //object->insertToZone(creature->getZone());
-
-
                                uint64 objectID = object->getObjectID();
                                creature->sendSystemMessage("oid: " + String::valueOf(objectID));
 
-                       } else if (itemtype.toLowerCase() == "delete") {
+                       } else if (action.toLowerCase() == "delete") {
 
                                String chatObjectID;
                                args.getStringToken(chatObjectID);
@@ -185,68 +212,10 @@ public:
 
                                creature->sendSystemMessage("Object " + chatObjectID + " deleted.");
 
-                       } else if (itemtype.toLowerCase() == "lair" || itemtype.toLowerCase() == "theater") {
-                               String lairTemplate;
-                               args.getStringToken(lairTemplate);
-
-                               if (creature->getParent() != NULL) {
-                                       creature->sendSystemMessage("You need to be outside and unmounted to execute this command");
-
-                                       return GENERALERROR;
-                               }
-
-                               unsigned int lairHashCode = lairTemplate.hashCode();
-
-                               LairTemplate* lair = CreatureTemplateManager::instance()->getLairTemplate(lairHashCode);
-
-                               if (lair == NULL) {
-                                       creature->sendSystemMessage("You must specify a valid lair template.");
-                                       return GENERALERROR;
-                               }
-
-                               CreatureManager* creatureManager = creature->getZone()->getCreatureManager();
-
-                               if (itemtype.toLowerCase() == "lair") {
-                                       if (lair->getBuildingType() != LairTemplate::LAIR) {
-                                               creature->sendSystemMessage("Template must be a lair type.");
-                                               return GENERALERROR;
-                                       }
-
-                                       unsigned int faction = lair->getFaction();
-                                       int level = args.getIntToken();
-
-                                       if (level < 1)
-                                               level = 1;
-                                       else if (level > 300)
-                                               level = 300;
-
-                                       TangibleObject* tano = creatureManager->spawnLair(lairTemplate.hashCode(), level, 2, creature->getPositionX(), creature->getPositionZ(), creature->getPositionY(), faction);
-
-                                       if (tano != NULL)
-                                               creature->sendSystemMessage("lair spawned");
-                                       else
-                                               creature->sendSystemMessage("error spawning lair");
-
-                               } else if (itemtype.toLowerCase() == "theater") {
-
-                                       if (lair->getBuildingType() != LairTemplate::THEATER) {
-                                               creature->sendSystemMessage("Template must be a theater type.");
-                                               return GENERALERROR;
-                                       }
-
-                                       TangibleObject* tano = creatureManager->spawnTheater(lairTemplate.hashCode(), 2, creature->getPositionX(), creature->getPositionZ(), creature->getPositionY());
-
-                                       if (tano != NULL)
-                                               creature->sendSystemMessage("theater spawned");
-                                       else
-                                               creature->sendSystemMessage("error spawning theater");
-                               }
                        }
                } catch (Exception& e) {
-                       creature->sendSystemMessage("Spawn: /createSpawningElement spawn path/to/object.iff");
+                       creature->sendSystemMessage("Spawn: /createSpawningElement spawn lairTemplate/IffObjectPath <level>");
                        creature->sendSystemMessage("Delete: /createSpawningElement delete oid");
-                       creature->sendSystemMessage("Lair: /createSpawningElement lair lair_template level");
-                       creature->sendSystemMessage("Theater: /createSpawningElement theater lair_template");
                }
 
                return SUCCESS;
diff --git a/MMOCoreORB/src/server/zone/objects/creature/events/DespawnDynamicSpawnTask.h b/MMOCoreORB/src/server/zone/objects/creature/events/DespawnDynamicSpawnTask.h
new file mode 100644 (file)
index 0000000..e38cbcf
--- /dev/null
@@ -0,0 +1,29 @@
+
+#ifndef DESPAWNDYNAMICSPAWNTASK_H_
+#define DESPAWNDYNAMICSPAWNTASK_H_
+
+#include "server/zone/objects/scene/SceneObject.h"
+
+class DespawnDynamicSpawnTask : public Task {
+       ManagedReference<SceneObject*> spawn;
+
+public:
+       DespawnDynamicSpawnTask(SceneObject* sceno) {
+               spawn = sceno;
+       }
+
+       void run() {
+               Locker locker(spawn);
+
+               Zone* zone = spawn->getZone();
+
+               if (zone == NULL)
+                       return;
+
+               spawn->destroyObjectFromWorld(true);
+
+       }
+};
+
+
+#endif /* DESPAWNDYNAMICSPAWNTASK_H_ */
diff --git a/MMOCoreORB/src/server/zone/objects/creature/events/DespawnTheaterTask.h b/MMOCoreORB/src/server/zone/objects/creature/events/DespawnTheaterTask.h
deleted file mode 100644 (file)
index ef4e36f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-#ifndef DESPAWNTHEATERTASK_H_
-#define DESPAWNTHEATERTASK_H_
-
-#include "server/zone/objects/tangible/TangibleObject.h"
-
-class DespawnTheaterTask : public Task {
-       ManagedReference<TangibleObject*> theater;
-
-public:
-       DespawnTheaterTask(TangibleObject* tano) {
-               theater = tano;
-       }
-
-       void run() {
-               Locker locker(theater);
-
-               Zone* zone = theater->getZone();
-
-               if (zone == NULL)
-                       return;
-
-               theater->destroyObjectFromWorld(true);
-
-       }
-};
-
-
-#endif /* DESPAWNTHEATERTASK_H_ */
index 88e85e3..3a12a91 100644 (file)
@@ -12,7 +12,6 @@ class ObserverType {
 public:
        const static int LAIR = 1;
        const static int IMAGEDESIGNPOSITION = 2;
-       const static int THEATER = 3;
        const static int SCREENPLAY = 4;
 };
 
index 2fe0cf3..d9ed88d 100644 (file)
@@ -171,14 +171,25 @@ int CampKitMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject,
                                return 0;
                        }
 
-                       if(scno != NULL && scno->getObserverCount(ObserverEventType::OBJECTDESTRUCTION) > 0 &&
-                                       scno->getDistanceTo(player) <= scno->getObjectTemplate()->getNoBuildRadius() + campStructureData->getRadius()) {
-
-                               SortedVector<ManagedReference<Observer* > > observers = scno->getObservers(ObserverEventType::OBJECTDESTRUCTION);
-                               for(int j = 0; j < observers.size(); ++j) {
-                                       if(observers.get(j)->isObserverType(ObserverType::LAIR)) {
-                                               player->sendSystemMessage("@camp:error_lair_too_close");
-                                               return 0;
+                       if(scno != NULL && scno->getDistanceTo(player) <= scno->getObjectTemplate()->getNoBuildRadius() + campStructureData->getRadius()) {
+
+                               if (scno->getObserverCount(ObserverEventType::OBJECTDESTRUCTION) > 0) {
+                                       SortedVector<ManagedReference<Observer* > > observers = scno->getObservers(ObserverEventType::OBJECTDESTRUCTION);
+                                       for(int j = 0; j < observers.size(); ++j) {
+                                               if(observers.get(j)->isObserverType(ObserverType::LAIR)) {
+                                                       player->sendSystemMessage("@camp:error_lair_too_close");
+                                                       return 0;
+                                               }
+                                       }
+                               }
+
+                               if (scno->getObserverCount(ObserverEventType::CREATUREDESPAWNED) > 0) {
+                                       SortedVector<ManagedReference<Observer* > > observers2 = scno->getObservers(ObserverEventType::CREATUREDESPAWNED);
+                                       for(int j = 0; j < observers2.size(); ++j) {
+                                               if(observers2.get(j)->isObserverType(ObserverType::LAIR)) {
+                                                       player->sendSystemMessage("@camp:error_lair_too_close");
+                                                       return 0;
+                                               }
                                        }
                                }
                        }