Difference between revisions of "MinerAI"

From Elite Wiki
m
(script example from Oolite -> scripting page)
 
Line 85: Line 85:
  
  
[[Category:Oolite]]
+
[[Category:Oolite scripting]]

Latest revision as of 12:13, 2 January 2011

One of the more complex state machines.

Looks for rocks, mines them, collects the ore, once hold is full it will return to dock. Miners are generally defenceless with only a mininglaser on the frontal mount, thus it runs when threatened.


Defined AIstates:

  • GLOBAL: ->LOOK_FOR_SPLINTERS
  • LOOK_FOR_SPLINTERS: ->COLLECT_STUFF, ->LOOK_FOR_ROCKS, ->DOCK_WITH_STATION, ->FLEE
  • COLLECT_STUFF: ->LOOK_FOR_SPLINTERS, ->FLEE
  • LOOK_FOR_ROCKS: ->BREAK_ROCKS, ->DOCK_WITH_STATION, ->FLEE
  • BREAK_ROCKS: ->LOOK_FOR_SPLINTERS, ->FLEE
  • DOCK_WITH_STATION: ->FLEE, ->ATTACK_SHIP
  • FLEE: ->FLEE, ->LOOK_FOR_SPLINTERS
  • ATTACK_SHIP: undefined

Referred to AI's: dockingAI.plist

{
   "LOOK_FOR_ROCKS" = {
       ENTER = (performIdle); 
       UPDATE = (scanForRocks, "pauseAI: 10.0"); 
       "TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: BREAK_ROCKS"); 
       "NOTHING_FOUND" = ("setStateTo: DOCK_WITH_STATION"); 
       EXIT = (); 
       ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE"); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");     }; 
   "BREAK_ROCKS" = {
       ENTER = (performMining); 
       UPDATE = (); 
       "TARGET_DESTROYED" = ("setStateTo: LOOK_FOR_SPLINTERS"); 
       "TARGET_LOST" = ("setStateTo: LOOK_FOR_SPLINTERS"); 
       EXIT = (); 
       ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE"); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");     }; 
   "LOOK_FOR_SPLINTERS" = {
       ENTER = (performIdle); 
       UPDATE = (scanForRandomLoot, "pauseAI: 10.0"); 
       "TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: COLLECT_STUFF"); 
       "NOTHING_FOUND" = ("setStateTo: LOOK_FOR_ROCKS"); 
       "HOLD_FULL" = ("setStateTo: DOCK_WITH_STATION"); 
       EXIT = (); 
       ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE"); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");     }; 
   "COLLECT_STUFF" = {
       ENTER = (performCollect); 
       UPDATE = (); 
       FRUSTRATED = ("setStateTo: LOOK_FOR_SPLINTERS"); 
       "CARGO_SCOOPED" = (checkForFullHold, "setStateTo: LOOK_FOR_SPLINTERS"); 
       "TARGET_LOST" = ("setStateTo: LOOK_FOR_SPLINTERS"); 
       "COLLISION" = ("setStateTo: LOOK_FOR_SPLINTERS"); 
       EXIT = (); 
       ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: FLEE"); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");     }; 
   "DOCK_WITH_STATION" = {
       ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", performIntercept);
       UPDATE = ();
       "DESIRED_RANGE_ACHIEVED" = ("setAITo: dockingAI.plist");
       EXIT = ();
       ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, "setStateTo: ATTACK_SHIP"); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE"); 	}; 
   FLEE = {
       ENTER = ("setDesiredRangeTo: 25600", performFlee); 
       EXIT = (); 
       "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE"); 
       "REACHED_SAFETY" = ("setSpeedTo: 0.0", performIdle); 
       "ENERGY_FULL" = (performIdle, "setStateTo: LOOK_FOR_SPLINTERS"); 
       "TARGET_LOST" = (performIdle, "setStateTo: LOOK_FOR_SPLINTERS"); 
       UPDATE = ();     }; 
   GLOBAL = {
       ENTER = ("setSpeedFactorTo: 0.1", "setStateTo: LOOK_FOR_SPLINTERS"); 
       EXIT = (); 
       UPDATE = (); }; 
}

BACK