Can improvements be copied?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
Is it possible to copy the art of existing improvements? I tried something like this, but it shows no terrain or icon artwork, even though they both point to the same art:

Code:
<Row>
    <Type>IMPROVEMENT_TRADING_POST</Type>
    <Description>TXT_KEY_IMPROVEMENT_TRADING_POST</Description>
    <Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_TRADING_POST_TEXT</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_TRADING_POST</ArtDefineTag>
    <PillageGold>20</PillageGold>
    <PortraitIndex>32</PortraitIndex>
    <IconAtlas>TERRAIN_ATLAS</IconAtlas>
</Row>

based on

<Row>
    <Type>IMPROVEMENT_BAZAAR</Type>
    <Description>TXT_KEY_IMPROVEMENT_BAZAAR</Description>
    <Civilopedia>TXT_KEY_IMPROVEMENT_BAZAAR_CIV</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_TRADING_POST</ArtDefineTag>
    <CivilizationType>CIVILIZATION_ARABIA</CivilizationType>
    <PillageGold>20</PillageGold>
    <PortraitIndex>32</PortraitIndex>
    <IconAtlas>TERRAIN_ATLAS</IconAtlas>
</Row>
 
Yes, I've created quite a few new Improvements. (Granted, many of them are temporary improvements used by my terraforming logic, but still.)

I've never tried using the CivilizationType field, so you might try just removing that line to see. Other than that, it should add it to the database just fine. Of course, you also have to create a Build action for it, and add that build action to your workers, but I'm assuming you did that already. (If not, then do that next. Units/CIV5Builds.xml for the build action declaration, and Unit_Builds inside CIV5Units.xml for the workers. The build action is where, for instance, you declare a tech prerequisite.)
 
Is it possible to create improvements? I tried something like this, but it shows no terrain or icon artwork, even though they both point to the same art:

Code:
<Row>
    <Type>IMPROVEMENT_TRADING_POST</Type>
    <Description>TXT_KEY_IMPROVEMENT_TRADING_POST</Description>
    <Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_TRADING_POST_TEXT</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_TRADING_POST</ArtDefineTag>
    <PillageGold>20</PillageGold>
    <PortraitIndex>32</PortraitIndex>
    <IconAtlas>TERRAIN_ATLAS</IconAtlas>
</Row>

based on

<Row>
    <Type>IMPROVEMENT_BAZAAR</Type>
    <Description>TXT_KEY_IMPROVEMENT_BAZAAR</Description>
    <Civilopedia>TXT_KEY_IMPROVEMENT_BAZAAR_CIV</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_TRADING_POST</ArtDefineTag>
    <CivilizationType>CIVILIZATION_ARABIA</CivilizationType>
    <PillageGold>20</PillageGold>
    <PortraitIndex>32</PortraitIndex>
    <IconAtlas>TERRAIN_ATLAS</IconAtlas>
</Row>

Hi Thalassicus, here is the XML info I used to make a gold mine, (only buildable on gold resource).
Spoiler :

<Improvements>
<Row>
<Type>IMPROVEMENT_GOLDMINE</Type>
<Description>TXT_KEY_IMPROVEMENT_GOLDMINE</Description>
<Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_GOLDMINE_TEXT</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_MINE</ArtDefineTag>
<PillageGold>100</PillageGold>
<PortraitIndex>26</PortraitIndex>
<IconAtlas>TERRAIN_ATLAS</IconAtlas>
</Row>
</Improvements>

<Language_en_US>
<Row Tag="TXT_KEY_IMPROVEMENT_GOLDMINE">
<Text>Gold Mine</Text>
</Row>
</Language_en_US>

<Improvement_HillsYields>
<Row>
<ImprovementType>IMPROVEMENT_GOLDMINE</ImprovementType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>0</Yield>
</Row>
</Improvement_HillsYields>

<Improvement_ResourceTypes>
<Row>
<ImprovementType>IMPROVEMENT_GOLDMINE</ImprovementType>
<ResourceType>RESOURCE_GOLD</ResourceType>
</Row>
</Improvement_ResourceTypes>

<Improvement_ResourceType_Yields>
<Row>
<ImprovementType>IMPROVEMENT_GOLDMINE</ImprovementType>
<ResourceType>RESOURCE_GOLD</ResourceType>
<YieldType>YIELD_GOLD</YieldType>
<Yield>5</Yield>
</Row>
</Improvement_ResourceType_Yields>

