Action Widgets

Events happening in the community are now at Drupal community events on www.drupal.org.
aaron's picture

(Crossposted at Drupal RPG. Thanks to Litwol for the inspiration!)

Borrowing from CCK, RPG Administrators will be able to create and extend RPG Types using forms in admin screens. Additionally, modules and include files may be used to predefine certain types, which may further be modified in the screens. Finally, types may be exported and imported between sites.

RPG Objects may be of one or more types. Each type may further inherit from one or more other types. Types may define Attributes and Actions. An Attribute is simply a numeric or text value that will be stored with a specific object and may be manipulated in the game by the results of certain actions.

An Action is a function created on screen or programatically that is attached to a specific type, and may be invoked by several methods, including clicking a link for an action, being invoked within another action, or called with a direct function call.

Attributes

When creating an Attribute for a type, the admin may also define a default value for the attribute for that type, which may be overridden by a child type. For instance, the admin might set a default Strength of 0 for Actors, and Humans, descending from the Actor type, would also inherit the Strength Attribute. Then Orcs might have an overridden default of 3, which in effect gives a +3 modifier to Strength when creating an orcish character (to which character points would be added).

The basic defined attributes are 'integer' and 'string'. Additional types of attributes may be defined by modules, using hook_rpg_attribute_types. When an attribute is created and attached to a type, a new database table will be created to store that attribute, similar to CCK. (TODO: Currently, it's all stored as a serialized array in the 'data' column of {rpg}. I need to decide the best way to store and retrieve this in the future. I also want to consider caching objects, resetting the cache on rpg_save_all_marked_objects -- however, though some objects may rarely change, others may change constantly. Perhaps each rpg type needs to determine cachability.)

Integer Attributes store a default value, and optional min/max values. String Attributes store default, min/max (in relation to character length), and filters. If no filter is specified, text values will be displayed using check_plain. Attributes attached to an object type may be overridden by later types.

Methods

Methods are performed by actions, usually to set or modify an attribute, or to trigger another action or event. When selecting a method from an Action creation or editing form, you will first selct the type, and then select specific options. Alternatively, you may select a php block, which will be evaluated when running the method within an action.

As an example, you may set a method to modify the target's health by -3d6 (as part of an action when attacking with a sword), or to spawn a new object. There are several predefined method types, such as 'modify attribute', 'set attribute', 'create object', 'spawn object', 'invoke new action', and 'php block'. Further, new method types may be created using hook_rpg_method_types.

Decisions

A decision is the UI version of an if/then/else statement, to direct the flow of an action. Decisions are nearly always based on comparing an attribute to either another attribute, a set value, or a random range (specified by random dice notation, such as 3d6 or 4d8+2). Alternatively, a php block may be specified for a decision, which will be based on whether the block evaluates to true or false. Within the UI, Decisions may specify different branches of methods or decisions based on whether the decision returns true or false, and may nest other decisions.

Modifiers

Modifiers may be attached to any attribute. Modifiers have a duration specified, and modify an attribute by a value set at the time of invoking the action (which may be a set value or a set range, or set to a variable range, which will modify the attribute by a checked random value each round). A modifier may also optionally specify a new action to be invoked upon destruction of the modifier.

Actions

Actions generally combine these elements. Putting it all together, an example action might be 'drink potion'. When someone holds the potion, the action will be exposed to that character. If they click the link, the action will be invoked. This action will check the decision of 1d10. If the result of the decision is greater than one, the action will attach a modifier to the character's strength. The modifier adds a set value of 2d4 to the character's strength, and will disappear in five minutes. If the result of the decision equals one, the action ends. In either case, a message is displayed to the character with the results of the action, and to observers noting that the character drank the potion.

Comments

Great stuff. i cant wait to

litwol's picture

Great stuff. i cant wait to see further designs.


------------------
Sometimes interesting things appears on http://litwol.com

Access Checks

aaron's picture

Available Actions will be checked for when in the same top-level room as the PC. In
addition, an individual Action may define its Access in relation to the PC. (In reality,
the same checks are made against NPC's, although they are called in a different place.)
Access checks are defined in the same manner as Decisions. If an Access check returns
true, the action will be listed with available actions. Furthermore, when an Action is
invoked, its Access will be checked against the calling character before running.

Aaron Winborn
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes

Aaron Winborn
Drupal Multimedia (my book, available now!)
AaronWinborn.com
Advomatic

Games

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week