Home » MODDING HQ 1.13 » v1.13 Modding, Customising, Editing » v1.13 Time Capsule (How-to 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 Go to next message
Headrock

 
Messages:1760
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 Advancement-Points:

Attributes: 50 Advancement-Points required per level

    Strength
  • Dexterity
  • Agility
  • Wisdom
  • Health

Skills: 25 Advancement-Points 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 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. Smile

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 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)
  • 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 level-up 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 normally-evolving 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 pseudo-code.

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 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.

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.
cool 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. Reverse-evolving 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 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.

--------------------------------------------

In the Next Part of this two-part article, I will explore the actions and activities which grant us Chances-To-Gain-Advancement-Points.

[Updated on: Mon, 27 April 2015 23:46] by Moderator

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #197234] Thu, 25 September 2008 05:04 Go to previous messageGo to next message
threewings is currently offline threewings

 
Messages:16
Registered:September 2006
Location: Hong Kong
Nice work! A little question: Mercs who are flagged as "DEVOLVING",any example in the game?

Report message to a moderator

Private
Re: "How does it work?" Part 7a: Levelling Up[message #197235] Thu, 25 September 2008 05:12 Go to previous messageGo to next message
Nutter is currently offline Nutter

 
Messages:20
Registered:August 2002
Location: New Zealand
Larry probably when he is drunk

Report message to a moderator

Private 1st Class
Re: "How does it work?" Part 7a: Levelling Up[message #197262] Thu, 25 September 2008 13:30 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Nutter is correct. That's the only NPC flagged as Reverse_evolution in the regular 1.13. Of course, if you're playing a mod, the who knows. Smile

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #236214] Thu, 29 October 2009 00:48 Go to previous messageGo to next message
futrtrubl is currently offline 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

Report message to a moderator

Civilian
Re: "How does it work?" Part 7a: Levelling Up[message #236218] Thu, 29 October 2009 02:33 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
actually, it's neither. The correct line would be:

Actual_Chance = Actual_Chance + ((Actual_Chance * Effective_Wisdom) / 100)

I'll edit it now.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #254057] Wed, 16 June 2010 12:44 Go to previous messageGo to next message
Fury is currently offline Fury

 
Messages:10
Registered:June 2010
Hm always wondered, how that weird level/skill-up system of JA2 worked. This article (and the others of the series) gives a great insight.

Thx for the efford! Smile

Is there any (reasonably easy Wink, im not realy good in reading bare code...) way to check your current Advancement-Point level for a certain skill? Would be helpfull to see if your doing any progress, when trying methods of training in different JA2 mods/version (as far as i know, some ways to raise/push skills work or dont work in different versions...)

[Updated on: Wed, 16 June 2010 12:44] by Moderator

Report message to a moderator

Private
Re: "How does it work?" Part 7a: Levelling Up[message #254060] Wed, 16 June 2010 13:02 Go to previous messageGo to next message
Logisteric

 
Messages:3199
Registered:December 2008
Location: B
ham 3.6 has progress bars - need to be activated, though

... and welcome to the pit

Report message to a moderator

Captain
Re: "How does it work?" Part 7a: Levelling Up[message #254063] Wed, 16 June 2010 13:18 Go to previous messageGo to next message
usrbid is currently offline usrbid

 
Messages:1506
Registered:December 2008
Hi Fury, Welcome to the board!! Very Happy

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #254068] Wed, 16 June 2010 13:35 Go to previous messageGo to next message
Fury is currently offline Fury

 
Messages:10
Registered:June 2010
thx Very Happy

Progress bars sounds interesting. Hope it works for existing savegames as well Smile

As someone with not much knowledge of the inner game mechanics of JA2 I thought, that those progress must be stored somewere in the savegame files though. Should be rather simple numeric values, so they shouldnt be realy hard to find.
Actualy had that idea already last time when I digged out my copy of JA2 (or maybe WF cant remember) However I was never actualy able to find them in the savegame, nor did any of the (rather simple) savegame editors i tried since JA2 was first released gave me any hint on that. So i finaly decided to ask the experts Wink

Report message to a moderator

Private
Re: "How does it work?" Part 7a: Levelling Up[message #254070] Wed, 16 June 2010 13:40 Go to previous messageGo to next message
Logisteric

 
Messages:3199
Registered:December 2008
Location: B
it does work with your saves (as long as your install isn't outdated)

Report message to a moderator

Captain
Re: "How does it work?" Part 7a: Levelling Up[message #254104] Thu, 17 June 2010 00:14 Go to previous messageGo to next message
Fury is currently offline Fury

 
Messages:10
Registered:June 2010
Well that bar must get its infos from somewere, and that somewere must be the sav file. Anything else would make no sense imo. That means if a mod can read out that progress data already with no problem, their is prolly a type of savegame editor or viewer, that already can do that and im just not finding it Smile

Been bothering me ever since the release of the original JA2... now I found a brilliant description on how it works (well not for the vanilla game, but i guess that was pretty much the same back then) and I still cant check it out myself Wink

Report message to a moderator

Private
Re: "How does it work?" Part 7a: Levelling Up[message #254106] Thu, 17 June 2010 00:25 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
A) Why do you need an editor? What's the point? Stat Bars are already visible in the game.
B) There's no editor that shows sub-point progress, that much is for sure.
C) It works the same as it did in vanilla.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #254107] Thu, 17 June 2010 00:44 Go to previous messageGo to next message
Fury is currently offline Fury

 
Messages:10
Registered:June 2010
Well as far as I understand it, that progress bar is only available with 1.13 and a your complete HAM mod. Im prolly gonna give that combi a try the next time I start a new game, since all the extra stuff sounds realy interesting, especialy working suppression fire. But that bar prolly wouldnt work on older games I recently "found" on my HDD and would love to finaly finish first or other mods.

Thats why I was looking for a more general, though less comfortable Wink, approach, that I could try out. More or less the curiosity of a veteran PC RPG player on "how things work" Smile

Report message to a moderator

Private
Re: "How does it work?" Part 7a: Levelling Up[message #254113] Thu, 17 June 2010 01:59 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Well one option would be to get the source code of whatever version of the game you were using, and run that in VC++ in debug mode.

Another option would be to dig through the files with a hex editor, but of course 1900 bytes of data are going to be difficult to sort through.

You could try looking for game cheating software and use that to find the values while they're being changed in memory.

Of course, it's all a lot of work when you could just start a new campaign. Razz

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 7a: Levelling Up[message #254118] Thu, 17 June 2010 04:05 Go to previous message
Fury is currently offline Fury

 
Messages:10
Registered:June 2010
Good point Smile Im not THAT curious Wink

Report message to a moderator

Private
Previous Topic: New Chance To Hit system - The Formula
Next Topic: "How does it work?" Part 3: Experience Level
Goto Forum:
  


Current Time: Fri Apr 19 05:43:20 GMT+3 2024

Total time taken to generate the page: 0.01248 seconds