ATS

Andor's Trail Scripting Language

AT (Andor's Trail) Scripting Language is a simple, C-like language used to write scripts (.ats files) that define game logic, trigger events, and control interactive elements in Andor's Trail.

Script files are located in the res/raw/ folder of the project, as plain-text .ats files. The file extension used doesn't matter, but it helps for identification. ATS stands for Andor's Trail Script. There is a detailed breakdown by Zukero on the forums.

Overview

AT scripts are stored in res/raw/ as .ats files and are executed by the game engine in response to triggers like:

  • Map entry/exit

  • Player actions

  • NPC interactions

  • Combat events

  • Item usage

Scripts define behavior through associations - connections between game objects and script methods.

Basic Script Structure

textassociation MyAssociation {
    onCondition() {
        // Triggered when condition is met
    }
    
    onExecute() {
        // Main execution logic
    }
    
    onDeactivate() {
        // Cleanup when association ends
    }
}

Script Lifecycle

  1. onLoad - Script file is loaded into memory.

  2. onInstantiate - Association object is created.

  3. onActivate - Condition is met, association becomes active.

  4. onExecute - Main logic runs each game tick.

  5. onDeactivate - Association becomes inactive or is destroyed.

Variables and Types

Variable Declaration

Value Types

  • numeral: Integer values (-∞ to +∞)

  • boolean: true or false.

  • string: Text values enclosed in quotes.

  • association: Reference to another association.

  • actor: Reference to an NPC or monster.

Trigger Conditions

Conditions determine when an association activates:

Map Triggers

Player Triggers

NPC Triggers

Item Triggers

Control Flow

If-Else Statements

While Loops

Logical Operators

Method Calls

Player Methods

NPC Methods

Map Methods

Item Methods

Associations

Associations link script logic to game objects and events:

Association Types

State Management

Track state using association variables:

Common Patterns

Quest Trigger

Dialogue Progression

Conditional Reward

Best Practices

  1. Use descriptive names - Name associations and variables clearly

  2. Keep scripts focused - One association should handle one logical unit

  3. Check conditions - Always verify conditions before executing actions

  4. State tracking - Use variables to track quest/dialogue progress

  5. Error handling - Assume items or NPCs might not exist

  6. Comments - Document complex logic

  7. Testing - Test edge cases (missing items, NPCs, etc.)

Integration with Game Files

Scripts are referenced in JSON files:

Limitations

  • Scripts run synchronously - they cannot create delays or wait

  • Script execution is limited to prevent infinite loops

  • Access to game objects is restricted for security

  • Cannot directly modify save game data

Debugging Tips

  1. Add dialogue messages to track execution

  2. Check console output for script errors

  3. Use map.displayMessage() to show variable values

  4. Test each association independently

  5. Verify JSON references are correct

Resources

  • Example Scripts: Check res/raw/*.ats in game repository

  • Game Engine: See source code in src/com/.../ for method definitions

Last updated