Headrock's "How does it work?" Part 7a: Leveling Up explains what circumstances make your character gain levels within the game
COMMON LEVEL PROGRESSION IN ROLE PLAYING GAMES
Progression in skills and levels is one of the most important tenets of Role Playing games. JA2 is no different, although the program itself handles progression in a rather unconventional way.
Most commonly, RPGs track a certain number of "advancement points", which are earned through activities. Once a certain number of points have been accumulated, the character's level goes up. In some games (like Oblivion) Skills collect points in separate pools, and in other games (like D&D and Fallout) there's just one pool that increases the character's overall level.
To make sure that these game get harder as you go along, you need to collect larger amounts of "Advancement Points" (Usually called Experience Points) as your level rises. Alternately, some games will simply reduce the reward you get from activities, giving the same result.
LEVEL PROGRESSION IN JA2
The idea behind the JA2 skill and level advancement is similar to that of other RPGs, in that it is harder to gain levels as the game progresses.
However, the method in which levels are gained is somewhat different. We have separate pools where our experience points accumulate, and once a pool is full, the associated skill goes up. To gain a level or a skill, we need to accumulate a certain number of Advancement-Points:
Attributes: 50 Advancement-Points required per level
Skills: 25 Advancement-Points required per level
Experience Level: 350 points required, per level already attained.
- So if you are at level 6, you need 350*6=2100 Advancement-Points to go up to level 7.
These points are accumulated separately for each skill (and separately for Experience Level).
Except for Experience Level, you need to same amount of "advancement points" to rise from MARKSMANSHIP 1 to MARSKMANSHIP 2 as you would to rise from MARKSMAPSHIP 99 to MARKSMANSHIP 100. The reason it takes much much longer to get high levels is that, in JA2, we do not always get advancement points for our actions. Instead, we get what is called a "CHANCE TO GET ADVANCEMENT POINTS". That is, when an activity associated with a certain skill is performed, there's a certain CHANCE to get advancement points, but not a guarantee. The higher your level, the less chance you have to actually get those points.
Every time we perform an action that is connected with one of our skills, we get a certain number of chances to gain advancement points - one point per "chance". For each chance, we roll a random number which will determine whether we've just gained an advancement point or not. Naturally, the higher our current level, we'll need to roll a higher number if we want to get a point. Once we gain a sufficient number of points this way, our skill/attribute/experience will go up one level. This randomal advancement system means that no two characters will gain levels at the same speed, even if they started at the exact same skill level.
Naturally, some actions are worth more than others, because they provide us with more chances to gain a point than other activities. But again, since the result is randomal, there's no guarantee that one action will really be more helpful than another action - just more LIKELY to be helpful. :)
This article will be split in two parts. The first part, which you are now reading, details the way that the program determines, for each "chance to level", whether we get a point or not. In the second part of this article, we'll see what activities give us chances to level up, and how many chances we get from each of those activities.
The "Chance to Level" formula begins with a function called "StatChange()". This function later branches out many times, but since it doesn't get too complicated I'll try to write it all down as a single algorithm. We'll go through all the motions of determining how likely we are to get an advancement_point, and then tally up all the points we've gained. If we accumulate enough points (together with points accumulated in the past), then our skill will go up one level.
We start the formula with several factors:
- Merc - The mercenary who's going to be tested for level-ups.
- Stat - The skill or level we are trying to increase
- Num_Chances - The number of chances we get to increase this skill
- Reason - This is one of three different possible reasons that the level-up was triggered: From a SUCCESSFUL use of the skill, from a FAILURE to use the skill, or from TRAINING.
We also want to draw some data from our character regarding the skill/attribute we're trying to raise:
- What is our current level in this skill?
- How many "Advancement_Points" have we already gathered in the past for this skill?
- How many "Advancement_Points" do we need to go up a level? (This is called the "Required_Points_To_Level")
Please note that some people are simply not eligible for level-ups:
- Anyone who hasn't been recruited yet (so Enemies and Militia naturally also never get level-ups in this way)
- The Robot
- Anyone in the Queen's prison
- Unconscious mercs
- Mercs who are flagged as "CANNOT IMPROVE" (I think Len used to have this, but no longer)
- Mercs who are flagged as "DEVOLVING", if the reason for the level-up is "FROM TRAINING".
Alrighty, let's begin.
We start out by deciding whether Wisdom is going to play a part in our calculation. As you can see, the physical traits are not affected by wisdom. However, if we're gaining experience through Training, wisdom always has effect.
I don't know how a skill could reach negative values - I guess this was changed from Vanilla JA2 where if a skill level was 0 then the skill couldn't be improved. Of course, in this current state, it's meaningless...
This line just starts us on a loop that will run once for each chance to increase our experience. Everything beyond this point will be repeated for each attempt.
At this point we begin processing characters who evolve normally. Remember, some characters may be set to DEVOLVE, meaning that they can't ever improve, instead they suffer from experience! Other characters may be set not to improve or suffer, but they don't get this far in the formula anyway. In any case, the code below is executed for normally-evolving characters. We'll see later how Devolving characters are treated.
This bit checks whether we're on the verge of gaining a level. If the next advancement_point will cause us to reach the required amount to level, we only want to get that point from TRAINING, or from a SUCCESSFUL use of a skill, but not from a FAILURE. We can learn from Failure, but it can only increase our advancement_point pool to the very edge of the next level. Only training or a successful use of our skills will push it over the edge.
This segment applies to any skill increases except our "Experience Level". It will determine the chance we have to gain an Advancement Point.
The Effective_Level calculation is very important to understand, as we'll see similar calculations in the future. You see that we start with our Current_Stat_Level, and then we add a strange modifier to it. The modifier is "Accumulated_Advancement_Points / Required_Advancement_Points". What does this mean?
If you want an easier explanation of how that works, look at this pseudo code. It's a different way to write the same thing:
Our Accumulated_Advancement_Points is the number of advancement points already gained in this skill, in the past. The Required_Advancement_points is how many of those points we need to go up to the next skill level. If we have enough points to go up a level, we treat our skill as though it was already one level higher.
Why is this check so important? It has to do with the fact that in most cases, we get several attempts to accumulate advancement points simultaneously. If this isn't the first attempt, then it's possible that a previous attempt has just accumulated enough points to level up. But the actual levelling up is done much later in the formula, so we need some sort of trick here to see if we've already gained enough points to do so. If so, then we treat our stat as though it's already one level higher. That'll make our chance to get another point a little bit tougher, as it would've been had we already gained that extra level.
We're going to see this trick used several more times, so it's important to understand. From now on, I will refer to it is a "Level_Up_Modifier", which can equal 0 or 1 as in the above pseudo-code.
The ACTUAL chance to gain points is then 100 - Effective_Level. So if our level is 99, the actual chance to gain advancement points is 1. If our level is 5, our actual_chance to gain points is 95. Easy.
The last bit in the calculation above simply makes sure that we cannot advance beyond a certain limit. The Maximum_Possible_Level_from_Training is set in our JA2_OPTIONS.INI file, and usually equals 85 (I think?). So if we're about to level beyond 85, and the reason is TRAINING, then we have 0 chance to gain any more advancement points.
Now we handle the chance-to-gain-points when trying to directly add Advancement_Points to our character's Experience Level. Most often, Experience Level goes up based on our advancement in other skills, but occasionally we add advancement points directly to Experience Level, especially when we finish quests.
This is done simiarly to other skills, except in the first line the Effective_Level is multiplied by 10, because our experience levels only go from 1 to 10, unlike other skills that can reach 100.
If our EXP.level is 5, then the actual chance is 100 - 5*10 = 50. If our experience level is 10, then actual chance is 100 - 10*10 = 0.
Also, experience level isn't affected by JA2_OPTIONS.INI. It can always reach 10.
Wisdom is applied as a percentage modifier to our actual chance. The higher wisdom goes above 50, the better chance we'll have to gain experience points. If our wisdom is below 50, we get a PENALTY to our chance to gain points. So the bottom line is: We get 1% bonus/penalty to our actual chance, for each 2 points of wisdom above or below 50, respectively. Also note that I've used the "Level_Up_Modifier" here that I explained above.
Making sure there's always room for failure.
Alright, a tad more complicated here, but easily explained.
Firstly we roll a random number and check it against our Actual_Chance. If we've succeeded the roll, a point is added to our Accumulated_Points pool for this stat. Yipee! That's what we wanted.
Also, our experience level can also gain Advancement_Points. Indeed, for each advancement_point you get in a skill, you might also be eligible for an advancement_point to your Experience Level. This only occurs if:
A) The stat we've just increased is NOT the experience level itself.
B) We are not training
C) Our effective Experience Level (I.E., taking into account the Level_Up_Modifier for experience) is still less than 10
D) The reason isn't failure, OR, it is failure but isn't going to cause our Experience_Level to go up yet.
So the experience level increases proportionatly when our other skills go up. Of course, it takes much longer to increase the experience level (350 advancement points for each level you already have!).
Next up, let's see what happens to characters who are flagged as "EVOLUTION_REVERSED". These characters don't benefit from training, and even worse - they will slowly LOSE skills instead of gaining them!
Figuring our effective level. The subtraction by one makes sure that physical abilities never drop below 1. Other skills can drop to 0, though.
Please note that Actual Chance is LARGER if our level is HIGHER. Reverse-evolving characters have a HIGHER chance to lose high skills...
Again, similar to the same calculation for normal mercs, except the end result is exactly reverse - the higher your Experience Level, the more likely you are to lose advancement points in it! High wisdom, however, reduces the chance to lose points.
So all in all, this is an almost exact reverse of the normal formula. So basically, forget reverse-evolving characters. They plain-out suck anyway.
And that's pretty much it. After the program has done this for each attempt to gain a point, it goes on to check all the stats to see if any have increased or decreased. If a stat has accumulated enough Advancement_Points to equal or surpass the Required amount, then the skill goes up a level. Remaining advancement points are not lost - they help towards the next level.
Finally, if the merc's experience level has gone up, and they are part of AIM or MERC, then their salary will now be adjusted accordingly. Essentially, a salary is increased by 25% each level (I.E. 25% of whatever you were paying right before the level went up). There are some modifiers to this, but they simply make sure it's a nice-looking number.