Is my UB idea possible?

Countbuffalo

Chieftain
Joined
Aug 16, 2013
Messages
94
Hi, I'm currently working on creating a Civ, I'm almost finished, just need to get the hardest bit out of the way, the Unique's.

Anyway, for my unique building I want it to convert a a percentage of local happiness into culture, I was wondering if this would be possible?

Thanks, I'm not really sure where to start with Lua and stuff, so being able to ask people who know their stuff is useful.
 
What do you mean by local happiness? Global happiness or happiness that the cities gets because they have an improved luxury or such?
 
I was thinking of happiness on a local city basis, I know the difference would be negligible, but I'm sure some policies refer to local happiness as a thing

Would this use a dummy building then? One that finds provides happiness.

I'd imagine the lua script would find the culture value for a city, then would there be some way to work out a percentage of this and use it as culture?.

Looking through, am I better off giving culture per fixed happiness value, or using a percentage?

Okay, think I've got it
SO - Every two happiness gives 1 culture, my dummy building gives a yield of 1 culture.

So, Lua needs to find the civilisation's happiness value, then somehow create a dummy building for every two happiness. This makes it sound easier. How would I go about doing this?
 
You can use1
City:GetLocalHappiness()
Then:
  1. multiply the 'answer' you get for City:GetLocalHappiness() by your percentage amount
  2. round up or down to nearest integer using either math.ceil(NumberToBeRounded) or math.floor(NumberToBeRounded)
  3. Either:
    • add dummy buildings to the city to match the mathematical result of your calculations. For G&K and BNW the dummy building needs to have in the Building_YieldChanges table:
      Code:
      <Building_YieldChanges>
      	<Row>
      		<BuildingType>BUILDING_DUMMY_SOMETHING</BuildingType>
      		<YieldType>YIELD_CULTURE</YieldType>
      		<Yield>1</Yield>
      	</Row>
      </Building_YieldChanges>
      "BUILDING_DUMMY_SOMETHING" is just an example of a building-name, not necessarily the actual XML-name of the dummy building as you would actually name it. You could just as easily use "BUILDING_HAPPINESS_TO_CULTURE_DUMMY" since the game-player never sees these XML tag-names anyway.
      or:
    • directly change the player's culture at the empire-level through direct lua-methods:
      Code:
      Player:ChangeJONSCulture(IntegerNumberToApplyForTheChange)
      And yes, you really do need to state "ChangeJONSCulture"



1See BNW Lua API Reference
 
Nice! Thankyou very much, all I need to do then is get my equally lua intensive UA out of the way and it'll finally be ready.

How would I do the multiplication phase? Is it literally
Code:
multiply by 4
?
 
Top Bottom