Problem with dummy happiness buildings

Ablatt_Ross

Chieftain
Joined
Jul 8, 2018
Messages
4
I've been working on a Finland civ with a friend of mine for a while. We're both experienced in programming (albeit not Lua, but the learning curve isn't overly large) and getting used to modding for civ, however we've run into a little problem regarding dummy happiness buildings.

We've found adding them to a city easy enough - that logic is completely fine - but the problem arises when said cities containing the dummy buildings are captured by enemy civs.

The UA is simply "+1 Happiness for every Great Person expended", but to use the dummy buildings (which are either captured and utilised by enemy civs if NeverCapture = false or destroyed and irretrievable if NeverCapture=true) means that happiness is lost because its dependent on the city belonging to Finland.

If there is a way around this then any suggestions would be really helpful (and some lua code/hooks would be helpful too. Still trying to wrap our heads around it.)
 
You could leave the building(s) in the city and use the CityCapureComplete event, if the city is not Finnish and contains the building(s), remove it/them (with Lua) and add it/them to an alternative Finnish city
 
Code:
	<Resources>
		<Row>
			<Type>RESOURCE_DUMMY_A</Type>
			<Description>TXT_KEY_RESOURCE_DUMMY_A</Description>
			<Help>TXT_KEY_RESOURCE_DUMMY_A_HELP</Help>
			<ResourceClassType>RESOURCECLASS_BONUS</ResourceClassType>
			<IconString>[ICON_RES_IRON]</IconString>
			<PortraitIndex>0</PortraitIndex>
			<IconAtlas>RESOURCE_ATLAS</IconAtlas>
		</Row>
	</Resources>
	<Language_en_US>
		<Row Tag="TXT_KEY_RESOURCE_DUMMY_A">
			<Text>Dummy Resource A</Text>
		</Row>
		<Row Tag="TXT_KEY_RESOURCE_DUMMY_A_HELP">
			<Text>Used to track the number of A</Text>
		</Row>
	</Language_en_US>
And get the number of accumulated Dummy resource in lua->>
Code:
Player:GetNumResourceTotal(GameInfoTypes.RESOURCE_DUMMY_A)
Add +1 to the number of accumulated Dummy resource in lua->>
Code:
Player:ChangeNumResourceTotal(GameInfoTypes.RESOURCE_DUMMY_A, 1)
So whenever a Great Person is expended make the code add the +1 to the count. Then set the number of dummy buildings (which actually give the happiness) in the capital equal to the result obtained from
Code:
Player:GetNumResourceTotal(GameInfoTypes.RESOURCE_DUMMY_A)
I directly use a dummy resource in two building-definitions wherein each copy of BuildingA grants one copy of ResourceA, and BuildingB consumes two of ResourceA. The game does not care whether a resource is defined as a Bonus or not -- it tracks them all and properly deducts and adds Bonus resources which means dummy resources which are never placed on the map anywhere can in fact be used to track these sorts of things.

The upside on all this are that a special dummy social policy is not needed where a dummy resource will accomplish the task (so we don't have to worry about the oddball side-effects of a player having "too many" social policies), but also like social policies Dummy Resources are not subject to being "disappeared" because a city was captured. Dummy Resources are owned by the player, not by any city.

The only downside here is if some other mod reworks the Resource system to for example make Bonus resources behave like Luxury resources in terms of Happiness values or whatever. But that's a mod compatibility issue that can be addressed when and if needed.
 
Top Bottom