Announcement

Collapse
No announcement yet.

Map Scripts: How do I .... ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Map Scripts: How do I .... ?

    How do I make/modify a map script to do some or all of the following:

    1. Place civilizations that know fishing at the coast.

    2. Make sure civilizations starting on the coast have at least one sea resource (fish/clam/crabs).

    3. Make sure that civilizations that need a resource for their unique unit has that resource available within x plots of the starting location.

    4. Place marble and stone so that they are halfway between two starting locations but on opposite sides of any given starting location. Example: The Greeks would find marble to the east halfway to The Indians and stone to the west halfway to The Romans.

    5. Clump a resource to encourage trading.

    6. Make sure two resources are placed close to each other while maintaining the standard amount of said resources on the map. For example have marble and stone close to each other without having more or less of them compared to a standard map script. Preferrably between two or more starting locations to encourage competition over the resources.

    7. Make sure a specific civilization has a specific resource close to their starting position. Example: Rome has Iron, India has Ivory and so on.

    8. Make sure the Player has a specific resource close to the starting location. Example: The player starts with cows close by.

    9. Make all of the above as options to set when starting a new custom game.

    10. Make a script that has options for which of the standard map types to use as well as the above.

    11. Make a script which randomly pick one of the standard map types to generate and has the above options. With an option to pick which types to randomly choose from so I can exclude archipelago but maybe get terra, pangaea or continents.

    How do I do all this? Where do I do all this? What if anything can be done in the .xml files and what needs to be done in Python? For python example code with comments would be appreciated. Thanks!

  • #2
    Generally speaking, check CvMapScriptInterfaces.py in Assets/Python/EntryPoints.
    Everything will be done in python.

    1. Place civilizations that know fishing at the coast:
    You should implement the assignStartingPlot() method in your script. Check for instance in Archipelago.py :
    # Ensure that starting plot is in chosen Area and is along the coast.
    def isValid(playerID, x, y):
    global iBestArea
    pPlot = CyMap().plot(x, y)
    if pPlot.getArea() != iBestArea:
    return false
    pWaterArea = pPlot.waterArea()
    if (pWaterArea.isNone()):
    return false
    return not pWaterArea.isLake()
    findstart = CvMapGeneratorUtil.findStartingPlot(playerID,isVal id)
    This py's a bit complex with lots of placements, but the isValid part is the interesting thing. You just need to check playerID's civ in addition for the fishing tech part.

    2. Make sure civilizations starting on the coast have at least one sea resource (fish/clam/crabs).
    You can add the resource in the radius of the city. Do that either in normalizeAddFoodBonuses() or normalizeAddGoodTerrain() (see CvMapScriptInterfaces.py). Then do map.plot(x,y).setBonusType(iBonusType) - I don't know how to retrieve the iBonusType from the name (though I know how to get the name from the type check Great_plains.py for instance).

    3. Make sure that civilizations that need a resource for their unique unit has that resource available within x plots of the starting location.
    Same as 2.

    4. Place marble and stone so that they are halfway between two starting locations but on opposite sides of any given starting location. Example: The Greeks would find marble to the east halfway to The Indians and stone to the west halfway to The Romans.
    This one is trickier as you must postprocess after the whole process is done. Either use addBonusType or afterGeneration. Better to use addBonusType so there won't be additional marble elsewhere.

    5. Clump a resource to encourage trading.
    Again in addBonusType.

    6.
    Same as 4. The problem is I don't know the default values so I can't really help there.

    7. That's the same as question 3.

    8. Again about the same a 3.

    9. Make all of the above as options to set when starting a new custom game.
    You need to define getNumCustomMapOptions, getCustomMapOptionName, getNumCustomMapOptionValues, getCustomMapOptionDescAt
    and then call
    CyMap().getCustomMapOption(i) for each to know whether to use your version or not. You can usually revert to default values by calling allowDefaultImpl() in the method you're overriding.

    10.
    Not sure what you mean. The options defined in 9 are in addition to the other options (sea level, climate) anyway.

    11.
    Way harder. Some do this. Check in the creation forum, I think there are some scripts like that already..
    Clash of Civilization team member
    (a civ-like game whose goal is low micromanagement and good AI)
    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

    Comment

    Working...
    X