V9.1 Police State gives only 30% on CH production

Herb0815

Chieftain
Joined
May 9, 2010
Messages
51
As you can see in the screenshot Edinburgh is only getting a 30% production boost on the CH instead the 100% it should with Police State.
 

Attachments

  • edinburgh.jpg
    edinburgh.jpg
    204 KB · Views: 60
turns to build = cost / income

We're unable to increase cost dynamically with our current modding tools, so I do cost-per-population by reducing income instead (the inverse), if that makes sense. I'm not sure of a good way to explain this on the tooltip.

However, it's very strange the production bonus is listed twice. That part is definitely a bug and I'm investigating it now.
 
It's because of the popcostmod you added to the Courthouse.
21/2.3=9.1

That is: [7*(100+200)]/[1+(10*13)/100]
 
Right. The +100% shouldn't be listed twice, however. It's very puzzling:

  1. 1 entry for the courthouse in Policy_BuildingClassProductionModifiers
  2. This is added to baseModString by M_GetBaseYieldModifierTooltip 1 time.
  3. baseModString is added to the main strTooltip 1 time.
There should only be one copy on the tooltip. I've looked over the various steps used to create this tooltip and haven't spotted the logic mistake yet.
 
I'm currently looking at the function M_GetBaseYieldRateModifier in YieldLibrary.lua (disclaimer: still 8.7).

On building it says:
Code:
elseif itemTable == GameInfo.Buildings then
				yieldMod = yieldMod + GetBuildingClassConstructionYieldModifier(city, yieldType, itemTable, itemID, queueNum)
				if IsWonder(itemID) then
					return yieldMod + GetWonderConstructionModifier(city, yieldType, itemTable, itemID, queueNum)
				end
				logger:Trace("buildMod = %s %s", city:GetBuildingProductionModifier(itemID), itemTable[itemID].Type)
				return yieldMod + city:GetBuildingProductionModifier(itemID)

You get +100 once from your own function GetBuildingClassConstructionYieldModifier. My guess would be you get another +100 from the vanilla function city:GetBuildingProductionModifier.
 
You're right and thanks for pointing that out. When I created that a separate function was necessary because the vanilla function didn't check policies. It appears they changed the vanilla function. Those kind of changes are frustrating to deal with... when undocumented, it's difficult to know what changes are made to the game core. It was hard enough reverse-engineering it the first time! :lol:

I've fixed that problem now, but the tooltip is a separate issue. The line appearing in the tooltip is "TXT_KEY_PRODMOD_BUILDING_POLICY", which in the current version is added to the tooltip on line 1413 of InfoTooltipInclude.lua. Maybe a fresh pair of eyes will help identify the logic error.
 
In case you haven't seen it yet, perhaps I'm missing something, but as far as I can see:

The first line is added by:

Code:
function M_GetBaseYieldModifierTooltip(city, yieldType)
	local tooltip = ""
...
	else
		tooltip = tooltip .. (city:GetYieldModifierTooltip(yieldType) or "")
...
	end
	return tooltip
end
constructed in the DLL I assume, and which now includes the policy effect

That function is the base for the tooltip in InfoToolTipInclude.lua:

Code:
local baseModString		= M_GetBaseYieldModifierTooltip(pCity, yieldType)

So then a second line with the same info gets added on a [newline] because of your self-made function:

Code:
local buildingMod = 0
	if yieldType == YieldTypes.YIELD_PRODUCTION then
		settlerMod = GetCapitalSettlerProductionModifier(pCity)
		buildingMod = GetBuildingClassConstructionYieldModifier(pCity)
	end
...
	if buildingMod ~= 0 then
		baseModString = baseModString .. Locale.ConvertTextKey("TXT_KEY_PRODMOD_BUILDING_POLICY", buildingMod)
	end
 
Top Bottom