Modding Relationship Points

From Wildermyth Wiki

There are three types of relationships between characters: friend, rival and lover. Each one has five levels with increasing effects on combat. From the modding standpoint, there are two things you can do with these relationships: start/stop them, and add points to existing relationships.

Start/stop a relationship

To start a relationship, add this outcome in the encounter:

{
	"class": "RelationshipPoints",
	"amount": "20",
	"who": [ "volunteer", "hero" ],
	"forceChangeRelationshipTo": "lover"
}

See the next section for details of the amount. The "who" list should be two roles that are defined for the encounter. The new relationship may be any of the three types. You can see the existing encounter effects/wilderness/paradise.json (id encounter_wilderness_paradise) for an example. Adding a relationship between a pair removes any other relationship between that pair. It is possible for a character to be in any number of relationships, but only one per pair.

To stop a relationship, use "forceChangeRelationshipTo" : "none".

Adding relationship points

The "amount" line in the outcome determines how many points to add. There is no direct way to control the relationship level. The breakpoints of relationships are at 20, 60, 120, 200, 300 points, or 20, +40, +60, +80, +100. However, the personality types of the two partners plays a huge role in awarding points. If the amount in the outcome is 20, the actual number of points awarded may be as low as 5, or as high as 80 or more. If your goal is to increase the relationship by one level, so that the player can see a tangible result, there is currently no way to do that.

The dev team has posted the actual code for scaling in the discord channel in late November; note this represents the code at that time, and may no longer be representative of the current software version.

   //calculate compatibility score
        float compatibility = calculateCompatibility(a, b);

        
        float charismaModifier = 0.005f*(a.getStat(CHARISMA) + b.getStat(CHARISMA)) + 0.5f;

        //use absolute value of compatibility here, so that "interesting" relationships are boosted.
        //floor of 1, likely ceil of 2
        float fascinationFactor = (Math.abs(compatibility) + 3f) / 3f;

        float finalModifier = MathUtils.clamp(charismaModifier * fascinationFactor, 0.33f, 3f);
        float finalRP = rawRP * finalModifier;
    private float calculateCompatibility(Status a, Status b) {
        float sum = 0;
        int statThreshold = 50;
        for (CompatibilityStats compatStat : compatStats) {
            if (a.getStat(compatStat.stat) >= statThreshold) {
                for (Stats cs : compatStat.positive) {
                    if(b.getStat(cs) >= statThreshold) {
                        sum += 1.0f;
                    }
                }
                for (Stats cs : compatStat.negative) {
                    if(b.getStat(cs) >= statThreshold) {
                        sum -= 1.0f;
                    }
                }
            }
        }
        return sum;
    }
and 
    enum CompatibilityStats {
        bookish(BOOKISH, HEALER, SNARK, GREEDY, GOOFBALL),
        coward(COWARD, LEADER, HEALER, HOTHEAD, LONER),
        goofball(GOOFBALL, GREEDY, SNARK, BOOKISH, POET),
        healer(HEALER, COWARD, BOOKISH, HOTHEAD, ROMANTIC),
        hothead(HOTHEAD, LEADER, ROMANTIC, HEALER, COWARD),
        leader(LEADER, COWARD, HOTHEAD, LONER, SNARK),
        loner(LONER, ROMANTIC, POET, COWARD, LEADER),
        greedy(GREEDY, POET, GOOFBALL, ROMANTIC, BOOKISH),
        poet(POET, LONER, GREEDY, SNARK, GOOFBALL),
        romantic(ROMANTIC, LONER, HOTHEAD, HEALER, GREEDY),
        snark(SNARK, BOOKISH, GOOFBALL, LEADER, POET),
        ;

        private final Stats stat;
        private final Array<Stats> positive;
        private final Array<Stats> negative;

        CompatibilityStats(Stats stat, Stats p1, Stats p2, Stats n1, Stats n2) {
            this.stat = stat;
            positive = new Array<>();
            positive.add(p1);
            positive.add(p2);
            negative = new Array<>();
            negative.add(n1);
            negative.add(n2);
        }
    }

For characters with limited compatibility and low charisma, the scale could be 0.25 or less. For characters with high compatibility and high charisma, the scale could be at least 4.0, possibly higher.

One possible recommendation is to just assign 20 points, and let it go. Maybe finer control will be added at some point.