<Builds>
<Row>
<Type>BUILD_GOLDMINE</Type>
<ImprovementType>IMPROVEMENT_GOLDMINE</ImprovementType>
<Description>TXT_KEY_BUILD_GOLDMINE</Description>
<Kill>1</Kill>
<Recommendation>TXT_KEY_BUILD_PROD_REC</Recommendation>
<EntityEvent>ENTITY_EVENT_GOLDMINE</EntityEvent>
<HotKey>KB_N</HotKey>
<OrderPriority>96</OrderPriority>
</Row>
</Builds>

<BuildFeatures>
<Row>
<BuildType>BUILD_GOLDMINE</BuildType>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
<Time>700</Time>
<Remove>true</Remove>
</Row>
<Row>
<BuildType>BUILD_GOLDMINE</BuildType>
<FeatureType>FEATURE_FOREST</FeatureType>
<PrereqTech>TECH_MINING</PrereqTech>
<Time>400</Time>
<Production>20</Production>
<Remove>true</Remove>
</Row>
<Row>
<BuildType>BUILD_GOLDMINE</BuildType>
<FeatureType>FEATURE_MARSH</FeatureType>
<PrereqTech>TECH_MASONRY</PrereqTech>
<Time>600</Time>
<Remove>true</Remove>
</Row>
</BuildFeatures>

<Language_en_US>
<Row Tag="TXT_KEY_BUILD_GOLDMINE">
<Text>Construct a [LINK=IMPROVEMENT_MINE]Gold Mine[\LINK]</Text>
</Row>
</Language_en_US>

This last little bit of XML links it with the LUA file you will also have to make.

LUA

BUILD_VINEYARD = g_BuildPlantationIcon,

This needs to be added to ActionIcons.lua right after the Vanilla improvements you see there. Dont forget to set import to TRUE. Note that this improvement also kills the builder. You can easily change this, though.
 
Thanks for the tip that ActionIcons.lua is coded incorrectly, I'll fix it to read from the xml files. If I set ArtDefineTag=ART_DEF_IMPROVEMENT_MINE it's visible, but if I set it to ART_DEF_IMPROVEMENT_TRADING_POST it's invisible.

How do we create an improvement with the trading post art?
 
Thanks for the tip that ActionIcons.lua is coded incorrectly, I'll fix it to read from the xml files. If I set ArtDefineTag=ART_DEF_IMPROVEMENT_MINE it's visible, but if I set it to ART_DEF_IMPROVEMENT_TRADING_POST it's invisible.

How do we create an improvement with the trading post art?


Spoiler :
Create an Improvement modifying the above XML code, then add:

BUILD_TRADING_POST = g_TradingPostIcon,

: to ActionIcons.lua but replace BUILD_TRADING_POST with your own.


Also change the following:

<Language_en_US>
<Row Tag="YOUR BUILDING TAG GOES HERE">
<Text>Construct a [LINK=IMPROVEMENT_TRADING_POST]Trading Post[\LINK]</Text>
</Row>
</Language_en_US>

and replace Trading Post with the name of your own building.


Spoiler :

Heres how things look in ActionIcons.lua for my NiGHTS mod (not this messy though, copy paste acting up on me). You see all the Vanilla Improvement Builds and then I just slide my own in after using the same format.


BUILD_ROAD = g_BuildRoadIcon,
BUILD_RAILROAD = g_BuildRailRoadIcon,
BUILD_FARM = g_BuildFarmIcon,
BUILD_MINE = g_BuildMineIcon,
BUILD_TRADING_POST = g_TradingPostIcon,
BUILD_LUMBERMILL = g_BuildLumberMillIcon,
BUILD_PASTURE = g_BuildPastureIcon,
BUILD_CAMP = g_BuildCampIcon,
BUILD_PLANTATION = g_BuildPlantationIcon,
BUILD_QUARRY = g_BuildQuarryIcon,
BUILD_WELL = g_BuildOilWellIcon,
BUILD_OFFSHORE_PLATFORM = g_BuildOffShoreIcon,
BUILD_FISHING_BOATS = g_FishingBoatsIcon,
BUILD_FORT = g_BuildFortIcon,
BUILD_REMOVE_JUNGLE = g_ChopForestJungleIcon,
BUILD_REMOVE_FOREST = g_ChopForestJungleIcon,
BUILD_REMOVE_MARSH = g_ClearMarshIcon,
BUILD_SCRUB_FALLOUT = g_ScrubFallout,
BUILD_REPAIR = g_RepairTileIcon,
BUILD_REMOVE_ROUTE = g_RemoveRoadIcon,
BUILD_CITADEL = g_Citadel;
BUILD_MANUFACTORY = g_Manufactory;
BUILD_CUSTOMS_HOUSE = g_CustomHouse;
BUILD_ACADEMY = g_BuildSchoolIcon;
BUILD_LANDMARK = g_Landmark;
BUILD_TERRACE_FARM = g_BuildTerraceFarmIcon;

