city:GetBaseYieldRateFromMisc(); sources for "misc" in base game?

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
Is there any other source for this "misc" yield in the base game other than population for YIELD_SCIENCE? I'm using the Change counterpart function and I need to know what I previously set, which means I need to know what the base game is adding. There is no Set function here so you can't "reset" exacly, you have to unchange your previous changes.

Also, does anyone know if changes I make with ChangeBaseYieldRateFromMisc would stick around in the city after the city changes hands by conquest?

The city UI on this is rather strange. Basically, call this yield "from population" if it is science, or "from misc" if anything else.
Code:
local iYieldFromMisc = pCity:GetBaseYieldRateFromMisc(iYieldType);
if (iYieldFromMisc ~= 0) then
	if (iYieldType == YieldTypes.YIELD_SCIENCE) then
		strYieldBreakdown = strYieldBreakdown .. "[ICON_BULLET]" .. Locale.ConvertTextKey("TXT_KEY_YIELD_FROM_POP", iYieldFromMisc, strIconString);
	else
		strYieldBreakdown = strYieldBreakdown .. "[ICON_BULLET]" .. Locale.ConvertTextKey("TXT_KEY_YIELD_FROM_MISC", iYieldFromMisc, strIconString);
	end
	strYieldBreakdown = strYieldBreakdown .. "[NEWLINE]";
end
 
Is there any other source for this "misc" yield in the base game other than population for YIELD_SCIENCE?
Checking the C++ code, the answer is "No".

Also, does anyone know if changes I make with ChangeBaseYieldRateFromMisc would stick around in the city after the city changes hands by conquest?
When a city changes owner, a new city is created, all the buildings, pop, etc are copied over, and the old city deleted, so again no, your changes wouldn't be carried over.

The city UI on this is rather strange.
Probably because in this case the "from misc" is known to be "from population". If you worked a system to add gold based on pop, you could alter that to be "from taxes" for gold.

The rest of the C++ code should work for any yield, so in G&K culture and faith as well as prod, gold, science
 
The rest of the C++ code should work for any yield, so in G&K culture and faith as well as prod, gold, science
Interesting. I could have sworn that both culture and faith did not work when I tested them. However, it's possible that they are working but simply not counted for the city or top panel UI. I'll have to retest this.
 
The bug is in the way Firaxis converted from "Jons culture" to "yield culture"

Code:
> pCity = Players[0]:GetCapitalCity()
> YieldTypes.YIELD_CULTURE
4
> pCity:GetBaseYieldRate(4)
31
> Players[0]:GetJONSCulturePerTurnFromCities()
164
> Players[0]:GetTotalJONSCulturePerTurn()
290
> pCity:ChangeBaseYieldRateFromMisc(4, 2000)
> pCity:GetBaseYieldRate(4)
2031
> Players[0]:GetJONSCulturePerTurnFromCities()
164
> Players[0]:GetTotalJONSCulturePerTurn()
290

As Faith was (partially) initially implemented in the same way as Jons Culture (there are still some redundant "faithper" tables hanging around in the xml files), it suffers the same issues

Code:
> YieldTypes.YIELD_FAITH
5
> pCity:GetBaseYieldRate(5)
9
> Players[0]:GetFaithPerTurnFromCities()
92
> Players[0]:GetTotalFaithPerTurn()
140
> pCity:ChangeBaseYieldRateFromMisc(5, 2000)
> pCity:GetBaseYieldRate(5)
2009
> Players[0]:GetFaithPerTurnFromCities()
92
> Players[0]:GetTotalFaithPerTurn()
140
 
OK. But it's not just the "per turn" functions that are buggered. If you do the above and run it out a few turns, there is no extra increase in culture or faith. You don't see any accumulated yield in Players[0]:GetJONSCulture() or Players[0]:GetFaith(). So it's really not added at all. (I thought from your post that maybe it "worked" but was just missed in the per turn accounting.)

So the only thing that pCity:ChangeBaseYieldRateFromMisc(4, 2000) does is change the output of print(pCity:GetBaseYieldRate(4)).


Even so, it does hold the value for the city. A Lua modder could grab the value of pCity:GetBaseYieldRate(4) each turn and add that much culture to the city via Lua. Then modify city yield and top panel UI to reflect it. Kind of a pain though.
 
So the only thing that pCity:ChangeBaseYieldRateFromMisc(4, 2000) does is change the output of print(pCity:GetBaseYieldRate(4)).
Unfortunately yes. All the code to handle Culture and Faith per city from various "sources" identically to Gold et al is in the city object code (which is what I looked at) but it's just not used by higher level functions (those on the player and team objects) which persist in using the older "JONSCulture" methods. And when Faith was added it followed the Culture model and not the Gold model.

Why anyone would add Faith (with its own set of methods) like this snippet is beyond me!

Code:
if(y == YIELD_CULTURE) {
	pLoopCity->ChangeJONSCulturePerTurnFromBuildings(b->GetTechEnhancedYieldChange(k) * i);
} else if(y == YIELD_FAITH) {
	pLoopCity->ChangeFaithPerTurnFromBuildings(b->GetTechEnhancedYieldChange(k) * i);
} else {
	pLoopCity->ChangeBaseYieldRateFromBuildings(y, b->GetTechEnhancedYieldChange(k) * i);
}

Especially when ChangeBaseYieldRateFromBuildings() works perfectly for Faith.

Even so, it does hold the value for the city. A Lua modder could grab the value of pCity:GetBaseYieldRate(4) each turn and add that much culture to the city via Lua. Then modify city yield and top panel UI to reflect it. Kind of a pain though.

They could, but it would be better to "fix" the DLL - which I may very well do after BNW has been released (as it would involve ripping out all of the JONSCulture/Faith rubbish and using the yield parameterised versions - which would be a lot of changes)
 
Back
Top Bottom