- Ships in behaviour "behaviour_attack_fly_from_target" should no longer fly out of scanner range here. (Better solution than one of my previous commits)
- Scripted cargopods released during "becomeExplosion" are working correct again. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3170 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
e07cf99430
commit
22387e560c
@ -2885,10 +2885,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
[self activateCloakingDevice];
|
||||
|
||||
desired_speed = max_available_speed;
|
||||
if (range < 0.035 * weaponRange)
|
||||
if (range < COMBAT_IN_RANGE_FACTOR * weaponRange)
|
||||
{
|
||||
double max_depart_speed = sqrt ((scannerRange - COMBAT_OUT_RANGE_FACTOR * weaponRange) * thrust) * max_flight_pitch * 1.5;
|
||||
if (max_depart_speed < max_available_speed) desired_speed = max_depart_speed;
|
||||
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||
}
|
||||
else
|
||||
@ -3071,13 +3069,6 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
jink.z = 1000.0;
|
||||
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||
frustration = 0.0;
|
||||
double max_depart_speed = sqrt ((scannerRange - COMBAT_OUT_RANGE_FACTOR * weaponRange) * thrust) * max_flight_pitch * 1.5;
|
||||
if (max_depart_speed < max_available_speed) max_available_speed = max_depart_speed;
|
||||
// desired_speed = max_available_speed;
|
||||
|
||||
// 2010-04-06 Eric: setting desired_speed here is useless, it is always overwritten a bit lower in control speed.
|
||||
// Putting a return here would keep the setting but also removes some randomness in reaction out of fights, so leave it for now.
|
||||
// maybe returning here with a randomised desired_speed in future?
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3085,7 +3076,6 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
jink = kZeroVector;
|
||||
behaviour = BEHAVIOUR_RUNNING_DEFENSE;
|
||||
frustration = 0.0;
|
||||
// desired_speed = maxFlightSpeed; // Setting desired_speed here is useless.
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3159,6 +3149,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
- (void) behaviour_attack_fly_from_target:(double) delta_t
|
||||
{
|
||||
double range = [self rangeToPrimaryTarget];
|
||||
double last_success_factor = success_factor;
|
||||
success_factor = range;
|
||||
|
||||
if (primaryTarget == NO_TARGET)
|
||||
{
|
||||
@ -3167,7 +3159,17 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
[self noteLostTarget];
|
||||
return;
|
||||
}
|
||||
if (range > COMBAT_OUT_RANGE_FACTOR * weaponRange + 15.0 * jink.x)
|
||||
if (last_success_factor > success_factor) // our target is closing in.
|
||||
{
|
||||
frustration += delta_t;
|
||||
if (frustration > 10.0)
|
||||
{
|
||||
if (randf() < 0.3) desired_speed = maxFlightSpeed * (([self hasFuelInjection] && (fuel > MIN_FUEL)) ? [self afterburnerFactor] : 1);
|
||||
else if (range > COMBAT_IN_RANGE_FACTOR * weaponRange && randf() < 0.3) behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
}
|
||||
if (range > COMBAT_OUT_RANGE_FACTOR * weaponRange + 15.0 * jink.x || flightSpeed > (scannerRange - range) * max_flight_pitch / 6.28)
|
||||
{
|
||||
jink.x = 0.0;
|
||||
jink.y = 0.0;
|
||||
|
@ -3184,7 +3184,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
OOCargoType co_type = [container commodityType];
|
||||
OOCargoQuantity co_amount = [container commodityAmount];
|
||||
|
||||
if ((co_type == CARGO_UNDEFINED)||(co_amount == 0))
|
||||
if (((co_type == CARGO_UNDEFINED)||(co_amount == 0)) && [container cargoType] != CARGO_SCRIPTED_ITEM)
|
||||
{
|
||||
// choose a random filling
|
||||
// select a random point in the histogram
|
||||
@ -3213,7 +3213,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
if (container != nil)
|
||||
{
|
||||
[container setScanClass: CLASS_CARGO];
|
||||
[container setCommodity:co_type andAmount:co_amount];
|
||||
if ([container cargoType] != CARGO_SCRIPTED_ITEM) [container setCommodity:co_type andAmount:co_amount];
|
||||
[accumulator addObject:container];
|
||||
[container release]; // released
|
||||
}
|
||||
@ -3249,7 +3249,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
if (container)
|
||||
{
|
||||
[container setScanClass: CLASS_CARGO];
|
||||
[container setCommodity:commodity_type andAmount:amount];
|
||||
if ([container cargoType] != CARGO_SCRIPTED_ITEM) [container setCommodity:commodity_type andAmount:amount];
|
||||
[accumulator addObject:container];
|
||||
[container release];
|
||||
}
|
||||
@ -3325,7 +3325,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
/* Bug: NSNotFound being returned for valid names.
|
||||
Analysis: Looking for name in commodityData rather than ith element.
|
||||
Analysis: Looking for name in commodityData rather than its element.
|
||||
Fix: look in [commodityData objectAtIndex:i].
|
||||
-- Ahruman 20070714
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user