Svengali, today I looked more closely at your script structure and this is the most structured OXP script I have seen so far. And good nesting of conditions so unnecessary condition checking is avoided. Compliments, it shows experience.
AI scripting is however more difficult, mainly because the documentation of how commands work is still far from complete. Next thing on my todo list is to write down how the "setDesiredRangeTo" works exactly under the different circumstances. I'll work on it this weekend. In your case I see problems with the two "raid" AI's.
Code: Select all
"TRAVEL_HARKOV3" = {
ENTER = (setTargetToSystemStation, setDestinationToTarget, "setDesiredRangeTo: 12000.0", "setSpeedFactorTo: 5.0", performFlyToRangeFromDestination, checkDistanceTravelled);
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: SCAN1");
"GONE_BEYOND_RANGE" = (performIdle, "setStateTo: TRAVEL_HARKOV3");
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
UPDATE = (setTargetToSystemStation, setDestinationToTarget, "setDesiredRangeTo: 8000.0", "setSpeedFactorTo: 5.0", performFlyToRangeFromDestination, checkDistanceTravelled);
EXIT = ();
};
I think the "raid" AI's will not work as planned. In UPDATE you always are resetting the range so I think, "DESIRED_RANGE_ACHIEVED" will never be triggered. And check for "distance traveled" is needless in this situation. And be aware that speedfactors higher than 1.0 need a lot of fuel to work. So you should give your ship the maximum amount of 70 instead of 30. (70 fuel = 7 lightyears fuel)
My alternation of your state-routine would be:
Code: Select all
"TRAVEL_HARKOV3" = {
ENTER = (setTargetToSystemStation, setDestinationToTarget, "setDesiredRangeTo: 3000.0", "setSpeedFactorTo: 5.0", performFlyToRangeFromDestination);
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: SCAN1");
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
UPDATE = ();
EXIT = ();
};
But to make it complete you could also check for a free travel path with checkCourseToDestination. If "COURSE_OK" you fly ahead, if not the system generates a new waypoint ("WAYPOINT_SET") and you just follow the gotoWaypointAI.plist. This is a subroutine that makes the evasive moves and returns to the original state when it has a free flight path or when it is attacked. Normaly the UPDATE it used to reset ranges and destinations but in your case you must reset the state by "setStateTo: TRAVEL_HARKOV3" so the enterpart is used to set things.
Code: Select all
"TRAVEL_HARKOV3" = {
ENTER = (setTargetToSystemStation, setDestinationToTarget, "setDesiredRangeTo: 3000.0", checkCourseToDestination);
"COURSE_OK" = ("setSpeedFactorTo: 5.0", performFlyToRangeFromDestination);
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist", "setStateTo: TRAVEL_HARKOV3");
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: SCAN1");
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
UPDATE = ();
EXIT = ();
};
The scanning you do is very original and will work fine. In version 1.70 there will be new, improved ways to scan.