How does BuildingClassYieldChanges work?

bouncymischa

Synthetic Genie
Joined
Nov 28, 2012
Messages
1,537
Location
In a bottle
Or, more specifically, how does it work if there's multiple copies of a building with BuildingClassYieldChanges?

When I was working on buildings for Future Worlds, I decided to try and represent some of the interconnectivity between certain buildings by having them use BuildingClassYieldChanges to modify their yields -- for example, the E-Commerce Server causes the Autoplant to gain +1 Gold. My original thought was that this effect would stack -- if you had 3 E-Commerce Servers, then each Autoplant would generate +3 Science. However, after getting some reports that the buildings weren't working like they were supposed to, I did some experimenting and got some odd results. It appears that the additional yields are being stacked, but if I remove the affected building, then any additional yields beyond the first remain in the city. If I had a city with an Autoplant and 3 cities with E-Commerce Servers, the city with the Autoplant would show a +3 Gold yield from Buildings... but if I removed the Autoplant, only 1 Gold would disappear, leaving +2 Gold from no source at all!

I'm guessing that there's probably some code in the DLL responsible for this -- I believe there are some Lua codes that get used occasionally to adjust yields from buildings directly (rather than through spawning dummy buildings), so I'm wondering if the code increments the yields from buildings properly, but if a building is removed, doesn't check to see how many copies of a building with BuildingClassYieldChanges exists, and thus only decrements one copy. Even the incrementing process seems a bit bugged -- in one test, it seemed like if Building A is modified by Building B, then each time a new Building B was built the yields for each Building A got incremented... but if a new Building A was built, it only checked for BuildingClassYieldChanges once.

All in all, I'm not familiar enough with the DLL code to say for sure... thus, I'm wondering if anyone out there might be able to shed some light on the phenomenon. At the very least, though, I figured it might be a cautionary tale for anyone else considering playing around with the same idea.

(All told, I'm probably just going to have to look at using Lua and more dummy buildings to handle yield modification more effectively... XD)
 
The DLL does NOT cope with multiple buildings in the same city gracefully or consistently. Some features from the multiple buildings work (or have been modded to work), eg happiness related values and yields directly from those buildings, as you have discovered, some features (notably cascade yields as you mention) are still in a state of "suck-it-and-see"
 
You have run smack into the second reason why I don't advise people to use any "Building_BuildingClass____" table for any <BuildingType> that is not a World or National Wonder. Even then the behavior can sometimes be a bit wonky. The three Guilds are a perfect example of the sort of wonkiness that can occur (though they aren't fully defined as National Wonders) -- you can rebuild your Guild if the city where you constructed it gets captured. And if you added a Building_BuildingClassYieldChanges entry to make the Writer's Guild for example add to Amphitheater Yields you could get some non-expected behavior both when you lose and rebuild your Writer's Guild. (note that I have not tested this exact scenario, but I have tested the following one). I once added a Building_BuildingClassYieldChanges to make Great Wall add +1 Gold to Walls, and discovered that the effect did not expire when Great Wall went obsolete, which was 100% contradictory to what I had expected to see.

The first reason why I don't advise use of these tables for anything except a World or National Wonder is that all "Building_BuildingClass____" tables are global in their effects.

For added fun, check what actually happens for table <Building_TechEnhancedYieldChanges>. They aren't applied to the building, but rather directly within the City Yields boxes.

Policy_BuildingClassYieldChanges as I recall also aren't directly added to the building, but rather are added directly to the City.

And as Willam mentioned, you cannot get 'stacking' of Building_BuildingClassYieldChanges from multiple copies of the same building as the <BuildingType> within the same city.
 
The first reason why I don't advise use of these tables for anything except a World or National Wonder is that all "Building_BuildingClass____" tables are global in their effects.

That's precisely congruous for the table to do.

For added fun, check what actually happens for table <Building_TechEnhancedYieldChanges>. They aren't applied to the building, but rather directly within the City Yields boxes.

Policy_BuildingClassYieldChanges as I recall also aren't directly added to the building, but rather are added directly to the City.

There's no difference in meaning to that.

Just keep in mind that the table was meant to apply to Limit1 buildings and you won't go too wrong. Sadly, this means that a matrix effect between Servers and Autoplants as you designed would not be possible.
 
Top Bottom