Author Topic: [Solved] Different Retaliation Missions/Deployments  (Read 6214 times)

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
[Solved] Different Retaliation Missions/Deployments
« on: August 06, 2018, 10:09:41 pm »
I discussed this topic in the past and I believe the answer I got was that the game is hardcoded against this so it can't easily be done. I had an idea though: perhaps you can change part of the mission and leave other parts unchanged. The important part I want to change is the deployment; specifically I want to be able to set in a retaliation mission which deployment it uses. All of the other parts of the base defense scenario can be left unchanged.


I don't know how the game sets up the base defense mission on the code end, but my thinking went like this:
The game selects Retaliation Mission X and you're at the point where the final UFO got past base defenses. It draws from built-in code and your save to determine the battlescape tilesets and layout. When it comes time to spawn aliens, the game checks Retaliation Mission X for a line of code declaring the final deployment set; if no response it defaults to the standard value. It then deploys the aliens from the given deployment set, and completes other functions as standard before starting the battlescape mission.
« Last Edit: February 11, 2023, 05:27:10 pm by Meridian »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #1 on: August 06, 2018, 10:22:26 pm »
This is already possible in a manner in OXCE/OXCE+; you can see many examples of this in Piratez and some in X-Com Files.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #2 on: August 06, 2018, 11:11:41 pm »
I coudn't describe it better than Reaver :)
This is exactly how it works in OXCE.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #3 on: August 07, 2018, 09:44:52 am »
Ah, I must have missed it. Thanks.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #4 on: August 07, 2018, 12:31:00 pm »
Can you explain to me how it works? I see this:
Code: [Select]
  - type: STR_ALIEN_RETALIATION_L
    missionWeights:
      0: 20
But I can't figure out what a missionWeight of 20 means??


Also, is there a way to determine, on the mission, what retaliation missions can spawn from it? Example: I have a special sectoid retaliation UFO, and I want sectoids to spawn this specific mission as retaliation, and use the special ship on the final assault.
« Last Edit: August 07, 2018, 12:34:08 pm by The Reaver of Darkness »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #5 on: August 07, 2018, 01:23:38 pm »
I discussed this topic in the past and I believe the answer I got was that the game is hardcoded against this so it can't easily be done. I had an idea though: perhaps you can change part of the mission and leave other parts unchanged. The important part I want to change is the deployment; specifically I want to be able to set in a retaliation mission which deployment it uses. All of the other parts of the base defense scenario can be left unchanged.

I don't know how the game sets up the base defense mission on the code end, but my thinking went like this:
The game selects Retaliation Mission X and you're at the point where the final UFO got past base defenses. It draws from built-in code and your save to determine the battlescape tilesets and layout. When it comes time to spawn aliens, the game checks Retaliation Mission X for a line of code declaring the final deployment set; if no response it defaults to the standard value. It then deploys the aliens from the given deployment set, and completes other functions as standard before starting the battlescape mission.

Code: [Select]
ufos:
  - type: STR_BATTLESHIP
    craftCustomDeploy: STR_BATTLESHIP_OTHER_RACES
    missionCustomDeploy: STR_BASE_DEFENSE_OTHER_RACES
    raceBonus:
      STR_SECTOID:
        craftCustomDeploy: STR_BATTLESHIP_SECTOID
        missionCustomDeploy: STR_BASE_DEFENSE_SECTOID
      STR_FLOATER:
        craftCustomDeploy: STR_BATTLESHIP_FLOATER
        missionCustomDeploy: STR_BASE_DEFENSE_FLOATER
        hitBonus: 15
      STR_MUTON:
        craftCustomDeploy: STR_BATTLESHIP_MUTON
        missionCustomDeploy: STR_BASE_DEFENSE_MUTON

Also, is there a way to determine, on the mission, what retaliation missions can spawn from it? Example: I have a special sectoid retaliation UFO, and I want sectoids to spawn this specific mission as retaliation, and use the special ship on the final assault.

Code: [Select]
alienRaces:
  - id: STR_SECTOID
    retaliationMission: STR_ALIEN_RETALIATION_2 #mission spawned after destroying a ufo.
    baseCustomDeploy: STR_ALIEN_BASE_ASSAULT_2  #override alien base default weapon deployment.
    baseCustomMission: STR_MIB_BASE             #override alien base construction
« Last Edit: August 07, 2018, 01:53:50 pm by Meridian »

Offline Tekamthi

  • Sergeant
  • **
  • Posts: 45
    • View Profile
Re: [IDEA] Different Retaliation Missions/Deployments
« Reply #6 on: August 07, 2018, 02:33:44 pm »
Can you explain to me how it works? I see this:
Code: [Select]
  - type: STR_ALIEN_RETALIATION_L
    missionWeights:
      0: 20
