project-navigation
Personal tools

Author Topic: How does the game decide wich map to use for a mission?  (Read 7388 times)

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
How does the game decide wich map to use for a mission?
« on: April 20, 2012, 11:00:59 am »
My questions are about campaign.

My understanding of this is like that. If a mission is created, the game uses the pixel map to check wich maps do fit. It checks culture/terrain/population/type of UFO. If there is no map for this, the mission gets canceled. This happens before the mission/UFO actually appears to the player. Is this correct? If there is more than one map, how does the game decide wich one to choose?

How do the dropships affect this? Is there a check, what dropships are available to the player? Or does the game assume each map supports every dropship? There is a statement in the wiki each map should support all dropships. What if the map does not? Is this map not supported by the campaign?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #1 on: April 20, 2012, 01:11:48 pm »
If there is more than one map, how does the game decide which one to choose?

It chooses randomly, but it builds a mapDef statistics and takes into account on choosing, see it in the source (CP_MapIsSelectable and CP_ChooseMap)

How do the dropships affect this? Is there a check, what dropships are available to the player? Or does the game assume each map supports every dropship?

It doesn't check for dropships, it assumes that the player can land there with any.

There is a statement in the wiki each map should support all dropships. What if the map does not? Is this map not supported by the campaign?

That's a good question, I found no check in the campaign code, so I think the map loading will fail.

-geever

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #2 on: April 21, 2012, 10:36:15 am »
Thanks for the answer, geever.

About statistic. My understanding of how this works is poor. To me it looks like, if there is more than one map available, the game is searching the one that was most used, than randomly chooses one out of the others. Correct?

