Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Coyote's Run

Content

Warnings

  1. Wiki check failed: java.lang.IllegalArgumentException: Illegal character in path at index 51: http://wiki.alioth.net/index.php/Konstantin%20Katik\'s%20pod
  2. Wiki check failed: java.lang.IllegalArgumentException: Illegal character in path at index 39: http://wiki.alioth.net/index.php/Sahana\'s%20pod
  3. Wiki check failed: java.lang.IllegalArgumentException: Illegal character in path at index 44: http://wiki.alioth.net/index.php/Asp%20Pilot\'s%20pod

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description A mission pack based on the Oolite fiction short story 'Coyote', by El Viejo. A mission pack based on the Oolite fiction short story 'Coyote', by El Viejo.
Identifier oolite.oxp.Okti.Coyotes_Run oolite.oxp.Okti.Coyotes_Run
Title Coyote's Run Coyote's Run
Category Missions Missions
Author Okti Okti
Version 2.5 2.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/Coyote%27s_Run n/a
Download URL https://wiki.alioth.net/img_auth.php/c/c7/Coyotes_Run_2.5.oxz n/a
License CC-BY-SA-NC 3.0 CC-BY-SA-NC 3.0
File Size n/a
Upload date 1710967252

Documentation

Also read http://wiki.alioth.net/index.php/Coyote's%20Run

readme.txt

Coyote’s Run OXP by Okti

Introduction:
=============
This OXP is based on the Oolite fiction short story Coyote, by El Viejo. 

The mission will commence when the player jumps into Laquused in G5 with a Cloaking Device. The mission uses comms messages extensively, and the player can check the current instructions by accessing the F5F5 Manifest screen. Also, all previous mission screens can be viewed by selecting the "Coyote's Run History" item on the F4 interfaces screen when docked.

Most of the actions are scripted according to the tale and only slightly changed or extended. It would be handy to have read the tale, or to read it during the mission play, but the OXP can be enjoyed even if you haven't read the tale.

The short story Coyote, can be downloaded here: http://www.box.net/shared/vpd2ln2mr3

Installation:
=============
Inside the .zip there are two OXP's: 
(1) Coyote's Run.oxp: This is the main OXP and should be the only back you need to install. Put this in your AddOns folder.
(2) Coyote's Run for Griff.oxp: If you are *not* using Griff’s all-in-one replacemment shipset in your game, but you *do* have Griff's ships installed and want the ships in this OXP to use the Griff versions, then you should also install the Coyote's Run for Griff.oxp into your AddOns folder. This will ensure that all the ships in the OXP are Griff ships.

Credits:
========
El Viejo (Screenplay Consultant): for allowing me to script his intellectual property, correcting the mission texts, giving ideas, test running the mission, motivating me during the WIP period... in short, for directing the OXP.

Smivs: for providing textures and test playing the mission, and invaluable insights and advice.

Fatleaf (Chief Test-pilot): for testing, giving ideas, motivation and making me laugh at his comments, and his heroic efforts to ‘break’ the mission.

Mauiby de Fug: for testing, correcting typos and his kind PM’s and posts about the mission.

Svengali, Ironfist: for testing and giving ideas about placing objects in the right locations.

Wyvern: for modelling and quaternion help and also for suggestions for the mission.

Griff: for allowing me to write the overrides oxp for his shipset, and his help in providing a custom paintjob and decals for some ships.

Eric Walch: for testing the plist’s on his Mac.
PhantorGorth: for facilitating the development environment in the Oolite chatroom, and for his knowledge of JavaScript. 

All the regulars at DS's Seedy Space Bar for the 'vibes'... thanks, guys and gals! 
All OXP authors, from whose work I learnt so much, and the Oolite development team, without which many missions would not be possible.

Copyright: 
==========
This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Version History
===============
2.5
- Fixed issue with invalid references in system populator functions.

2.4
- Fixed undeclared variable error.

2.3
- Added specular maps to Avernus and the two Navy stations.
- Added Navy logo to Navy stations.

2.2
- Fixed missing variable reference error.

2.1
- Added restaurant menu to Avernus Orbital F4 screen, and disabled the F8 Market screen on the station as well.
- Tweaked the Avernus Orbital textures and shipdata entry.

2.0
- Updated Griff pack to use the latest version of the Griff normal-mapped ships.
- Updated hermit model to use standard default model.
- Corrected links to Green Gecko OXP.
- Updated some texture and image files.
- Update dock model and textures.
- Switched to use system population routines for planet and station additions.
- Added market script for Navy Stations.
- Added market to Avernus Orbital station.
- Moved the historic mission text display to an F4 interface screen (rather than overloading the F7 system data screen).
- Updated subentities to use new style definitions.
- Added "use strict"; to all script files.
- Bug fixes, spelling corrections, code refactoring and cleanup.

Equipment

Name Visible Cost [deci-credits] Tech-Level
UberTek Tractor Beam yes 100000 15+

Ships

Name
Avernus-dock
Avernus Orbital
Katik Anaconda
Katik Anaconda
Katik Anaconda
Coyote-asp-10
Coyote-asp-11
Coyote-asp-12
Coyote-asp-13
Coyote-asp-225
Coyote-asp-230
autoskimmer
Krait
Mamba
Coriolis Station
Coyote-cobra
Cameron
Cameron
Cameron
Cameron
Cameron
Cuervo
Greer
Greer
Greer
Greer
Greer
La Bruja Agent
Lobo
Lobo
Lobo
Lobo
Coyote-cobra-trio
Zorra
Zorra
Zorra
Zorra
Zorra
Escape Capsule
Greer's Escape Capsule
Coyote-ferdie-1
Coyote-ferdie-10
Coyote-ferdie-11
Coyote-ferdie-2
Coyote-ferdie-225
Coyote-ferdie-226
Coyote-ferdie-230
Coyote-ferdie-3
Coyote-ferdie-4
Coyote-gecko
Rogue Interceptor
Rogue Interceptor
Rogue Escape Pod
Coyote-interstellar-station
Coyote-interstellar-station-gg
Katik Asteroid
Katik Asteroid
Asteroid
Konstantin Katik
Katik Escort
Katik Escort
Katik Escort
Konstantin Katik\'s pod
Konstantin Katik
Katik Asteroid
Coyote-mamba-1
Katik Escort
Katik Escort
Katik Escort
Katik Escort
Sahana
Navy Base
Navy Base
Navy Base
Navy Base
Mamba
Mamba
Python
Katik Python
Katik Python
Python
Katik Python
Katik Python
Katik Python
Katik Python
Python
Python
Coyote-rock-hermit
Rogue Viper
Rogue Viper
Sahana
Sahana\'s pod
Asp Pilot\'s pod
GalCop Viper
Bribed GalCop
GalCop Viper
GalCop Viper
Rogue Viper

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/Coyote-Main.js
"use strict";
this.name = "Coyote-Main";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "A mission based On Coyote by EL Viejo.";

/*
	todo: 
		maybe implement a more 'natural' way of giving the player a full fuel tank at the start of the mission
			add a special cargo pod near the witchpoint, which, when scooped, will give the player full fuel and kick off the mission?
		have an MFD which displays the most current comms instructional message, so it doesn't get lost off the screen?
*/

this.startUp = function () {
	this.CamAndGreerTrackId = null;
	this.cam1 = null;
	this.greer1 = null;
	this.showScreen = true;
}

this.startUpComplete = function () {
	this.$initInterface(player.ship.dockedStation);
}

this.$disableMarketObserver = function $disableMarketObserver(station) {
	if (station.primaryRole == "Coyoteinterstellarstation" || station.primaryRole == "Coyoteinterstellarstationgg" || station.primaryRole == "coyoterockhermit") {
		if (worldScripts.market_ads) {
			var ma = worldScripts.market_ads;
			if (ma.guiScreenChanged) {
				ma.$cm_hold_guiScreenChanged = ma.guiScreenChanged;
				delete ma.guiScreenChanged;
			}
		}
		if (worldScripts.market_observer3) {
			var mo = worldScripts.market_observer3;
			if (mo.guiScreenChanged) {
				mo.$cm_hold_guiScreenChanged = mo.guiScreenChanged;
				delete mo.guiScreenChanged;
			}
		}
		if (worldScripts.NoMarketNotification) {
			var nmn = worldScripts.NoMarketNotification;
			if (nmn.guiScreenChanged) {
				nmn.$cm_hold_guiScreenChanged = nmn.guiScreenChanged;
				nmn.$cm_hold_guiScreenWillChange = nmn.guiScreenWillChange;
				delete nmn.guiScreenChanged;
				delete nmn.guiScreenWillChange;
			}
		}
	}
}

this.$enableMarketObserver = function $enableMarketObserver (station) {
	if (!station) return;
	if (station.primaryRole == "Coyoteinterstellarstation" || station.primaryRole == "Coyoteinterstellarstationgg" || station.primaryRole == "coyoterockhermit") {
		if (worldScripts.market_ads) {
			var ma = worldScripts.market_ads;
			if (ma.$cm_hold_guiScreenChanged) {
				ma.guiScreenChanged = ma.$cm_hold_guiScreenChanged;
				delete ma.$cm_hold_guiScreenChanged;
			}
		}
		if (worldScripts.market_observer3) {
			var mo = worldScripts.market_observer3;
			if (mo.$cm_hold_guiScreenChanged) {
				mo.guiScreenChanged = mo.$cm_hold_guiScreenChanged;
				delete mo.$cm_hold_guiScreenChanged;
			}
		}
		if (worldScripts.NoMarketNotification) {
			var nmn = worldScripts.NoMarketNotification;
			if (nmn.$cm_hold_guiScreenChanged) {
				nmn.guiScreenChanged = nmn.$cm_hold_guiScreenChanged;
				nmn.guiScreenWillChange = nmn.$cm_hold_guiScreenWillChange;
				delete nmn.$cm_hold_guiScreenChanged;
				delete nmn.$cm_hold_guiScreenWillChange;
			}
		}
	}
}

this.guiScreenChanged = function (to, from) {
	/*if (to == "GUI_SCREEN_SYSTEM_DATA" && this.showScreen && player.ship.docked) {
		this.showScreen = false;
		this.displayPreviousScreens();
	}*/
	if (to == "GUI_SCREEN_MARKET" && player.ship.docked) {
		if (player.ship.dockedStation.primaryRole == "Coyoteinterstellarstation" || player.ship.dockedStation.primaryRole == "Coyoteinterstellarstationgg") {
			mission.runScreen({
				title: "Avernus Commodity Market",
				messageKey: "Avernus_Commodity_Market",
				choicesKey: "Avernus_Commodity_Market_choices"
			}, this.choices);
		}
		if (player.ship.dockedStation.primaryRole == "coyoterockhermit") {
			mission.runScreen({
				title: "Rock Hermit Commodity Market",
				messageKey: "Labruja_Commodity_Market"
			});
		}
	}
}

this.shipSpawned = function (ship) {
	if (!player.ship.docked) {
		if (ship.primaryRole == "EQ_QC_MINE" || ship.primaryRole == "EQ_RMB_CASCADE_MISSILE" || ship.primaryRole == "EQ_RMB_LAW_MISSILE" || ship.primaryRole == "EQ_RMB_OVERRIDE_MISSILE" || ship.primaryRole == "EQ_NUKE2_MISSILE" || ship.primaryRole == "EQ_HARPOON_NUKE2_MISSILE" || ship.primaryRole == "EQ_PHOTON_MISSILE" || ship.primaryRole == "RANDOM_HITS_MINE") {
			if ((missionVariables.Coyote_status == "STAGE_200" || missionVariables.Coyote_status == "STAGE_210" || missionVariables.Coyote_status == "STAGE_220") && galaxyNumber == 4 && system.ID == 185) {
				this.shArray = system.shipsWithPrimaryRole("coyotekatikrockhermit");
				if (this.shArray.length > 0) {
					if (this.shArray[0].position.distanceTo(player.ship.position) < 25600) {
						player.consoleMessage(ship.primaryRole + " has been disarmed", 6);
						ship.remove(true);
					}
				}
			}
			if (!missionVariables.Coyote_status || missionVariables.Coyote_status == "COMPLETED") {
				return;
			}
			if (ship.position.distanceTo(player.ship.position) < 25600) {
				player.consoleMessage(ship.primaryRole + " has been disarmed", 6);
				ship.remove(true);
			}
		}
	}
}

this.shipDockedWithStation = function (station) {
	this.$initInterface(station);
	this.$disableMarketObserver(station);
}

this.shipLaunchedFromStation = function (station) {
	this.$enableMarketObserver(station);
	if (missionVariables.Coyote_status == "STAGE_310" && galaxyNumber == 4 && system.ID == 58) {
		this.station = station;
		station.launchShipWithRole("coyoteinterceptor")
	}
}

this.shipWillLaunchFromStation = function (station) {
	this.showScreen = true;
	// Anbedi
	if (missionVariables.Coyote_status == "STAGE_350" && galaxyNumber == 4 && system.ID == 20) {
		if (system.countShipsWithRole("coyotecameron4") == 0) {
			system.addShips("coyotegreer4", 1, station.position.add(station.vectorForward.multiply(5000)), 100);
			system.addShips("coyotecameron4", 1, station.position.add(station.vectorForward.multiply(5000)), 100);
		}
	}
	// Zaquesso
	/*if (galaxyNumber == 4 && system.ID == 25) {
		if (system.countShipsWithRole("CoyoteNavystation1") == 0) {
			var P = system.addPlanet("Coyote_planet1")
			P.solarGasGiant = true;
			var P2 = system.addPlanet("Coyote_planet2")
			P2.solarGasGiant = true;
			var M = system.addMoon("Coyote_moon1");
			tv = P.position.subtract(M.position).direction();

			var stationPos = M.position.add(tv.multiply(-15000));
			//stationPos.x = 267107;
			//stationPos.y = -172013;
			//stationPos.z = 563825;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = M.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
	}*/
	// Leteisan
	/*
	if (missionVariables.Coyote_status == "STAGE_200" && galaxyNumber == 4 && system.ID == 185) {
		if (system.countShipsWithRole("coyotekatikrockhermit") == 0) {
			var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
			var targetVector = system.sun.position.subtract(RH.position).direction();
			var angle = RH.heading.angleTo(targetVector);
			var cross = RH.heading.cross(targetVector).direction();
			RH.orientation = RH.orientation.rotate(cross, -angle);
			system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
			system.addShips("coyotePython200", 1, RH.position, 3000);
			system.addShips("coyotePython201", 1, RH.position, 3000);
			system.addShips("coyotePython202", 1, RH.position, 3000);
			system.addShips("coyotePython203", 1, RH.position, 3000);
			this.lobo = system.addShips("coyotelobo4", 1)[0];
			this.zorra = system.addShips("coyotezorra4", 1)[0];
			this.massedLocked = false;
			this.trackId = addFrameCallback(this.loboAndZorra.bind(this));
		}
	}
	// Leteisan
	if (missionVariables.Coyote_status == "STAGE_210" && galaxyNumber == 4 && system.ID == 185) {
		if (system.countShipsWithRole("coyotekatikrockhermit") == 0) {
			var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
			var targetVector = system.sun.position.subtract(RH.position).direction();
			var angle = RH.heading.angleTo(targetVector);
			var cross = RH.heading.cross(targetVector).direction();
			RH.orientation = RH.orientation.rotate(cross, -angle);
			system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
			system.addShips("coyotelobo5", 1, RH.position, 3000);
			system.addShips("coyotezorra5", 1, RH.position, 3000);
		}
	}
	// Leteisan
	if (missionVariables.Coyote_status == "STAGE_220" && galaxyNumber == 4 && system.ID == 185) {
		if (system.countShipsWithRole("coyotekatikrockhermit") == 0) {
			var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
			var targetVector = system.sun.position.subtract(RH.position).direction();
			var angle = RH.heading.angleTo(targetVector);
			var cross = RH.heading.cross(targetVector).direction();
			RH.orientation = RH.orientation.rotate(cross, -angle);
			system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
			system.addShips("coyotelobo5", 1, RH.position, 3000);
			system.addShips("coyotezorra5", 1, RH.position, 3000);
		}
	}
	// Tirizaan
	if (galaxyNumber == 4 && system.ID == 40) {
		if (system.countShipsWithRole("CoyoteNavystation1") == 0) {
			var stationPos = new Vector3D;
			stationPos.x = 377799;
			stationPos.y = 157513;
			stationPos.z = 624280;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
	}
	// Inmaarxe
	if (galaxyNumber == 4 && system.ID == 124) {
		if (system.countShipsWithRole("CoyoteNavystation1") == 0) {
			var stationPos = new Vector3D;
			stationPos.x = -65000;
			stationPos.y = -52600;
			stationPos.z = 809500;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
	}
	// Zaeredre
	if (galaxyNumber == 4 && system.ID == 39) {
		if (system.countShipsWithRole("CoyoteNavystation2") == 0) {
			S = system.addShipsToRoute("CoyoteNavystation2", 1, 0.5, "sp")[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
	}
	// Bizalein
	if (galaxyNumber == 4 && system.ID == 89) {
		if (system.countShipsWithRole("CoyoteNavystation2") == 0) {
			var stationPos = new Vector3D;
			stationPos.x = -67015;
			stationPos.y = 56389;
			stationPos.z = 594198;
			S = system.addShips("CoyoteNavystation2", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
	}
	// Ergeso
	if (system.ID == 87 && galaxyNumber == 4) {
		if (system.countShipsWithRole("coyoterockhermit") == 0) {
			var rh = system.addShips("coyoterockhermit", 1, Vector3D(0, 0, 3).fromCoordinateSystem("sws"))[0];
			system.addShips("asteroid", 10, rh.position, 10000);
		}
	}*/
}

