Page 1 of 1
Autopilot AI
Posted: Thu Dec 09, 2010 1:08 pm
by Killer Wolf
Would it be possible to have an AI for NPCs that would follow a patrol route? what i'm thinking of is a list of waypoints in an array, simply a position using whatever Oolite format (WSP etc) and a speed as a % of the ship's top speed, and a variable to loop or not, so the ship would stop at the end of the list, or be able to fly circuits etc. (Viper patrol around a planet, say).
. this could open stuff up for eye candy ship/mission OXPs ~ you could have ships heading out to a station etc on a path none of the existing AIs incorporate.
Posted: Thu Dec 09, 2010 9:31 pm
by Switeck
Total Patrol OXP sort-of does that for police Vipers:
http://wiki.alioth.net/index.php/Total_patrol_OXP
Posted: Thu Dec 09, 2010 10:35 pm
by Commander McLane
Total patrol is only an extension of the usual police AI, so don't bother with it.
Instead have a look at cataclysm_militaryAI.plist from (you guessed it) Cataclysm.oxp. It is a patrol AI with 12 pre-defined waypoints, which sends ships along the lines between these waypoints, and randomly choose another waypoint to go to whenever they reached their destination. It also allows for them to break up course and attack, if necessary. It's basically exactly what you want. You only have to replace the waypoint co-ordinates with whatever suits you (SHIFT-F in game is your friend here; that's how I determined the co-ordinates in the AI).
Or you could have a look at the AI of the Tionisla Orbital Graveyard patrol ships. I guess it will be similar.
Posted: Fri Dec 10, 2010 7:17 am
by Killer Wolf
cheers Cmdr McLane, i'll have a look into that. it's not an immediate priority for me, but i thought it might be a useful thing for people who wanted to script missions, like an "intercept a pirate fleet" or "take a photo of a new secret ship on trials" type thing.
Re: Autopilot AI
Posted: Fri Dec 10, 2010 8:58 am
by Eric Walch
Killer Wolf wrote:Would it be possible to have an AI for NPCs that would follow a patrol route? what i'm thinking of is a list of waypoints in an array,
There are plenty AI scripts out there doing such things. From the older ones: Tianve.oxp or Tionisla Graveyard.oxp. Both have patrol ships along special routes. In this old stuff the route is hardcoded in the AI. Since 1.74 a JS script can also set coordinates. With JS it becomes possible to calculate coordinates. One example is the control ship in buoy repair.oxp. Its AI starts as:
Code: Select all
GLOBAL = {
ENTER = (switchLightsOff, "setStateTo: NEXT_COORDS", "pauseAI: 5.0");
};
"NEXT_COORDS" = {
"APPROACH_COORDINATES" = (setDestinationFromCoordinates, "setStateTo: GO_TO_COORDS", switchLightsOff);
"END_CONTROL" = ("setStateTo: EXIT_SYSTEM");
UPDATE = ("sendScriptMessage: nextPosition", "setDesiredRangeTo: 10.0", "setSpeedTo: 0");
};
"GO_TO_COORDS" = {
ENTER = (performFaceDestination);
"FACING_DESTINATION" = ("setSpeedTo: 60", performFlyToRangeFromDestination);
"DESIRED_RANGE_ACHIEVED" = (performStop, switchLightsOn, "setStateTo: GET_TARGET");
"END_CONTROL" = ("setStateTo: EXIT_SYSTEM");
ATTACKED = (setTargetToPrimaryAggressor, "setAITo: interceptAI.plist");
RESTARTED = ("setStateTo: EXIT_SYSTEM");
STOP = (performStop);
"ENERGY_FULL" = (performFaceDestination);
};
Its a bit of a copy of Oolites own planetPatrolAI and dockingAI. In "NEXT_COORDS" is a sendScriptMessage that calls a JS function that sets a destination from an array of coordinates. Every call it returns the next position within the array. When a new coordinate is set, the JS script returns APPROACH_COORDINATES to the AI, or when the last coordinate was reached, it returns END_CONTROL.
NB the current release sets coordinates on a more complex way that worked already with 1.72, but the next release will use the easy 1.74 way to set coordinates with JS.