| Config/script.js | this.name					= "stealth_missionScript";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Mission script for Stealth OXP.";
this.version				= "1.05";
this.startUp = function()
	{
	// mission has already been rejected or completed, clean up and remove active script parts
	if(missionVariables.stealth_mission == "CASE_CLOSED") 
		{
		this.cleanUp();
		return;
		}
	 
	//initialise mission variables
	if(!missionVariables.stealth_mission) // mission general status
		{ missionVariables.stealth_mission = "OFFER"; }
	if(!missionVariables.stealth_barraCount) // how many barracuda's launched
		{ missionVariables.stealth_barraCount = 0; }
		
	if(!missionVariables.stealth_barraKills) // and how many killed by the player
		{ missionVariables.stealth_barraKills = 0; }
	}
	
this.cleanUp = function() // get rid of active script elements if no longer needed.
		{
		delete this.startUp;
		delete this.playerEnteredNewGalaxy;
		delete this.missionScreenOpportunity;
		delete this.choice;
		mission.setInstructionsKey(null);
		return;
		}
this.missionScreenOpportunity = function()
	{	
	// next check if we have any conditions preventing the offering or continuing of the mission
	if(!player.ship.docked // we're in space
			|| player.score < 512 // need to be dangerous rank to begin
			|| galaxyNumber != 2 // we're not in G3
			|| !player.ship.dockedStation.isMainStation // if we're not at the main station
			) 
		{ return; }
	
	if(system.ID === 131) // if we're at Lequena
		{
		if(player.ship.docked && player.ship.dockedStation.isMainStation && missionVariables.stealth_mission === "GO_GET_EM" && this.dockHint === "NO")
			{
			this.dockHint = "YES";
			mission.runScreen({title: "Anyone seen old Jeeq?", messageKey:"stealth_hint"});
			return;
			}
		}
	
	if(system.ID === 116) // if we're at Beenboer
		{
		switch(missionVariables.stealth_mission)
			{
			case "OFFER": // make the initial offer
				{
				mission.runScreen({title: "Catch the Barracuda", messageKey:"stealth_initialOffer", choicesKey:"stealth_choices"}, this.choice);
				break;
				}
			case "REJECTED": // player said no
				{
				missionVariables.stealth_mission = "CASE_CLOSED";
				mission.setInstructionsKey(null);
				mission.runScreen({title: "Ah well...", messageKey:"stealth_rejected"});
				break;
				}
			case "ACCEPTED": // player said yes
				{
				missionVariables.stealth_mission = "GO_GET_EM";
				mission.setInstructionsKey("stealth_missionShort");
				mission.markSystem(131);
				mission.runScreen({title: "Final briefing", messageKey:"stealth_accepted"});
				break;
				}
			case "BASE_DESTROYED": // mission over - base destroyed
				{
				missionVariables.stealth_mission = "CASE_CLOSED";
				mission.setInstructionsKey(null);
				mission.unmarkSystem(116);
				switch(missionVariables.stealth_barraKills)
					{
					case(6):
						{
						mission.runScreen({title: "Mission accomplished", messageKey:"stealth_allBarraDestroyed"});
						player.credits += 2000;
						break;
						}
					case(5):
					case(4):
					case(3):
						{
						missionVariables.stealth_award = missionVariables.stealth_barraKills * 250;
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_someBarraDestroyed"});
						player.credits += missionVariables.stealth_award;
						break;
						}
					case(2):
					case(1):
						{
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_fewBarraDestroyed"});
						break;
						}					
					case(0):
						{
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_noBarraDestroyed"});
						break;
						}
					}
				break;	
				}
			case "BASE_INTACT": // mission over - base intact
				{
				missionVariables.stealth_mission = "CASE_CLOSED";
				mission.setInstructionsKey(null);
				mission.unmarkSystem(116);
				switch(missionVariables.stealth_barraKills)
					{
					case(6):
						{
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_allBarraIntact"});
						player.credits += 1000;
						break;
						}
					case(5):
					case(4):
					case(3):
						{
						missionVariables.stealth_award = missionVariables.stealth_barraKills * 100;
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_someBarraIntact"});
						player.credits += missionVariables.stealth_award;
						break;
						}
					case(2):
					case(1):
						{
						mission.runScreen({title: "Mission debriefing", messageKey:"stealth_fewBarraIntact"});
						break;
						}					
					case(0):
						{
						mission.runScreen({title: "Mission failed", messageKey:"stealth_noBarraIntact"});
						break;
						}	
					}
				break;	
				}
			}
		return;	
		}
	}
	
