Difference between revisions of "DockingAI"
From Elite Wiki
Eric Walch (talk | contribs) (script example from Oolite -> scripting page) |
|||
Line 4: | Line 4: | ||
{ | { | ||
− | + | 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); | ||
+ | }; | ||
+ | } | ||
'''[[AI|BACK]]''' | '''[[AI|BACK]]''' | ||
− | [[Category:Oolite]] | + | [[Category:Oolite scripting]] |
Revision as of 12: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); }; }