[RT] How do civilizations get perks besides through Personality?

g02703

Chieftain
Joined
Apr 2, 2016
Messages
33
Please correct me if I'm misunderstanding something, but from observing the XML in the game's assets folder,

Civilization has a Personality field/reference, so we create a Personality record for a custom sponsor.

Each Personality has a UniquePersonalityTrait field of type PersonalityTrait.

There are PersonalityTraits_PlayerPerks of a Personality, which must be identified by one of the four PersonalityTraitCategories (Character, Political, Domestic, and Military). And we have to make 3 PersonalityTraits_PlayerPerks that must be of the Character category, and 3 distinct levels.

Each PersonalityTraits_PlayerPerks associates a PersonalityTrait and a PlayerPerk, and the PlayerPerk is in which we define bonuses like added yield of something for a building, cheaper cost to buy, faster development, and stronger attack/defense for military units.

I don't see something like a Civilizations_PlayerPerks table where it would keep track of which perks a civilization might have at runtime. Yet I still see player:AddPerk('PLAYERPERK_ID') and player:HasPerk('PLAYERPERK_ID') in some lua code even for RT.

When I sign one of another faction's foreign policy, my civ gains the PlayerPerk associated with that foreign policy. I also think that (sorry, I didn't really look) Cargo, Spacecraft, Virtues (as Policies carried over from Civ5), and quest decisions also have associated PlayerPerks that I would gain when I choose them.

If it's possible in RT, how do I write the XML to declare that my sponsor gets a specific PlayerPerk that isn't a part of the Personalities system? Do I code this in lua in some game initialized event handler?
 
If it's possible in RT, how do I write the XML to declare that my sponsor gets a specific PlayerPerk that isn't a part of the Personalities system? Do I code this in lua in some game initialized event handler?
A faction will always have exactly 1 of the 3 perks associated with the 3 levels of their unique character trait. You can add your effect to those 3 perks to guarantee a player has it.

Alternatively, if you want to have it as a separate perk it would be a ~4 lines of lua to player:AddPerk(YOUR_PERK) to the player with that civilization at the start of the game.

