Home » MODDING HQ 1.13 » v1.13 Modding, Customising, Editing » v1.13 Time Capsule (Howto Library) » "How does it work?" Part 7a: Levelling Up
"How does it work?" Part 7a: Levelling Up[message #197191] 
Wed, 24 September 2008 19:45  
Headrock


Messages:1795
Registered:March 2006 Location: Jerusalem 


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 AdvancementPoints:
Attributes: 50 AdvancementPoints required per level
Strength Dexterity
 Agility
 Wisdom
 Health
Skills: 25 AdvancementPoints required per level
Marksmanship Leadership
 Explosives
 Medical
 Mechanical
Experience Level: 350 points required, per level already attained.
So if you are at level 6, you need 350*6=2100 AdvancementPoints 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 (located HERE ), 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 levelups.
 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 levelup 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 levelups:
 Anyone who hasn't been recruited yet (so Enemies and Militia naturally also never get levelups in this way)
 Vehicles
 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 levelup is "FROM TRAINING".
Alrighty, let's begin.
If trying to level up in STRENGTH, AGILITY, DEXTERITY, or HEALTH, then
WISDOM is irrelevant
Else,
WISDOM is relevant
If Reason is TRAINING, then
WISDOM is always relevant.
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.
If Current Level < 0, then
No experience gain.
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...
For each "chance to increase", do...
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.
If Character Evolves Normally, then...
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 normallyevolving characters. We'll see later how Devolving characters are treated.
If Reason = FAILURE, then
If Advancement_Points already accumulated = (Required_Points_to_Level  1), then
No level gain!
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.
If Stat is not EXPERIENCE_LEVEL, then
Effective_Level = Current_Stat_Level + (Accumulated_Advancement_Points / Required_Advancement_Points)
Actual_Chance = 100  Effective_Level
If Reason = TRAINING, and Base_Chance_To_Gain_Points >= Maximum_Possible_Level_from_Training, then
Actual_Chance = 0
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:
If Accumulated_Advancement_Points is less than Required_Advancement_Points, then
Modifier = 0
Else,
Modifier = 1
Effective_Level = Current_Stat_Level + Modifier
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 pseudocode.
Moving on.
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.
If Stat = EXPERIENCE_LEVEL, then
Effective_Level = 10 * (Current_Experience_Level + (Level_Up_Modifier) )
Actual_Chance = 100  Effective_Level
Now we handle the chancetogainpoints 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.
If we have more than 0% chance, and WISDOM should take effect, then
Effective_Wisdom = Current_Wisdom + (Wisdom_Level_Up_Modifier)  50
Actual_Chance is increased by (Actual_Chance * Effective_Wisdom / 100)
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.
If Actual_Chance > 99, then
Actual_Chance = 99
Making sure there's always room for failure.
Random_Number = anywhere between 0 and 99
If Random_Number < Actual_Chance, then
Increase Accumulated_Points for this Stat by 1
If Stat is NOT EXPERIENCE_LEVEL, and Reason is NOT TRAINING, then
Effective_Experience_Level = Current_Experience_Level + (Experience_Level_Up_Modifier)
If Effective_Experience_Level < 10, then
If Reason is NOT FAILURE, or if it is a failure but we're not on the verge of going up in Experience_Level, then
Increase Accumulated_Points for our Experience_Level by 1
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.
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!
If Character is set to REVERSE_EVOLUTION, then
Effective_Level = Current_Level + Level_Up_Modifier
If Stat is an ability (STRENGTH, AGILITY, DEXTERITY, HEALTH, or WISDOM), then
Effective_Level is reduced by 1
Actual_Chance = Effective_Level
If Actual_Chance < 0, then
Actual_Chance = 0
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. Reverseevolving characters have a HIGHER chance to lose high skills...
If Stat is EXPERIENCE_LEVEL, then
Effective_Level = (10 * (Current_Experience_Level + Experience_Level_Up_Modifier))  1
Actual_Chance = Effective_Level
If Reason is TRAINING, then
Effective_Wisdom = 0  (Current_Wisdom + (Wisdom_Level_Up_Modifier)  50)
Actual_Chance = Actual_Chance * Effective_Wisdom / 100
If Actual_Chance < 1, then
Actual_Chance = 1
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.
And finally:
[code]
Random_Number = anywhere between 0 and 99
If Random_Number < Actual_Chance, then
Reduce Accumulated_Points for this Stat by 1
If Stat is NOT EXPERIENCE_LEVEL, and Reason is NOT TRAINING, then
Effective_Experience_Level = Current_Experience_Level + (Experience_Level_Up_Modifier)
If Effective_Experience_Level > 1, then
If Reason is NOT FAILURE, or if it is a failure but we're not on the verge of going up in Experience_Level, then
Reduce Accumulated_Points for our Experience_Level by 1
So all in all, this is an almost exact reverse of the normal formula. So basically, forget reverseevolving characters. They plainout 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 nicelooking number.

In the Next Part of this twopart article, I will explore the actions and activities which grant us ChancesToGainAdvancementPoints.
[Updated on: Mon, 27 April 2015 23:46] by Moderator



   
Re: "How does it work?" Part 7a: Levelling Up[message #236214] 
Thu, 29 October 2009 00:48  
futrtrubl

Messages:2
Registered:October 2009 Location: Kingston, Jamaica 


I feel there must be a typo in the formula posted for the effect of Wisdom..
If we have more than 0% chance, and WISDOM should take effect, then
Effective_Wisdom = Current_Wisdom + (Wisdom_Level_Up_Modifier)  50
Actual_Chance = Actual_Chance * Effective_Wisdom / 100
This would mean that for any character with less than 50 Wisdom their Actual_Chance is always 0.
Wis = 50
Effective_Wisdom = 50 + 0  50 = 0
Actual_Chance = Actual_Chance * 0/100 = 0
For it to work the way you described it would have to be
If we have more than 0% chance, and WISDOM should take effect, then
Effective_Wisdom = Current_Wisdom + (Wisdom_Level_Up_Modifier)  50
Actual_Chance = Actual_Chance + (Effective_Wisdom / 100)
Edward



           
Goto Forum:
Current Time: Sat Oct 21 02:32:22 EEST 2017
Total time taken to generate the page: 0.00896 seconds
