Newbie at Modding cannot change Affinity leveling

Azem.Ocram

King
Joined
Sep 15, 2015
Messages
671
Location
WA
I tried this in November and it didn't work and I tried it again today and it still doesn't work. I want to make the cost of leveling up Affinity become quadratic instead of linear, add more affinity levels, and eventually give each affinity level different perks or unlocks.

I thought that I only needed the .modinfo file and my XML file and I thought I made everything correctly. Help would be appreciated!

My XML file:
Spoiler :

Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 3/26/16 1:56:39 PM -->
<GameData>
	<Affinity_Levels>

		<!-- Scaling is now quadratic instead of linear -->

		<Update>
			<Where ID="1"/>
			<Set AffinityValueNeededAsDominant="8"
				 AffinityValueNeededAsNonDominant="8"/>
		</Update>
		<Update>
			<Where ID="2"/>
			<Set AffinityValueNeededAsDominant="9"
				 AffinityValueNeededAsNonDominant="10"/>
		</Update>
		<Update>
			<Where ID="3"/>
			<Set AffinityValueNeededAsDominant="11"
				 AffinityValueNeededAsNonDominant="13"/>
		</Update>
		<Update>
			<Where ID="4"/>
			<Set AffinityValueNeededAsDominant="14"
				 AffinityValueNeededAsNonDominant="18"/>
		</Update>
		<Update>
			<Where ID="5"/>
			<Set AffinityValueNeededAsDominant="18"
				 AffinityValueNeededAsNonDominant="23"/>
		</Update>
		<Update>
			<Where ID="6"/>
			<Set AffinityValueNeededAsDominant="23"
				 AffinityValueNeededAsNonDominant="30"/>
		</Update>
		<Update>
			<Where ID="7"/>
			<Set AffinityValueNeededAsDominant="29"
				 AffinityValueNeededAsNonDominant="37"/>
		</Update>
		<Update>
			<Where ID="8"/>
			<Set AffinityValueNeededAsDominant="36"
				 AffinityValueNeededAsNonDominant="46"/>
		</Update>
		<Update>
			<Where ID="8"/>
			<Set AffinityValueNeededAsDominant="44"
				 AffinityValueNeededAsNonDominant="55"/>
		</Update>
		<Update>
			<Where ID="9"/>
			<Set AffinityValueNeededAsDominant="53"
				 AffinityValueNeededAsNonDominant="66"/>
		</Update>
		<Update>
			<Where ID="10"/>
			<Set AffinityValueNeededAsDominant="63"
				 AffinityValueNeededAsNonDominant="77"/>
		</Update>
		<Update>
			<Where ID="11"/>
			<Set AffinityValueNeededAsDominant="74"
				 AffinityValueNeededAsNonDominant="90"/>
		</Update>
		<Update>
			<Where ID="12"/>
			<Set AffinityValueNeededAsDominant="86"
				 AffinityValueNeededAsNonDominant="104"/>
		</Update>
		<Update>
			<Where ID="13"/>
			<Set AffinityValueNeededAsDominant="100"
				 AffinityValueNeededAsNonDominant="120"/>
		</Update>
		<Update>
			<Where ID="14"/>
			<Set AffinityValueNeededAsDominant="115"
				 AffinityValueNeededAsNonDominant="136"/>
		</Update>
		<Update>
			<Where ID="15"/>
			<Set AffinityValueNeededAsDominant="131"
				 AffinityValueNeededAsNonDominant="154"/>
		</Update>
		<Update>
			<Where ID="16"/>
			<Set AffinityValueNeededAsDominant="148"
				 AffinityValueNeededAsNonDominant="172"/>
		</Update>
		<Update>
			<Where ID="17"/>
			<Set AffinityValueNeededAsDominant="166"
				 AffinityValueNeededAsNonDominant="192"/>
		</Update>
		<Update>
			<Where ID="18"/>
			<Set AffinityValueNeededAsDominant="185"
				 AffinityValueNeededAsNonDominant="212"/>
		</Update>
		<Row>
			<ID>19</ID>
			<AffinityValueNeededAsDominant>205</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>234</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>20</ID>
			<AffinityValueNeededAsDominant>226</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>256</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>21</ID>
			<AffinityValueNeededAsDominant>248</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>280</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>22</ID>
			<AffinityValueNeededAsDominant>271</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>314</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>23</ID>
			<AffinityValueNeededAsDominant>295</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>330</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>24</ID>
			<AffinityValueNeededAsDominant>320</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>356</AffinityValueNeededAsNonDominant>
		</Row>
		<Row>
			<ID>25</ID>
			<AffinityValueNeededAsDominant>346</AffinityValueNeededAsDominant>
			<AffinityValueNeededAsNonDominant>384</AffinityValueNeededAsNonDominant>
		</Row>
	</Affinity_Levels>
