Page 1 of 1

Finding highest personality trait value?

Posted: Thu Sep 13, 2018 7:02 pm
by aotihav
First of all, thank you so much for Love/Hate! It's really a great asset!
I was wondering if there was a way to find the highest personality trait value at a given time: e.g. a character with 50 Respect, -50 Deception, and 75 Loyalty returning Loyalty as the highest value? I completely understand if that's outside the scope of Love/Hate.

Re: Finding highest personality trait value?

Posted: Fri Sep 14, 2018 4:54 am
by Tony Li
Hi,

There isn't a built-in method or visual scripting action, but you can check it manually in a little method, something like:

Code: Select all

var db = FactionManager.instance.factionDatabase;
var faction = db.LookupFactionByName("Some Name");
int highestIndex = 0;
int highestValue = -100;
for (int i = 0; i < faction.traits.Length; i++)
{
    if (faction.traits[i] > highestValue) highestIndex = i;
}
Debug.Log("Highest trait is " + db.personalityTraitDefinitions[highestIndex].name + " at " + highestValue);