"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));
	}
}