Making near-copycat resources: where do I look?

isnorden

Amnesiac Modder
Joined
Jul 6, 2012
Messages
608
Location
Madison, Wisconsin, USA
If I wanted to create a new resource which uses the same skin/artdefines as an official one, but has its own onscreen name and font/SV icons...where do I look for the original resource's data? (Examples from the food/drink modpack I'm working on: tweaking Truffles to create a separate Wild Boar resource, or Wheat to create a separate Barley resource.) If anyone can tell me where to find the code that needs reworking, I'd appreciate it very much. :thanx:
 
where do I look for the original resource's data?
I use a SQLite browser (e.g., SQLiteSpy or SQLite Browser for Firefox) to check out the database. Either way, you will also want to get a search tool (e.g., Agent Ransack or grepWin) to search through the XML files.
 
if you're using G&K and BNW, there are files with most of what you need for Resources and Improvements in:

Code:
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\XML\Terrain

Info on the Build functions of Improvements is in

Code:
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\XML\Units

(That's the install path in my Win10 machine)

Whoward has extracted the Improvements info, see the first post here
 
@Nutty: I just finished installing both Agent Ransack and SQLite Manager for Firefox. Which part of my Civ5 directory is the right place to start my search -- would it be the *.db files in the cache? It's been so long since I've done anything with SQL that I feel absolutely clueless.
 
Which part of my Civ5 directory is the right place to start my search -- would it be the *.db files in the cache?
Right, you want cache\Civ5DebugDatabase.db (and cache\Civ5LocalizationDatabase.db for the TXT_KEY entries)
 
Thanks to the users who've replied so far (and a bit of Google-fu), I've searched through the database files...now I need to create a couple of new artdefines that tweak the existing resource data (copying everything that doesn't change, substituting the new text and SV/font icons). I have Dragon Unpacker re-installed; which .fpk file(s) should I rip to get the improvement and resource art?
 
Hopefully I did all the SQL bits correctly. I guess I could also have done the ArtDefine_Landmarks table in the same way as I did the original definition of 'Barley' into the Resources table (ie, copied everything I needed from the ART_DEF_RESOURCE_WHEAT into the new ART_DEF_RESOURCE_BARLEY)

Spoiler SQL bit :
Code:
--========================================================================================================================================================================
--	--Resources
--========================================================================================================================================================================

--you will need to edit the values for PortraitIndex and IconAtlas

INSERT INTO Resources
	(Type,			Description,			Civilopedia,				ResourceClassType,	ArtDefineTag,			PlacementOrder,	ConstAppearance,	MinAreaSize,	MaxLatitude,	RandApp1,	RandApp2,	Unique,	TilesPer,	Flatlands,	Normalize,	IconString,		PortraitIndex,	IconAtlas)
SELECT	('RESOURCE_BARLEY',	'TXT_KEY_RESOURCE_BARLEY',	'TXT_KEY_CIV5_RESOURCE_BARLEY_TEXT',	ResourceClassType,	'ART_DEF_RESOURCE_BARLEY',	PlacementOrder,	ConstAppearance,	MinAreaSize,	MaxLatitude,	RandApp1,	RandApp2,	Unique,	TilesPer,	Flatlands,	Normalize,	'[ICON_RES_BARLEY]',	6,		'RESOURCE_ATLAS')
FROM Resources WHERE Type = 'RESOURCE_WHEAT';


INSERT INTO Resource_YieldChanges
	(ResourceType,		YieldType,	Yield)
SELECT	('RESOURCE_BARLEY',	YieldType,	Yield)
FROM Resource_YieldChanges WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_Flavors
	(ResourceType,		FlavorType,	Flavor)
SELECT	('RESOURCE_BARLEY',	FlavorType,	Flavor)
FROM Resource_Flavors WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_TerrainBooleans
	(ResourceType,		TerrainType)
SELECT	('RESOURCE_BARLEY',	TerrainType)
FROM Resource_TerrainBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_FeatureTerrainBooleans
	(ResourceType,		TerrainType)
SELECT	('RESOURCE_BARLEY',	TerrainType)
FROM Resource_FeatureTerrainBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_FeatureBooleans
	(ResourceType,		FeatureType)
SELECT	('RESOURCE_BARLEY',	FeatureType)
FROM Resource_FeatureBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Improvement_ResourceTypes
	(ResourceType,		ImprovementType)
SELECT	('RESOURCE_BARLEY',	ImprovementType)
FROM Improvement_ResourceTypes WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Improvement_ResourceType_Yields
	(ResourceType,		ImprovementType,	YieldType,	Yield)
SELECT	('RESOURCE_BARLEY',	ImprovementType,	YieldType,	Yield)
FROM Improvement_ResourceType_Yields WHERE ResourceType = 'RESOURCE_WHEAT';

--========================================================================================================================================================================
--	Barley Art_Defines copying Wheat
--========================================================================================================================================================================


INSERT INTO ArtDefine_LandmarkTypes
	(Type,				LandmarkType,	FriendlyName)
VALUES	('ART_DEF_RESOURCE_BARLEY',	'Resource',	'Barley');

INSERT INTO ArtDefine_StrategicView
	(StrategicViewType,		TileType,	Asset)
VALUES	('ART_DEF_RESOURCE_BARLEY',	'Resource',	'SV_Wheat.dds');

INSERT INTO ArtDefine_Landmarks
	(Era,		State,			Scale,			ImprovementType,		LayoutHandler,	ResourceType,			Model,									TerrainContour)
VALUES	('Any',		'Any',			1.0,			'ART_DEF_IMPROVEMENT_FARM',	'SNAPSHOT',	'ART_DEF_RESOURCE_BARLEY',	'NULL',									1),
	('Any',		'UnderConstruction',	1.0,			'ART_DEF_IMPROVEMENT_FARM',	'SNAPSHOT',	'ART_DEF_RESOURCE_BARLEY',	'NULL',									1),
	('Ancient',	'UnderConstruction',	1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Medieval/HB_Medieval_Farm.fxsxml',	1),
	('Ancient',	'Constructed',		1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Medieval/Medieval_Farm.fxsxml',	1),
	('Ancient',	'Pillaged',		1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Medieval/PL_Medieval_Farm.fxsxml',	1),
	('Industrial',	'UnderConstruction',	1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Modern/HB_Modern_Farm.fxsxml',	1),
	('Industrial',	'Constructed',		1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Modern/Modern_Farm.fxsxml',	1),
	('Industrial',	'Pillaged',		1.0,			'ART_DEF_IMPROVEMENT_FARM',	'FARM',		'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Improvements/Farms/Modern/PL_Modern_Farm.fxsxml',	1),
	('Any',		'Any',			0.939999997615814,	'ART_DEF_IMPROVEMENT_NONE',	'SNAPSHOT',	'ART_DEF_RESOURCE_BARLEY',	'Assets/Buildings/Resources/Wheat/Wheat_Decal.fxsxml',			1);

Spoiler text xml :
Code:
<GameData>
	<Language_en_US>
		<!--BARLEY-->
		<Row Tag="TXT_KEY_RESOURCE_BARLEY">
			<Text>Barley</Text>
		</Row>
		<Row Tag="TXT_KEY_CIV5_RESOURCE_BARLEY_TEXT">
			<Text>Barley is Something and Something is Barley!</Text>
		</Row>
	</Language_en_US>
</GameData>

I'd appreciate a Nutty, JFD, and/or whoward69 look-over of the SQL to look for whoopsies. Also, I'm assuming we can copy the definitions in table ArtDefine_Landmarks using the usual "INSERT INTO" and "SELECT" methods like we can do with table Buildings, or what have you, rather than the brute-force method I used for making the new Barley use the Wheat defines.

You will need to add the code for <IconTextureAtlases>, <IconFontTextures>, and <IconFontMapping> as well as come up with the needed ggxml file for the IconFont stuff. I think I caught everything else needed, but of course there is always that one missed thing :(

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

ISN,

  • The real elephant in the room is going to be whether AssignStartingPlots.lua also needs to be edited and a custom version of it used like as Barathor did in the More Luxuries mod. Before proceeding further it will be necessary to know whether a custom version of AssignStartingPlots.lua will be needed in order to get the resources to be placed properly.
  • Also I see Barathor's mod has a Terra.lua which I haven't even looked into yet and don't know exactly what it is supposed to do.
  • AssignStartingPlots.lua is such a pita to try to mod, however, I am not willing to do so if that will be required. Sorry.

edit --> in case you don't spot it, in the SQL you will have to change the filename for the Strategic View to match to your new SV Icon file here:
Code:
INSERT INTO ArtDefine_StrategicView
	(StrategicViewType,		TileType,	Asset)
VALUES	('ART_DEF_RESOURCE_BARLEY',	'Resource',	[COLOR="Blue"]'SV_Wheat.dds'[/COLOR]);
editedit -->which made me realise I had a typo in that I copy/pasted and didn't change the table name, which I have now fixed :(
 
I've already got a resource-placer Lua script, DeepBlue's code (which became part of my most popular mod). I've also got a font icon for all my new resources in the food/drink project, and .ggxml code to match (thank goodness for cut-and-paste). It's mainly those pesky artdefs that get me stuck... Thanks for doing your best to help! :worship:
 

Attachments

I've already got a resource-placer Lua script, DeepBlue's code (which became part of my most popular mod). I've also got a font icon for all my new resources in the food/drink project, and .ggxml code to match (thank goodness for cut-and-paste). It's mainly those pesky artdefs that get me stuck... Thanks for doing your best to help! :worship:
You should be able to use the SQL as a template for grabbing and copy-catting any of the other ArtDefines for Resources. Maybe Nutty or William will be able to respond as to whether there's any reason we cannot use the "INSERT INTO .... SELECT" method for grabbing the info out of table ArtDefine_Landmarks because that will make it possible to make the SQL into even more of a 'user-friendly' template for accomplishing this for any additional ArtDefines you want to muse.
 
Looks good at a glance. Let me know if you have trouble and I can look closer.

There's nothing special about that table that makes SQLite operations different. I personally use a lot of complicated SQL statements on the art defines.

The only oddness with the art defines is the XML template system Firaxis uses for the unit art defines to which we don't have access. Which is why, if you use XML for the unit art defines, it needs to adhere to the SQL database rather than the XML shorthand that Firaxis uses.
 
So for purposes of a better SQL template:
Spoiler barley copies wheat :
Code:
--========================================================================================================================================================================
-- Resources
--========================================================================================================================================================================

--you will need to edit the values for PortraitIndex and IconAtlas and possibly IconString

INSERT INTO Resources
	(Type,			Description,			Civilopedia,				ResourceClassType,	ArtDefineTag,			PlacementOrder,	ConstAppearance,	MinAreaSize,	MaxLatitude,	RandApp1,	RandApp2,	Unique,	TilesPer,	Flatlands,	Normalize,	IconString,		PortraitIndex,	IconAtlas)
SELECT	('RESOURCE_BARLEY',	'TXT_KEY_RESOURCE_BARLEY',	'TXT_KEY_CIV5_RESOURCE_BARLEY_TEXT',	ResourceClassType,	'ART_DEF_RESOURCE_BARLEY',	PlacementOrder,	ConstAppearance,	MinAreaSize,	MaxLatitude,	RandApp1,	RandApp2,	Unique,	TilesPer,	Flatlands,	Normalize,	'[ICON_RES_BARLEY]',	6,		'RESOURCE_ATLAS')
FROM Resources WHERE Type = 'RESOURCE_WHEAT';


INSERT INTO Resource_YieldChanges
	(ResourceType,		YieldType,	Yield)
SELECT	('RESOURCE_BARLEY',	YieldType,	Yield)
FROM Resource_YieldChanges WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_Flavors
	(ResourceType,		FlavorType,	Flavor)
SELECT	('RESOURCE_BARLEY',	FlavorType,	Flavor)
FROM Resource_Flavors WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_TerrainBooleans
	(ResourceType,		TerrainType)
SELECT	('RESOURCE_BARLEY',	TerrainType)
FROM Resource_TerrainBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_FeatureTerrainBooleans
	(ResourceType,		TerrainType)
SELECT	('RESOURCE_BARLEY',	TerrainType)
FROM Resource_FeatureTerrainBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Resource_FeatureBooleans
	(ResourceType,		FeatureType)
SELECT	('RESOURCE_BARLEY',	FeatureType)
FROM Resource_FeatureBooleans WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Improvement_ResourceTypes
	(ResourceType,		ImprovementType)
SELECT	('RESOURCE_BARLEY',	ImprovementType)
FROM Improvement_ResourceTypes WHERE ResourceType = 'RESOURCE_WHEAT';

INSERT INTO Improvement_ResourceType_Yields
	(ResourceType,		ImprovementType,	YieldType,	Yield)
SELECT	('RESOURCE_BARLEY',	ImprovementType,	YieldType,	Yield)
FROM Improvement_ResourceType_Yields WHERE ResourceType = 'RESOURCE_WHEAT';

--========================================================================================================================================================================
--	Barley Art_Defines copying Wheat
--========================================================================================================================================================================


INSERT INTO ArtDefine_LandmarkTypes
	(Type,				LandmarkType,	FriendlyName)
VALUES	('ART_DEF_RESOURCE_BARLEY',	'Resource',	'Barley');

--you will need to edit the value for Asset

INSERT INTO ArtDefine_StrategicView
	(StrategicViewType,		TileType,	Asset)
VALUES	('ART_DEF_RESOURCE_BARLEY',	'Resource',	'SV_Wheat.dds');

INSERT INTO ArtDefine_Landmarks
	(Era,	State,	Scale,	ImprovementType,	LayoutHandler,	ResourceType,			Model,	TerrainContour)
SELECT	(Era,	State,	Scale,	ImprovementType,	LayoutHandler,	'ART_DEF_RESOURCE_BARLEY',	Model,	TerrainContour)
FROM ArtDefine_Landmarks WHERE ResourceType = 'ART_DEF_RESOURCE_WHEAT';
 
Many thanks to both of you, Nutty and LeeS! I've done 99% of my from-scratch modding in XML only; so when another coding language is necessary, it helps when someone like you makes that code clearer to read. :rockon:
 
Back
Top Bottom