this.shipWillDockWithStation = function (station) {
	if (galaxyNumber == 4) {
		if (missionVariables.Coyote_status == "STAGE_20" && system.ID == 25 && station.primaryRole == "CoyoteNavystation1") {
			player.addMessageToArrivalReport("For Capturing Ka'eli Tun, a slimmy rodent from Ririqu, you're paid a bounty of " + formatCredits(74.9, true, true));
			player.credits += 74.9;
		}
		if (missionVariables.Coyote_status == "STAGE_350" && system.ID == 39 && player.ship.dockedStation.primaryRole == "CoyoteNavystation") {
			this.cam1.remove(true);
		}
		if (missionVariables.Coyote_status == "STAGE_60") {
			this.deactivateSkimTracking()
		}
	}
}

this.shipTargetAcquired = function (target) {
	if (!target) return;
	//player.consoleMessage(target.primaryRole,3);
	if (target.primaryRole == "coyotepythonstart" && !missionVariables.Coyote_status) {
		mission.setInstructionsKey("CE_MI_S_10_01");
		player.commsMessage(expandDescription("[COYOTE_START5]"), 10);
		missionVariables.Coyote_status = "STAGE_10";
	}
}

this.systemWillPopulate = function () {
	if (galaxyNumber == 4) {
		if (system.ID == 39) {
			var posNS = Vector3D(0, 0, 0.5).fromCoordinateSystem("spu");
			system.setPopulator("coyoteNS2", {
				location: "COORDINATES",
				coordinates: posNS,
				deterministic: true,
				callback: function (pos) {
					var S = system.addShips("CoyoteNavystation2", 1, pos, 0)[0];
					var targetVector = system.mainPlanet.position.subtract(S.position).direction();
					var angle = S.heading.angleTo(targetVector);
					var cross = S.heading.cross(targetVector).direction();
					S.orientation = S.orientation.rotate(cross, -angle);
				}
			});
		}
		// Zaquesso
		if (system.ID == 25) {
			var P = system.addPlanet("Coyote_planet1");
			P.solarGasGiant = true;
			var P2 = system.addPlanet("Coyote_planet2");
			P2.solarGasGiant = true;
			var M = system.addMoon("Coyote_moon1");
			var tv = P.position.subtract(M.position).direction();
			var stationPos = M.position.add(tv.multiply(-15000));
			system.setPopulator("coyteNS1", {
				location: "COORDINATES",
				coordinates: stationPos,
				deterministic: true,
				callback: function (pos) {
					//stationPos.x = 267107;
					//stationPos.y = -172013;
					//stationPos.z = 563825;
					var S = system.addShips("CoyoteNavystation1", 1, pos, 0)[0];
					var mn = null;
					for (var i = 0; i < system.planets.length; i++) {
						if (system.planets[i].texture == "Coyotemoon.png") {
							mn = system.planets[i];
						}
					}
					var targetVector = mn.position.subtract(S.position).direction();
					var angle = S.heading.angleTo(targetVector);
					var cross = S.heading.cross(targetVector).direction();
					S.orientation = S.orientation.rotate(cross, -angle);
				}
			});
		}
		// Bizalein
		if (system.ID == 89) {
			var stationPos = new Vector3D;
			stationPos.x = -67015;
			stationPos.y = 56389;
			stationPos.z = 594198;
			system.setPopulator("coyoteNS2", {
				location: "COORDINATES",
				coordinates: stationPos,
				deterministic: true,
				callback: function (pos) {
					var S = system.addShips("CoyoteNavystation2", 1, pos, 0)[0];
					var targetVector = system.mainPlanet.position.subtract(S.position).direction();
					var angle = S.heading.angleTo(targetVector);
					var cross = S.heading.cross(targetVector).direction();
					S.orientation = S.orientation.rotate(cross, -angle);
				}
			});
		}
		// Tirizaan
		if (system.ID == 40) {
			var stationPos = new Vector3D;
			stationPos.x = 377799;
			stationPos.y = 157513;
			stationPos.z = 624280;
			system.setPopulator("coyoteNS1", {
				location: "COORDINATES",
				coordinates: stationPos,
				deterministic: true,
				callback: function (pos) {
					var S = system.addShips("CoyoteNavystation1", 1, pos, 0)[0];
					var targetVector = system.mainPlanet.position.subtract(S.position).direction();
					var angle = S.heading.angleTo(targetVector);
					var cross = S.heading.cross(targetVector).direction();
					S.orientation = S.orientation.rotate(cross, -angle);
				}
			});
		}
		// Inmaarxe
		if (system.ID == 124) {
			var stationPos = new Vector3D;
			stationPos.x = -65000;
			stationPos.y = -52600;
			stationPos.z = 809500;
			system.setPopulator("coyoteNS1", {
				location: "COORDINATES",
				coordinates: stationPos,
				deterministic: true,
				callback: function (pos) {
					var S = system.addShips("CoyoteNavystation1", 1, pos, 0)[0];
					var targetVector = system.mainPlanet.position.subtract(S.position).direction();
					var angle = S.heading.angleTo(targetVector);
					var cross = S.heading.cross(targetVector).direction();
					S.orientation = S.orientation.rotate(cross, -angle);
				}
			});
		}
		// Leteisan
		if (system.ID == 185) {
			if (missionVariables.Coyote_status == "STAGE_200") {
				var stationPos = Vector3D(0, 0, 4).fromCoordinateSystem("sws");
				system.setPopulator("coyoteKRH1", {
					location: "COORDINATES",
					coordinates: stationPos,
					callback: function (pos) {
						var RH = system.addShips("coyotekatikrockhermit", 1, pos, 0)[0];
						var targetVector = system.sun.position.subtract(RH.position).direction();
						var angle = RH.heading.angleTo(targetVector);
						var cross = RH.heading.cross(targetVector).direction();
						var cr = worldScripts["Coyote-Main"];
						RH.orientation = RH.orientation.rotate(cross, -angle);
						system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
						system.addShips("coyotePython200", 1, RH.position, 3000);
						system.addShips("coyotePython201", 1, RH.position, 3000);
						system.addShips("coyotePython202", 1, RH.position, 3000);
						system.addShips("coyotePython203", 1, RH.position, 3000);
						cr.lobo = system.addShips("coyotelobo4", 1)[0];
						cr.zorra = system.addShips("coyotezorra4", 1)[0];
						cr.massedLocked = false;
						cr.trackId = addFrameCallback(cr.loboAndZorra.bind(cr));
					}
				});
			} else if (missionVariables.Coyote_status == "STAGE_210" || missionVariables.Coyote_status == "STAGE_220") {
				var stationPos = Vector3D(0, 0, 4).fromCoordinateSystem("sws");
				system.setPopulator("coyoteKRH1", {
					location: "COORDINATES",
					coordinates: stationPos,
					callback: function (pos) {
						var RH = system.addShips("coyotekatikrockhermit", 1, pos, 0)[0];
						var targetVector = system.sun.position.subtract(RH.position).direction();
						var angle = RH.heading.angleTo(targetVector);
						var cross = RH.heading.cross(targetVector).direction();
						RH.orientation = RH.orientation.rotate(cross, -angle);
						system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
						system.addShips("coyotelobo5", 1, RH.position, 3000);
						system.addShips("coyotezorra5", 1, RH.position, 3000);
					}
				});
			}
		}
		// Ergeso
		if (system.ID == 87) {
			var stationPos = Vector3D(0, 0, 3).fromCoordinateSystem("sws");
			system.setPopulator("coyoteRH1", {
				location: "COORDINATES",
				coordinates: stationPos,
				deterministic: true,
				callback: function (pos) {
					if (system.countShipsWithRole("coyoterockhermit") == 0) {
						var S = system.addShips("coyoterockhermit", 1, pos, 0)[0];
						system.addShips("asteroid", 10, S.position, 10000);
					}
				}
			});
		}
	}
}

this.interstellarSpaceWillPopulate = function () {
	if (this.addInterstellarPlanet) {
		var stationPos = new Vector3D;
		stationPos.x = 22172;
		stationPos.y = -20312;
		stationPos.z = 696652;
		system.setPopulator("coyoteNS2a", {
			location: "COORDINATES",
			coordinates: stationPos,
			deterministic: true,
			callback: function (pos) {
				var P = system.addPlanet("Coyote_interstellar_planet");
				P.solarGasGiant = true;
				var stn = "Coyoteinterstellarstation";
				if (worldScripts["ev_green_gecko"]) {
					//log("Coyote-Main", "gg");
					stn = "Coyoteinterstellarstationgg";
				} else {
					//log("Coyote-Main", "not gg");
				}
				var S = system.addShips(stn, 1, pos, 0)[0];
				// add an event to track when ships are launched - so we can attached destinations to shuttles

				var targetVector = P.position.subtract(S.position).direction();
				var angle = S.heading.angleTo(targetVector);
				var cross = S.heading.cross(targetVector).direction();
				S.orientation = S.orientation.rotate(cross, -angle);

				var targetVector1 = S.position.subtract(player.ship.position).direction();
				var pos1 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) / 2));
				system.addShips("asteroid", 30, pos1, 30000);
				var pos2 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 1 / 6));
				system.addShips("asteroid", 30, pos2, 30000);
				var pos3 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 2 / 6));
				system.addShips("asteroid", 30, pos3, 30000);
				var pos4 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 4 / 6));
				system.addShips("asteroid", 30, pos4, 30000);
				var pos5 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 5 / 6));
				system.addShips("asteroid", 30, pos5, 30000);
			}
		});
	}
}


this.shipWillEnterWitchspace = function (cause) {
	if (galaxyNumber == 4 && ((system.ID == 55 && player.ship.targetSystem == 128) || (system.ID == 128 && player.ship.targetSystem == 55) || (system.ID == 55 && player.ship.targetSystem == 55))) {
		this.addInterstellarPlanet = true;
	}
	if (missionVariables.Coyote_status == "STAGE_60") {
		this.deactivateSkimTracking();
	}
}