</GameData>
 
When you look at the table in SQLite (or whatever you use) has it been updated? What you have looks ok. If it isn't working there may be some stuff hard-coded behind the scenes.
 
Just copied and pasted your code into a new mod, and it works fine.

The new affinity levels are not displayed properly on the affinity wheel of the diplomacy screen (you might need to write a modified version of the UI lua for that), but the player can earn levels all the way up to 25 when I spam affinity xp using firetuner, and all those levels cost the amount of xp specified in your mod.
 
OK, good! My "testing" was too brief to tell that the costs changed despite of the UI remaining the same.

New questions:
1. How do I change the UI to reflect my changes to the costs?
2. How do I change Affinity perks?

I want to break hybrid perks into 2.5 parts (so the health bonus is weak at first, almost full strength in mid game, and slightly higher than default in late game, if you go along the lines of 21/21/3 or cheat) and straight-line perks into 3 parts (with some unique or reappearing (from vanilla) perks), as well as giving each Affinity level its own perk.

Later down the road, I will want to change victories.
 
1. How do I change the UI to reflect my changes to the costs?
The costs displayed fine for me in the tooltips saying "x/y points needed for next level". If that's not the case for you then you have some problem other than the code you copied and pasted here (perhaps you forgot to set an OnModActivated trigger for the xml file?)

The only problem I noticed was that there were still only 18 concentric rings on the wheel in the "My Affinity" section of the diplomacy screen, so the line went off the edge of the circle when going above that level.
Spoiler :
attachment.php

That's not a major problem, so you could just decide it's not worth the hassle of fixing, and ignore it.

To make it look better though, you'd want to enlarge that wheel and add more concentric rings for your new levels. I've not investigated very much how to do that, but it looks like the relevant variables are hardcoded in the file DiplomacyState_Affinity.lua, so you'd need to copy and paste that file into your mod, edit the relevant lines in it, and flag it as Import Into VFS=true so that your modified version replaces the normal version of the file.

2. How do I change Affinity perks?

This depends whether your mod's for use with Rising Tide, or without it.

In Vanilla, the perks are defined within the <Affinity_Levels> table:
Code:
<Affinity_Levels>
<Row>
	<AffinityValueNeededAsDominant>11</AffinityValueNeededAsDominant>
	<AffinityValueNeededAsNonDominant>11</AffinityValueNeededAsNonDominant>
[b]	<HarmonyPlayerPerk>PLAYERPERK_EXPLORER_MIASMA_IMMUNITY</HarmonyPlayerPerk>
	<PurityPlayerPerk>PLAYERPERK_EXPLORER_DOUBLE_DEFENSE</PurityPlayerPerk>
	<SupremacyPlayerPerk>PLAYERPERK_EXPLORER_CHARGES</SupremacyPlayerPerk>[/b]
	<HarmonyFlavorText>TXT_KEY_AFFINITY_LEVEL_UP_FLAVOR_HARMONY_1</HarmonyFlavorText>
	<HarmonyFlavorAudio>AS2D_NARRATOR_SPEECH_AFFINITY_HARMONY_01</HarmonyFlavorAudio>
	<PurityFlavorText>TXT_KEY_AFFINITY_LEVEL_UP_FLAVOR_PURITY_1</PurityFlavorText>
	<PurityFlavorAudio>AS2D_NARRATOR_SPEECH_AFFINITY_PURITY_01</PurityFlavorAudio>
	<SupremacyFlavorText>TXT_KEY_AFFINITY_LEVEL_UP_FLAVOR_SUPREMACY_1</SupremacyFlavorText>
	<SupremacyFlavorAudio>AS2D_NARRATOR_SPEECH_AFFINITY_SUPREMACY_01</SupremacyFlavorAudio>
</Row>
</Affinity_Levels>

But in RT, they're defined in a table called <Affinity_Perks> instead:
Code:
<Affinity_Perks>
	<Row>
		<PlayerPerk>PLAYERPERK_AFFINITY_TRADER_MIASMA_IMMUNITY</PlayerPerk>
		<HarmonyLevelNeeded>2</HarmonyLevelNeeded>
	</Row>
</Affinity_Perks>
 

Attachments

  • OutsideAffinityWheel.jpg
    OutsideAffinityWheel.jpg
    240.7 KB · Views: 134
Back
Top Bottom