Page 1 of 1

Combining Love / Hate and Stats

Posted: Mon Feb 15, 2021 1:46 am
by Birchmark
Hi
I am in the process of digitizing a game I was already working on in printable form and I wanted to give my NPCs stats similar to what you'd see in an RPG and have modifiers on those stats that are affected by interactions with players (so the modifiers adjust to for example, make it harder to persuade an NPC you have already deceived in the past etc).

I've had a bit of a fiddle with the free trial of Love / Hate and it seems pretty good but I'm not sure if it will be possible to use it for what I want or not.

Would it be possible to program it so that the traits it uses changes the values of other traits used for other things like combat or reactions to player's actions?


I assume it would be possible to do something along the lines of:

if (affinity and trust with player 1, player 2 or player 3 == -40)
{
increase intimidate mod & perception mod +5
}

(Obviously not quite like that, but that being the general logic of the code).

However, I'm not sure if something like that would work so I thought I'd ask if it is something that would be possible.

Thank you for your help

Re: Combining Love / Hate and Stats

Posted: Mon Feb 15, 2021 11:14 am
by Tony Li
Hi,

Thanks for checking out Love/Hate! Yes, that's one of the primary use cases.

You can compute the modifiers at the time they're needed, such as:

Code: Select all

// Assumes code runs on NPC:
int perceptionModifier = GetBasePerceptionModifier();
var myFaction = GetComponent<FactionMember>();
if (myFaction.GetAffinity("Player 1") <= -40 || myFaction.GetAffinity("Player 2") <= -40 || myFaction.GetAffinity("Player 3") <= -40)
{
    perceptionModifier += 5;
}
Or, if you want to update the modifiers as soon as the NPC adds or removes a deed from memory, you can add a script to the NPC that implements the IRememberDeedEventHandler and IForgetDeedEventHandler interfaces:

Code: Select all

public class MaintainModifiers : MonoBehaviour, IRememberDeedEventHandler, IForgetDeedEventHandler
{
    int perceptionModifier = 0;
    
    public void RememberDeed(Rumor rumor) { UpdateModifiers(); }
    public void ForgetDeed(Rumor rumor) { UpdateModifiers(); }
    
    void UpdateModifiers()
    {
        var myFaction = GetComponent<FactionMember>();
        if (myFaction.GetAffinity("Player 1") <= -40 || myFaction.GetAffinity("Player 2") <= -40 || myFaction.GetAffinity("Player 3") <= -40)
        {
            perceptionModifier = -10;
            ShowMessage(name + " now looks at you skeptically.");
        }    
    }
}
(Those are just hypothetical examples of how you might set something up in code.)

Re: Combining Love / Hate and Stats

Posted: Mon Feb 15, 2021 7:41 pm
by Birchmark
Thank you. That is really helpful

Re: Combining Love / Hate and Stats

Posted: Mon Feb 15, 2021 7:51 pm
by Tony Li
Glad to help! If you have other questions as you start to integrate Love/Hate, just let me know.