Author Topic: [DONE] [Suggestion] Ability to mod stat improvement algorithm  (Read 11058 times)

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3360
    • View Profile
Re: Modding experience gained and stat caps
« Reply #15 on: October 07, 2018, 09:10:56 pm »
Done, it will be available in next release.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: Modding experience gained and stat caps
« Reply #16 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.
« Last Edit: October 07, 2018, 09:17:44 pm by The Reaver of Darkness »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9116
    • View Profile
Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
« Reply #17 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
« Last Edit: October 07, 2018, 10:01:38 pm by Meridian »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3360
    • View Profile
Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
« Reply #18 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?

Offline Joe

  • Sergeant
  • **
  • Posts: 11
    • View Profile
Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
« Reply #19 on: October 08, 2018, 04:54:30 am »
Thanks so much Yankes, this is great! Could you explain how to use it?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3360
    • View Profile
Re: [DONE] [Suggestion] Ability to mod stat improvement algorithm
« Reply #20 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.