ID:2119555
 
How would I go about coding someone gaining their abilities. I have a Mastery gain and once you gain a certain number you will unlock a new skill. Should I make a variable for each skill you earn and then once you learn it I do "blank_skill=1" so that it doesn't give the message again? Or would that be too much code?
Code:
    Mastery_Gain()
if(src.Mastery<100)
if(src.power_use==1)
switch(rand(0,10))
if(5)
src.Mastery += 1

No. That is THE worst possible way to handle this. I'd do something like:
var/list/skill_mastery = list("attack"=5,"blast"=10)

And
skill_mastery[skillName] += mastery
This has the added benefit of being able to have different mastery levels for each skill.

Disclaimer: Don't expect this to be plug&play. It's off the top of my head, written on my phone.
//list(current mastery, max_mastery)

var/list/skill_mastery = list("punch"=list(1,5),"slash"=list(1,15))
var/list/masteredSkills
proc/gainMastery(skill, amount)
if(!skill_mastery[skill]) return // don't have this skill or it's mastered

if( (skill_mastery[skill][1] + amount) < skill_mastery[skill][2])
skill_mastery[skill][1] += amount
else
skill_mastery -= skill
if(!masteredSkills) masteredSkills = list()
masteredSkills += skill
src << "You mastered [skill]!"

Using if(var==1) is not a good way to check for a true value. Use if(var) instead.
@GreatPirateEra I love the help, but I meant like the message you get in games when you learn a skill like "You just learned fire breath!" or something. The mastery proc I should does not show the mastery of skills someone has, but the Mastery of your overall power like Telekinesis. Once you get about 25 percent mastery you earn a new ability. I just do not know how to make the message without having to have a var so that the proc doesn't repeat it if your mastery is still the same.
In response to Dayvon64
Not the best way, but it is one way:

var/old_mastery = src.telekenesis_mastery

// add some mastery as a result of training...

if(old_mastery < threshold_3 && telekenesis_mastery >= threshold_3)
src << "You are a master with magic!"
else if(old_mastery < threshold_2 && telekenesis_mastery >= threshold_2)
src << "You are proficient with magic!"
else if(old_mastery < threshold_1 && telekenesis_mastery >= threshold_1)
src << "You get better with magic!"


You could remove the else-if chain to allow each message to show in the case of a player jumping significantly in a stat. It's up to you.