OpenXcom Forum

Modding => Work In Progress => Topic started by: robin on June 16, 2014, 10:44:13 pm

Title: Can someone explain how alien missions are generated?
Post by: robin on June 16, 2014, 10:44:13 pm
regions:
  - type: SOMEREGION
    missionWeights:

alienMissions:
    [...]
    waves:
        count:
        timer:


I tried different values but I can't figure it out, I have to put "ridiculous" values (like 'missionWeights: STR_MISSION: 250') to get the mission generated with some frequency. And even then I seem to get no mission of that kind on the first month, but lots on the second which seems strange to me (tested with hyper-waver decoder).
(If a bit more background is needed, I'm actually speaking about the STR_MIB_COVERUP mission form my men in black mod. With the current values it seems it almost never gets generated).

Might be that missions on the same ufo trajectory gets "canceled" if there is already one ongoing?
If someone could clarify a bit it could be helpful.

Thanks
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on June 16, 2014, 11:12:29 pm
the first mission is always alien_research ..
iirc you get one terror per month
but i cant say how many other missions you get in the first month
Title: Re: Can someone explain how alien missions are generated?
Post by: Warboy1982 on June 17, 2014, 12:11:07 am
month 1: one alien research mission, one terror mission. shooting down UFOs may trigger a retaliation mission.
month 2: one randomly selected mission, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 6: two randomly selected missions, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 12-ish: two randomly selected missions, one terror mission, one alien retaliation mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
Title: Re: Can someone explain how alien missions are generated?
Post by: robin on June 17, 2014, 12:47:16 am
month 1: one alien research mission, one terror mission. shooting down UFOs may trigger a retaliation mission.
month 2: one randomly selected mission, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 6: two randomly selected missions, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 12-ish: two randomly selected missions, one terror mission, one alien retaliation mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
Ok, I thought it just randomly selected and executed one wave, and the mission was already over.

If I try to describe the whole process, it's actually like this:

- a region is randomly selected;
  the only factor influencing this choice is the "regionWeight" entry.

- mission STR_ALIEN_BUKKAKE is randomly selected;
  the only factor influencing this choice is "missionWeight" for the mission in the selected region.

- after 'timer', the first listed wave is executed, and the related 'count' ufos are spawned;
- the ufo (or ufos) goes over its 'trajectory' until it reaches the exit point (last coordinate of trajectory);
- the first wave is over;
- after 'timer', the second listed wave is executed, and the related 'count' ufos are spawned;
- the ufo (or ufos) goes over its 'trajectory' until it reaches the exit point (last coordinate of trajectory);
- the second wave is over;
(..and so on, in descending order, until it gets at the bottom of the list of waves for the STR_ALIEN_BUKKAKE mission).

- the mission then is over;
       if the month is not over: it waits the end of the month and then it starts the whole process from the beginning;
       if the month already switched to the next: it immediately re-starts the process.

?
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on June 17, 2014, 01:05:24 am
the missions are generated at start
take a look at a save file you will find something like this
Code: [Select]
alienStrategy:
  regions:
    STR_ANTARCTICA: 4
    STR_SOUTHERN_AFRICA: 8
    STR_NORTH_AMERICA: 18
    STR_SOUTH_AMERICA: 10
    STR_EUROPE: 16
...
  possibleMissions:
    - region: STR_ANTARCTICA
      missions:
        STR_ALIEN_BASE: 35
        STR_ALIEN_RESEARCH: 25
    - region: STR_ARCTIC
      missions:
        STR_ALIEN_BASE: 35
        STR_ALIEN_RESEARCH: 25
    - region: STR_AUSTRALASIA
      missions:
        STR_ALIEN_BASE: 16
        STR_ALIEN_HARVEST: 11
        STR_ALIEN_ABDUCTION: 4
      region: STR_EUROPE
    - region: STR_NORTH_AFRICA
      missions:
        STR_ALIEN_RESEARCH: 8
        STR_ALIEN_ABDUCTION: 8
...
the regions part shows the likelihood what target-region is selected for the next mission
within the region the number show the likelyhood of a mission within this region
if a region/mission combo is selscted it will be deleted from the list
if all missione are done the list will be newly generated - so if you add a mod with new mission you need you play some time (iirc mid 2000?) until the list is empty and is regenerated with the new missions
i hope the devs correct me i if i am wrong
Title: Re: Can someone explain how alien missions are generated?
Post by: Warboy1982 on June 17, 2014, 01:05:33 am
once the last ufo from the last wave of the mission has been removed from play, the mission ends.
completely regardless of the time of month. when i say "missions from the previous months continue" i mean that literally, any missions that haven't ended continue until they end.
once a mission has ended, that particular mission/region combination won't pop up again (except terror, retaliation, supply and infiltration)

what falko stated is correct, but the caveat about waiting until 2000 only applies to saved games, not new ones.
Title: Re: Can someone explain how alien missions are generated?
Post by: Solarius Scorch on June 17, 2014, 01:52:04 am
once a mission has ended, that particular mission/region combination won't pop up again (except terror, retaliation, supply and infiltration)

Warboy, does it mean that once aliens complete (or fail to complete) a, say, Alien Base mission in Europe, they will never undertake this mission again, even if the player blows up the base or prevents the base from being built at all?
Title: Re: Can someone explain how alien missions are generated?
Post by: Warboy1982 on June 17, 2014, 02:06:15 am
until the mission reset in 2000, yes, although countries signing pacts from infiltration (which continues indefinitely) also generate bases
Title: Re: Can someone explain how alien missions are generated?
Post by: Solarius Scorch on June 17, 2014, 04:32:07 am
until the mission reset in 2000, yes, although countries signing pacts from infiltration (which continues indefinitely) also generate bases

Clever. I never suspected the game is so complex.

I wonder if this feature can somehow be highlighted as part of the glamour/tactics... :)
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on June 20, 2014, 04:12:31 pm
month 1: one alien research mission, one terror mission. shooting down UFOs may trigger a retaliation mission.
month 2: one randomly selected mission, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 6: two randomly selected missions, one terror mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.
repeat until:
month 12-ish: two randomly selected missions, one terror mission, one alien retaliation mission, missions from previous months continue. shooting down UFOs may trigger a retaliation mission.