this.choice = function(choice)
	{
	switch(choice)
		{
		case "STEALTH_1_ACCEPTED":
			{
			missionVariables.stealth_mission = "ACCEPTED";
			break;
			}
		case "STEALTH_2_REJECTED":
			{
			missionVariables.stealth_mission = "REJECTED";
			break;
			}
		}
	}
this.playerEnteredNewGalaxy	= function(galaxyNumber)
	{ // if we jump galaxies whilst mission is running or after rejection
	if(galaxyNumber == 3 && missionVariables.stealth_mission != "OFFER")
		{
		missionVariables.stealth_mission = "CASE_CLOSED";
		this.cleanUp();
		}
	}
	
this.shipWillExitWitchspace = function()
	{
	if(galaxyNumber == 2 && system.ID == 131 && missionVariables.stealth_mission && missionVariables.stealth_mission == "GO_GET_EM" && system.countShipsWithRole("stealth_base") == 0)
		{
		this.location = (Math.random() * 0.5) + 0.25;
		system.addShipsToRoute("stealth_base", 1, this.location, "ws");
		this.dockHint = "NO";
		}
	}
	
this.playerStartedJumpCountdown = function()
	{ 
	if(galaxyNumber == 2 && system.ID == 131 && missionVariables.stealth_mission && missionVariables.stealth_mission == "GO_GET_EM")
		{
		player.commsMessage("If we leave now there will not be sufficient time to return before the Barracuda base is evacuated - the mission will be lost!");
		delete this.playerStartedJumpCountdown;
		}
	}	
	
this.shipWillLaunchFromStation = function()
	{
	this.shipWillExitWitchspace();
	delete this.shipWillLaunchFromStation;
	}
 | 
                
                    | Scripts/stealth_barracuda.js | this.name			= "stealth_barracuda";
this.author			= "Thargoid";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Script for stealth ship appearing and vanishing";
this.version		= "1.05";
this.shipSpawned = function ()
	{
	if (player.score > 512) { this.ship.awardEquipment("EQ_SHIELD_BOOSTER"); }
	if (player.score > 2560) { this.ship.awardEquipment("EQ_SHIELD_ENHANCER"); }
	missionVariables.stealth_barraCount += 1;
	}
this.stealthMode = function(state)
	{
	if(state && state == "off")
		{
		this.ship.scannerDisplayColor1 = "redColor";
		this.ship.scannerDisplayColor2 = "redColor";
		}
	else
		{
		this.ship.scannerDisplayColor1 = [0,0,0,0];
		}
	}
this.shipDied = function(who, why)
	{ missionVariables.stealth_barraKills += 1; } | 
                
                    | Scripts/stealth_base.js | this.name			= "stealth_base";
this.author			= "Thargoid";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Script for stealth base";
this.version		= "1.05";
var stealth_stealthGroup = new ShipGroup();
this.shipSpawned = function()
	{
	stealth_stealthGroup.leader = this.ship;
	this.ship.scannerDisplayColor1 = "whiteColor";
	this.ship.scannerDisplayColor2 = "grayColor";
	system.addShips("asteroid", 30, this.ship.position, 25600); // add the asteroid field
	system.addShips("stealth_mine", 10, this.ship.position, 20000); // and the mines hidden in it
	this.watchTimer = new Timer(this, this.checkPlayer, 0, 1);
	}
