Fast Travel Example

Amadeus

The Maestro
Staff member
Below is an example script utilizing the functionality added on January 1, 2024.

Code:
function main()
{
    variable int WaitCounter
    variable int i

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; TRAVELMAP WINDOW (Fast Travel Window)
    ;;
    ;; The following routines outlines how one might iterate through information
    ;; provided by the Fast Travel (TravelMap) Window.
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ; Open the Fast Travel (TravelMap) Window
    EQ2:OpenFastTravelWindow

    ; Wait for the TravelMapWindow to appear, then wait just a bit longer to be safe.
    WaitCounter:Set[0]
    do
    {
        waitframe
        WaitCounter:Inc
        if (${WaitCounter} > 1000)
        {
            echo "TravelMap never appeared.  Giving up."
            endscript FastTravelTest
        }
    }
    while (!${TravelMapWindow(exists)})
    wait 10

    ; Iterate through and spew all fast travel points in the game world.  This data is
    ; purely informational, as it's not used by ISXEQ2 anywhere else.
    echo "FastTravelWindowLocations (Size: ${TravelMapWindow.TeleportLocations}):"
    i:Set[1]
    do
    {
        echo "- ${i}. ID: ${TravelMapWindow.TeleportLocation[${i}].ID}"
        echo "- ${i}. LowerLevel: ${TravelMapWindow.TeleportLocation[${i}].LowerLevel}"
        echo "- ${i}. UpperLevel: ${TravelMapWindow.TeleportLocation[${i}].UpperLevel}"
        echo "- ${i}. ZoneName: ${TravelMapWindow.TeleportLocation[${i}].ZoneName}"
        echo "- ${i}. ZoneShortName: ${TravelMapWindow.TeleportLocation[${i}].ZoneShortName}"
        echo "- ${i}. ZoneDescription: ${TravelMapWindow.TeleportLocation[${i}].ZoneDescription}"
        echo "- ${i}. Destination: ${TravelMapWindow.TeleportLocation[${i}].Destination}"
        echo "- ${i}. DestinationDescription: ${TravelMapWindow.TeleportLocation[${i}].DestinationDescription}"
        echo "- ${i}. MapPositionX: ${TravelMapWindow.TeleportLocation[${i}].MapPositionX}"
        echo "- ${i}. MapPositionY: ${TravelMapWindow.TeleportLocation[${i}].MapPositionY}"
        echo "--"
    }
    while (${i:Inc} <= ${TravelMapWindow.TeleportLocations})

    ; Now, iterate through the "buttons" available on the Fast Travel (TravelMap) Window
    ; These are the zone names that you see on the window and that you click on before
    ; clicking the big "Next" button.
    echo "Fast Travel Zone Destinations (Count: ${TravelMapWindow.Buttons.NumChildren}):"
    i:Set[1]
    do
    {
        echo "- ${i}. ${TravelMapWindow.Buttons.Child[${i}].Text}"
    }
    while (${i:Inc} <= ${TravelMapWindow.Buttons.NumChildren})

    ; Choose/click the "Antonica" button
    TravelMapWindow.Buttons.Child[Antonica]:LeftClick

    ; Wait until the "Next" button is enabled and ready
    WaitCounter:Set[0]
    do
    {
        waitframe
        WaitCounter:Inc
        if (${WaitCounter} > 1000)
        {
            echo "'Next' button never enabled.  Giving up."
            endscript FastTravelTest
        }
    }
    while (!${TravelMapWindow.Child[button, ZoneButton].IsEnabled})
    wait 10

    ; click the button and then wait a bit before going on, just in case
    TravelMapWindow.Child[button, ZoneButton]:LeftClick
    wait 20
    ; NOTE:  To Cancel, you would use "TravelMapWindow.Child[button, WC_CloseButton]:LeftClick"

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; MAP WINDOW
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; The map window should already be open, based upon the routines above.
    ; Now, iterate through the available fast travel locations.  Please note that
    ; the "Index" value below is the number used with the actual :Teleport method
    ; that will be used next in this script.
    echo "Fast Travel Destinations within ${MapWindow.MapZoneShortName} (Count: ${MapWindow.TeleportLocations}):"
    i:Set[1]
    do
    {
        echo "- ${i}. Index: ${i}"
        echo "- ${i}. ID: ${MapWindow.TeleportLocation[${i}].ID}"
        echo "- ${i}. Description: ${MapWindow.TeleportLocation[${i}].Description}"
        echo "- ${i}. Location: ${MapWindow.TeleportLocation[${i}].Location}"
        echo "--"
    }
    while (${i:Inc} <= ${MapWindow.TeleportLocations})

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; ACTUAL TRAVEL
    ;;
    ;; The following routine will travel to the Fast Travel location index 1.
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Fast Travel to the location with index 1  (Sanity Check: Make sure Travel Choice Window is not already
    ; active; otherwise it will crash the game.)
    if (!${ChoiceWindow.Choice1.Equal[Travel]})
    {
        MapWindow:Teleport[1]
    }
    else
    {
        echo "Please close (Cancel) the fast travel choice window before continuing."
        endscript FastTravelTest
    }

    ; Wait for the Travel Choice Window to appear, then wait just a bit longer to be safe.
    WaitCounter:Set[0]
    do
    {
        waitframe
        WaitCounter:Inc
        if (${WaitCounter} > 1000)
        {
            echo "Choice Window never appeared.  Giving up."
            endscript FastTravelTest
        }
    }
    while (!${ChoiceWindow.Choice1.Equal[Travel]})
    wait 10

    ; Choose "Travel" from the Choice Window
    ChoiceWindow:DoChoice1

    ; Wait until Zoning
    WaitCounter:Set[0]
    do
    {
        waitframe
        WaitCounter:Inc
        if (${WaitCounter} > 1000)
        {
            echo "Never started zoning.  Giving up."
            endscript FastTravelTest
        }
    }
    while (${EQ2.Zoning.Equal[0]})

    ; Wait until Zoning finishes
    WaitCounter:Set[0]
    do
    {
        waitframe
        WaitCounter:Inc
        if (${WaitCounter} > 1000)
        {
            echo "Never finished zoning.  Giving up."
            endscript FastTravelTest
        }
    }
    while (${EQ2.Zoning.Equal[1]})

    ; finish-up
    wait 10
    press esc
}
 
Last edited:
Top Bottom