Allow trader AI to make distress calls
JS-sourced distress calls don't automatically dump cargo or flee
This commit is contained in:
parent
34ce5ed934
commit
b8da00024b
@ -32,7 +32,7 @@ this.version = "1.79";
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_sendsDistressCalls",true);
|
||||
ai.setParameter("oolite_flag_sendsDistressCalls",true);
|
||||
|
||||
/* Communications currently for debugging purposes. Need to either
|
||||
* be removed or given a much bigger set of phrases to choose from
|
||||
|
@ -179,10 +179,21 @@ this.AILib = function(ship)
|
||||
}
|
||||
|
||||
/* Requests reconsideration of behaviour ahead of schedule. */
|
||||
this.reconsiderNow = function() {
|
||||
this.reconsiderNow = function()
|
||||
{
|
||||
_resetReconsideration.call(this,0.25);
|
||||
}
|
||||
|
||||
/* Stops timer (for script shutdown) */
|
||||
this.stopTimer = function()
|
||||
{
|
||||
if (reconsiderationTimer != null)
|
||||
{
|
||||
reconsiderationTimer.stop();
|
||||
reconsiderationTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.setUpHandlers = function(handlers)
|
||||
{
|
||||
@ -1543,6 +1554,10 @@ this.AILib = function(ship)
|
||||
|
||||
handlers.shipAttackedWithMissile = function(missile,whom)
|
||||
{
|
||||
if (!this.ship.hasHostileTarget && this.ship.getParameter("oolite_flag_sendsDistressCalls"))
|
||||
{
|
||||
this.ship.broadcastDistressMessage();
|
||||
}
|
||||
if (this.ship.equipmentStatus("EQ_ECM") == "EQUIPMENT_OK")
|
||||
{
|
||||
this.ship.fireECM();
|
||||
@ -1579,6 +1594,10 @@ this.AILib = function(ship)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this.ship.hasHostileTarget && this.getParameter("oolite_flag_sendsDistressCalls"))
|
||||
{
|
||||
this.ship.broadcastDistressMessage();
|
||||
}
|
||||
if (this.ship.defenseTargets.indexOf(whom) < 0)
|
||||
{
|
||||
this.ship.addDefenseTarget(whom);
|
||||
@ -1601,6 +1620,10 @@ this.AILib = function(ship)
|
||||
};
|
||||
handlers.shipBeingAttackedUnsuccessfully = function(whom)
|
||||
{
|
||||
if (!this.ship.hasHostileTarget && this.getParameter("oolite_flag_sendsDistressCalls"))
|
||||
{
|
||||
this.ship.broadcastDistressMessage();
|
||||
}
|
||||
if (this.ship.defenseTargets.indexOf(whom) < 0)
|
||||
{
|
||||
this.ship.addDefenseTarget(whom);
|
||||
@ -1611,7 +1634,7 @@ this.AILib = function(ship)
|
||||
{
|
||||
this.reconsiderNow();
|
||||
};
|
||||
// TODO: this one needs overriding for escorts
|
||||
// overridden for escorts
|
||||
handlers.helpRequestReceived = function(ally, enemy)
|
||||
{
|
||||
this.ship.addDefenseTarget(enemy);
|
||||
@ -1642,8 +1665,14 @@ this.AILib = function(ship)
|
||||
this.ship.desiredRange = 15000;
|
||||
this.ship.performFlyToRangeFromDestination();
|
||||
}
|
||||
handlers.shipWillEnterWormhole = function()
|
||||
{
|
||||
this.setUpHandlers({});
|
||||
this.stopTimer();
|
||||
}
|
||||
handlers.shipExitedWormhole = function()
|
||||
{
|
||||
this.ship.AIScript.oolite_intership = {};
|
||||
// this.reconsiderNow();
|
||||
}
|
||||
|
||||
@ -1731,6 +1760,7 @@ this.AILib = function(ship)
|
||||
|
||||
}
|
||||
|
||||
/* Additional handlers for scooping */
|
||||
this.responsesAddScooping = function(handlers)
|
||||
{
|
||||
handlers.shipAchievedDesiredRange = function()
|
||||
|
@ -67,6 +67,7 @@ MA 02110-1301, USA.
|
||||
- (void) performTumble;
|
||||
|
||||
- (void) broadcastDistressMessage;
|
||||
- (void) broadcastDistressMessageWithDumping:(BOOL)dumpCargo;
|
||||
|
||||
- (void) requestDockingCoordinates;
|
||||
- (void) recallDockingInstructions;
|
||||
|
@ -741,7 +741,11 @@
|
||||
- (void) broadcastDistressMessage
|
||||
{
|
||||
/*-- Locates all the stations, bounty hunters and police ships in range and tells them that you are under attack --*/
|
||||
|
||||
[self broadcastDistressMessageWithDumping:YES];
|
||||
}
|
||||
|
||||
- (void) broadcastDistressMessageWithDumping:(BOOL)dumpCargo
|
||||
{
|
||||
[self checkScanner];
|
||||
DESTROY(_foundTarget);
|
||||
|
||||
@ -762,7 +766,7 @@
|
||||
ShipEntity* ship = scanned_ships[i];
|
||||
|
||||
// dump cargo if energy is low
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
if (dumpCargo && !is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self ejectCargo];
|
||||
[self performFlee];
|
||||
|
@ -3177,7 +3177,7 @@ static JSBool ShipBroadcastDistressMessage(JSContext *context, uintN argc, jsval
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt broadcastDistressMessage];
|
||||
[thisEnt broadcastDistressMessageWithDumping:NO];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user