"use strict";
this.name = "coyoteLobo4";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteLebo4.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython200");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithRole("coyotemambaescort");
		if (this.shArray.length == 0) {
			this.ship.reactToAIMessage("NOTHING_FOUND");
		} else {
			if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
				this.ship.target = this.shArray[0];
				this.ship.reactToAIMessage("VIPER_FOUND");
				this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
			} else {
				this.ship.reactToAIMessage("NOTHING_FOUND");
			}
		}
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor200 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython200");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor200E = function () {
	this.shArray = system.shipsWithRole("coyotemambaescort");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			//this.ship.reactToAIMessage("TARGET_FAR");
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.scanFor201 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython201");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor201E = function () {
	this.shArray = system.shipsWithRole("coyotemambaescort1");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			//this.ship.reactToAIMessage("TARGET_FAR");
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.scanFor202 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython202");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor202E = function () {
	this.shArray = system.shipsWithRole("coyotemambaescort2");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			//this.ship.reactToAIMessage("TARGET_FAR");
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.scanFor203 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython203");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor203E = function () {
	this.shArray = system.shipsWithRole("coyotemambaescort3");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("NOTHING_FOUND");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("TARGET_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		} else {
			//this.ship.reactToAIMessage("TARGET_FAR");
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.informPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S200_01]"), player.ship);
	mission.unmarkSystem(185);
	mission.markSystem(128);
	worldScripts["Coyote-Main"].setMissionInstructions("CE_MI_S_210_01");
	missionVariables.Coyote_status = "STAGE_210";
}

this.locateHermit = function () {
	this.playerArray = system.shipsWithPrimaryRole("coyotekatikrockhermit");
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(player.ship.position) < 5000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("HERMIT_FOUND");
		}
	}
}