Author Topic: Mission Zones, UFOTrajectories and Rulesets - How it works?  (Read 7087 times)

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Mission Zones, UFOTrajectories and Rulesets - How it works?
« on: October 03, 2014, 11:26:13 pm »
I'm having problems understanding a bit how the values on the ruleset are related/used regarding the actual missionZones/UFOTrajectories. Maybe the issue is how it is explained on the wiki (or the lack of precise explanation).

The Ruleset Reference on the wiki states this regarding UFOTrajectory:

Quote
List of waypoints for the UFO to traverse, defined as [zone, altitude, speed].
zone: Globe zone where the waypoint is located.
altitude: UFO altitude after reaching this waypoint:
0 - Ground
1 - Very Low
2 - Low
3 - High
4 - Very High
speed: UFO speed after reaching this waypoint, as a percentage (0-100%) of its maximum speed.

So, to figure it out, I've given my initial base a Hyperwave Decoder, increased its detection range to cover the entire globe and took pics as a Large Scout appeared headed towards Europe on a Terror Mission, with a P1 UFOTrajectory. This is what I saw:



For comparison I'll list the waypoints for the P1 UFOTrajectory listed on the XCom1ruleset and comment using the image above and Falko's Worldeditor that shows the different missionZones.

Code: [Select]
  - id: P1
    groundTimer: 4000
    waypoints:
      - [5, 4, 100]

