Help modding unhappiness effects

g0datwork2

Chieftain
Joined
Jan 13, 2015
Messages
12
Im trying to make a leader trait that makes units GAIN 2% combat strength per unhappiness. Anyone have any idea how to do this.
 
So if I make it just like plus 15 percent when unhappy could I just make a promotion then some time of clauses like it unhappy =true then give promotion. (Don't have much mod experience but know some coding lol)
 
you have to create 50 promotions (4%, 8%, ... 100%) in XML
Not necessarily...
Think binary. You'd need a 2% and 4% to begin with, yes, but when the player has 3 unhappiness and needs a 6% boost, just give all of the units both the 2% and 4%. By combining other promotions, you can severely cut down on space taken up in the civilopedia and XML files.
Spoiler :
Code:
2		= 2
4		= 4	
2 + 4		= 6	
8		= 8
8 + 2		= 10
8 + 4		= 12
8 + 4 + 2	= 14
16		= 16
16 + 2		= 18
16 + 4		= 20
16 + 4 + 2	= 22
16 + 8		= 24
16 + 8 + 2	= 26	
16 + 8 + 4	= 28
16 + 8 + 4 + 2	= 30
32		= 32

And so on...
Reusing that concept a couple more times, with just 5 promotions you could give the player's units up to 62% bonus, which corresponds to 31 unhappiness, and realistically unless they're the worst civ5 player known to man OR they're purposely trying to lower their unhappiness beyond rock bottom, there shouldn't be any legitimate reason for anyone to have a bonus that high. Even so, the algorithm can still be easily extended to accommodate 6 promotions for up to a 126% bonus (64 + 32 + 16 + 8 + 4 + 2), 7 promotions for up to a 254% bonus (128 + 64 + 32 + 16 + 8 + 4 + 2), 8 promotions for - without even calculation, I can guess it will be 510%, because according to the pattern, it should be the next binary number - 2. (So 9 promotions should be 1022%, right?)

This is actually a reuse of an idea UltimatePotato came up with for dynamically adding any amount of tourism, but I think with a little simple adjustment to the bit-converting part of the lua, it should be equally applicable here.

But generally, yes, having something like this max out at some point is a good idea.
 
how would I write the new promotion though cuz dont all promotions have to come from the promotion table
 
Not necessarily...

good idea
i think though 25 different promotions is better as you dont pollute UI (unit panel)
civilopedia issue is bad, dont know if promotions can be hidden from pedia like buildings
with xml theres no problem as you can add those promotions with sql (no xml copy-paste): join promotion data with range of ints 1..25 (can be obtained from any table's ID column) and insert into promotions
 
It might be possible to hide the promotion from the civilopedia by omitting <PediaType> and <PediaEntry>:
Code:
<PediaType/>
<PediaEntry/>
But I've never actually tried it so the game might dump on it by causing a hash in the civilopedia.
 
Back
Top Bottom