I'm going to make a wiki page explaining how the Strategic AI works to include this info.

Are you guys thinking of allowing this part to be costumized?
Title: Re: Can someone explain how alien missions are generated?
Post by: Warboy1982 on June 20, 2014, 06:03:27 pm
uh, possibly?
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on June 20, 2014, 07:03:49 pm
uh, possibly?

My question came out of curiosity rather than need. :)

There are also a few things I'm curious about:

      - ufo: STR_MEDIUM_SCOUT
        count: 1
        trajectory: P1
        timer: 15000
      - ufo: STR_LARGE_SCOUT
        count: 1
        trajectory: P1
        timer: 9600
      - ufo: STR_TERROR_SHIP
        count: 1
        trajectory: P0
        timer: 12000
      - ufo: STR_TERROR_SHIP
        count: 1
        trajectory: P7
        timer: 9000

From my recollection of the original game, you'd get first a scout, then the Terror Ship and there would be a chance that the scout failed to pick a target or that it would be shot down. I'm guessing that the first 3 UFOs listed are scouts and the final UFO is the one that actually performs the terror attack, if one of the scouts picks a target, but they fail, does the last UFO still gets generated?

And the value after timer, is it minutes?
Title: Re: Can someone explain how alien missions are generated?
Post by: Solarius Scorch on June 20, 2014, 07:07:44 pm
The first UFO is hard-coded to be an Alien Research mission with Sectoids. Therefore I think it works outside of the normal pattern.
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 03:33:45 am
until the mission reset in 2000

Can anyone point me to where in the code this is located? I've been collecting all the info about Alien Mission Generation and looking at GeoscapeState.
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on July 24, 2014, 03:45:38 am
there is no fixed timer
there is the "possibleMissions"-list in the save that is generated at start of the game
if the list is empty after all mission are executed the list will be newly generated
my best guess in the code would be in AlienStrategy::chooseRandomRegion
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 03:59:54 am
there is no fixed timer
there is the "possibleMissions"-list in the save that is generated at start of the game
if the list is empty after all mission are executed the list will be newly generated
my best guess in the code would be in AlienStrategy::chooseRandomRegion