But I can't figure out what a missionWeight of 20 means??

I'm a little new to this, was wondering this too.. the "0" should be the mission string you want connected to this script I think, but if you only had one in the list with a weight of "20" like this (or any weight for that matter), your odds of spawning this mission are 100%, right?  ie you'd need two weighted list missions before the weight would have any effect? 

Or are these weights hard percentages? ie only one in list w/ weight 20 means 20% chance of this mission, 80% chance of going to mission table?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #7 on: August 07, 2018, 07:54:08 pm »
It's an undocumented vanilla feature from March 2015: https://github.com/SupSuper/OpenXcom/commit/98a0fa30d19b4c1e94eaca41cb33ddda620491c7

It is used to give weights to retaliation missions spawned when shooting down UFOs.
Note: other mission types are NOT affected...although original commit suggests it was supposed to work for some other mission types too... it was probably changed somewhere between 2015 and 2018 (probably almost fully replaced by mission scripts).

For example, you can have 3 different retaliation missions and give them different probability based on number of game months passed.

Code: [Select]
alienMissions:
  - type: STR_ALIEN_RETALIATION_EARLY
    missionWeights:
      0: 80
      6: 20
      12: 0
  - type: STR_ALIEN_RETALIATION_MIDGAME
    missionWeights:
      0: 20
      6: 60
      12: 20
  - type: STR_ALIEN_RETALIATION_LATE
    missionWeights:
      0: 0
      6: 20
      12: 80
« Last Edit: August 07, 2018, 08:06:32 pm by Meridian »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #8 on: August 07, 2018, 08:11:59 pm »
You spoil me, Meridian! Very thorough!  ;D
Thanks so much!

Offline Tekamthi

  • Sergeant
  • **
  • Posts: 45
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #9 on: August 07, 2018, 08:51:06 pm »
all weights must add to 100 then, inferring from example?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #10 on: August 07, 2018, 11:36:43 pm »
all weights must add to 100 then, inferring from example?

No, they can add up to anything.
I just used 100 to make it easier to understand.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #11 on: August 07, 2018, 11:45:21 pm »
Can I get some help on missionScripts? The ruleset appears to declare this much code:
Code: [Select]
  - type: recurringTerror
    missionWeights:
      0:
        STR_ALIEN_TERROR: 100
    useTable: false
    startDelay: 150

  - type: recon
    firstMonth: 1

  - type: invasion
    firstMonth: 6
for 98% of the missions in the game.

Can I get some info on all of the missions running automatically, and how I can edit them? I don't even know where to start, and X-Com Files doesn't make a very good example because it still doesn't explain what the original research, harvest, abduction, base, and infiltration missions are doing.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #12 on: August 08, 2018, 12:23:17 am »
Most of the vanilla missions do not run by mission scripts, they run by picking one from the weighted tables defined in the regions and elsewhere.  The only script that does something here is the "recurringTerror".

The "missionWeights" determines which mission this script runs: in month 0 (the first month) STR_ALIEN_TERROR has a weight of 100 (it could have been just 1 since there's no other mission), so for month 0 and all the following, this script causes STR_ALIEN_TERROR to run.  If you have more than one mission, the weights don't need to add up to 100, that's just the easiest way if you want to pick missions by percentage.

The "useTable" true/false just determines whether or not running this script should use up the pick of the mission every month from the usual vanilla mission spawning.  In this case, the terror missions run in addition to the one vanilla mission per month.

The "startDelay" is just how long into the month the mission should wait before starting; I think this is in minutes.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #13 on: August 09, 2018, 09:19:13 pm »
Thanks!

--- post merge no jutsu! ---

So how often does a region select a new mission? How would I go about making the rate of a certain mission increase later in the game?
« Last Edit: August 09, 2018, 10:02:56 pm by Solarius Scorch »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Question] [Solved] Different Retaliation Missions/Deployments
« Reply #14 on: August 09, 2018, 10:24:13 pm »
Once a month, a region and mission are selected from the "alien strategy" table.  You can see the relative weights for these in /path/to/openxcom/standard/xcom1/regions.rul and which races conduct these missions in alienMissions.rul.  As the game progresses, mission+region combinations are removed from the table when they are chosen, and when the table is completely empty, it regenerates from the ruleset file settings.  You'll notice that this means you don't really have control over which missions happen over time, only which races conduct this mission by month.

However, you can use the scripts to determine which missions are run in a given month; the missionWeights parameter allows you to create a weighted list of missions by month when this script is run, and if you have "useTable: true" on the script, the mission chosen by the script will be run instead any chosen by the alien strategy table.