Re: Scripters cove
Posted: Tue Feb 12, 2013 12:25 pm
I made this AI for my freighttrain. The idea is, that it flies to a random station and then searchs for another random station to fly to... but if I check the destination in the debug console, it's changing it constantly... so it just flies around and almost ever into empty space in something that looks like a very big circle.
Help!
Please?
Help!
Code: Select all
{
GLOBAL = {
ENTER = ("randomPauseAI: 1.0 2.0");
UPDATE = ("setStateTo: SETUP_FLIGHT");
};
"SETUP_FLIGHT" = {
ENTER = ("setDesiredRangeTo: 30000000.0", setTargetToRandomStation);
"STATION_FOUND" = (setDestinationToTarget, "setDesiredRangeTo: 30000.0", "setStateTo: HEAD_FOR_RANDOMSTATION");
"NO_STATION_IN_RANGE" = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setStateTo: HEAD_FOR_RANDOMSTATION");
UPDATE = ();
};
FLEEING = {
ENTER = ("setDesiredRangeTo: 25600", performFlee);
"ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: HEAD_FOR_RANDOMSTATION");
"INCOMING_MISSILE" = (setTargetToPrimaryAggressor, groupAttackTarget, "setDesiredRangeTo: 25600", performFlee);
"REACHED_SAFETY" = ("setStateTo: HEAD_FOR_RANDOMSTATION");
"ATTACKED" = (setTargetToPrimaryAggressor, broadcastDistressMessage, groupAttackTarget, "setDesiredRangeTo: 25600", performFlee);
"GROUP_ATTACK_TARGET" = (setTargetToPrimaryAggressor, fightOrFleeHostiles, fightOrFleeMissile, broadcastDistressMessage, "setDesiredRangeTo: 25600", performFlee);
"TARGET_LOST" = ("setStateTo: HEAD_FOR_RANDOMSTATION");
"TARGET_DESTROYED" = ("setStateTo: HEAD_FOR_RANDOMSTATION");
UPDATE = ();
};
"HEAD_FOR_RANDOMSTATION" = {
ENTER = (performStop);
"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
"DESIRED_RANGE_ACHIEVED" = ("pauseAI: 30.0", "setStateTo: SETUP_FLIGHT");
"INCOMING_MISSILE" = (setTargetToPrimaryAggressor, fightOrFleeHostiles, fightOrFleeMissile, "setStateTo: FLEEING");
"ATTACKED" = (setTargetToPrimaryAggressor, fightOrFleeHostiles, fightOrFleeMissile, "setStateTo: FLEEING");
"ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
"GROUP_ATTACK_TARGET" = (setTargetToPrimaryAggressor, fightOrFleeHostiles, fightOrFleeMissile, "setStateTo: FLEEING");
UPDATE = ("setDesiredRangeTo: 30000.0", checkCourseToDestination, scanForHostiles, "pauseAI: 10.0");
};
}