aliens

Author Topic: [Solved] Soldier Transformation > Add a setting monthlyLimit?  (Read 1383 times)

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Hi,

I had a look at ruleset definition (really great work!) unfortunately I did not find any answer to my need, so I finally decided to ask here

Context: I modded a facility that allows to train soldiers in different manners. I don't want to use standard system that provides a global improvement of soldiers stats, but provides instead some kind of specialization.

Request: I would like to set a monthly limit (i.e., not possible to train more than 5 soldiers per month)

The facility attribute "trainingRooms" doesn't help as it will allow "combat/martial training", that I want to avoid. In fact, I think some kind of "monthlyLimit" per SoldierTransformation should fit this expectation. I know there are already several such attributes for different puposes, as monthlyBuyLimit, etc. (very useful), but I don't know the level of difficulty ot implement it

I don't know if others may be interetested and if it could be considered as interesting/useful by our dear "developpers"
« Last Edit: March 12, 2023, 08:28:54 pm by Aldorn »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #1 on: March 11, 2023, 05:30:32 pm »
Context: I modded a facility that allows to train soldiers in different manners.

Can you tell us exactly how it works?
I know only of one way to train soldiers, so I would need to understand what you did differently and how.

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #2 on: March 11, 2023, 10:59:30 pm »
I use BaseFunc

Let me share an example

Code: [Select]
facilities:
  - type: STR_TRAINING_ROOM
    spriteShape: 1
    spriteFacility: 111
    buildCost: 800000
    buildTime: 20
    monthlyCost: 8000
    mapName: XBRO_01
    provideBaseFunc: [BASEFUNC_TRAINING]
    refundValue: 400000
    rightClickActionType: 6
    maxAllowedPerBase: 1

soldierTransformation:
  - name: STR_TRAINING_SURVIVAL1
    listOrder: 100
    requires: []
    requiresBaseFunc: [BASEFUNC_TRAINING]
    keepSoldierArmor: true
    allowsLiveSoldiers: true
    allowedSoldierTypes: [STR_SOLDIER,STR_VETERAN_SNIPER,STR_VETERAN_GRENADIER,STR_VETERAN_WARRIOR]
    requiredPreviousTransformations: []
    forbiddenPreviousTransformations: [STR_TRAINING_SURVIVAL1,STR_TRAINING_ENDURANCE1]
    cost: 15000
    transferTime: 360
    includeBonusesForMinStats: true
    soldierBonusType: STR_SB_TRAINING_SURVIVAL1
  - name: STR_TRAINING_SURVIVAL2
    listOrder: 101
    requires: []
    minRank: 2
    requiresBaseFunc: [BASEFUNC_TRAINING]
    keepSoldierArmor: true
    allowsLiveSoldiers: true
    allowedSoldierTypes: [STR_VETERAN_SNIPER,STR_VETERAN_GRENADIER,STR_VETERAN_WARRIOR]
    requiredPreviousTransformations: [STR_TRAINING_SURVIVAL1]
    forbiddenPreviousTransformations: [STR_TRAINING_SURVIVAL2]
    requiredMinStats:
      health: 120
      reaction: 80
    cost: 30000
    transferTime: 720
    includeBonusesForMinStats: true
    soldierBonusType: STR_SB_TRAINING_SURVIVAL2

soldierBonuses:
  - name: STR_SB_TRAINING_FIRING1
    stats:
      firing: 5
  - name: STR_SB_TRAINING_FIRING2
    stats:
      firing: 5
  - name: STR_SB_TRAINING_THROWING1
    stats:
      throwing: 5
  - name: STR_SB_TRAINING_THROWING2
    stats:
      throwing: 5
  - name: STR_SB_TRAINING_MELEE1
    stats:
      throwing: 5
  - name: STR_SB_TRAINING_MELEE2
    stats:
      throwing: 5
  - name: STR_SB_TRAINING_SURVIVAL1
    stats:
      health: 10
      reactions: 5
  - name: STR_SB_TRAINING_SURVIVAL2
    stats:
      health: 10
      reactions: 5

And I would like to not allow more than x soldiers per month:
- either globally (as does trainingRooms)
- or per soldierTransformation (throufh a "monthlyLimit")
« Last Edit: March 11, 2023, 11:05:31 pm by Aldorn »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #3 on: March 12, 2023, 09:15:58 am »
I see.
Well, that's not training, that's transformations.
But if we close both eyes, I guess it will do :)

If you want to limit the number of transformations, you can generate "gym tickets" via geoscape events every month and then use them as resources required for the transformation.

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #4 on: March 12, 2023, 12:07:09 pm »
If you want to limit the number of transformations, you can generate "gym tickets" via geoscape events every month and then use them as resources required for the transformation.

Oh god, Geoscape events, very nice!!

I will try that

You shared an example here
https://openxcom.org/forum/index.php/topic,7215.msg116753.html#msg116753

And the ruleset definition contains lots of very useful information
https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Event_Scripts

Thank you very much
« Last Edit: March 12, 2023, 02:27:51 pm by Aldorn »

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #5 on: March 12, 2023, 02:54:55 pm »
Meridian

Following your advice, I created an event system to trigger expected training tickets ("gym event")
1. An eventScript triggers a monthly event
2. This monthly event provides 5 training tickets
3. Training ticket is declared as an item that will be stored in the database (with no attributes, will see later if needed ; I made tests with some attributes but it does not change the error message)
4. Some extraStrings

Spoiler:
eventScripts:
  - type: STR_TRAINING_TICKET_MONTHLY_EVENT_SCRIPT
    facilityTriggers:
       STR_TRAINING_ROOM
    eventWeights:
      0:
        STR_TRAINING_TICKET_MONTHLY_EVENT: 100
    firstMonth: 0
    lastMonth: -1
    executionOdds: 100

