OpenXcom Forum

Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started by: Joe on October 04, 2018, 08:26:20 am

Title: [DONE] [Suggestion] Ability to mod stat improvement algorithm
Post by: Joe on October 04, 2018, 08:26:20 am
I really like open xcom, lots of fun.

So I just want to make some small changes instead of big mods. Currently playing the x files mod.

I wanted to change

1- how much experience you gain, but didn't find any rules anywhere in the rules files about it, and I looked hard.
2-  and the maximum stats of soldiers : I did find the rules file and changed them. The problem is I think the formula for experience gained is based on the maximum stats caps, so if I change the stats caps it messes up the experience formula, so I need to be able to change both.

Does anyone know?

Thanks
Title: Re: Modding experience gained and stat caps
Post by: Meridian on October 04, 2018, 09:36:04 am
1/ there are no such rules in the ruleset

2/ improvement of bravery, reactions, firing, throwing, melee, psi skill and psi strength don't depend on max stats... only on experience gained during the mission;
TU, stamina, HP and strength depend on the difference between max stats and current stats
Title: Re: Modding experience gained and stat caps
Post by: Joe on October 04, 2018, 10:00:04 am
Thanks for the answer.

1- So there's no way I can create my own rule for experience?

2- And is there a way I can change the way that works too?
Title: Re: Modding experience gained and stat caps
Post by: Meridian on October 04, 2018, 10:11:19 am
1/ correct
2/ no
Title: Re: Modding experience gained and stat caps
Post by: Solarius Scorch on October 04, 2018, 12:13:26 pm
Just curious, what would you do with the experience formula if you could?
Title: Re: Modding experience gained and stat caps
Post by: The Reaver of Darkness on October 04, 2018, 09:12:16 pm
This is what you can do to change experience gain rates: New experience award system / accuracy training system (https://openxcom.org/forum/index.php/topic,4230.0.html)

You can reduce experience gain rates by selecting a lower value, for example experienceTrainingMode: 6 trains firing accuracy only 1/3 of the time. You can't increase an individual attribute's training rate above 1, but you can train faster by applying multiple attributes. For example, experienceTrainingMode: 14 trains both firing accuracy and reactions.

As you probably figured out by reading Meridian's thread, this only affects experience gained by hitting hostile targets with weapons. If you want extra training in addition to this, you can implement a training facility into your mod, which can have any training rate you like.

Another way to alter the rate of training is to change all of the attributes. You can cut all training in half by doubling every attribute except psi strength. You can double the rate of training by halving all attributes except psi strength. You can change psi strength as well, but you'll need to understand that doubling psi strength and doubling psi skill quadruples psi offense power while increasing psi defense to slightly more than double.
Let me know if you want an in-depth tutorial for how to do this.
Title: Re: Modding experience gained and stat caps
Post by: Yankes on October 05, 2018, 12:11:15 am
1/ there are no such rules in the ruleset

2/ improvement of bravery, reactions, firing, throwing, melee, psi skill and psi strength don't depend on max stats... only on experience gained during the mission;
TU, stamina, HP and strength depend on the difference between max stats and current stats

3/ For sadist: there is script that can read max stats and adjust stat grain per attack.
Title: Re: Modding experience gained and stat caps
Post by: Joe on October 05, 2018, 12:28:56 am
This is what you can do to change experience gain rates: New experience award system / accuracy training system (https://openxcom.org/forum/index.php/topic,4230.0.html)

You can reduce experience gain rates by selecting a lower value, for example experienceTrainingMode: 6 trains firing accuracy only 1/3 of the time. You can't increase an individual attribute's training rate above 1, but you can train faster by applying multiple attributes. For example, experienceTrainingMode: 14 trains both firing accuracy and reactions.

As you probably figured out by reading Meridian's thread, this only affects experience gained by hitting hostile targets with weapons. If you want extra training in addition to this, you can implement a training facility into your mod, which can have any training rate you like.

Another way to alter the rate of training is to change all of the attributes. You can cut all training in half by doubling every attribute except psi strength. You can double the rate of training by halving all attributes except psi strength. You can change psi strength as well, but you'll need to understand that doubling psi strength and doubling psi skill quadruples psi offense power while increasing psi defense to slightly more than double.
Let me know if you want an in-depth tutorial for how to do this.

Thanks for the answer. I read the thread and If I understand correctly, I have to put the line experienceTrainingMode : xx  on every weapon in the game? Or on every soldier? I know how to edit the text files but I'm a beginner, I found the ruleset for soldiers and units.
Title: Re: Modding experience gained and stat caps
Post by: Joe on October 05, 2018, 12:32:33 am
Just curious, what would you do with the experience formula if you could?

I want to put the stats cap higher and lower the experience gain rate, and maybe not use training facilities altogether. Just for fun, cause I remember playing xcom apocalypse and having all my soldiers maxed out very early, then I felt it got less fun.
Title: Re: Modding experience gained and stat caps
Post by: Yankes on October 05, 2018, 01:33:41 am
Basic exp grain have minimum 33% chance, but script can reduce it to 1%
Title: Re: Modding experience gained and stat caps
Post by: Joe on October 05, 2018, 01:38:38 am
Basic exp grain have minimum 33% chance, but script can reduce it to 1%

Which script? I'm interested.
Title: Re: Modding experience gained and stat caps
Post by: The Reaver of Darkness on October 05, 2018, 02:45:40 am
For simple modding, you have to add the line to each weapon.

In my mod, pistols use mode 14 (reactions and firing) since there's not a lot of other ways to train reactions anyway, and pistols need a buff:
Code: [Select]
  - type: STR_PISTOL
    accuracySnap: 60
    accuracyAimed: 88
    tuSnap: 18
    tuAimed: 30
    experienceTrainingMode: 14
Fully automatic weapons are using training mode 5 (firing 50%), since they're hitting more often, so they will train firing accuracy at a rate comparable to slower-firing weapons:
Code: [Select]
  - type: STR_MACHINEGUN
    accuracyAuto: 44
    accuracySnap: 44
    accuracyAimed: 86
    tuAuto: 32
    tuSnap: 18
    tuAimed: 52
    autoShots: 5
    experienceTrainingMode: 5
For auto-pistols I use mode 17 (reactions or firing):
Code: [Select]
  - type: STR_AUTO_PISTOL
    accuracyAuto: 40
    accuracySnap: 45
    accuracyAimed: 66
    tuAuto: 19
    tuSnap: 13
    tuAimed: 22
    experienceTrainingMode: 17
Title: Re: Modding experience gained and stat caps
Post by: Meridian on October 05, 2018, 07:32:52 pm
I want to put the stats cap higher and lower the experience gain rate, and maybe not use training facilities altogether. Just for fun, cause I remember playing xcom apocalypse and having all my soldiers maxed out very early, then I felt it got less fun.

Well, it won't be easy.

Although what Reaver and Yankes said is all true, it doesn't help you much... because as I said at the beginning, you can't change how the stats improve, the algorithm is hardcoded.

a/ There's absolutely nothing you can do about TU, stamina, HP and strength stat improvement.
b/ There's almost nothing you can do about bravery, psi skill/strength and reactions... the new experience system can only help you increase them quicker... but you want slower
c/ melee accuracy is relevant only for mods... but if you're using some mods that depend on it, you can slow it down... a little
d/ throwing has been changed in OXCE and is now only trained when you actually hit an enemy with a grenade or something thrown... just throwing random stuff around doesn't do anything... so I guess here you can be happy at least
e/ as for firing accuracy, you can slow it down a little, same as for melee... but it probably won't be enough for you... even 33% experience gain compared to vanilla doesn't translate into 33% stat improvement... the formula for stat improvement is not linear... Last, most drastic thing you could do for firing accuracy, is turn off firing accuracy training for some weapons completely... but that somehow doesn't feel right.


My best advice... allow your soldiers to die... vanilla xcom is balanced in a way that even most veteran players can't keep them alive for more than 20 missions or so. Unless you of course don't use them; or use all possible cheesy tactics in the world. The game is MUCH more fun when soldiers die, believe me.
Title: Re: Modding experience gained and stat caps
Post by: Yankes on October 05, 2018, 11:17:35 pm
I think I could reorganize my script to be call after stat improvement and expose result of that to it.
With this you could overwrite or adjust final change of stats after mission and this will not made mess in code.

Another thing is that I will expose current exp of each stat to script with this you could create custom training function.
Title: Re: Modding experience gained and stat caps
Post by: Joe on October 07, 2018, 12:38:05 am
Thanks to all for the answers, for now I use a little hack work around, not too pretty but does the job. I'd be interested in your script Yankes though.
Title: Re: Modding experience gained and stat caps
Post by: Yankes on October 07, 2018, 09:10:56 pm
Done, it will be available in next release.
Title: Re: Modding experience gained and stat caps
Post by: The Reaver of Darkness on October 07, 2018, 09:15:45 pm
My best advice... allow your soldiers to die... vanilla xcom is balanced in a way that even most veteran players can't keep them alive for more than 20 missions or so. Unless you of course don't use them; or use all possible cheesy tactics in the world. The game is MUCH more fun when soldiers die, believe me.
It's good advice. I don't follow it completely; rather, I found a way around it. After a soldier squad experiences enough losses, I retire the survivors. The idea behind it says that they are ensured a greater than 50% survival rate, but the effect is the same: you have to keep training new soldiers. It's better this way.


But I am also eager to see more ways to adjust experience gain, especially downward. I always support more options for modders, but in this case I know there are many players who can't stand to lose soldiers. I myself was once this way, and to some degree I still am.
Title: Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
Post by: Meridian on October 07, 2018, 09:51:05 pm
But I am also eager to see more ways to adjust experience gain, especially downward. I always support more options for modders, but in this case I know there are many players who can't stand to lose soldiers. I myself was once this way, and to some degree I still am.

@Reaver: Yeah, I was also one of those who could not let soldiers die... but once I tried it, it just felt right and I never went back. But I understand the hesitation.

@Yankes: thanks for the new script possibilities... maybe you can write a sample script for us?
Something very simple... like take vanilla stat improvements and divide them by 2 (rounded down to nearest integer) except for bravery improvement, which would instead have a 50% chance to stay unchanged and 50% chance to be set to zero

EDIT: I have moved the thread to OXCE subforum and changed the title
Title: Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
Post by: Yankes on October 08, 2018, 01:42:49 am
Code: [Select]
extended:
  scripts:
    returnFromMissionUnit:
      - offset: 1
        code: |
          var int origFiring 0;
         
          var int incStrength 0;
          var int currStrength 0;
         
          var int expPsiSkill 0;
          var int incPsiSkill 0;
          var int currPsiSkill 0;
         
          #arbitrary value
          statPrevious.getFiring origFiring;
          add origFiring 10; #add 10 to old firing stat
          soldier.Stats.setFiring origFiring; #overwrite firing now alwas +10
         
          #boost to current exp
          statChange.getStrength incStrength; #how much strength was incresed by exp
          soldier.Stats.getStrength currStrength; #current strength (alredy with bonsu value from exp)
          add currStrength incStrength; #effective 2x bonus
          soldier.Stats.setStrength currStrength;
         
          #overwrite how exp is converted to stats
          unit.Exp.getPsiSkill expPsiSkill;
          soldier.Stats.getPsiSkill currPsiSkill;
          statChange.getPsiSkill incPsiSkill;
          sub currPsiSkill incPsiSkill; #remove default stat grain
          add currPsiSkill expPsiSkill; #add new linear stat grain from exp
          soldier.Stats.setPsiSkill currPsiSkill;
         
          return;

a) you can stop any stats grain.
b) you can set different conversion between exp and stats grain.
c) you can create new way to grain stats. like if you get hit you grain +1 health or permanent +10 hp when you kill someone with vampiric blade?
Title: Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
Post by: Joe on October 08, 2018, 04:54:30 am
Thanks so much Yankes, this is great! Could you explain how to use it?
Title: Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
Post by: Yankes on October 08, 2018, 11:29:55 am
This is script that will be executed at end of mission for each soldier that survive battle.
It call after normal stats grain from experience is assigned.
Now you have access in that script to:

statPrevious - original stats before mission (read only)
statChange - stats change from exp (read only)
soldier.Stats - current stats of geoscape soldier, if you change it it will permanently change stats of soldier
unit.Stats - stats of battle soldier, changed by armor. Only affect current battle.
unit.Exp - exp grain during battle (read only)

In each of this there is named function that get or set proper stat:
Code: [Select]

          #boost to current exp
          statChange.getStrength incStrength; #`getStrength ` is function that will write current strength change to local variable `incStrength`
          soldier.Stats.getStrength currStrength; #get current strength
          add currStrength incStrength; #we add both value (this line do `currStrength  = currStrength  + incStrength`)
          soldier.Stats.setStrength currStrength; #we set new value of strength to geoscape soldier
If you want know bit more about scripts in https://openxcom.org/forum/index.php/topic,2915.msg31641.html#msg31641 is Extended readme where I add some other script examples.