| 1 |
// $Id:$
|
| 2 |
|
| 3 |
RPG
|
| 4 |
|
| 5 |
This module provides a base for creating an online role-playing game, at its
|
| 6 |
basic similar in nature to Lord of the Red Dragon or Urban Dead, but as
|
| 7 |
development progresses, able to handle increasingly complex games including
|
| 8 |
graphics and jquery. Being integrated with Drupal, it will allow administrators
|
| 9 |
to fully utilize other features of Drupal, integrating forums, organic groups,
|
| 10 |
and more with the RPG.
|
| 11 |
|
| 12 |
NOTE: This engine is still in development. Not only does it not do anything at
|
| 13 |
the moment (besides the admin screens), it is likely to change drastically as
|
| 14 |
time goes on.
|
| 15 |
|
| 16 |
IMPORTANT: Go to DrupalRPG.org and the Drupal Games and Game APIs group page
|
| 17 |
for ongoing discussions and plans concerning the progress of this module.
|
| 18 |
|
| 19 |
RPG
|
| 20 |
|
| 21 |
Created by Aaron Winborn
|
| 22 |
aaron at advomatic dot com
|
| 23 |
Begun 6 December 2006
|
| 24 |
Rewrite of engine 12 April 2007
|
| 25 |
Begun support for rulesets 18 August 2007
|
| 26 |
|
| 27 |
The engine itself does little more than provide a core to build a game with.
|
| 28 |
Although it is intended to be for online RPG's, there is no reason the base
|
| 29 |
couldn't be expanded to create other types of games, such as Turn-Based
|
| 30 |
Strategy games, RTS games, or even slidescrollers. The engine is able to do
|
| 31 |
this by providing basic functionality for administrators to create, use, and
|
| 32 |
share 'rulesets'.
|
| 33 |
|
| 34 |
Rulesets are definitions of the Types, Attributes, and Actions used to create
|
| 35 |
in-game objects. They may be created in forms available to game administrators,
|
| 36 |
and may also be imported/exported from forms or even files. RPG Object Types
|
| 37 |
follow inheritance rules, and may even include multiple parents, allowing types
|
| 38 |
to share and even override attributes and actions.
|
| 39 |
|
| 40 |
Types
|
| 41 |
|
| 42 |
All in-game objects are derived from an RPG type. Types include anything from an
|
| 43 |
abstract 'tangible' object, to a 'weapon' that 'swords' or 'hammers' inherit, to
|
| 44 |
an 'orc' that could be used as an NPC or a user's PC. Types follow inheritance
|
| 45 |
rules, so for instance, you might have tangible -> weapon -> sword -> flaming
|
| 46 |
sword, or something more complex where in addition to the 'sword' that 'flaming
|
| 47 |
sword' derives from, it might have an additional parent of 'magical item', so that
|
| 48 |
it inherits attributes and actions from both types, and so on down the line.
|
| 49 |
|
| 50 |
Types will inherit the Attributes and Actions of all its parents (and their parents,
|
| 51 |
etc.). In addition to defining new Attributes and Actions, they may override any from
|
| 52 |
their parent types. For instance, the aforementioned magic sword might inherit the
|
| 53 |
action 'take sword' from the 'tangible' type, the action 'swing sword at $target'
|
| 54 |
from 'weapon', and 'charge sword mana' from 'magical item'. It might furthermore
|
| 55 |
override the 'charge sword mana', which might normally allow charging by any wizard,
|
| 56 |
to only allow charging by a wizard with a weaponsmith skill.
|
| 57 |
|
| 58 |
Types may be defined and modified from various admin screens, available from
|
| 59 |
/admin/rpg/types.
|
| 60 |
|
| 61 |
Attributes
|
| 62 |
|
| 63 |
Most RPG object types will define and/or inherit attributes. Attributes will be stored
|
| 64 |
for individual objects, so that each object will (usually) have its own unique values
|
| 65 |
for the attributes defined by its type.
|
| 66 |
|
| 67 |
Attributes will be one of several 'classes'. Several classes come with the RPG module,
|
| 68 |
and others may be defined by other contributed or custom modules. The attributes
|
| 69 |
shipped with the module include 'text', 'number', 'boolean', 'object array', 'figured',
|
| 70 |
'sprite', 'node', 'view' and 'link'.
|
| 71 |
|
| 72 |
The text, number, and boolean attributes are what they sound like. Text attributes
|
| 73 |
will store unique text for the object, such as a name, description, or message to be
|
| 74 |
displayed when the object explodes. Number attributes currently only store integers.
|
| 75 |
Booleans are simple true or false values, set by a checkbox in the admin screens.
|
| 76 |
Object arrays will store an array of rpg objects, and are useful for such things as
|
| 77 |
a list of items contained within a chest, or a list of wizards who have read a
|
| 78 |
certain scroll.
|
| 79 |
|
| 80 |
Figured attributes may not be set for an individual object, but rather are figured
|
| 81 |
on the fly. For instance, 'mobile actors' might have 'max hit points' that are
|
| 82 |
figured by a combination of 'class', 'race', 'health', and 'level'. They are
|
| 83 |
defined as a snippet of php code that will be evaluated as needed.
|
| 84 |
|
| 85 |
In actuality, any attribute may make use of this code; for instance, when setting
|
| 86 |
'location', the snippet might also ensure that an object is removed from it's old
|
| 87 |
location's 'contents', and added to the new. However, the technical difference
|
| 88 |
with figured attributes is that they do not store a value in the database. For
|
| 89 |
those technically minded, there are three php snippets available to all attributes:
|
| 90 |
'get', 'verify', and 'set'. When present in a type, 'get' is evaluated before an
|
| 91 |
attribute's value is called for an object, 'verify' just before setting the value
|
| 92 |
(which will fail if it returns false, thus not setting the new value), and 'set',
|
| 93 |
which is called just before setting the new value (and if provided, the new value
|
| 94 |
will be set to the number returned by that snippet).
|
| 95 |
|
| 96 |
Continuing through the attribute classes, 'sprites' are images (or other files,
|
| 97 |
such as animated gifs or embedded flash objects) that may be displayed as needed.
|
| 98 |
For instance, chests might have a static image, potions might have an animated
|
| 99 |
gif, and orcs might have animated gifs that change direction as the orc moves in
|
| 100 |
a certain direction.
|
| 101 |
|
| 102 |
'Node' classed attributes reference Drupal nodes. This might be used to embed a
|
| 103 |
link to a group page for assassins, to display a news item teaser, to show an ad
|
| 104 |
for a book sold by the site, or many other creative uses. Likewise, 'view'
|
| 105 |
attributes reference a View on the site, assuming the Views module is installed.
|
| 106 |
Finally, 'link' is any URL, internal or external, for similar purposes.
|
| 107 |
|
| 108 |
Actions
|
| 109 |
|
| 110 |
Actions are used to affect the game state of objects. They may be called by players
|
| 111 |
on the site, or internally by other actions, depending on their definition.
|
| 112 |
|
| 113 |
For instance, our flaming sword type might inherit an action of 'take sword'. This
|
| 114 |
action would first check that the sword may be taken by the player, which is a
|
| 115 |
figured attribute called 'may_take' (which in turn examines 'moveable' and makes
|
| 116 |
certain the object is in the same room as the player). Assuming this check passes,
|
| 117 |
the sword is moved to the player's inventory.
|
| 118 |
|
| 119 |
Another action might be 'wield sword', which by default might simply set the
|
| 120 |
'wielded' attribute to true, assuming it's in the player's inventory. However, the
|
| 121 |
flaming sword might override this behavior, so that if a player is an orc, the
|
| 122 |
player might be damaged when grasping its hilt.
|
| 123 |
|
| 124 |
Objects
|
| 125 |
|
| 126 |
In code, objects are always referenced by their id, and never directly. Functions
|
| 127 |
are provided for this, such as rpg_get($object, $attribute) and rpg_set($object,
|
| 128 |
$attribute, $value). This is particularly important with setting attributes -- this
|
| 129 |
ensures the new value will be saved to the database.
|
| 130 |
|
| 131 |
Meta Game
|
| 132 |
|
| 133 |
Rulesets may also define their own meta game values. This includes how often a
|
| 134 |
turn takes place, how many 'action points' are available to characters, how many
|
| 135 |
characters a player may use, what the weather is like, etc. As with every other
|
| 136 |
aspect of the RPG module, these values may be changed from various admin forms and
|
| 137 |
by importing/exporting rulesets.
|
| 138 |
|
| 139 |
Drudge Ruleset
|
| 140 |
|
| 141 |
The RPG currently is shipped with the Drudge ruleset. This is a generic ruleset,
|
| 142 |
defining some basic object types, skills, and simple actions. It is meant to be
|
| 143 |
built upon for an individual game's flavor, but is also meant to be robust enough
|
| 144 |
to be meaningful with little modification.
|
| 145 |
|
| 146 |
Other rulesets may be available in the future. Admins are encouraged to contribute
|
| 147 |
their own rulesets. Please see the discussions at DrupalRPG.org and the Drupal Games
|
| 148 |
and Game APIs group page for more information.
|