New modder looking for some pointers on a custom Civ

One issue I did finally run into last night are two traits that weren't working -- or at least I'm not aware of how it works.
These are:
Trait_YieldChangesPerTradePartner
Trait_YieldChangesIncomingTradeRoute

Both of those are used by the Moroccan Civ trait "Gateway to Africa" which adds what I assume are inherent bonuses to trade routes. I added those to provide an extra 3 Gold both ways, but when I tested with a Caravan going both ways between my City and an AI city, neither of us seemed to gain any extra Gold; Total Gold was around 2 GPT (really early-game.)

Not sure what's going on there.

Did you establish a trade route with a major player or a city-state? There seem to be a lot of exceptions regarding how trade-routes with city-states work as opposed to major players. Could also be, as Whoward69 put it, the "spaghetti" effect.

Also, with the hidden building being in its own buildingclass, do I need to add code to prevent anyone else from acquiring this? It should be unbuildable with a cost of -1, but I'm not sure if I need to go ahead and override or set its defaultbuilding to nothing.

Cost=-1 and Faithcost=-1 should lock out any civ being able to construct a building in the "normal" way.

I usually include HurryModifier=-1 as an extra safety measure, but I'm not sure it's strictly necessary. I just assumed I would need it the first time I tried a hidden and /or dummy building, and since it was in there after I got everything to work I have always left it there since I always adhere to the "if it ain't broke..." approach.

And completely hiding a building with XML-only relies on GreatWorkCount=-1 as you suspected. But of course as you firgured out, it only works for BNW. Irkalla discovered this code loophole -- he put up a tutorial on it some time back.
 
Haha, glad that information was useful to you, bouncymischa!

LeeS:
I will try to test that eventually; whenever I get started on my next UB, I'll toss those parameters in temporarily and see what happens to spies.

I brought up the ExtraSpies thing only because it wasn't mentioned in your explanation (I think) when these were available. I was under the impression that spies in general were not available before Renaissance, since even the ExtraSpies Trait held off until then to kick in. I was surprised to see that attaching it to a building sidestepped this, and I had a Spy in the Classical Era... lol.

Also, seems Spy names are picked randomly, just like Great People names are. Thought they were read sequentially like City names, so I guess I wasted some effort sorting the Spy names for my Civ.

Edit:
The trade route was to the only other major Civ in the game when I tested it.
Parameters: Duel size Pangaea, 1v1, 4 CS's, standard game speed.
Other Civ was one of Vicevirtuoso's Civs -- Miki Sayaka (Game chose it randomly.)
I progressed a few turns to test other things, then used IGE to give both myself and the AI one Caravan each.
The next turn we sent trade routes to each other, and I observed that none of the trade routes appeared to give more than 2 GPT, despite the Trait set to give a 3 Gold bonus.
 
I brought up the ExtraSpies thing only because it wasn't mentioned in your explanation (I think) when these were available. I was under the impression that spies in general were not available before Renaissance, since even the ExtraSpies Trait held off until then to kick in. I was surprised to see that attaching it to a building sidestepped this, and I had a Spy in the Classical Era... lol.

Yeah, I just assumed everyone would understand that since the building was in control of giving the spies it was the prereqtech for the building that mattered, and not the usual game-mechanics for recieving spies. Seemed a natural assumption to make as "given". Bad assumption on my part.

I probably made the same assumptions for <FreeBuilding>, <FreeBuildingThisCity>, and the <Building_FreeUnits> table. Have to check those to see how specific I was. Useful feedback to me in any event.
 
Yeah, some assumptions I've made so far have been wrong, so I figured it was best to just try it out and see what happened.

I just did another round of testing:
1) Trait_NoTrain for UNITCLASS_MISSIONARY does -not- work. Missionary still appears in list of Faith-purchaseable units, and can be purchased and moved around.

