|★ CODING ★ 9. LOCATIONS, OBJECTS AND EVENTS IN AKS ★|
|Writing Adventure Games on the Amstrad - 00 - Contents||Writing Adventure Games on the Amstrad - 09 - Locations, objects and events in AKS|
An AKS scenario is based around the structures of Locations, Objects and Events, as these govern which actions take place where, which objects can be manipulated and so on. In this chapter we will take a look at how the Actions and Triggers we have already considered fit into the Location and Object structures.
The ordering of different data types is important in AKS, as the memory map in chapter 6 shows, and thus we will deal with these differing data types in the order they will appear in an AKS scenario.
Locations must be declared in an AKS database in ascending order of location number. Location zero is the special global location, as we have already mentioned in the previous chapter while looking at Triggers. Each location has a very similar header, which might look like this:
This declares location 15, with a description of “In the dark woods”, which has no condition attached. The location is connected to location 16 to the north, and location 18 to the S. There are no conditions attached to the player moving to either of these two locations. There can be as many descriptions (each with an associated condition) as you wish, which enables us to simulate darkness, or to abbreviate the description if the player has already visited this location. We simply include these facts in the relevant condition; see the next chapter for a detailed description of the conditions available in AKS, and their use.
The above location declaration is very basic, as it does not include any triggers, these are simply added in before or after the connection information. An example location might be:
This adds triggers which will detect attempts to climb trees, and plant acorns!
Objects must be declared in numerical order, any out of sequence objects being reported by the AKS system when you attempt to execute the adventure. In the same way that location 0 is special, so is object 0, as it represents the player! This does mean that object 0 can be manipulated in the same way as other objects — so you can move the player around, but, the declaration for the player will normally only include an initial starting location and nothing else.
There are a number of elements to an object declaration, and we will look at each of these in turn. The best method is to consider the following example, and we can then look at what each element stands for:
This declares object number 4. The first line of the declaration gives the object a description, which will be printed out with no conditions attached. The “P, 19" says that the lamp's initial position at the start of the adventure will be location 19. We need to let the player refer to the lamp by different names in his command input, so we declare a set of names using the "N” command, which allows you to attach a condition to the player using that name.
Finally, the “S” construct lets us set the suitability of the object to be used with certain of the inbuilt AKS actions. In our example above, our lamp is suitable for GEtting, DRopping and Examining; there is no limit to the actions which can be performed on an object (except com-monsense of course!).
An event is acted upon whenever the counter associated with it reaches a value of zero, after it has been activated by another part of the database. This is where the Initialise Counter action comes in, as we can set the counter to a number of turns, after which the event associated with that counter will come into action.
An example event might be declared as follows:
This declares event 0 (which is not special in the way location and object 0 are) and lists a number of actions to be performed. In the case of our example, when the event is triggered, a message "You have run out of time ..." is printed, the player's score displayed and then the game ended. This could be used if the player had a maximum number of moves to complete some action, or even the whole game, in. If he fails to do so, event 0 comes into action.