Author Topic: Randomized alien equipment?  (Read 3461 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Randomized alien equipment?
« on: November 23, 2019, 06:43:29 am »
I'm trying to make it so that an alien soldier sometimes spawns with weapon (A) and sometimes with weapon (B).

So for example if an alien UFO held the following aliens:
Rank 0 - Commander
Rank 1 - Leader
Rank 2 - Engineer 
Rank 3 - Medic     
Rank 4 - Navigator
Rank 5 - Soldier
Rank 6 - Terrorist 1
Rank 7 - Terrorist 2


And there are 3 "Rank 5" Soldiers deployed, each soldier may be carrying a different weapon.

To achieve this my first thought was to use extraRandomItems: to grant that rank random weapons and leave their rank's itemSets: without weapons so the extraRandomItems: would be the sole source supplying them firearms.

In theory this would work, however only for weapons that do not require ammo as extraRandomItems: appears to only award one item from each list so unless the alien spawns with all possible ammo types their weapon will potentially be unloaded.


My other thought was to expand the number of Ranks so that there were more variants of a specific "Rank" then use lowQty, highQty & extraQty to make that enemy item set randomly appear by giving it a lowQty / highQty value of 0 with an extraQty value of X(Desired max number).

So it would look more like this:
Rank 0 - Commander
Rank 1 - Leader
Rank 2 - Engineer 
Rank 3 - Medic     
Rank 4 - Navigator
Rank 5 - Soldier
Rank 6 - Additional Soldier (A)
Rank 7 - Additional Soldier (B)
Rank 8 - Additional Soldier (C)
Rank 9 - Additional Soldier (D)
Rank 10 - Terrorist 1
Rank 11 - Terrorist 2



However if all of the soldier ranks can spawn lowQTy / highQty of 0 the UFO could be devoid of soldiers, and if I make it so each "Soldier" rank has a minimum value greater than 0 that just assures the deployment of the item set defeating the intended purpose of making it not always present.


I also considered trying to force the alien to spawn with the intended weapons using an attached weapon and the livingWeapon: setting, but my understanding is that would prevent it from accessing its inventory or dropping the weapon if the unit panicked.

The builtInWeaponSets: variable appears to be what I'm looking for as if I'm reading this correctly it will allow a randomization between several pre-defined item sets specifically referenced by that unit itself.

(builtInWeaponSets)    A set of lists of weapons this unit can come pre-equipped with. Game will pick one set "at random" (randomness comes from the current alien tech level definition). These weapons WILL appear in inventory slots (references items).

So if builtInWeaponSets: was used in combination with membersRandom: and the Rank 5 Soldier was configured to spawn either as a Sectoid soldier or a Muton soldier, builtInWeaponSets: could then be used to cause the Sectoid to spawn randomly with a Plasma Pistol or Plasma Rifle where as the Muton could be configured to only spawn with an Alien Launcher or Blaster Bomb. Do I understand this correctly?

(membersRandom)    Alternative to members. Instead of defining just a single unit type per alien rank, you can define any number of unit types here and one will be chosen randomly (each time a new unit is generated). To increase a chance of a certain unit type being selected, you can add it multiple times.


For example using builtInWeaponSets: there would be 3 different units of a Sectoid soldier with the only difference between them being the contents of the builtInWeaponSets: list:
A: Sectoid with Plasma Pistol | Plasma Pistol Clip
B: Sectoid with Plasma Rifle | Plasma Rifle Clip
C: Sectoid with Heavy Plasma  | Heavy Plasma Clip


Then membersRandom: would randomly deploy either A, B or C version of the Sectoid soldier every time a Rank 5 was placed in the UFO. So if a UFO had 4 soldiers in it they could potentially all be Rank 5 soldier but be carrying different equipment.


(Question)
Is this membersRandom: + builtInWeaponSets: the best method for setting up multiple potential loadouts for the same unit in a UFO without other aliens of the same rank sharing that randomized loadout, or is there a different way of doing this?
« Last Edit: November 23, 2019, 07:16:37 am by The Martian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Randomized alien equipment?
« Reply #1 on: November 23, 2019, 01:41:22 pm »
I probably misunderstand the objective, but if your goal is to simply increase the range of possible weapons, why not simply increase the number of item levels? For example, I have 10 in the X-Com Files.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Randomized alien equipment?
« Reply #2 on: November 24, 2019, 11:24:09 am »
If I understand correctly how alienItemLevels: + itemSets: work is that:

(1)
The possible equipment loadout for each alien Rank on the UFO is defined in the alienDeployments: itemSets: section, example:


Code: [Select]
alienDeployments:
  - type: STR_MIB_SMALL_SCOUT
    data:
      - alienRank: 5
        lowQty: 3
        highQty: 6
        dQty: 3
        percentageOutsideUfo: 100
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_PLASMA_PISTOL_CLIP
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
            - STR_PLASMA_RIFLE_CLIP
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
            - STR_HEAVY_PLASMA_CLIP
    width: 40
    length: 40
    height: 4

(2)
When a UFO mission's battlescape is generated depending how many months have passed ingame since the start of the game the corresponding line in alienItemLevels: is used to select one of 10 random values in a 10 dimensioned array. This value determines which of the itemSets: STR_ITEM_NAME groups is used.

(Or the last line in alienItemLevels: if the number of months past exceeds the number of lines written in the alienItemLevels: section.)

Code: [Select]
alienItemLevels:
  - [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
  - [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
  - [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]

So for example if it was the second month using the above code example there would be a 50% chance of it being either item level 1 or 2.

If item level 1 was selected this would translate into all Rank 5 aliens carrying 1 Plasma Rifle & 2 Clips where as if the UFO generated using item level 2 all Rank 5 aliens would be equipped with 1 Heavy Plasma & 2 Clips.



Am I correct about this or does it randomly assign each alien equipment from an item set belonging to the current item level or lower when they are placed on the battlescape?
(My understanding is they all share the same assigned item level once it has been rolled during mission generation.)


I probably misunderstand the objective, but if your goal is to simply increase the range of possible weapons, why not simply increase the number of item levels? For example, I have 10 in the X-Com Files.

As you are suggesting I agree that expanding the alienItemLevels: + itemSets: to a total of ten would add more variation, example:

Code: [Select]
alienItemLevels:
  - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

alienDeployments:
  - type: STR_MIB_SMALL_SCOUT
    data:
      - alienRank: 5
        lowQty: 3
        highQty: 6
        dQty: 3
        percentageOutsideUfo: 100
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_PLASMA_PISTOL_CLIP
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
            - STR_PLASMA_RIFLE_CLIP
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
            - STR_HEAVY_PLASMA_CLIP
          -
            - STR_SMALL_LAUNCHER
            - STR_STUN_BOMB
            - STR_STUN_BOMB
          -
            - STR_BLASTER_LAUNCHER
            - STR_BLASTER_BOMB
            - STR_BLASTER_BOMB
          -
            - STR_LASER_PISTOL
          -
            - STR_LASER_RIFLE
          -
            - STR_HEAVY_LASER
          -
            - STR_ALIEN_GRENADE
            - STR_ALIEN_GRENADE
            - STR_ALIEN_GRENADE
            - STR_ALIEN_GRENADE
          -
            - STR_LASER_PISTOL
            - STR_ALIEN_GRENADE
            - STR_ALIEN_GRENADE
    width: 40
    length: 40
    height: 4

However all aliens of each Rank will share the same equipment when the item level is selected, and if membersRandom: is used to change the alien unit type of that Rank so that the UFO could have a Sectoid or Muton soldier they will still all share the same equipment with only the unit carrying it differing.


If instead of using alienDeployments: itemSets: the units: builtInWeaponSets: variables are used and the Sectoid soldier is assigned to have a Plasma Pistol for item levels 0,1,2 and the Muton soldier is assigned to carry a Plasma Rifle for item level 0 & 1 and a heavy plasma at item level 2, then the Rank 5 itemSets: would not be shared by both the Muton and Sectoid on the same UFO.

Additionally if several versions of each unit are created with different builtInWeaponSets: like below:
Sectoid Soldier (A) With Plasma Pistol
Sectoid Soldier (B) With Plasma Pistol & Grenades
Sectoid Soldier (C) With Plasma Rifle & Grenades
Muton Soldier (A) With Plasma Rifle
Muton Soldier (B) With Heavy Plasma
Muton Soldier (C) With Blaster Bomb Launcher


Then the alienRaces: membersRandom: variables could be used to randomly place different Rank 5 units that each have a different loadout, instead of all Rank 5 units sharing the same loadout on the same UFO.

If I've read the UFOpaedia correctly each time a unit is spawned on the battlescape using membersRandom: it is randomized so there could potentially be several different Rank 5 units on the same map.

(membersRandom)    Alternative to members. Instead of defining just a single unit type per alien rank, you can define any number of unit types here and one will be chosen randomly (each time a new unit is generated). To increase a chance of a certain unit type being selected, you can add it multiple times.

(Question)
Have I misunderstood how "alienDeployments: itemSets:" "units: builtInWeaponSets:" "alienRaces: membersRandom:" function?
« Last Edit: November 24, 2019, 11:38:16 am by The Martian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Randomized alien equipment?
« Reply #3 on: November 24, 2019, 12:03:52 pm »
However all aliens of each Rank will share the same equipment when the item level is selected

This quote alone makes me think we're not on the same page.

Why would all aliens of the same rank have the same equipment on the same mission? The entire point of multiple data sets is to ensure it doesn't happen...

Well, if you do this:

Code: [Select]
alienItemLevels:
  - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

then yes, all aliens of the same rank will have the same equipment... But why would you do that?

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Randomized alien equipment?
« Reply #4 on: November 24, 2019, 12:19:40 pm »
The entire point of multiple data sets is to ensure it doesn't happen...

If I understand you correctly what you are saying is that for each individual alien unit that is spawned on the battlescape during map generation it randomly selects a number for that alien's assigned itemSets: from:
Code: [Select]
alienItemLevels:
  - [0, 1, 1, 1, 2, 2, 2, 2, 2, 2]

My mistake was that I thought it only selected a number from the alienItemLevels: list once and used that for the item level of all aliens in the current mission.
(So if the item level was rolled as 2, then it would be 2 for every alien on that UFO.)

(builtInWeaponSets)    A set of lists of weapons this unit can come pre-equipped with. Game will pick one set "at random" (randomness comes from the current alien tech level definition). These weapons WILL appear in inventory slots (references items).

The builtInWeaponSets: description on the UFOpaedia is making a lot more sense now.

Thank you for the help.
« Last Edit: November 24, 2019, 01:00:31 pm by The Martian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Randomized alien equipment?
« Reply #5 on: November 24, 2019, 03:12:52 pm »
Yes, you are correct.