Adding happiness to a non-luxury resource

Countbuffalo

Chieftain
Joined
Aug 16, 2013
Messages
94
Hi, I'm creating a Civ and I want part of the UA to give +1 Happiness from Wheat, my initial thoughts are that this will require some LUA work, though if it's possible with XML then please let me know.

I initially thought maybe it would make use of checking plots, but plots seem to be terrain rather than the resources on them. Usually similar things get the bonuses from the improvement, but then I'd end up with +1 happiness from all farms.

Would it be possible to modify one of the pantheon beliefs? That covers things such as giving resources from unimproved resources.
 
Plots are
- plot type (mountains, hills, flat - see PlotTypes.PLOT_XYZ)
- plus terrain (plains, desert, etc - see the Terrains table)
- plus (optional) feature (forest, ice, fallout, etc - see the Features table)
- plus (optional) resource (gems, wheat, iron, etc - see the Resources table) - strategic resources have a count
- plus (optional) improvement (farm, mine, moai, etc - see the Improvements table) - may be pillaged
- plus (optional) route (road or rail - see the Routes table) - routes are cumulative (rail implies also a road) - may be pillaged

A plot can only have ONE of each thing (so no fallout on forests as they're both Features)

Plots also have an owner civ and owning city. Plots may also be being worked by a city.

So you can find all wheat resources by iterating all the plots on the map and testing for pPlot:GetResourceType() == GameInfoTypes.RESOURCE_WHEAT
 
Ah, thanks, so I just need it to check the tiles, return the number of wheat tiles, then give local/global happiness based on this?

Edit, nevermind, I've cleared this. How does this look?
Code:
function Happinessfromwheat(player)
   local pplayer = Players[player]
   if pplayer:IsAlive() and pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HERO then
   for pCity in pPlayer:Cities() do

   pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_UDON, 0)

   local NumberCultureBuildings = 0;
   for i = 0, pcity:GetNumCityPlots() -1,1 do
   local pPlot = Pcity:GetCityIndexPlot(i)
   if pPlot:GetOwner() ==player a pPlot:GetResourceType() == GameInfoTypes.RESOURCE_WHEAT then
   NumberCultureBuildings = NumberCultureBuildings + 1
   end
end

It makes use of an invisible, happiness giving building.

I want to use very similar thing for the other part of my UA. This time I want it to count Culture yield and create a different dummy building for every 5 culture an empire is producing, i've written this so far, but i'm a little stuck.

Code:
function tourism from culture(player)
local pplayer = Players[player]
if pplayer:IsAlive() and pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HERO then
for 

pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_HEROES, 0)

local NumberCultureBuildings = 0
for i = 0, pcity:GetNumCityPlots() -1,1 do
local pYield = Pcity: GetCityIndexYield (i)

and again I realise this code is incorrect, I've just looked over it and i'm trying to get yield from plots, rather than from all of the cities.
 
To avoid the prior post becoming too cluttered, I'm posting this here, with my code to give 2 tourism per 5 culture, I'm using invisible buildings again, which means I can use the majority of the code for happiness from wheat.

I'll assume this will be used to find the culture value
Code:
int Player:GetTotalJONSCulturePerTurn() then




Overall I need something along these lines right?
Code:
--If player is Yuna
if pplayer:IsAlive() and pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HERO then

--Get Civ Culture
int Player:GetTotalJONSCulturePerTurn() then 

--Every five culture


--Create Local building giving tourism
pCity:SetNumRealBuilding(GameInfoTypes.BUILDINGHEROES, 0)
NumberCultureBuildings - NumberCultureBuildings + 1
 
Back
Top Bottom