events:
  - name: STR_TRAINING_TICKET_MONTHLY_EVENT
    description: STR_TRAINING_TICKET_DESCRIPTION
    everyItemList: [STR_TRAINING_TICKET,STR_TRAINING_TICKET,STR_TRAINING_TICKET,STR_TRAINING_TICKET,STR_TRAINING_TICKET]

items:
  - type: STR_TRAINING_TICKET

extraStrings:
   - type: en-US
     strings:
       STR_TRAINING_TICKET: "Lorem ipsum"
       STR_TRAINING_TICKET_MONTHLY_EVENT: "Lorem ipsum dolor sit amet"
       STR_TRAINING_TICKET_DESCRIPTION: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
   - type: fr
     strings:
       STR_TRAINING_TICKET: "Lorem ipsum"
       STR_TRAINING_TICKET_MONTHLY_EVENT: "Lorem ipsum dolor sit amet"
       STR_TRAINING_TICKET_DESCRIPTION: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."

Then I added this training ticket as required item in soldierTranformations
Spoiler:
soldierTransformation:
# Survival (Health/Reactions)
  - name: STR_TRAINING_SURVIVAL1
    listOrder: 100
    requires: []
    requiresBaseFunc: [BASEFUNC_TRAINING]
    keepSoldierArmor: true
    allowsLiveSoldiers: true
    allowedSoldierTypes: [STR_SOLDIER,STR_VETERAN_SNIPER,STR_VETERAN_GRENADIER,STR_VETERAN_WARRIOR]
    requiredPreviousTransformations: []
    forbiddenPreviousTransformations: [STR_TRAINING_SURVIVAL1,STR_TRAINING_ENDURANCE1]
    cost: 15000
    transferTime: 360
    includeBonusesForMinStats: true
    soldierBonusType: STR_SB_TRAINING_SURVIVAL1
    requiredItems: [STR_TRAINING_TICKET]

Unfortunately, it causes following error message
I tried to change the way to declare requiredItems (with or without brackets, the line after, the line after but with a minus... with same result)
Code: [Select]
F:/OXCE/OXCE V7.8 HellMod/user/mods/HellMod/Ruleset/050_Facilities_TagSoldierTransformation.rul: Error for 'STR_TRAINING_SURVIVAL1': wrong node type, expected a map at line 28
(Line 28 is always the line before the one containing requiredItems; in this case, the line 28 is soldierBonusType: STR_SB_TRAINING_SURVIVAL1; if I put requiredItems just after  name: STR_TRAINING_SURVIVAL1, the involved line will be the one containing name)


Another question (in case I solve error above): would you have any idea how I could delete each month unused training tickets
Meaning: aim is to allow a "maximum" of 5 training per month but do not store unused training tickets
Example:
  Month M: it generates 5 training tickets
  Let's assume I train 2 soldiers, so I consume 2 training tickets (and so 3 remaining training tickets)
  Month M+1: it generates 5 new training tickets
  => I would like to be able to use only 5 training tickets (and not : 8 training tickets = 5 new TT + 3 old TT)

Thanks in advance for your "science"  :D
« Last Edit: March 12, 2023, 03:06:21 pm by Aldorn »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #6 on: March 12, 2023, 03:05:29 pm »
Code: [Select]
requiredItems:
  STR_TRAINING_TICKET: 1

There is no way to steal player's items atm.

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #7 on: March 12, 2023, 03:10:08 pm »
It works, perfect :)

I will still make some attempts, then mark this post as solved if I don't find anything else to improve it

Thanks dude !!

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #8 on: March 12, 2023, 03:34:53 pm »
Another question (in case I solve error above): would you have any idea how I could delete each month unused training tickets
Meaning: aim is to allow a "maximum" of 5 training per month but do not store unused training tickets
Example:
  Month M: it generates 5 training tickets
  Let's assume I train 2 soldiers, so I consume 2 training tickets (and so 3 remaining training tickets)
  Month M+1: it generates 5 new training tickets
  => I would like to be able to use only 5 training tickets (and not : 8 training tickets = 5 new TT + 3 old TT)

Thanks in advance for your "science"  :D
I think it could be added, but as Meridian said not by stealing any thing for player, more as limit,
even could have another property "itemLimit" or some thing like this, and when it try add new item check if total do not excess current limit.
if you have 5 item in base then none will be generated, but if you have 3 then two will be given. If you have more then nothing will happen.
Question is what should count to this limit, base what get this items, or every base.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8598
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #9 on: March 12, 2023, 05:16:31 pm »
I think it could be added, but as Meridian said not by stealing any thing for player, more as limit,
even could have another property "itemLimit" or some thing like this, and when it try add new item check if total do not excess current limit.
if you have 5 item in base then none will be generated, but if you have 3 then two will be given. If you have more then nothing will happen.
Question is what should count to this limit, base what get this items, or every base.

Yeah, I quite like that.

Since events are global, I'd say the limit should be global too, for all items in all bases together.

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Suggestion] Soldier Transformation > Add a setting monthlyLimit?
« Reply #10 on: March 12, 2023, 08:27:27 pm »
I made it work

It's not perfect, main inconvenients are:
- the tickets are sent to one Xcom base (Xcom base 1)
- it's a global amount of tickets (I mean, not depending on bases having such a facility)
- the tickets have then to be transferred from base 1 to other bases to be used there
- the transfertime has a minimum of 12 hours (cannot be set to zero or even one hour)

So, finally, I created a ticket for each training type, and will provide 1 ticket per training category each month

It's ok like that, I put this suggestion as solved

Thank you very much for your help, Meridian & Yankee!

And you really do an amazing job here, so many new features and possibilities, QOL, etc. :o I love you both as much as I love SupSuper, Warboy  & Co :)