- added two AI commands: setTargetToRandomStation and setTargetToLastStation.
- setTargetToRandomStation will select a random station from all stations within 'desiredRange'. Carriers and stations without npc_traffic are excluded. It returns "NO_STATION_IN_RANGE" or "STATION_FOUND" - setTargetToLastStation sets the primary target to the last selected station. It returns "NO_STATION_FOUND" when the last station lo longer exists. - Updated the route1traderAI.plist so that ships with bounty no longer go to the main station as default but start looking for a random station. - Bugfix: Activating the fuel injector while deceleration from torus speed, no longer drops the speed immediately to max-injector speed. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4770 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
403e02fe94
commit
6fd5701273
@ -44,7 +44,7 @@
|
|||||||
};
|
};
|
||||||
"DOCK_WITH_STATION" =
|
"DOCK_WITH_STATION" =
|
||||||
{
|
{
|
||||||
ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", performIntercept);
|
ENTER = (setTargetToNearestStation, "setDesiredRangeTo: 5000.0", performIntercept);
|
||||||
"DESIRED_RANGE_ACHIEVED" = ("setAITo: dockingAI.plist");
|
"DESIRED_RANGE_ACHIEVED" = ("setAITo: dockingAI.plist");
|
||||||
ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget, broadcastDistressMessage, "setStateTo: FLEE");
|
ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget, broadcastDistressMessage, "setStateTo: FLEE");
|
||||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
ENTER =
|
ENTER =
|
||||||
(
|
(
|
||||||
switchLightsOff,
|
switchLightsOff,
|
||||||
setTargetToStation,
|
setTargetToNearestStation,
|
||||||
"setDesiredRangeTo: 5000.0",
|
"setDesiredRangeTo: 5000.0",
|
||||||
setDestinationToTarget,
|
setDestinationToTarget,
|
||||||
checkCourseToDestination
|
checkCourseToDestination
|
||||||
@ -46,7 +46,7 @@
|
|||||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||||
UPDATE =
|
UPDATE =
|
||||||
(
|
(
|
||||||
setTargetToStation,
|
setTargetToNearestStation,
|
||||||
"setDesiredRangeTo: 5000.0",
|
"setDesiredRangeTo: 5000.0",
|
||||||
setDestinationToTarget,
|
setDestinationToTarget,
|
||||||
checkCourseToDestination,
|
checkCourseToDestination,
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
};
|
};
|
||||||
"GO_TO_STATION" =
|
"GO_TO_STATION" =
|
||||||
{
|
{
|
||||||
ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
|
ENTER = (setTargetToNearestStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
|
||||||
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
|
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
|
||||||
"COURSE_OK" = ("setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
|
"COURSE_OK" = ("setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
|
||||||
"DESIRED_RANGE_ACHIEVED" = (setTargetToStation, "setAITo: dockingAI.plist");
|
"DESIRED_RANGE_ACHIEVED" = (setTargetToNearestStation, "setAITo: dockingAI.plist");
|
||||||
ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE");
|
ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE");
|
||||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||||
UPDATE = (setTargetToStation, "setDesiredRangeTo: 5000.0",
|
UPDATE = (setTargetToNearestStation, "setDesiredRangeTo: 5000.0",
|
||||||
setDestinationToTarget, checkCourseToDestination, "pauseAI: 5.0");
|
setDestinationToTarget, checkCourseToDestination, "pauseAI: 5.0");
|
||||||
};
|
};
|
||||||
"LIFT_OFF_FROM_MAIN_PLANET" =
|
"LIFT_OFF_FROM_MAIN_PLANET" =
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
{
|
{
|
||||||
GLOBAL =
|
GLOBAL =
|
||||||
{
|
{
|
||||||
ENTER = ("setStateTo: HEAD_FOR_PLANET");
|
ENTER = ("setStateTo: CHECK_STATUS");
|
||||||
};
|
};
|
||||||
|
"CHECK_STATUS" = {
|
||||||
|
ENTER = (checkOwnLegalStatus, "setDesiredRangeTo: 500000.0");
|
||||||
|
"SELF_CLEAN" = ("setStateTo: HEAD_FOR_PLANET");
|
||||||
|
"SELF_MINOR_OFFENDER" = (setTargetToRandomStation);
|
||||||
|
"SELF_OFFENDER" = (setTargetToRandomStation);
|
||||||
|
"SELF_FUGITIVE" = (setTargetToRandomStation);
|
||||||
|
"SELF_THARGOID" = ("switchAITo: thargoidAI.plist");
|
||||||
|
"NO_STATION_IN_RANGE" = ("setStateTo: HEAD_FOR_PLANET");
|
||||||
|
"STATION_FOUND" = ("setStateTo: GO_TO_RANDOM_STATION");
|
||||||
|
};
|
||||||
"HEAD_FOR_PLANET" =
|
"HEAD_FOR_PLANET" =
|
||||||
{
|
{
|
||||||
ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
|
ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
|
||||||
@ -49,10 +59,10 @@
|
|||||||
};
|
};
|
||||||
"GO_TO_SUB_STATION" =
|
"GO_TO_SUB_STATION" =
|
||||||
{
|
{
|
||||||
ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
|
ENTER = (setTargetToNearestFriendlyStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
|
||||||
"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
|
"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
|
||||||
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
|
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
|
||||||
"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToStation, "setAITo: dockingAI.plist");
|
"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToNearestFriendlyStation, "setAITo: dockingAI.plist");
|
||||||
"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
|
"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
|
||||||
"DOCKING_REFUSED" = ("switchAITo: route2sunskimAI.plist");
|
"DOCKING_REFUSED" = ("switchAITo: route2sunskimAI.plist");
|
||||||
"NO_STATION_FOUND" = ("switchAITo: exitingTraderAI.plist");
|
"NO_STATION_FOUND" = ("switchAITo: exitingTraderAI.plist");
|
||||||
@ -61,7 +71,7 @@
|
|||||||
ATTACKED = ("setAITo: traderInterceptAI.plist", fightOrFleeHostiles);
|
ATTACKED = ("setAITo: traderInterceptAI.plist", fightOrFleeHostiles);
|
||||||
UPDATE =
|
UPDATE =
|
||||||
(
|
(
|
||||||
setTargetToStation,
|
setTargetToNearestFriendlyStation,
|
||||||
"setDesiredRangeTo: 5000.0",
|
"setDesiredRangeTo: 5000.0",
|
||||||
setDestinationToTarget,
|
setDestinationToTarget,
|
||||||
checkCourseToDestination,
|
checkCourseToDestination,
|
||||||
@ -69,4 +79,25 @@
|
|||||||
"pauseAI: 10.0"
|
"pauseAI: 10.0"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
"GO_TO_RANDOM_STATION" =
|
||||||
|
{
|
||||||
|
ENTER = ("setDesiredRangeTo: 15000.0", setDestinationToTarget, checkCourseToDestination);
|
||||||
|
"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
|
||||||
|
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
|
||||||
|
"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToNearestStation, "setAITo: dockingAI.plist");
|
||||||
|
"DOCKING_REFUSED" = ("switchAITo: route2sunskimAI.plist");
|
||||||
|
"NO_STATION_FOUND" = ("switchAITo: exitingTraderAI.plist");
|
||||||
|
"TARGET_FOUND" = (setTargetToFoundTarget, "setAITo: traderInterceptAI.plist", fightOrFleeHostiles);
|
||||||
|
"INCOMING_MISSILE" = ("setAITo: traderInterceptAI.plist", "setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 1.5");
|
||||||
|
ATTACKED = ("setAITo: traderInterceptAI.plist", fightOrFleeHostiles);
|
||||||
|
UPDATE =
|
||||||
|
(
|
||||||
|
setTargetToLastStation,
|
||||||
|
"setDesiredRangeTo: 15000.0",
|
||||||
|
setDestinationToTarget,
|
||||||
|
checkCourseToDestination,
|
||||||
|
scanForHostiles,
|
||||||
|
"pauseAI: 10.0"
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
@ -177,6 +177,8 @@
|
|||||||
"scanForNearestShipMatchingPredicate:",
|
"scanForNearestShipMatchingPredicate:",
|
||||||
"setCoordinates:",
|
"setCoordinates:",
|
||||||
"checkForNormalSpace",
|
"checkForNormalSpace",
|
||||||
|
"setTargetToRandomStation",
|
||||||
|
"setTargetToLastStation",
|
||||||
"requestDockingCoordinates",
|
"requestDockingCoordinates",
|
||||||
"recallDockingInstructions",
|
"recallDockingInstructions",
|
||||||
"enterPlayerWormhole",
|
"enterPlayerWormhole",
|
||||||
|
@ -1996,10 +1996,19 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
UPDATE_STAGE(@"updating afterburner");
|
UPDATE_STAGE(@"updating afterburner");
|
||||||
|
|
||||||
float abFactor = [self afterburnerFactor];
|
float abFactor = [self afterburnerFactor];
|
||||||
if (flightSpeed < maxFlightSpeed * abFactor)
|
float maxInjectionSpeed = maxFlightSpeed * abFactor;
|
||||||
flightSpeed += (float)(speed_delta * delta_t * abFactor);
|
if (flightSpeed > maxInjectionSpeed)
|
||||||
if (flightSpeed > maxFlightSpeed * abFactor)
|
{
|
||||||
flightSpeed = maxFlightSpeed * abFactor;
|
// decellerate to maxInjectionSpeed but slower than without afterburner.
|
||||||
|
flightSpeed -= (float)(speed_delta * delta_t * abFactor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flightSpeed < maxInjectionSpeed)
|
||||||
|
flightSpeed += (float)(speed_delta * delta_t * abFactor);
|
||||||
|
if (flightSpeed > maxInjectionSpeed)
|
||||||
|
flightSpeed = maxInjectionSpeed;
|
||||||
|
}
|
||||||
fuel_accumulator -= (float)(delta_t * AFTERBURNER_BURNRATE);
|
fuel_accumulator -= (float)(delta_t * AFTERBURNER_BURNRATE);
|
||||||
while ((fuel_accumulator < 0)&&(fuel > 0))
|
while ((fuel_accumulator < 0)&&(fuel > 0))
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,6 @@ MA 02110-1301, USA.
|
|||||||
- (NSArray *) contractList;
|
- (NSArray *) contractList;
|
||||||
- (void) setGuiToManifestScreen;
|
- (void) setGuiToManifestScreen;
|
||||||
|
|
||||||
//- (void) setGuiToDeliveryReportScreenWithText:(NSString*) report;
|
|
||||||
- (void) setGuiToDockingReportScreen;
|
- (void) setGuiToDockingReportScreen;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------- //
|
// ---------------------------------------------------------------------- //
|
||||||
|
@ -1166,69 +1166,6 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Eric 2012-01-02: As far as I see, is the next code unused since at least 1.65 and can be deleted.
|
|
||||||
// Presenting any arrival messages is integrated in the general 'setGuiToDockingReportScreen'
|
|
||||||
// and in not likely to be used in future.
|
|
||||||
/*
|
|
||||||
- (void) setGuiToDeliveryReportScreenWithText:(NSString*) report
|
|
||||||
{
|
|
||||||
OOGUIScreenID oldScreen = gui_screen;
|
|
||||||
|
|
||||||
GuiDisplayGen *gui = [UNIVERSE gui];
|
|
||||||
gui_screen = GUI_SCREEN_REPORT;
|
|
||||||
BOOL guiChanged = (oldScreen != gui_screen);
|
|
||||||
|
|
||||||
// GUI stuff
|
|
||||||
{
|
|
||||||
[gui clearAndKeepBackground:!guiChanged];
|
|
||||||
[gui setTitle:ExpandDescriptionForCurrentSystem(@"[arrival-report-title]")];
|
|
||||||
|
|
||||||
// report might be a multi-line message
|
|
||||||
|
|
||||||
if ([report rangeOfString:@"\n"].location != NSNotFound)
|
|
||||||
{
|
|
||||||
int text_row = 1;
|
|
||||||
NSArray *sections = [report componentsSeparatedByString:@"\n"];
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < [sections count]; i++)
|
|
||||||
text_row = [gui addLongText:(NSString *)[sections objectAtIndex:i] startingAtRow:text_row align:GUI_ALIGN_LEFT];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void)[gui addLongText:report startingAtRow:1 align:GUI_ALIGN_LEFT];
|
|
||||||
}
|
|
||||||
|
|
||||||
[gui setText:[NSString stringWithFormat:DESC_PLURAL(@"contracts-cash-@-load-d-of-d-passengers-d-of-d-berths", max_passengers), OOCredits(credits), current_cargo, max_cargo, [passengers count], max_passengers] forRow: GUI_ROW_MARKET_CASH];
|
|
||||||
|
|
||||||
[gui setText:@"press-space-commander" forRow:21 align:GUI_ALIGN_CENTER];
|
|
||||||
[gui setColor:[OOColor yellowColor] forRow:21];
|
|
||||||
[gui setShowTextCursor:NO];
|
|
||||||
}
|
|
||||||
// ends
|
|
||||||
|
|
||||||
if (lastTextKey)
|
|
||||||
{
|
|
||||||
[lastTextKey release];
|
|
||||||
lastTextKey = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setShowDemoShips: NO];
|
|
||||||
[UNIVERSE setDisplayCursor: NO];
|
|
||||||
[UNIVERSE setViewDirection: VIEW_GUI_DISPLAY];
|
|
||||||
|
|
||||||
if (guiChanged)
|
|
||||||
{
|
|
||||||
[gui setForegroundTextureKey:@"docked_overlay"]; // has to be docked!
|
|
||||||
|
|
||||||
NSDictionary *bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"report"];
|
|
||||||
if (bgDescriptor == nil) bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status_docked"];
|
|
||||||
if (bgDescriptor == nil) bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status"];
|
|
||||||
[gui setBackgroundTextureDescriptor:bgDescriptor];
|
|
||||||
[self noteGUIDidChangeFrom:oldScreen to:gui_screen];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
- (void) setGuiToDockingReportScreen
|
- (void) setGuiToDockingReportScreen
|
||||||
{
|
{
|
||||||
OOGUIScreenID oldScreen = gui_screen;
|
OOGUIScreenID oldScreen = gui_screen;
|
||||||
|
@ -237,6 +237,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) checkForNormalSpace;
|
- (void) checkForNormalSpace;
|
||||||
|
|
||||||
|
- (void) setTargetToRandomStation;
|
||||||
|
- (void) setTargetToLastStation;
|
||||||
- (void) recallDockingInstructions;
|
- (void) recallDockingInstructions;
|
||||||
|
|
||||||
- (void) addFuel:(NSString *) fuel_number;
|
- (void) addFuel:(NSString *) fuel_number;
|
||||||
@ -2137,6 +2139,66 @@ MA 02110-1301, USA.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) setTargetToRandomStation
|
||||||
|
{
|
||||||
|
/*- selects the nearest station it can find -*/
|
||||||
|
int ent_count = UNIVERSE->n_entities;
|
||||||
|
Entity **uni_entities = UNIVERSE->sortedEntities; // grab the public sorted list
|
||||||
|
Entity *my_entities[ent_count];
|
||||||
|
StationEntity *station, *my_station = nil;
|
||||||
|
double maxRange2 = desired_range * desired_range;
|
||||||
|
int i;
|
||||||
|
int station_count = 0;
|
||||||
|
for (i = 0; i < ent_count; i++)
|
||||||
|
{
|
||||||
|
// find stations within range but exclude carriers.
|
||||||
|
if (uni_entities[i]->isStation)
|
||||||
|
{
|
||||||
|
my_station = (StationEntity*)uni_entities[i];
|
||||||
|
if ([my_station maxFlightSpeed] == 0 && [my_station hasNPCTraffic] && distance2(position, [my_station position]) < maxRange2)
|
||||||
|
{
|
||||||
|
my_entities[station_count++] = [uni_entities[i] retain]; // retained
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (station_count != 0)
|
||||||
|
{
|
||||||
|
// select a random station
|
||||||
|
station = (StationEntity *)my_entities[ranrot_rand() % station_count];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < station_count; i++)
|
||||||
|
[my_entities[i] release]; // released
|
||||||
|
//
|
||||||
|
if (station)
|
||||||
|
{
|
||||||
|
primaryTarget = [station universalID];
|
||||||
|
targetStation = primaryTarget;
|
||||||
|
[shipAI message:@"STATION_FOUND"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[shipAI message:@"NO_STATION_IN_RANGE"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setTargetToLastStation
|
||||||
|
{
|
||||||
|
Entity *station = [UNIVERSE entityForUniversalID:targetStation];
|
||||||
|
|
||||||
|
if ([station isStation])
|
||||||
|
{
|
||||||
|
primaryTarget = targetStation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[shipAI message:@"NO_STATION_FOUND"];
|
||||||
|
targetStation = NO_TARGET;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void) requestDockingCoordinates
|
- (void) requestDockingCoordinates
|
||||||
{
|
{
|
||||||
/*- requests coordinates from the target station
|
/*- requests coordinates from the target station
|
||||||
|
Loading…
x
Reference in New Issue
Block a user