aliens

Author Topic: [DONE][Request] Support for non-point mission site areas  (Read 3164 times)

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
[DONE][Request] Support for non-point mission site areas
« on: December 30, 2021, 11:29:47 am »
EDIT: another related topic available since OXCE v7.9: [DONE][Suggestion] Aliens should build a base where the (final) UFO lands: https://openxcom.org/forum/index.php/topic,10860.0.html
--


In OpenXcom, all site type missions (the ones with `objective: 3`) work only with point areas (representing cities).

Since OXCE v7.3, it is now possible to use also non-point (i.e. rectangular) areas and the exact mission site coordinates will be chosen randomly from that rectangle area.

Please note that for mission sites spawned directly, the entire area is considered valid and no additional checks are performed:
- no check for ocean texture
- no check for fake underwater texture
- no check for being inside the region

For mission sites spawned from a landed UFO (only since OXCE v7.3.3), there are additional checks performed if `objectiveOnTheLandingSite: true` (see below)
- check for ocean texture is done
- check for fake underwater texture is done
- but the check for being inside the region is not done (intentionally)
Note that if a valid landing site is not found after 100 random attempts, UFO will still land (on water or invalid texture).


More technical details below, just copypasted from the source code comments:


// -----------------------------------------------------------
// Summary of mission site spawning algorithms (objective: 3)
// -----------------------------------------------------------

// Type 1:
// - no UFOs involved
// - only 1 wave
// - the wave specifies the alien deployment directly (e.g. `ufo: STR_ARTIFACT_SITE_P1 # spawn this site directly`)
// - example (1): STR_ALIEN_ARTIFACT (TFTD)
// Support for non-point areas: yes, without any additional ruleset changes required

// Type 2:
// - no UFOs involved
// - only 1 wave
// - the wave does NOT specify the alien deployment directly (e.g. `ufo: dummy #don't spawn a ufo, we only want the site`)
//   -> option A: alien deployment is chosen randomly = from the area's texture definition
//   -> option B: alien deployment is specified by the mission's `siteType` (overrides option A if both are defined)
// - example (2A): STR_ALIEN_SHIP_ATTACK (TFTD)
// - example (2B): none in vanilla, only mods
// Support for non-point areas: yes, without any additional ruleset changes required

// Type 3:
// - with UFOs waves
// - only 1 wave with `objective: true`
// - the wave does NOT specify the alien deployment (because it already specifies the UFO type)
//   -> option A: alien deployment is chosen randomly = from the area's texture definition
//   -> option B: alien deployment is specified by the mission's `siteType` (overrides option A if both are defined)
// - example (3A): STR_ALIEN_SURFACE_ATTACK (TFTD)
// - example (3B): none in vanilla, only mods
// Support for non-point areas: yes, but it is recommended to use one more wave attribute: `objectiveOnTheLandingSite: true`
//   -> false: UFO always lands in the top-left corner of the area; site spawns randomly inside the area
//   ->  true: UFO lands randomly inside the area; site spawns exactly on the UFO landing site



Minimum required OXCE version for non-point areas:
------------------------------------------
since OXCE v6.8: support for 2a and partially 3a
since OXCE v7.2.1: support for 3b and 2b, full support for 3a
since OXCE v7.2.2: support for 1

since OXCE v7.3: support for old save conversion (i.e. older saves can be loaded even if modders remove/delete technical mission regions used previously... for example XcomFiles v2.2 and higher)
since OXCE v7.3.3: support for checks for valid land point for site spawns by a landed UFO



Don't hesitate to ask if unclear.


