Bugfix: Bug #13712 - Hyper speed approach to a moon crashes ship. If the player gets closer than 25km from a moon the ship is mass locked, no matter how small the moon itself is.

1.72: events cleanup: now player receives shipBeingAttacked, reworked shipExitedPlanetaryVicinity (now with planet parameter in most cases) & shipEnteredPlanetaryVicinity and re-added "AEGIS_CLOSE_TO_PLANET" AI message for compatibility with earlier oolite. Corrected the name of a jumpCountDown event.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1644 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2008-05-20 04:01:45 +00:00
parent 3ac2fa38bb
commit 6f80e3bb37
4 changed files with 42 additions and 12 deletions

View File

@ -2924,6 +2924,8 @@ double scoopSoundPlayTime = 0.0;
rel_pos = (ent != nil) ? [ent position] : kZeroVector;
rel_pos = vector_subtract(rel_pos, position);
[self doScriptEvent:@"shipBeingAttacked" withArgument:ent];
d_forward = dot_product(rel_pos, v_forward);
[self playShieldHit];

View File

@ -968,7 +968,7 @@ static NSTimeInterval time_last_frame;
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-to-@-in-f-seconds]"), [UNIVERSE getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
[self doScriptEvent:@"didBeginJumpCountDown" withArgument:@"standard"];
[self doScriptEvent:@"playerStartedJumpCountDown" withArgument:@"standard"];
}
}
hyperspace_pressed = YES;

View File

@ -3407,7 +3407,18 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
[self doScriptEvent:@"shipExitedStationAegis"];
[shipAI message:@"AEGIS_LEAVING_DOCKING_RANGE"];
}
[self doScriptEvent:@"shipExitedPlanetaryVicinity"];
PlanetEntity* the_planet;
if (aegis_status == AEGIS_CLOSE_TO_ANY_PLANET)
{
the_planet = [self findPlanetNearestSurface];
}
else //must be the main planet!
{
the_planet = [UNIVERSE planet];
}
[self doScriptEvent:@"shipExitedPlanetaryVicinity" withArgument:the_planet];
[shipAI message:@"AWAY_FROM_PLANET"];
if (aegis_status != AEGIS_CLOSE_TO_ANY_PLANET)
{
@ -3500,8 +3511,6 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
if (d2 < cr2 * 9.0f && [UNIVERSE sun] != the_planet) //to 3x radius of any planet/moon
{
[self doScriptEvent:@"shipEnteredPlanetaryVicinity" withArgument:the_planet];
[shipAI message:@"CLOSE_TO_PLANET"];
result = AEGIS_CLOSE_TO_ANY_PLANET;
}
@ -3538,8 +3547,31 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
if ((aegis_status == AEGIS_NONE)&&(result == AEGIS_CLOSE_TO_MAIN_PLANET))
{
[self doScriptEvent:@"shipEnteredPlanetaryVicinity" withArgument:[UNIVERSE planet]];
[shipAI message:@"CLOSE_TO_PLANET"];
[shipAI message:@"AEGIS_CLOSE_TO_PLANET"]; //keep for compatibility with pre-1.72 AI plists
[shipAI message:@"AEGIS_CLOSE_TO_MAIN_PLANET"];
}
if ((aegis_status == AEGIS_NONE)&&(result == AEGIS_CLOSE_TO_ANY_PLANET))
{
[self doScriptEvent:@"shipEnteredPlanetaryVicinity" withArgument:the_planet];
[shipAI message:@"CLOSE_TO_PLANET"];
}
if ((aegis_status == AEGIS_CLOSE_TO_ANY_PLANET || result == AEGIS_IN_DOCKING_RANGE)&&(result == AEGIS_CLOSE_TO_MAIN_PLANET))
{
[self doScriptEvent:@"shipExitedPlanetaryVicinity"]; //needs work!
[self doScriptEvent:@"shipEnteredPlanetaryVicinity" withArgument:[UNIVERSE planet]];
[shipAI message:@"AWAY_FROM_PLANET"];
[shipAI message:@"CLOSE_TO_PLANET"];
[shipAI message:@"AEGIS_CLOSE_TO_PLANET"];
[shipAI message:@"AEGIS_CLOSE_TO_MAIN_PLANET"];
}
if ((aegis_status == AEGIS_CLOSE_TO_MAIN_PLANET || result == AEGIS_IN_DOCKING_RANGE)&&(result == AEGIS_CLOSE_TO_ANY_PLANET))
{
[self doScriptEvent:@"shipExitedPlanetaryVicinity" withArgument:[UNIVERSE planet]];
[self doScriptEvent:@"shipEnteredPlanetaryVicinity" withArgument:the_planet];
[shipAI message:@"AWAY_FROM_PLANET"];
[shipAI message:@"CLOSE_TO_PLANET"];
}
if (((aegis_status == AEGIS_CLOSE_TO_MAIN_PLANET)||(aegis_status == AEGIS_NONE))&&(result == AEGIS_IN_DOCKING_RANGE))
{
[self doScriptEvent:@"shipEnteredStationAegis" withArgument:the_station];
@ -3762,12 +3794,6 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
}
- (double) desiredSpeed
{
return desired_speed;
}
- (void) setDesiredSpeed:(double) amount
{
desired_speed = amount;
@ -4828,8 +4854,9 @@ BOOL class_masslocks(int some_class)
{
if (primaryTarget != NO_TARGET)
{
ShipEntity* target = [UNIVERSE entityForUniversalID:primaryTarget];
primaryTarget = NO_TARGET;
[self doScriptEvent:@"shipLostTarget"];
[self doScriptEvent:@"shipLostTarget" withArgument: (target && target->isShip) ? target : nil];
[shipAI reactToMessage:@"TARGET_LOST"];
}
}

View File

@ -455,7 +455,8 @@ static BOOL hostiles;
double dist = planet->zero_distance;
double rad = planet->collision_radius;
double factor = ([planet planetType] == PLANET_TYPE_SUN) ? 2.0 : 4.0;
if (dist < rad*rad*factor)
//mass lock no closer than 25 km from the surface
if (dist< rad*rad +50000*rad+625000000 || dist < rad*rad*factor)
{
mass_locked = YES;
}