I really liked the way this skill system is turning out and I figured anyone looking to make some sort of RPG could really benefit from it. While technically, the whole project is a WIP (and threfore this skills system is too), it is only a particular section of our overall code, so I figured the snippets would be a good board for it to go in.
The premise is that writing code for skills can be quite a daunting task. If you want 100 skills in your RPG, you may try writing 100 functions to handle them all. This skills system cuts that work down considerably by using a parser system. Only Skill categories are hard coded into functions. Within each category, each skill can be detailed out using the parser script arguments, which allows for quite a lot of fexibility within the category.
I've included some sample code, sample skills, and sample Characteristic "skills", Attack skills, and Damage skills. The specific skill functions are set up for a test text environment, but can easily be converted for 3D game applications (all the actual, non-demo, skill functions are just data and logic management - no real user "output").
In the demo, I've included:
_ Two Characterisitics: Strength & Agilty
_ Two Attack Skills: Basic Attack & Fencing Attack
_ Two Damage Skills: Basic Damage & Fencing Damage
Characateristic do not have any true functionality as skills, but simply act as "Parent" skills for other skills to be based on. In the example, Basic Attack uses Strength as a 'parent skill', which adds to the attack total. Fencing Attack uses Agility as its 'parent skill'.
The Attack Skills can be activted by the user by pressing the key bindings (left [Ctrl] for Basic Attack, and [F] for the Fencing Attack). Deactive a skill by pressing [Shift] + the bound key.
The Damage Skills are not skills that can be activted by the user (like Characteristics). Instead, the Damage Skills are called at the completion of an Attack Skill. So each Attack Skill can call its own specific Damage Skill.
So, how would someone use this? Well first, there are two levels of use. There is a sort of administrative level of use, which is simply to write each skill's argument list to create new skills within each category. Then there is the coder's level of use. The coder would write the specific functions for each category of skill. For example, the coder would write the Craft Skills category function. Then the administrator would write the specific Crafting Skills following the argument structure for Craft Skills.
All the coder really needs to do is use the Skills functions like any DBPro commands to write the category functions. All the dirty work has been done already.
For coders:
There are two levels for skills in the skill code (not the specific skill code): Base Skills (array = Skill() as Skills) and Active Skills (array = ActiveSkill() as ActiveSkills). Skills hold all the base loaded data from the Arguments. Active Skills simply act as references to indicate the base skill is Active (in play). The active array also tracks timing information, such as Delay, Decay, and Reset. Each Skill can also have an unlimited number of assigned Integers, Floats, or Strings. These can be used effectively for any additional information a skill may require. For example: a craft skill that produces an object once it is complete can use these variables to store the object information (maybe a base object number, or a file name).
The only remaining concept to understand is that the specific skill functions are set up for this demo, and not for an actual game. In an actual game, the specific skills functions should be written to do as much of the work as is possible. For example: The Attack Skills function will be modified to actually compare the Attack Total to the Target's defense. Only if the Attack Total exceeds the target's defense will the Damage Skill be called. The Damage Skill will simply deduct the damage directly from the target's health. Any special effects and animations will also be handled by these functions as well.
There are also a lot of protections (and redundant protections) involved when calling these functions, so the code is hard to break (not that it can't be - this isn't a challenge). If you call most functions with an invalid reference, the function will likely return a 'null' response (commonly 0 or -1).
The generic_functions file is just our project global use generic functions. There are a few functions I used for the skills code from that file, so I included the whole thing. Feel free to use those other functions as well.
============================================
I have put a lot of hard work into this code. Feedback and suggestions are more than welcome as I want that work to "pay off". Please try to write your own skills (either parser arguments for the existing skill categories or new catagories). Let me know what works and what doesn't work. Ask questions (related to the code) - I will happy to answer if I can. Thanks in advance!
And remember - it is all Open Source, so feel free to use and abuse it.
Open MMORPG: It's your game!