this.shipWillExitWitchspace = function () {
	if (galaxyNumber == 4) {
		// Laquused - this is the start point of the mission set
		if (!missionVariables.Coyote_status && system.ID == 159 && player.ship.equipmentStatus("EQ_CLOAKING_DEVICE") == "EQUIPMENT_OK") {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					shArr[j].remove(true);
				}
				j -= 1;
			}
			system.sendAllShipsAway();
			player.ship.position = player.ship.vectorForward.multiply(50000);
			this.MST_Count = 0;
			this.MissionStartTimer = new Timer(this, this.MST, 10, 10);
		}
		// Ririqu
		if (missionVariables.Coyote_status == "STAGE_10" && system.ID == 144) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			player.ship.removeEquipment("EQ_CLOAKING_DEVICE");
			player.ship.awardEquipment("EQ_CLOAKING_DEVICE");
			mission.setInstructionsKey("CE_MI_S_20_01");
			system.addShips("coyoteferdie2", 1, player.ship.position, 6000);
			system.addShips("coyotepython2", 1, player.ship.position, 6000);
		}
		// Lazaso
		else if (missionVariables.Coyote_status == "STAGE_120" && system.ID == 128) {
			system.addShips("coyoteAnaconda", 1, player.ship.position.add(player.ship.vectorForward.multiply(6000)), 100);
			system.addShips("coyotezorra1", 1, player.ship.position.add(player.ship.vectorForward.multiply(25000)));
		}
		// Xemageat
		else if (missionVariables.Coyote_status == "STAGE_140" && system.ID == 72) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			system.addShips("coyoteviper1", 1, player.ship.position.add(player.ship.vectorForward.multiply(40000)));
			system.addShips("coyotelobo1", 1, player.ship.position, 2000);
			system.addShips("coyotezorra2", 1, player.ship.position, 2000);
		}
		// steel halo: Zaenza, Lazaso, Xemageat, Leteisan, Cecear, Tiuson
		else if (missionVariables.Coyote_status == "STAGE_160") {
			missionVariables.Coyote_jumpCount += 1;
			if (system.ID == 55 || system.ID == 128 || system.ID == 72 || system.ID == 185 || system.ID == 126 || system.ID == 100) {
				this.Stage160();
			}
		}
		// Ortema
		else if (missionVariables.Coyote_status == "STAGE_180" && system.ID == 109) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						shArr[j].remove(true);
					}
				}
				j -= 1;
			}
			missionVariables.Coyote_KatikHunt = 0;
			system.addShips("coyotezorra3", 1, player.ship.position, 6000);
			system.addShips("coyotelobo2", 1, player.ship.position, 6000);
			this.S180TimerCount = 0;
			this.S180Timer = new Timer(this, this.Stage180, 60, 120);
		}
		// Cecear
		else if (missionVariables.Coyote_status == "STAGE_225" && system.ID == 126) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						shArr[j].remove(true);
					}
				}
				j -= 1;
			}
		}
		// Leteisan
		else if (missionVariables.Coyote_status == "STAGE_227" && system.ID == 185) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {

						shArr[j].remove(true);
					}
				}
				j -= 1;
			}
			system.addShips("coyoteasp230", 2, player.ship.position.add(player.ship.vectorForward.multiply(10000)).add(player.ship.vectorRight.multiply(10000)), 2000);
			system.addShips("coyoteferdie230", 2, player.ship.position.add(player.ship.vectorForward.multiply(10000)).add(player.ship.vectorRight.multiply(10000)), 2000);
			system.addShips("coyotepython230", 2, player.ship.position.add(player.ship.vectorForward.multiply(10000)).add(player.ship.vectorRight.multiply(10000)), 2000);
			system.addShips("coyotepirateescort2", 6, player.ship.position.add(player.ship.vectorForward.multiply(10000)).add(player.ship.vectorRight.multiply(10000)), 2000);
			system.addShips("coyotesahana2", 1, player.ship.position, 1000);
			system.addShips("coyotecuervo", 1, player.ship.position.add(player.ship.vectorForward.multiply(24000)), 0);
			mission.setInstructionsKey("CE_MI_S_225_06", "Coyote-Main");
		}
		// Bizalein
		else if (missionVariables.Coyote_status == "STAGE_240" && system.ID == 89) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			system.addShips("coyoteviper2", 4, player.ship.position, 5000);
			system.addShips("coyoteferdie4", 3, player.ship.position, 5000);
		}
		// Atbiarxe SCAN
		else if (missionVariables.Coyote_status == "STAGE_280" && system.ID == 49) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			system.addShips("coyoteviperleader", 1, player.ship.position.add(player.ship.vectorForward.multiply(-5000)), 100);
		}
		// Biceri
		else if (missionVariables.Coyote_status == "STAGE_300" && system.ID == 58) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						shArr[j].remove(true);
					}
				}
				j -= 1;
			}
		}
		// Biarra
		else if (missionVariables.Coyote_status == "STAGE_310" && system.ID == 66) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			this.BiarraTimer = new Timer(this, this.BiarraBattle, 10);
			system.addShips("coyotegreer1", 1, player.ship.position, 2000);
			system.addShips("coyotecameron1", 1, player.ship.position, 2000);
		}
		// Teesbi
		else if (missionVariables.Coyote_status == "STAGE_325" && system.ID == 84) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			system.addShips("coyotepiratepython", 1, player.ship.position, 6000);
			system.addShips("coyotegreer2", 1, player.ship.position, 2000);
			system.addShips("coyotecameron2", 1, player.ship.position, 2000);
			mission.unmarkSystem(66);
			mission.markSystem(84);
			mission.setInstructionsKey("CE_MI_S_310_04");
			missionVariables.Coyote_status = "STAGE_330";
		}
		// Anbedi Scan
		else if (missionVariables.Coyote_status == "STAGE_335" && system.ID == 20) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						} else {
							if (shArr[j].bounty !== 0) {
								shArr[j].remove(true);
							}

						}
					}
				}
				j -= 1;
			}
			system.addShips("coyoteviperleader", 1, player.ship.position.add(player.ship.vectorForward.multiply(-5000)), 100);
			this.lobo = system.addShips("coyotecameron3", 1)[0];
			this.zorra = system.addShips("coyotegreer3", 1)[0];
			this.massedLocked = false;
			this.trackId = addFrameCallback(this.loboAndZorra.bind(this));
			mission.unmarkSystem(84);
			mission.markSystem(20);
			mission.setInstructionsKey("CE_MI_S_310_08");
		}
		// Zaeredre
		else if (missionVariables.Coyote_status == "STAGE_350" && system.ID == 39) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						shArr[j].remove(true);
					}
				}
				j -= 1;
			}
			system.addShips("coyotegreer5", 1, player.ship.position.add(player.ship.vectorForward.multiply(-100)));
			system.addShips("coyotecameron5", 1, player.ship.position.add(player.ship.vectorForward.multiply(-200)));
			system.addShips("coyoteasp10", 1, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);
			system.addShips("coyoteasp11", 1, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);
			system.addShips("coyoteasp12", 1, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);
			system.addShips("coyoteasp13", 1, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);
			system.addShips("coyoteferdie10", 1, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);
			system.addShips("coyoteferdie11", 2, player.ship.position.add(player.ship.vectorForward.multiply(-3000)), 100);

			/*S = system.addShipsToRoute("CoyoteNavystation2", 1, 0.5, "sp")[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);*/

			mission.setInstructionsKey("CE_MI_S_360_01");
		}
		// on the way to Xele
		else if (missionVariables.Coyote_status == "STAGE_260" && system.ID !== 65) {
			if (Math.random() > 0.30) {
				this.pirateAmbush();
			}
		}
		// Edceon,Atrare
		else if (missionVariables.Coyote_status == "STAGE_280" && (system.ID == 242 || system.ID == 125)) {
			this.pirateAmbush();
		}
		// Zaquesso
		// >> sysWillPop
		/*
		if (system.ID == 25) {
			P = system.addPlanet("Coyote_planet1")
			P.solarGasGiant = true;
			P2 = system.addPlanet("Coyote_planet2")
			P2.solarGasGiant = true;
			M = system.addMoon("Coyote_moon1");
			tv = P.position.subtract(M.position).direction();

			var stationPos = M.position.add(tv.multiply(-15000));
			//stationPos.x = 267107;
			//stationPos.y = -172013;
			//stationPos.z = 563825;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = M.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
		*/
		// Second system after Bizaar
		if (missionVariables.Coyote_status == "STAGE_55" && system.ID !== -1) {
			missionVariables.Coyote_status = "STAGE_60";
			this.sunSkimCounter = 0;
			this.sunSkimTimer = new Timer(this, this.sunSkimT, 3, 3);
		}
		// First system after Bizaar
		if (missionVariables.Coyote_status == "STAGE_50" && system.ID !== -1) {
			missionVariables.Coyote_status = "STAGE_55";
			system.addShips("coyoteferdie3", 1, player.ship.position, 10000);
			system.addShips("coyotemamba1", 1, player.ship.position, 10000);
		}
		// Ergeso
		/*
		if (system.ID == 87) {
			var rh = system.addShips("coyoterockhermit", 1, Vector3D(0, 0, 3).fromCoordinateSystem("sws"))[0];
			system.addShips("asteroid", 10, rh.position, 10000);
		}
		*/
		// interstellar space Avernus
		// >> intsysWillPop
		/*
		if (system.ID == -1 && this.addInterstellarPlanet) {
			P = system.addPlanet("Coyote_interstellar_planet")
			P.solarGasGiant = true;
			var stationPos = new Vector3D;
			stationPos.x = 22172;
			stationPos.y = -20312;
			stationPos.z = 696652;
			if (worldScripts["gg-character"]) {
				log(this.name, "gg");
				S = system.addShips("Coyoteinterstellarstationgg", 1, stationPos, 100)[0];
				var targetVector = P.position.subtract(S.position).direction();
				var angle = S.heading.angleTo(targetVector);
				var cross = S.heading.cross(targetVector).direction();
				S.orientation = S.orientation.rotate(cross, -angle);
				var targetVector1 = S.position.subtract(player.ship.position).direction();
				var pos1 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) / 2));
				system.addShips("asteroid", 30, pos1, 30000);
				var pos2 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 1 / 6));
				system.addShips("asteroid", 30, pos2, 30000);
				var pos3 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 2 / 6));
				system.addShips("asteroid", 30, pos3, 30000);
				var pos4 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 4 / 6));
				system.addShips("asteroid", 30, pos4, 30000);
				var pos5 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 5 / 6));
				system.addShips("asteroid", 30, pos5, 30000);
			} else {
				log(this.name, "not gg");
				S = system.addShips("Coyoteinterstellarstation", 1, stationPos, 100)[0];
				var targetVector = P.position.subtract(S.position).direction();
				var angle = S.heading.angleTo(targetVector);
				var cross = S.heading.cross(targetVector).direction();
				S.orientation = S.orientation.rotate(cross, -angle);
				var targetVector1 = S.position.subtract(player.ship.position).direction();
				var pos1 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) / 2));
				system.addShips("asteroid", 30, pos1, 30000);
				var pos2 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 1 / 6));
				system.addShips("asteroid", 30, pos2, 30000);
				var pos3 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 2 / 6));
				system.addShips("asteroid", 30, pos3, 30000);
				var pos4 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 4 / 6));
				system.addShips("asteroid", 30, pos4, 30000);
				var pos5 = player.ship.position.add(targetVector1.multiply(player.ship.position.distanceTo(S.position) * 5 / 6));
				system.addShips("asteroid", 30, pos5, 30000);
			}
		}
		*/
		/*
		// Bizalein
		if (system.ID == 89) {
			var stationPos = new Vector3D;
			stationPos.x = -67015;
			stationPos.y = 56389;
			stationPos.z = 594198;
			S = system.addShips("CoyoteNavystation2", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
		// Tirizaan
		if (system.ID == 40) {
			var stationPos = new Vector3D;
			stationPos.x = 377799;
			stationPos.y = 157513;
			stationPos.z = 624280;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}
		// Inmaarxe
		if (system.ID == 124) {
			var stationPos = new Vector3D;
			stationPos.x = -65000;
			stationPos.y = -52600;
			stationPos.z = 809500;
			S = system.addShips("CoyoteNavystation1", 1, stationPos, 100)[0];
			var targetVector = system.mainPlanet.position.subtract(S.position).direction();
			var angle = S.heading.angleTo(targetVector);
			var cross = S.heading.cross(targetVector).direction();
			S.orientation = S.orientation.rotate(cross, -angle);
		}*/
	}
}

this.shipExitedWitchspace = function () {
	if (galaxyNumber == 4) {
		// Leteisan
		if (system.ID == 185) {
			/*if (missionVariables.Coyote_status == "STAGE_200") {
				var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
				var targetVector = system.sun.position.subtract(RH.position).direction();
				var angle = RH.heading.angleTo(targetVector);
				var cross = RH.heading.cross(targetVector).direction();
				RH.orientation = RH.orientation.rotate(cross, -angle);
				system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
				system.addShips("coyotePython200", 1, RH.position, 3000);
				system.addShips("coyotePython201", 1, RH.position, 3000);
				system.addShips("coyotePython202", 1, RH.position, 3000);
				system.addShips("coyotePython203", 1, RH.position, 3000);
				this.lobo = system.addShips("coyotelobo4", 1)[0];
				this.zorra = system.addShips("coyotezorra4", 1)[0];
				this.massedLocked = false;
				this.trackId = addFrameCallback(this.loboAndZorra.bind(this));
			}
			else if (missionVariables.Coyote_status == "STAGE_210") {
				var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
				var targetVector = system.sun.position.subtract(RH.position).direction();
				var angle = RH.heading.angleTo(targetVector);
				var cross = RH.heading.cross(targetVector).direction();
				RH.orientation = RH.orientation.rotate(cross, -angle);
				system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
				system.addShips("coyotelobo5", 1, RH.position, 3000);
				system.addShips("coyotezorra5", 1, RH.position, 3000);
			}
			else if (missionVariables.Coyote_status == "STAGE_220") {
				var RH = system.addShips("coyotekatikrockhermit", 1, Vector3D(0, 0, 4).fromCoordinateSystem("sws"))[0];
				var targetVector = system.sun.position.subtract(RH.position).direction();
				var angle = RH.heading.angleTo(targetVector);
				var cross = RH.heading.cross(targetVector).direction();
				RH.orientation = RH.orientation.rotate(cross, -angle);
				system.addShips("coyotekatikasteroid", 10, RH.position, 12000);
				system.addShips("coyotelobo5", 1, RH.position, 3000);
				system.addShips("coyotezorra5", 1, RH.position, 3000);
			}*/
			if (missionVariables.Coyote_status == "STAGE_200") {
				this.zorra.commsMessage(expandDescription("[COYOTE_S200_00]"), player.ship);
			}
		}
		// Cecear
		if (missionVariables.Coyote_status == "STAGE_225" && system.ID == 126) {
			var shArr = system.allShips;
			var j = shArr.length - 1;
			while (j > 0) {
				if (!shArr[j].isMainStation) {
					if (!shArr[j].isBeacon) {
						if (shArr[j].position.distanceTo(player.ship.position) < 100000) {
							shArr[j].remove(true);
						}
					}
				}
				j -= 1;
			}
			system.addShips("coyotekatikboss2", 1, player.ship.position.add(player.ship.vectorForward.multiply(-5000)), 300);
			system.addShips("coyotekatikboss2escort", 1, player.ship.position.add(player.ship.vectorForward.multiply(-5000)), 300);
			system.addShips("coyotekatikboss3escort", 1, player.ship.position.add(player.ship.vectorForward.multiply(-5000)), 300);
			mission.setInstructionsKey("CE_MI_S_225_01", "Coyote-Main");
		}
		// Teesbi
		if (missionVariables.Coyote_status == "STAGE_330" && system.ID == 84) {
			mission.unmarkSystem(66);
			mission.markSystem(84);
		}
		// Zaenza
		if (missionVariables.Coyote_status == "STAGE_110" && system.ID == 55) {
			this.ComTimer = new Timer(this, this.ComTimerCB, 5);
		}
		// steel halo: Zaenza, Lazaso, Xemageat, Leteisan, Cecear, Tiuson
		if (missionVariables.Coyote_status == "STAGE_160" && (system.ID == 55 || system.ID == 128 || system.ID == 72 || system.ID == 185 || system.ID == 126 || system.ID == 100)) {
			var MessageText = "";
			if (missionVariables.Coyote_KatikHunt <= 7) {
				if (missionVariables.Coyote_jumpCount >= 3) {
					missionVariables.Coyote_jumpCount = Math.floor(Math.random() * 2) + 1;
					var SType = Math.floor(Math.random() * 2);
					MessageText = expandDescription("[COYOTE_S160_02]");
					var RType = "";
					if (SType == 0) {
						RType = "coyoteAnaconda160";
						MessageText = MessageText.replace("$$$", "Anaconda");
					} else {
						RType = "coyotePython160";
						MessageText = MessageText.replace("$$$", "Python");
					}
					var DType = Math.floor(Math.random() * 4)
					if (DType == 0) {
						system.addShipsToRoute(RType, 1, 0.25, "wp");
						MessageText = MessageText + expandDescription("[COYOTE_S160_03]");
					} else if (DType == 1) {
						system.addShipsToRoute(RType, 1, 0.50, "wp");
						MessageText = MessageText + expandDescription("[COYOTE_S160_04]");
					} else {
						system.addShipsToRoute(RType, 1, 0.75, "wp");
						MessageText = MessageText + expandDescription("[COYOTE_S160_05]");
					}
				} else {
					MessageText = expandDescription("[COYOTE_S160_06]");
				}
			} else {
				MessageText = expandDescription("[COYOTE_S160_01]");
			}
			this.agentshp.commsMessage(MessageText, player.ship);
		}
	}
}

this.playerStartedJumpCountdown = function (type) {
	if (galaxyNumber == 4) {
		this.massblocked = false;
		if (missionVariables.Coyote_status == "STAGE_280" && system.ID == 40 && player.ship.targetSystem !== 242) {
			this.massblocker = system.addShips("coyotemassblocker", 1, player.ship.position.add(player.ship.vectorForward.multiply(-50)))[0];
			this.massblocked = true;
			this.masstrackId = addFrameCallback(this.moveMass.bind(this));

		}
		if (missionVariables.Coyote_status == "STAGE_310" && system.ID == 58) {
			if (system.countShipsWithRole("coyotevipermember1") !== 4) {
				this.massblocker = system.addShips("coyotemassblocker", 1, player.ship.position.add(player.ship.vectorForward.multiply(-50)))[0];
				this.massblocked = true;
				this.masstrackId = addFrameCallback(this.moveMass.bind(this));
			}
		}
	}
}

this.playerCancelledJumpCountdown = function () {
	if (isValidFrameCallback(this.masstrackId)) {
		removeFrameCallback(this.masstrackId);
		this.massblocker.position = player.ship.position.add(player.ship.vectorForward.multiply(-1000000));
		this.massblocked = false;
	}
}

this.playerJumpFailed = function (reason) {
	if (this.massblocked) {
		if (isValidFrameCallback(this.masstrackId)) {
			removeFrameCallback(this.masstrackId);
		}
		if (missionVariables.Coyote_status == "STAGE_280" && system.ID == 40 && player.ship.targetSystem !== 242) {
			this.massblocker.position = player.ship.position.add(player.ship.vectorForward.multiply(-1000000));
			player.consoleMessage(expandDescription("[COYOTE_S280_00]"), 6);
			player.consoleMessage(expandDescription("[COYOTE_S280_01]"), 6);
			this.massblocked = false;
		}
		if (missionVariables.Coyote_status == "STAGE_310" && system.ID == 58) {
			this.massblocker.position = player.ship.position.add(player.ship.vectorForward.multiply(-1000000));
			player.consoleMessage(expandDescription("[COYOTE_S280_00]"), 6);
			player.consoleMessage(expandDescription("[COYOTE_S300_01]"), 6);
			this.massblocked = false;
		}
	}
}

this.missionScreenOpportunity = function () {
	if (galaxyNumber !== 4) {
		return;
	}
	if (!missionVariables.Coyote_status) {
		return;
	}
	if (missionVariables.Coyote_status == "COMPLETED") {
		return;
	}
	this.missionScreens();
}