this.checkPlayer = function()	
	{
	if(system.countShipsWithRole("player") == 0)
		{ this.stopWatch(); }
	
	this.distanceToPlayer = this.ship.position.distanceTo(player.ship.position);	
	if(this.distanceToPlayer < 25600)
		{
		this.launchBarra();
		this.launchBarra();
		this.stopWatch();
		}
	}
		
this.playerWillEnterWitchspace = function()
	{
	this.stopWatch();
	if(missionVariables.stealth_mission != "BASE_DESTROYED")
		{ 
		missionVariables.stealth_mission = "BASE_INTACT"; 
		mission.setInstructionsKey("stealth_backToBaseFailure", "stealth_missionScript");
		}
	}
this.stopWatch = function()
	{
	if(this.watchTimer && this.watchTimer.isRunning)
		{	
		this.watchTimer.stop();
		delete this.watchTimer;
		}
	}
	
this.launchBarra = function()
	{
	if(missionVariables.stealth_barraCount < 6)
		{
		this.launchSpot = (this.ship.position.add(this.ship.orientation.vectorForward().multiply(1000)));
		var newShip = system.addShips("stealth_barracuda", 1, this.launchSpot, 100);
		newShip.group = stealth_stealthGroup;
		}
	}
this.shipBeingAttacked = this.shipBeingAttackedByCloaked = function()
	{
	this.launchChance = (this.ship.maxEnergy - this.ship.energy) / this.ship.maxEnergy;
	if(Math.random() < this.launchChance) 
		{ this.launchBarra(); }
	}
	
this.shipEnergyIsLow = function()
	{
	player.commsMessage("Emergency warning to all Barracuda, base systems are going critical!      Take that SOB out before we're toasted!", 6);	
	if(missionVariables.stealth_barraCount < 6)
		{		
		this.launchSpot = (this.ship.position.add(this.ship.orientation.vectorForward().multiply(1000)));
		var newShip = system.addShips("stealth_barracuda", (6 - missionVariables.stealth_barraCount), this.launchSpot, 200);
		newShip.group = stealth_stealthGroup;
		}	
	delete this.shipEnergyIsLow;	
	}
	
this.shipDied = function(who, why)
	{
	this.stopWatch();
	
	if(this.scanTimer && this.scanTimer.isRunning)
		{	
		this.scanTimer.stop();
		delete this.scanTimer;
		}
	
	if(why && why != "removed")
		{
		missionVariables.stealth_mission = "BASE_DESTROYED";
		mission.setInstructionsKey("stealth_backToBaseSuccess", "stealth_missionScript");
		mission.unmarkSystem(131);
		mission.markSystem(116);
		}
	}
	
this.otherShipDocked = function(whom)		
	{	
	if(whom.isPlayer)
		{ // if the player was dumb enough to dock
		mission.runScreen({title: "Bad Move!", messageKey:"stealth_getHim"}, this.damagePlayer);
		}
	}	
	
this.damagePlayer = function()
	{
	player.ship.launch();
	player.ship.takeInternalDamage();
	player.ship.takeInternalDamage();
	player.ship.energy *= (0.5 + (Math.random() * 0.5));
	player.ship.aftShield *= (0.1 + (Math.random() * 0.8));
	player.ship.forwardShield *= (0.1 + (Math.random() * 0.8));
	}	 | 
                
                    | Scripts/stealth_mine.js | this.name			= "stealth_mine";
this.author			= "Thargoid";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Script for space mine";
this.version		= "1.05";
this.activate = function()
	{
	this.ship.scannerDisplayColor1 = "yellowColor";
	this.ship.scannerDisplayColor2 = "redColor";
	this.ship.displayName = "Homing Mine (Active)";
	}
this.deactivate = function()
	{
	this.ship.scannerDisplayColor1 = "whiteColor";
	this.ship.scannerDisplayColor2 = "whiteColor";
	this.ship.displayName = "Homing Mine (Inactive)";
	}	
 |