Page 1 of 1

[design] RPG Skills Framework

PostPosted: Mon Feb 16, 2015 21:54
by domtron vox
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.

  • 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!

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 17, 2015 18:37
by Krock
This mod has a similar use like the "hudbars" mod by Wuzzy.
At general, the idea is not bad.

Re: [design] RPG Skills Framework

PostPosted: Mon Feb 23, 2015 17:20
by Wuzzy
I don't get it. What is the difference between the level-based skill system and the training-based skill system?

After reading the description, it seems both are the same, it has only been reworded.

Re: [design] RPG Skills Framework

PostPosted: Mon Feb 23, 2015 17:52
by domtron vox
Krock wrote:This mod has a similar use like the "hudbars" mod by Wuzzy.
At general, the idea is not bad.


I saw that and hope to use it later in a project, but haven't had time to look at it much in depth. And thanks. :)

Wuzzy wrote:I don't get it. What is the difference between the level-based skill system and the training-based skill system?

After reading the description, it seems both are the same, it has only been reworded.


Sorry about that. I knew the wording wasn't the best but couldn't seem to refine it and keep it brief. Will work on that more.

Here is the difference:
  • In the Training skill system you must train each skill's experience individually. Using the woodcutting skill will only improve the woodcutting skill(ignoring the fact that an action might use multiple skills). Chopping wood does not help your cartography skill in any way and vice versa. When you chop a log you gain experience for your woodcutting skill. When you have chopped a number of logs you gain a level in woodcutting.
  • In the Level skill system you have only one experience bar but many levels. Any action you do adds experience to that one experience tracker. That experience bar is associated with your character's overall level (like in dnd or many mmo's). When the experience bar is full a character level is gained and the player receives progression points to buy levels for other skills. So cutting logs in this case can effect your cartography skill since you can gain a level then buy points in cartography.

I hope that is clearer. I'll try to fix the readme later.

I would love suggestions for changing the names to be more clear. I don't particularly like level and training since both have levels and both require training. :/

I have finished coding it and fixing syntax errors(it loads without error). I just need to make sure it has no run time errors.

Edit: I wanted to add that I may well change these skill systems depending on feedback and am kinda wanting to implement the major well known skill systems instead. If that makes sense? I had a list of the 3 major skill systems + hybrid ones but can't find the wikipage anymore. :/ Anyway for the first version I just want to get this simple(?) idea done decently.

Also I have a question but was in a hurry before. I was planning on using mostly register_ondignode and similar then noticed the warning in lua_api.txt about preferring to not use it. Would using the api for override parts of a node cause problems with other mods? So if I say redefine the on_dig function for default:dirt will that conflict with another mod that does the same? I am assuming yes but wanted to make sure.

In my original idea we would define a register_on_dignode(mainly because this is what AdventurTest does), run through a bunch of if statements to figure out which nodes effect which skills (tree=1 adds woodcutting exp; soil=1 adds digging exp) then run trySkill for the relevant skills.

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 00:33
by Wuzzy
Ah, thanks. Now it is much clearer to me.

For better names, I would suggest these:
  • Training skill system → Multi skill system (because you have multiple skills which you must master one by one)
  • Level skill system → Single skill system (because you only have one “skill”, the global experience bar, and everything adds to this “skill”)

Hmm. When I think about it and I understood correctly, it looks like the single skill system / level skill system is really nothing more but a subset of the multi skill system / training skill system, because you could emulate the single skill system completely in the multi skill system by adding just one skill and only using this one skill. Then the multi skill system would behave exactly like the single skill system.
If I am right, it might be a better idea to merge both systems into one skill system, because otherwise, the single skill system would be redundant, and you would not lose anything by merging.
Unless both systems differ in something else than just the number of skills which you are allowed to use, I see no point in seperating these systems.


I can't answer the other modding-related questions, sadly. Maybe you should ask in IRC or in the Modding Discussion forum.

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 01:06
by HeroOfTheWinds
I believe you are missing what he is saying, Wuzzy.

In his proposed Level Skill System, you have multiple skills, but only one Exp. bar. When you fill that bar, you choose where to invest your skill points. So you still have multiple skills, just you can cultivate them through completely unrelated tasks.

