Author Topic: [DONE] New experience award system / accuracy training system  (Read 8383 times)

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1248
    • View Profile
Re: New experience award system / accuracy training system
« Reply #30 on: March 13, 2018, 06:55:42 pm »
If you ramp up experience gain for stats any further, the purpose of recruiting warriors and veterans becomes pointless.
I can't speak for Piratez specifically, but in general it is useful to the modder to have options to give soldiers more or less experience. If a weapon is very slow and cumbersome, it may make sense to have that weapon grant a lot of exp per use. But a very fast weapon might need to give less exp. If you feel your soldiers are skilling up too fast, then you might suggest to Dioxine to adjust that. The discussion should never approach the subject of removing a modder's feature, as modders should always be given more tools, not have them taken away.


Yankes added scripting possibility for experience gain, you can define all these options via a script.

Except for strength, which is not a primary skill and cannot be trained directly.
Can you give me an example of how to script it?

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 5477
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: New experience award system / accuracy training system
« Reply #31 on: March 13, 2018, 07:02:47 pm »
Can you give me an example of how to script it?

No, I have close to no idea how scripts work... but maybe @Ohartenstein could help... I'll ping him.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1711
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: New experience award system / accuracy training system
« Reply #32 on: March 13, 2018, 07:27:30 pm »
I'll start off by saying I don't get yet all the intricacies of the awardExperience script, but here's the complete documentation from the verbose debug log.  At it's most basic, the script will run whenever experience is awarded to your unit, modifying the experience gain by a multiplier, and then returning it.  The following example just outputs the experience type and multiplier values to the openxcom.log file, so you can see what's going on:

Code: [Select]
extended:
  scripts:
    awardExperience:
      - offset: 1
        code: |
          debug_log 1 experience_multipler;
          debug_log 2 experience_type;

          return experience_multipler;
And no, "experience_multipler" is not a typo in the script, that's just what the variable is called.

An autoshot from a rifle on an alien looks like this in openxcom.log:
Code: [Select]
[13-03-2018_12-14-25] [DEBUG] Script debug log at     0x23: 1 100
[13-03-2018_12-14-25] [DEBUG] Script debug log at     0x46: 2 4
[13-03-2018_12-14-26] [DEBUG] Script debug log at     0x23: 1 100
[13-03-2018_12-14-26] [DEBUG] Script debug log at     0x46: 2 4
[13-03-2018_12-14-27] [DEBUG] Script debug log at     0x23: 1 100
[13-03-2018_12-14-27] [DEBUG] Script debug log at     0x46: 2 4
Note that the experience_type variable corresponds to the types Meridian wrote down in the first post of this thread; type 4 is firing accuracy experience, trained at 100% of normal rate.

If you want to simply double experience gain for all actions, that can be done by this:
Code: [Select]
extended:
  scripts:
    awardExperience:
      - offset: 1
        code: |
          mul experience_multipler 2;

          return experience_multipler;

Or if you wanted to replace 100% firing accuracy training with your request for 67% firing accuracy training, you could do it like this:
Code: [Select]
extended:
  scripts:
    awardExperience:
      - offset: 1
        code: |
          if eq experience_mode 4;
            muldiv experience_multipler 67 100;
          end;

          return experience_multipler;

You can write more complex logic based on a large number of variables; I'd recommend looking at some of the script example Yankes and I have written to get an idea of how to set ruleset tags on an item to influence the logic in scripts.
« Last Edit: March 13, 2018, 07:37:19 pm by ohartenstein23 »

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 5477
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: New experience award system / accuracy training system
« Reply #33 on: March 13, 2018, 08:02:44 pm »
Hmm, looks like I overestimated what the script can do... this would mean only the second group of your requests (the 67% chances) is doable.

Maybe worth asking Yankes if we even understand it correctly... and if yes, if he plans on extending it...

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1248
    • View Profile
Re: New experience award system / accuracy training system
« Reply #34 on: March 13, 2018, 08:08:54 pm »
So I guess I could add a script to change a given exp gain mode that I don't use into one I do use.

Code: [Select]
extended:
  scripts:
    awardExperience:
      - offset: 1
        code: |
          if eq experience_mode 4;
            muldiv experience_multipler 2 3;
          end;

          return experience_multipler;

muldiv experience_multipler 2 3 should make more sense, it's not supposed to be exactly 67% but rather exactly 2/3rds, but it should make little difference either way.


