[BNW] Spawn units with XML

Withdrawnbean

Chieftain
Joined
Jul 1, 2020
Messages
4
I've been looking through the c++ source code for civ 5, trying to wrap my head around it. I'm sure you can do this with c++, but I was wondering if there is a way to spawn units using xml through a leader trait or a unique building instead.
 
Definition of the Building_FreeUnits table. When the Building is completed by whatever means, the specified unit is given. The same building can have multiple different units listed in the table, and will give all such units upon completion of the building.
Code:
	<Table name="Building_FreeUnits">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="UnitType" type="text" reference="Units(Type)"/>
		<Column name="NumUnits" type="integer"/>
	</Table>
Columns "FreeUnit" and "FreeUnitPrereqTech" in table "Traits" can also be used but they are one-shot deals.

The best method to determine what can and cannot be done by xml or sql methods is to look at the game's base xml files. Even though the game uses an SQL database, Firaxis uses xml files to build the contents of the unmodded game database.

Mods can then alter the contents of that unmodded database using either xml or sql.
 
Definition of the Building_FreeUnits table. When the Building is completed by whatever means, the specified unit is given. The same building can have multiple different units listed in the table, and will give all such units upon completion of the building.
Code:
    <Table name="Building_FreeUnits">
        <Column name="BuildingType" type="text" reference="Buildings(Type)"/>
        <Column name="UnitType" type="text" reference="Units(Type)"/>
        <Column name="NumUnits" type="integer"/>
    </Table>
Columns "FreeUnit" and "FreeUnitPrereqTech" in table "Traits" can also be used but they are one-shot deals.

The best method to determine what can and cannot be done by xml or sql methods is to look at the game's base xml files. Even though the game uses an SQL database, Firaxis uses xml files to build the contents of the unmodded game database.

Mods can then alter the contents of that unmodded database using either xml or sql.

Thank you, that helps a lot! Do you know if there is any way to have a building or title improvement spawn a unit over time, such as creating a unit every 3 turns for example?
 
Not with any Database-only method (ie, no amount of either XML or SQL will accomplish this). Lua scripting can be used to accomplish this. I have done this sort of thing with my Knights Templar World Wonder mod. But I wrote the code quite a few years ago so it is probably not nearly as efficiently-written lua code as I would make today.

Spoiler :
:cringe: there's nothing that will make a modder :cringe: so much as looking at code they wrote years ago :cringe:
 
Back
Top Bottom