I also think that (sorry, I didn't really look) Cargo, Spacecraft, Virtues (as Policies carried over from Civ5), and quest decisions also have associated PlayerPerks that I would gain when I choose them.
By default there is not functionality to have Loadouts (ei: Cargo, Spacecraft, Colonists) and Virtues grant a playerPerk. But I've already written some code that does it. (Virtues, Loadouts)
 
YES! Thank you very much! I went with the XML route instead of LUA for this.

So, assuming that we have set up our personality traits and our "bonus" PlayerPerk:


<PersonalityTraits_Perks>
<!-- PlayerPerks designated for the character trait are not shown -->
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>1</Level>
</Row>
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>2</Level>
</Row>
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>3</Level>
</Row>
</PersonalityTraits_Perks>


The above code would associate the primary personality trait with the bonus PlayerPerk.

Can someone confirm if the naming of PersonalityTraitType, PlayerPerk, and other related data is not only convention but actual rules?

For example, for PersonalyTraitType, it must ALWAYS start with PERSONALITY_TRAIT_CHARACTER, followed by _, then your sponsor's name, another _, then finally, A?

Also, (not shown in the above code), the player perk type that we want to be associated with the unique personality trait must be named PLAYERPERK_PERSONALITY_TRAIT_CHARACTER, followed by _, then the sponsor's name, another _, then A, then a number matching the tier?

From experience, I did not follow the "convention", and it messed up my diplomacy UI - my character traits were empty, and the Political, Domestic, and Military sections disappeared. When I followed the naming "conventions" I got my diplomacy screen back and working as intended.

@Machiavelli24, I will check out your Loadout mods - it looks extremely useful. Thank you!
 

<PersonalityTraits_Perks>
<!-- PlayerPerks designated for the character trait are not shown -->
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>1</Level>
</Row>
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>2</Level>
</Row>
<Row>
<PersonalityTraitType>PERSONALITY_TRAIT_CHARACTER_MYSPONSOR_A</PersonalityTraitType>
<PlayerPerkType>PLAYERPERK_BONUS</PlayerPerkType>
<Level>3</Level>
</Row>
</PersonalityTraits_Perks>
This is not done correctly, it would make all 3 levels use exactly the same bonuses. Instead do it as Machiavelli has said, create 3 perks with the same bonuses and just change the numbers. Like this:

Code:
<PersonalityTraits_Perks>
		<Update>
			<Where PersonalityTraitType="PERSONALITY_TRAIT_CHARACTER_INDUSTRY_A" Level="1"/>
			<Set PlayerPerkType="PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_1"/>
		</Update>
		<Update>
			<Where PersonalityTraitType="PERSONALITY_TRAIT_CHARACTER_INDUSTRY_A" Level="2"/>
			<Set PlayerPerkType="PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_2"/>
		</Update>
		<Update>
			<Where PersonalityTraitType="PERSONALITY_TRAIT_CHARACTER_INDUSTRY_A" Level="3"/>
			<Set PlayerPerkType="PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_3"/>
		</Update>
	</PersonalityTraits_Perks>

	<PlayerPerks>
		<Row>
			<Type>PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_1</Type>
			<Help>TXT_KEY_RYIKA_PLAYERPERK_PERSONALITY_TRAIT_PAN_ASIA_1_HELP</Help>
			<CapitalGrowthMod>25</CapitalGrowthMod>
			<WonderProductionMod>25</WonderProductionMod>
			<WonderDiploCapitalChange>3</WonderDiploCapitalChange>
		</Row>
		<Row>
			<Type>PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_2</Type>
			<Help>TXT_KEY_RYIKA_PLAYERPERK_PERSONALITY_TRAIT_PAN_ASIA_2_HELP</Help>
			<CapitalGrowthMod>50</CapitalGrowthMod>
			<WonderProductionMod>25</WonderProductionMod>
			<WonderDiploCapitalChange>3</WonderDiploCapitalChange>
		</Row>
		<Row>
			<Type>PLAYERPERK_RYIKA_PERSONALITY_TRAIT_PAN_ASIA_3</Type>
			<Help>TXT_KEY_RYIKA_PLAYERPERK_PERSONALITY_TRAIT_PAN_ASIA_3_HELP</Help>
			<CapitalGrowthMod>125</CapitalGrowthMod>
			<WonderProductionMod>25</WonderProductionMod>
			<WonderDiploCapitalChange>3</WonderDiploCapitalChange>
		</Row>
	</PlayerPerks>

Naming conventions don't matter, the names just have to match each other in different tables. If they don't match each other the UI will be messed up because the game can't find what it's looking for.
 
A faction will always have exactly 1 of the 3 perks associated with the 3 levels of their unique character trait. You can add your effect to those 3 perks to guarantee a player has it.

I just took what he said to say that in addition to my 3 PlayerPerks intended to represent my character, I can create another Personalities_PlayerPerks that all point to the same exact PlayerPerk. So in total, I have 6 Personalities_PlayerPerks. The game doesn't seem to mess up AFAIK when I do this.

However, I could go to my 3 original distinct character-intended PlayerPerks and add additional capabilities, albeit all with the same values for all 3 levels. I think this is the recommended approach, yes?

I only mentioned about convention because of my experience, and I remember a guy in a video on modding for Civ 5 saying that the SDK does check for certain things in naming our keys. I doubted that for a while, but it's possible that it's true.
 
@Ryika - so I guess I can go to my original 3 distinct character-intended PlayerPerks and add the exact same capabilities with the exact same values, then, instead of creating another 3 Personalities_PlayerPerks that all point to the same (4th) PlayerPerk.

The game doesn't seem to mess up, AFAIK with the way I set it up, but if the above recommendation is modding convention, I'll follow it.

There was a video I watched about modding (probably for Civ 5) where the guy said something about making sure our keys contained certain elements because the SDK looks for them. I thought that sounded suspicious, but from my experience, it seems true. I will try again in my next mod not to follow naming conventions (as long as all my references are spelled correctly) and see.
 
I just took what he said to say that in addition to my 3 PlayerPerks intended to represent my character, I can create another Personalities_PlayerPerks that all point to the same exact PlayerPerk. So in total, I have 6 Personalities_PlayerPerks. The game doesn't seem to mess up AFAIK when I do this.

However, I could go to my 3 original distinct character-intended PlayerPerks and add additional capabilities, albeit all with the same values for all 3 levels. I think this is the recommended approach, yes?

I only mentioned about convention because of my experience, and I remember a guy in a video on modding for Civ 5 saying that the SDK does check for certain things in naming our keys. I doubted that for a while, but it's possible that it's true.
Ah, you want to create extra perks, I see. Well, if that works then sure, that's an alternative. The game does however directly pull the Description of the Perk-Helptext and sets it as the Tooltip for the Perk-Levels (I assume it just takes the first one when there are more than one?), so you'd need to add that information into the other Perk.

Just adds more (unnecessary) complexity in my opinion but if you game actually reads both PlayerPerks then I don't see wrong with it if you prefer it that way. My post above was under the assumption that you wanted to use just that one perk for all three levels.
 
Back
Top Bottom