OpenXcom Forum

Modding => Released Mods => Topic started by: Firaa on September 18, 2019, 10:31:05 pm

Title: [OXCE] Randomized Stat Caps for Soldiers
Post by: Firaa on September 18, 2019, 10:31:05 pm
v1.1 (06-20-2020)
- Primary experience gain using intelligence should now work on recent versions of OXCE.
- New MinMind and MaxMind tags must now be defined in the soldier ruleset. These tags set the range for primary experience gain on a soldier-to-soldier basis, as opposed to the previous method of 70% to 130%.

What is this?
I've played an embarrassing amount of X-Com: UFO Defense in my life, and probably so have most of you. But, in my opinion, a lot of mods have started to run into a problem with the vanilla mechanics that didn't really become an issue itself in the original game - late-game stat caps. I have a lot of fun outfitting soldiers in the early/mid-game of basically every mod I've played. I enjoy micromanaging soldiers to have effective and unique loadouts, and the sheer girth of equipment lists in many mods really feed into that enjoyment. Then, when the end-game rolls around, I end up having a few common loadouts that get pasted onto my ever-growing group of well-trained veterans, as everyone's stats begin to become... samey. I've played a lot with this script active, and it has made veterans so much more exciting for me, since I was dealing with soldiers who had variable stats once again. Some soldiers will make better snipers, heavy weapon specialists, or grenadiers than others, and you will encounter the rare soldier who is truly elite. Anyway, I hope someone else gets some enjoyment out of this.

How it Works
Tags are assigned to the soldier ruleset. These tags are a random 'penalty', which stats cannot grow beyond. By raising the stat caps by 10 and applying a random penalty between 0 to 20, you effectively create a random stat that is either up to 10 lower or 10 higher than the original stat cap. When a battle begins, this script calculates the stat caps for any soldiers present who have not yet been assigned stat caps. When the battle ends, after experience is awarded, the script 'trims the fat'. This script is easily applied to any mod, and is safe to add to any in-progress game.

A secondary function is that this script also generates an "intelligence" tag for each soldier. This is a multiplier applied to all experience earned, meaning some soldiers will just grow faster than others, and some soldiers will grow slower than normally. This intelligence modifier is assigned to a soldier at the same time they are initialized with their stat caps, and is completely invisible. The only way to know a soldier's intelligence modifier is via their actual growth rate. If you don't like this, you can easily disable it by opening script.rul and deleting the line near the end of the document that includes the text "awardExperience" and everything after it.

This script trims excess stats at the end of combat, so if you play with training facilities, make sure your training caps aren't higher than the minimum stat caps. This script also does not affect Psi-strength or Psi-skill. It also doesn't affect Bravery, since some people will just have better vision than others, but everybody has the capacity to be completely and utterly mentally broken desensitized to high-impact alien violence. Also, I assume that anyone who trains their entire force's bravery to capacity is an ABSOLUTE PSYCHOPATH. :P

Known Issues
- After a battle, the experience screen may show secondary stats (TUs, Stamina, Strength) as a negative change. This is only a display error, and these stats are at their current cap. You can safely ignore this if it occurs.

Attached Downloads
Standard - The vanilla soldier version. Soldiers are given a random stat cap that is 10 above or below the old stat cap. You will most likely not notice this mod in a normal vanilla playthrough (although it is fully functional for it), what with the limited gear options and comparatively short campaign, but this download will work with any mod that uses the default soldier, like XenoOps, or FMP.
40k - This version is already configured for the 40k mod. Guardsmen have more tame stat ranges, while units like Ogryn, Sisters of Battle, and Space Marines can generate certain stat caps at much greater ranges. Tags aren't modified when a soldier is transformed, so units will retain their strengths and weaknesses when they become officers/dreadnoughts while still gaining the benefits of the increased stat caps. This means that some soldiers are clearly superior candidates for advancement!
Title: Re: [OXCE] Randomized Stat Caps for Soldiers
Post by: peirceg on May 09, 2020, 06:41:51 pm
Hi I edited around and got this working for the xpiratez mod. However for some reason soldiers are not gaining any primary stats, is there anything you think I might have missed?
Title: Re: [OXCE] Randomized Stat Caps for Soldiers
Post by: vadracas on May 09, 2020, 07:00:34 pm
Hi I edited around and got this working for the xpiratez mod. However for some reason soldiers are not gaining any primary stats, is there anything you think I might have missed?

Upload file please?
Title: Re: [OXCE] Randomized Stat Caps for Soldiers
Post by: peirceg on May 10, 2020, 06:51:31 am
Seems to load with it. deleted the end bit because it wasnt giving out firing accuracy experience.

Also tested slightly with the 40k version in the 40k mod, doesnt seem to be giving out xp there either.
Title: Re: [OXCE] Randomized Stat Caps for Soldiers
Post by: Firaa on June 16, 2020, 06:58:13 am
Sorry for taking so long to reply. Replace the awardExperience section of this script with the following:

Code: [Select]
      - offset: 1 ## Apply the soldier's learning speed
        code: |
          var int expMulti;
          var int temp;
          var ptr GeoscapeSoldier currentSoldier;
          attacker.getGeoscapeSoldier currentSoldier;
          currentSoldier.getTag expMulti Tag.SOLDIER_MIND;
          if eq expMulti 0; ## If the unit doesn't have a soldier mind, then don't modify experience gain
            set expMulti 100;
          muldiv experience_multipler expMulti 100;
          return experience_multipler;

This should fix every version of the script, whether it's the ones in the original post, or your modification for xpiratez. Note: "experience_multipler" is not a typo, but is the returning variable for awardExperience. The new versions of this script include this change.