Programming with the Scourge Object Model (SOM)
The game Scourge exposes its object structure to be manipulated by squirrel scripts.
These web pages describe these objects and their methods. Before diving into writing
scripts, it is important to understand how SOM objects are created and what is possible
to change via scripting. If there is functionality you whish were added to the SOM,
please send me an email.
Overview
All scourge game objects are created by the game engine in order to simplify object life-cycle
management. You should never have to create a new instance of a class.
The main object you control scourge with is called scourgeGame.
It is created when the game is started. Almost all aspects of the SOM start from this class.
For example in script you could write:
print( "version=" + scourgeGame.getVersion() + "\n" );
To print the version of Scourge you're using. The scourgeGame
object contains the current mission, its creatures,
items, etc.
Script files
Currently, script files are loaded from the following locations:
- /data/world/skills.nut
- /data/world/map.nut
Script files are reloaded automatically by the game every 5 game minutes. Alternatively,
you can open the squirrel command prompt and type:
scourgeGame.reloadNuts();
to accomplish the same thing.
skills.nut
The skills (capabilities) themselves are described in the skills.txt file in the same directory.
For each capability, there are two squirrel functions that will be called: one for a prerequisite check
and one for the capabilitie's action. So for example, for the capability "Superior Toughness",
prereqSuperTough(creature) returns a boolean value to represent if the creature (parameter to function)
meets the prerequisites for this capability. actionSuperTough(creature) is called when the creature (parameter
to function) needs to defend itself against an attack. The armor value of the player is placed
in the global variable "armor" and this function can change that value as needed.
(See Special global variables.)
map.nut
Functions in this file are called as special event handlers, relating to the life-cycle and interactivity of
a mission's map.
- enterMap( mapName ) is called when the party enters a new map.
- exitMap( mapName ) is called when the party leaves a map.
- usePool( x, y, z ) is called when the player clicks on a healing pool.
Utilities
It is possible to save game state information between sessions by using the getValue(), setValue() and
eraseValue() methods of the scourgeGame object. Values placed in
this map are automatically saved and loaded by the game. For example the capability "Natural Healing"
can only be used twice a day. To ensure this criteria, the value map is used via the utility function incrementDailyCount()
in skills.nut. Be careful when using the value map, esp. with regard to time, as you don't want to save
new values for every time instance. Take a look at incrementDailyCount() for the correct usage.
Special global variables
Information in this section is likely to change.
For automatic capabilities such as offensive and defensive modifier skills (e.g.: Missile Defense)
special global variables are created to show the current value of the creature's "armor" (for defensive modifiers) and "damage" to be done in combat (for offensive modifiers).
The action function of the capability can modify this value to increase or reduce it. These special
global variables are only available while the action function of the capability is being called.
Take a look at actionSuperTough(creature) in skills.nut as an example.
Resources
The Scourge homepage
The squirrel language reference manual