this.missionScreens = function () {
	// Zaquesso navy station
	if (missionVariables.Coyote_status == "STAGE_20" && system.ID == 25 && player.ship.dockedStation.primaryRole == "CoyoteNavystation1") {
		missionVariables.Coyote_status = "STAGE_30";
		mission.setInstructionsKey("CE_MI_S_30_01");
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Zaquesso_navystation_1"
		});
	}
	// Zaquesso main station	
	else if (missionVariables.Coyote_status == "STAGE_30" && system.ID == 25 && player.ship.dockedStation.isMainStation) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Zaquesso_mainstation_1",
			choicesKey: "Coyote_Zaquesso_mainstation_1_choices"
		}, this.choices);
	}
	// Bizaar
	else if (missionVariables.Coyote_status == "STAGE_40" && system.ID == 101 && player.ship.dockedStation.isMainStation) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Bizaar_mainstation_1",
			choicesKey: "Coyote_Bizaar_mainstation_1_choices"
		}, this.choices);
	}
	// Bizalein navy station
	else if (missionVariables.Coyote_status == "STAGE_60" && system.ID == 89 && player.ship.dockedStation.primaryRole == "CoyoteNavystation2") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Bizalein_mainstation_1",
			choicesKey: "Coyote_Bizalein_mainstation_1_choices"
		}, this.choices);
	}
	// Ergeso Rock Hermit
	else if (missionVariables.Coyote_status == "STAGE_70" && system.ID == 87 && player.ship.dockedStation.primaryRole == "coyoterockhermit") {
		missionVariables.Coyote_status = "STAGE_80";
		mission.setInstructionsKey("CE_MI_S_80_01");
		mission.unmarkSystem(87);
		mission.markSystem(89);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Ergeso_rockhermit"
		});
	}
	// Bizalein
	else if (missionVariables.Coyote_status == "STAGE_80" && system.ID == 89 && player.ship.dockedStation.isMainStation) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Bizalein_mainstation_3",
			choicesKey: "Coyote_Bizalein_mainstation_3_choices"
		}, this.choices);
	}
	// Ortema
	else if (missionVariables.Coyote_status == "STAGE_90" && system.ID == 109 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_100";
		mission.setInstructionsKey("CE_MI_S_100_01");
		mission.unmarkSystem(109);
		mission.markSystem(128);
		clock.addSeconds(24 * 3600);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Ortema_mainstation"
		});
	}
	// Avernus
	else if (missionVariables.Coyote_status == "STAGE_100" && system.isInterstellarSpace && (player.ship.dockedStation.primaryRole == "Coyoteinterstellarstation" || player.ship.dockedStation.primaryRole == "Coyoteinterstellarstationgg")) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Avernus_1",
			choicesKey: "Coyote_Avernus_1_choices"
		}, this.choices);
	}
	// A station in Halo
	else if (missionVariables.Coyote_status == "STAGE_150" && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_160";
		mission.setInstructionsKey("CE_MI_S_160_01");
		missionVariables.Coyote_jumpCount = Math.floor(Math.random() * 2) + 1;
		missionVariables.Coyote_KatikHunt = 0;
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Stage_150",
			model: "coyoteAnaconda160"
		});
	}
	// A station in Halo
	else if (missionVariables.Coyote_status == "STAGE_160" && system.ID !== 100 && player.ship.dockedStation.isMainStation && missionVariables.Coyote_KatikHunt >= 7) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Stage_160_1",
			choicesKey: "Coyote_Stage_160_1_choices"
		}, this.choices);
	}
	// Tiuson
	else if (missionVariables.Coyote_status == "STAGE_170" && system.ID == 100 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_180";
		mission.setInstructionsKey("CE_MI_S_180_01");
		mission.unmarkSystem(100);
		mission.markSystem(109);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Stage_Tiuson_1",
			model: "coyotePython200"
		});
	}
	// Tiuson
	else if (missionVariables.Coyote_status == "STAGE_190" && system.ID == 100 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_200";
		mission.setInstructionsKey("CE_MI_S_200_01");
		mission.unmarkSystem(100);
		mission.markSystem(185);
		if (worldScripts["Coyote-Griff"]) {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_Tiuson_2",
				model: "coyotetriogriff",
				spinModel: false
			});
		} else {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_Tiuson_2",
				model: "coyotetrio",
				spinModel: false
			});
		}
	}
	// Avernus
	else if (missionVariables.Coyote_status == "STAGE_210" && system.isInterstellarSpace && (player.ship.dockedStation.primaryRole == "Coyoteinterstellarstation" || player.ship.dockedStation.primaryRole == "Coyoteinterstellarstationgg")) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Avernus_3",
			choicesKey: "Coyote_Avernus_3_choices"
		}, this.choices);
	}
	// Cecear
	//else if(missionVariables.Coyote_status == "STAGE_229" && system.ID == 126 && player.ship.dockedStation.isMainStation)
	//{
	//	missionVariables.Coyote_status = "STAGE_230";
	//	mission.setInstructionsKey("CE_MI_S_230_01");
	//	mission.runScreen({title: "Coyote's Run", messageKey: "Coyote_Cecear_mainstation"});
	//}
	// Leteisan
	else if (missionVariables.Coyote_status == "STAGE_229" && system.ID == 185 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_240";
		mission.setInstructionsKey("CE_MI_S_240_01");
		mission.unmarkSystem(185);
		mission.markSystem(89);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Leteisan_mainstation",
			model: "coyotesahana2"
		});
	}
	// Bizalein Navy Station
	else if (missionVariables.Coyote_status == "STAGE_240" && system.ID == 89 && player.ship.dockedStation.primaryRole == "CoyoteNavystation2") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Bizalein_navystation",
			choicesKey: "Coyote_Bizalein_navystation_choices"
		}, this.choices);
	}
	// Qulecele
	else if (missionVariables.Coyote_status == "STAGE_250" && system.ID == 152 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_260";
		mission.setInstructionsKey("CE_MI_S_260_01");
		mission.unmarkSystem(152);
		mission.markSystem(65);
		clock.addSeconds(24 * 3600);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Qulecele"
		});
	}
	// Xele
	else if (missionVariables.Coyote_status == "STAGE_260" && system.ID == 65 && player.ship.dockedStation.isMainStation) {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Xele",
			choicesKey: "Coyote_Xele_choices"
		}, this.choices);
	}
	// Tirizaan
	else if (missionVariables.Coyote_status == "STAGE_270" && system.ID == 40 && player.ship.dockedStation.primaryRole == "CoyoteNavystation1") {
		missionVariables.Coyote_status = "STAGE_280";
		mission.setInstructionsKey("CE_MI_S_280_01");
		mission.unmarkSystem(40);
		mission.markSystem(49);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Tirizaan_navystation",
			choicesKey: "Coyote_Tirizaan_navystation_choices"
		}, this.choices);
	}
	// Atbiarxe
	else if (missionVariables.Coyote_status == "STAGE_290" && system.ID == 49 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_300";
		mission.setInstructionsKey("CE_MI_S_300_01");
		mission.unmarkSystem(49);
		mission.markSystem(58);
		clock.addSeconds(48 * 3600);
		//		if(player.credits > 210000)
		//		{
		//			player.credits -= 200000;
		//			missionVariables.Coyote_prePayment = 200000;
		//		}
		//		else
		//		{
		//			missionVariablesCoyote_prePayment = player.credits -10000;
		//			player.credits = 10000;
		//		}
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Atbiarxe"
		});
	}
	// Biceri
	else if (missionVariables.Coyote_status == "STAGE_300" && system.ID == 58 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_ViperCount = 0;
		missionVariables.Coyote_status = "STAGE_310";
		mission.setInstructionsKey("CE_MI_S_310_01");
		mission.unmarkSystem(58);
		mission.markSystem(66);
		clock.addSeconds(4 * 3600);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Biceri"
		});
	}
	// Anbedi
	else if (missionVariables.Coyote_status == "STAGE_340" && system.ID == 20 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_350";
		mission.setInstructionsKey("CE_MI_S_350_01");
		mission.unmarkSystem(20);
		mission.markSystem(39);
		clock.addSeconds(24 * 3600);
		if (worldScripts["Coyote-Griff"]) {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Anbedi",
				model: "coyotetriogriff"
			});
		} else {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Anbedi",
				model: "coyotetrio"
			});
		}
	}
	// Zaeredre navy station
	else if (missionVariables.Coyote_status == "STAGE_350" && system.ID == 39 && player.ship.dockedStation.primaryRole == "CoyoteNavystation2") {
		missionVariables.Coyote_status = "STAGE_360";
		mission.setInstructionsKey("CE_MI_S_360_03");
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Zaeredre_navystation"
		});
	}
	// Zaeredre main station
	else if (missionVariables.Coyote_status == "STAGE_360" && system.ID == 39 && player.ship.dockedStation.isMainStation) {
		missionVariables.Coyote_status = "STAGE_370";
		mission.setInstructionsKey("CE_MI_S_370_01");
		mission.unmarkSystem(39);
		mission.markSystem(124);
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Zaeredre"
		});
	}
	// Inmaarxe navy station
	else if (missionVariables.Coyote_status == "STAGE_370" && system.ID == 124 && player.ship.dockedStation.primaryRole == "CoyoteNavystation1") {
		missionVariables.Coyote_status = null;
		mission.setInstructions(null);
		player.credits += 200000;
		mission.unmarkSystem(124);
		missionVariables.CoyoteFerdie_status = null;
		missionVariables.CoyotePhythonPilot = null;
		missionVariables.Coyote_BattleAtBiarra = null;
		missionVariables.Coyote_KatikHunt = null;
		missionVariables.Coyote_ViperCount = null;
		missionVariables.Coyote_jumpCount = null;
		missionVariables.coyote_escapePodKilled = null;
		if (!missionVariables.CoyoteCompletionCount) {
			missionVariables.CoyoteCompletionCount = 1;
		} else {
			missionVariables.CoyoteCompletionCount += 1;
		}
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_Inmaarxe_navystation"
		});
	}
}

this.choices = function (choice) {
	switch (choice) {
		case "1_Cont": {
			mission.setInstructionsKey("CE_MI_S_40_01");
			missionVariables.Coyote_status = "STAGE_40";
			var Boo = player.ship.awardContract(1000, "Platinum", 25, 101, clock.seconds + 18 * 24 * 3600, 50000);
			mission.unmarkSystem(25);
			clock.addSeconds(48 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaquesso_mainstation_2"
			});
			break;
		}
		case "2_Cont": {
			missionVariables.Coyote_status = "STAGE_50";
			mission.setInstructionsKey("CE_MI_S_50_01");
			mission.markSystem(89);
			clock.addSeconds(24 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizaar_mainstation_2"
			});
			break;
		}
		case "3_Cont": {
			missionVariables.Coyote_status = "STAGE_70";
			mission.setInstructionsKey("CE_MI_S_70_01");
			mission.unmarkSystem(89);
			mission.markSystem(87);
			clock.addSeconds(1 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_2"
			});
			break;
		}
		case "4_Cont": {
			missionVariables.Coyote_status = "STAGE_90";
			mission.setInstructionsKey("CE_MI_S_90_01");
			mission.unmarkSystem(89);
			mission.markSystem(109);
			clock.addSeconds(120 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_4"
			});
			break;
		}
		case "5_Cont": {
			missionVariables.Coyote_status = "STAGE_110";
			mission.setInstructionsKey("CE_MI_S_110_01");
			mission.unmarkSystem(128);
			mission.markSystem(55);
			clock.addSeconds(120 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_2",
				model: "Coyoteinterstellarstation"
			});
			break;
		}
		case "6_Cont": {
			missionVariables.Coyote_status = "STAGE_170";
			mission.setInstructionsKey("CE_MI_S_170_01");
			mission.markSystem(100);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_160_2"
			});
			break;
		}
		case "7_Cont": {
			missionVariables.Coyote_status = "STAGE_220";
			mission.setInstructionsKey("CE_MI_S_220_01");
			//EquipmentInfo.infoForKey("EQ_AVERNUS_TRACTOR_BEAM").effectiveTechLevel = 14;
			mission.unmarkSystem(128);
			clock.addSeconds(24 * 3600);
			mission.markSystem(185);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_4"
			});
			break;
		}
		case "8_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_navystation_2",
				choicesKey: "Coyote_Bizalein_navystation_choices_2"
			}, this.choices);
			break;
		}
		case "9_Cont": {
			missionVariables.Coyote_status = "STAGE_250";
			mission.setInstructionsKey("CE_MI_S_250_01");
			mission.unmarkSystem(89);
			mission.markSystem(152);
			clock.addSeconds(120 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_navystation_3"
			});
			break;
		}
		case "10_Cont": {
			missionVariables.Coyote_status = "STAGE_270";
			mission.setInstructionsKey("CE_MI_S_270_01");
			mission.unmarkSystem(65);
			mission.markSystem(40);
			clock.addSeconds(24 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Xele_2"
			});
			break;
		}
		case "11_Cont": {
			clock.addSeconds(12 * 3600);
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Tirizaan_navystation_2"
			});
			break;
		}
		case "XX1_Cont": {
			mission.runScreen({
				title: "L\'Auberge de Lago",
				overlay: {
					name: "menu3.png",
					height: 546
					//width: 1024,
					//height: 512
				}
			});
			break;
		}
		case "100_Cont": {
			break;
		}
		case "101_Previous_Screens": {
			this.displayPreviousScreens();
			break;
		}
	}
}

this.displayPreviousScreens = function () {
	this.longScreen = false;
	if (missionVariables.Coyote_status == "STAGE_30") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_1"
		}, this.previousScreenChoices);

	} else if (missionVariables.Coyote_status == "STAGE_40") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_2"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_50") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_3"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_60") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_3"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_70") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_4"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_80") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_5"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_90") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_6"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_100") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_7"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_110") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_8"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_160") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_9"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_170") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_10"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_180") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_11"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_200") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_12"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_220") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_13"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_240") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_14"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_250") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_15"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_260") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_16"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_270") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_17"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_280") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_18"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_300") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_19"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_310") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_20"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_350") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_21"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_360") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_22"
		}, this.previousScreenChoices);
	} else if (missionVariables.Coyote_status == "STAGE_370") {
		mission.runScreen({
			title: "Coyote's Run",
			messageKey: "Coyote_All_Mission_Screens",
			choicesKey: "Coyote_All_Mission_Screens_23"
		}, this.previousScreenChoices);
	} else {
		mission.runScreen({
			title: "Coyote's Run",
			message: "No mission information currently available."
		});
	}
	return;
}

this.previousScreenChoices = function (choice) {
	switch (choice) {
		case "98_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaquesso_navystation_1",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "97_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaquesso_mainstation_1",
				choicesKey: "Coyote_Zaquesso_mainstation_1_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "96_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizaar_mainstation_1",
				choicesKey: "Coyote_Bizaar_mainstation_1_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "95_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_1",
				choicesKey: "Coyote_Bizalein_mainstation_1_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "94_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Ergeso_rockhermit",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "93_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_3",
				choicesKey: "Coyote_Bizalein_mainstation_3_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "92_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Ortema_mainstation",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "91_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_1",
				choicesKey: "Coyote_Avernus_1_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "90_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_150",
				choicesKey: "Coyote_All_Mission_Screens_prompt",
				model: "coyoteAnaconda160"
			}, this.previousScreenChoices);
			break;
		}
		case "89_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_160_1",
				choicesKey: "Coyote_Stage_160_1_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "88_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_Tiuson_1",
				choicesKey: "Coyote_All_Mission_Screens_prompt",
				model: "coyotePython200"
			}, this.previousScreenChoices);
			break;
		}
		case "87_MS": {
			if (worldScripts["Coyote-Griff"]) {
				mission.runScreen({
					title: "Coyote's Run",
					messageKey: "Coyote_Stage_Tiuson_2",
					choicesKey: "Coyote_All_Mission_Screens_prompt",
					model: "coyotetriogriff",
					spinModel: false
				}, this.previousScreenChoices);
			} else {
				mission.runScreen({
					title: "Coyote's Run",
					messageKey: "Coyote_Stage_Tiuson_2",
					choicesKey: "Coyote_All_Mission_Screens_prompt",
					model: "coyotetrio",
					spinModel: false
				}, this.previousScreenChoices);
			}
			break;
		}
		case "86_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_3",
				choicesKey: "Coyote_Avernus_3_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "85_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Leteisan_mainstation",
				model: "coyotesahana2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "84_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_navystation",
				choicesKey: "Coyote_Bizalein_navystation_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "83_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Qulecele",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "82_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Xele",
				choicesKey: "Coyote_Xele_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "81_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Tirizaan_navystation",
				choicesKey: "Coyote_Tirizaan_navystation_choices"
			}, this.previousScreenChoices);
			break;
		}
		case "80_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Atbiarxe",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "79_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Biceri",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "78_MS": {
			if (worldScripts["Coyote-Griff"]) {
				mission.runScreen({
					title: "Coyote's Run",
					messageKey: "Coyote_Anbedi",
					choicesKey: "Coyote_All_Mission_Screens_prompt",
					model: "coyotetriogriff"
				}, this.previousScreenChoices);
			} else {
				mission.runScreen({
					title: "Coyote's Run",
					messageKey: "Coyote_Anbedi",
					choicesKey: "Coyote_All_Mission_Screens_prompt",
					model: "coyotetrio"
				}, this.previousScreenChoices);
			}
			break;
		}
		case "77_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaeredre_navystation",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "76_MS": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaeredre",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}

		case "99_BPrev": {
			this.longScreen = true;
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_All_Mission_Screens",
				choicesKey: "Coyote_All_Mission_Screens_14a"
			}, this.previousScreenChoices);
			break;
		}

		case "98_return": {
			if (!this.longScreen) {
				this.displayPreviousScreens();
			} else {
				mission.runScreen({
					title: "Coyote's Run",
					messageKey: "Coyote_All_Mission_Screens",
					choicesKey: "Coyote_All_Mission_Screens_14a"
				}, this.previousScreenChoices);
			}
			break;
		}
		case "99_APrev": {
			this.displayPreviousScreens();
			break;
		}
		case "1_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Zaquesso_mainstation_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "2_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizaar_mainstation_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "3_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "4_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_mainstation_4",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "5_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt",
				model: "Coyoteinterstellarstation"
			}, this.previousScreenChoices);
			break;
		}
		case "6_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Stage_160_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "7_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Avernus_4",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "8_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_navystation_2",
				choicesKey: "Coyote_Bizalein_navystation_choices_2"
			}, this.previousScreenChoices);
			break;
		}
		case "9_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Bizalein_navystation_3",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "10_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Xele_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
		case "11_Cont": {
			mission.runScreen({
				title: "Coyote's Run",
				messageKey: "Coyote_Tirizaan_navystation_2",
				choicesKey: "Coyote_All_Mission_Screens_prompt"
			}, this.previousScreenChoices);
			break;
		}
	}
}