2) Trait_YieldChangesPerTradePartner and Trait_YieldChangesIncomingTradeRoute actually -do- work, just the numbers are in different places, so I probably overlooked them. Both of these trigger -once- per unique trade partner, so each City State triggers the bonus, but each Major Civ can only trigger this once; additional trade routes to them do not get any benefit.

I tested this time by putting in very large numbers to force it to stand out when looking over the various displays. (+30 Gold to me, +10 Gold to them)

Upon selecting a Caravan unit to select the optimal trade route to set, this bonus does -not- appear in any of the calculations. However, once a trade route is set, although the trade route info screen itself still does not reveal any additional gold changes, the GPT value jumped substantially. Checking that revealed that I was getting "+30 Gold from Trait" added directly to my GPT, rather than being lumped with the trade route. Trade partner receives no benefit from this trade route that I opened.

Upon providing the AI Civ (this time, Austria) with a Caravan, they linked a trade route with one of my cities. I receive no benefit (probably because I already had a trade route with them and got my +30 bonus) from this additional trade route. However, the trade route info screen -does- show them gaining an extra +10 Gold from my Civ's Trait right in the trade route list. Why it shows the bonus for them there and not for me, I have no idea.

3) I still don't really have any idea what the MoveRates do.
I spawned both a Venetian Merchant and a standard Great Merchant.
On land, both move identically at 2 moves. Once embarked, the Venetian Merchant had 4 moves, vs. the Great Merchant's 2 moves.
However, I spawned my Great Merchant UU which has the same GREAT_PERSON MoveRate as the standard GM, but has 3 moves on land. Once embarked, he had 4 moves as well..

4) SpaceProductionModifier does accept negative values as well.

5) None of the Production Modifiers seem to affect the World's Fair, and by extension, I'll assume every other similar "League" project.

Think that's all I've got for now.. Need to keep pushing on with the other buildings I need.
 
Just to update, I did a bit more testing.

LeeS, I tried the code you suggested earlier:
Code:
 <Civilization_UnitClassOverrides>
	<Row>
		<CivilizationType>CIVILIZATION_ROME</CivilizationType>
		<UnitClassType>UNITCLASS_MISSIONARY</UnitClassType>
		<UnitType/>
	</Row>
</Civilization_UnitClassOverrides>

This didn't quite work as expected.
The Missionary was still available to purchase using Faith, but upon building the Borobudur, which grants 3 free ones, the game crashed.

I then tried something a little sneakier:
Code:
 <Civilization_UnitClassOverrides>
	<Row>
		<CivilizationType>CIVILIZATION_ROME</CivilizationType>
		<UnitClassType>UNITCLASS_MISSIONARY</UnitClassType>
		<UnitType>UNIT_WORKER</UnitType>
	</Row>
</Civilization_UnitClassOverrides>

The Missionary was -still- available for purchase with Faith. However, upon constructing the Borobudur, instead of providing me with 3 Missionaries, it provided me with 3 Workers.

Not entirely sure where to go from here..
 
I just did another round of testing:
1) Trait_NoTrain for UNITCLASS_MISSIONARY does -not- work. Missionary still appears in list of Faith-purchaseable units, and can be purchased and moved around.

Faith buying is a colossal mess. It's all hardcoded into the DLL and it seems to ignore a pretty large number of factors such as the Civilization_UnitClassOverrides table and the Trait_NoTrain table. There was a pretty major problem with this in an earlier revision of the game, without a single mod running: Siam was able to buy both Wats and standard Universities with Faith if they had Jesuit Education, which catapulted them to the best Civ in the game by a large margin if they got that belief.

But anyway, you aren't gonna get Faith-buyable UUs to work properly with just XML. In fact, it wouldn't surprise me if even the Lua hook PlayerCanTrain didn't work...but I'm gonna try it with Kyouko's new UU.

3) I still don't really have any idea what the MoveRates do.
I spawned both a Venetian Merchant and a standard Great Merchant.
On land, both move identically at 2 moves. Once embarked, the Venetian Merchant had 4 moves, vs. the Great Merchant's 2 moves.
However, I spawned my Great Merchant UU which has the same GREAT_PERSON MoveRate as the standard GM, but has 3 moves on land. Once embarked, he had 4 moves as well..

