Skip to content

Unit replacements | Unique units #863

@stavrosfa

Description

@stavrosfa

I have come across some issues regarding unit replacements and unique units and the way we import them and subsequently handle them during the game.

I will use the Scout upgrade chain as an example, as this is the one I stumbled upon, but perhaps this applies to other units as well.

In a vanilla Conquests game, only some civilizations can build the Scout. We know it's the expansionist civs, but that is a common trait these civs share, not a hardcoded/selectable rule by itself.
All civs after learning Astronomy can build an Explorer, with the exeption of Spain which instead can build a Conquistador. The Explorer unit is completely unavailable to Spain.
All civs that had Scouts, can now upgrade them to an Explorer, except of course from Spain that has neither. Spain can only build a Conquistador, and only if it knows Astronomy and has access to horses.

This vanilla logic works ok with what we currently have.

Now let's examine the rules and expected behaviour of scenario 6 MP Age of Discovery.biq

Only the Iroquois can build/have a Scout, and they are not playable by a human.

All other civs can build an Explorer after learning Navigation.

And this is where the problems start.

Spain has the ability to build both an Explorer and a Conquistador after learning Navigation.
Not at the same time, meaning, if they don't have horses, they can build an Explorer, if they do, the can build a Conquistador instead. But they still can have both.
A Spanish Explorer can also be upgraded to a Conquistador if Spain gains access to horses after building the Explorer.

When we are importing these units, we have some rules that disallow some of that.
For example

// A valid upgrade must require a different technology than the base unit and must not be a unique unit.

So our Explorer unit in the output doesn't specify an upgrade.

In this scenario also a Scout can be upgraded to a Conquistador. This can never actually happen because Spain can't have Scouts and Iroquois can't have Conquistadors, so this is irrelevant, but still it seems like we are missing this when importing and the Scout can't be upgraded to anything.

There are also problems during the game where, even after I update these upgrades manually in the json, the code doesn't handle the Explorer/Conquistador issue for Spain correctly because it checks if it is unique or not and decides what is obsolete/available based on that. Possible culprits are

private bool IsUnitObsolete(City city, HashSet<Resource> accessibleResources) {

and

public bool IsUnitAvailable(UnitPrototype unit) {

Another thing we might also want to consider is

private bool MeetsProductionRequirements(City city, HashSet<Resource> accessibleResources) {

I think the availability should be separate from the production capabilities.

Do you have any insights on this?

Side note, I just hadn't noticed it, the Civilopedia entries seem to be dynamic based on the civ we currently play as, in the sense that if I pick Portugal and check the Explorer entry, there is no upgrade. If I pick Spain I can see it upgrades to a Conquistador.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions