include library.space_utils; include library.objvar_mangle; include library.space_quest; include library.space_create; include library.ship_ai; include library.utils; include library.space_battlefield; include java.lang.Math; include library.hue; // basic spawner //Burninated messageHandler getSpawnerData() { if(hasObjVar(self, "strAsteroidType")) { //LOG("space", "Spawning us some asteroids!"); if(utils.checkConfigFlag("ScriptFlags", "spawnersOn")) { messageTo(self, "startSpawning",null, 3, false); } return SCRIPT_CONTINUE; } if(!hasObjVar(self, "strDefaultBehavior")) { //LOG("space", "Stopping because no default behavior exists! and I am at "+getLocation(self)); return SCRIPT_CONTINUE; } string strDefaultBehavior = getStringObjVar(self, "strDefaultBehavior"); if((strDefaultBehavior=="patrol")||(strDefaultBehavior=="patrolNoRecycle")) { ///LOG("space", "We're doing our thang!"); // we need to get our patrol points(transforms in fact) string[] strPatrolPoints = objvar_mangle.getMangledStringArrayObjVar(self, "strPatrolPoints"); if(strPatrolPoints==null) { //LOG("space", "HUGE PROBLEM WITH "+self+" NO PATROL POINTS and I am at "+getLocation(self)); return SCRIPT_CONTINUE; } resizeable transform[] trPatrolPoints = new transform[0]; obj_id[] objTestObjects = getAllObjectsWithTemplate(getLocation(self), 320000, "object/tangible/space/content_infrastructure/basic_patrol_point.iff"); //LOG("space", "length is "+objTestObjects.length); if(objTestObjects==null) { //LOG("space", "HUGE PROBLEM WITH OBJECT "+self+"and I am at "+getLocation(self)); return SCRIPT_CONTINUE; } for(int intI =0; intI=strWaves.length) { intWave = 0; utils.setScriptVar(self, "intWave", intWave); float fltMinResetTime = getFloatObjVar(self, "fltMinResetTime"); float fltMaxResetTime = getFloatObjVar(self, "fltMaxResetTime"); float fltTime = rand(fltMinResetTime, fltMaxResetTime); // time is the spawner reset time //LOG("space", "respawn time for global spawner is "+fltTime); messageTo(self, "spawnNextWave", null, fltTime, false); } else { // time is the wave reset time utils.setScriptVar(self, "intWave", intWave); float fltMinWaveSpawnTime = getFloatObjVar(self, "fltMinWaveSpawnTime"); float fltMaxWaveSpawnTime = getFloatObjVar(self, "fltMaxWaveSpawnTime"); float fltTime = rand(fltMinWaveSpawnTime, fltMaxWaveSpawnTime); //LOG("space", "respawn time for individual wave is "+fltTime); messageTo(self, "spawnNextWave", null, fltTime, false); } } else { utils.setScriptVar(self, "intWavePopulation", intWavePopulation); } } return SCRIPT_CONTINUE; } messageHandler respawnAsteroid() { if(!isSpawnerActivated(self)) { return SCRIPT_CONTINUE; } string strAsteroidType = getStringObjVar(self, "strAsteroidType"); int intMinResourcePool = getIntObjVar(self, "intMinResourcePool"); int intMaxResourcePool = getIntObjVar(self, "intMaxResourcePool"); int intDangerLevel = getIntObjVar(self, "intDangerLevel"); int intDangerPct = getIntObjVar(self, "intDangerPct"); obj_id objAsteroid = createAsteroidSpawn(self, strAsteroidType, intMinResourcePool, intMaxResourcePool, intDangerLevel, intDangerPct); return SCRIPT_CONTINUE; } messageHandler respawnShip() { // when a ship dies, it'll respawn. //LOG("space", "4"); //LOG("space", "IN BATTLEFIELD"); if(!isSpawnerActivated(self)) { return SCRIPT_CONTINUE; } string[] strSpawns = objvar_mangle.getMangledStringArrayObjVar(self, "strSpawns"); float fltMinSpawnDistance = getFloatObjVar(self, "fltMinSpawnDistance"); float fltMaxSpawnDistance = getFloatObjVar(self, "fltMaxSpawnDistance"); string strDefaultBehavior = getStringObjVar(self, "strDefaultBehavior"); transform trMyLocation = getTransform_o2w(self); string strSpawn = strSpawns[rand(0, strSpawns.length-1)]; //LOG("space", "spawning "+strSpawn); if(!isSquad(strSpawn)) { obj_id objShip = createGenericSpawn(self, strSpawn, fltMinSpawnDistance, fltMaxSpawnDistance, false); if(isIdValid(objShip)) { setupSpawnerSpawn(objShip, self); } } else { resizeable obj_id[] objMembers = space_create.createSquadHyperspace(self, strSpawn, getTransform_o2p(self), 100, null); if(objMembers!=null) { setupSpawnerSpawn(objMembers, self); } } return SCRIPT_CONTINUE; } obj_id createGenericSpawn(obj_id objSpawner, string strShipType, float fltMinDistance, float fltMaxDistance, boolean boolRandomizeOrientation) { obj_id objShip = null; if(hasObjVar(objSpawner, "intLaunchFromDockingPoint")) { objShip = space_create.createShip(strShipType, getTransform_o2p(objSpawner), null); transform trTest = ship_ai.unitGetDockTransform(objSpawner, objShip); //LOG("space", "setting "+objShip+" to "+trTest); setTransform_o2p(objShip, trTest); } else { transform trSpawnLocation= space_utils.getRandomPositionInSphere(getTransform_o2w(objSpawner), fltMinDistance, fltMaxDistance, boolRandomizeOrientation); objShip = space_create.createShipHyperspace(strShipType, trSpawnLocation, null); //objShip = space_create.createShip(strShipType, trSpawnLocation, null); } if(isIdValid(objShip)) { setObjVar(objShip, "intNoDump", 1); return objShip; } return null; } obj_id createAsteroidSpawn(obj_id objSpawner, string strAsteroidType, int intMinResourcePool, int intMaxResourcePool, int intDangerLevel, int intDangerPct) { string strAsteroidTable = "datatables/space_mining/mining_asteroids.iff"; transform trSpawnLocation= space_utils.getRandomPositionInSphere(getTransform_o2w(objSpawner), 0, 1, true); obj_id objAsteroid = null; if (strAsteroidType == "iron") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "iron", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "silicaceous") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "silicaceous", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "carbonaceous") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "carbonaceous", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "ice") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "ice", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "obsidian") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "obsidian", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "diamond") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "diamond", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "crystal") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "crystal", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "petrochem") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "petrochem", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "acid") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "acid", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "cyanomethanic") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "cyanomethanic", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "sulfuric") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "sulfuric", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "methane") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "methane", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else if (strAsteroidType == "organometallic") { int choice = rand(1, 2); string template = dataTableGetString(strAsteroidTable, "organometallic", choice); objAsteroid = createObject(template, trSpawnLocation, null); } else { objAsteroid = null; } setObjVar(objAsteroid, "objParent", objSpawner); setObjVar(objAsteroid, "strAsteroidType", strAsteroidType); setObjVar(objAsteroid, "intMinResourcePool", intMinResourcePool); setObjVar(objAsteroid, "intMaxResourcePool", intMaxResourcePool); setObjVar(objAsteroid, "intDangerLevel", intDangerLevel); setObjVar(objAsteroid, "intDangerPct", intDangerPct); setObjVar(objAsteroid, "intNoDump", 1); int resourcePool = rand(intMinResourcePool, intMaxResourcePool); setMaxHitpoints(objAsteroid, resourcePool); setHitpoints(objAsteroid, resourcePool); return objAsteroid; } messageHandler destroyableCreated() { obj_id objDestroyable = params.getObjId("objDestroyable"); obj_id objParent = params.getObjId("objParent"); deltadictionary dctScriptVars = self.getScriptVars(); return SCRIPT_CONTINUE; } void addDestroyable(obj_id objParent, obj_id objDestroyable) { obj_id self = getSelf(); obj_id objMom = getObjIdObjVar(objParent, "objParent"); dictionary dctParams = new dictionary(); dctParams.put("objParent", self); dctParams.put("objDestroyable", objDestroyable); messageTo(objMom, "destroyableCreated", dctParams, 1, false); return; } void RemoveDestroyable(obj_id objParent, obj_id objDestroyable) { obj_id self = getSelf(); obj_id objMom = getObjIdObjVar(objParent, "objParent"); dictionary dctParams = new dictionary(); dctParams.put("objParent", self); dctParams.put("objDestroyable", objDestroyable); messageTo(objMom, "destroyableDestroyed", dctParams, 1, false); return; } void writeSpawner(obj_id self) { sendSystemMessageTestingOnly(self, "Writing spawner"); obj_id objSpawner = createObject("object/tangible/space/content_infrastructure/basic_iff", getTransform_o2w(self), null); string strSpawnerType = utils.getStringScriptVar(self, "strSpawnerType"); if(strSpawnerType=="generic") { string[] strSpawns = utils.getStringArrayScriptVar(self, "strSpawns"); float fltMinSpawnDistance = utils.getFloatScriptVar(self, "fltMinSpawnDistance"); float fltMaxSpawnDistance = utils.getFloatScriptVar(self, "fltMaxSpawnDistance"); float fltMinSpawnTime = utils.getFloatScriptVar(self, "fltMinSpawnTime"); float fltMaxSpawnTime = utils.getFloatScriptVar(self, "fltMaxSpawnTime"); int intSpawnCount = utils.getIntScriptVar(self, "intSpawnCount"); setObjVar(objSpawner, "strSpawnerType", strSpawnerType); setObjVar(objSpawner, "fltMinSpawnDistance",fltMinSpawnDistance); setObjVar(objSpawner, "fltMaxSpawnDistance", fltMaxSpawnDistance); setObjVar(objSpawner, "fltMinSpawnTime", fltMinSpawnTime); setObjVar(objSpawner, "fltMaxSpawnTime", fltMaxSpawnTime); setObjVar(objSpawner, "strSpawns", strSpawns); } string strDefaultBehavior = utils.getStringScriptVar(self, "strDefaultBehavior"); setObjVar(objSpawner, "strDefaultBehavior", strDefaultBehavior); if(strDefaultBehavior=="loiter") { float fltMinLoiterDistance = utils.getFloatScriptVar(self, "fltMinLoiterDistance"); float fltMaxLoiterDistance = utils.getFloatScriptVar(self, "fltMaxLoiterDistance"); setObjVar(objSpawner, "fltMinLoiterDistance", fltMinLoiterDistance); setObjVar(objSpawner, "fltMaxLoiterDistance", fltMaxLoiterDistance); } else if(strDefaultBehavior=="patrol") { // patrol points? are tehse transfroms? string strPatrolPointName = utils.getStringScriptVar(self, "strPatrolPointName"); resizeable string[] strPatrolPoints = new string[0]; obj_id[] objPatrolPoints = utils.getObjIdArrayScriptVar(self, "objPatrolPoints"); for(int intI = 0; intI0) { setObjVar(objSpawner, "strPatrolPoints", strPatrolPoints); } utils.setScriptVar(objSpawner, "objPatrolPoints", objPatrolPoints); // NAME THE BASTICHES } } boolean isSquad(string strSpawn) { int intIndex = strSpawn.indexOf("squad_"); if(intIndex>-1) { return true; } return false; }