trigger OnInitialize() { requestPreloadCompleteTrigger(self); return SCRIPT_CONTINUE; } trigger OnPreloadComplete() { if(!hasObjVar(self, "spawn.object")) return SCRIPT_CONTINUE; LOG("bomb_spawner","OnPreloadComplete"); // If an obj oid exists, check it. If it is still around, just exit. // If not remove the oid if(hasObjVar(self, "spawn.oid")) { obj_id currentObject = getObjIdObjVar(self, "spawn.oid"); if(!isValidId(currentObject) || !exists(currentObject)) { removeObjVar(self, "spawn.oid"); } else return SCRIPT_CONTINUE; } string objectName = getStringObjVar(self, "spawn.object"); if(objectName == null || objectName.equals("")) return SCRIPT_CONTINUE; location spawnerLocation = getLocation(self); if(spawnerLocation == null) return SCRIPT_CONTINUE; obj_id spawnedObject = createObject(objectName, spawnerLocation); if(!isValidId(spawnedObject) || !exists(spawnedObject)) return SCRIPT_CONTINUE; setObjVar(self, "spawn.oid", spawnedObject); setObjVar(spawnedObject, "spawn.spawner", self); if(hasObjVar(self, "collection.aggro")) setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self,"collection.aggro")); LOG("bomb_spawner","spawnedObject: "+spawnedObject); return SCRIPT_CONTINUE; } messageHandler handleTangibleRespawn() { if(!hasObjVar(self, "spawn.object")) return SCRIPT_CONTINUE; LOG("bomb_spawner","handleTangibleRespawn"); // If an obj oid exists, check it. If it is still around, just exit. // If not remove the oid if(hasObjVar(self, "spawn.oid")) { obj_id currentObject = getObjIdObjVar(self, "spawn.oid"); LOG("bomb_spawner","found old oid: "+currentObject); if(!isValidId(currentObject) || !exists(currentObject)) { LOG("bomb_spawner","removing Oid: "+currentObject); removeObjVar(self, "spawn.oid"); } else return SCRIPT_CONTINUE; } string objectName = getStringObjVar(self, "spawn.object"); if(objectName == null || objectName.equals("")) return SCRIPT_CONTINUE; location spawnerLocation = getLocation(self); if(spawnerLocation == null) return SCRIPT_CONTINUE; obj_id spawnedObject = createObject(objectName, spawnerLocation); if(!isValidId(spawnedObject) || !exists(spawnedObject)) return SCRIPT_CONTINUE; setObjVar(self, "spawn.oid", spawnedObject); setObjVar(spawnedObject, "spawn.spawner", self); if(hasObjVar(self, "collection.aggro")) setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self,"collection.aggro")); return SCRIPT_CONTINUE; } messageHandler handleTangibleDestroy() { if(!hasObjVar(self, "spawn.oid")) return SCRIPT_CONTINUE; obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid"); if(!isValidId(spawnedObject) || !exists(spawnedObject)) return SCRIPT_CONTINUE; destroyObject(spawnedObject); removeObjVar(self, "spawn.oid"); return SCRIPT_CONTINUE; } trigger OnRemovingFromWorld() { if(!hasObjVar(self, "spawn.oid")) return SCRIPT_CONTINUE; obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid"); if(!isValidId(spawnedObject) || !exists(spawnedObject)) return SCRIPT_CONTINUE; destroyObject(spawnedObject); removeObjVar(self, "spawn.oid"); return SCRIPT_CONTINUE; }