PS: also when defining areas in your mission zones, keep each individual mission zone either with 100% point areas or 100% non-point areas... don't mix them (in some uncommon cases, this will lead to unexpected behavior and/or crashes)
« Last Edit: April 22, 2023, 09:08:07 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #1 on: January 04, 2022, 06:03:07 pm »
reserved

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #2 on: February 12, 2022, 03:04:01 pm »
I guess I'm missing some point of the change. Defining the areas for terror-alike missions is great, but I got this:
Code: [Select]
[12-02-2022_16-00-17] [WARN] Mixed area types (point vs non-point), region: RESISTANCE_FARM_START_ZONE, zone: 0, area: 2
[12-02-2022_16-00-17] [WARN] Mixed area types (point vs non-point), region: RESISTANCE_FARM_START_ZONE, zone: 0, area: 5
[12-02-2022_16-00-17] [WARN] Mixed area types (point vs non-point), region: RESISTANCE_SCIENTIST, zone: 0, area: 5

So what? It looks like it still working for me... Output is not clear, do I need to remove points?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #3 on: February 12, 2022, 03:33:20 pm »
You can use it, but I don't guarantee it will always work.

PS: also when defining areas in your mission zones, keep each individual mission zone either with 100% point areas or 100% non-point areas... don't mix them (in some uncommon cases, this will lead to unexpected behavior and/or crashes)

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #4 on: February 12, 2022, 04:54:12 pm »
But can you explain what are those cases?

And also, probably I just don't get how mission zones works for terror-like missions. Those regions are used only in one mission, here is a syntax for it:

Code: [Select]
  - type: RESISTANCE_SCIENTIST #FIXME add more nodes
    missionZones:
      -
        - [12.36, 16.56, -62.81, -61.09, -6]
        - [39.21, 45.82, -53.18, -51.39, -6]
        - [54.49, 58.75, -59.27, -57.66, -6]
        - [97.42, 105.42, -55.86, -53.78, -6]
        - [283.84, 286.55, -49.06, -46.41, -6]
        - [295.38, 295.38, -45.2, -45.2, -6]
        - [233.73, 241.01, -54.72, -50.6, -6]
        - [272.3038, 282.3038, -40.27409, -38.12594, -6]
Do I need to make it like this?
Code: [Select]
  - type: RESISTANCE_SCIENTIST #FIXME add more nodes
    missionZones:
      -
        - [12.36, 16.56, -62.81, -61.09, -6]
        - [39.21, 45.82, -53.18, -51.39, -6]
        - [54.49, 58.75, -59.27, -57.66, -6]
        - [97.42, 105.42, -55.86, -53.78, -6]
        - [283.84, 286.55, -49.06, -46.41, -6]
        - [233.73, 241.01, -54.72, -50.6, -6]
        - [272.3038, 282.3038, -40.27409, -38.12594, -6]
      -
        - [295.38, 295.38, -45.2, -45.2, -6]

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #5 on: February 12, 2022, 05:12:32 pm »
But can you explain what are those cases?

No, I cannot explain those cases properly, I don't understand them fully myself. Thus the warning.

One place where it could fail is for example this: https://github.com/MeridianOXC/OpenXcom/blob/oxce-plus/src/Savegame/AlienMission.cpp#L1165

Code: [Select]
if (region.getMissionZones().at(zone).areas.at(0).isPoint()) // if a UFO wants to land on a city, let it.
{
pos = region.getRandomPoint(zone);
}

It checks only the first entry... and assumes that all other entries are of the same type.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #6 on: February 12, 2022, 05:15:22 pm »
And also, probably I just don't get how mission zones works for terror-like missions. Those regions are used only in one mission, here is a syntax for it:

No, you don't need to split them into 2 zones.

Just change the point area into a tiny rectangle area, that's all.
Or remove the point area.

For example change:

Code: [Select]
[295.38, 295.38, -45.2, -45.2, -6]

into this:

Code: [Select]
[295.38, 295.39, -45.2, -45.19, -6]
« Last Edit: February 12, 2022, 05:18:01 pm by Meridian »

Offline Finnik

  • Commander
  • *****
  • Posts: 508
  • Finnik#0257
    • View Profile
Re: [DONE][Request] Support for non-point mission site areas
« Reply #7 on: February 12, 2022, 07:15:05 pm »
Ok, I got your point, thanks!