this.MST = function () {
	this.MST_Count += 1;
	if (this.MST_Count == 1) {
		//player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n", 10);
		player.consoleMessage(expandDescription("[COYOTE_START1]"), 10);
		//player.consoleMessage("\n", 10)
	} else if (this.MST_Count == 2) {
		//player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n", 10);
		//player.consoleMessage(expandDescription("[COYOTE_START1]"), 10);
		player.consoleMessage(expandDescription("[COYOTE_START2]"), 10);
		//player.consoleMessage("\n", 10)
		player.ship.fuel = 7.0;
	} else if (this.MST_Count == 3) {
		//player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n", 10);
		//player.consoleMessage(expandDescription("[COYOTE_START1]"), 10);
		//player.consoleMessage(expandDescription("[COYOTE_START2]"), 10);
		player.consoleMessage(expandDescription("[COYOTE_START2a]"), 10);
		//player.consoleMessage("\n", 10)
	} else if (this.MST_Count == 4) {
		//player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n", 10);
		//player.consoleMessage(expandDescription("[COYOTE_START1]"), 10);
		//player.consoleMessage(expandDescription("[COYOTE_START2]"), 10);
		//player.consoleMessage(expandDescription("[COYOTE_START2a]"), 10);
		player.consoleMessage(expandDescription("[COYOTE_START3]"), 10);
		//player.consoleMessage("\n", 10)
	} else {
		if (player.ship.isCloaked) {
			var pos = player.ship.position.add(player.ship.vectorForward.multiply(25600));
			system.addShips("coyotepythonstart", 1, pos, 100);
			//player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n", 10);
			player.commsMessage(expandDescription("[COYOTE_START4]"), 10);
			this.MissionStartTimer.stop();
		}
	}
}

this.setMissionInstructions = function (message) {
	mission.setInstructionsKey(message, "Coyote-Main");
}

this.ComTimerCB = function () {
	var witchBuoy = system.shipsWithPrimaryRole("buoy-witchpoint")[0];
	witchBuoy.commsMessage(expandDescription("[COYOTE_S110_01]"), player.ship);
	missionVariables.Coyote_status = "STAGE_120";
	mission.unmarkSystem(55);
	mission.markSystem(128);
	mission.setInstructionsKey("CE_MI_S_120_01");
}

this.Stage160 = function () {
	this.agentshp = system.addShips("coyotelabrujaagent", 1, player.ship.position.add(player.ship.vectorForward.multiply(-6000)))[0];
}

this.Stage180 = function () {
	this.S180TimerCount += 1;
	if (this.S180TimerCount == 5) {
		this.S180Timer.stop();
	}
	if (this.S180TimerCount < 6) {
		system.addShips("coyotePython180", 1, player.ship.position.add(player.ship.vectorForward.multiply(6000)));
	}
}

this.loboAndZorra = function () {
	this.lobo.position = player.ship.position.add(player.ship.vectorForward.multiply(-50)).add(player.ship.vectorRight.multiply(200));
	this.lobo.orientation = player.ship.orientation;
	this.zorra.position = player.ship.position.add(player.ship.vectorForward.multiply(-50)).add(player.ship.vectorRight.multiply(-200));
	this.zorra.orientation = player.ship.orientation;
	if (player.alertMassLocked) {
		this.shArray = system.shipsWithPrimaryRole("coyotekatikrockhermit");
		if (this.shArray.length > 0) {
			if (this.shArray[0].position.distanceTo(player.ship.position) < 25600) {
				this.massLocked = true;
			}
		}
	}
	if (this.massLocked) {
		this.shArray = system.shipsWithPrimaryRole("coyotekatikrockhermit");
		if (this.shArray.length > 0) {
			if (this.shArray[0].position.distanceTo(player.ship.position) < 12000) {
				this.massLocked = true;
				this.zorra.reactToAIMessage("HOSTILES_NEAR");
				this.lobo.reactToAIMessage("HOSTILES_NEAR");

				if (isValidFrameCallback(this.trackId)) {
					removeFrameCallback(this.trackId);
				}
			}
		}
	}
}

this.tractorBeam = function () {
	this.tractorDistance = player.ship.target.position.distanceTo(player.ship.position);
	missionVariables.coyote_beam = "WORKING";
	this.TRCount = 0;
	this.TRtrackId = addFrameCallback(this.tractorCallBack.bind(this));
}

this.dtractorBeam = function () {
	missionVariables.coyote_beam = null;
	if (isValidFrameCallback(this.TRtrackId)) {
		removeFrameCallback(this.TRtrackId);
	}
}

this.tractorCallBack = function (delta) {
	if (!player.ship.target) {
		if (isValidFrameCallback(this.TRtrackId)) {
			removeFrameCallback(this.TRtrackId);
		}
	} else {
		if (delta !== 0) {
			this.TRCount += 1;
			if (this.TRCount >= 4) {

				player.ship.energy -= 1;
				this.TRCount = 0;
			}
		}
		player.ship.target.position = player.ship.position.add(player.ship.vectorForward.multiply(-1 * this.tractorDistance));
	}
}

this.moveMass = function () {
	this.massblocker.position = player.ship.position.add(player.ship.vectorForward.multiply(-50));
}

this.BiarraBattle = function () {
	if (system.ID == 66) {
		system.addShips("coyoteinterceptor1", 1, player.ship.position.add(player.ship.vectorForward.multiply(-6000)));
		system.addShips("coyoterogueviper1", 2, player.ship.position.add(player.ship.vectorForward.multiply(-6000)));
		system.addShips("coyoterogueviper2", 2, player.ship.position.add(player.ship.vectorForward.multiply(-6000)));
	}
}

this.cam = function (cam1) {
	this.camCount = 0;
	this.cam1 = cam1;
	if (!isValidFrameCallback(this.CamAndGreerTrackId)) {
		this.CamAndGreerTrackId = addFrameCallback(this.CamAndGreer.bind(this));
		this.checkDistanceFirstTime = true;
		this.massLocked = false;
		this.informTimer = new Timer(this, this.checkDistance, 5, 5);
	}
}

this.checkDistance = function () {
	if (this.checkDistanceFirstTime && this.greerCount == 150 && this.camCount == 150) {
		this.checkDistanceFirstTime = false;
		mission.setInstructionsKey("CE_MI_S_310_02", this.name);
		if (system.ID == 66) {
			this.greer1.commsMessage(expandDescription("[COYOTE_S310_04]"), player.ship);
			mission.setInstructionsKey("CE_MI_S_310_02", this.name);
			missionVariables.Coyote_status = "STAGE_320"
		}
		if (system.ID == 84) {
			this.greer1.commsMessage(expandDescription("[COYOTE_S310_05]"), player.ship);
			mission.setInstructionsKey("CE_MI_S_310_05", this.name);
			missionVariables.Coyote_status = "STAGE_335"
		}
	}
	var S = system.sun;
	if (system.ID == 66) {
		if (player.ship.position.distanceTo(S.position) < 300000) {
			this.informTimer.stop();
			system.addShips("coyotebandit1", 4, player.ship.position.add(player.ship.vectorForward.multiply(25000)));
			this.massLock = "coyotebandit1";
			this.massLocked = true;
			this.greer1.commsMessage(expandDescription("[COYOTE_S310_06]"), player.ship);
			this.informTimer.stop();
		}
	}
	if (system.ID == 84) {
		if (player.ship.position.distanceTo(S.position) < 600000) {
			this.informTimer.stop();
			system.addShips("coyotebandit2", 4, player.ship.position.add(player.ship.vectorForward.multiply(25000)));
			this.massLock = "coyotebandit2";
			this.massLocked = true;
			this.greer1.commsMessage(expandDescription("[COYOTE_S310_07]"), player.ship);
			mission.setInstructionsKey("CE_MI_S_310_06", "Coyote-Main");
			this.informTimer.stop();
		}
	}
}

this.greer = function (greer1) {
	this.greerCount = 0;
	this.greer1 = greer1;
	if (!isValidFrameCallback(this.CamAndGreerTrackId)) {
		this.CamAndGreerTrackId = addFrameCallback(this.CamAndGreer.bind(this));
		this.checkDistanceFirstTime = true;
		this.massLocked = false;
		this.informTimer = new Timer(this, this.checkDistance, 5, 5);
	}
}

this.CamAndGreer = function () {
	//rVector=new Vector3D;
	//rVector.x=Math.random()*2;
	//rVector.y=Math.random()*2;
	//rVector.z=Math.random()*2;
	var pos = 0;
	if (!this.cam1) {} else {
		pos = -50;
		if (this.camCount < 150) {
			this.camCount += 1;
			pos = -200 + this.camCount;
		}
		//this.cam1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(-200)).add(rVector);
		this.cam1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(-200));
		this.cam1.orientation = player.ship.orientation;
	}
	if (!this.greer1) {} else {
		pos = -50;
		if (this.greerCount < 150) {
			this.greerCount += 1;
			pos = -200 + this.greerCount;
		}
		//this.greer1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(200)).add(rVector);
		this.greer1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(200));
		this.greer1.orientation = player.ship.orientation;
	}
	if (this.massLocked) {
		this.shArray = system.shipsWithRole(this.massLock);
		if (this.shArray.length > 0) {
			if (this.shArray[0].position.distanceTo(player.ship.position) < 12000) {
				this.massLocked = true;
				this.cam1.reactToAIMessage("HOSTILES_NEAR");
				this.greer1.reactToAIMessage("HOSTILES_NEAR");
				this.greerCount = 0;
				this.camCount = 0;
				this.cam1 = null;
				this.greer1 = null;
				if (isValidFrameCallback(this.CamAndGreerTrackId)) {
					removeFrameCallback(this.CamAndGreerTrackId);
				}
			}
		}
	}
}

this.camT1 = function (cam1) {
	this.camCount = 0;
	this.cam1 = cam1;
	if (!isValidFrameCallback(this.CamAndGreerT1TrackId)) {
		this.greer1 = null;
		this.checkDistanceFirstTime = true;
		this.hyperSpaceTimer = new Timer(this, this.hyperSpace, 5, 1);
		this.CamAndGreerT1TrackId = addFrameCallback(this.CamAndGreerT1.bind(this));
	}
}

this.greerT1 = function (greer1) {
	this.greerCount = 0;
	this.greer1 = greer1;
	if (!isValidFrameCallback(this.CamAndGreerT1TrackId)) {
		this.cam1 = null;
		this.checkDistanceFirstTime = true;
		this.hyperSpaceTimer = new Timer(this, this.hyperSpace, 5, 1);
		this.CamAndGreerT1TrackId = addFrameCallback(this.CamAndGreerT1.bind(this));
	}
}

this.CamAndGreerT1 = function () {
	//rVector=new Vector3D;
	//rVector.x=Math.random()*2;
	//rVector.y=Math.random()*2;
	//rVector.z=Math.random()*2;
	var pos = 0;
	if (!this.cam1) {} else {
		pos = -50;
		if (this.camCount < 150) {
			this.camCount += 1;
			pos = -200 + this.camCount;
		}
		//this.cam1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(-200)).add(rVector);
		this.cam1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(-200));
		this.cam1.orientation = player.ship.orientation;
	}
	if (!this.greer1) {} else {
		pos = -50;
		if (this.greerCount < 150) {
			this.greerCount += 1;
			pos = -200 + this.greerCount;
		}
		//this.greer1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(200)).add(rVector);
		this.greer1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(200));
		this.greer1.orientation = player.ship.orientation;
	}
	if (this.massLocked) {
		this.shArray = system.shipsWithRole(this.massLock);
		if (this.shArray.length > 0) {
			if (this.shArray[0].position.distanceTo(player.ship.position) < 12000) {
				this.massLocked = true;
				this.cam1.reactToAIMessage("HOSTILES_NEAR");
				this.greer1.reactToAIMessage("HOSTILES_NEAR");

				if (isValidFrameCallback(this.CamAndGreerTrackId)) {
					removeFrameCallback(this.CamAndGreerTrackId);
				}
			}
		}
	}
}

this.hyperSpace = function () {
	if (this.checkDistanceFirstTime && this.greerCount == 150 && this.camCount == 150) {
		this.checkDistanceFirstTime = false;
		if (system.ID == 84) {
			this.cam1.commsMessage(expandDescription("[COYOTE_S310_08]"), player.ship);
		}
		if (system.ID == 20) {
			this.cam1.commsMessage(expandDescription("[COYOTE_S310_09]"), player.ship);
		}
		this.hyperSpaceTimer.stop();
		this.jumpCount = 0;
		this.jumpTimer = new Timer(this, this.jump, 1, 1);
	}
}

this.jump = function () {
	if (this.jumpCount <= 14) {
		this.cam1.commsMessage("\n\n\n\n\n\n\n\n\n\ Jumping in " + (15 - this.jumpCount) + " secs.", player.ship);
		this.jumpCount += 1;
	} else {
		this.jumpTimer.stop();
		if (isValidFrameCallback(this.CamAndGreerT1TrackId)) {
			removeFrameCallback(this.CamAndGreerT1TrackId);
		}
		var pos = this.cam1.position;
		this.cam1.fuel = 7.0;
		if (system.ID == 20) {
			while (!this.cam1.exitSystem(39)) {}
		} else {
			while (!this.cam1.exitSystem(20)) {}
			missionVariables.Coyote_status = "STAGE_335"
		}
		player.ship.position = pos;
	}
}

this.releaseUS = function () {
	log(this.name, "Release Us");
	if (isValidFrameCallback(this.trackId)) {
		removeFrameCallback(this.trackId);
	}
	this.lobo.commsMessage(expandDescription("[COYOTE_S310_10]"), player.ship);
}

this.camT2 = function (cam1) {
	this.camCount = 0;
	this.cam1 = cam1;
	this.checkDistanceFirstTime = true;
	this.stationNearTimer = new Timer(this, this.stationNear, 5, 5);
	this.CamFRMT1TrackId = addFrameCallback(this.CamFRMT1.bind(this));
}

this.CamFRMT1 = function () {
	var pos = -50;
	if (this.camCount < 150) {
		this.camCount += 1;
		pos = -200 + this.camCount;
	}
	this.cam1.position = player.ship.position.add(player.ship.vectorForward.multiply(pos)).add(player.ship.vectorRight.multiply(-200));
	this.cam1.orientation = player.ship.orientation;
}

this.stationNear = function () {
	this.shArray = system.shipsWithRole("CoyoteNavystation2");
	if (this.shArray.length > 0) {
		if (this.shArray[0].position.distanceTo(player.ship.position) < 12000) {
			this.cam1.reactToAIMessage("STATION_NEAR");

			if (isValidFrameCallback(this.CamFRMT1TrackId)) {
				removeFrameCallback(this.CamFRMT1TrackId);
			}
		}
	}
}

this.pirateAmbush = function () {
	var SC = Math.floor(Math.random() * 3) + 5;
	system.addShips("pirate", SC, player.ship.position, 10000);
}

this.sunSkimT = function () {
	this.sunSkimCounter += 1;
	if (this.sunSkimCounter == 1) {
		player.commsMessage(expandDescription("[COYOTE_S60_01]"), 6)
	} else {
		this.sunSkimTimer.stop();
		this.autoskimmer = system.addShips("coyoteautoskimmer", 1, player.ship.position.add(player.ship.vectorRight.multiply(100)).add(player.ship.vectorUp.multiply(100)), 0)[0];
		this.autoskimmer.orientation = player.ship.orientation;
		this.skimTrackId = addFrameCallback(this.followAutoSkimmer.bind(this));
		player.consoleMessage(expandDescription("[COYOTE_S60_02]"), 6);
		this.skimProgressTimer = new Timer(this, this.skimProgress, 2, 2);
	}
}

this.skimProgress = function () {
	if (player.alertMassLocked) {
		// don't tell the player to engage injectors if ShipConfig is installed - too much heat!
		// also, don't tell the player to use injectors if they don't have any
		if (!worldScripts.ShipConfiguration_Core || player.ship.hasEquipmentProviding("EQ_FUEL_INJECTION") === true) {
			if (player.ship.speed <= player.ship.maxSpeed) {
				player.consoleMessage(expandDescription("[COYOTE_S60_03]"), 6);
			}
		}
	} else {
		if (player.ship.speed <= player.ship.maxSpeed * 10) {
			player.consoleMessage(expandDescription("[COYOTE_S60_04]"), 6);
		}
	}
}

this.followAutoSkimmer = function () {
	player.ship.orientation = this.autoskimmer.orientation;
	player.ship.position = this.autoskimmer.position.add(this.autoskimmer.vectorRight.multiply(-100)).add(this.autoskimmer.vectorUp.multiply(-100));
}

this.deactivateSkimTracking = function () {
	if (isValidFrameCallback(this.skimTrackId)) {
		removeFrameCallback(this.skimTrackId);
		this.autoskimmer.remove(true);
		player.commsMessage(expandDescription("[COYOTE_S60_05]"), 6);
		player.commsMessage(expandDescription("[COYOTE_S60_06]"), 6);
		this.skimProgressTimer.stop();
	}
}