As far as I know, this has nothing to do with gameplay. I think (emphasis on think) this affects the movement rate of the 3D model across the landscape when you move the unit. Different MoveRates will animate the unit models from point A to point B more quickly.




Also, re: ExtraSpies before the Renaissance Era. This was actually Big Boss's very first UA -- he got a spy on turn 1. It was, uh...super-broken. :lol:

Come to think of it, it could probably be rebalanced by giving out a dummy policy with -100000% Tech Stealing rate until someone reaches the Renaissance. But I'm not bothering with the old version of the MSF anymore, so maybe someone else can give that a shot.
 
Haha, turn 1 spies does indeed sound very broken.

Yeah, it seems like this Faith portion is not going to be possible to really mod. I'll have to think of something else, or some other sort of workaround for this.

It's amusing that I can force the Missionaries to be replaced with Workers, but the game still lets you buy them. Perhaps I'll just see about adding a dummy policy to increase Faith costs 100% and hope they don't want to bother buying Missionaries.

That being said, I've no idea how to go about it.. Looking up how to make a dummy Policy is next on my list, after I get the Promotions done.

I just finished adding my other main UB to the game, and this one doesn't replace anything.
For a sanity check, can anyone verify for me that this is the correct way of preventing any other Civ from building it? I tested briefly, and the game didn't crash, but I'm not sure if this is the right way to do it or not.

Code:
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_NEW_BUILDING</Type>
			<DefaultBuilding/>
		</Row>
	</BuildingClasses>
Code:
<Civilization_BuildingClassOverrides>
		<Row>
			<CivilizationType>CIVILIZATION_NEWCIV</CivilizationType>
			<BuildingClassType>BUILDINGCLASS_NEW_BUILDING</BuildingClassType>
			<BuildingType>BUILDING_NEW_BUILDING</BuildingType>
		</Row>
</Civilization_BuildingClassOverrides>

As well, I ran into a few more problems:
1) Is there any way to override the game's desire to list UU's before UB's in the Civ selection screen? I do have a UU, but I would much rather it display the two UB's that are actually game changing to this Civ.
2) I don't suppose there's any way to modify an Improvement's Yields with a Building, is there?

Vicevirtuoso, I may be close to the point where I may need to ask for your help with some LUA stuff, particularly the Farm replacements we discussed a few days ago. I'm approaching the limit of what I can add via XML, I think.
 
Code:
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_NEW_BUILDING</Type>
			<DefaultBuilding/>
		</Row>
	</BuildingClasses>

I'm suprised this didn't make the game crash. I've always done this sort of thing by creating a dummy (not hidden, just dummy) building to be used as the default building and then adding in the <Civilization_BuildingClassOverrides> table just as you did.

In the dummy building I've just always set prereqtech=null, cost=-1, and faithcost=-1 to lock-out the dummy default building and omitted all the civilopedia tags so the dummy doesn't show in the civilopedia.

Further research into other game elements such as units leads me to suspect I can probably get by without a dummy building. The <Civilization_BuildingClassOverrides> appears to be the key. My untested suspicion is that any building-class that has an override with the <BuildingType> column having a complete entry such as <BuildingType>BUILDING_NEW_BUILDING</BuildingType>
will lock other civs from building anything within that class of buildings when the only building that exists for that class is the default building.

If you wanted to test this suspicion you could change your BuildingClasses table to
Code:
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_NEW_BUILDING</Type>
			<DefaultBuilding>BUILDING_NEW_BUILDING</DefaultBuilding>
	<Description>TXT_KEY_BUILDING_NEW_BUILDING</Description>
		</Row>
	</BuildingClasses>
And then leave your civilization building overrides table just as you already have it.
 