In his proposed Training Skill System, you still have multiple skills, but each has its own strict exp. bar. You cannot cultivate construction by digging caves, for example.

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 03:15
by domtron vox
@Wuzzy: HeroOfTheWinds has it right sorry I botched the description again. :(

However your assumption that the level system is just a subset is kinda right but the mechanics are different enough to warrant the separation. What I'm doing is adding a hidden "skill" called level which has a level and experience table entry. Then when adding normal skills I only add the level table entry. So it looks like:

An example skillset for the Level Skill System
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
singleplayer_skillset = {
    "__level" = {
        ["name"] = "__level",        --fake "skill" name
        ["group"] = "invisible",      --grouping name
        ["level"] = 0,                     --current character level
        ["experience"] = 0,           --current character experience
        ["next_level"] = 2000,      --cost to reach next level (experience)
        ["level_func"] = <function>   --function that calculates each level's cost
    },
    "woodcutting" = {
        ["name"] = "woodcutting,       --skill name
        ["group"] = "landscaping",     --grouping name
        ["level"] = 0,                           --current skill's level
        --experience entry missing, exp gain gets added to the __level fake skill
        ["next_level"] = 1,                  --cost to reach next level (in progression points)
        ["level_func"] = <function>    --function that calculates each levels cost
    },
    "digging" = {
        ["name"] = "digging,            --skill name
        ["group"] = "landscaping",   --grouping name
        ["level"] = 0,                         --current skill's level
        --experience entry missing, exp gain gets added to the __level fake skill
        ["next_level"] = 1,                 --cost to reach next level (progression points)
        ["level_func"] = <function>   --function that calculates each levels cost
    }
}


as opposed to a training skill system skill set which would look like this
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
singleplayer_skillset = {
    "woodcutting" = {
        ["name"] = "woodcutting,     --skill name
        ["group"] = "landscaping",   --grouping name
        ["level"] = 0,                        --current skill's level
        ["experience"] = 0 ,             --current skill's experience
        ["next_level"] = 1,                --cost to reach next level (in experience points)
        ["level_func"] = <function>  --function that calculates each levels cost
    },
    "digging" = {
        ["name"] = "digging,            --skill name
        ["group"] = "landscaping",   --grouping name
        ["level"] = 0,                         --current skill's level
        ["experience"] = 0 ,              --current skill's experience
        ["next_level"] = 1,                 --cost to reach next level (in experience points)
        ["level_func"] = <function>   --function that calculates each levels cost
    }
}


That's probably a slightly hacky way to do it which is why I was saying:

Domtron Vox wrote:I wanted to add that I may well change these skill systems depending on feedback and am kinda wanting to implement the major well known skill systems instead. If that makes sense? I had a list of the 3 major skill systems + hybrid ones but can't find the wikipage anymore. :/ Anyway for the first version I just want to get this simple(?) idea done decently.


The solution is to separate the actual mechanics of each skill system into their own lua file and only loading the configured skill system's API. But that is for later.

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 08:29
by Minetestforfun
I strongly support your skills framework, it's an amazing project for our RPG Minetest community !

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 15:04
by domtron vox
Minetestforfun wrote:I strongly support your skills framework, it's an amazing project for our RPG Minetest community !


Thanks! I have plans for a core RPGEntities modpack which this works towards. We really have a ton of RPG focused mods already.

I do have a question. Is it wired that the API changes depending on a setting(the skill_system type)? It occurred to me last night it might be better to make a separate mod for each skill system. I'll deal with it later but I would like some feedback on it.

Re: [design] RPG Skills Framework

PostPosted: Tue Feb 24, 2015 20:57
by Napiophelios
I think this is a great idea, I like the idea that crafting could fail if you are a novice :)

It could lead into player classes/vocations and base skill levels/bonuses per profession.
The idea of seperating the skill systems into their own mods could make this kinda expansion later on much tidier.

Re: [design] RPG Skills Framework

PostPosted: Fri May 08, 2015 09:59
by asanetargoss
I personally feel the skill systems should be done away with entirely. The level-based skill system is particularly problematic because different mods may grant the player different amounts of experience, and thus players may end up spending time grinding some boring and menial skill to level up some entirely unrelated skill. On the other hand, the training-based skill system is too limited by itself. I would recommend breaking things up and leaving balancing to the individual modders, something like this:

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
SkillsFramework.registerLevel({
    id = "some_rpg_mod:level", -- Unique identifier would be nice to have for compatibility's sake
    name = "Level" -- Display name
    group = "Some RPG Mod", -- Group it is displayed in
    min = 1,
    max = 99,
    level_func = <function>, -- As you would expect, it takes a level and calculates how much experience is needed to get to the next level
    on_level_up = <function> -- Would allow the mod to give the player skill points, display a level up message, etc...
})
SkillsFramework.registerLevel({
    id = "other_rpg_mod:herbalism",
    name = "Herbalism",
    group = "Crafting",
    min = 1,
    max = 30,
    level_func = <function>,
    on_level_up = <function>
})
SkillsFramework.registerLevel({
    id = "other_rpg_mod:farming",
    name = "Farming",
    group = "Building",
    min = 1,
    max = 30,
    level_func = <function>,
    on_level_up = <function>
})

SkillsFramework.registerSkillPoint({
    id = "some_rpg_mod:aptitude",
    name = "Aptitude"
})
SkillsFramework.registerSkillPoint({
    id = "other_rpg_mod:nature",
    name = "Nature"
})

SkillsFramework.registerSkill({
    id = "some_rpg_mod:mining",
    name = "Mining",
    description = "Increases digging speed slightly",
    eligible_skill_points = {"some_rpg_mod:aptitude"},
    min = 1,
    max = 20
})
SkillsFramework.registerSkill({
    id = "other_rpg_mod:nature",
    name = "Nature Skill",
    description = "Improves your ability in all nature-related skills",
    eligible_skill_points = {
        "other_rpg_mod:nature",
        "other_rpg_mod:magic",
        "some_magic_mod:earth"
    },
    min = 1,
    max = 40
})

Re: [design] RPG Skills Framework

PostPosted: Fri May 08, 2015 13:15
by domtron vox
@asanetargoss, hello. Sorry this topic is old so to speak as I have released the mod in WIP. see this topic viewtopic.php?f=9&t=11406

I do like your example of the register function passing a table to define everything though it should be defineSkill.

asanetargoss wrote:I personally feel the skill systems should be done away with entirely.


asanetargoss wrote: I would recommend breaking things up and leaving balancing to the individual modders, something like this:


What you suggest is essentially what I did. Modders will manipulate an entity's skills using get and set functions for the exp and level handling progression on their own. This way a modder can just ignore experience if they want, ignore the level(i'll need to do some tweaks for this to work), or create a 'skill' called Level (like your first example?) to define an overall character level and define all actions as advancing the level. It needs lots of work though.

asanetargoss wrote:The level-based skill system is particularly problematic because different mods may grant the player different amounts of experience, and thus players may end up spending time grinding some boring and menial skill to level up some entirely unrelated skill. On the other hand, the training-based skill system is too limited by itself.


I am not entirely sure I follow you. Please go look at the updated topic and make another post and we can discuses it. I love feedback and discussion since it makes this mod closer to what the community wants. Thanks!