this.startSahanaFun = function () {
	this.sahanaFunCount = 0;
	this.sahanaFunTimer = new Timer(this, this.sahanaFun, 5, 1);
}

this.sahanaFun = function () {
	this.sahanaFunCount += 1;
	if (this.sahanaFunCount == 1) {
		player.commsMessage(expandDescription("[COYOTE_S225_01]"), 6);
	}
	if (this.sahanaFunCount == 3) {
		player.commsMessage(expandDescription("[COYOTE_S225_02]"), 6);
	}
	if (this.sahanaFunCount == 5) {
		player.commsMessage(expandDescription("[COYOTE_S225_03]"), 6);
	}
	if (this.sahanaFunCount == 7) {
		player.commsMessage(expandDescription("[COYOTE_S225_04]"), 6);
	} else if (this.sahanaFunCount == 12) {
		this.sahanaPod = system.addShips("coyotesahanapod", 1, player.ship.position.add(player.ship.vectorForward.multiply(-30)), 0)[0];
		this.shpArray = system.shipsWithPrimaryRole("coyotekatikboss3escort");
		if (this.shpArray.length == 0) {} else {
			this.mambaEscort = this.shpArray[0]
			this.shpArray[0].reactToAIMessage("SCOOP_SAHANA");
		}
		mission.setInstructionsKey("CE_MI_S_225_02", "Coyote-Main");
	} else if (this.sahanaFunCount == 15) {
		player.commsMessage(expandDescription("[COYOTE_S225_05]"), 6);
	} else if (this.sahanaFunCount == 20) {
		this.mambaEscort.commsMessage(expandDescription("[COYOTE_S225_06]"), player.ship);
	}
}

this.$initInterface = function (station) {
	if (galaxyNumber == 4) {
		station.setInterface(this.name, {
			title: "Coyote's Run History",
			category: expandDescription("[interfaces-category-logs]"),
			summary: "Views previous mission data for Coyote's Run mission",
			callback: this.displayPreviousScreens.bind(this)
		});
	}
	if (station.primaryRole == "Coyoteinterstellarstation" || station.primaryRole == "Coyoteinterstellarstationgg") {
		station.setInterface(this.name + "_menu", {
			title: "Avernus Orbital 'L\'Auberge de Lago' Restaurant",
			category: "Station Interfaces",
			summary: "View the menu for Avernus Orbital Restaurant 'L\'Auberge de Lago'",
			callback: this.$displayRestaurantMenu.bind(this)
		});
	}
}

this.$displayRestaurantMenu = function $displayRestaurantMenu() {
	mission.runScreen({
		title: "L\'Auberge de Lago",
		overlay: {
			name: "menu3.png",
			height: 546
		}
	});
}
Scripts/coyoteAnaconda.js
"use strict";
this.name = "coyoteAnaconda";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAnaconda.";

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

this.shipDied = function (whom, why) {
	if (missionVariables.Coyote_status == "STAGE_120") {
		missionVariables.Coyote_status = "STAGE_130";
	}
}
Scripts/coyoteAnaconda160.js
"use strict";
this.name = "coyoteAnaconda160";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAnaconda and python during STAGE_160.";

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

this.shipDied = function (whom, why) {
	if (whom !== null) {
		if (whom.isPlayer) {
			missionVariables.Coyote_KatikHunt += 1;
		}

	}
}
Scripts/coyoteAnaconda180.js
"use strict";
this.name = "coyoteAnaconda180";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAnaconda and python during STAGE_160.";

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

this.shipDied = function (whom, why) {
	missionVariables.Coyote_KatikHunt += 1;
	if (missionVariables.Coyote_KatikHunt == 1) {
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_180_02");
	} else if (missionVariables.Coyote_KatikHunt == 2) {
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_180_03");
	} else if (missionVariables.Coyote_KatikHunt == 3) {
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_180_04");
	} else if (missionVariables.Coyote_KatikHunt == 4) {
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_180_05");
	} else if (missionVariables.Coyote_KatikHunt == 5) {
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_180_06");
		missionVariables.Coyote_status = "STAGE_190";
		mission.unmarkSystem(109);
		mission.markSystem(100);
	}
	player.consoleMessage(missionVariables.Coyote_KatikHunt + "/5 Clan Katik's transports have been Killed", 5);
}
Scripts/coyoteAsp10.js
"use strict";
this.name = "coyoteAsp10";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer2.";

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

this.shipDied = function (whom, why) {}

this.shipTakingDamage = function (amount, whom, type) {
	if (whom == null) {
		return;
	}
	if (whom.primaryRole == "coyotegreer5") {
		this.ship.explode();
	}
}
Scripts/coyoteAsp11.js
"use strict";
this.name = "coyoteAsp11";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer2.";

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

this.shipDied = function (whom, why) {}

this.shipTakingDamage = function (amount, whom, type) {
	if (whom == null) {
		return;
	}
	if (whom.primaryRole == "coyotegreer5") {
		whom.reactToAIMessage("TARGET_DERELICT");
		this.ship.awardEquipment("EQ_ESCAPE_POD");
		this.ship.abandonShip();
	}
}
Scripts/coyoteAsp225.js
"use strict";
this.name = "coyoteAsp225";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for coyoteAsp225.";

this.shipSpawned = function () {
	this.damage = 0;
}

this.shipTakingDamage = function (amount, whom, type) {
	if (whom !== null) {
		if (whom.primaryRole == "coyotekatikboss3escort") {
			this.damage += amount;
			if (this.damage >= 100); {
				missionVariables.Coyote_status = "STAGE_227";
				this.ship.explode();
			}
		}
	}
}
Scripts/coyoteAsp230.js
"use strict";
this.name = "coyoteAsp230";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for coyoteAsp230.";

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

this.checkPlayer = function () {
	if (this.ship.position.distanceTo(player.ship.position) < 25000) {
		this.ship.target = player.ship;
		this.ship.reactToAIMessage("TARGET_FOUND");
	}
}

this.shipTakingDamage = function (amount, whom, type) {
	if (whom !== null) {
		if (whom.primaryRole == "coyotecuervo" || whom.primaryRole == "coyotesahana2") {
			this.damage += amount;
			//log(this.name,this.damage);
			if (this.damage >= 30); {
				this.ship.explode();
			}
		}
	}
}
Scripts/coyoteAutoSkimmer.js
"use strict";
this.name = "autoSkimmer";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for autoSkimmer.";

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

this.checkMassLocked = function () {
	if (player.alertMassLocked) {
		if (system.sun.position.distanceTo(this.ship.position) - system.sun.radius > 100000) {
			this.ship.velocity = this.ship.vectorForward.multiply(player.ship.speed);
		} else {
			this.ship.velocity = this.ship.vectorForward.multiply(this.ship.maxSpeed);

		}
	} else {
		this.ship.velocity = this.ship.vectorForward.multiply(player.ship.speed);
	}
}

this.checkMassLocked2 = function () {
	if (player.alertMassLocked) {
		this.ship.velocity = this.ship.vectorForward.multiply(player.ship.speed);
	} else {
		this.ship.velocity = this.ship.vectorForward.multiply(player.ship.speed);
	}
}

this.shipDied = function (whom, why) {}

this.checkFuel = function () {
	if (player.ship.fuel >= 6.9) {
		this.ship.reactToAIMessage("FULL_FUEL");
	}
}

this.removeMe = function () {
	worldScripts["Coyote-Main"]["deactivateSkimTracking"]();
}
Scripts/coyoteAvernus.js
"use strict";
this.name = "coyoteAvernus";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAvernus.";

this.shipTakingDamage = function (amount, whom, type) {
	if (whom.isPlayer) {
		if (player.bounty < 64) {
			player.bounty = 64;
		}
	}
}

this.shipBeingAttacked = function (whom) {
	if (whom.isPlayer) {
		player.bounty = 64;
		this.ship.launchDefenseShip();
		this.ship.launchDefenseShip();
		this.ship.launchDefenseShip();
	}
}
Scripts/coyoteCameron1.js
"use strict";
this.name = "coyoteCameron1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteLebo1.";

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

this.locatePlayer = function () {
	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");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {
	player.consoleMessage(expandDescription("[COYOTE_S310_01]"), 6);

	this.ship.commsMessage(expandDescription("[COYOTE_S310_02]"), player.ship);
	this.shArray = system.shipsWithPrimaryRole("coyotegreer1");
	if (this.shArray.length > 0) {
		this.shArray[0].commsMessage(expandDescription("[COYOTE_S310_03]"), player.ship);
	}

}

this.informPlayer2 = function () {}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoterogueviper1");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithPrimaryRole("coyoterogueviper2");
		if (this.shArray.length == 0) {
			this.shArray = system.shipsWithPrimaryRole("coyoteinterceptor1");
			if (this.shArray.length == 0) {
				if (!missionVariables.Coyote_BattleAtBiarra) {
					this.ship.reactToAIMessage("NOTHING_FOUND");
				} else {
					this.ship.reactToAIMessage("END_OF_BATTLE");
				}
			} else {
				this.ship.target = this.shArray[0];
				this.ship.reactToAIMessage("VIPER_FOUND");
			}
		} else {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
		}
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
		} else {
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.locatePlayer1 = function () {
	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) < 2000) {
			if (missionVariables.coyote_escapePodKilled == "TRUE") {
				this.ship.reactToAIMessage("POD_KILLED");
			} else {
				this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
			}
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["cam"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(-200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["cam"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.checkSunskim1 = function () {
	var P = system.mainPlanet;
	var targetVector = P.position.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
	if (this.ship.speed == 0) {
		this.playerArray = system.shipsWithPrimaryRole("coyotegreer1");
		if (this.playerArray.length == 0) {} else {
			// this.ship.target = this.playerArray[0];
			this.ship.position = this.playerArray[0].position.add(this.playerArray[0].vectorUp.multiply(200));
		}
	}
}

this.checkSunskim = function () {
	if (this.ship.speed == 0) {
		var P = system.mainPlanet;
		var targetVector = P.position.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		this.playerArray = system.shipsWithPrimaryRole("coyotegreer1");
		if (this.playerArray.length == 0) {} else {
			// this.ship.target = this.playerArray[0];
			this.ship.position = this.playerArray[0].position.add(this.playerArray[0].vectorUp.multiply(200));
			this.ship.orientation = this.playerArray[0].orientation;
		}
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteCameron2.js
"use strict";
this.name = "coyoteCameron2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteCameron2.";

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

this.locatePlayer = function () {
	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");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {
	player.consoleMessage(expandDescription("[COYOTE_S310_01]"), 6);
	this.ship.commsMessage(expandDescription("[COYOTE_S310_02]"), player.ship);
	this.shArray = system.shipsWithPrimaryRole("coyotegreer1");
	if (this.shArray.length > 0) {
		this.shArray[0].commsMessage(expandDescription("[COYOTE_S310_03]"), player.ship);
	}
}

this.informPlayer2 = function () {}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotepiratepython");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithRole("coyotepirateescort");
		if (this.shArray.length == 0) {
			this.ship.reactToAIMessage("END_OF_BATTLE");
		} 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.locatePlayer1 = function () {
	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) < 500) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
}

this.startMove3 = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
	this.ship.commsMessage(expandDescription("[COYOTE_S310_12]"), player.ship);
	player.consoleMessage(expandDescription("[COYOTE_S310_13]"), 6);
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["cam"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(-200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["cam"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.startMove2 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["camT1"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(-200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["camT1"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.checkSunskim1 = function () {
	var P = system.mainPlanet;
	var targetVector = P.position.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);

}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteCameron3.js
"use strict";
this.name = "coyoteCameron3";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteCameron3.";

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

this.releaseUs = function () {
	worldScripts["Coyote-Main"]["releaseUS"]();
}
Scripts/coyoteCameron4.js
"use strict";
this.name = "coyoteCameron4";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteCameron4.";

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

this.locatePlayer = function () {
	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) < 3500) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["camT1"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(-200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["camT1"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteCameron5.js
"use strict";
this.name = "coyoteCameron5";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteCameron4.";

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

this.locatePlayer = function () {
	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) < 3500) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["camT2"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(-200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["camT2"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.informPlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("coyotegreerspod");
	if (this.playerArray.length == 0) {
		this.ship.commsMessage("Scooped Greer", player.ship);
	} else {
		this.playerArray[0].remove(true);
		this.ship.commsMessage("Scooped Greer", player.ship);
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}

this.locatePod = function () {
	this.playerArray = system.shipsWithPrimaryRole("coyotegreerspod");
	if (this.playerArray.length == 0) {
		this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
	} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(this.playerArray[0].position) < 50) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}
Scripts/coyoteConditions.js
"use strict";
this.name = "coyoteConditions";
this.author = "phkb";
this.copyright = "2018 phkb";
this.description = "Condition script for determining whether the tractor beam can be purchased";
this.licence = "CC BY-NC-SA 4.0";

//-------------------------------------------------------------------------------------------------------------
this.allowAwardEquipment = function (equipment, ship, context) {
	// always return true for scripted install
    if (context === "scripted") return true;
    // only at a certain stage of the mission, and only at avernus orbital
    if (missionVariables.Coyote_status == "STAGE_220" && player.ship.dockedStation.hasRole("avernus_orbital") === true) {
        return true;
    }
    return false;
}
Scripts/coyoteCuervo.js
"use strict";
this.name = "coyoteCuervo";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for coyoteCuervo.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.firstMessage = false;
	this.ship.fuel = 7.0;
}


this.fMessage = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_14]"), player.ship);
	this.ship.reactToAIMessage("LOOKFOR_TARGET");
}

this.locatePlayer = function () {
	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) < 25000) {
			if (!this.firstMessage) {
				mission.setInstructionsKey("CE_MI_S_225_07", "Coyote-Main");
			}
		}
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.scanFor200 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotepython230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor200E = function () {
	this.shArray = system.shipsWithRole("coyotepirateescort2");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor201 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteferdie230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor202 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteasp230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.informPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_16]"), player.ship);
	this.shArray = system.shipsWithPrimaryRole("coyotesahana2");
	if (this.shArray.length !== 0) {
		this.shArray[0].reactToAIMessage("HEAD_FOR_PLANET");
	}
	mission.setInstructionsKey("CE_MI_S_225_08", "Coyote-Main");
}
Scripts/coyoteEscapePod.js
"use strict";
this.name = "Coyote-EscapePod";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for the pilots escape pod.";

this.shipWasScooped = function (scooper) {
	if (scooper.isPlayer) {
		if (missionVariables.CoyoteFerdie_status == "FLEE") {
			player.commsMessage(expandDescription("[COYOTE_S_03]"), 10);
			worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_20_03");
		} else {
			player.commsMessage(expandDescription("[COYOTE_S_04]"), 10);
			worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_20_04");
		}
		mission.markSystem(25);
		missionVariables.CoyotePhythonPilot = "RESCUED";
		missionVariables.Coyote_status = "STAGE_20";
	}
}
Scripts/coyoteEscapePod2.js
"use strict";
this.name = "Coyote-EscapePod2";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for the pilots escape pod 2.";

this.shipDied = function (whom, why) {
	if (whom == null) {
		return;
	}
	if (whom.isPlayer) {
		missionVariables.coyote_escapePodKilled = "TRUE";
	}
}
Scripts/coyoteEscapePod3.js
"use strict";
this.name = "Coyote-EscapePod3";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for the pilots escape pod 3.";

this.shipSpawned = function () {

}

this.shipWasScooped = function (scooper) {
	if (scooper.isPlayer) {} else {}
}
Scripts/coyoteEscapePod4.js
"use strict";
this.name = "Coyote-EscapePod4";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for the pilots escape pod 4.";

this.shipSpawned = function () {
	this.killed = false;
}

this.shipTakingDamage = function (amount, whom, type) {
	if (whom !== null) {
		if (whom.primaryRole == "coyotekatikboss3escort") {
			this.killed = true;
			missionVariables.Coyote_status = "STAGE_226";
			this.ship.explode();
		}
	}
}

this.shipDied = function () {
	if (this.killed == false) {
		this.ship.spawnOne("coyotekatikboss2pod");
	}
}
Scripts/coyoteFerdie10.js
"use strict";
this.name = "coyoteFerdie10";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteFerdie11.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
}
Scripts/coyoteFerdie11.js
"use strict";
this.name = "coyoteFerdi11";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer1.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
}
Scripts/coyoteFerdie2.js
"use strict";
this.name = "coyoteFerdie2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteFerdie2.";

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

this.flee = function () {
	missionVariables.CoyoteFerdie_status = "FLEE";
}

this.shipDied = function () {
	missionVariables.CoyoteFerdie_status = "KILLED";
}

this.checkPilotRescue = function () {
	if (missionVariables.CoyotePhythonPilot == "RESCUED") {
		this.ship.position = player.ship.position.add(player.ship.vectorForward.multiply(25000));
		this.ship.target = player.ship;
		this.ship.reactToAIMessage("ATTACK_PLAYER");
	}
}

this.locatePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		if (this.ship.position.distanceTo(player.ship.position) < 8000) {
			this.ship.target = this.playerArray[0];
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.target = this.playerArray[0];
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}
Scripts/coyoteFerdie225.js
"use strict";
this.name = "coyoteFerdie225";
this.author = "Captain Okti";
this.copyright = "(C) 2011 Oktay Sarioglu";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Script for coyoteAsp225.";

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

this.checkPlayer = function () {
	if (this.ship.position.distanceTo(player.ship.position) < 25000) {
		this.ship.target = player.ship;
		this.ship.reactToAIMessage("TARGET_FOUND");
	}
}
Scripts/coyoteFerdie3.js
"use strict";
this.name = "coyoteFerdie3";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteFerdie3.";

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

this.locatePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		this.ship.target = this.playerArray[0];
		this.ship.reactToAIMessage("PLAYER_FOUND");
	}
}
Scripts/coyoteFerdie4.js
"use strict";
this.name = "coyoteFerdie4";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteFerdie4.";

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

this.shipDied = function (whom, why) {
	if (whom == null) {
		return;
	}
	if (whom.isPlayer) {
		this.shArray = system.shipsWithPrimaryRole("coyoteferdie4");
		if (this.shArray.length == 0) {} else {
			var j = 0
			while (j < this.shArray.length) {
				this.shArray[j].explode();
				j += 1;
			}
		}
		this.shArray = system.shipsWithRole("coyoteviper2");
		if (this.shArray.length == 0) {} else {
			this.shArray[0].commsMessage("Bizalein system police thank you for your assistance.", player.ship);
		}
	}
}
Scripts/coyoteGecko.js
"use strict";
this.name = "coyoteGecko";
this.author = "Okti";
this.copyright = "";
this.description = "Coyote Gecko Ship Script";

this.scanForTarget = function () {
	this.ship.target = player.ship;
	this.ship.reactToAIMessage("TARGET_FOUND");
};
Scripts/coyoteGreer1.js
"use strict";
this.name = "coyoteGreer1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer1.";

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

this.locatePlayer = function () {
	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");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {}

this.informPlayer2 = function () {}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoterogueviper2");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithPrimaryRole("coyoterogueviper1");
		if (this.shArray.length == 0) {
			this.shArray = system.shipsWithPrimaryRole("coyoteinterceptor1");
			if (this.shArray.length == 0) {
				if (!missionVariables.Coyote_BattleAtBiarra) {
					this.ship.reactToAIMessage("NOTHING_FOUND");
				} else {
					this.ship.reactToAIMessage("END_OF_BATTLE");
				}
			} else {
				this.ship.target = this.shArray[0];
				this.ship.reactToAIMessage("VIPER_FOUND");
			}
		} else {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
		}
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
		} else {
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.locatePlayer1 = function () {
	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) < 2000) {
			if (missionVariables.coyote_escapePodKilled == "TRUE") {
				this.ship.reactToAIMessage("POD_KILLED");
			} else {
				this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
			}
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
	var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
	log(this.name, des.distanceTo(this.ship.position) / 240);
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["greer"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["greer"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.checkSunskim1 = function () {
	var P = system.mainPlanet;
	var targetVector = P.position.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);

}

this.checkSunskim = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			var pos = this.ship.position;
			this.shArray = system.shipsWithPrimaryRole("coyotecameron1");
			mission.unmarkSystem(66);
			mission.markSystem(84);
			this.ship.fuel = 7.0;
			this.ship.exitSystem(84);
			missionVariables.Coyote_status = "STAGE_325"
			if (this.shArray.length > 0) {
				this.shArray[0].position = pos;
			}
		} else if (this.ship.position.distanceTo(player.ship.position) < 15000) {
			if (this.firstMessage) {
				this.ship.commsMessage("Come near to us to follow our wormhole", player.ship);
				worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_310_03");
				this.firstMessage = false;
			}
		}
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}

this.cheatThePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length > 0) {
		if (this.ship.position.distanceTo(player.ship.position) > 40000) {
			this.shArray = system.shipsWithPrimaryRole("coyotebandit1");
			i = this.shArray.length - 1;
			while (i >= 0) {
				this.shArray[0].remove();
				i -= 1;
			}
		}
	}
}
Scripts/coyoteGreer2.js
"use strict";
this.name = "coyoteGreer2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer2.";

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

this.locatePlayer = function () {
	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) < 3300) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {}

