Difference between revisions of "DockingAI"

From Elite Wiki
 
(script example from Oolite -> scripting page)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
   
 
{
 
{
"AWAIT_COORDS" = {
 
  +
GLOBAL =
"APPROACH_START" = ("setStateTo: GO_TO_START");
 
  +
{
"APPROACH_COORDINATES" = ("setStateTo: GO_TO_COORDS");
 
  +
ENTER =
"HOLD_POSITION" = (performIdle, "pauseAI: 10.0", "setStateTo: GLOBAL");
 
  +
(
"DOCKING_ABORTED" = ("setStateTo: ABORT");
 
  +
"dropMessages: DOCKING_ABORTED,FACING_DESTINATION",
"TRY_AGAIN_LATER" = ("pauseAI: 30.0", "setStateTo: ABORT");
 
  +
"setSpeedTo: 0.0",
"COLLISION" = ("setStateTo: ABORT");
 
  +
requestDockingCoordinates,
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
+
"setStateTo: AWAIT_COORDS"
DOCKED = ("setStateTo: EXIT_SYSTEM");
+
);
ENTER = ();
+
};
EXIT = ();
 
UPDATE = ();};
 
 
ABORT = {
 
ENTER = (abortDocking, "setSpeedFactorTo: 0.0", setDestinationToDockingAbort, "setDesiredRangeTo: 500.0", performFaceDestination);
 
"FACING_DESTINATION" = ("setSpeedFactorTo: 1.0", "setDesiredRangeTo: 500.0", performFlyToRangeFromDestination);
 
EXIT = ();
 
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
 
"REACHED_SAFETY" = (performIdle, "setStateTo: GLOBAL");
 
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: GLOBAL");
 
UPDATE = (); };
 
   
GLOBAL = {
 
  +
"AWAIT_COORDS" =
ENTER = ("setSpeedTo: 0.0", "setDesiredRangeTo: 5.0", requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
 
  +
{
EXIT = ();
 
  +
"APPROACH" = ("setStateTo: APPROACH");
UPDATE = (); };
 
  +
"APPROACH_COORDINATES" = ("setStateTo: GO_TO_COORDS");
  +
"BACK_OFF" = ("setStateTo: RETREAT");
  +
"HOLD_POSITION" = ("setStateTo: STATIONKEEPING");
  +
"DOCKING_ABORTED" = ("setStateTo: ABORT");
  +
"TRY_AGAIN_LATER" = ("pauseAI: 30.0", "setStateTo: ABORT");
  +
"COLLISION" = ("setStateTo: ABORT");
  +
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
  +
"TOO_BIG_TO_DOCK" = ("exitAIWithMessage: DOCKING_REFUSED");
  +
DOCKED = ("setStateTo: EXIT_SYSTEM");
  +
"NO_STATION_FOUND" = ("setStateTo: EXIT_SYSTEM");
  +
UPDATE = ("pauseAI: 2");
  +
};
   
"GO_TO_WAYPOINT" = {
 
  +
STATIONKEEPING =
ENTER = ("setDesiredRangeTo: 50.0", checkCourseToDestination);
 
  +
{
"COURSE_OK" = ("setSpeedFactorTo: 0.85", performFlyToRangeFromDestination);
 
  +
ENTER = (performIdle, "setSpeedTo: 0.0", "pauseAI: 10.0");
"WAYPOINT_SET" = ("setDesiredRangeTo: 50.0", checkCourseToDestination);
 
  +
ATTACKED = ("setStateTo: ATTACK_SHIP");
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: GO_TO_STATION");
 
  +
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
EXIT = ();
 
  +
"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
UPDATE = (); };
 
  +
UPDATE = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
  +
};
   
"GO_TO_START" = {
 
  +
APPROACH =
ENTER = ("setSpeedFactorTo: 0.05", setDestinationFromCoordinates,
 
  +
{
checkCourseToDestination);
 
  +
ENTER = (recallDockingInstructions, "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
"WAYPOINT_SET" = ("setStateTo: GO_TO_WAYPOINT");
 
  +
"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
"COURSE_OK" = ("setSpeedFactorTo: 0.25", performFaceDestination);
 
  +
"DOCKING_ABORTED" = ("setStateTo: ABORT");
"FACING_DESTINATION" = ("setDesiredRangeTo: 50.0", "setSpeedFactorTo: 0.85",
 
  +
"COLLISION" = ("setStateTo: ABORT");
performFlyToRangeFromDestination);
 
  +
ATTACKED = ("setStateTo: ATTACK_SHIP");
"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
 
  +
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
"DOCKING_ABORTED" = ("setStateTo: ABORT");
+
"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
"COLLISION" = ("setStateTo: ABORT");
+
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
+
};
EXIT = ();
 
UPDATE = (); };
 
   
"GO_TO_COORDS" = {
 
  +
RETREAT =
ENTER = (performFaceDestination);
 
  +
{
FRUSTRATED = (performIdle, "pauseAI: 5.0", performFaceDestination);
+
ENTER = (recallDockingInstructions, "setSpeedTo: 0.0", setDestinationToDockingAbort, performFaceDestination);
"FACING_DESTINATION" = (recallDockingInstructions, performFlyToRangeFromDestination);
+
"FACING_DESTINATION" = ("setSpeedFactorTo: 1.0", "setDesiredRangeTo: 500.0", performFlyToRangeFromDestination);
"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
+
"DESIRED_RANGE_ACHIEVED" = ("setSpeedTo: 0.0", requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
"DOCKING_ABORTED" = ("setStateTo: ABORT");
+
ATTACKED = ("setStateTo: ATTACK_SHIP");
"COLLISION" = ("setStateTo: ABORT");
+
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
+
"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
EXIT = ();
+
"DOCKING_ABORTED" = ("setStateTo: ABORT");
UPDATE = (); }; }
+
"COLLISION" = ("setStateTo: ABORT");
  +
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
  +
};
   
"EXIT_SYSTEM" = {ENTER = (performDocking, exitAI); EXIT = (); UPDATE = (); };
 
  +
"GO_TO_COORDS" =
  +
{
  +
ENTER = (performFaceDestination, dockEscorts);
  +
"FRUSTRATED" = (performFaceDestination);
  +
"FACING_DESTINATION" = (recallDockingInstructions, performFlyToRangeFromDestination);
  +
ATTACKED = ("setStateTo: ATTACK_SHIP");
  +
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
  +
"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
  +
"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
  +
"DOCKING_ABORTED" = ("setStateTo: ABORT");
  +
"COLLISION" = ("setStateTo: ABORT");
  +
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
  +
DOCKED = ("setStateTo: EXIT_SYSTEM");
  +
};
  +
  +
ABORT =
  +
{
  +
ENTER = (abortDocking, "setSpeedTo: 0.0", setDestinationToDockingAbort, "setDesiredRangeTo: 500.0", performFaceDestination);
  +
"FACING_DESTINATION" = ("setSpeedFactorTo: 1.0", "setDesiredRangeTo: 500.0", performFlyToRangeFromDestination);
  +
"RESTART_DOCKING" = ("setStateTo: GLOBAL");
  +
"REACHED_SAFETY" = (performIdle, "setStateTo: GLOBAL");
  +
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: GLOBAL");
  +
ATTACKED = ("setStateTo: ATTACK_SHIP");
  +
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
  +
"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
  +
};
  +
  +
"ATTACK_SHIP" =
  +
{
  +
ENTER = (abortDocking, setTargetToFoundTarget, "setAITo: interceptAI.plist");
  +
RESTARTED = (performIdle, "setStateTo: GLOBAL");
  +
};
  +
  +
"EXIT_SYSTEM" =
  +
{
  +
ENTER = (exitAI);
  +
};
  +
}
  +
'''[[AI|BACK]]'''
  +
  +
  +
[[Category:Oolite scripting]]

Latest revision as of 13:04, 2 January 2011

An extremely complex JobAI.

States: ABORT, AWAIT_COORDS, EXIT_SYSTEM, GLOBAL, GO_TO_WAYPOINT, GO_TO_START, GO_TO_COORDS.

{
	GLOBAL =
	{
		ENTER =
		(
			"dropMessages: DOCKING_ABORTED,FACING_DESTINATION",
			"setSpeedTo: 0.0",
			requestDockingCoordinates,
			"setStateTo: AWAIT_COORDS"
		);
	};
	"AWAIT_COORDS" = 
	{
		"APPROACH" = ("setStateTo: APPROACH");
		"APPROACH_COORDINATES" = ("setStateTo: GO_TO_COORDS");
		"BACK_OFF" = ("setStateTo: RETREAT");
		"HOLD_POSITION" = ("setStateTo: STATIONKEEPING");
		"DOCKING_ABORTED" = ("setStateTo: ABORT");
		"TRY_AGAIN_LATER" = ("pauseAI: 30.0", "setStateTo: ABORT");
		"COLLISION" = ("setStateTo: ABORT");
		"RESTART_DOCKING" = ("setStateTo: GLOBAL");
		"TOO_BIG_TO_DOCK" = ("exitAIWithMessage: DOCKING_REFUSED");
		DOCKED = ("setStateTo: EXIT_SYSTEM");
		"NO_STATION_FOUND" = ("setStateTo: EXIT_SYSTEM");
		UPDATE = ("pauseAI: 2");
	};
	STATIONKEEPING =
	{
		ENTER = (performIdle, "setSpeedTo: 0.0", "pauseAI: 10.0");
		ATTACKED = ("setStateTo: ATTACK_SHIP");
		"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
		"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
		UPDATE = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
	};
	APPROACH =
	{
		ENTER = (recallDockingInstructions, "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
		"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
		"DOCKING_ABORTED" = ("setStateTo: ABORT");
		"COLLISION" = ("setStateTo: ABORT");
		ATTACKED = ("setStateTo: ATTACK_SHIP");
		"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
		"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
		"RESTART_DOCKING" = ("setStateTo: GLOBAL");
	};
	RETREAT =
	{
		ENTER = (recallDockingInstructions, "setSpeedTo: 0.0", setDestinationToDockingAbort, performFaceDestination);
		"FACING_DESTINATION" =  ("setSpeedFactorTo: 1.0", "setDesiredRangeTo: 500.0", performFlyToRangeFromDestination);
		"DESIRED_RANGE_ACHIEVED" = ("setSpeedTo: 0.0", requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
		ATTACKED = ("setStateTo: ATTACK_SHIP");
		"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
		"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
		"DOCKING_ABORTED" = ("setStateTo: ABORT");
		"COLLISION" = ("setStateTo: ABORT");
		"RESTART_DOCKING" = ("setStateTo: GLOBAL");
	};
	"GO_TO_COORDS" =
	{
		ENTER = (performFaceDestination, dockEscorts);
		"FRUSTRATED" = (performFaceDestination);
		"FACING_DESTINATION" = (recallDockingInstructions, performFlyToRangeFromDestination);
		ATTACKED = ("setStateTo: ATTACK_SHIP");
		"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
		"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
		"DESIRED_RANGE_ACHIEVED" = (requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
		"DOCKING_ABORTED" = ("setStateTo: ABORT");
		"COLLISION" = ("setStateTo: ABORT");
		"RESTART_DOCKING" = ("setStateTo: GLOBAL");
		DOCKED = ("setStateTo: EXIT_SYSTEM");
	};
	ABORT =
	{
		ENTER = (abortDocking, "setSpeedTo: 0.0", setDestinationToDockingAbort, "setDesiredRangeTo: 500.0", performFaceDestination);
		"FACING_DESTINATION" = ("setSpeedFactorTo: 1.0", "setDesiredRangeTo: 500.0", performFlyToRangeFromDestination);
		"RESTART_DOCKING" = ("setStateTo: GLOBAL");
		"REACHED_SAFETY" = (performIdle, "setStateTo: GLOBAL");
		"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: GLOBAL");
		ATTACKED = ("setStateTo: ATTACK_SHIP");
		"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", "setStateTo: ATTACK_SHIP");
		"GROUP_ATTACK_TARGET" = ("setStateTo: ATTACK_SHIP");
	};
	"ATTACK_SHIP" =
	{
		ENTER = (abortDocking, setTargetToFoundTarget, "setAITo: interceptAI.plist");
		RESTARTED = (performIdle, "setStateTo: GLOBAL");
	};
	"EXIT_SYSTEM" =
	{
		ENTER = (exitAI);
	};
}

BACK