"use strict";
this.name = "Blackmonk Station AI";

this.$advertise = function () {
	ship.commsMessage("[monk-greeting]");
}

//this is read from ship script and controls the warning given to the hostile player when fire upon
this.$warn = true;

this.aiStarted = function () {
	var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
	var aiScript = this;

	ai.setParameter("oolite_flag_markOffenders", true);

	ai.setCommunicationsRole("station");

	ai.setPriorities([
		/* Fight */
		{
			preconfiguration: ai.configurationStationValidateTarget,
			condition: ai.conditionInCombat,
			behaviour: ai.behaviourStationLaunchDefenseShips,
			reconsider: 5
		},
		/* Advertise */
		{
			condition: ai.conditionPlayerNearby,
			configuration: function () {
				if (!aiScript.$adTimer) {
					aiScript.$adTimer = new Timer(aiScript, aiScript.$advertise, 20, 120);
				}
			}
		},
		{
			notcondition: ai.conditionPlayerNearby,
			configuration: function () {
				aiScript.$warn = true;
				if (aiScript.$adTimer) {
					aiScript.$adTimer.stop();
					delete aiScript.$adTimer;
				}
			}
		},
		{
			configuration: ai.configurationStationReduceAlertLevel,
			behaviour: ai.behaviourStationManageTraffic,
			reconsider: 60
		}
	]);
}
