New question, this time about the AI: There is a ship that is a Thargoid hunter. It wanders the space lane between witch point and main station and attacks all Thargoids it finds. If its energy is low, it performs evasive maneuvers until it is at least medium, otherwise it attacks the Thargoids until they are destroyed. If it is being attacked by pirates, it just follows the fightOrFlee logic, nothing fancy there.
This is how I put it into an AI, based on what I understood from the documentation:
Code: Select all
{
GLOBAL = {
ENTER = ("setStateTo: LOOK_FOR_THARGOIDS");
};
LOOK_FOR_THARGOIDS = {
ENTER = (scanForThargoid);
TARGET_FOUND = (setTargetToFoundTarget, "setStateTo: ATTACK_THARGOID");
NOTHING_FOUND = (checkForNormalSpace);
NORMAL_SPACE = ("setStateTo: HEAD_FOR_WITCHPOINT");
UPDATE = (scanForThargoid, "pauseAI: 3.0");
};
ATTACK_THARGOID = {
ENTER = (checkEnergy);
ENERGY_LOW = (performTumble, "pauseAI: 1.0", checkEnergy);
ENERGY_MEDIUM = (performAttack);
ENERGY_HIGH = (performAttack);
ENERGY_FULL = (performAttack);
TARGET_DESTROYED = ("setStateTo: LOOK_FOR_THARGOIDS");
UPDATE = (checkEnergy, "pauseAI: 1.0");
};
HEAD_FOR_WITCHPOINT = {
ENTER = (setCourseToWitchpoint, "setDesiredRangeTo: 15000.0", checkCourseToDestination);
RESTARTED = (setCourseToWitchpoint, "setDesiredRangeTo: 15000.0", checkCourseToDestination);
COURSE_OK = (setSpeedToCruiseSpeed, performFlyToRangeFromDestination);
WAYPOINT_SET = ("setAITo: goToWaypointAI.plist");
DESIRED_RANGE_ACHIEVED = ("pauseAI: 2.0", "setStateTo: HEAD_FOR_PLANET");
ATTACKED = (fightOrFleeHostiles);
INCOMING_MISSILE = (fightOrFleeMissile);
UPDATE = (scanForThargoid, "pauseAI: 3.0");
TARGET_FOUND = (setTargetToFoundTarget, "setThrustFactorTo: 0.8", "setStateTo: ATTACK_THARGOID");
NOTHING_FOUND = ("pauseAI: 3.0");
};
HEAD_FOR_PLANET = {
ENTER = (setCourseToPlanet, "setDesiredRangeTo: 80000.0", checkCourseToDestination);
RESTARTED = (setCourseToPlanet, "setDesiredRangeTo: 80000.0", checkCourseToDestination);
COURSE_OK = (setSpeedToCruiseSpeed, performFlyToRangeFromDestination);
WAYPOINT_SET = ("setAITo: goToWaypointAI.plist");
DESIRED_RANGE_ACHIEVED = ("pauseAI: 2.0", "setStateTo: HEAD_FOR_WITCHPOINT");
ATTACKED = (fightOrFleeHostiles);
INCOMING_MISSILE = (fightOrFleeMissile);
UPDATE = (scanForThargoid, "pauseAI: 3.0");
TARGET_FOUND = (setTargetToFoundTarget, "setThrustFactorTo: 0.8", "setStateTo: ATTACK_THARGOID");
NOTHING_FOUND = ("pauseAI: 3.0");
};
}
Does that make sense? Please disregard the goToWaypointAI for the moment. Also, I haven't thought thoroughly about what needs to change when being in witchspace, so please disregard this, too.