ID:153315
 
I'll get straight to the point, I have a set of skills (around 15+) that the player is able to learn through-out the game, but each skill has a different set of requirements that mumst be met in order to learn the specific skill.
Now the thing i want to ask, is what would be more efficient in how to do this. I was thinking of making the skills objects in the game, and then when it checks whether the players mob is able to learn them, make a new object then check against the requirements, and if they arent met, just delete the object. But if they were, add them into a list of which the player is able to select one of these skills to have perminantly.
To me, this sounds like too much hassle for just selecting one skill, and i was wondering if anyone else had any good ideas on how i should go about making this.
Thanks in advance.
I think stuff like this is pretty much up to how you want to do it. Personally, I like to just give every player-mob an associative list containing skills and their levels.

So, skill["Fishing"] = 52, for example. Then you can use the 52 however you want. Maybe making it a 50% chance of success + skill / 2, so with 52 skill I'd have a 76% chance of success when fishing.

But if you want skills to be used by clicking on the skill object, or something... Well, it all depends on what you want.
In response to Foomer
I should have mentioned before, but there are multiple requirements, for example:

There is a skill called sniper, which becomes available when a player reaches level 21. But also, for it to become available, the player must have a perception of at least 9.

Sometimes more than one attribute is used, or sometimes its just a level. I suppose i could just use an associated list with a text-string containing all of the information, but this is why i was thinking of making objects before.
In response to Lazyboy
If you've got more than one bit of data (such as a level) for each skill, then use a datum. Unless you want it stored in a location instead of a list, in which case you'd use an /obj. I think you can even give datums a var/icon and have it show up in statpanels and such. But doesn't quote me on that.
In response to Foomer
Foomer wrote:
I think you can even give datums a var/icon and have it show up in statpanels and such.

Ya, I think you'd have to give it a parent_type first. I recall someone saying something about this, but forget who.
In response to Lazyboy
I just use associative lists:
skills_building["brickmaking"] = 3
skills_building["brickmaking_exp"] = 50
skills_building["brickmaking_strengthneeded"] = 2 //Example
In response to Goku72
Only atoms display icon, name, or suffix values in the statpanels. Adding those vars to a datum that is not a child of atom will not cause them to display. You can use parent_type to make it a child of atom.
In response to Foomer
This may sound pretty complex, but it really cuts back on the number of datums floating around in memory.

I have a skill system for a yet to be announced project that works something like this:

Skills are datums that are stored in a global associated list indexed by skill name. For example: SkillList["stealth"] = an instance of /skill/stealth. This instance stores all the things about the skill that don't change from character to character like requirements and procs. Some procs include: one to see if a mob can learn the skill, one to check skill success, and one to apply skill results to a target. Most of the procs take the character mob as an argument so the skill knows who to check, for example: skill/proc/requirements(mob/M) returns 1 if M meets the requirements to learn that skill, or 0 if M does not. skill/proc/test(mob/M) checks M's skill rating, modified by M's attributes and possibly resisted by M's target, then applies the skill results if it succeeds.

Only the skill rating changes from character to character, so mobs have an associated list of skill ratings. A player with a stealth rating of 12 has mob.SkillRating["stealth"] = 12.

This allows the game to function with only one instance of /skill/stealth no matter how many active characters have a stealth rating. Save files will also be much smaller because it only has to store the name and rating in the list instead of all the details of a datum instance.

P.S. You may prefer to index the lists by typepath instead of name.
In response to Shadowdarke
Living proof that great minds think alike: Haven's skill system (which is actually implemented, though the skills themselves are just placeholders for the time being... =P) follows a system which is very similar to the one just described.