Well, if the 2000 number is merely an estimate then I'd advance it. I've been compiling all the mission weights to compare them and see the most probable missions and there are 51 possible Base, Abductions, Infiltration, Research and Harvest missions. On the first year you have 5 (1 mission until June) + 14 or 19 missions. On 2000 you get a total of 24 missions, leaving 8 for 2001.
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on July 24, 2014, 04:51:37 am
each region only gets at most one mission type
so there are no two harvest missions in europe only one (till mission reset) - the race assignment is done when the mission goes from possible to "real"
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 05:10:23 am
each region only gets at most one mission type
so there are no two harvest missions in europe only one (till mission reset) - the race assignment is done when the mission goes from possible to "real"

Warboy said differently

once a mission has ended, that particular mission/region combination won't pop up again (except terror, retaliation, supply and infiltration)

But if it is as you say, then it doesn't make sense either. There are only 12 regions that have UFO missions assigned so the list would have to refill still on 1999 since the first year has 19 missions (Base, Infiltration, etc.)
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on July 24, 2014, 05:23:58 am
warboy told me that the race is assigned at mission creation (possible mission != creation)
new game -> save -> editor
Code: [Select]
  possibleMissions:
    - region: STR_ANTARCTICA
      missions:
        STR_ALIEN_BASE: 35
        STR_ALIEN_RESEARCH: 25
    - region: STR_ARCTIC
      missions:
        STR_ALIEN_BASE: 35
        STR_ALIEN_RESEARCH: 25
    - region: STR_AUSTRALASIA
      missions:
        STR_ALIEN_ABDUCTION: 4
        STR_ALIEN_BASE: 16
        STR_ALIEN_HARVEST: 11
        STR_ALIEN_INFILTRATION: 8
        STR_ALIEN_RESEARCH: 15
    - region: STR_CENTRAL_ASIA
      missions:
        STR_ALIEN_ABDUCTION: 6
        STR_ALIEN_BASE: 8
        STR_ALIEN_HARVEST: 5
        STR_ALIEN_INFILTRATION: 10
        STR_ALIEN_RESEARCH: 5
    - region: STR_EUROPE
      missions:
        STR_ALIEN_ABDUCTION: 15
        STR_ALIEN_BASE: 6
        STR_ALIEN_HARVEST: 10
        STR_ALIEN_INFILTRATION: 20
        STR_ALIEN_RESEARCH: 10
    - region: STR_INDIAN_OCEAN
      missions: ~
    - region: STR_NORTH_AFRICA
      missions:
        STR_ALIEN_ABDUCTION: 8
        STR_ALIEN_BASE: 19
        STR_ALIEN_HARVEST: 8
        STR_ALIEN_INFILTRATION: 8
        STR_ALIEN_RESEARCH: 8
    - region: STR_NORTH_AMERICA
      missions:
        STR_ALIEN_ABDUCTION: 20
        STR_ALIEN_BASE: 20
        STR_ALIEN_HARVEST: 17
        STR_ALIEN_INFILTRATION: 20
        STR_ALIEN_RESEARCH: 14
    - region: STR_NORTH_ATLANTIC
      missions: ~
    - region: STR_PACIFIC
      missions:
        STR_ALIEN_BASE: 27
        STR_ALIEN_RESEARCH: 15
    - region: STR_SIBERIA
      missions:
        STR_ALIEN_ABDUCTION: 4
        STR_ALIEN_BASE: 9
        STR_ALIEN_RESEARCH: 6
    - region: STR_SOUTHERN_AFRICA
      missions:
        STR_ALIEN_ABDUCTION: 8
        STR_ALIEN_BASE: 9
        STR_ALIEN_HARVEST: 8
        STR_ALIEN_INFILTRATION: 8
    - region: STR_SOUTH_AMERICA
      missions:
        STR_ALIEN_ABDUCTION: 12
        STR_ALIEN_BASE: 22
        STR_ALIEN_HARVEST: 24
        STR_ALIEN_INFILTRATION: 18
        STR_ALIEN_RESEARCH: 10
    - region: STR_SOUTH_ATLANTIC
      missions: ~
    - region: STR_SOUTH_EAST_ASIA
      missions:
        STR_ALIEN_ABDUCTION: 21
        STR_ALIEN_BASE: 8
        STR_ALIEN_HARVEST: 13
        STR_ALIEN_INFILTRATION: 13
        STR_ALIEN_RESEARCH: 8