------------------------------------------------------

-- NiGHTS

BUILD_VINEYARD = g_BuildPlantationIcon,
BUILD_BANANAPLANTATION = g_BuildPlantationIcon,
BUILD_DYEPLANTATION = g_BuildPlantationIcon,
BUILD_SILKPLANTATION = g_BuildPlantationIcon,
BUILD_SPICESPLANTATION = g_BuildPlantationIcon,
BUILD_SUGARPLANTATION = g_BuildPlantationIcon,
BUILD_COTTONPLANTATION = g_BuildPlantationIcon,
BUILD_INCENSEPLANTATION = g_BuildPlantationIcon,
BUILD_WHEATFARM = g_BuildFarmIcon,
BUILD_GOLDMINE = g_BuildMineIcon,
BUILD_COALMINE = g_BuildMineIcon,
BUILD_IRONMINE = g_BuildMineIcon,
BUILD_ALUMINUMMINE = g_BuildMineIcon,
BUILD_URANIUMMINE = g_BuildMineIcon,
BUILD_GEMSMINE = g_BuildMineIcon,
BUILD_SILVERMINE = g_BuildMineIcon,
BUILD_MARBLEMINE = g_BuildQuarryIcon,
BUILD_HORSEPLANTATION = g_BuildPastureIcon,
BUILD_COWPLANTATION = g_BuildPastureIcon,
BUILD_SHEEPPLANTATION = g_BuildPastureIcon,
BUILD_IVORYPLANTATION = g_BuildCampIcon,
BUILD_FURPLANTATION = g_BuildCampIcon,
BUILD_DEERPLANTATION = g_BuildCampIcon,
BUILD_LUMBERMINE = g_BuildLumberMillIcon,
BUILD_PARSONAGE = g_BuildSchoolIcon;
BUILD_SHED = g_BuildFortIcon,
BUILD_STARS = g_BuildMineIcon,
BUILD_PEARLZ = g_FishingBoatsIcon,
BUILD_SHORE = g_BuildOffShoreIcon,
BUILD_PIPELINE = g_BuildOilWellIcon,


All of these LINK files:

<Language_en_US>
<Row Tag="YOUR BUILDING TAG GOES HERE">
<Text>Construct a [LINK=IMPROVEMENT_TRADING_POST]Trading Post[\LINK]</Text>
</Row>
</Language_en_US>


:are found in CIV5GameTextInfos_Jon.xml
 
To expand slightly on what markusbeutel said:

You can add an entirely new action icon if you want, so that you don't have this using the same icon as the Trading Post, as long as it's an icon available in 64 and 45-pixel sizes. (Which all unit icons, natural wonders, promotions, buildings, specialists, civilizations, and technologies are, so you could recycle one of those. Most unit/building/tech icons would be to picture-y, but the promotion icons could work.) Note that this is separate from the improvement's icon, which shows up in the Civilopedia and such; the build action is just the thing that shows up in the little worker window when you assign his next job.

If you've added a new icon atlas already, then you just have to create a few new entries at the top of ActionIcons.lua, like so (taken from my own mod):
Code:
local g_Monolith				= {IconIndex = 17, IconAtlas = "MISC_ATLAS_SMAC"};
local g_PlantForest				= {IconIndex = 16, IconAtlas = "MISC_ATLAS_SMAC"};
local g_PlantJungle				= {IconIndex = 18, IconAtlas = "MISC_ATLAS_SMAC"};
local g_DeepMine				= {IconIndex = 19, IconAtlas = "MISC_ATLAS_SMAC"};
local g_Terraform				= {IconIndex = 20, IconAtlas = "MISC_ATLAS_SMAC"};
local g_CityRuins				= {IconIndex = 21, IconAtlas = "MISC_ATLAS_SMAC"};
local g_RaiseHills				= {IconIndex = 22, IconAtlas = "MISC_ATLAS_SMAC"};

and then link those to the build actions with the type of command markusbeutel said. I've gone a bit further in my own mod, because I wanted improvement icons to appear on the tech tree (for the yield increases) instead of that default starburst icon, so don't use my mod's file as a guideline, but this general syntax should hold for what you're doing.
 
The icon isn't the problem, I got that to work. To clarify post #4:

  • ART_DEF_IMPROVEMENT_MINE
  • ART_DEF_IMPROVEMENT_TRADING_POST
If I put A in the ArtDefineTag field everything works fine and it shows up with a mine terrain graphic. If I put B in the field it has no terrain art. By terrain art I mean the graphic that displays on the map.
 
