Various adjustments and bugfixes to assassination, parcel contracts

This commit is contained in:
cim 2013-09-15 16:00:26 +01:00
parent 4c733916f2
commit c19476ac8e
5 changed files with 52 additions and 28 deletions

View File

@ -37,6 +37,7 @@ this.aiStarted = function() {
ai.setCommunicationsRole("assassin"); ai.setCommunicationsRole("assassin");
ai.setParameter("oolite_flag_witchspacePursuit",true); ai.setParameter("oolite_flag_witchspacePursuit",true);
ai.setParameter("oolite_flag_surrendersLate",true);
ai.setPriorities([ ai.setPriorities([
/* Fight */ /* Fight */

View File

@ -277,7 +277,7 @@ this._initialiseCargoContractsForSystem = function()
attempts++; attempts++;
var commodity = commodities[Math.floor(Math.random()*commodities.length)]; var commodity = commodities[Math.floor(Math.random()*commodities.length)];
// sub-tc contracts only available for top rep // sub-tc contracts only available for top rep
if (system.mainStation.market[commodity].quantityUnit != 0 && player.contractReputation != 7) if (system.mainStation.market[commodity].quantityUnit != 0 && player.contractReputation < 6.5)
{ {
} }
// ignore commodities with 0 availability here // ignore commodities with 0 availability here

View File

@ -777,7 +777,7 @@ this.systemWillPopulate = function()
// if carrying high-risk contracts through dangerous systems, // if carrying high-risk contracts through dangerous systems,
// especially bottlenecks, add some more assassins // especially bottlenecks, add some more assassins
// specifically waiting for the player // specifically waiting for the player
var cs = ship.parcels; var cs = player.ship.parcels;
for (var i = cs.length-1; i >= 0 ; i--) for (var i = cs.length-1; i >= 0 ; i--)
{ {
if (bottleneck) if (bottleneck)
@ -793,10 +793,12 @@ this.systemWillPopulate = function()
} }
else if (cs[i].destination == system.ID) else if (cs[i].destination == system.ID)
{ {
// if you're going to intercept, waiting in the
// destination system for the package isn't a bad idea
initial += Math.random()*cs[i].risk; initial += Math.random()*cs[i].risk;
} }
} }
cs = ship.passengers; cs = player.ship.passengers;
for (i = cs.length-1; i >= 0 ; i--) for (i = cs.length-1; i >= 0 ; i--)
{ {
if (bottleneck) if (bottleneck)
@ -1837,13 +1839,12 @@ this._addAssassin = function(pos)
if (Math.random() > g / 10) if (Math.random() > g / 10)
{ {
role = "assassin-medium"; role = "assassin-medium";
extra = 2; extra = 1;
ws = 2.5; ws = 2.5;
if (Math.random() > g / 5) if (Math.random() > g / 5)
{ {
role = "assassin-heavy"; role = "assassin-heavy";
ws = 2.8; ws = 2.8;
extra = 4;
} }
} }
var main = this._addShips(role,1,pos,0)[0]; var main = this._addShips(role,1,pos,0)[0];
@ -1865,8 +1866,15 @@ this._addAssassin = function(pos)
{ {
var g = new ShipGroup("assassin group",main); var g = new ShipGroup("assassin group",main);
main.group = g; main.group = g;
var extras = this._addShips("assassin-light",extra,pos,3E3); if (role == "assassin-heavy")
for (var i=0;i<extra;i++) {
var extras = this._addShips("assassin-medium",2,pos,3E3);
}
else
{
var extras = this._addShips("assassin-light",2,pos,3E3);
}
for (var i=0;i<2;i++)
{ {
extras[i].group = g; extras[i].group = g;
g.addShip(extras[i]); g.addShip(extras[i]);

View File

@ -544,8 +544,13 @@ PriorityAIController.prototype.checkScannerWithPredicate = function(predicate)
var io = (i+offset)%sl; var io = (i+offset)%sl;
if (predicate.call(this,scan[io])) if (predicate.call(this,scan[io]))
{ {
this.setParameter("oolite_scanResultSpecific",scan[io]); // stops ships near the witchpoint beginning an attack on the player
return true; // before they've even got ship control back
if (scan[io].status != "STATUS_EXITING_WITCHSPACE")
{
this.setParameter("oolite_scanResultSpecific",scan[io]);
return true;
}
} }
} }
return false; return false;
@ -1178,7 +1183,14 @@ PriorityAIController.prototype.threatAssessment = function(ship,full)
{ {
return 1; // mostly ignore stations in assessment return 1; // mostly ignore stations in assessment
} }
return worldScripts["oolite-libPriorityAI"]._threatAssessment(ship,full); var ta = worldScripts["oolite-libPriorityAI"]._threatAssessment(ship,full);
if (!full && ship.isPlayer && ship.alertCondition < 3 && this.playerRole != "player-unknown")
{
// we haven't already added on the player's skill bonus, but
// the player is somewhat known
ta += Math.pow(player.score,0.33)/10;
}
return ta;
} }
/* ****************** Condition functions ************** */ /* ****************** Condition functions ************** */
@ -2656,6 +2668,7 @@ PriorityAIController.prototype.behaviourDestroyCurrentTarget = function()
{ {
// entering attack mode // entering attack mode
this.communicate("oolite_beginningAttack",this.ship.target,3); this.communicate("oolite_beginningAttack",this.ship.target,3);
this.ship.requestHelpFromGroup();
} }
else else
{ {
@ -2996,9 +3009,10 @@ PriorityAIController.prototype.behaviourFollowGroupLeader = function()
} }
else else
{ {
this.ship.destination = this.ship.group.leader.position; var gl = this.ship.group.leader;
this.ship.destination = gl.position.add(gl.vectorForward.multiply(gl.speed*10));
this.ship.desiredRange = 500+Math.random()*1000; this.ship.desiredRange = 500+Math.random()*1000;
this.ship.desiredSpeed = this.ship.maxSpeed; this.ship.desiredSpeed = Math.min(this.ship.maxSpeed,gl.speed*1.5);
this.behaviourApproachDestination(); this.behaviourApproachDestination();
} }
} }
@ -3181,6 +3195,7 @@ PriorityAIController.prototype.behaviourRepelCurrentTarget = function()
{ {
// entering attack mode // entering attack mode
this.communicate("oolite_beginningAttack",target,3); this.communicate("oolite_beginningAttack",target,3);
this.ship.requestHelpFromGroup();
} }
else if (this.ship.target) else if (this.ship.target)
{ {

View File

@ -1146,23 +1146,22 @@ static GLfloat sBaseMass = 0.0;
// role weights // role weights
[roleWeights release]; [roleWeights release];
roleWeights = [[dict oo_arrayForKey:@"role_weights"] mutableCopy]; roleWeights = [[dict oo_arrayForKey:@"role_weights"] mutableCopy];
NSUInteger rc = [self maxPlayerRoles];
if (roleWeights == nil) if (roleWeights == nil)
{ {
NSUInteger rc = 16;
if (ship_kills > 6400)
{
rc = 64;
}
else if (ship_kills > 128)
{
rc = 32;
}
roleWeights = [[NSMutableArray alloc] initWithCapacity:rc]; roleWeights = [[NSMutableArray alloc] initWithCapacity:rc];
while (rc-- > 0) while (rc-- > 0)
{ {
[roleWeights addObject:@"player-unknown"]; [roleWeights addObject:@"player-unknown"];
} }
} }
else
{
if ([roleWeights count] > rc)
{
[roleWeights removeObjectsInRange:(NSRange) {rc,[roleWeights count]-rc}];
}
}
roleWeightFlags = [[dict oo_dictionaryForKey:@"role_weight_Flags"] mutableCopy]; roleWeightFlags = [[dict oo_dictionaryForKey:@"role_weight_Flags"] mutableCopy];
if (roleWeightFlags == nil) if (roleWeightFlags == nil)
@ -1500,8 +1499,8 @@ static GLfloat sBaseMass = 0.0;
[reputation oo_setInteger:0 forKey:PARCEL_BAD_KEY]; [reputation oo_setInteger:0 forKey:PARCEL_BAD_KEY];
[reputation oo_setInteger:MAX_CONTRACT_REP forKey:PARCEL_UNKNOWN_KEY]; [reputation oo_setInteger:MAX_CONTRACT_REP forKey:PARCEL_UNKNOWN_KEY];
roleWeights = [[NSMutableArray alloc] initWithCapacity:16]; roleWeights = [[NSMutableArray alloc] initWithCapacity:8];
for (i = 0 ; i < 16 ; i++) for (i = 0 ; i < 8 ; i++)
{ {
[roleWeights addObject:@"player-unknown"]; [roleWeights addObject:@"player-unknown"];
} }
@ -3749,7 +3748,7 @@ static GLfloat sBaseMass = 0.0;
{ {
role = @"pirate"; role = @"pirate";
} }
else if ([[victim primaryRole] hasPrefix:@"hunter"] || [victim scanClass] == CLASS_POLICE) else if ([UNIVERSE role:[self primaryRole] isInCategory:@"oolite-hunter"] || [victim scanClass] == CLASS_POLICE)
{ {
role = @"pirate-interceptor"; role = @"pirate-interceptor";
} }
@ -3810,7 +3809,8 @@ static GLfloat sBaseMass = 0.0;
if (!includingLongRange) if (!includingLongRange)
{ {
NSString *role = [roleWeights objectAtIndex:slot]; NSString *role = [roleWeights objectAtIndex:slot];
if ([role hasSuffix:@"+"]) // long range roles cleared at 1/2 normal rate
if ([role hasSuffix:@"+"] && randf() > 0.5)
{ {
return; return;
} }
@ -3836,15 +3836,15 @@ static GLfloat sBaseMass = 0.0;
{ {
if (ship_kills >= 6400) if (ship_kills >= 6400)
{ {
return 64; return 32;
} }
else if (ship_kills >= 128) else if (ship_kills >= 128)
{ {
return 32; return 16;
} }
else else
{ {
return 16; return 8;
} }
} }