Of course I have to keep asking. Sorry.  :-[


When choosing a map, there are two checks about UFOs in the code (my 'C' is *somewhat rusty, so mostly I read comments or guess).

Code: [Select]
164                 /* a mission without UFO should not use a map with UFO */
If there is an entry like 'ufos      craft_ufo_scout" in the mapdef, this map is invalid. Of course.
So only maps with 'ufos    any' will pass here? ("any ufo" is treated as 'no ufo shown on map')


Code: [Select]
168                 /* A mission with UFO should use a map with UFO
169                  * first check that list is not empty */

So a map is only valid if it supports the correct UFO. E.g. the mission involves a Scout UFO, the mapdef needs to show 'ufos    craft_ufo_scout'.
How Is 'ufos = any' handled here?


A lot of the RMA themes we have can not be used in a mission without ufo atm. How often do missions like that happen during campaign? Will this number increase over time, as aliens will have more bases, and alien interest gets higher?


*non-existent

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #3 on: April 21, 2012, 11:59:07 am »
About statistic. My understanding of how this works is poor. To me it looks like, if there is more than one map available, the game is searching the one that was most used, than randomly chooses one out of the others. Correct?

The code is a bit cryptic, I'll clean it up a bit this evening, but as I see: It does a minimum search on the usable mapDefs' usage statistics, and also counts the mapDefs which has the same (minimal) usage counter. Then it chooses one from them ( the ones with minimal use count).

When choosing a map, there are two checks about UFOs in the code (my 'C' is *somewhat rusty, so mostly I read comments or guess).

If a mapdef has an empty ufos section (or maybe no ufos section at all), that means it has no restriction to UFOs => supports them all (and can be used without UFO too). If it has a non empty ufos section, the map can be used only with UFOs listed there.

A lot of the RMA themes we have can not be used in a mission without ufo atm. How often do missions like that happen during campaign? Will this number increase over time, as aliens will have more bases, and alien interest gets higher?

It depends on XVI: cp_missions.cpp:1408.

-geever

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #4 on: April 21, 2012, 01:10:16 pm »
If a mapdef has an empty ufos section (or maybe no ufos section at all), that means it has no restriction to UFOs => supports them all (and can be used without UFO too).
-geever

Sorry for bothering you. A map with 'any' parameter or an empty/missing ufos section will still be valid for a mission that has a landed UFO ?


Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #5 on: April 21, 2012, 02:05:09 pm »
Sorry for bothering you. A map with 'any' parameter or an empty/missing ufos section will still be valid for a mission that has a landed UFO ?

Yes.

Btw. I see no parser for any "any" value, so it is probably invalid... (and the "any" strings I saw in the script were comments)

-geever

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #6 on: April 21, 2012, 02:21:07 pm »
Maybe I should be more verbose about the reason for my questions.

When adding the missing spawnpoints to the maps lately, I had to open each one in the mapeditor. Some of them I have never seen in game (I played a lot, at least before I started contributing to this project) or they come up rarely, while other maps come up very often. Something must be going wrong here, as we have a lot of maps, but only few show up in game.

My guess was, if a mission contains a landed ufo, only maps with this ufo are used (maps with 'any' are not). Thats why our static map show up rarely (only used in missions with no ufo). Of course I might be wrong, as this is only based on some observations of my own and a small sample of data H-Hour collected from some savegames (http://pastebin.com/Yw2XEPCY).

I made a (very unprofessional) check. Out of the sample I picked up the oriental/desert combination, no crashed ufo. We have 14 maps that fit this combination (5 have ufos defined(group A),  9 have not (group B)). 109 missions wre played at these 14 maps. 94 of them on maps of group A, 15 of them on maps of group B.
Landed UFOs should be the major part of missions (94), while missions without UFO appear less often (15). If I am correct, missions with ufos use only maps from group A.

Or maybe just the check how often a map was used compared to others has to be improved?

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #7 on: April 21, 2012, 02:26:10 pm »
Geever, sorry. If I talk about 'any' here, it is always an empty block ( where 'any' is used as comment only). Sometimes the block is completely missed.

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #8 on: April 21, 2012, 09:45:16 pm »
There is a statement in the wiki each map should support all dropships. What if the map does not? Is this map not supported by the campaign?

Static maps will show the wrong dropship but RMAs will fail

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #9 on: April 21, 2012, 10:45:00 pm »
To clarify, although it may not need clarifying. We have basically three types of maps (I think) in terms of support for UFOs/Dropships:

1. RMA that *should* have support for all dropships and UFOs (but often doesn't).

2. Static map or fake RMA (ie - supports different dropships but just one map tile for the rest) in which a particular UFO appears. These support only one UFO (+bridge is an example. it only supports crashed fighter UFOs).

3. Static maps that have no dropships or UFOs on the map (bunker, for example).

The (1) maps are what we wish every map would be like. The (2) and (3) maps is where there is some confusion about how maps are chosen and how they should be chosen to ensure we're getting as much map diversity as possible.

Personally, I think that in most cases we should use (3) maps for any UFO mission, crashed or landed, with any dropship -- at least until we have more support for crashed dropships in other maps. We should, however, reserve a couple maps for special mission types (like terror missions), so that these missions feel special and different.

Of course, (2) maps have certain restrictions because the UFO is built into the map, so for now we will just have to make sure they don't appear with the wrong UFO.

With all maps that include a landed UFO, I think we should consider, as a temporary stop-gap, allowing landed UFOs to be used for crashed UFO missions. Our support for landed UFO tiles is much wider, but that happens much less in the game. Until we have more support for crashed tiles, lets allow landed UFO tiles to work as well. It's possible, for instance, that a UFO has a soft crash landing after some of its instruments are destroyed but the hull remains intact.

The question is, does this already happen in the game? How can we use (3) maps more often? I haven't looked yet at the newly commented code geever just committed, but will try to look this week.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #10 on: April 22, 2012, 09:20:23 am »
Static maps will show the wrong dropship but RMAs will fail

I love this kind of messages. I wonder how could one know?  ;)

Thanks for digging into this, DarkRain. Using the bugtracker as source for information did not come to my mind.

From what I have seen our RMA type of maps all have the needed dropship tiles available. And I can only remember two static maps maps showing a Firebird dropship on it. This is easy to fix, so we should not have trouble with this in the future.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #11 on: April 22, 2012, 10:17:26 am »
1. RMA that *should* have support for all dropships and UFOs (but often doesn't).

Only one I know of is shelter map. This can be fixed.
Edit : Only in way of the dropships of course. UFOs you are right, of course.

The (2) and (3) maps is where there is some confusion about how maps are chosen ...

Thats not entirely correct. How maps are choosen for missions does not depend on whether it is RMA, semiRMA or static. The problem is the 'ufos' section in the mapdef, because maps with ufo defined there are very frequently used, while maps that havenĀ“t (empty section for '// all') are rarely show up. At least this is what I think is shown by the data you collected. As long as I am not able to prove it, it is only an educated guess.


... how they should be chosen to ensure we're getting as much map diversity as possible.

Personally, I think that in most cases we should use (3) maps for any UFO mission, crashed or landed, with any dropship -- at least until we have more support for crashed dropships in other maps. We should, however, reserve a couple maps for special mission types (like terror missions), so that these missions feel special and different.

Of course, (2) maps have certain restrictions because the UFO is built into the map, so for now we will just have to make sure they don't appear with the wrong UFO.

With all maps that include a landed UFO, I think we should consider, as a temporary stop-gap, allowing landed UFOs to be used for crashed UFO missions. Our support for landed UFO tiles is much wider, but that happens much less in the game. Until we have more support for crashed tiles, lets allow landed UFO tiles to work as well. It's possible, for instance, that a UFO has a soft crash landing after some of its instruments are destroyed but the hull remains intact.

This would be better than what we have. I just think it would be a kind of waste, because that will need to be coded first and changed back again in the future. I would like more to have a 'final' version of code and adding the needed maps as good as we can. This work needs to be done anyway.
« Last Edit: April 23, 2012, 04:58:50 pm by ShipIt »

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: How does the game decide wich map to use for a mission?
« Reply #12 on: April 26, 2012, 08:56:46 am »
If a mapdef has no certain ufo defined in the 'ufos' section, this map is never used in a battlescape mission with landed ufo. I am quite sure about this after playing with a modified maps.ufo for some time.