As well, I ran into a few more problems:
1) Is there any way to override the game's desire to list UU's before UB's in the Civ selection screen? I do have a UU, but I would much rather it display the two UB's that are actually game changing to this Civ.
2) I don't suppose there's any way to modify an Improvement's Yields with a Building, is there?

#1 I think whoward69 has a tutorial on how to do that
#2 No.

Added:

re #2 the answer is not directly. but it is possible to modify total city yields for the gold, food, production, and science yields when an improved resource is within the working range of the city.

<Building_ResourceYieldModifiers> actually does work to modify total city yield. But you have to have the resource within the working range of the city, and you have to have the correct improvement for the resource. My earlier testing on this failed simply because I was not looking in the correct place for the modification. I'll be needing to change my tutorial once I'm sure it's consistent -- a friend of mine from steam said he was getting it to work, but also having trouble with it not always working.
 
#1 I think whoward69 has a tutorial on how to do that

Rob (R8XFT) came up with a trick - create an unbuildable UU with the same icon/description as the UB. The UU (just happen to) list in the order the appear in the override table
 
lol, it sounds like I'll end up making more dummy buildings and units than -actual- buildings and units.

LeeS:
I can't explain why what I tried didn't crash, but I admit I only ran a very brief test.
I verified that the new building in question (with the 'blank' defaultbuilding of its class) was buildable and functioned without issue with my intended Civ. I then reloaded as America instead, and used IGE to 'fast forward' my tech progression to when that building normally unlocks, and it was unavailable for me to build, but everything else still functioned as normal.

Still, I want to do things properly where possible, so I will give that code a shot and report back. I actually seem to have forgotten about the <Description> since all my other buildings have been replacements for the EIC and Shrine so far, and it doesn't seem like I need to make BuildingClass stuff for those.

Regarding my question #2, is it possible to do this via LUA? Loop through each workable/improved tile within a city's boundaries, gather a list of eligible tiles, and add a yield to them? (I've not yet read about how the LUA system in this game works yet as it pertains to modding, so I may be asking the impossible sometimes.)

I'm not sure what would make Building_ResourceYieldModifiers work where Building_ResourceYieldChanges doesn't, since both appear to target the same thing, but one adds yields and the other modifies existing yields. I will be interested in seeing your conclusions on this, though. Spaghetti at work, I suppose.

whoward69:
That sounds like a very clever solution, although I'm not sure how to make a dummy UU.. Is it just a unit with a Cost and FaithCost of -1, or something? Would it appear in the list of units available to be built somehow, or is it effectively hidden like the hidden dummy buildings with -1 GreatWorkSlots?

Speaking of all these hidden and dummy things, I think I have an idea for how to restrict my NW to only handing out its free Spy once, but I'm unsure on my logic, so I will have to test it first..
 
Also, re: ExtraSpies before the Renaissance Era. This was actually Big Boss's very first UA -- he got a spy on turn 1. It was, uh...super-broken. :lol:

Well, now I'm worried... I've incorporated the "spies in Classical and Medieval era" code into my TAnuki mod and am ready to post it... is it going to be that broken? So far I've just been using them to manipulate city-states, admittedly.

