Happiness Trait

theGuitarist27

Chieftain
Joined
Nov 4, 2017
Messages
16
Hey guys, I really need some help with creating my own civ. I'm quite new to modding, and I really hope somebody here could help me.

I want my civ to receive +1 (global) happiness for every city in the empire.
I also want my civ to receive 100 culture every time a great person is born.

A cousin of mine also said something about having to "redirect" (or something like that) your lua code into xml, if someone could help me with that too, I'd really appreciate it.

Thanks in advance

Btw, if this isn't the right place to post this, please mention
 
Assuming that you know your way around in XML (the bare basics of civ5 modding), here's how to do the first thing.
Create a dummy building (so a building with <GreatWorkCount>-1</GreatWorkCount>, <NukeImmune>true and <NeverCapture>true) which provides +1 global happiness (look at how the Notre Dame adds happiness if you don't know the column).
Then, in your trait, set <FreeBuilding>BUILDING_THE_DUMMY_BUILDING_I_JUST_CREATED</FreeBuilding>. This ensures that your civ will receive the happiness dummy in each city exactly once. If a city is captured/taken away, <NeverCapture> ensures that the conqueror does not gain access to the building. The negative <GreatWorkCount> ensures that the building is hidden in the city screen.

The 2nd part would require Lua (or I might be overlooking some useful XML columns). There are 2 options: Either grant the culture upon Great Peron birth, which requires more Lua, or grant the culture when the Great Person is expended (which requires significantly less Lua).
I will be providing the latter for you here:
Code:
local iCiv = GameInfoTypes.CIVILIZATION_GUITARIST_CIV_THAT_GAINS_CULTURE_FROM_GREAT_PEOPLE_EXPENDED;
local iFreeCultureAmount = 100;

function FreeCultureFromGreatPeople(iPlayer,iUnitType) --iUnitType=UNIT_ENGINEER for example. It's just the UnitType unfortunately
     local pPlayer = Players[iPlayer] --get the player pointer (allows us to use functions)
     if pPlayer:GetCivilizationType() == iCiv then --is the civ that expended the unit playing as my custom civ?
           print(pPlayer:GetName()..' expended a Great Person and so he gains '..iFreeCultureAmount..' culture'); --print in Lua.log. useful for debugging
           pPlayer:ChangeJONSCulture(iFreeCultureAmount); --grants culture to the given player
     end
end
GameEvents.GreatPersonExpended.Add(FreeCultureFromGreatPeople); --subscribe to teh gameEvent with the given function. I.e. the given function executes whenever the GameEvent fires.
 
Top Bottom