this.informPlayer2 = function () {}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotepiratepython");
	if (this.shArray.length == 0) {
		this.shArray = system.shipsWithRole("coyotepirateescort");
		if (this.shArray.length == 0) {
			this.ship.reactToAIMessage("END_OF_BATTLE");
		} 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.locatePlayer1 = function () {
	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) < 2000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.desired = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S310_11]"), player.ship);
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
	var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
	log(this.name, des.distanceTo(this.ship.position) / 240);
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["greer"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["greer"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.startMove2 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["greerT1"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["greerT1"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.checkSunskim1 = function () {
	var P = system.mainPlanet;
	var targetVector = P.position.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);

}

this.checkSunskim = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			var pos = this.ship.position;
			this.shArray = system.shipsWithPrimaryRole("coyotecameron1");

			this.ship.exitSystem(84);
			if (this.shArray.length > 0) {
				this.shArray[0].position = pos;
			}
		} else if (this.ship.position.distanceTo(player.ship.position) < 15000) {
			if (this.firstMessage) {
				this.ship.commsMessage("Come near to us to follow our wormhole", player.ship);
				this.firstMessage = false;
			}
		}
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}

this.cheatPlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length > 0) {
		if (this.ship.position.distanceTo(player.ship.position) > 40000) {
			if (this.ship.savedCoordinates.distanceTo(this.ship.position) > 21000) {
				this.ship.position = this.ship.position.add(this.ship.vectorForward.multiply(20000));
			}
		}
	}
}

this.cheatPlayer1 = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length > 0) {
		if (this.ship.position.distanceTo(player.ship.position) > 50000) {
			if (player.ship.position.distanceTo(this.ship.position) > 21000) {
				this.ship.position = this.ship.position.add(this.ship.vectorForward.multiply(20000));
			}
		} else {
			if (system.countShipsWithPrimaryRole("coyotebandit2") !== 0) {
				this.ship.reactToAIMessage("WAIT_FOR_BANDITS");
			}
		}
	}
}

this.checkBandit = function () {
	if (system.countShipsWithPrimaryRole("coyotebandit2") == 0) {
		this.ship.reactToAIMessage("HOSTILES_SMASHED");
	}
}
Scripts/coyoteGreer4.js
"use strict";
this.name = "coyoteGreer4";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer2.";

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

this.locatePlayer = function () {
	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) < 3300) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.startMove = function () {
	this.count = 0;
	this.originalDistance = this.ship.position.distanceTo(player.ship.position);
	this.originalPosition = this.ship.position;
	var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
}

this.startMove1 = function () {
	if (this.count >= 240) {
		this.ship.reactToAIMessage("IN_POSITION");
		worldScripts["Coyote-Main"]["greerT1"](this.ship);
	} else {
		this.count += 1;
		//var d = this.originalPosition
		var des = player.ship.position.add(player.ship.vectorRight.multiply(200)).add(player.ship.vectorForward.multiply(-200));
		var targetVector = des.subtract(this.ship.position).direction();
		var angle = this.ship.heading.angleTo(targetVector);
		var cross = this.ship.heading.cross(targetVector).direction();
		this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
		if (des.distanceTo(this.ship.position) < 10) {
			this.ship.reactToAIMessage("IN_POSITION");
			worldScripts["Coyote-Main"]["greerT1"](this.ship);
		} else {
			this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
		}
	}
}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteGreer5.js
"use strict";
this.name = "coyoteGreer5";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreer2.";

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

this.shipDied = function (whom, why) {}

this.shipTakingDamage = function (amount, whom, type) {
	if (!whom) {
		return;
	}
	if (whom.primaryRole == "coyoteferdie10" && this.killByFerdie) {
		this.ship.spawnOne("coyotegreerspod");
		this.ship.explode();
	}
}

this.FDL = function () {
	this.killByFerdie = true;
}
Scripts/coyoteGreersPod.js
"use strict";
this.name = "coyoteGreersPod";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteGreersPod.";

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

this.startMove = function () {
	this.playerArray = system.shipsWithPrimaryRole("coyotecameron5");
	if (this.playerArray.length == 0) {} else {
		this.cameron = this.playerArray[0];
		this.cameron.reactToAIMessage("POD_SPAWNED")
	}
}

this.moveMe = function () {
	this.count += 1;
	//var d = this.originalPosition
	var des = this.cameron.position
	var targetVector = des.subtract(this.ship.position).direction();
	var angle = this.ship.heading.angleTo(targetVector);
	var cross = this.ship.heading.cross(targetVector).direction();
	this.ship.orientation = this.ship.orientation.rotate(cross, -angle);
	if (des.distanceTo(this.ship.position) < 10) {
		this.cameron.commsMessage("I scooped Greer", player.ship);
		this.ship.remove(true);
	} else {
		this.ship.position = this.ship.position.add(targetVector.multiply(des.distanceTo(this.ship.position) / 240));
	}
}
Scripts/coyoteInterceptor.js
"use strict";
this.name = "coyoteInterceptor";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteInterceptor.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	player.consoleMessage("A jump capable interceptor has launched from the station, I think they will analyse our wormhole and come after us.", 6);
}

this.locatePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		this.ship.reactToAIMessage("PLAYER_NOT_FOUND");
	} else {
		this.ship.target = this.playerArray[0];
		this.ship.reactToAIMessage("PLAYER_FOUND");
	}
}
Scripts/coyoteInterceptor1.js
"use strict";
this.name = "coyoteInterceptor1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteInterceptor1.";

this.shipSpawned = function () {
	missionVariables.Coyote_BattleAtBiarra = "STARTED";
}

this.shipDied = function () {
	this.ship.spawnOne("coyoteinterceptorpod");
	player.consoleMessage(expandDescription("[COYOTE_S310_14]"), 6);
	worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_310_10");
}
Scripts/coyoteKatikBoss1.js
"use strict";
this.name = "coyoteKatikBoss1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteKatikBoss1.";

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

this.removeMe = function () {
	this.ship.remove(true);
}

this.message1 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S220_09]"), player.ship);
	this.ship.isCloaked = false;
}

this.exitSystem = function () {
	this.ship.exitSystem(126);
	this.ship.reactToAIMessage("WITCHSPACE OKAY");
	player.commsMessage(expandDescription("[COYOTE_S220_10]"), 6);
	worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_220_02");
}
Scripts/coyoteKatikBoss1Escort.js
"use strict";
this.name = "coyoteKatikBoss1Escort";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteKatikBoss1Escort.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.ship.fuel = 7;
}
Scripts/coyoteKatikBoss2.js
"use strict";
this.name = "coyoteKatikBoss2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteKatikBoss2.";

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

this.shipDied = function (whom, why) {
	this.ship.spawnOne("coyotekatikboss2pod");
	worldScripts["Coyote-Main"]["startSahanaFun"]();
}
Scripts/coyoteKatikBoss3Escort.js
"use strict";
this.name = "coyoteKatikBoss3Escort";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteKatikBoss3Escort.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.ship.fuel = 7.0;
	this.attackCount = 0;
}

this.findSahana = function () {
	this.shpArray = system.shipsWithRole("coyotesahanapod");
	if (this.shpArray.length == 0) {} else {
		this.ship.target = this.shpArray[0];
		this.ship.reactToAIMessage("TARGET_FOUND");
	}
}

this.findBoss = function () {
	this.shpArray = system.shipsWithRole("coyotekatikboss2pod");
	if (this.shpArray.length == 0) {} else {
		this.ship.target = this.shpArray[0];
		this.ship.reactToAIMessage("TARGET_FOUND");
	}
}

this.message1 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_08]"), player.ship);
}

this.message2 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_09]"), player.ship);
	mission.setInstructionsKey("CE_MI_S_225_03", "Coyote-Main");
	this.checkDistanceTimer = new Timer(this, this.checkDistance, 10, 10);
}

this.message4 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_11]"), player.ship);
}

this.message5 = function () {
	player.commsMessage(expandDescription("[COYOTE_S225_12]"), 6);
}

this.message6 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S225_13]"), player.ship);
}

this.message7 = function () {
	this.ship.fuel = 7;
	this.ship.exitSystem(185);
	mission.setInstructionsKey("CE_MI_S_225_05", "Coyote-Main");
}

this.checkDistance = function () {
	if (this.ship.position.distanceTo(system.mainStation.position) < 350000 && this.attackCount == 0) {
		if (this.ship.position.distanceTo(player.ship.position) < 25000) {
			var pos = this.ship.position.add(this.ship.vectorForward.multiply(25000));
			system.addShips("coyoteasp225", 2, pos, 500);
			system.addShips("coyoteferdie225", 1, pos, 500);
			system.addShips("coyoteferdie226", 1, pos, 500);
			this.ship.commsMessage(expandDescription("[COYOTE_S225_09a]"), player.ship);
			mission.setInstructionsKey("CE_MI_S_225_04", "Coyote-Main");
			this.ship.reactToAIMessage("AMBUSH_1");
			this.attackCount += 1;
			this.checkDistanceTimer.stop();
		}
	}
}

this.shipDied = function (whom, why) {
	this.ship.spawnOne("coyotesahanapod2");
}

this.addFuel = function () {
	this.ship.fuel = 7.0;
}

this.shipDockedWithStation = function () {
	player.commsMessage(expandDescription("[COYOTE_S225_10]"), 6);
	missionVariables.Coyote_status = "STAGE_229";
}

this.checkFacing = function () {
	this.stationBuoy = system.entitiesWithScanClass("CLASS_BUOY", system.mainStation, 12000)[0];
	let idealVector = system.mainStation.position.subtract(this.stationBuoy.position).direction(); // direction 
	let targetVector = system.mainStation.position.subtract(this.ship.position).direction(); // direction unit 
	let shipOrientation = this.ship.orientation;
	let shipHeading = shipOrientation.vectorForward().direction(); // the way the ship is pointing (Z-axis)
	let shipPitch = shipOrientation.vectorUp(); // ship's up and down (Y-axis)
	let shipYaw = shipOrientation.vectorRight(); // ship's left and right (X-axis)
	this.shipAngle = shipHeading.angleTo(targetVector); // how accurately ship is pointing at the station centre
	this.shipUD = Math.abs(shipPitch.dot(idealVector)); // how far off-axis we are in the Y direction
	this.shipLR = Math.abs(shipYaw.dot(idealVector)); // how far off-axis we are in the X direction
	if (this.shipUD < 0.02 && this.shipLR < 0.02) {
		this.ship.fuel = 7.0;
		this.ship.reactToAIMessage("DOCK_WITH_INJECTORS");
		this.dockSahanaTId = addFrameCallback(this.dockSahana.bind(this));
	}
}

this.dockSahana = function () {
	if (this.ship.isValid) {
		var norient = system.mainStation.orientation.rotate(system.mainStation.vectorForward, 3.14159 / 2);
		this.ship.orientation = norient.rotate(system.mainStation.vectorUp, 3.14159);
	} else {
		if (isValidFrameCallback(this.dockSahanaTId)) {
			removeFrameCallback(this.dockSahanaTId);
		}
	}
}

this.shipScoopedOther = function (whom) {
	if (whom.primaryRole == "coyotesahanapod") {
		this.podTimer = new Timer(this, this.podTim, 4, 0);
	}
}

this.podTim = function () {
	this.ship.displayName = "Sahana";
	this.ship.commsMessage(expandDescription("[COYOTE_S225_07]"), player.ship);
	this.ship.spawnOne("coyotesahanapod2");
}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteKatikHermit.js
"use strict";
this.name = "coyoteKatikHermit";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAnaconda and python during STAGE_160.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.ctTimer = new Timer(this, this.checkTemp, 5, 5)
	this.heatLevel = 0;
}

this.shipDied = function (whom, why) {
	missionVariables.Coyote_status = "STAGE_225";
}

