[design] RPG Skills Framework
Edit: This topic is old. I have posted the mod onto git and the WIP mod section (or later in the release section hopefully). Please go here to discuses the mod. viewtopic.php?f=9&t=11406
Hello, I've been working on a RPG skills framework mod that implements two skill systems(described later). Since it is a framework I would like feedback on the general idea and API. Also a name would be good since at the moment I can only think of SkillFramework. (I'm not good with names :P) It may be slightly based on AdventureTest's skills because I looked though the code to see how skills were used in actions.
Below I will try to briefly explain the concept by taking snippets from my design doc. Full markdown doc (as of this post) is available at this gist.
Skill Sets
Skill sets are created and "attached" to identifiers. A skill set can therefore be used to describe a group, like level 1 skeletons, or individuals, like the player. Each skill set contains information for every registered skill.
Skill Systems
I currently have two skill systems, but this may change later especially if I get some feedback on it.
Using Skills
An action is said to occur whenever SkillsFramework.trySkill(entity, skill, test_func) is called. This will usually be called in a register_on_punchnode or register_on_craft, but would probably be useful in any "on something" registration function. The test_func returns a number which is the amount of experience that will be added to the skill(or character experience bar). The try skill function will then return the same number to it's caller allowing for further processing(i.e. adding special meta data to a crafted item).
Using Multiple Skills
If an action requires several skill checks, a modder could do two things. He could call them in parallel in the "on something" registration function and then combined the results to determine the action effect. If the success of one skill depends on the success of another, he could also chain trySkill calls with in a trySkill test function.
Example of the first way:
Example of the second way:
Configuration
Planned API
Usage: SkillsFramework.function_name(arguments)
Arguments:
Training System Specific Functions
Level System specific functions
I will probably add some alias functions to the API like addExperience(amount) which is just a setExperience(getExperience()+amount).
Feedback
Tell me if it is good or bad, if anything is missing, or if anything seems like it would be awkward to use. Any and all suggestions welcome.
I am specifically curious if people like or dislike the two skill systems I choose. I think they are flexible enough to fit most skill uses.
I'm currently in school so it might take me a few days to get back to you. Thanks!
Hello, I've been working on a RPG skills framework mod that implements two skill systems(described later). Since it is a framework I would like feedback on the general idea and API. Also a name would be good since at the moment I can only think of SkillFramework. (I'm not good with names :P) It may be slightly based on AdventureTest's skills because I looked though the code to see how skills were used in actions.
Below I will try to briefly explain the concept by taking snippets from my design doc. Full markdown doc (as of this post) is available at this gist.
Skill Sets
Skill sets are created and "attached" to identifiers. A skill set can therefore be used to describe a group, like level 1 skeletons, or individuals, like the player. Each skill set contains information for every registered skill.
Skill Systems
I currently have two skill systems, but this may change later especially if I get some feedback on it.
- Level-based: Each skill set has a single experience bar and a character level. Each skill also has a level. Every attempted action earns points for the overall experience bar. Each time the experience bar fills, the character gains a level and progression points which can be spent on increasing skill levels.
- Training-based: Each skill has an experience bar and level. Every attempted action related to a skill earns experience for that skill. The skill level increases each time the bar is filled.
Using Skills
An action is said to occur whenever SkillsFramework.trySkill(entity, skill, test_func) is called. This will usually be called in a register_on_punchnode or register_on_craft, but would probably be useful in any "on something" registration function. The test_func returns a number which is the amount of experience that will be added to the skill(or character experience bar). The try skill function will then return the same number to it's caller allowing for further processing(i.e. adding special meta data to a crafted item).
- "entity" is an unique identifier. This should be the entity's Minetest ID for individuals or a unique string for groups.
- "skill" the name of the skill to test/check.
- "test_func" is a function that receives the skill level and experience worth and returns a number.
Using Multiple Skills
If an action requires several skill checks, a modder could do two things. He could call them in parallel in the "on something" registration function and then combined the results to determine the action effect. If the success of one skill depends on the success of another, he could also chain trySkill calls with in a trySkill test function.
Example of the first way:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
result1 = trySkill("singleplayer", "woodworking", function(lvl, exp)
*do dice roll/random number gen and checking*
end)
result2 = trySkill("singleplayer", "metalworking", function(lvl, exp)
*do dice roll/random number gen and checking*
end)
*do tests against result 1 and 2 for final outcome*
Example of the second way:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
result = trySkill("singleplayer", "woodworking", function(lvl, exp)
inside_result = trySkill("singleplayer", "knowledge: botany", function(lvl, exp)
*do dice roll/random number gen and checking*
end)
*do dice roll/random number gen and check against inside_result*
end)
*do tests against result and inside_result for final outcome*
Configuration
- HIDE_ZERO_SKILLS (bool): When true hides skills with a 0 in both level and experience. Allows for 'discovering' skills.
- SAVE_SKILLS (bool): When false skills will not be saved. Use if you want to handle saving skills in another mod.
- SAVE_INTERVAL (positive integer): How often skill data should be saved. This is ignored if save skills is false.
- SKILL_SYSTEM (string): Sets what skill system to use. Choices are "level" or "training". Defaults to level.
- CHARACTER_LEVEL_FUNC (function): Only used when SKILL_SYSTEM is set to "level." Defines the number of experience points needed for each level (exactly like test_func).
Planned API
Usage: SkillsFramework.function_name(arguments)
Arguments:
- entity: the skill set identifier (i.e. the entity or group name)
- skill: name of the skill
- level/experience: a number to set the level/experience to.
- level_func: determines the cost of each level. Receives next_level as it's argument (i.e. current level is 1 this function will be provided 2) returns the cost.
- test_func: determine the outcome of an action. Receives skill level and experience returns experience gained.
- static: when true the skill set will not allow experience gain. (good for group skill sets like "level one skeletons")
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
| Name | Arguments | Returns | Description |
| showFormspec | player | none | Shows a formspec for graphical skill interaction. |
| defineSkill | name, group, level_func | none | Adds a new skill definition to the skill system. |
| trySkill | entity, name, test_func | int | Tests a skill to see if the action succeeds. |
| attachSkillset | entity, static=false | none | Creates and then attaches a new skill set to the given identifier.|
| removeSkillSet | entity | none | Deletes a skill set. |
| setLevel | entity, skill, level | none | Allows setting the level of a skill in a skill set. |
| getLevel | entity, skill | int | Return the level of specified skill. |
Training System Specific Functions
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
| Name | Arguments | Returns | Description |
| setExperience | entity, skill, experience | none | Sets the specified skill's experience. |
| getExperience | entity, skill | int | Returns the specified skill's experience. |
Level System specific functions
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
| Name | Arguments | Returns | Description |
| setCharLevel | entity, level | none | Allows setting the entity's level for Level-based skill systems. |
| getCharLevel | entity | int | Returns the entity's level for Level-based skill systems. |
| setCharExperience | entity, experience | none | Allows setting the entity's experience for Level-based skill systems. |
| getCharExperience | entity | int | Returns the entity's experience for Level-based skill systems. |
I will probably add some alias functions to the API like addExperience(amount) which is just a setExperience(getExperience()+amount).
Feedback
Tell me if it is good or bad, if anything is missing, or if anything seems like it would be awkward to use. Any and all suggestions welcome.
I am specifically curious if people like or dislike the two skill systems I choose. I think they are flexible enough to fit most skill uses.
I'm currently in school so it might take me a few days to get back to you. Thanks!