Do you guys know how to change what tech gives the improvement?

Units/CIV5Builds.xml

The tech prerequisites are tied to the Build action, not the improvement itself. This seems a bit strange, but it adds some possibilities. For instance, let's say I want my Worker units to eventually be able to create Academies, Landmarks, Customs Houses, Manufactories, and Citadels, but with a huge build time and the sacrifice of the unit. So I can create a new build action for each of those Improvements, give that new action a high tech prerequisite, and assign it to the workers. That gives me two different ways to make that improvement, without them both unlocking at the same time.

This has other possibilities as well. Maybe you want to create a dedicated sea worker unit that doesn't sacrifice but has Worker-like build times. Maybe you want other naval units to be able to build fishing boats and offshore platforms. Maybe you want Scout units to be able to lay roads a half-dozen techs later than Workers can (since they're the only ancient-era units other than Workers and Settlers that doesn't get an upgrade in the vanilla game). All of these are possible with this setup.

Thalassicus said:
By terrain art I mean the graphic that displays on the map.

Ah. Then let me ask this: what terrain type are you trying to do this on, and are there any resources on the tile? If you create a combo that doesn't have an existing graphic, then it blanks out. Either improvement on a terrain type it wasn't built for, or improvement on a resource it wasn't supposed to pair with.

I'll give an example. In my mod, I added Dilithium, which is a mineral only found in coastal water tiles. It uses the Uranium graphic (green crystals), despite being in the water, and that part works just fine. But placing the Offshore Platform on the tile to harvest it makes it go blank, because the game doesn't know how to mix an Offshore Platform with the Uranium graphic. Likewise, if I tried using a Mine (which DOES work with Uranium) in water it also has problems.

So to your example, are you asking it to use a Trading Post graphic on a terrain type, or on top of a resource, that Trading Posts aren't normally found on?
 
Ah. Then let me ask this: what terrain type are you trying to do this on, and are there any resources on the tile? If you create a combo that doesn't have an existing graphic, then it blanks out. Either improvement on a terrain type it wasn't built for, or improvement on a resource it wasn't supposed to pair with.

I'll give an example. In my mod, I added Dilithium, which is a mineral only found in coastal water tiles. It uses the Uranium graphic (green crystals), despite being in the water, and that part works just fine. But placing the Offshore Platform on the tile to harvest it makes it go blank, because the game doesn't know how to mix an Offshore Platform with the Uranium graphic. Likewise, if I tried using a Mine (which DOES work with Uranium) in water it also has problems.

So to your example, are you asking it to use a Trading Post graphic on a terrain type, or on top of a resource, that Trading Posts aren't normally found on?

I'm testing it on empty plains and grassland tiles with no features, resources, rivers, hills, etc.

  • Trading post displays the art.
  • Copied improvement with mine artdef displays the art.
  • Copied improvement with trading post artdef does not display any art.
 
Did this ever get solved?

It's not broken. I've DONE it, many times, as I posted above; there are specific situations where it can't handle the graphics, as I listed. I've got a dozen custom improvements in my mod, all of which use existing art definitions and all of which work.

But I'll post more in your other thread.
 
Could it be a particular issue with farm graphics, because farms display differently depending on whether adjacent tiles are farms or not?
 
Could it be a particular issue with farm graphics, because farms display differently depending on whether adjacent tiles are farms or not?

Very easily. A LOT of graphical things depend on adjacent hexes, era, civilization art style, and so on. So some graphics just might not be copyable.

The easiest way to check that is to try changing it to use, say, the Mine graphic instead. If it stays blank, then you know there's some other issue, but if the Mine appears then you know it's Farm-specific.
 
Very easily. A LOT of graphical things depend on adjacent hexes, era, civilization art style, and so on. So some graphics just might not be copyable.

The easiest way to check that is to try changing it to use, say, the Mine graphic instead. If it stays blank, then you know there's some other issue, but if the Mine appears then you know it's Farm-specific.

Mine graphics works - weird!

\Skodkim
 
Mine graphics works - weird!

Then that tells us the problem is in the variability of the Farm graphics. Era variation, culture group variation, or adjacent tile variation. I don't have the database in front of me, so I can't tell you which is most likely to be causing the issues and/or if the problem can be avoided in some other way.

In the short term, change it to some improvement that lacks any sort of variation. Or try using something like the Marsh graphic instead; Marshes, Oases, Flood Plains, Forests, and Jungles are Features, and so their graphics are designed to be placed on top of (or removed from) terrain without any sort of adjacency, era, or culture adjustment. I've used that to my advantage in my terraforming code from time to time.
 
Back
Top Bottom