home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Select: Games 3
/
cd.iso
/
games
/
dcg303
/
dcscript.doc
< prev
next >
Wrap
Text File
|
1993-04-08
|
79KB
|
2,219 lines
NOTE: This manual was written in a graphics word processing system
(Ami Pro 2.0). This text file contains most of the text in the
manual, but the graphics are lost and the tables are not formated.
When you register, you can get a copy of the documentation for
only $5 to cover the cost of printing and shipping. See INVOICE.DOC
for details.
--------------------------------------------------------------------
Introduction ............................................1
Preface .................................................1
Document Organization ...................................1
Conventions .............................................2
Getting Help ............................................2
Basic Information .......................................3
What is a script? .......................................3
What is a script used for? ..............................3
Character scripts .......................................3
Object scripts ..........................................4
World script. ...........................................5
Control script ..........................................5
Magic Spells ............................................5
Game Initialization Script ..............................6
Dead and Resurrection ...................................6
Basic Script Elements ...................................7
Keywords ................................................7
Keywords Table ..........................................8
Comments ................................................8
Numbers .................................................9
Tokens ..................................................9
Variables ...............................................10
Generic Variables (Local and Global) ....................10
String Variables ........................................10
World Variables and Attributes ..........................11
Object Variables and Attributes .........................11
Character Variables and Attributes ......................13
Group Variables and Attributes ..........................14
Types of Scripts ........................................15
Introduction Script .....................................15
Character Script ........................................16
Object Script ...........................................17
World Script ............................................18
Control Script ..........................................18
Resurrection Script .....................................18
Writing Scripts .........................................19
Script Files ............................................19
Expressions and Assignments .............................20
Function Table ..........................................21
Statements ..............................................22
Conditional Statements ..................................22
Flow Control Statements .................................23
Flow control using if ...................................23
Flow control using on-goto ..............................23
Loop Control Statements .................................24
The while statement .....................................24
The for statement .......................................24
The foreach statement ...................................24
Object Manipulation Statements ..........................25
Move and Copy ...........................................25
Drop ....................................................25
Output Statements .......................................25
Write and Writeln .......................................25
Display .................................................26
Input Statements ........................................26
Getstr and Getnum .......................................26
Select ..................................................26
Going Places ............................................26
Animation ...............................................27
Entering Doors ..........................................27
Teleportation ...........................................27
Advanced Topics .........................................27
Entry Points ............................................27
Calling A DOS program ...................................28
Creating New Types and Classes ..........................29
New Character Types .....................................29
New Character Classes ...................................29
New Object Types ........................................30
New Object Classes ......................................30
New Object Modifiers ....................................31
New World Types .........................................32
Shareware Opportunities .................................33
Extending the magic system ..............................33
MS-DOS based extensions .................................33
Writing a whole new system ..............................34
D C - G A M E S
Version 3.0
SCRIPT LANGUAGE USER'S GUIDE
March 1993
(c) DC Software, 1992
6705 Laramie Dr.
Plano TX 75023
(214)517-0428
Introduction
Preface
One of the goals of the DCGAMES adventure and role-playing game
building system is to provide an environment in which you can
create adventure games without having to know anything about
computer programming, and without having to maintain a zillion
lists of cryptic numbers. If you want to draw a river, you just
do it. If you want to create a dragon, just grab the right
picture and do it. The idea is to have a large enough set of
objects, characters, monsters and landscaping to allow you to
concentrate on the story.
While this works fine most of the time, it is almost inevitable
that there will be a few things you need to do that I didn't
think of, or which need to work slightly different. You may
need a new type of character or object, or some new magic
spells. Maybe the wizards are too wimpy or elves and dwarfs
should not exist in your adventure.
Most of the features in the DCGAMES system are handled by
scripts. The script language is a simple yet powerful language
that the game driver understands, and which control the behavior
of most parts of the game system.
The scripts are created using a standard text editor, and can be
as simple or complex as you need them to be. While you can
write a complete game without writing a single line of script, a
small effort on your part to learn how to write script will
result in significantly better games, since you can fine-tune
your creation to work exactly the way you want it to work.
Document Organization
This manual is organized in several sections. The first one is
an introduction to the elements of the DCGAMES system. It
explains each of the building blocks used to create an
adventure, and how (and why) you would want to customize them.
Everyone should read this section!
The second section is a Reference Manual, which is a list of the
features of the script language in a logical order. You will
need a printed copy of that section of the manual when you are
actually writing a script.
Conventions
In this document, the following conventions are used:
UPPER-CASE-WORDS
represent tokens that have a specific value and are typed
exactly as shown.
italic-words
are used when a new concept is being introduced, and the world
in italics is the name of that concept. They are also used to
indicate that you should be replace the word with an appropriate
name or value.
bold-words
represent names or values that should be typed exactly as shown.
text1 | text2
items separated by a vertical bar (|) mean you get to choose one
of them.
[ ]
items enclosed in square brackets are optional. If multiple
items are listed, separated by a vertical bar, then you may
choose one of them or none.
{ text1 | text2 }
items enclosed in curly braces are NOT optional. You must
select one of the items listed.
...
three dots (ellipsis) indicate that the previous item can be
repeated multiple times. If there is a limit to the number of
times an item can be repeated, it will be indicated in a note
near the area where the ellipsis were used.
Getting Help
Registered users of DCGAMES get free telephone assistance
evenings and weekends. This assistance may range from
explaining how a certain feature works to guidance in how to add
a new feature. I might even write some specialized scripts for
you (within reason).
Non-registered users are welcome to call also. I will try to
answer questions over the phone, but please keep your questions
simple and organized. If you feel you can't afford to pay for
the game, I've been known to accept a smaller amount or even
waive the fee in exchange for some serious feed back or some
outstanding artwork or sound recordings that I may incorporate
into the shareware product.Basic Information
What is a script?
A script is a text file, created using a simple text editor (If
you use a word processor, be sure to store the file in 'ASCII'
or 'PLAIN TEXT' format).
The script file contains the instructions that tell the game
driver (DCPLAY program) how to handle most aspects of the game.
The system includes a large number of predefined scripts to
handle objects, characters, worlds, etc. You can modify these
scripts to meet your game's individual requirements, and you can
write whole new scripts to extend the number of options you have.
The script language was designed to be easy to learn and use.
The documentation was written specifically for people that have
no prior exposure to programming, and the predefined scripts
have extensive annotations to help you understand them and learn
from them.
A good thing to remember is that you cannot cause any damage
through experimentation. The worst you can do is to make some
changes to a script that prevent it from operating properly.
All you have to do is retrieve a copy of the original script
(which you saved before you modified the script, right? right!)
or at worst, you can give me a call and I will help you fix it.
Don't be afraid to try!
What is a script used for?
The game builder (DCWORLD program) is used to create worlds. You
use landscaping graphics blocks to paint the different worlds,
you open doors between them to allow the game player to move
from one world to another. You then add characters and objects
to the worlds, populating towns, cities, castles and dungeons,
each of them having it's own reason for existing in your
universe.
The DCGAMES system includes a large set of predefined scripts
which are used to handle your game. While these scripts are
complete, you may want to modify them or write new scripts to
handle your specific needs. The type of script you write depends
on the aspect of the game that you want to control.
Character scripts
Every character in your game will have a character type
associated with it. You specify the type when you create the
character using the DCWORLD program. Each character type is
completely defined with a script file.
DCGAMES includes a full set of character scripts that implement
the following character types: Adventurer, Bartender, Beggar,
Civilian, Guard, Healer, Merchant, Prisoner, Teller and Trainer.
The behavior of these character types is described in detail in
the DCGAMES User's Guide. One of the best ways to become
quickly familiar with the script language is to compare the
description of the character type as documented in the User's
Guide with the actual script that makes the character behave
that way.
The name of the character script is created by taking the first
8 characters of the character type and adding the extension
.SCR. Thus, a healer's script is HEALER.SCR, and a bartender's
script is BARTENDE.SCR.
Of course, you may add new character types by creating new
scripts, or you can modify existing scripts if the character
type doesn't meet your exact needs.
Object scripts
Objects, like characters, behave in predictable ways depending
on the object's type. Unlike characters, however, a single
script handles all of the object types.
The script OBJECT.SCR is by far the most complex script
provided. It can handle object of type Food, Weapon,
Ammunition, Armor, Shield, Amulet, Ring, Potion, Scroll, Staff,
Chest, Keys, Gems, Book, Gold Sack, Torch, Lantern, Rope, Hooks,
Mirror, Sign and Vehicle.
When the game driver needs to handle an object, it checks to see
if it has a script assigned to it. If it does, the object's
script is given the opportunity to handle the action that the
game driver is trying to accomplish. If the object does not
have a script, or, if it does have a script but the script does
not handle that particular action, then the OBJECT script is
invoked.
You can alter the behavior of an object in several ways. You may
modify the OBJECT.SCR to alter the way existing objects types
work, or define new object types; You can also create a brand
new script file to control the behavior of a specific object.
For example, if your adventure is loosely based on 'Snow White
and the Seven Dwarfs', you definitely need a 'mirror' that can
talk back to you. Mirrors as handled by the OBJECT script have
no special features. You can modify the script so that two
classes of mirrors exist. Normal mirrors, which do nothing
special, and Magic mirrors, which have special uses. This
modification means you can now create any number of normal or
magic mirrors.
However, if you only need ONE magic mirror, with some very
specific behavior, you may just create a separate script for
that particular item. The script doesn't even have to handle
most of the actions that you can perform on a mirror. It only
has to handle the situation where the character TALKS to the
mirror. Any other action, such as GET, DROP, LOOK, etc, can be
handled by the OBJECT script.
World script.
A world is the scenario upon which your adventure takes place.
A world's most visible attribute is it's graphical landscaping,
but worlds, just like characters and objects, worlds can be
configured with special attributes and have a script associated
with them.
When the player enters or exists a world, the world's script is
executed. The predefined script WORLDDEF.SCR is executed if you
don't provide one of your own. The world's script can deny
access to the world, or send the character to a different
destination within the same world or in any other world.
The game system includes 10 different types of worlds: Outdoors,
City, Town, Dungeon, Hideout, House, Castle, Arena, Haunted and
End-Game. The world's type affects different aspects of the
game system. For example, in OUTDOOR type worlds if you walk
all the way to the edge of the world you 'wrap around' to the
other side. (i.e. the world is round), but in a town or city,
if you walk to the edge you leave the city and go back to the
place where you originally came from.
Control script
The game system includes the concept of time. You have complete
control over the duration of a minute, the number of minutes per
hour, hours per day, days per month and months per year.
Once a minute (in game time), the CONTROL script is invoked.
This script performs tasks that depend on time, such as
restoring health, causing damage to exhausted, famished or sick
players, creating random monsters, etc. You can add your own
timed events to the control script.
The script is also called when the party decides to rest
(Camp-out command) and when a member of the party is asked to
leave.
Magic Spells
The OBJECT script includes two kinds of magical objects. Food,
Potions, Rings, Amulets and Gems all have personal magic, which
is invoked on the individual that uses the object. Staffs and
Scrolls have external magic, which affect individuals other than
those that use them. You can, of course, modify the
implementation of magic at will.
When a magic user Casts a spell, no object is involved, so a
separate script (CASTING.SCR) is used to control magic user
spells. The casting scripts allows Wizards and Elves to cast
external magic spells as long as they have enough power points
to handle the spell. You could easily change this script to
have a multi-level spell system which allows only certain spells
within each level, or you could create a new character type (say
Cleric) that has a different set of spells than a Wizard or Elf.
Game Initialization Script
When the game first starts, the INITGAME script will be invoked.
This script is used to present the game's story. You can use
voice, music, graphics, text, animation, etc.
Within this script you have the chance to create the player's
character. If you don't, the game system will invoke the
standard character creation screen after the INITGAME script is
done.
Dead and Resurrection
When all members of the playing party die, the resurrection
script will be invoked to allow you to perform standard actions
such as save, restore, restart or even revive the party and give
the player another chance.
The predefined resurrection script (RESURECT.SCR) will keep
giving the player another chance as long as the player's level
exceeds the number of times the player has died.Basic Script Elements
This section introduces the basic elements that form the script
language. Just like in English you use words to build sentences,
and those words are classified into verbs, adjectives, etc, so
does the script language use a basic set of elements to build
it's sentences.
The script language contains the following basic elements:
Keywords, Tokens, Constants, Variables, Structures, Statements,
Functions, Procedures, Comments. Let's look at each one in turn.
Keywords
A keyword is a word that has a special meaning in the script
language. They are presented in alphabetical order, but grouped
into primary, secondary and function keywords.
A primary keyword is equivalent to a verb in the English
language. It indicates the action taking place.
Secondary keywords are used to complement primary keywords and
have meaning only within the context of a primary keyword. For
example:
if player.name = "Henry" and fighting then write("Go Away");
endif;
In the above line, the if and write keywords are primary, then,
and endif are secondary because they have a meaning only in
relation to the if keyword.
Function keywords are used to determine (or modify) a system
value. For example, if the keyword fighting has a non-zero
value it indicates that a fight is currently taking place.
Note that player.name is not a keyword, it is a variable
(player) and an attribute (name). Variables and their
attributes are covered in elsewhere.
The section Writing Scripts in this manual introduces most of
the keywords using simple examples. A detailed description of
each keyword can be found in the Script Language Reference Guide.
Keywords Table
Primary Keywords Primary (continued) Function Keywords
continue save abs
copy select adjustments
dec setbody Day
display setbp DaysInAMonth
drop stats DefCaveBlk
endgame stop DefLandBlk
enter teleport DefPack
fight vanish DefSpookBlk
find viewpcx DefStat
for voice DefWaterBlk
foreach vplay fighting
frame wait failure
getnum while group
getstr write Hour
goto writeln HoursInADay
gosub Secondary Keywordsmax
if and min
inc by Minute
join else MinutesInAnHour
leave elsif Month
loadhint end MonthsInAYear
loadtext endif MovesPerMinute
locate endfor object
move endwhile player
npc matching random
on not success
paint or SunSet
pause screen SunRise
readtext then version
restart to world
restore window Year
return xor
Keywords in italics are a special kind of keyword, in that they
represent Control Variables.
Comments
A comment is a sequence of characters beginning with the
character '!'. The exclamation point tells the script language
compiler that the text that follows is a comment and should be
ignored. Comments are used to document your scripts so they are
easier to understand.
For example:
! This is a comment
! This is also a comment! All of it..
!!! This is another comment.
Note that all text following first ! is part of the comment,
including any other ! character.
Numbers
Numbers are very important in DCGAMES.
They are used extensively to identify the attributes of objects
and characters. As a rule, numbers can be values between
-2147483647 and 2147483647. While this is true for constants,
when using numbers, you will usually have to restrict them to be
within the range of values allowed for the purpose you are using
the number for. For example, a ring object has an attribute
called charges which holds the number of times the ring can be
used. This attribute can have a value between 0 (no charges
left) and 255. Trying to set the charges attribute to 500 will
result in a warning message, and assign the maximum allowed
value of 255. The range of values that an attribute can take are
documented along with each attribute in the section entitled
STRUCTURES further on in this chapter.
Tokens
When you write a script, you frequently need to examine and
modify the attributes of objects and characters, or to perform
different actions depending on the values of the same. While
most of these attributes are numeric, you don't need to remember
what each number means. Instead, tokens have been defined that
represent the numeric values.
In this document, tokens are shown in UPPER CASE. Any name
shown in upper case letters can be considered to be a token.
For example. The standard product includes a set of pre-defined
object types such as FOOD, WEAPON, ARMOR, etc. The game uses a
number to represent the object's type (0, 1, 2, 3, etc), but it
would be difficult to remember that if you want to create a
WEAPON, you need to set the object's type to 1. Thus, a token
(namely WEAPON) can be used. A complete list of predefined
tokens, their values and their usage can be found in the
appendix.
If you modify or extend the set of pre-defined element types,
you will also add new tokens to the file DCCTOKEN.DAT, which
associates the token name with the actual value it is going to
represent. Once the name has been added to the file, you no
longer have to remember what value you were using for your new
'type' or 'class' or whatever.
Variables
A variable is a name used to represent a value, just like a
token, but the difference is that the variable holds a value,
and the value can be modified. For example, an object could
have a weight of 100, but you can change that value any time.
Variables are shown in bold letters in this document. A
variable may have more than one value associated with it (for
example, an object has a name, a value, a weight, etc.). The
values associated with the variable are called the attributes of
the variable.
The following paragraphs hold a complete list of all variables,
their names, attributes, values and a brief description of the
meaning of the associated value.
Generic Variables (Local and Global)
There are 256 local variables, named L0 through L255. They can
hold values between -32768 and +32767. They are called local
because they exist only during execution of the script. Once
the script has been executed, any value you placed in them is
lost.
Every time a script starts execution, it's local variables are
initialized to zero. These variables are used mostly for
control purposes and to hold intermediate values.
There are 256 global variables, named G0 through G255. These
variables can hold values between -32768 and +32767. They are
called global because they exist for the entire duration of the
game. If you set one of these variables to a certain value, it
will retain that value until you change it again. These
variables are used to hold values that are important throughout
the life of the game. For example, you might use one of these
variables to indicate that a certain action has taken place.
Other scripts could then check the value of the variable and
take different actions depending on whether the action has taken
place or not.
String Variables
There are 17 string variables, named S0 through S16. They are
different from other variables in that they hold TEXT instead of
numbers. They are also different in that they are used for some
specific purposes, and so, are not "generic".
Variable S0 can contain up to 255 characters. While you can use
it for any purpose, it is also used to store any text that the
player types during conversations, as well as other values. The
getstr() script function asks the user to type something, and
stores that value in this variable (among other things).
Variables S1 through S16 can contain up to 64 characters. These
variables hold the 16 lines of text associated with the current
object or character. The loadtext() script function will load a
given text record and place each of the lines in the
corresponding variable.
World Variables and Attributes
Each world has a certain number of attributes which you can
examine and in some cases modify. You can only access the
attributes for the world you are currently in.
Attribute Description
name Name of the current world, text, 15 chars
index* Current world number
type World's type, 0 - 255 Tokens: OUTDOORS, CITY, TOWN, DUNGEON, HIDEOUT, HOUSE, CASTLE, ARENA and ENDGAME
x* Horizontal size (width) of the current world
y* Vertical size (height) of the current world
block(x,y) Landscaping block # displayed at position x,y
density(x,y) Density of landscaping block at position x,y
level Minimum player level needed to enter this world
door* the door through which you entered the current world
doorx(door#) Horizontal location of the door in the current world
doory(door#) Vertical location of the door in the current world
destinationworld(door#) Destination world #
destinationdoor(door#) Destination door in the destination world (non-trap doors only)
destinationx(door#) Horizontal location in the destination world (trap doors only)
destinationy(door#) Vertical location in the destination world (trap doors only)
trapdoorswitch(door#) Is non-zero if the door is a TRAP (destinationx/y instead of destinationdoor)
entrytext(door#) Text block # displayed when the player enters the world through the door
entrytextswitch(door#) If non-zero, the text is displayed only the first time the door is used
exittext(door#) Text block # displayed when the player exits the world through the door
exittextswitch(door#) If non-zero, the text is displayed only the first time the door is used
edgedoor The door through which the player exits the current world by walking 'of-the-edge' of the world, or casting the standard 'exit' spell
Object Variables and Attributes
An object is an item that can be manipulated in many different
ways during game play. The object's TYPE and CLASS determine
what can be done with the object.
Most of the behavior of objects is controlled from the
predefined script OBJECT. This script can handle objects of
type food, weapon, ammunition, shield, armor, ring, amulet,
scroll, staff, chest, vehicles, etc.
Objects Description
player.weapon The weapon wielded by the current player (if any).
player.armor The armor worn by the current player (if any).
player.shield The shield being used by the current player (if any).
player.ring The ring being worn by the current player (if any).
player.amulet The amulet being worn by the current player (if any).
player.staff The staff being used by the current player (if any).
player.body The last selected body item (represents one of player.weapon,
player.armor, player.shield, player.ring, player.amulet or
player.staff.
player.bp The last selected backpack item for the current player.
The backpack can hold up to 16 items, but only one of
them is selected at a time.
npc.weapon The weapon wielded by the current npc (if any).
npc.armor The armor worn by the current npc (if any).
npc.shield The shield being used by the current npc (if any).
npc.ring The ring being worn by the current npc (if any).
npc.amulet The amulet being worn by the current npc (if any).
npc.staff The staff being used by the current npc (if any).
npc.body The last selected body item (represents one of
npc.weapon, npc.armor, npc.shield, npc.ring, npc.amulet or
npc.staff.
npc.bp The last selected backpack item for the current npc.
The backpack can hold up to 16 items, but only one of them is
selected at a time.
group.vehicle The vehicle the group is currently on (if any).
object The object represented by this variable is not being
carried by anyone. It exists on it's own in the current world.
curritem The object represented by this variable is being
carried by either the player or the npc character, either in the
backpack or being worn. It is used when the exact location of
the object is not important.
All of the objects listed above have the same exact attributes,
as follows:
Attribute Description
name Name of the object (15 characters max).
index Position in it's current environment (backpack, world,
etc..)
type Object Type (0-255). Tokens: FOOD, WEAPON, AMMO, ARMOR,
SHIELD, AMULET, RING, POTION, SCROLL, STAFF, CHEST, KEYS, GEMS,
BOOK, GOLDSACK, TORCH, LANTERN, ROPE, HOOKS, MIRROR, SIGN,
VEHICLE.
class Object Class (0-255). Class depends on object type. See
Predefined Object Types section for details.
block Current graphics block # associated with this object.
picture Current graphics file # (Filename: OPICTnnn.PCX)
voice Current voice file # (Filename: VOICEnnn.VFL)
weight Current weight of the object (1=None, 2-255 lbs, >255
special purpose).
value Current value of the object in Silver Pieces (10sp =
1gp).
x Object's horizontal location (when not being carried).
y Object's vertical location (when not being carried).
count Number of objects represented by this single instance.
script Object's current script file (default = OBJECT), may be
blank.
text Object's text record (if any).
endgame 0=No, 1=When user GETs object. 2=When user gives the
object to a 'quester' type character.
endtext Text block # to be displayed when the game ends due to
'endgame'.
v0 - v7 Object variable. Use for anything you want.
m0 - m4 Object modifier. Meaning depends on object type and
class. See Predefined Object Types section for details.
Character Variables and Attributes
A character in the adventure can be a simple 'extra', with no
other function than to flesh out a story, or it can be an
integral part of it. Every character is controlled by a script,
and the system includes a large number of predefined scripts to
handle different types of characters. Amongst the different
types of characters are: Regular, Bartender, Merchant, Civilian,
Quester, Beggar, etc. Each of these character types has it's
own script, and when you create a character, you will usually
select one of these scripts to handle it's behavior. You may
extend the functionality of each character type by modifying the
scripts, or you can create brand new scripts to handle a brand
new type of character. For those characters that are central to
the story, you may even want to create a special script that
handles their unique behavior.
When referring to characters, you may talk about the player or
the npc. In any interaction, the player is a member of the
game player's party. The npc is the member with which the
player is interacting.
Attribute Description
name Name of the character (15 characters max).
index Current position in the world.
type Character Type: (0-255). Tokens: HUMAN, WIZARD, ELF,
DWARF, etc.
class Character Class (0-255). Depends on character type. See
Predefined Character Types section for details.
block Current graphics block # associated with this character.
block2 Alternate graphics block # (used for followers in a
monster party).
picture Current graphics file # (Filename: CPICTnnn.PCX)
voice Current voice file # (Filename: VOICEnnn.VFL)
x Character's horizontal location in the current world.
y Character's vertical location in the current world..
count Number of characters in the party (1-16).
script Character's current script file (default = OBJECT), may
be blank.
text Character's text record (if any).
load/mload Current/Maximum load (how much weight can be
carried)
str/mstr Current/Normal strength
aim/maim Current/Normal aim
dex/mdex Current/Normal dexterity
spd/mspd Current/Normal speed
pwr/mpwr Current/Normal magical power points
hp/mhp Current/Normal Hit Points
iq/miq Current/Normal intelligence
ac/mac Current/Normal Armor Class
exp Current experience points
level Current character level
poisoned Character is poisoned
scared Character is scared
paralyzed Character is paralyzed
confused Character is confused
invisible Character is invisible
energy Current energy level (From food. See group.energy for
energy from sleep).
stats Character statistics record.
v0 - v7 Character variable. Use for anything you want.
weapon Currently wielded weapon (if any)
armor Currently worn armor (if any)
shield Currently worn shield (if any)
ring Currently worn ring (if any)
amulet Currently worn amulet (if any)
staff Currently wielded staff (if any)
bp Currently selected backpack object (The backpack can hold
16)
body Currently selected body object (if any, one of the
following 6 objects).
Group Variables and Attributes
The group is the party of up to 6 characters that are playing
the game. Usually, the game starts with only one character in
the group, which is created by the game player.
During the game other players may join the group.
Attribute Description
size* Current number of characters in the group.
current Currently selected 'spokesbeing' for the group (0-5).
gold Total amount of currency carried by the party. For
consistency, the actual value in this attribute is the amount of
SILVER (divide by 10 to get the amount of gold).
food The total amount of normal (non-magical) food being
carried by the party.
energy The group's energy, which is replenished with sleep.
dead_count Number of times that everyone in the group has died
(and thus, how many times they have been resurrected).
x Current horizontal location in the current world.
y Current vertical location in the current world.
moves Total number of moves since the game started.
block Graphics block # that represents the group. Note that
when a fight is taking place, each member of the group is
represented by their own graphics block)
vehicle Current vehicle (if any). If the group is riding a
vehicle, the vehicle's graphics block is displayed instead of
the group's graphics block.
Types of Scripts
This section talks about the different TYPES of scripts you may
want to write, and tries to point out WHY you would want to
write that kind of script, instead of HOW. The actual script
language is presented in the section Script Language Programming
Guide later in this manual.
Introduction Script
The introduction script (INITGAME.SCR) is a script that is
executed only the first time you start playing. Like most games,
you must start of by telling the game player what the story is
about, give some background information, set the mood for the
game.
Before the script is invoked, a 'standard' character is created
with the following attributes:
group.gold = 1000; ! 1000 silver pieces = 100 gold
pieces
group.food = 25; ! 25 units of food
player.name = "John Doe"; ! Character is called John Doe
player.class = 0; ! First defined player class
(HUMAN usually)
player.blk = 0; ! First defined character
graphics block.
player.level = 1; ! Level 1
player.exp = 0; ! No experience at all.
player.str and .mstr = *; ! All attributes are as stored in
record 0 of the
player.spd and .mspd = *; ! statistics file, which can be
modified using
player.aim and .maim = *; ! the DCWORLD program.
player.dex and .mdex = *; !
player.iq and .miq = *; !
player.pwr and .mpwr = *; !
player.hp and .mhp = *; !
which you may modify as you please along with the rest of the
character attributes. The character will be positioned over
door 0 in world 0, but you can also change the character's
location from the script.
If the script ends with the 'CONTINUE' keyword, the standard
character creation screen will be invoked, and the user will
have a chance to specify a character name, graphics block,
class, and attributes.
If you modify the character's name, graphics block or class,
the player will not be allowed to change it in the character
creation screen. If you modify an attribute's maximum value
(.mstr, .mspd, .maim, etc) that value will be used as the basis
for character creation.
If you set any value below 9 or above 20, that value will be
'fixed' and the player will not be able to modify it.
The user will only be allowed to choose graphics blocks marked
as type 'REGULAR' in the graphics blocks file. This allows you
to limit the graphics images that the user may choose.
A typical introductory script would look like this:
!
! FILE : initgame.scr
!
readtext( "intro.txt" ); ! Read some text
viewpcx ( "intro2" ); ! Show a nice picture
music ( "intro2" ); ! Play background music
wait ( 120 ); ! Wait until music ends or <SPACE> is
pressed
player.class = ELF; ! Character must be an elf.
player.mpwr = 25; ! Start with 25 power points
player.hp = 20; ! and 20 hit points..
CONTINUE; ! Continue with normal character
creation
Note that the READTEXT command has some voice, music and
graphics capabilities also. The 'intro.txt' file does not
necessarily display a single page of text.
Character Script
Every character in the game MUST have a script to control it's
behavior, except for monsters (type HOSTILE), whose behavior
consists of chasing the player and fighting to the dead.
The world builder assumes that the first 8 characters of the
character TYPE can be used as the name of the character's
script. Thus a BARTENDER's script is BARTENDE.SCR, and a
BEGGAR's script is BEGGAR.SCR.
The system provides 11 predefined character scripts, each of
which has a unique function. A full explanation of each
character 'type' as implemented by the scripts can be found in
the DCGAMES User's Guide.
Usually, a character script handles conversation. When the
player 'talks' to a character, the character takes control of
the conversation by means of the script. A merchant, for
example, asks if you wish to buy or sell something, while a
healer asks if you need to be cured, healed, etc.
Special characters may have their own unique script, as is the
case of JIMMY in the example adventure. That script does a bit
of animation when the character is asked to join the adventurer,
and handles special needs of that character.
You should print out the character scripts and compare each of
them with the description of the character type as given in the
User's Guide. You will then understand how the given script
implements the behavior.
There are three ways of working with character scripts. You can
modify the default scripts to alter the behavior of existing
character types, you can create a brand new character type, with
it's own script, or you can create a unique script for a unique
character.
Object Script
Object scripts are a very different type of animal. First of
all, if an object does not have a script, then the OBJECT script
is invoked. This script can handle all of the standard actions
that you can take on all types and classes of objects. It is by
far the most complex of the predefined scripts.
Every time you create a new object type or even a new class
within an object type, you will need to modify the OBJECT script
to handle the new object. For example, mirrors currently don't
do anything. If you wanted to have a mirror that shows you an
area around you, you could create mirror classes. Class 0 would
be a normal mirror, while class 1 would invoke a 'view' spell.
You can then modify the OBJECT script to check the class
attribute for mirrors and behave accordingly.
Now, if you need to have a given object behave differently, you
need to write a separate script for it. The script does not
need to handle all actions on that object, just the ones that
are different. For example: You want to create a magic ring,
but this ring can cast more than one spell. You could write a
special script that has an entry point (see the programming
guide section) for the WEAR action. When the character wears
the ring, your script might display the image of a genie, and
ask the player what spell is desired. The script would then
perform the appropriate spell.
Remember that if a script does not have an entry point for a
given action, then a default action is taken. In this case, the
default action is to call the OBJECT script. Thus, all actions
would be handled by the OBJECT script except WEAR.
Remember also that if your script ends with CONTINUE instead of
STOP, the default action is taken anyway, so your script doesn't
really have to handle the situation. For example, your 'ring'
may have a 'random' effect (i.e. you never know what is going to
happen when you wear it). To do this, your script would just
set the ring's class (which determines it's magical effect) and
terminate with CONTINUE. The default action would be taken, and
the OBJECT script would handle the actual magical effect!World Script
World scripts are executed whenever you ENTER or EXIT the world.
The default world script, WORLDDEF.SCR, is invoked if your
world does not have it's own script. The world type and other
attributes configured using DCWORLD allow the WORLDDEF script to
handle most normal situations.
World scripts can be very powerful tools to introduce some
amount of 'sequencing' into the game. From within a script you
can change landscaping, doors, etc. You can also examine and
change every single object and character in that world. You
could have a character that exists only after you have performed
a certain action. The world script could check to see if you
have performed that action every time you enter the world, and
create the character only when you have done so.
You can even re-route the player to a different destination
within the same world, or in a totally different one.
Control Script
The control script is the most sensitive script of all. It is
called every 'minute' of game play (as defined in the
MovesPerMinute control variable. This script handles events
that depend on time, such as the creation of random monsters and
the healing of wounds with the passage of time.
The script is also called every time the game player decides to
'rest' his/her party, as well as when a member of the party is
asked to leave the party. These are good opportunities for
control.
If you need to have certain events happen at certain times, you
can modify the control script to check the time and perform
those actions when needed.
Resurrection Script
The resurrection script (RESURECT.SCR) is called whenever all
members of the playing party die. From this script you have the
option to give the player a second chance. Once again, you have
complete control over the situation. You can terminate the
game, give the player the option to restart, restore or quit, or
just restore the player's hit points and continue the game. You
can also transport the party to another location, and perform
some cleanup activities.
Writing Scripts
Script Files
A script can be written using any regular text editor or word
processor. If you use a word processor, you should save the
script in ASCII or TEXT format (with no special controls like
fonts or page formatting). The script file name should have an
extension of .SCR, to indicate it contains a script.
Once the script has been saved, you will use the script compiler
to translate the script from human readable form (text) into a
compact code that the game driver understands. The translated
code is written into a file with the same name as the original
file, but with extension of .SCO (for SCript Object).
For example:
C:\DCGAME> edit myscript.scr
... you create the script using some editor ...
C:\DCGAME> dir myscript.*
Volume in drive C is MYVOLUME
Directory of C:\DCGGAME
MYSCRIPT SCR 1208 10-29-92 1:25p
1 file(s) 1208 bytes
6920192 bytes free
C:\DCGAME> dcc myscript
DCGAMES Script Compiler Version 1.0, April 1992
Copyright (c) 1992 DC Software, 6705 Laramie Dr., Plano, Texas
Compiling Script <myscript.SCR>
Code Size = 179
Data Size = 367
Labels = 25
Compilation successful
C:\DCGAME> dir myscript.*
Volume in drive C is MYVOLUME
Directory of C:\DCGGAME
MYSCRIPT SCO 604 10-29-92 1:28p
MYSCRIPT SCR 1208 10-29-92 1:25p
1 file(s) 1208 bytes
6920192 bytes free
The script MYSCRIPT is now ready to be used in your adventure.
Now, every script must be translated in the above manner
whenever you modify it, or the changes will not be seen by the
game driver. The game driver uses the .SCO file only.
To compile ALL the scripts in your current directory, type:
C:\DCGAME> for %i in (*.scr) do dcc %i
If you are familiar with any programming language at all, the
script language will be quite easy to learn, but even if you
have never learned any programming language, you should be able
to learn how to write scripts without to much trouble.
To assist you, the following section sections try to present the
script language in easy incremental steps, so you may learn at
your own pace.
If you get hopelessly lost, give me a call and I will try to
assist over the phone, but please give it your best shot and try
to have specific questions written down when you call. It will
help keep the phone call as short as possible.
I urge you to annotate this document wherever you see think
something being presented poorly, in the wrong order, or just
plain wrong. This section is the most important one because it
is the one that enables YOU to write your games. Send me a copy
of the pages on which you have made notes and I will gladly
correct the problem and send you back a new copy with
corrections as soon as they are made.
Expressions and Assignments
An expression is a list of one or more symbols that represent a
single value. The symbols may be variables, attributes,
constants, functions or operands. We already know what
variables, attributes and constants are. An operand is a symbol
that tells the computer that an operation should take place.
For example, in the expression 3 * 5 + 2, the * operand tells
the computer to multiply the constants 3 and 5, and the symbol +
tells the computer to add two values together..
In DCGAMES there are 3 types of expressions, arithmetic,
relational.
An arithmetic expression is one which takes numeric values (from
variables, attributes, constant or functions) and performs an
arithmetic operation on them. The arithmetic operands are: *,
/, +, - and % (this last representing a modulo operation, or the
'remainder' portion of an integer division).
A relational expression is one which compares two numerical
expressions and results in a logical value (to be specific, a
relational expression will always result in either a zero or a
one).
A logical value is either zero (meaning FALSE) or non-zero
meaning true.
Expressions are used in many places, but the most common use of
expressions is on the right side of an assignment statement.
The second most common use for expressions is as part of a flow
control statement, such as if or on, which are examined a bit
later.
A function is much like an operand. Just like the * sign takes
two arguments and multiplies them, returning the result as it's
value, so does a function take it's arguments and return a value
based on a well defined process. There are many functions in
DCGAMES. This table is a complete list, but a complete
explanation of each is found in the Script Language Reference
Guide.
Function Table
Function Description
General General purpose functions
abs(expr) Returns the value of the expression without a sign
(removes negative signs)
adjustments(expr,...) Returns the sum of the attribute
adjustments indicated by the expressions
find(where,what,type) Find an object or character
getnum(str,low,high) Display a message and get a value between
low and high from the player.
getstr(str,...) Get a string from the player and return the
index of the matching one.
locate(what) Locate an object or npc character by allowing the
player to point to it.
Time Related Used to control time during game play
MovesPerMinute Number of moves that can be made in one minute
of game play.
MinutesInAnHour Number of minutes in one hour of game play.
HoursInADay Number of hours in a day of game play.
DaysInAMonth Number of days in a month of game play.
MonthsInAYear Number of months in a year of game play.
Year The current year.
Month The current month of the current year.
Day The current day of the current month.
Hour The current hour of the current day.
Minute The current minute of the current hour.
SunRise The hour of the day at which the sun rises
SunSet The hour of the day at which the sun sets
Monster Related Used to create random monsters
DefStat(0-2) Backpacks that contain likely treasure (usually
Potions, Rings and Staffs).
DefPack(0-3) The statistics records for SMALL, MEDIUM, LARGE
and PIRATE monsters.
DefLandBlk(0-4) Graphics blocks for land based monsters
(ordered, 0=Easy,4=Very Hard)
DefCaveBlk(0-4) Graphics blocks for cave dwelling monsters
(ordered)
DefWaterBlk(0-4) Graphics blocks for water dwelling monsters.
(ordered, 4=Pirate Ship)
DefSpookBlk(0-4) Graphics blocks of skeletons, ghosts, etc.
(ordered)
expr represents any expression that results in a numeric value
... means that any number of the preceding may be listed,
separated by commas (up to 255 maximum)
The numeric range (0-N) means that a value in the given range
must be provided when referring to this variable
Examples:
! Increase a player's current level
player.level = player.level + 1;
! When selling an object, increase the group's gold by half the
value of the object.
group.gold = group.gold - player.bp.value / 2;
! Compute the amount of damage done by a weapon, taking into
account the wielder's
! strength (assumes this is not a missile weapon), where
strength is not important.
L25 = npc.weapon.damage + adjustments(npc.str);
! NOTE: Since relational expressions return 0 if false and 1 if
true, the following
! expression returns a value between 0 and 7, which is the
number of attributes
! of the current npc that exceed 25 points.
L7 = npc.str > 25 + npc.aim > 25 + npc.dex > 25 + npc.spd > 25 +
npc.pwr > 25 + npc.iq > 25;
! Change the character's name to "Henry"
player.name = "Henry";
Please note that the last assignment statement assigns a string
value to the name attribute. The name and script attributes may
only hold string values.
Statements
Just like the English language, the script language uses words
and symbols to build sentences or statements which tell the game
driver what to do. A statement is a complete sequence of words
and symbols that tell the game driver how to perform a single
given action.
A complex statement consists of a one or more statements that
are grouped together in some fashion to create a more complex
one. You are already acquainted with the assignment statement,
now let's look at some other ones, grouped by their nature or
intended usage.
Conditional Statements
In most cases, rather than just assign values to variables, what
you want to do is take different action depending on certain
conditions:
! Compute the amount of damage done by a weapon, taking into
account the wielder's
! strength IF the weapon is a contact weapon (i.e. not a missile
weapon).
if npc.weapon.class = BLUNT or npc.weapon.class = EDGED then
L25 = npc.weapon.damage + adjustments(npc.str);
else
L25 = npc.weapon.damage; ! No adjustment for strength
endif;
! The above might also be accomplished as follows
L25 = npc.weapon.damage;
if npc.weapon.class = BLUNT or npc.weapon.class = EDGED then
L25 = L25 + adjustments(npc.str);
endif;
! Now, the following statement displays the current health
status of a player
if player.hp = 0 then
writeln( player.name, " is dead!" );
elsif player.hp = 1 then
writeln( player.name, " is unconscious" );
elsif player.hp < player.mhp
writeln( player.name, " is hurt, but still able to function" );
else
writeln( player.name, " is healthy" );
endif;
Flow Control Statements
Sometimes, the if statement can result in long and difficult to
read statements. In some cases, it is more appropriate to use
one of the various forms of the goto or gosub statements to
accomplish the same goal.
In order to use these statements, you must first declare one or
more labels to which the flow of the execution may be
transferred. The following examples are equivalent.
Flow control using if
:AGAIN
L3 = getstr( "Sell", "Buy", "Talk" );
if L3 = 0 then
! script for selling goes here
elsif L3 = 1 then
! script for buying goes here
elsif L3 = 2 then
! script for talking goes here
else
writeln( "What did you say?" );
endif;
goto AGAIN; ! do it again and again, forever.
Flow control using on-goto
:AGAIN
L3 = getstr( "Sell", "Buy", "Talk" );
on L3 goto XSELL, XBUY, XTALK;
writeln( "What did you say?" );
goto AGAIN;
:XSELL
! script for selling goes here
goto AGAIN;
:XBUY
! script for buying goes here
goto AGAIN;
:XTALK
! script for talking goes here
goto AGAIN;
When a script is large, a single if statement may be several
pages long. It is easy to loose track of what you were trying
to accomplish. The on-goto statement has the advantage of
breaking the logic into separate sections, each self contained
and self explanatory. A more complete analysis of the goto,
gosub, on-goto and on-gosub statements can be found in the
reference guide.
Loop Control Statements
Whenever you need to perform the same operation multiple times,
a loop statement may come in handy. The following code shows a
player giving a copy of everything in his/her backpack to the
npc character:
L6 = 0; ! Start with the first backpack object;
:DOIT
setbp(player.bp, L6); ! Select the Nth backpack object
if player.bp.count then ! If count non-zero, there is an object
copy(player.bp,npc); ! Give a copy of the object
endif;
inc( L6 ); ! Same as L6 = L6 + 1;
if L6 < 16 goto DOIT; ! Repeat 16 times
The above code uses the goto statement to create a loop that
examines the 16 backpack locations for an object and then copies
the objects (if they exist) to the npc.
The while statement
The while statement simplifies loops by providing an easy way of
defining a loop without having to declare a label or writing an
IF statement. Note that the test for L6 < 16 is made before the
statements inside the loop are executed.
L6 = 0;
while L6 < 16 do
setbp( player.bp, L6 );
if player.bp.count then
copy( player.bp, npc );
endif;
inc( L6 );
endwhile;
The for statement
The for statement simplifies the loop even more by allowing you
to specify both the initial value, the final value and the
amount by which the control variable (L6) is to be incremented
(or decremented). Thus, the loop becomes:
for L6 = 0 to 15 do
setbp( player.bp, L6 );
if player.bp.count then
copy( player.bp, npc );
endif;
endfor;
The foreach statement
To top it of, the foreach statement allows you to select in
sequence every element of a group. In this case, the group is
the set of objects in the backpack. The foreach loop is
executed once for each element in the player's backpack. Empty
slots are not even selected, so no test is needed.
Note that if the backpack has NO elements, then the statements
inside the loop not executed. This is the best way of examining
all the elements of a group.
foreach player.bp do
copy( player.bp, npc );
endfor;
The foreach statement can select: a) All the characters in the
player's group, b) All the objects in a character's backpack, c)
All the objects a character is wearing, d) All the character's
in the current world (but not in the player's group) and e) All
the objects in the current world (but not in anyone's backpack).
Object Manipulation Statements
As you saw in the examples above, sometimes you want to move or
copy objects from one place to another.
Move and Copy
When you move an object, it is removed from it's current place
and inserted in the destination, as long as the destination has
enough room for it. If there is not enough room or the
destination character cannot carry the object, the object is not
moved.
The copy statement works the same way, but does not delete the
object from the source, thus making a copy instead of moving the
object.
In both cases, you can specify how many objects you want to
move. The command will move as many as the destination can
possibly hold. If you specify that you want to move or copy
more objects than are available in the source, additional
objects are created.
Drop
When you drop an object, it is added to the list of objects in
the world that you are in. The object will remain where you put
it. There are no temporary objects in DCGAMES.
Output Statements
Write and Writeln
When you want to display a value, you have several ways of doing
it. The most simple one is the write or writeln statement.
With this statement you can display all attributes and variables
as well as text.
The following example displays the time of day in the text
window (assuming that the day has an even number of hours).
if hour < HoursInADay / 2 + 1 then
writeln( "The time is ", Hour, ":", Minute, "am" );
else
L7 = Hour - HoursInADay / 2;
writeln( "The time is ", L7, ":", Minute, "pm" );
endif;
Display
The display statement will show a list of items in the menu
window, with or without numbers or values associated with it.
It is useful when you need to show a list of items but are not
requesting user input. The many forms of the display statement
are documented in the reference guide.
Input Statements
Frequently, when you display something you are asking the player
for directions; During a conversation, you ask the player what
they want to talk about; A merchant might display a list of
items and ask which you want to buy.
Getstr and Getnum
The getstr and getnum functions both return a number. The
getstr function asks the user to type a string and searches the
list of strings you provided. If a match is found, the command
returns the index of the matching string (i.e. which one
matched). If no match is found, the function returns a -1. In
any case, the string is stored in the string variable s0.
The getnum function displays a string and asks the user to enter
a value in a given range. Only values in the range are allowed.
If the user presses Esc instead of typing a number, the
function returns -1.
Select
The select function displays a menu identical to the one
displayed by display, but allows the user to select one of the
entries by using the arrow keys. This function is used
extensively, and you should study it with care in the reference
guide.
Going Places
There are several ways in which characters and objects may move
under script control.
Animation
All characters and any object that is not being carried by a
character has a location within the world reflected by the x and
y attributes of that character or object. From a script you may
modify these attributes and effectively move the characters or
objects within the limits of the world they are in. You can
also change the block attribute to provide some additional
visual feed back (as long as the character is on screen).
A small example of animation is presented in the JIMMY.SCR file
in the example game. When asked to join the party, Jimmy will
walk over to his chest and retrieve his weapons, armor and
money. He will then walk back towards the player and join the
party.
Automatic animation WILL be eventually handled by the system, so
don't go writing animation routines for every character in your
game. This kind of animation should be used in specific
instances where you want things to happen that the user must not
be able to prevent or should not have to do him/herself.
Entering Doors
The player's party may move from one location to another in
several ways. The simplest one is to use the Enter command to
enter a door. The party will be transferred to the world and
destination that the door leads to.
NOTE: The party will NOT be transferred to the new location
until the script finishes execution.
Teleportation
If you wish to transfer the player to a specific world, you may
use the Teleport command. This command allows you to specify a
destination world (by number) as well as either a door in the
destination world through which you wish to enter, or the actual
x and y location at which the party should appear. Thus, a door
need not be present in the destination world.
Advanced Topics
Entry Points
Whenever a script is invoked, execution of the script will begin
at a special label which is called an Entry Point. The entry
points are labels of the form :@# where # is a number between 0
and 20, but, to make life easier, the labels have specific names
associated with them, which make it easier to remember them.
The entry points and the names associated with them are
different for each type of script, and are shown below: You
should use the name form of the entry points unless you have a
very good reason for using the numbers.
For Character Scripts
@TALK (0) - Talk to the character
@DROP (2) - Character is being asked to leave the party
@CAST (11) - Character will try to cast a given spell.
For Object Scripts
@TALK (0) - Talk to an object.
@GET (1) - Move an object into the player's backpack.
@DROP (2) - Drop an object being carried.
@WEAR (3) - Wear an object.
@REMOVE (4) - Remove an object being worn.
@LOOK (5) - Look at an object.
@EXAMINE (6) - Examine an object carefully.
@INVOKE (7) - Invoke the magic in a magical object (ring,
amulet, etc)
@USE (9) - Use a generic object for whatever purpose it is
intended.
@EXIT (10) - The player's party wants to get out of a vehicle.
For World Scripts
@ENTER (9) - The player's party is entering the current world
@EXIT (10) - The player's party is leaving the current world
For Control Scripts
n/a (0) - Time Control Entry Point.
n/a (1) - Party wants to rest for the night.
n/a (2) - A member of the party wants to leave the group.
For Magic Spells
@CAST (11) - A magic user has casts a spell.
For Game Initialization
n/a (0) - Invoked at game initialization
For Dead and Resurrection
n/a (0) - Invoked when everyone in the party dies.
Calling A DOS program
From within a script, you may execute a DOS program by using the
system command. This command works exactly like the writeln
command, except that instead of sending a line of text to the
text window, the text is formed into an MS-DOS command and
executed. When the command ends execution, the MS-DOS error
level is stored in the failure variable. A value of 0 usually
indicates success.
See the reference guide entry for additional information.
Creating New Types and Classes
When the current types and classes of characters, objects or
worlds is not enough, you may create your own types and classes
as needed. The procedure for doing this is highlighted here,
the assumption is made that you have read the manuals and are
familiar with the script language before you attempt to add a
new type or class.
New Character Types
To create a new character type, you should edit the file
DCCTOKEN.DAT, look for the section [CHARACTER TYPES and add an
entry after the last character type in the file:
[CHARACTER TYPES]
REGULAR 0 ! REGULAR.SCR - Will join the party if asked
to..
HOSTILE 1 ! HOSTILE.SCR - Will attack on sight and
follow you..
MERCHANT 2 ! MERCHANT.SCR - Buys and Sells stuff..
BARTENDER 3 ! BARTENDE.SCR - Sells beer. Good source of
information.
HEALER 4 ! HEALER.SCR - Cure, Heal, Resurrect, Remove
Curse,..
CIVILIAN 5 ! CIVILIAN.SCR - Will talk, but won't join..
TELLER 6 ! TELLER.SCR - Fortune Teller or Oracle
type..
QUESTER 7 ! QUESTER.SCR - Asks you to find an object or
person.
BEGGAR 8 ! BEGGAR.SCR - Want's money. Might give you
a tip.
TRAINER 9 ! TRAINER.SCR - Will train someone
(STR,DEX,AIM,IQ)
GUARD 10 ! GUARD.SCR - Blocks your way unless given
the password.
PRISONER 11 ! PRISONER.SCR - Will join your party
temporarily (to escape).
LAWYER 12
In the above segment, the new character type LAWYER has number
12 assigned to it (the next available number). You may now
write a script file called LAWYER.SCR to handle the default
behaviour of lawyers.
New Character Classes
Character classes in the current implementation apply only to
characters that join the party. The class of the character is
used to determine what kind of weapons and armor they can use,
what kind of magic they have, how fast they recover, etc.
To create a new character class, just edit the DCCTOKEN.DAT file
and add the new class to the [CHARACTER CLASSES] section:
[CHARACTER CLASSES]
HUMAN 0 ! standard stuff, no power
ELF 1 ! fast, magical power, not strong
DWARF 2 ! slow, STRONG, no magic, no missiles or
shields
WIZARD 3 ! slow, lot's of magic, not strong
ARCHER 4 ! fast, no magic, + on missile weapons
FIGHTER 5 ! fast, strong, no magic of any kind
THIEF 6
In the above segment, the new character class THIEF has a number
6 (next available one).
The DCBLOCK, DCWORLD, DCPLAY and DCREPORT programs will now
recognize thieves as a valid character type.
You may also want to modify the OBJECT and CASTING scripts to
give a thief certain advantages when dealing with traps, and to
enable or restrict the kinds of weapons, magic, etc, that the
character can handle.
New Object Types
Creating a new object type is again started by adding the new
type to the DCCTOKEN.DAT file. The section [OBJECT TYPES]
contains the names and numbers for all object types.
Unlike characters, a single script handles all object types and
classes. The OBJECT script should be extended to handle the new
object type for all it's entry points.
The object types Food, Weapon, Armor, Shield, Amulet, Ring and
Staff have special treatment because they can be worn by the
characters. The Vehicle object type also has special handling
because it can be used for transportation. Other than these
special handling, you can modify the OBJECT script file as much
as you want.
New Object Classes
An object class is also represented by a section in the
DCCTOKEN.DAT file. It is different from other sections in that
multiple object types may have the same class (for example:
rings, amulets, food, potions and gems all have the same class
set).
If your new object is going to have the same set of class items
that already exists for another type, just add the name to the
list, for example:
!
! Magical Effects, Type 1
!
[OBJECT CLASS: FOOD, POTION, RING, AMULET, GEMS, WIDGET]
NONE 0 ! No magical effect
CURE 1 ! Remove POISON
HEAL 2 ! Restore some HP
POISON 3 ! (Trap) POISON drinker
RESTORE 4 ! Restore ALL HP
PLUS_STR 5 ! Increase STRENGTH
PLUS_DEX 6 ! Increase DEXTERITY
PLUS_SPD 7 ! Increase SPEED
PLUS_AIM 8 ! Increase AIM
PLUS_AC 9 ! Increase AC
PLUS_HP 10 ! Increase HP
PLUS_IQ 11 ! Increase IQ
PLUS_PWR 12 ! Increase POWER
Here, we have added the new object type WIDGET to the set of
objects that have personal magic.
You still have to modify the OBJECT script to handle the
object's class. For example,
on object.type goto
USE_FOOD, USE_WEAPON, USE_AMMO, USE_ARMOR, USE_SHIELD,
USE_AMULET, USE_RING, USE_POTION, USE_SCROLL, USE_STAFF,
USE_CHEST, USE_KEYS, USE_GEMS, USE_BOOK, USE_GOLDSACK,
USE_TORCH, USE_LANTERN, USE_ROPE, USE_HOOKS, USE_MIRROR,
USE_SIGN, USE_VEHICLE, USE_WIDGET;
.
.
.
:USE_AMULET
:USE_RING
:USE_ARMOR
:USE_WEAPON
:USE_SHIELD
:USE_STAFF
writeln( "You must first 'get' it, then 'wear' or 'wield' it.." );
STOP;
:USE_WIDGET
writeln( "If you want to use it, you must first 'get' it.." );
STOP;
.
.
Here, we have decided that a WIDGET must be in the player's
backpack before it can be used.
If your new object is different from all other objects, you can
create a brand new section for it's classes in the DCCTOKEN.DAT
file:
!
! My WIDGET object classes
!
[OBJECT CLASS: widget]
ROUND 0 ! A round widget
SQUARE 1 ! A square widget
OVAL 2 ! An oval widget
At this point, you may create graphics blocks with type widget
and class round, square or oval. You may also write script code
like this:
if object.type = widget then
on object.class goto XROUND, XSQUARE, XOVAL;
writeln( "Unknown widget class.." );
stop;
endif;
:XROUND ! Handle a round widget
....
STOP;
:XSQUARE ! Handle a square widget
....
STOP;
:XOVAL ! Handle an oval widget
....
STOP;
New Object Modifiers
Each object has 5 attributes that can be used to implement it's
differences from other objects. These attributes have names m0
through m4, but the object modifiers section in the DCCTOKEN.DAT
file allows you to call them by other names.
When you create a new object type and/or class, you may want to
create new names for those fields that you might use to
differentiate between them For example:
[OBJECT MODIFIERS]
! Object Type: FOOD
! 0 Is not used
UNITS 1 ! If magical, how many units are affected
PERMANENT 2 ! If magical, how long does effect last? (0=one day, 1=permanent)
! 3 Is not used
! 4 Is not used
! Object Type: WEAPON
HANDS 0 ! # of hands needed to use the weapon
RANGE 1 ! Range of this weapon
DAMAGE 2 ! Damage done when using this weapon.
AMMONEEDED 3 ! Type of ammunition needed (See AMMOTYPE below..)
! 4 Is not used
! Object Type: WIDGET
SIDES 0 ! # of sides that the widget has
RANGE 1 ! Range of this widget
Note that if you want to use a token that already has a value
assigned, like range in the example, which has a value 1
assigned for weapons, you MUST use the same value for the token.
Tokens are replaced by their numeric value during compilation,
so the following two lines are equivalent:
if object.hands = 7 then ...
if object.sides = 7 then ...
Both lines are comparing the m0 modifier of the object with the
value 7. The type of the object is not checked to see that the
token you are using belongs to the object's type.
New World Types
Perhaps the easiest to create would be a new world type. Again,
just add the entry to the DCCTOKEN.DAT file, section world
types, and then edit the WORLDDEF script file to handle the new
world type.
Note that many of the currently defined world types have no
actual differences between them. For example, Cities, Towns,
Hideouts, Houses and Castles are all the same.. You can change
that by modifying the appropriate scripts.
For example: If you want to make opening a locked chest a crime
in Castles and Houses, you can add a check in the OBJECT script
to verify the type of world you are in when the character tries
to break a lock.
Shareware Opportunities
While most users will use the script language to make small
changes to the game system, with a few customized scripts to
handle special characters or objects, the true power of scripts
lies in the ability to completely change the way everything
works. Here are a few example of some more complex projects
that you may want to attempt once you are comfortable writing
scripts:
Extending the magic system
The current magic system allows a character to cast a spell if
it has the required number of power points. There is no
requirement to learn the spells, or to be at a certain level
before you can cast it. You can change the OBJECT and CASTING
scripts to handle a magic book, which can be either a class of
book (currently, books don't have classes) or a whole new type
of object (Magic Book).
You can also change the scripts to handle a lot more spells (up
to 255 of each type), or add a level requirement for each spell.
MS-DOS based extensions
The system command allows you to run DOS programs from within a
script. The following DOS programs could be called from a
script to extend the functionality of the system. Writing these
extensions requires knowledge about internal structures of the
game files, which I will be glad to provide on a case by case
basis.
Save/Restore/Restart
Replace the prompts that perform this function with a window
that shows saved games along with comments and let's you choose
which one you want to restore, or lets you specify which slot
you want to save in, and what comment you want to associate with
the saved game.
Character Editor
Allows you to examine/modify (i.e. cheat) the PARTY file.
Arcade/Casino extensions
A completely separate sub-game that is executed when you enter a
world. For example, when you enter a casino, you can run a DOS
game that allows the user to play poker or some other games in
order to make money. The program may read the PARTY file to get
the names of the characters and the amount of gold they have.
It would update the gold amount when the characters leave the
casino.
Stand Alone Utilities
A nice utility would be one that can take the game and create
PCX graphics files for each world, optionally including the
objects and characters that appear in it. The PCX file can then
be scaled and manipulated by other utilities to print maps or
include the graphics in documentation.
Writing a whole new system
It is perfectly feasible to take the rules, character types,
magic system, etc of game systems such as Dungeons and Dragonstm
or Man, Myth and Magictm and write them as scripts. You would
have to throw away all of the current scripts and write them
from scratch, but it's perfectly feasible. Of course, these
systems are copyrighted by their respective publishers, so it
wouldn't be possible to distribute such a system as shareware (I
think, but I'm not a copyright expert).