Configurable battlefields

Still didn’t start work on battlefields added to terrain.

  1. My license is out (mouth have passed since installation and i was out of Internet reach last 2 weeks).
  2. Now i think that current idea to move battlefields list to terrain json structure is bad (leaving special battlefields as it was earlier).

This is because two things (Obstacles, where we have id’s (number in array of battlefields names) ) and because of things like in undeground level this way we will still get random battlefields for surface.

I think that battlefields must be made objects like other things. Battlefields must get symbolic names and they must be used in obstacles.json. It’s complex thing.

It must be something like

    "grassField1":  {   
             "graphics": "mybtfds\COOLBFFD.bmp",
             "allowedLevel": "surface", "underground"], //if not set than it can be used only in map objects if set in them as battlefield "grassField1"

In obstacles.json we then need instead of

	"allowedTerrain" : [0],
"specialBattlefields" : ],

to only write

	"allowedBattlefields" : "grassField1","grassField2"],

What do you think of it?

  1. Field “terrain” should be moved to terrain format. Allowed battlefields should be defined in terrains or in overlays (e.g. Magic Plains). Oh - and since map objects branch is now merged you can also implement moddable special terrains (or at least remove hardcode for existing terrains).

  2. Remove “allowedLevels” field - no point in it, at least right now. Later we can think on how to select battlefield out of available ones.

  3. What about special battlefields - there is one background specifically for coast and we have 2 battlefields with ships - one is hero vs neutral, another is hero vs hero. How such situations should be handled?

When boats will be configurable, there “allowedBattlefields” with string identifiers can be added as for other objects.
Same goes for battlefield to fight with two boats. These special 2-boats battlefield can be added to boat configuration, so it will be taken from acting hero boat, when 2 boats fight.

About coast i need some further throughts. Why not make new terrain type “coast”? While map editing/generation coast tiles will get this terrain type.

No. Creating separate terrain is overkill. Something like “any neighbor tile is water” should be more easy to implement.

Then go ahead with boats config as well. With map objects branch merged there is now standard mechanism to configure objects. Although I don’t think that this should be part of boat config.

I think you should start from listing all the features we want for new battlefields. Starting from json format is just the wong way.

My list:

  • Battlefields should be randomized - there could be more than one for each type of terrain
  • Obstacles positions should be compatible with original battlefields
  • Obstacles apperance should be compatible
  • Battlefields can be linked to specific objects, for example different battlefield for every creature bank
  • Battlefields should be randomized - there could be more than one for each type of terrain
    Proposed than Terrain should have “allowedBattlefields” : ] list. But this will be not good, if we have more than 1 mod, adding battlefields.
    So better add field “allowedTerrain” : ] to Battlefield configuration. After loading configuration files VCMI can than prepare inner list of all battlefields available for specific terrain, and to randomly choose BF from this list in runtime.

  • Obstacles positions should be compatible with original battlefields
    There is already list of BF in Obstacles.json. Just id numbers must be replaced by string ID of BF.

  • Obstacles apperance should be compatible
    if obstacle is assigned to BF in Obstacles.json, then it will be so and on shoulders of modder.

  • Battlefields can be linked to specific objects, for example different battlefield for every creature bank
    There should be added “allowedBattlefields”: ] to each bank (to allow randomly choosing BF for bank in runtime). If not set, BF should be taken from terrain/magic land, on which bank stands.

And think of a commonized API to be able for scripting :wink:

No. Main reason is because terrains are not the only place where battlefields will be used - special terrains will also have such field and this one is definitely property of an object.

To keep it mod-compatible we can use such format in terrains:

However this leaves question on how to select coast battlefield open. And another related modding-only feature - allow selecting battlefield based on nearby objects, e.g. select “forest” background if hero is near trees, or mountains if hero is near them.

IMO what we need is some way to “inspect” nearby tiles.

As i remember, it’s about tags for map object. If “tree” or “forest” tag is added, that object can be treated as forest. This leaves coast detection open. Can tag be assigned to sea tile?

Yes, tags would be quite useful here. But I was using situation like this as example:


T = open terrain
F = tile with forest object
H = hero
G = attacked creature

In this case game should select “forest” battlefield because neighbor tile has a forest on it. To do this we would also need

  • some way to check all neighbor tiles
  • some way to describe such requirements in battlefields config.
  • randomly select battlefield from allowed. This part is a bit tricky. Consider example:

battlefield A: grass battlefield
battlefield B: grass battlefield
battlefield C: grass battlefield for forest
battlefield D: grass battlefield for forest

When battle takes place near forest all 4 battlefields are applicable because we’re on grass terrain. Game needs to filter out such normal battlefields as a first step.

We may try something like this:

// normal battlefields
"genericBattlefields" : { "A" : true, "B" : true } 

// special battlefields, probably we can reuse logical expressions yet again.
// If none of these are applicable - game falls back to generic BF's
"specialBattlefields" : { "C" :  "nearbyObject", "forest" ], "D" :  "nearbyObject", "forest" ] }

And for coast we may implement check “nearbyTerrain” as well.

This leaves boats as the only issue.