I suppose I can still post it, and if need be work on an update to reduce the tech-stealing factor. (I figure I can just give the Tanuki a dummy policy to reduce their tech stealing rate outside of the REnaissance... once they hit the REnaissance, everyone will have a spy, so it won't be an issue.)
 
I think part of being broken is more that you could use him from the very beginning.
Being able to "befriend" a Maritime CS within the first 15 turns of the game sounds pretty nuts.
I have no idea how the AI reacts if you steal their tech before anyone else has Spies to catch yours with, though.

LeeS:
I just tested the properly defined BuildingClass entry, and it doesn't work as suspected it should.
I was still able to build the building with the intended Civ, which is normal since it's their UB and has the override entry. However, upon switching to America, they were -also- allowed to build the building (it even showed up on their tech tree) and it functioned properly, granting whatever bonuses the building was supposed to have.

So, short of reverting back to my empty DefaultBuilding entry which you imply could cause problems, I might have to create a "bonus-less" hidden building to set as the DefaultBuilding. (It -can- be a hidden building, right? I don't really want to toss in extra Civilopedia entries if I don't have to.)
 
Still, I want to do things properly where possible, so I will give that code a shot and report back. I actually seem to have forgotten about the <Description> since all my other buildings have been replacements for the EIC and Shrine so far, and it doesn't seem like I need to make BuildingClass stuff for those.
Replacements that fit within an existing class do not need a <BuildingClasses> table since that already exists. It is always better for such unique replacement buildings to not include a <BuildingClasses> table as it would conflict with the one Firaxis supplied.
I'm not sure what would make Building_ResourceYieldModifiers work where Building_ResourceYieldChanges doesn't, since both appear to target the same thing, but one adds yields and the other modifies existing yields. I will be interested in seeing your conclusions on this, though. Spaghetti at work, I suppose...
Both tables work. Building_ResourceYieldChanges simply adds yields directly to the tiles having the correct resource regardless of whether the tile has an improvement or not. Building_ResourceYieldModifiers makes a direct percentage modification to total city yield when an improved copy of the resource is within the city radius, but the table won't do FAITH or CULTURE.
 
LeeS:
I just tested the properly defined BuildingClass entry, and it doesn't work as suspected it should.
I was still able to build the building with the intended Civ, which is normal since it's their UB and has the override entry. However, upon switching to America, they were -also- allowed to build the building (it even showed up on their tech tree) and it functioned properly, granting whatever bonuses the building was supposed to have.
Well, that's good to know. I did say untested suspicion. Yeah, you'll probably have to go with the dummy route, or add a default building every civ can build that's more generic than the one you want as your Unique Building.
 
lol, it sounds like I'll end up making more dummy buildings and units than -actual- buildings and units.

CIV5Buildings_Madoka.xml is currently rocking a dozen dummy buildings, versus its seven "actual" buildings. It's just the nature of modding this game, I'm afraid.


Regarding my question #2, is it possible to do this via LUA? Loop through each workable/improved tile within a city's boundaries, gather a list of eligible tiles, and add a yield to them? (I've not yet read about how the LUA system in this game works yet as it pertains to modding, so I may be asking the impossible sometimes.)

Yes, using Lua, you can dynamically improve various tiles in various ways -- based on Terrain, Feature, Resource, etc. You can really get into fine-tuning this with dummy Features, if need be.


That sounds like a very clever solution, although I'm not sure how to make a dummy UU.. Is it just a unit with a Cost and FaithCost of -1, or something? Would it appear in the list of units available to be built somehow, or is it effectively hidden like the hidden dummy buildings with -1 GreatWorkSlots?

That, and add the tag <ShowInPedia> and set it to false. (though this still isn't going to prevent the "UU" being linked in the article for the Civ in the Civilopedia, so an explanation in the Strategy text field that this is an unbuildable unit would be helpful!)
 
I think part of being broken is more that you could use him from the very beginning.
Being able to "befriend" a Maritime CS within the first 15 turns of the game sounds pretty nuts.
I have no idea how the AI reacts if you steal their tech before anyone else has Spies to catch yours with, though.

Hmm... since my UA currently only activates in the Classical era, it's probably a bit safer. Heck, even my spies aren't being terribly effective at keeping my city-states allied with me without my active intervention. :p

I'll give it a bit more thought...
 
Both tables work. Building_ResourceYieldChanges simply adds yields directly to the tiles having the correct resource regardless of whether the tile has an improvement or not. Building_ResourceYieldModifiers makes a direct percentage modification to total city yield when an improved copy of the resource is within the city radius, but the table won't do FAITH or CULTURE.

Hmm, I think there may have been a misunderstanding. Both of these would improve yields of a resource regardless of an improvement being built on it; I had wanted to alter the Trading Post building, but it's impossible to tell which type of tile or resource it will be built on, and if it's improved by a policy it'd be available almost as soon as you can build one. I think, with the specificity that I want here, I'd have to resort to doing this in LUA.

Well, that's good to know. I did say untested suspicion. Yeah, you'll probably have to go with the dummy route, or add a default building every civ can build that's more generic than the one you want as your Unique Building.

I will probably go with an unbuildable dummy, I don't want to burden the AI any further by giving them useless buildings. In your Buildings Guide, you posted the "minimal code" for a hidden building; Perhaps I can just stick that somewhere and remove the Happiness bonus, and use that as the stand-in "dummy building with no effects."

CIV5Buildings_Madoka.xml is currently rocking a dozen dummy buildings, versus its seven "actual" buildings. It's just the nature of modding this game, I'm afraid.

Yes, using Lua, you can dynamically improve various tiles in various ways -- based on Terrain, Feature, Resource, etc. You can really get into fine-tuning this with dummy Features, if need be.

That, and add the tag <ShowInPedia> and set it to false. (though this still isn't going to prevent the "UU" being linked in the article for the Civ in the Civilopedia, so an explanation in the Strategy text field that this is an unbuildable unit would be helpful!)

Jeez, that is a lot, lol.

Yeah, I think I will try to pick up LUA, both for this improvement yield issue, as well as the dynamic re-assigning of Farms over Wheat.
Actually, can you remove yields that are given via LUA as well?
Thinking back to the Wheat bonus I had originally discussed with you, I want the code to -remove- any bonus food yield from the tile as soon as -any- improvement is built on it, and then assign a new bonus only if a Farm was built on it. Or something like that.

I think I will send you another PM in the coming days when I have wrapped up all I can do in XML and see if we can hammer something out in LUA, if you do not mind.

Hmm... since my UA currently only activates in the Classical era, it's probably a bit safer. Heck, even my spies aren't being terribly effective at keeping my city-states allied with me without my active intervention. :p

I'll give it a bit more thought...

My UB currently gives a free Spy toward the end of the Classical Era, but it should be sufficiently delayed from the beginning of the game since the NW is almost as expensive to build as the Petra.
 
I will probably go with an unbuildable dummy, I don't want to burden the AI any further by giving them useless buildings. In your Buildings Guide, you posted the "minimal code" for a hidden building; Perhaps I can just stick that somewhere and remove the Happiness bonus, and use that as the stand-in "dummy building with no effects."

Just tested this, and I believe it's working just as well as when I had the DefaultBuilding set to be blank, and hopefully this won't cause any issues down the line either.
UB is still able to be built with the new Civ, as it's specified as an override, but otherwise, it does not appear on the tech tree for America, nor is it in the build list after the tech unlocks.
IGE actually lists two '???' buildings in the Ancient Era, which I assume are my unnamed hidden buildings; one for the New Civ's traits, and the other being this dummy one.

Code:
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_EMPTY_DUMMY</Type>
			<DefaultBuilding>BUILDING_EMPTY_DUMMY</DefaultBuilding>
		</Row>
		<Row>
			<Type>BUILDINGCLASS_NEW_BUILDING</Type>
			<DefaultBuilding>BUILDING_EMPTY_DUMMY</DefaultBuilding>
			<Description>TXT_KEY_BUILDING_NEW_BUILDING</Description>
		</Row>
	</BuildingClasses>
	<Buildings>
		<Row>
			<Type>BUILDING_EMPTY_DUMMY</Type>
			<BuildingClass>BUILDINGCLASS_EMPTY_DUMMY</BuildingClass>
			<Cost>-1</Cost>
			<FaithCost>-1</FaithCost>
			<PrereqTech>NULL</PrereqTech>
			<GreatWorkCount>-1</GreatWorkCount>
			<ArtDefineTag>NONE</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<NeverCapture>true</NeverCapture>
			<HurryCostModifier>-1</HurryCostModifier>
			<PortraitIndex>0</PortraitIndex>
			<IconAtlas>CIV_COLOR_ATLAS</IconAtlas>
		</Row>
	</Buildings>
 
Top Bottom