RPG Module in Development

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

I've been working for a couple of months on the RPG module, which will be an engine for building web based rpg games, similar to Lord of the Red Dragon and Urban Dead. Although it borrows some ideas from the Game module (such as loading include files as object types), it is written from a different direction, and has different goals in mind. Once matured, the engine will be easily customizable by site admins (using form interfaces), requiring no php knowledge to implement, but allowing fairly easy expansion with some php knowledge.

Nearly everything in the game will be an object, which may be derived from one or more object types (each of which may have one or more parent types). For instance, a player character may have 'Human' and 'Wizard' for its types, which will inherit properties and functions from their parent types (which might be 'Classed Actor' -> 'Actor' -> 'Tangible Object' and 'Race' -> 'Actor' -> 'Tangible Object' respectively). Likewise, a sword might have a simpler inheritance of 'Sword' -> 'Weapon' -> 'Tangible Object'.

Events in the game are created by Actions, which might be invoked from a clicked link or from other actions. When an action is invoked, it will branch through the object inheritance tree for resolution. For instance, a player might click on a link that says 'Attack Goblin with Sword', and the action will be called through the various types accordingly (in this case, the call would be rpg_invoke('attack', $pc, $goblin, $sword), and the function would call the defined rpg_TYPE_attack function in each include file (rpg_actor_attack, etc.). rpg_actor_attack would likewise call the rpg_weapon_attack_with hook and maybe the rpg_actor_defend and/or rpg_actor_damage functions for the goblin. I know this sounds confusing, but hopefully it will be more clear with better examples, and should be easily customizable and scalable in the future.

I'm planning for the system to use 'Action Points', allotting a configurable number of action points that an individual character may use during a day. Also, it will use 'Game Turns', again configurable, so a player might, for instance, only be able to take an action once every five seconds (for things like pvp combat, another configurable option). I have some of this code written, but not yet in the repository.

I've begun writing a function (rpg_t) that extends the t() function, to allow intelligent string substitution in the system. So you can write a message like '!You swing!s !the_dobj at the !the_iobj.', which would be substituted as 'You swing the sword at Sponge Bob,' 'The Green Knight swings the sword at you,' and 'The Green Knight swings the sword at Sponge Bob', according to the observer. (Or if the sword were actually an intelligence controlled by a human player, they might even see 'The Green Knight swings you at Sponge Bob.')

My main concerns at this point are: 1) I want the system to be flexible and easily customizable. 2) I want objects to inherit functionality. 3) I want the system to run at a reasonable speed, so it can handle a reasonable server load.

1) isn't a problem using what's in place.

2) works, although not perfectly -- I want to honor the Drupal specification of not using classes, which makes inheritance tricky, of course. I've go something working, and results can be passed through the system of hooks, but it gets trickier when you want to do things like modify or replace displayed messages. I'll expand on that in another post (probably next week).

3) This is where I'm nervous, and I won't personally know until I develop it further and put it through the works (and maybe run some Devel query tests as a start). I'm doing things like caching types and inheritance order to help this along, and would appreciate more minds looking into the code and seeing how else things can be optimized, keeping the other two priorities in mind.

Well, that's all for now. Let me know your thoughts, or if you want to help with the project!

Aaron Winborn

Spindowners - An online, text-based, sci-fi rpg being developed in Drupal using the RPG module.

Games

Group organizers

Group notifications

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