First issue is that the UFO has appeared over the Pacific while the MissionZone (MZ) 5 areas defined for Europe (use Falko's editor to check) are located in Africa. At this moment I'm guessing the game simply picks a random MZ 5 to generate the UFO, regardless of the MZ being assigned to a specific location or not, since the UFO was generated on a MZ 5 assigned to Antarctica.
 
Code: [Select]
      - [0, 2, 76]
      - [0, 2, 20]

 I couldn't take a pic of the [0, 2, 76]  waypoint but the 2nd is shown on image #2 above, where the UFO reaches MZ 0 over the British Isles and then slows down.

Code: [Select]
      - [1, 1, 44]
      - [0, 0, 20]

Image #3 and 4 - UFO accelerates to 44% maximum speed and heads for a random MZ 1, on this case located in Spain, where it lands. The MZ 0 location for the landing doesn't appear to be used, my guess is that the game lands the UFO on the location reached on the last waypoint, rather than a random location on MZ 0.

Code: [Select]
      - [0, 2, 32]
      - [2, 1, 65]

Image #5 and 6 - I couldn't take a pic of the [0, 2, 32] waypoint, my guess is that this waypoint is simply for the UFO to lift off before heading towards the next random waypoint, located on MZ 2, on this case on Iceland.

Code: [Select]
      - [5, 0, 100]
Images #7 and 8 - UFO takes off and heads towards South Africa before disappearing. Here the actual MZs 5 assigned to Europe are used.

So, to try to conclude what I've seen:
* When the UFO is first generated, it appears over any MZ 5, regardless of being assigned or not.
* UFOs landing locations are not those on the waypoint where the 0 (Landed) value appears but on the MZ defined on the previous waypoint.
* It seems that the explanation on the wiki is wrong regarding speeds and altitudes. It refers not to their altitude/speed after reaching the waypoint, but when it starts heading towards the next waypoint. This is most evident on image #3 where the UFO is heading towards MZ 1 in Spain with a Very Low altitude and 44% speed and on image #6 where it is headed towards MZ 2 on Iceland.
* The wiki also wrongly explains "zone" on an incomplete way. It is defined as "Globe zone where the waypoint is located." The issue is that is value is used in different ways. When a UFO is initially generated, it uses the MZ 5 value on the 1st UFO trajectory, but afterwards the region where it is headed is defined by the 2nd UFOtrajectory (MZ 0).
* The last waypoint defines the exit area and the specific MZs assigned to regions are used, unlike when they are generated. But there's missing info since there's no way to define the altitude as the UFO heads away (on image #8 it appears with a Very Low altitude).

So, how to explain all of this?
« Last Edit: October 04, 2014, 12:07:57 am by Hobbes »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #1 on: October 04, 2014, 06:02:25 am »
ok here some more explanations
"while the MissionZone (MZ) 5 areas defined for Europe are located in Africa. "
no they are on multiple continents if you have all regions in the imported ruleset many missionzone5 entries the zones overlap. in the image i only show european missionzones + i showed how many region-missionzone5 entries are in that pacific ocean zone.
to get an image like the one i attached import only one region (delete the other regions fom the import rul) click on blue/white plus sign and enable all missionzone layers.

" my guess is that the game lands the UFO on the location reached on the last waypoint"
that is my guess too


"* It seems that the explanation on the wiki is wrong regarding speeds and altitudes."
yes and i found out about it in august but was not 100% sure and only got a "maybe" as assurances so i did not fix the wiki ..
Code: [Select]
15:51 Falko i am a bit confused with trajetories
15:51 Falko in wiki it says: speed: UFO speed after reaching this waypoint, as a percentage (0-100%) of its maximum speed.
15:51 Falko so P0 = [5, 4, 100], [0, 3, 74],[0, 1, 28], [1, 1, 47],[5, 2, 100]
15:51 Falko i would have guessed that means a ufo appears in zone 5 (outside of region) flys with 74% to another zone 0 then with 28%speed to zone 0 with speed 47 to a zone1 after that with 100% speed to another "exit" zone 5
15:51 Falko if the wiki si right the exit-fly is not 100% speed with P0
15:51 Falko so whats right?
15:56 Falko i think the wiki should say: speed: UFO speed USED TO reach this waypoint, as a percentage (0-100%) of its maximum speed.
16:00 SupSuper uhhhhhhhhhhhhh
16:00 SupSuper maybe? :V
but i did not take a deeper look at altitude at that time
so i have no idea why many exit (last/missionzone5) points are altitude 0 that sure is confusing

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #2 on: October 04, 2014, 01:11:46 pm »
I noticed that some MZs overlap one another but it's almost impossible to see how that Pacific MZ is so much overlapped. It would be nice if your world editor had a filter to only show MZs from a specific region in addition to the filter for the different types of MZs.

The answer to the speed/altitude issues lies on how the engine uses these settings to determine the path of UFOs. I wasn't really interested in having to discover where that code is located and figuring out how it works but it seems there's no choice if I want to understand these UFOtrajectory definitions.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #3 on: October 04, 2014, 01:36:05 pm »
 :o

I really should be looking more into the code. I just found out that the UFO size and altitude actually affect the chance of radar detection! No wonder those Small Scouts are so easy to miss.

Quote
/**
 * Returns a UFO's visibility to radar detection.
 * The UFO's size and altitude affect the chances
 * of it being detected by radars.
 * @return Visibility modifier.
 */

And here it is what I was looking for:

Quote
void AlienMission::ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe)
{
   const Ruleset &rules = *engine.getRuleset();
   SavedGame &game = *engine.getSavedGame();
   const size_t curWaypoint = ufo.getTrajectoryPoint();
   const size_t nextWaypoint = curWaypoint + 1;
   const UfoTrajectory &trajectory = ufo.getTrajectory();
   if (nextWaypoint >= trajectory.getWaypointCount())
   {
      ufo.setDetected(false);
      ufo.setStatus(Ufo::DESTROYED);
      return;
   }
   ufo.setAltitude(trajectory.getAltitude(nextWaypoint));
   ufo.setTrajectoryPoint(nextWaypoint);
   std::pair<double, double> pos = getWaypoint(trajectory, nextWaypoint, globe, *rules.getRegion(_region));

UFO's current altitude is given by the definitions on the next way point that the UFO is headed for. But in the case of landed UFOs it is defined automatically as Very Low after they take off. And after taking off speed is the one on the current waypoint.

Quote
   case Ufo::LANDED:
      {
         https:// base missions only get points when they are completed.
         if (_rule.getPoints() > 0 && _rule.getType() != "STR_ALIEN_BASE")
         {
            addScore(ufo.getLongitude(), ufo.getLatitude(), engine);
         }
         ufo.setAltitude("STR_VERY_LOW");
         ufo.setSpeed((int)(ufo.getRules()->getMaxSpeed() * ufo.getTrajectory().getSpeedPercentage(ufo.getTrajectoryPoint())));
      }
      break;

Otherwise, if the UFO has not been landed, the current UFO speed is determined by the settings on next waypoint:
Quote
      https:// Set next waypoint.
      ufo.setSpeed((int)(ufo.getRules()->getMaxSpeed() * trajectory.getSpeedPercentage(nextWaypoint)));

What I need to discover now is where the speed and altitude are assigned when the UFO is first generated. And I found it:

Quote
   https:// Spawn according to sequence.
   Ufo *ufo = new Ufo(const_cast<RuleUfo*>(&ufoRule));
   ufo->setMissionInfo(this, &trajectory);
   const RuleRegion &regionRules = *ruleset.getRegion(_region);
   std::pair<double, double> pos = getWaypoint(trajectory, 0, globe, regionRules);
   ufo->setAltitude(trajectory.getAltitude(0));
   if (trajectory.getAltitude(0) == "STR_GROUND")
   {
      ufo->setSecondsRemaining(trajectory.groundTimer());
   }
   ufo->setSpeed(trajectory.getSpeedPercentage(0) * ufoRule.getMaxSpeed());
   ufo->setLongitude(pos.first);
   ufo->setLatitude(pos.second);
   Waypoint *wp = new Waypoint();
   pos = getWaypoint(trajectory, 1, globe, regionRules);
   wp->setLongitude(pos.first);
   wp->setLatitude(pos.second);
      ufo->setDestination(wp);
   return ufo;

Now, I need to make sense of all of this code and the images above :P
« Last Edit: October 04, 2014, 02:26:08 pm by Hobbes »

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #4 on: October 05, 2014, 03:55:45 am »
First issue is that the UFO has appeared over the Pacific while the MissionZone (MZ) 5 areas defined for Europe (use Falko's editor to check) are located in Africa. At this moment I'm guessing the game simply picks a random MZ 5 to generate the UFO, regardless of the MZ being assigned to a specific location or not, since the UFO was generated on a MZ 5 assigned to Antarctica.
 

just FYI, here's an accurate representation of the mission zones for europe.

note that there are zone 5s covering both poles, and all continents.

just as a matter of record, the colours in the debug view for mission zones are as follows:
0: pink
1: orange
2: white
3: green (these correspond to cities)
4: cyan
5: yellow
« Last Edit: October 05, 2014, 09:51:37 am by Warboy1982 »

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #5 on: October 05, 2014, 05:29:16 am »
just FYI, here's an accurate representation of the mission zones for europe.

note that there are zone 5s covering both poles, and all continents.

I keep forgetting that Debug mode shows the zones. Thanks.

Can you shed some light on this UFOtrajectory issues? My coding skills are quite limited and looking at all that code sometimes feels like I'm trying to read Chinese.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #6 on: October 05, 2014, 08:26:19 am »
basically it goes waypoint to waypoint, but if the next waypoint's altitude is 0 it means "land before heading there, then proceed at very low altitude"

what this means:

the waypoint zone BEFORE the "land" altitude is where it touches down.

Code: [Select]
    groundTimer: 4000
    waypoints:
      - [5, 4, 100]
      - [0, 2, 76]
      - [0, 2, 20]
      - [1, 1, 44]
      - [0, 0, 20]
      - [0, 2, 32]
      - [2, 1, 65]
      - [5, 0, 100]

means:
- spawn in region 5, fly at high altitude and top speed towards a zone 0
- once there, trajectoryPoint is still 0. so we head to region 0 at altitude 2 and 76 speed.
- once there, head towards a zone 0 at 2 altitude and 20% speed
- once there, head towards a zone 1 at 1 altitude and 44% speed
- once there, LAND and start counting down from 4000.
- at the end of the countdown, take off and head to a zone 0 at 1 altitude and 20% speed.
- once there, head towards a zone 0 at 2 altitude and 32% speed
- once there, head towards a zone 2 at 1 altitude and 65% speed
- once there, LAND and count down from 4000.
- at the end of the countdown, take off and head to a zone 5 at 1 altitude and 100% speed.
- once there, the ufo despawns.

or something to that effect.
« Last Edit: October 05, 2014, 09:32:41 am by Warboy1982 »

Offline clownagent

  • Colonel
  • ****
  • Posts: 380
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #7 on: October 18, 2014, 10:17:49 pm »
This thread is very interesting. But one thing I didn't understand. Mission zones are defined for different regions in the ruleset. But many mission zones are not in the region area.

Is it in any way relevant for which region I define a mission zone? Or could I in principle just mix all mission zone definitions in all regions without affecting the game? ???

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Mission Zones, UFOTrajectories and Rulesets - How it works?
« Reply #8 on: October 18, 2014, 10:26:15 pm »
the mission zones that lay outside the region itself are mostly used as entry/exit points for missions being carried out inside said region.

each mission is restricted to a single region, eg: an alien base mission in northern africa may have ships spawning in antartica or europe, but only because northern africa has a mission zone type 5s defined there, and the ship will only fly between mission zones defined for the north african region.
« Last Edit: October 18, 2014, 10:29:35 pm by Warboy1982 »