Can you give an example of changing the ratio for 2 attribute types? Say I wanted to get melee 75% of the time and reactions 25% of the time. Or what if it's training melee AND reactions? Could I have it give 1 melee, plus 50% of the time 1 additional melee, or 50% of the time 1 reactions?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1711
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: New experience award system / accuracy training system
« Reply #35 on: March 13, 2018, 08:15:50 pm »
It doesn't matter terribly much whether you use muldiv 67 100 or muldiv 2 3, as the decimal part will just be truncated in either case due to integer math.  Also, what Meridian just said is that you can't change the ratio of two types of experience, only the changes of granting experience to the types already chosen; in the case of melee or reactions on a coin flip, that flip is already done by the time the script runs, and the script doesn't know which was chosen.  If it's training both and you want +1 experience and a 50% chance at additional +1, then you just need to have experience_multipler be 150 when you return it.

Offline FG

  • Colonel
  • ****
  • Posts: 161
    • View Profile
Re: New experience award system / accuracy training system
« Reply #36 on: June 14, 2018, 06:14:29 pm »
So, both these lines do the same thing?
> set experience_multipler 200;
> mul experience_multipler 2;

e.g.

Code: [Select]
extended:
  scripts:
    awardExperience:
      - offset: 1
        code: |
          set experience_multipler 200;

          return experience_multipler;

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1711
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: New experience award system / accuracy training system
« Reply #37 on: June 14, 2018, 06:18:50 pm »
Close, but not quite.  For some experience training modes, the experience_multiplier is not equal to 100, for example, any of the ones that train at a 50% rate.

Offline FG

  • Colonel
  • ****
  • Posts: 161
    • View Profile
Re: New experience award system / accuracy training system
« Reply #38 on: June 14, 2018, 06:29:54 pm »
Close, but not quite.  For some experience training modes, the experience_multiplier is not equal to 100, for example, any of the ones that train at a 50% rate.
Oh, i see. thx for clarifying :)

Offline Ethereal

  • Colonel
  • ****
  • Posts: 303
    • View Profile
Re: [DONE] New experience award system / accuracy training system
« Reply #39 on: July 30, 2018, 12:45:34 pm »
In General, I did not understand anything, I did not find a script template, but the problem remained.

Not enough options for Training Mode;

?? train firing and melee (100%)
?? train firing or melee (coinflip)
?? train throwing and melee (100%)
?? train throwing or melee (coinflip)

Please explain to noob how to do this.

Offline Ashghan

  • Colonel
  • ****
  • Posts: 100
    • View Profile
Re: [DONE] New experience award system / accuracy training system
« Reply #40 on: May 28, 2019, 07:42:02 pm »
I know this is a bit of a necro, but this seems a good topic to ask the question - is there a way to set a training mode separate for secondary melee attack? Ie. I want my gun to train firing when shooting, but stabbing with the bayonet should train melee. What I'm looking for is something like MELEEexperienceTrainingMode: XX setting, separate from experienceTrainingMode: (and overriding it in melee combat).

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1711
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [DONE] New experience award system / accuracy training system
« Reply #41 on: May 28, 2019, 09:43:39 pm »
I know this is a bit of a necro, but this seems a good topic to ask the question - is there a way to set a training mode separate for secondary melee attack? Ie. I want my gun to train firing when shooting, but stabbing with the bayonet should train melee. What I'm looking for is something like MELEEexperienceTrainingMode: XX setting, separate from experienceTrainingMode: (and overriding it in melee combat).

What you're describing is the default behavior for firearms in OXCE - if a gun has a "hit" attack, it will train melee.

Offline Ashghan

  • Colonel
  • ****
  • Posts: 100
    • View Profile
Re: [DONE] New experience award system / accuracy training system
« Reply #42 on: May 29, 2019, 07:07:35 pm »
I admit - I chose my previous example poorly. The default work like this, yes.  But if you use the  experienceTrainingMode: to override the default behaviour, then any attack made with that weapon gives the same type of training. So if I override a rifle to type 14 experience training Firing + Reactions, it's gunbutt melee attack will also give fire + react not melee. My question is - would be possible to apply different types of experience to different attacks. Ideally something like - Aimed (Firing), Snap (Reactions), Gunbutt (Melee) - or whatever other skill defined by use.