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

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

this.locatePlayer = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotePython180");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithPrimaryRole("coyoteAnoconda180");
		if (this.shArray.length == 0) {
			this.shArray = system.shipsWithRole("coyotemambaescort");
			if (this.shArray.length == 0) {} else {
				this.ship.target = this.shArray[0];
				this.ship.reactToAIMessage("VIPER_FOUND");
				return;
			}
		} else {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
			return;
		}
	} 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);
			return;
		} else {}
	}
	if (missionVariables.Coyote_KatikHunt >= 5) {
		this.ship.reactToAIMessage("GO_TO_STATION");
		this.ship.commsMessage(expandDescription("[COYOTE_S180_03]"), player.ship);
		return;

	}
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_01]"), player.ship);
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {}

this.informPlayer2 = function () {}

this.shipStartAttack = function () {
	if (missionVariables.Coyote_KatikHunt >= 5) {
		this.ship.reactToAIMessage("GO_TO_STATION");
		this.ship.commsMessage(expandDescription("[COYOTE_S180_03]"), player.ship);
		return;

	}
	this.shArray = system.shipsWithPrimaryRole("coyotePython180");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithPrimaryRole("coyoteAnoconda180");
		if (this.shArray.length == 0) {
			this.shArray = system.shipsWithRole("coyotemambaescort");
			if (this.shArray.length == 0) {
				this.ship.reactToAIMessage("NOTHING_FOUND");
			} else {
				this.ship.target = this.shArray[0];
				this.ship.reactToAIMessage("VIPER_FOUND");
			}
		} else {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
			this.ship.commsMessage(expandDescription("[COYOTE_S180_02]"), player.ship);
		}
		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");
		}
	}
}