Module airship_ai

Source

Structsยง

AirshipRouteContext ๐Ÿ”’
The context data for the pilot_airship action.
DistanceTrendTracker ๐Ÿ”’
Tracks airship distance trend from a fixed position. Used for airship traffic control. The parameter C is the threshold for determining if the trend is stable (i.e., not increasing or decreasing too much).
MovingAverage ๐Ÿ”’
A moving average of at least N values and at most S values.
RateTracker ๐Ÿ”’
Tracks previous position and time to get a rough estimate of an NPCโ€™s velocity.
StuckAirshipTracker ๐Ÿ”’
Tracks the airship position history. Used for determining if an airship is stuck.

Enumsยง

AirshipAvoidanceMode ๐Ÿ”’
Airships can slow down or hold position to avoid collisions with other airships. Stuck mode means the airship was stuck in one position and is not backing out and climbing to clear the obstacle.
AirshipFlightPhase
The flight phases of an airship.
DistanceTrend ๐Ÿ”’
The trend of the distance changes. The distance measured could be between a fixed position and an NPC or between two NPCs.

Constantsยง

CLOSE_AIRSHIP_SPEED_FACTOR ๐Ÿ”’
CLOSE_TO_DOCKING_SITE_DISTANCE_SQR ๐Ÿ”’
CRUISE_CHECKPOINT_DISTANCE ๐Ÿ”’
MOVING_AVERAGE_SCALE_FACTOR ๐Ÿ”’
NEXT_PILOT_CRUISE_SPEED_TOLERANCE ๐Ÿ”’
NEXT_PILOT_MOVING_DIST_AVERAGE_CAPACITY ๐Ÿ”’
NEXT_PILOT_MOVING_DIST_AVERAGE_MIN_SIZE ๐Ÿ”’
NEXT_PILOT_MOVING_DIST_TRACKER_THRESHOLD ๐Ÿ”’
NEXT_PILOT_MOVING_VELOCITY_AVERAGE_CAPACITY ๐Ÿ”’
NEXT_PILOT_MOVING_VELOCITY_AVERAGE_MIN_SIZE ๐Ÿ”’
NEXT_PILOT_SPACING_THRESHOLD_SQR ๐Ÿ”’
NEXT_PILOT_VELOCITY_RATIO_MIN ๐Ÿ”’
VERY_CLOSE_AIRSHIP_DISTANCE_SQR ๐Ÿ”’

Functionsยง

approach_target_pos ๐Ÿ”’
Get the target position for airship movement given the target position, the default height above terrain, and the height above terrain for the airship route cruise phase. This samples terrain points aound the target pos to get the maximum terrain altitude in a 200 block radius of the target position (only checking 4 cardinal directions). and returns the input approach_pos with z equal to the maximum terrain alt + height or the default_alt whichever is greater.
fly_airship ๐Ÿ”’
Wrapper for the fly_airship action, so the route context fields can be reset.
fly_airship_inner ๐Ÿ”’
The action that moves the airship.
fly_inner_default_goto ๐Ÿ”’
The normal controller movement action of the airship. Called from fly_airship_inner() for cases that do not mean the airship is avoiding the airship ahead of it on the route.
log_airship_position ๐Ÿ”’
When the logging feature is not enabled, this should become a no-op.
pilot_airship
The NPC is the airship captain. This action defines the flight loop for the airship. The captain NPC is autonomous and will fly the airship along the assigned route. The routes are established and assigned to the captain NPCs when the world is generated.
should_hold ๐Ÿ”’
My airship should hold position if the next pilot is moving towards my docking target and is close to my docking target and my pilot is close to the next pilot.
should_slow_down ๐Ÿ”’
My pilot should slow down if the pilot ahead is moving towards my target docking position and the ratio of next pilot velocity over my velocity is less than a threshold (i.e. the next pilot is moving slower than my pilot), and the distance between the next pilot and my pilot is less than some fraction of the standard airship spacing, and the distance between my pilot and my docking target position is greater than the distance between the next pilot and my docking target position (i.e. the next pilot is inside my radius from my target docking position).