|Project News||General Info||Screenshots||Downloads|
General introduction to RPG.XLS Engine (Chapter Two)
Map Object Model
Large-scale Computer Role Playing Games feature very complex object structure and databases. To get the idea: in a typical arcade game, you mostly deal with objects movement and collisions. But in an CRPG, an object may be a NPC with whom you may fight (movement and collisions like in an arcane) talk (conversation engine, text databases) or exchange items (item database, mapping, usage algorithms) and so on.
This section describes a general structure of map related objects. A single cell in a map can either contain one simple object, fully identified by its numeric id, like tree or plain grass, or a several special objects, linked to other data sources than map array. Special map objects fall into one of the three categories: creatures, items, and all other objects. The example below shows a road sign object:
The info screen states, that at the 154th row and 34th column on the map, there is an object represented visually by tile 1603 and occupying eleventh position on the special object list. Each special object incorporates several numeric and one textual parameter. It can be conveniently edited using RPG.XLS Construction Set UserForms.
One can easily guess that the value "North: Irecocloom" represents textual parameter - a description the player will see during the game when clicking on this particular sign. The meaning of each of the parameters depends on the object, for example doors have parameters representing their resistance to lockpicking and breaking, while alchemy plants store the information when they were harvested last time and the rate of re-growth.
Some special objects are not linked to single cells, but rater a group of cells. These objects are called zones, and are used to trigger events when character enters a given area. The event may be a simple splash screen like "you can smell rotting flesh in this part of the cave" or it may be a complex script that triggers ambush / combat situation. Hidden traps are also stored in zone objects.
Many special objects are linked one to another, for example the lever in a wall may be used to open a door in another part of a building. Objects use their parameters to point to other objects. For sake of simplicity, in some cases linking between objects is based solely on their identical position on the map, for example, the same position of an item and a chest is enough to assume that item is placed in the chest.
Each creature on the map has its unique ID, and many linked objects points to this ID. Linking objects like doors or chests to NPCs allows for easier recognition who will be alarmed if character tries to rob the chest of break through the door. However, the most prominent link between objects and creatures are items placed in creature's inventory.
In example above, a NPC named "Lisa the Brave" carries three items. The access to this oobject is fast and simple with RPG.XLS Construction Set. Note the option "T" in the bottom of Item Manager UserForm – it indicates that selected item, a bedroll, is available for trade and may be acquired from Lisa if character selects the option to barter with that NPC.
Conversations once played crucial role in RPGs, but things changed with the ongoing shift towards the growing emphasis on visuals. I live in Poland, and I learned quite a lot of English by playing RPGs in early 1990s. Now, younger gamers prefer fast action console-style gaming, and don’t want the ‘action’ to be interrupted by 'boring texts'. Fortunately, lot of mature gamers miss old-style conversations and RPG.XLS project will cater to their needs.
There are three basic levels of in game conversations. On the basic level, the player only receive information, without the possibility to interact. In this Non-Player Characters works like voice mail or message board. The step up is keyword system - player chooses a keyword from a list (e.g. ‘brigands’) and receives an answer (e.g. ‘They live in nearby caves’). This model is sometimes called a "wiki" as it resembles searching the encyclopedia.
Finally, advanced conversation system is based on dialog trees, the player chooses a full sentence and gets the extended response, and the whole interaction resembles dynamic real-life conversation. RPG.XLS uses this kind of conversation engine.
The dialog tree method not only allows to transmit information, but also to logically manipulate the state of in-game world. For example, the player may ask about the same thing in either the rude or polite way, and it affects not only the answer but also other dimension The rude question may cause NPC to becomes aggressive and reject further conversations or even to attack the player character.
While writing decent in-game texts requires a lot of work and skill, the dialogue tree engine is surprisingly simple on the technical side. All one need is the code that moves through a simple tree (graph, net) structure: first answer, the set of new questions pointing to a set of answers and so on. Such a basic model may be extended to incorporate conditioned redirections, i.e., the same question may point to different answers on the basis of logical tests involving many different variables.
To easily handle relatively complex dialog trees, I turned conversation engine into a simple script interpreter. For each NPC, its dialog module consists of a set of lines of code. Each line has its label (a unique id, equivalent to the line number in old-style BASIC programming language), its script, and sometimes the text of the question of answer that will be displayed in the conversation UserForm. Below is the simplest dialog module possible:
"X1" is the label, "add" is the script, and "Hello!" is the text. This dialog engine will display "Hello!" in NPC answer window and end conversation, since no pointers to player character’s questions were specified. You may unhide the worksheet text-obj in the RPG Engine workbook to view the actual dialog modules. More complex instruction may look as follows:
The interpreter tests the value of a flag no. 25506 (a kind of universal global variable) and then jumps to label xm30 if test is passed, otherwise it continues processing the code at label xm06a. Processing each dialog branch ends when interpreter finds "add", "addif" or "break" keyword. The number of possible conditions and thus - possible answers to a single question - is only limited by available memory, so one may create very complex conversations.
If you study the unprotected code in RPG engine workbook, you will notice that the interpreter uses VBA Split and Replace functions to "understand" the script. Especially the less known Split function proves very useful when dealing with string variables in VBA programming.