this.checkTemp = function () {
	if (this.ship.temperature >= 0.99) {
		this.ship.spawnOne("coyotekatikboss1")
		this.ctTimer.stop();
		this.ship.explode();
	} else if (this.ship.temperature >= 0.80 && this.heatLevel == 0) {
		this.heatLevel += 1;
		this.ship.commsMessage(expandDescription("[COYOTE_S220_04]"), player.ship);
	} else if (this.ship.temperature >= 0.80 && this.heatLevel == 1) {
		this.heatLevel += 1;
		this.ship.commsMessage(expandDescription("[COYOTE_S220_05]"), player.ship);
	} else if (this.ship.temperature >= 0.80 && this.heatLevel == 2) {
		this.heatLevel += 1;
		player.commsMessage(expandDescription("[COYOTE_S220_06]"), 6);

	} else if (this.ship.temperature >= 0.80 && this.heatLevel == 3) {
		this.heatLevel += 1;
		this.ship.commsMessage(expandDescription("[COYOTE_S220_07]"), player.ship);
	} else if (this.ship.temperature >= 0.80 && this.heatLevel == 4) {
		this.heatLevel += 1;
		player.commsMessage(expandDescription("[COYOTE_S220_08]"), 6);
	}
}
Scripts/coyoteLobo1.js
"use strict";
this.name = "coyoteLobo1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteLebo1.";

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

this.locatePlayer = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteviper1");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("VIPER_DEAD");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
			return;
		} else {}
	}
	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");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.informPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S140_01]"), player.ship);
	worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_140_01");
}

this.informPlayer2 = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S150_01]"), player.ship);
	worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_150_01");
	this.ship.bounty = 0;
	player.ship.bounty = 0;
	mission.unmarkSystem(72);
}

this.shipStartAttack = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteviper1");
	if (this.shArray.length == 0) {
		this.ship.reactToAIMessage("VIPER_DEAD");
	} else {
		if (this.ship.position.distanceTo(this.shArray[0].position) < 25000) {
			this.ship.target = this.shArray[0];
			this.ship.reactToAIMessage("VIPER_FOUND");
		} else {
			this.ship.reactToAIMessage("NOTHING_FOUND");
		}
	}
}

this.clearLegalStatus = function () {
	this.ship.bounty = 0;
}

this.locatePlayer2 = function () {
	this.playerArray = system.shipsWithPrimaryRole("player", this.ship);
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		this.ship.target = this.playerArray[0];
		if (this.ship.position.distanceTo(player.ship.position) < 10000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}
Scripts/coyoteLobo2.js
"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");
		}
	}
}
Scripts/coyoteLobo4.js
"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");
		}
	}
}
Scripts/coyoteLobo5.js
"use strict";
this.name = "coyoteLobo5";
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.locatePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		//this.ship.remove(); 
	} else {
		if (this.ship.position.distanceTo(player.ship.position) < 12000) {
			this.ship.reactToAIMessage("PLAYER_NEAR");
		} else {}
	}
}

this.questionPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S220_01]"), player.ship);
	player.consoleMessage(expandDescription("[COYOTE_S220_03]"), 6);
}

this.replyPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S220_02]"), player.ship);
	this.playerArray = system.shipsWithPrimaryRole("coyotezorra5");
	if (this.playerArray.length == 0) {
		//this.ship.remove(); 
	} else {
		this.playerArray[0].setAI("route1traderAI.plist");
	}
}
Scripts/coyoteMamba1.js
"use strict";
this.name = "coyoteMamba1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteMamba 1.";

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

this.flee = function () {
	missionVariables.CoyoteFerdie_status = "FLEE";
}

this.shipDied = function () {
	missionVariables.CoyoteFerdie_status = "FLEE";
}

this.checkPilotRescue = function () {
	if (missionVariables.CoyotePhythonPilot = "RESCUED") {
		this.ship.position = player.ship.position.add(player.ship.vectorForward.multiply(25000));
		this.ship.target = player.ship;
		this.ship.reactToAIMessage("ATTACK_PLAYER");
	}
}

this.locatePlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {
		this.ship.remove();
	} else {
		this.ship.target = this.playerArray[0];
		this.ship.reactToAIMessage("PLAYER_FOUND");
	}
}
Scripts/coyoteNavystationMarket.js
"use strict";
this.name = "coyoteNavystationMarket";
this.author = "spara";
this.copyright = "2014 spara";
this.license     = "CC BY-NC-SA 4.0";

this.$originalDefs = {
      "food" : [0, 0, 13, 0, 0, 0, 0, 0, 0],
      "textiles" : [0, 0, 19, 0, 0, 0, 0, 0, 0],
      "radioactives" : [0, 0, 98, 0, 0, 0, 0, 0, 0],
      "slaves" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "liquor_wines" : [0, 0, 104, 0, 0, 0, 0, 0, 0],
      "luxuries" : [0, 0, 189, 0, 0, 0, 0, 0, 0],
      "narcotics" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "computers" : [0, 0, 150, 0, 0, 0, 0, 0, 0],
      "machinery" : [0, 0, 122, 0, 0, 0, 0, 0, 0],
      "alloys" : [0, 0, 107, 0, 0, 0, 0, 0, 0],
      "firearms" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "furs" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "minerals" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "gold" : [0, 0, 92, 0, 0, 0, 0, 0, 1],
      "platinum" : [0, 0, 183, 0, 0, 0, 0, 0, 1],
      "gem_stones" : [0, 0, 53, 0, 0, 0, 0, 0, 2],
      "alien_items" : [0, 0, 224, 0, 0, 0, 0, 0, 0]
};

this.updateLocalCommodityDefinition = function(goodDefinition) {
	var commodity = goodDefinition.key;
	var oldDefs = this.$originalDefs[commodity];
	//old style definition found for the good. calculate it the old way
	if (oldDefs) {
		var market_base_price = oldDefs[2];
		var market_eco_adjust_price = oldDefs[3];
		var market_eco_adjust_quantity = oldDefs[4];
		var market_base_quantity = oldDefs[5];
		var market_mask_price = oldDefs[6];
		var market_mask_quantity = oldDefs[7];
		var market_rnd = Math.floor(Math.random() * 256);

		var economy = system.economy;

		var price = (market_base_price + (market_rnd & market_mask_price) + (economy * market_eco_adjust_price)) & 255;
		price *= 0.4;

		var quantity = (market_base_quantity + (market_rnd & market_mask_quantity) - (economy * market_eco_adjust_quantity)) & 255;
		if (quantity > 127) quantity = 0;
		quantity &= 63;

		goodDefinition.price = price * 10;
		goodDefinition.quantity = quantity;
	}
	//no definition found. nullify the goods.
	else {
		goodDefinition.price = 0;
		goodDefinition.quantity = 0;
	}
	return goodDefinition;
};
Scripts/coyotePython2.js
"use strict";
this.name = "coyotepython2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyotepython2.";

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

this.checkFerdie = function () {
	if (missionVariables.CoyoteFerdie_status == "FLEE" || missionVariables.CoyoteFerdie_status == "KILLED") {
		this.ship.target = player.ship;
		this.ship.reactToAIMessage("FERDIE_FLEED");
	}
}

this.eject = function () {
	if (this.ship.equipmentStatus("EQ_ESCAPE_POD") == "EQUIPMENT_OK") {
		player.commsMessage(expandDescription("[COYOTE_S_01]"), 10);
		player.commsMessage(expandDescription("[COYOTE_S_02]"), 10);
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_20_03");
		this.ship.abandonShip();
	} else {
		this.ship.awardEquipment("EQ_ESCAPE_POD");
		player.commsMessage(expandDescription("[COYOTE_S_01]"), 10);
		player.commsMessage(expandDescription("[COYOTE_S_02]"), 10);
		worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_20_03");
		this.ship.abandonShip();
	}
}

this.checkEnergy = function () {
	if (this.damaged > 500) {
		this.ship.reactToAIMessage("ENERGY_LOW");
	} else {
		this.ship.target = player.ship;
	}
}

this.shipTakingDamage = function (amount, whom, type) {
	this.damaged += amount;
}
Scripts/coyotePython200.js
"use strict";
this.name = "coyotePython200";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteAnaconda and python during STAGE_160.";

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

this.shipDied = function (whom, why) {
	missionVariables.Coyote_KatikHunt += 1;
}
Scripts/coyotePythonStart.js
"use strict";
this.name = "coyotePythonStart";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyotepythonStart.";

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

this.FindPlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {} else {
		this.ship.target = this.playerArray[0];
		this.ship.reactToAIMessage("PLAYER_FOUND");
	}
}

this.checkDistanceToPlayer = function () {
	this.playerArray = system.shipsWithPrimaryRole("player");
	if (this.playerArray.length == 0) {} else {
		if (player.ship.position.distanceTo(this.ship.position) < 5000) {
			player.commsMessage(expandDescription("[COYOTE_START6]"), 10);
			player.commsMessage(expandDescription("[COYOTE_START7]"), 10);
			//mission.setInstructionsKey("COYOTE_MI_STAGE_10_02","Coyote-Main.js");
			system.addShips("coyoteferdiestart", 1, player.ship.position.add(player.ship.vectorForward.multiply(-25000)), 100);

			worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_10_02");
			this.ship.reactToAIMessage("PREPARE_TO_EXIT_SYSTEM");
		}
	}
}

this.exitSystem = function () {
	this.ship.fuel = 7.0;
	this.ship.exitSystem(144);
}

this.removeMe = function () {
	this.ship.remove(true);
}
Scripts/coyoteQBomb.js
"use strict";
this.name = "coyoteQBomb";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteQBomb.";

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

this.checkDistance = function () {
	this.playerArray = system.shipsWithPrimaryRole("coyotekatikrockhermit");
	if (this.playerArray.length == 0) {
		this.ship.remove(true);
	} else {
		if (this.ship.position.distanceTo(this.playerArray[0].position) > 500) {
			this.ship.remove(true);
		}
	}
}
Scripts/coyoteRogueViper1.js
"use strict";
this.name = "coyoteRogueViper1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteViper1.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	//missionVariables.Coyote_ViperCount +=1;
}

this.shipLaunchedFromStation = function (station) {
	missionVariables.Coyote_ViperCount += 1;

}
Scripts/coyoteRogueViper2.js
"use strict";
this.name = "coyoteRogueViper2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteViper2.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
}
Scripts/coyoteSahana2.js
"use strict";
this.name = "coyoteSahana2";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteSahana2.";

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

this.addFuel = function () {
	this.ship.fuel = 7.0;
}

this.shipDockedWithStation = function () {
	player.commsMessage(expandDescription("[COYOTE_S225_10]"), 6);
	missionVariables.Coyote_status = "STAGE_229";
}

this.locatePlayer = function () {
	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) < 25000) {}
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.checkFacing = function () {
	this.stationBuoy = system.entitiesWithScanClass("CLASS_BUOY", system.mainStation, 12000)[0];
	let idealVector = system.mainStation.position.subtract(this.stationBuoy.position).direction(); // direction 
	let targetVector = system.mainStation.position.subtract(this.ship.position).direction(); // direction unit 
	let shipOrientation = this.ship.orientation;
	let shipHeading = shipOrientation.vectorForward().direction(); // the way the ship is pointing (Z-axis)
	let shipPitch = shipOrientation.vectorUp(); // ship's up and down (Y-axis)
	let shipYaw = shipOrientation.vectorRight(); // ship's left and right (X-axis)
	this.shipAngle = shipHeading.angleTo(targetVector); // how accurately ship is pointing at the station centre
	this.shipUD = Math.abs(shipPitch.dot(idealVector)); // how far off-axis we are in the Y direction
	this.shipLR = Math.abs(shipYaw.dot(idealVector)); // how far off-axis we are in the X direction
	if (this.shipUD < 0.02 && this.shipLR < 0.02) {
		this.ship.fuel = 7.0;
		this.ship.reactToAIMessage("DOCK_WITH_INJECTORS");
		this.dockSahanaTId = addFrameCallback(this.dockSahana.bind(this));
	}
}

this.dockSahana = function () {
	if (this.ship.isValid) {
		var norient = system.mainStation.orientation.rotate(system.mainStation.vectorForward, 3.14159 / 2);
		this.ship.orientation = norient.rotate(system.mainStation.vectorUp, 3.14159);
	} else {
		if (isValidFrameCallback(this.dockSahanaTId)) {
			removeFrameCallback(this.dockSahanaTId);
		}
	}
}

this.scanFor200 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyotepython230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor200E = function () {
	this.shArray = system.shipsWithRole("coyotepirateescort2");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor201 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteferdie230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

this.scanFor202 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteasp230");
	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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}
Scripts/coyoteTractorBeam.js
"use strict";
this.name = "coyoteTractorBeam";
this.copyright = "(C) 2011 Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Tractor Beam Implementation";

this.activated = function () {
	if (!missionVariables.coyote_beam) {
		if (!player.ship.target) {
			player.consoleMessage("No active target", 6);
			return;
		}
		if (player.ship.target.mass > 200000000) {
			player.consoleMessage("Target has too much mass for this equipment", 6);
			return;
		}
		if (player.ship.target.position.distanceTo(player.ship.position) > 1000) {
			player.consoleMessage("Target is too far away to engage", 6);
			return;
		}
		var targetVector = player.ship.target.position.subtract(player.ship.position).direction();
		var angle = player.ship.heading.multiply(-1).angleTo(targetVector);
		if (angle > .10) {
			player.consoleMessage("Target must be on your rear to engage.", 6);
			return;
		}

		worldScripts["Coyote-Main"].tractorBeam();
	} else {
		worldScripts["Coyote-Main"].dtractorBeam();
	}
}
Scripts/coyoteViper1.js
"use strict";
this.name = "coyoteViper1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteViper1.";

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

this.shipDied = function (whom, why) {
	missionVariables.Coyote_status = "STAGE_150";
}
Scripts/coyoteViperLeader.js
"use strict";
this.name = "coyoteViperLeader";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteViperLeader.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.firstMessage = false;
	this.firstMessage1 = false;
	this.messageCount = 0;
}

this.locatePlayer = function () {
	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) < 25000) {
			if (this.firstMessage == false) {
				this.ship.commsMessage(expandDescription("[COYOTE_S280_02]"), player.ship);
				this.firstMessage = true;
			}
		}
		if (this.ship.position.distanceTo(player.ship.position) < 1000) {
			if (player.ship.speed !== 0) {
				this.ship.reactToAIMessage("PLAYER_NOT_STOPED");
				return;
			}
		}
		if (this.ship.position.distanceTo(player.ship.position) < 200) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.checkPlayer = function () {
	if (this.messageCount > 30) {
		if (system.ID !== 20) {
			this.ship.commsMessage(expandDescription("[COYOTE_S280_04]"), player.ship);
			this.ship.reactToAIMessage("INSPECTION_FINISHED");
			missionVariables.Coyote_status = "STAGE_290"
		} else {
			this.ship.commsMessage(expandDescription("[COYOTE_S280_04]"), player.ship);
			missionVariables.Coyote_status = "STAGE_340"
			worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_310_09");
			this.ship.reactToAIMessage("INSPECTION_FINISHED");
		}
	} else {
		this.messageCount += 1;
		if (player.ship.speed == 0) {
			if (this.firstMessage1 == false) {
				this.ship.commsMessage(expandDescription("[COYOTE_S280_03]"), player.ship);
				this.firstMessage1 = true;
			}
			this.ship.reactToAIMessage("PLAYER_STOPPED");
		} else {
			this.ship.reactToAIMessage("PLAYER_NOT_STOPPED");
		}
	}
}
Scripts/coyoteZorra1.js
"use strict";
this.name = "coyoteZorra1";
this.author = "Okti";
this.copyright = "(C) Okti";
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
this.description = "Ship script for coyoteZorra1.";

this.shipSpawned = function () {
	//this.ship.reportAIMessages = true;
	this.ship.fuel = 7.0;
	this.firstMessage = false;
}

this.fMessage = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S130_00]"), player.ship);
	this.firstMessage = true;
	this.ship.reactToAIMessage("LOOKFOR_TARGET");
}

this.locatePlayer = function () {
	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) < 25000) {
			if (this.firstMessage == false) {
				this.ship.commsMessage(expandDescription("[COYOTE_S130_00]"), player.ship);
				this.firstMessage = true;
				this.ship.reactToAIMessage("LOOKFOR_TARGET");
			}
		}
		if (this.ship.position.distanceTo(player.ship.position) < 3000) {
			this.ship.reactToAIMessage("DESIRED_RANGE_ACHIEVED");
		} else {
			this.ship.reactToAIMessage("PLAYER_FOUND");
		}
	}
}

this.scanFor200 = function () {
	this.shArray = system.shipsWithPrimaryRole("coyoteAnaconda");
	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");
		} 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");
		} else {
			this.ship.reactToAIMessage("TARGET_FAR");
		}
	}
}

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.informPlayer = function () {
	this.ship.commsMessage(expandDescription("[COYOTE_S130_01]"), player.ship);
	worldScripts["Coyote-Main"]["setMissionInstructions"]("CE_MI_S_130_01");
	mission.unmarkSystem(128);
	mission.markSystem(72);
}

this.exitSystem = function () {
	this.ship.fuel = 7.0;
	this.ship.exitSystem(72);
	missionVariables.Coyote_status = "STAGE_140";
}

this.removeMe = function () {
	this.ship.remove(true);
}