1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice

[XML + Python] Spawn A Civ 2016-10-05

[XML + Python] Spawn A Civ

  1. The_J
    This modcomp allows you to spawn a civ dynamically triggered by technologies during the game :).

    Explanation from my readme:

    Spoiler :

    Parts of the modcomp:
    All files in Assets\Python and Assets\XML\CustomXML\CIV4SpawnCivInfos.xml are parts of this modcomp. All other files belong to the huns civ by cool3a2 and are just in here, to show a good example for a special case.

    CvEventManager: There are 6 parts, which have to be merged. All are labeled with "spawn a civ".
    (all changes in all python files are labeled like this).
    In 2 parts you have to change the path to YOUR MODS CustomXML folder.
    For example, the current line is MyFile=open("Mods/SpawnACiv/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml").
    If i would merge this in my mod "marsjetzt-v03", i would have to change it to

    SpawnCivUtil: You don't have to change anything here!
    (only, if you removed TERRAIN_TUNDRA, TERRAIN_SNOW or TERRAN_DESERT from your mod.
    These terrains are named to indicate, which plot is crap for a city. If you have
    completely other terrain, then just put in your crappy terrain).

    The scoreboard and the foreign advisors are changed for the special case of a barbarian civ. These civs should not appear on the scoreboard and in the foreign advisor and this had to be changed. This is just esthetical and is not essential. If you have problems with merging it, then just don't do it.

    XML\CustomXML\CIV4SpawnCivInfos.xml: This is a self written file, which is manually loaded my a self written simple XML parser. You can put all your information in here.
    There's no schema, so i'll explain it.

    <Type>CIVILIZATION_HUNS</Type>: The civilization, which should appear.

    <Leader>LEADER_HUNS_Attila</Leader>: The leader for the civ.
    Note 1: You can put every leader together with every civ and create nonsense combinations like for example LEADER_ASOKA and CIVILIZATION_SPAIN.
    Note 2: If you put in -1 instead of LEADER_XY, the algorithm will choose a random leader from the civ. So if you have CIVILIZATION_AMERICA, you'll get randomly Lincoln, Washington or Roosevelt.

    <SpawnTech>TECH_CONSTRUCTION</SpawnTech>: The technology, which spawns the civ.
    <NumberOfSpawnTech>3</NumberOfSpawnTech>: So many civs must have the SpawnTech.
    Note: If NumberOfSpawnTech is smaller then 1, the first tech will trigger the civ.

    <IsBarbarianCiv>True</IsBarbarianCiv>: If set to True, the civ will be at war with
    everyone, can't do any diplomacy, is blocked from the foreign advisor and the scoreboard.
    1) The civ appears in the espionage and the military advisor.
    2) You'll get diplomacy bonuses to other civs for having war with this civ.
    3) You'll get war weariness for fighting this civ. The war weariness is half of the normal ww.

    To make it more clear to the player, that this civ is barbarian,
    i suggest that you give the "barbarian" leader the skull button from the barbarians and
    add a (barbarian) to civ and leader name.

    <StartAtCoast>False</StartAtCoast>: If set to True, all cities will be at the coast.

    <TotalGold>100</TotalGold>: With how much gold the civ starts.

    <DefaultShips>NONE</DefaultShips>: With what ships the civ starts.
    <NumberShipsPerCity>0</NumberShipsPerCity>With how many ships of this type the civ starts.
    1) -1 and NONE in DefaultShips will give you no ship.
    2) only cities at the coast will start with ships.
    3) A number below 1 will not produce an error, you'll just get no ship.

    <NumberOfCities>2</NumberOfCities>: With how many cities the civ starts.
    Note: My city placement algorithm is not very good. It will probably spread the cities
    over the whole map, so it's better to let the civ start with a small number of cities.
    This will have to be fixed in future versions.

    <NumWorkerPerCity>1</NumWorkerPerCity>: How many workers should be in the city.
    Note: Worker UUs are not considered here, the civ will start with a normal worker.

    <DefaultCityDefender>UNIT_HORSE_ARCHER</DefaultCityDefender>: What units should be in the cities?
    <NumberCityDefendersPerCity>4</NumberCityDefendersPerCity>: How many of these units?

    1) NONE in DefaultCityDefender will give you no units.
    2) -1 in DefaultCityDefender will give you the best conscriptable unit which is available for the civ.
    (attention: There are no units conscriptable between warrior and rifleman, so if you use that, you should
    make some other units conscriptable)
    3) A number below 1 in NumberCityDefendersPerCity will not produce an error, you'll just get no units.

    <NumberSecondUnit>2</NumberSecondUnit>: Same as above.

    Other notes:
    1) A typo in the XML file will probably directly lead to a crash and will not produce a python exception
    (i don't know why :/ ).
    2) The new civ starts with all the technologies from the civ, by which it's triggered.
    3) You need a free civ slot to let a civ appear. There's no built in mechanism to kill a civ at the start, so if you start with 18 civs and don't kill one, you'll see no effect.
    4) I've added a check for existing civilizations, so that you don't get double civs. CIVILIZATION_RUSSIA will not spawn, if already russia is present in the game.
    5) The random leader option doesn't work, if the leader is modular.

    cool3a2 for the huns civ, and all the artists who have contributed to the civ:
    - Ekmek for the animated LH
    - Bakuel for unit art, GeoModder and Walter Hawkwood for citystyle
    - strategyonly for the files the flag and the button are based on and for finding that horrible bug
    - Aranor for the units the tarkan is based on
    - Terror666 for the units' sounds

    Also credits go to alpha civ for helping me with some basic and essential python things, and to EmperorFool and davidlallen, who have commented on my approaches for reading the xml file via python (which i didn't use in the end...).

    Re-uploaded on November, 15th, 3:20 forum time.
    - added the tag "SpawnChance" to the XML, so that there's also a chance, that the civ will not spawn. Every value between 0 and 100 is valid. Values under 0 will be treated like 0, values over 100 will be treated like 100.
    - added the tags "StartX" and "StartY" to the XML. You can add here a X and a Y coordinate for the first city (only for the first). Attention: There's no check for a valid position. If you want to place a city in water or on a peak, the function will do this. It's only checked, if there's already a city, then the new city will not be placed. Other units on the plot will be moved to a near plot.

    Re-uploaded on December, 5th, 4:54 PM forum time.
    - Added TechPercent tag, so that a civ can also start with less techs than the civ, which causes the spawn. Every value between 0 and 100 is valid. Values under 0 will be treated like 0, values over 100 will be treated like 100. For example, if you have 15 techs, and the TechPercent is 33, the new civ will 5 techs, which are at the most left in the tech tree. It will not happen, that a civ has an advanced tech, but not an basic tech.

    Re-Uploaded on April, 9th, 6:39 AM Forum time.
    - added 2 tags, to allow also to add a unit only to the capital and to define the number of it.

    Re-Uploaded on May, 5th, 2012, 11:18 AM Forum time.
    - Added tags to spawn a civ by year (incl. optional month) or turn.
    - Added a tag to spawn a civ only by tech research of the human player
    If you put multiple options in (tech, human tech, turn and year), then whatever happens first will trigger the civ.


    1. attiladeclaredwar_lQ2.jpg