Tutorials: Upgrading to AGAST Morningstar


Upgrading to AGAST Morningstar

AGAST Morningstar expands the power of the AGAST development system substantially. While most tasks remain as they were in AGAST 1.08, some improvements to the AGAST development system will require changes to existing code. We realize that this list looks a little long, but keep in mind that it affects a fairly small portion of a game's actual code. The required alterations are mainly confined to initialization and item declaration.

If you need more help, or have questions about any of this, please let us know! We're happy to help.

New text editor

Previous versions of AGAST included an older version of SciTE for editing scripts. Morningstar includes ANGEL, a customized version of SciTE 1.53 with many useful features, including popup function hints.

Re-organized example games

Morningstar's example games are in the agast\games directory. Each includes a batch file called game.bat, which will compile and run the game for you.

The included games are:

  • Demo- A high-resolution feature demo, showing some of the many special effects possible with AGAST Morningstar. Very shiny, very cool.
  • Skeleton- Formerly the SkeletonGame. A bare-bones game that can be copied as the basis for your AGAST game.
  • Simple- Formerly the SampleGame. A simple three-room game with a basic puzzle and dialog.
  • Bedazzled- Parts of a puzzle game. Shows uses for the vertex buffer, and also the process of building a non-adventure game with AGAST.
  • MinimumApp- The smallest possible AGAST application that will compile and run. Does nothing except launch and exit.

Altered and expanded standard scripts

There are a number of new standard script files included with the example games (check games\skeleton

  • Inventory.s now contains the default inventory interface. More information is included later in this document.
  • Items.s now defines the item class.
  • Functions.s now contains the implementation of CallScript(). (See detailed explanation below.)
  • Draw.s now contains most of the drawing functions formerly located in the interpreter. Also, the interpreter function DrawSprite() now implements features previously handled by variant functions like DrawSpriteFilterAddZ().
  • Vertex.s is required for Draw.s.
  • Constants.s includes several new constants required for other included scripts.
  • List.s is required for Midnight. (See below for more details on Midnight.)
  • The Midnight GUI system

    The Midnight GUI system, created by ARKBAN, is the foundation for the default inventory interface (inventory.s) and the default main menu interface (menus.s). In order to use the default inventory interface, you must add inventory.s and also the Midnight files to your game.

    The Midnight required files are:

    • MidnightActions.s
    • MidnightControlClass.s
    • MidnightCreate.s
    • MidnightData.s
    • MidnightDraw.s
    • MidnightMessageBox.s
    • MidnightDefaultScrollArrows.sprite.tga

    Midnight depends on the following standard scripts:

    • Input.s (updated to support Midnight)
    • Constants.s (includes Midnight constants)
    • List.s (provides linked lists for Midnight's list box control)

    You must also set up Midnight before it is used. We recommend doing this by placing a call like the following in event main:

    // Configure Midnight GUI
     Midnight_Setup(
       AgastSmall_font,  //text font
       COLOR_WHITE,  //text color
       MidnightDefaultScrollArrows_sprite  //scroll arrow resource
     );

    Revamped Menus.s

    As mentioned above, menus.s has been revamped to use Midnight. The result is a cleaner and more easily modifiable menu system. Use of the updated menus.s is not required, but it is recommended. Also, use of the old menus.s will require you to comment out DrawGradientBox() in menus.s, since it has been moved to draw.s for the new release.

    Default inventory system is now a standard script

    The default inventory system, which used to be a part of the interpreter, is now a set of standard scripts, located in items.s and inventory.s. While most of the inventory functions operate like those in the previous version, there are also several changes:

    • StickItem() and UnstickItem() have been removed. It should be easy to re-implement them as scripts, or simply replace them with objects (which is the best solution in most cases, since objects have access to a wider range of events, graphical effects, and other coolness than sticky items did).
    • GetItem() is now TakeItem(), to avoid confusion with the multitude of GetWhatever() functions which returned a value, rather than modifying a data structure.
    • SelectedItem() has been replaced by SelectedObject().
    • Inventory functions now exclusively accept and return the indices of objects which represent item types, rather than the position of the item in the inventory. Therefore, GetItemType() is no longer necessary and has been removed.
    • Inventory banks have been removed. Since they can be easily implemented by modifying the inventory scripts, and, as far as we know, no one was using them anyway, they are no longer a part of the inventory system.
    • InvBarEnabled, InvBarX, InvBarY, InvBarStepX, and InvBarStepY have been replaced with properties and members of the inventoryBar object. For example, instead of "InvBarX", you would type "inventoryBar.PositionX".

    Objects replace items

    Morningstar replaces the special item data type in favor of regular objects. That means item definitions like this one are no longervalid:

    item porkchop = porkchop_sprite;
    In order to ease the transition, items.s now includes a class called "item" which, in conjunction with the new script-based inventory system, provides the functionality of the old item data type. A declaration using this new class looks like this:
    object item porkchop{iconSprite = porkchop_sprite;}

    Dynamic backgrounds and zbuffers removed

    Dynamic backgrounds and zbuffers were introduced during the AGAST 1.08 release series in order to ease performance in games which used large numbers of static sprites. With the introduction of Morningstar, this is no longer a concern. All applications of dynamic backgrounds that I've seen can be easily replaced with an object array. While it's possible we might re-introduce dynamic image creation functions at some point in the future (if people want them), I'll probably re-design the way they work substantially.

    Renamed Functions

    A few functions have been renamed in order to be clearer or more consistent with our naming conventions:
    • GetNumObjects() has become ObjectCount().
    • GetLastCycleLength() is now LastCycleLength().

    CallScript() now a script

    Since CallScript() was introduced in the first release of AGAST 1.08, it seems to have become one of the interpreter's most popular functions. As a result, we've expanded on the idea with the new call syntax. CallScript itself is now just a script which takes advantage of this syntax, and is implemented in functions.s. If you want to just copy and paste it yourself, here's the code:
    script CallScript(scriptIndex)
    {
         return <(scriptIndex)>;
    }
    Note that you will need this script if you intend to use the Midnight GUI system, which calls it extensively. Also note that in AGAST 1.08, it was possible to call a script which was declared with arguments via CallScript (which did not support argument passing). This "feature" was in fact unintended and could cause extremely bizarre behavior under the right circumstances. Calling a script which requires arguments without providing those arguments will now produce an error message.