aliens

Author Topic: How does the totalKillsByRace: commendation setting work?  (Read 3872 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
How does the totalKillsByRace: commendation setting work?
« on: November 24, 2021, 08:17:33 am »
I'm assuming that you can record commendation sets using totalKillsByRace: for each of the [units:] [race:] that exist.

For example it sounds like an Aquatoid Soldier & Aquatoid Medic both with their [units:] [race:] variable set to race: STR_AQUATOID would both yield +1 towards this commendation's STR_AQUATOID set when killed.

UFOpaedia Site: Ruleset Reference Nightly


I was also looking through the code for Solarius Scorch's 'The X-Com Files' mod and saw this:

Spoiler:
Code: [Select]
  - type: STR_MEDAL_RACE_KILLS_NAME #KOs by faction
    description: STR_MEDAL_RACE_KILLS_UFOPEDIA
    soldierBonusTypes: [STR_MEDAL_RACE_KILLS_1, STR_MEDAL_RACE_KILLS_2, STR_MEDAL_RACE_KILLS_3, STR_MEDAL_RACE_KILLS_4, STR_MEDAL_RACE_KILLS_5, STR_MEDAL_RACE_KILLS_6, STR_MEDAL_RACE_KILLS_7, STR_MEDAL_RACE_KILLS_8, STR_MEDAL_RACE_KILLS_9, STR_MEDAL_RACE_KILLS_10]
    sprite: 3
    criteria:
      totalKillsByRace: [15, 25, 40, 60, 80, 100, 150, 200, 350, 500]

But I didn't see how you define soldierBonusTypes: for each individual type of race in the game using totalKillsByRace: as the criteria.


Is it that you need to define each as their own separate commendation?

For example something like this:

Code: [Select]
  - type: STR_COMMENDATION_AQUATOID_RACE_KILLS
    description: STR_COMMENDATION_AQUATOID_RACE_KILLS_UFOPEDIA
    soldierBonusTypes: [STR_AQUATOID_RACE_KILLS_1, STR_AQUATOID_RACE_KILLS_2, STR_AQUATOID_RACE_KILLS_3, STR_AQUATOID_RACE_KILLS_4, STR_AQUATOID_RACE_KILLS_5, STR_AQUATOID_RACE_KILLS_6, STR_AQUATOID_RACE_KILLS_7, STR_AQUATOID_RACE_KILLS_8, STR_AQUATOID_RACE_KILLS_9, STR_AQUATOID_RACE_KILLS_10]
    sprite: 3
    criteria:
       -
           1: ["STR_AQUATOID_SOLDIER", "STATUS_DEAD"]
       -
           1: ["STR_AQUATOID_SQUAD_LEADER", "STATUS_DEAD"]
       -
           1: ["STR_AQUATOID_TECHNICIAN", "STATUS_DEAD"]
       -
           1: ["STR_AQUATOID_MEDIC", "STATUS_DEAD"]
       -
           1: ["STR_AQUATOID_NAVIGATOR", "STATUS_DEAD"]
       -
           1: ["STR_AQUATOID_COMMANDER", "STATUS_DEAD"]
Code: [Select]
  - type: STR_COMMENDATION_TASOTH_RACE_KILLS
    description: STR_COMMENDATION_TASOTH_RACE_KILLS_UFOPEDIA
    soldierBonusTypes: [STR_TASOTH_RACE_KILLS_1, STR_TASOTH_RACE_KILLS_2, STR_TASOTH_RACE_KILLS_3, STR_TASOTH_RACE_KILLS_4, STR_TASOTH_RACE_KILLS_5, STR_TASOTH_RACE_KILLS_6, STR_TASOTH_RACE_KILLS_7, STR_TASOTH_RACE_KILLS_8, STR_TASOTH_RACE_KILLS_9, STR_TASOTH_RACE_KILLS_10]
    sprite: 3
    criteria:
       -
           1: ["STR_TASOTH_SOLDIER", "STATUS_DEAD"]
       -
           1: ["STR_TASOTH_SQUAD_LEADER", "STATUS_DEAD"]


« Last Edit: November 24, 2021, 08:35:43 am by The Martian »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #1 on: November 25, 2021, 11:15:17 pm »
It's probably based on this value:
Code: [Select]
  - type: STR_SECTOID_SOLDIER
    race: STR_SECTOID #<--
    rank: STR_LIVE_SOLDIER

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #2 on: November 26, 2021, 01:37:13 am »
It's probably based on this value:
Code: [Select]
  - type: STR_SECTOID_SOLDIER
    race: STR_SECTOID #<--
    rank: STR_LIVE_SOLDIER

That is what I believe as well. I was not able to properly convey my meaning with [units:] [race:] as I'm still learning the terminology:
For example it sounds like an Aquatoid Soldier & Aquatoid Medic both with their [units:] [race:] variable set to race: STR_AQUATOID would both yield +1 towards this commendation's STR_AQUATOID set when killed.

I still can't figure out how to access each of the individual tracked alien race: values stored by totalKillsByRace: to award the player different bonuses for Tasoth, Aquatoid, Lobsterman, etc kills. Does this variable not provide this ability?



I've continued experimenting with commendations and have yet to meet with success.

Here are my two most recent attempts. Both produce different error messages and fail to load.

(#1)
The first uses killsWithCriteriaCareer: to award medal tiers for its commendation at 1, 2, 3, 4 & 5 total aquatoid race kills over that soldiers entire career.

Code: [Select]
# [=] Kills By Race (Aquatoid) [=]
  - type: STR_COMMENDATION_AQUATOID_RACE_KILLS
    description: STR_COMMENDATIONS_TEST
    sprite: 1
    criteria:
      killsWithCriteriaCareer: [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]
    killCriteria:
      -
        1: ["STR_AQUATOID_SOLDIER", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
        1: ["STR_AQUATOID_SQUAD_LEADER", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
        1: ["STR_AQUATOID_TECHNICIAN", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
        1: ["STR_AQUATOID_MEDIC", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
        1: ["STR_AQUATOID_NAVIGATOR", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
        1: ["STR_AQUATOID_COMMANDER", "FACTION_HOSTILE", "STATUS_DEAD"]

This produces this error message when trying to launch OpenXcom:
"wrong node type, expected a list at line 51" which is the line with this code on it:


(#2)
The second attempt is based on code I saw inside Solarius Scorch's 'The X-Com Files' mod for entries using the killsWithCriteriaCareer: variable.

I do not understand why but these use " -[1, ":
Code: [Select]
    killCriteria:
      -
         - [1, ["OBJECT", "OBJECT", "OBJECT"]

instead of how it is described in the UFOpaedia - Ruleset Reference " 1: ":
Code: [Select]
   killCriteria:
       -
           1: ["OBJECT", "OBJECT", "OBJECT"]


Code: [Select]
# [=] Kills By Race (Aquatoid) [=]
  - type: STR_COMMENDATION_AQUATOID_RACE_KILLS
    description: STR_COMMENDATIONS_TEST
    sprite: 1
    criteria:
      killsWithCriteriaCareer: [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]
    killCriteria:
      -
         - [1, ["STR_AQUATOID_SOLDIER", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
         - [1, ["STR_AQUATOID_SQUAD_LEADER", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
         - [1, ["STR_AQUATOID_TECHNICIAN", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
         - [1, ["STR_AQUATOID_MEDIC", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
         - [1, ["STR_AQUATOID_NAVIGATOR", "FACTION_HOSTILE", "STATUS_DEAD"]
      -
         - [1, ["STR_AQUATOID_COMMANDER", "FACTION_HOSTILE", "STATUS_DEAD"]


This produces this error message when trying to launch OpenXcom:
"error at line 85, column 7: illegal block entry" which is the line with this code on it:



For convenience I've attached two example .rul files with the above commendations code in them to this post.
« Last Edit: November 26, 2021, 01:47:56 am by The Martian »

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #3 on: November 26, 2021, 06:21:28 pm »
Your second example does not work because the brackets are unbalanced.
Per criteria you have two `[` but only one `]`. Adding closing brackets to each line starting with `- [1,` should fix the error.

As for the rest of your post: My knowledge of that part is too limited, cannot help with that.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #4 on: November 27, 2021, 09:03:11 am »
Thank you that stopped the crash.

I placed the end bracket after the second set of brackets and OpenXcom now loads successfully.




However the medal is not being awarded when Aquatoids are killed during combat so I'm still doing something incorrectly.

I double checked the unit name and it should be correct.

But when an Aquatoid (Soldier) on the enemy faction is killed no commendation is assigned to the soldier.
Code: [Select]
["STR_AQUATOID_SOLDIER", "FACTION_HOSTILE", "STATUS_DEAD"]
I also check the soldier's combat diary entry after the mission and it does display that they killed Aquatoids during the mission so it should have triggered the commendation.


UFOpaedia Site: Ruleset Reference Nightly
Spoiler:

The only thing I think that I'm doing differently compared to the UFOpaedia Site's example is not adding the alien's [units:] [rank:] variable to the killCriteria: list.

I'll test it with the rank: variable added and post the result in a minute...
« Last Edit: November 27, 2021, 09:08:33 am by The Martian »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #5 on: November 27, 2021, 09:18:19 am »
I just tried it again with each Aquatoid's rank added to the killCriteria: list and the medal was still not being awarded.





Spoiler:

Spoiler:

I've attached the updated commendations.rul to this post.
« Last Edit: November 27, 2021, 09:29:55 am by The Martian »

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #6 on: November 27, 2021, 04:26:23 pm »
Based on assumptions (since i do not know your testing procedure).

One possible reason the medal is not visible on those screens is that the commendation rule was not loaded the moment you killed the aquatoid (e.g. you loaded an old save game to check the screen).
To put in other words:
Commendations are only awarded (checked) the moment you kill an enemy, they cannot be awarded for conditions met in the past.

At least that seemed to be the case last time i glanced over that part of the (oxc) code.



Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #7 on: November 27, 2021, 05:35:04 pm »
Commendations are only awarded (checked) the moment you kill an enemy, they cannot be awarded for conditions met in the past.

Commendations are awarded during debriefing, and most of them can be awarded for conditions met in the past.

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #8 on: November 27, 2021, 06:16:59 pm »
Good thing you corrected me, seems my memory was flawed on that part.

From your correction it looks like the basic idea seem to hold:
In order to see the results of newly defined commendation rules one needs to at least make it to the debriefing of a mission. Perhaps even with the correct soldier (not trusting my memory here)?
Loading an old save and just looking at the commendations through the Base->Soldiers->Commendation route will not work.


Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #9 on: November 27, 2021, 06:23:41 pm »
I didn't read the original post so I'm not in the picture, but what you just said is true.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: How does the totalKillsByRace: commendation setting work?
« Reply #10 on: November 28, 2021, 10:38:02 am »
For each example I've posted in this thread my method of testing has been to start a new game from scratch and shoot down the first alien sub that appears which is usually Aquatoid and then play through that mission.

I think that I've got it working now, the medal is successfully being awarded after combat.

It appears you can't use the [units:] [type:] variable. Instead the [units:] [race:] and [units:] [rank:] variables are used.

Code: [Select]
commendations:

# [=] Kills By Race (Aquatoid) [=]
  - type: STR_COMMENDATION_AQUATOID_RACE_KILLS
    description: STR_COMMENDATIONS_TEST
    sprite: 1
    criteria:
      killsWithCriteriaCareer: [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]
    killCriteria:
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_SOLDIER", "FACTION_HOSTILE", "STATUS_DEAD"]]
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_SQUAD_LEADER", "FACTION_HOSTILE", "STATUS_DEAD"]]
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_TECHNICIAN", "FACTION_HOSTILE", "STATUS_DEAD"]]
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_MEDIC", "FACTION_HOSTILE", "STATUS_DEAD"]]
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_NAVIGATOR", "FACTION_HOSTILE", "STATUS_DEAD"]]
      -
         - [1, ["STR_AQUATOID", "STR_LIVE_COMMANDER", "FACTION_HOSTILE", "STATUS_DEAD"]]

Here is the working version of the .rul file:
commendations.rul





I would still like to know why The X-Com Files code and the UFOpaedia code for commendations use different formatting. (Is the UFOpaedia example out of date?)

Example, note that the " 1: " is bracketed in The X-Com Files and is preceded by a " - " but not in the UFOpaedia example:

(UFOpaedia)
Code: [Select]
   killCriteria:
       -
           1: ["STR_SECTOPOD_TERRORIST", "STR_LIVE_TERRORIST", "STATUS_DEAD", "BT_GRENADE"]

(The X-Com Files)
Code: [Select]
    killCriteria:
      -
         - [1, ["STR_GRENADE", "FACTION_HOSTILE", "STATUS_DEAD"]]


« Last Edit: November 28, 2021, 04:13:29 pm by The Martian »