diff --git a/Resources/AIs/thargletAI.js b/Resources/AIs/thargletAI.js index b9f07a1d..f29189ef 100644 --- a/Resources/AIs/thargletAI.js +++ b/Resources/AIs/thargletAI.js @@ -35,6 +35,7 @@ this.aiStarted = function() { ai.setCommunicationsRole("_thargoid"); ai.setCommunicationsPersonality("tharglet"); + ai.setParameter("oolite_flag_fightsNearHostileStations",true); ai.setParameter("oolite_flag_scanIgnoresUnpowered",true); ai.setPriorities([ diff --git a/Resources/AIs/thargoidAI.js b/Resources/AIs/thargoidAI.js index a4ba0ffc..e46ca3b9 100644 --- a/Resources/AIs/thargoidAI.js +++ b/Resources/AIs/thargoidAI.js @@ -32,6 +32,8 @@ this.version = "1.79"; this.aiStarted = function() { var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship); + ai.setParameter("oolite_flag_fightsNearHostileStations",true); + ai.setCommunicationsRole("_thargoid"); ai.setCommunicationsPersonality("thargoid"); diff --git a/Resources/Scripts/oolite-ailib.js b/Resources/Scripts/oolite-ailib.js index 2a5e6222..47283597 100644 --- a/Resources/Scripts/oolite-ailib.js +++ b/Resources/Scripts/oolite-ailib.js @@ -509,6 +509,11 @@ AILib.prototype.allied = function(ship1,ship2) AILib.prototype.broadcastDistressMessage = function() { + if (this.__ltcache.oolite_sentDistressMessage) + { + return; + } + this.__ltcache.oolite_sentDistressMessage = true; this.ship.broadcastDistressMessage(); if (this.ship.AIPrimaryAggressor) { @@ -4235,6 +4240,13 @@ AILib.prototype.responseComponent_standard_distressMessageReceived = function(ag { return; } + if (this.ship.scanClass == "CLASS_POLICE" || (this.ship.isStation && this.ship.allegiance == "galcop")) + { + if (this.distance(aggressor) < this.scannerRange) + { + aggressor.bounty |= 8; + } + } this.setParameter("oolite_distressAggressor",aggressor); this.setParameter("oolite_distressSender",sender); this.setParameter("oolite_distressTimestamp",clock.adjustedSeconds); @@ -4375,7 +4387,7 @@ AILib.prototype.responseComponent_standard_shipAttackedOther = function(other) AILib.prototype.responseComponent_standard_shipAttackedWithMissile = function(missile,whom) { - if (!this.ship.hasHostileTarget && this.getParameter("oolite_flag_sendsDistressCalls")) + if (this.getParameter("oolite_flag_sendsDistressCalls")) { this.broadcastDistressMessage(); } @@ -4459,7 +4471,7 @@ AILib.prototype.responseComponent_standard_shipBeingAttacked = function(whom) // don't get confused and shoot the station! this.ship.target = null; } - if (!this.ship.hasHostileTarget && this.getParameter("oolite_flag_sendsDistressCalls")) + if (this.getParameter("oolite_flag_sendsDistressCalls")) { this.broadcastDistressMessage(); } @@ -4534,7 +4546,7 @@ AILib.prototype.responseComponent_standard_shipBeingAttacked = function(whom) AILib.prototype.responseComponent_standard_shipBeingAttackedUnsuccessfully = function(whom) { - if (!this.ship.hasHostileTarget && this.getParameter("oolite_flag_sendsDistressCalls")) + if (this.getParameter("oolite_flag_sendsDistressCalls")) { this.broadcastDistressMessage(); } @@ -4873,6 +4885,13 @@ AILib.prototype.responseComponent_station_distressMessageReceived = function(agg { return; } + if (this.ship.scanClass == "CLASS_POLICE" || (this.ship.isStation && this.ship.allegiance == "galcop")) + { + if (this.distance(aggressor) < this.scannerRange) + { + aggressor.bounty |= 8; + } + } this.setParameter("oolite_distressAggressor",aggressor); this.setParameter("oolite_distressSender",sender); this.setParameter("oolite_distressTimestamp",clock.adjustedSeconds); diff --git a/src/Core/Entities/ShipEntityAI.m b/src/Core/Entities/ShipEntityAI.m index a2872617..6c3068df 100644 --- a/src/Core/Entities/ShipEntityAI.m +++ b/src/Core/Entities/ShipEntityAI.m @@ -806,10 +806,16 @@ // we only can send distressMessages to ships that are known to have a "ACCEPT_DISTRESS_CALL" reaction // in their AI, or they might react wrong on the added found_target. - // FIXME: this test only works with core AIs - if (ship->isStation || [ship hasPrimaryRole:@"police"] || [ship hasPrimaryRole:@"hunter"]) + // ship must have a plist AI for this next bit. JS AIs + // should already have done something sensible on + // distressMessageReceived + if (![[[self getAI] name] isEqualToString:@"nullAI.plist"]) { - [ship acceptDistressMessageFrom:self]; + // FIXME: this test only works with core AIs + if (ship->isStation || [ship hasPrimaryRole:@"police"] || [ship hasPrimaryRole:@"hunter"]) + { + [ship acceptDistressMessageFrom:self]; + } } } }