JSAI: Constrictor
This commit is contained in:
parent
be6d167f38
commit
be388e4fa2
69
Resources/AIs/ooliteConstrictorAI.js
Normal file
69
Resources/AIs/ooliteConstrictorAI.js
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
|
||||
ooliteConstrictorAI.js
|
||||
|
||||
Priority-based AI for the Constrictor
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2013 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
this.name = "Oolite Constrictor AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
preconfiguration: function()
|
||||
{
|
||||
if (this.ship.script._checkDistance)
|
||||
{
|
||||
this.ship.script._checkDistance();
|
||||
}
|
||||
},
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Stop following me! */
|
||||
{
|
||||
condition: ai.conditionPlayerNearby,
|
||||
configuration: ai.configurationAcquirePlayerAsTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Return to witchpoint */
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 5
|
||||
}
|
||||
]);
|
||||
}
|
@ -1146,7 +1146,7 @@
|
||||
"oolite_template_constrictor" =
|
||||
{
|
||||
aft_eject_position = "0.0 5.5 -19.0";
|
||||
ai_type = "oolite-constrictor-AI.plist";
|
||||
ai_type = "ooliteConstrictorAI.js";
|
||||
bounty = 250;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 5;
|
||||
|
@ -907,6 +907,12 @@ this.AILib = function(ship)
|
||||
}
|
||||
|
||||
|
||||
this.conditionPlayerNearby = function()
|
||||
{
|
||||
return this.ship.position.distanceTo(player.ship) < this.ship.scannerRange;
|
||||
}
|
||||
|
||||
|
||||
this.conditionFriendlyStationNearby = function()
|
||||
{
|
||||
var stations = system.stations;
|
||||
@ -1297,6 +1303,7 @@ this.AILib = function(ship)
|
||||
}
|
||||
}
|
||||
this.setParameter("oolite_lastFleeing",this.ship.target);
|
||||
this.ship.desiredRange = this.ship.scannerRange;
|
||||
this.ship.performFlee();
|
||||
}
|
||||
|
||||
@ -1510,6 +1517,12 @@ this.AILib = function(ship)
|
||||
this.responsesAddStandard(handlers);
|
||||
this.responsesAddDocking(handlers);
|
||||
this.ship.requestDockingInstructions();
|
||||
if (!this.ship.dockingInstructions)
|
||||
{
|
||||
this.ship.performIdle();
|
||||
this.reconsiderNow();
|
||||
return;
|
||||
}
|
||||
switch (this.ship.dockingInstructions.ai_message)
|
||||
{
|
||||
case "TOO_BIG_TO_DOCK":
|
||||
@ -2283,12 +2296,20 @@ this.AILib = function(ship)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.configurationAcquirePlayerAsTarget = function()
|
||||
{
|
||||
this.ship.target = player.ship;
|
||||
}
|
||||
|
||||
|
||||
this.configurationCheckScanner = function()
|
||||
{
|
||||
this.setParameter("oolite_scanResults",this.ship.checkScanner());
|
||||
this.setParameter("oolite_scanResultSpecific",null);
|
||||
}
|
||||
|
||||
|
||||
this.configurationAcquireScannedTarget = function()
|
||||
{
|
||||
this.ship.target = this.getParameter("oolite_scanResultSpecific");
|
||||
|
Loading…
x
Reference in New Issue
Block a user