there are 48 missions in the list
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 05:41:31 am
there are 48 missions in the list

48 is correct, miscounted there.

Let's see if Warboy can clear this out. I'm curious if the resetting of the alien missions happens when there is none left (which make them more predictable) or if it resets before that.

This is also interesting:
Code: [Select]
if (monthsPassed >= 14 - (int)(_game->getSavedGame()->getDifficulty())
|| _game->getSavedGame()->isResearched("STR_THE_MARTIAN_SOLUTION"))
{
newRetaliation = true;
}

Essentially you get the additional retaliation mission is added either by reaching the end of 1999/2000 (month depends on the difficulty level) or by researching The Martian Solution.
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 05:43:31 pm
Being going through the code and I think I found the function that refills the mission pool at AlienStrategy, if I'm reading this correctly:

Code: [Select]
const std::string AlienStrategy::chooseRandomRegion(const Ruleset *rules)
{
std::string chosen = _regionChances.choose();
if (chosen == "")
{
init(rules);
chosen = _regionChances.choose();
}
assert ("" != chosen);
return chosen;
}

The game removes a region from the list of possible choices  by setting the regionChance to 0 once there are no more missions available. But when the choice for a region turns empty, it resets the Mission and Region weight values on the ruleset before choosing again.

If this is correct than it means that the mission list is refreshed around 2001 and not 2000.
Title: Re: Can someone explain how alien missions are generated?
Post by: Falko on July 24, 2014, 06:23:44 pm
my best guess in the code would be in AlienStrategy::chooseRandomRegion
your guess is as good as mine :)
not sure how many missions are there per year or if the "emptying" happens in nov 00 or mar 01 - if you add mods with new missions its further away
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on July 24, 2014, 06:36:56 pm
your guess is as good as mine :)
not sure how many missions are there per year or if the "emptying" happens in nov 00 or mar 01 - if you add mods with new missions its further away

This is what determines the number of random missions:

Code: [Select]
determineAlienMissions();
if (monthsPassed > 5)
determineAlienMissions();

For the first 5 months you get Alien Research + 4 random missions, for a total of 5 missions. In addition you also get Alien Terror once a month and, by the end of 1999 and beginning of 2000 (depends on the difficulty level) a Retaliation mission is added.

Starting on the 6th month you get 2 random missions per month, so 14 missions for 7 remaining months, for a yearly total of 19 missions in 1999. And on 2000, that's 24 random missions, with 5 missions remaining for 2001.

Of course, all of this applies only to vanilla since adding new random missions will push forward the March 2001 date.
Title: Re: Can someone explain how alien missions are generated?
Post by: richardhead on February 07, 2019, 11:06:05 pm
I would like to slow down alien activity. Toward the end of the game im shooting down 3-10 ships A DAY!  I can barely get time to pass at all just shooting down ships, if I tried to recover every ship I shot down the game would take forever!
Title: Re: Can someone explain how alien missions are generated?
Post by: Meridian on February 07, 2019, 11:45:40 pm
I would like to slow down alien activity. Toward the end of the game im shooting down 3-10 ships A DAY!  I can barely get time to pass at all just shooting down ships, if I tried to recover every ship I shot down the game would take forever!

it's the game telling you to stop messing around and go to cydonia already...
Title: Re: Can someone explain how alien missions are generated?
Post by: Hobbes on February 07, 2019, 11:46:51 pm
I would like to slow down alien activity. Toward the end of the game im shooting down 3-10 ships A DAY!  I can barely get time to pass at all just shooting down ships, if I tried to recover every ship I shot down the game would take forever!

A couple of tips:
* You don't really need to expand your base network to cover the entire globe. You can win by building just a couple of additional bases, or none at all (the 1 base challenge). That way, you don't detect so many UFOs
* You don't get any penalty if you shoot down the UFO and then don't assault it afterwards. You already got the score from shooting it down, so unless you're desperate for cash or want to train rookies, let the crashed UFOs disappear