"use strict";
this.name = "IR-sdf-leader.js";
this.author = "Ramirez";
this.copyright = "November 2010";
this.description = "Script for SDF leader";
this.version = "2.0";

//-------------------------------------------------------------------------------------------------------------
this.shipEnergyIsLow = function () {
	if (missionVariables.IR_status == "IR_sources_4" || missionVariables.IR_status == "IR_LOA_5")
		this.ship.energy = 5000;
}

//-------------------------------------------------------------------------------------------------------------
this.shipDied = function () {
	if (missionVariables.IR_status == "IR_tankers_B") {
		this.ship.spawn("IR-sdf-courier", 1);
		missionVariables.IR_status = "IR_imperator";
	}

	if (missionVariables.IR_status == "IR_landers_B") { 
		missionVariables.IR_status = "IR_imperator_alt";
	}
}

//-------------------------------------------------------------------------------------------------------------
this.shipBeingAttacked = function(whom) {
	var grp = worldScripts["IR-main-script.js"]._sdf_group;
	for (var i = 0; i < grp.ships.length; i++) {
		if (!grp.ships[i].target) {
			grp.ships[i].target = whom;
			grp.ships[i].performAttack();
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.deployTransports = function () {
	if (system.shipsWithRole("IR-sdf-transporter") != 0) {
		var coriolis = system.shipsWithRole("coriolis")[0];
		var transporter = system.shipsWithRole("IR-sdf-transporter");
		for (var i = 0; i < transporter.length; i++) {
			transporter[i].setAI("IR-sdf-transporterattackAI.plist");
		}
	}
}