Search Unity

[RELEASED] Love/Hate: The Emotion-Driven Relationship System

Discussion in 'Assets and Asset Store' started by TonyLi, Mar 24, 2015.

  1. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    50% Off in Cyber Mega Sale Ends Today

    Is Love/Hate on your list?

    Need to give your NPCs personalities, emotional states, and relationships, and have them automatically notice and judge the player's actions?

    Make sure to get Love/Hate before midnight PST for the 50% discount!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.5 Released

    Love/Hate 1.10.5 is now available on the Asset Store!

    Release Notes:
    • Updated to handle Disabled Domain Reloading (a new feature in Unity 2019.3+).
    • Save System: Added SpawnedObjectManager option to call ApplyData on respawned objects' savers.
    • Text Table: Fixed: right-click context menu would select wrong field row.
    • Emerald AI: Added affinity-based AI behavior and faction relation options.
    • Opsive Character Controllers: Added support. (Available in Tools > Opsive menu.)
    • ORK: Updated for 2.27.0.
    • Super Text Mesh: Added native support.
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Adventure Creator Integration Updated

    The Love/Hate Extras page has an updated integration package for Adventure Creator 1.67.0.
     
  4. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    481
    Hello,

    I have a couple of questions.

    1. I created a faction called GenericHumans and added some relationships to the player, then I went to HumanMale and assigned GenericHuman as a parent, but the Inherited Relationship list stays empty.
    2. What is the best way to setup a reputation earning system using love hate, for example I want to have 4 clans and the player will complete quests to earn reputation (from -100 to 100) and it will stay static unless the player starts killing NPCs.
     
    Last edited: Jan 26, 2020
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi @skinwalker -
    upload_2020-1-26_12-14-28.png

    Tick the Inheritable checkbox:

    upload_2020-1-26_12-17-56.png

    Then you should see the relationships inherited:

    upload_2020-1-26_12-18-32.png

    Use affinity to represent the player's reputation. For example:
    • Pink Girl starts with no relationship to the player, so her affinity to the player is zero.
    • When the player completes a quest, call
      FactionManager.instance.ModifyPersonalAffinity("Pink Girl", "Player", 10) ;
      to increase the player's rep with Pink Girl by 10. (It will automatically cap at +100, so you don't have to check that yourself.) You can do it in code, visual scripting, Dialogue System Lua function, or Quest Machine action.
    • If the player attacks Pink Girl or her friends, or otherwise does something Pink Girl disapproves of, she will automatically reduce her affinity to the player. The amount of reduction depends on the player's deed.
     
  6. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    481
    I tried clicking that box and then refresh button but nothing happens. I duplicated the RPG Database and added my own data inside, but even inside the example database it doesnt work for some reason.

    About the other question:
    Im thinking of making Human as a parent of all human npcs and when I complete a quest I can call that method on human I guess and the children will inherit it? (if I get the inheritance working). What do you think about having Affinity as a base reputation measurement and another relationship trait for the same thing but more personal (to each NPC), so since its a survival game I can give food to the NPCs and that personal relationship will increase, while the general Affinity only increases through quests. That way I can have good reputation with the Human clan, but 1 guy can still hate the player for some reason and you can start doing favors personally to him (giving food, doing tasks etc).
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Which box?

    While it's perfectly fine to have as many relationship traits as you want, affinity by itself should suffice for that. An NPC relies on relationships it inherits from its parents -- until it sets or modifies a personal relationship value to the player. At that point, that relationship branches off, and the NPC maintains it separately from its parents.

    So when you start giving food to the NPC, it will start a personal relationship to the player based on its inherited affinity plus whatever additional affinity was gained when giving the good.

    Assuming the NPC still has +100 affinity to Humans, whenever you report a deed to Humans that increases affinity, the NPC will either witness the same deed and increase its personal affinity, or it will learn about it and increase affinity the next time it shares rumors with another human that knows about the deed.
     
  8. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    481
    I just duplicated my database and the Inherited Relationships showed up, still dont show on my first one (even if I enable/disable the checkbox) but I can just delete it.

    Okay, so I have to setup a parent affinity to the player lets say -100 and then the NPC that will remain hating the player will have a Relationship of -100 affinity to the player and that way even if the parent clan affinity goes to 100, that NPC will still hate the player unless I add some to its personal affinity.
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Yes, that's correct.

    Also, if you delete the personal relationship, the NPC will resume using its inherited relationship.
     
    skinwalker likes this.
  10. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    236
    Hi, I can't find integration information for Behaviour Designer, is it still supported?
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi! Yes. You can download the integration from Opsive's site: https://opsive.com/downloads/?pid=803

    Opsive recently updated their site, and the link in Love/Hate's manual points to the old location. I'll make sure the link is updated in the next Love/Hate release.
     
    AngelBeatsZzz likes this.
  12. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    236
    I imported the integration demo, but it didn't work, and both the Behaviour Designer script and the Love Hate script in the demo scene failed.

    It looks like there is a problem with the DLL, do you know how to fix it?

    20200325210008.png
    20200325210037.png
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    @AngelBeatsZzz - Did you turn off Unity Input?

    BTW, Love/Hate has optional support for the new Input System, but the evaluation version is not compiled with that option.
     
  14. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    236
    I use the old input system and it is enabled.

    Edit:
    I use the Love / Hate evaluation version. The previous errors were generated in the Unity 2019.1 project. , Now I use Unity 2019.3 to create the project, no errors occurred after importing Love / Hate.
     
    Last edited: Mar 25, 2020
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    @AngelBeatsZzz - Please try a new, empty project. I just tested a Unity 2019.3.5 project and it works fine. These are the steps I used:
    1. Created a new, empty Unity 2019.3.5 project.
    2. Imported Behavior Designer.
    3. Imported Love/Hate 1.10.6 evaluation version. (Also works with paid version.)
    4. Imported the integration package (LoveHate.unitypackage).
    5. Played the integration's demo scene.
    Note: The evaluation version requires Unity 2019.3+. The paid version works with 2017.4+.
     
    AngelBeatsZzz likes this.
  16. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    481
    Hello,

    Is there a way to serialize Faction and get the same inspector as the one on FactionMember class? I noticed it just has int factionId, so I think a custom inspector does that taking the database into account. It will help if I can do that for the UI elements to know what faction its targeting instead of passing Ids.
     
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi @skinwalker - The Faction class is serializable, so you can show it in the inspector. But it doesn't have a custom property drawer, so you'll just see its raw content, not an inspector view that's similar to FactionMember. FactionDatabase has a custom inspector that shows names instead of IDs, too.

    If you want to get a faction name from a faction ID at runtime, call FactionManager.instance.GetFaction(factionID).name.
     
  18. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    481
    Yes I tried the Faction before and it didnt show things I wanted, its mostly to use at design time because I have a couple of progress bars that will be tied to showing the reputation of faction - player and needed an easy way to do it instead of passing ints or strings.

    I will see if I can make a drawer using Odin..
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    @skinwalker - Sounds good. If you get stuck, let me know. I could look at adding a special drawer to Love/Hate in a future release.
     
    skinwalker likes this.
  20. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Hello,

    Thanks for your work. I enjoyed studying it.

    I purchase it for not commercial purposes.
    I am a pensioner and for me all this is just mental gymnastics, so that it would brain not turn into a vegetable after 70 :)
    Once upon a time, before the collapse of the USSR :), I was making a personality model.
    Your model is good at performance and rumor spreading. But it is focused not on the internal state of the personality but on
    assessment of proximity characteristics. The personalities in it are more likely in solidarity than empathic. Since the main mechanism is Affinity.
    But emotions will not work at all. You select the first one that fell into the range from the list. The widest range and closest to the start of Gloating.
    It is this emotion (Gloating) that characters mostly experience. You can exit it only by driving the PAD to the extreme values.
    But even if you change its range or place, it will not help.
    I tried to list all the emotions that fall into the range in the PAD.
    I also tried different measures of similarity, starting from a simple minimal deviation of the PAD from the middle of the intervals of the emotion pattern.
    In the list of possible applicants, I calculated the weight of the similarities, hoping that he would somehow sort the selection.
    Emotions are quite randomly dependent on PAD. And to make matters worse, they simply do not fit well, because at the same time almost antoganistic emotions fall on the list.

    I do not criticize you. I just want to share some thoughts. Of course, I'll try to do something myself. But for me now, programming is something like a short walk. To support the brain.
    I'm no longer capable of a marathon :)
    I tried to simplify the model I was doing as much as possible. It is not suitable for Unity.
    Since I know English poorly, I’ll just try to express my thoughts as close to the pseudo-code as possible.
    Perhaps this will push you to some interesting decisions.
    The action itself must still have modality, otherwise there is no way to determine the reaction.
    Two more factors will determine the reaction.
    Motivation - how much the object itself is motivated.
    Obligation - as far as the sum of the factors of relations such as the authority of the actor presses on the object

    An important part of the reaction is consent (SUCESS) or denial (DECLINE).
    IMPERATIVE - an action that does not imply a refusal by the person to whom it is applied (you were hit, imprisoned, your hand chopped off, Pope excommunicated you).
    Non-IMPERATIVE influences imply both a SUCESS reaction in the common interest and coercion, as well as a DECLINE reaction.
    PHYSICAL is a physical action and reactions to it as a physical effect.
    VERBAL is an expression of intention, request, wish.
    Reactions classified
    VERBAL_SUCESS, PHYSICAL_SUCESS PROVOLUNTARY Max [entusiastic, interested]
    VERBAL_SUCESS, PHYSICAL_SUCESS PROOBLIGATE Max [polite, passive, sad]
    PHYSICAL_DECLINE CONTRAPHYSICAL Max [agressive stoicism intimidate fleeing pleading hysterical]
    VERBAL_DECLINE CONTRAVERBAL Max [ignore, argue, deny]
    The choice from the list is determined by the weight of the reaction, which is determined by character traits.
    You can rely on any system of traits and relationships. You can create different temperaments and accentuated personalities by manipulating amounts.
    I will give an example of a personality model that gave me plausible behavior, even without any special settings.
    In addition to personal features represented by binary scales (Egoism - Altruism [100, -100]) Egoism, Conformism, Dominance, Concsious, Suspiction, Racionalism,
    Brevery, Frendliness, Diplomacy, Extraversion other variables are present.
    mood - mood level (excellent - vile)
    stress - stress level.
    f_energy - physical energy (power reserve - fatigue).
    m_energy - mental energy (the ability to focus - distraction).
    e_energy - emotional energy (fresh emotions - emotional fatigue).
    Love, Trust and Autority, a binary relationship with another character.
    Since these are just lists, I will not indicate that I am dividing the sum by the length of the list to normalize :)
    And so the reaction weight.
    // Counteraction reactions during physical action
    agressive = (stress + f_energy - mood - Love - autority + brevery + dominance - frendliness - diplomacy);
    stoicism = (m_energy - conformism - extraversion + concsious + racionalism + brevery);
    intimidate = (egoism + dominance - diplomacy - frendliness + extraversion - Love);
    fleeing = (f_energy - m_energy + autority - trust + suspiction - conformism - concsious - brevery - extraversion);
    pleading = (e_energy + m_energy - f_energy + love + autority + trust + conformism - dominance - brevery - suspiction + extraversion + diplomacy + frendliness);
    hysterical = (stress + e_energy + egoism + conformism - racionalism);
    // Counteraction reactions, with an ultimatum or request
    deny = (racionalism + autority);
    argue = (stress + e_energy + m_energy + egoism - conformism + suspiction - frendliness + extraversion - love - autority - trust);
    ignore = (stress - f_energy - e_energy - m_energy + egoism + diplomacy - conformism - concsious - extraversion - autority + trust);
    // Subordination Reactions
    polite = (autority + conformism + racionalism + concsious + diplomacy + frendliness);
    passive = (stress - f_energy - e_energy - m_energy + Love + trust);
    sad = (stress + e_energy + egoism + suspiction + racionalism - brevery - love - autority - trust);
    // Collaboration Reactions
    entusiastic = (stress + e_energy + love + trust + extraversion - suspiction - racionalism - diplomacy);
    interested = m_energy;

    Do not confuse the luck or failure of the action itself and the DECLINE or SUCESS reaction.
    Theft (PHYSICAL) applied to the character may be successful or unsuccessful, but this is not a reaction. Reaction is -
    SUCESS PROOBLIGATE reaction [polite, passive, sad].
    Or DECLINE CONTRAPHYSICAL [agressive stoicism intimidate fleeing pleading hysterical].
    It will depend on personality characteristics.
    Consensus Decision Logic
    f() - functions of a rather tedious weighted summation of the list of variables and their normalization.
    Evasion = f(moral) ; The requirements of morality. Goodness qualities with a positive rating have a negative sign and enhance motivation
    Motivation = f(needs) - Evasion ; Motivation is the sum of needs affecting the situation, limited or reinforced by moral requirements.
    Obligation = f(Relation) ; Obligation - Power arising from relationships that require you to submit to other people's interests

    if IMPERATIVE
    {
    if (Motivation > 0)
    max[entusiastic interested] wishes it PROVOLUNTARY SUCESS
    else
    max[polite, passive sad] not willing, but agree PROOBLIGATE SUCESS
    } else
    if Motivation > 0
    max[entusiastic interested] wishes it PROVOLUNTARY SUCESS
    else
    if (Obligation > Abs(Motivation))
    max[polite, passive sad] not willing, but agree PROOBLIGATE SUCESS
    else
    if PHYSICAL
    max[aggressive stoicism intimidate fleeing pleading hysterical] resistance to action CONTRAPHYSICAL DECLINE
    else
    max[ignore argue deny] resistance to intention CONTRAVERBAL DECLINE

    Have you identified the reaction, what does she do with the character? How are emotions calculated?
    All emotions have the characteristic Elastic, it determines the rate of attenuation of emotions.

    Ways to manipulate variables
    + <VARIABLE> <DELTA> :: Variable = Variable + Delta |
    - <VARIABLE> <DELTA> :: Variable = Variable - Delta |
    * <VARIABLE> <MULTIPLIER> :: Variable = Variable * Multiplier |
    < <VARIABLE> <THRESHOLD> <DELTA> :: IF Variable < Threshold THEN Variable = Threshold ELSE Variable = Variable + Delta
    > <VARIABLE> <THRESHOLD> <DELTA> :: IF Variable > Threshold THEN Variable = Threshold ELSE Variable = Variable - Delta


    I do not insist on such a complex model. I have all the characteristics of traits and relationships at the beginning of the period (waking) were preserved
    and at the end (dream), the delta between the starting and the current state was calculated, by a certain percentage of which traits and relationships changed.
    So the personality changed under a stream of circumstances.
    The coefficient 0.04 is just a test one, you can choose the real one. This configuration is not a balanced model. But she works well even with him.
    :agressive
    * mood 0.9;
    < stress 0.7 0.04;
    < f_energy 0.9 0.04;
    + dominance 0.04;
    + brevery 0.04;
    - frendliness 0.04;
    - diplomacy 0.04;
    - love 0.04;
    - autority 0.04;
    ;; emotion
    + insult 0.04;
    ;; emotion
    + anger 0.04;
    ;; emotion
    - tender 0.04;
    ;; emotion
    - gratitude 0.04;
    Since the qualities in your model can but should not change, I will not dwell on them.
    Further I will show only a change in emotions. You can build them in accordance with any model acceptable to you.
    >stoicism + suffer 0.04; + confuse 0.04; + disgust 0.04; - attraction 0.04; - complacency 0.04; - pleasure 0.04;
    >intimidate + confidence 0.04; + insult 0.04; + disgust 0.04; + anger 0.04; - tender 0.04; - attraction 0.04; - gratitude 0.04; - fear 0.04;
    >fleeing + suffer 0.04; + fear 0.04; + guilt 0.04; + confuse 0.04; + disgust 0.04; - attraction 0.04; - complacency 0.04; - proud 0.04; - confidence 0.04; - pleasure 0.04;
    >Pleading + fear 0.04; + guilt 0.04; - proud 0.04; - confidence 0.04;
    >hysterical + fear 0.04; + suffer 0.04; + insult 0.04; - gratitude 0.04; - pleasure 0.04; - confidence 0.04;
    >deny - attraction 0.04; - pleasure 0.04;
    >argue + insult 0.04; + disgust 0.04; + anger 0.04; - gratitude 0.04; - attraction 0.04; - tender 0.04;
    >ignore + fear 0.04; + insult 0.04; + confuse 0.04; + disgust 0.04; - attraction 0.04; - complacency 0.04; - gratitude 0.04; - confidence 0.04;
    >Polite + disgust 0.04; + suffer 0.04; - pleasure 0.04; - attraction 0.04;
    >Passive + confuse 0.04; - complacency 0.04;
    >sad + suffer 0.04; + fear 0.04; + disgust 0.04; - attraction 0.04; - confidence 0.04; - pleasure 0.04;
    >entusiastic + pleasure 0.04; + confidence 0.04; + proud 0.04; + attraction 0.04; - disgust 0.04; - guilt 0.04; - fear 0.04; - suffer 0.04;
    >interested + attraction 0.04; - disgust 0.04;
    There is an element of "needs" in the logic. Action (Deed) satisfies or wears out some needs.
    If you have this need (its value! = 0), then need creates Motivation = need * (deed.need / 100).
    We determine the influence of needs by normalizing it by weight in determining the Deed. Then we sorting the need with the maximum weight received.
    This is the dominant need determining Motivation.
    Example. If you have need.hunger = 80 and Deed 'Give bread' hunger = 50, then Motivation = 40.
    There is an "Obligation" element in the logic. Defined by f(Relation). All relations determine the degree of influence on the actor on the object.
    If they do not set the status (Ex. Spouse), which does not have a numerical value.
    Autority - actor has credibility.
    dependance - the object depends on the actor.
    Weakness - the object is weak
    Subjection - the object obey the actor
    Custom - the action is tradition to the object.
    Trust - the object trusts the actor.
    Love - object loves actor.
    Important - action is emotionally important to the object.
    You can make a lot of them by creating a more flexible system - Deed.
    And you can have one at all. This is all the power of influence on the object, capable of forcing him to accept the reaction SUCESS.
    Deed appeals to Relations, determining the degree of their influence.
    It all comes down to finding the strongest Relation and normalizing it to Deed.
    Otherwise, if Deed does not mention Relation, the strongest available is taken.
    This is Obligation.
    Deed - 'Parents send you to throw out trash' Subjection = 50 your relationship Subjection = 80, Obligation = 40.
    But it’s even easier not to specify anything. Perhaps you are afraid not to get pocket money, dependance = 100. Without specifying in Deed, Obligation = 100.
    In logic there is an element of "moral", this is a table of relations, the bearer of this morality, to which the character refers.
    This may include Goodness qualities. Just their strength will increase to -100.

    MORAL [ 'modern urban morality'
    ;; shameful filthy fearful dishonorable forbidden

    AGRESSION 0 0 90 0 100
    VANDALISM 0 0 0 0 100
    THIVERY 0 0 0 0 100
    ABUSE 0 0 100 100 0
    TORTURE 0 0 100 0 100
    XENOFILYA 0 100 0 0 0
    INCEST 0 100 0 0 100
    CANNIBALISM 0 100 100 0 100
    LIES 100 0 0 100 0
    DRUGS 0 0 100 0 100
    TREASON 0 0 0 0 100
    NUDITY 80 0 0 0 0
    SUBMISSION 0 0 0 40 0
    PROMISCUITY 100 0 0 -10 0
    SLAVERY 0 0 100 100 100
    DEATH 0 0 100 0 0
    CORPSES 0 100 100 0 0
    MURDER 0 0 100 0 100
    mercy -100 -80 0 0 -30
    ]


    Deed may include references to what moral criteria the action touches and how much (Ex. Deed AGRESSION = 50).
    If there are no references, Deed does not affect morality.
    If there is, then this is the same finding the maximum value for non-zero position elements in MORAL(AGRESSION fearful = 90) and normalization by Deed(Evasion 45).
    Example.
    Deed 'Asking for undressing' NUDITY = 100.
    Evasion = shameful = 80 * (100/100). Obligation = 20. needs = 0.
    Motivation = needs - Evasion = -80. (Motivation < 0)AND(Obligation < Abs(Motivation)). max[ignore argue deny] CONTRAVERBAL DECLINE
    Result reaction 'deny' dominant emotion 'Confuse' DECLINE
    This 'DECLINE' is important to know because the character has not completed the request.
    Deed IMPERATIVE 'Make undress' NUDITY = 100.
    All the same, but max [polite, passive sad] PROOBLIGATE SUCESS.
    Result reaction 'sad' dominant emotion 'Shame' SUCCESS. The character could not refuse.
    If before that there was something else aggressive, then the dominant emotion could be 'Anger' OR 'Fear'
    In addition, you can analyze shameful, filthy, fearful, dishonorable, forbidden and adjust emotions according to them.
    All this creates a flexible reaction and easy to configure system for simulating emotions and reactions based on them.

    Alexander.
     
    Last edited: Mar 28, 2020
    vorokoi likes this.
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi @Xsanf - Thank you for the detailed writeup. Love/Hate's primary focus is on relationships, since interactions between people are much more interesting than a single person in a vacuum, especially in a game where the player generally has agency to interact with multiple people.

    When it comes to individual emotional states, you're correct that Love/Hate does not precisely emulate the full range of real human emotions, whatever that means in the ever-changing field of psychology. Instead, it provides a very high performance approximation based on three vectors, using the fairly well-established PAD model. This allows it to scale to thousands of simultaneous characters while still providing an interesting model of each one's emotional state that has enough data to make interesting decisions with.

    However, should anyone want to replace the PAD model, these are two easy ways:

    1. Add a script that implements IModifyPadDeedEventHandler to the faction member. It has one method that receives happiness, pleasure, arousal, and dominance values that you can interpret however you want.

    2. Or, if you want to bypass those values altogether and compute your own, assign your own delegate method to the faction member's EvaluateRumor hook.

    Love/Hate also has personality traits. By default, personality traits are static. But if increase a faction member's Impressionability slider it will automatically adjust its personality based on what it sees others doing (since, again, Love/Hate is focused primarily on relationships).
     
  22. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Thanks for the answer.

    Like I said, I do not criticize.
    You are doing an excellent job of building complex systems of social interactions. These are just notes where you can improve the product.

    I do so. Having received the hook, I look at the list of emotions that the filter is currently passing through and shows the measure of their similarity to PAD.
    So I realized that the existing system of emotions is not developed. As I said, these are different tasks.
    It's just that everything is ready for you to implement them. All you need is additional structures that specify traits. “Traits” do not currently share “personal traits,” “needs,” or other conditions. For you, all these "Traits"
    You already distinguish ordinary "traits" and "Relations" as you needed it.
    The only problem is that the model of emotions, has a different idea about "traits" in "Deed".
    This is a measure of affinity for you, and in emotions it is a power of influence. This difference will not allow the use of "Deed" at once in two models simultaneously in the form
    as it exists now.
    I simply duplicate the display of "traits" for "Deed" and give them a different interpretation.

    I will try to expand your system for a more complete analysis of emotions and be sure to unsubscribe. But as I said, unfortunately I can’t work fast ((

    Yes, you are very convenient for creating your own extensions.

    Alexander.
     
    Last edited: Mar 29, 2020
  23. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    The main problem for me is how to complement the Deed template.
    I do not want to interfere with the main text. Hook EvaluateRumor and IModifyPadDeedEventHandler allow me to do all the interpretation without affecting the main text.
    I can create an additional component for Faction Manager, creating additional lists that separate Traits by the necessary additional types (personality, Needs, Moral).
    Make a Moral template that includes values for the corresponding Trait (shameful, filthy, fearful, dishonorable, forbidden). This will allow you to create moral patterns.
    Create a template for reactions (agressive ... interested), which allows you to create Add and Sub lists for them for the for calculating reaction weights.

    But how do I add an additional list of Traits to Deeds that affect emotions and reactions, but without changing the template, I don’t understand yet.
    I really do not want decisions affecting the main text. The only thing that comes to mind is to create a parallel Deeds template and use it if you need emotions.

    I would be grateful for any thoughts.

    Alexander.
     
  24. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    I will explain my interest in the inner kitchen of emotions.

    I first acquired the dialogue system for unity.
    I took Love / Hate's hoping to get the opportunity to build dialogue based on character relationships.
    In the dialogue for you, "interactions between people are much more interesting than a single person", is not so interesting.
    You are communicating with "single person".
    It is interesting to branch the dialogue on emotional reaction and moral assessment. Affinity here does not provide many opportunities.
    Therefore, I was so interested in the opportunity to improve the mechanism of emotions and reactions.

    It is not so important for fractional relations of RPG, but the basis for example for VN.

    Alexander.
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi Alexander,
    There are two people: the NPC and you, the player. But I agree with your point that the default emotional model may be simpler than what you want.

    Here is one way to approach your extension. The Rumor class has a field for customData. It's an object variable, so you can assign anything to it.

    Here is an example script that creates a Rumor that sets customData to Physical or Verbal. If you press F1, it reports this rumor to a target FactionMember:

    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.LoveHate;
    3.  
    4. public enum DeedType { Physical, Verbal }
    5.  
    6. public class ExpandedDeedReporter : MonoBehaviour
    7. {
    8.     public FactionMember actor;
    9.     public FactionMember target;
    10.  
    11.     private void Update()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.F1))
    14.         {
    15.             Rumor rumor = Rumor.GetNew();
    16.             rumor.tag = "Lie";
    17.             rumor.actorFactionID = actor.factionID;
    18.             rumor.targetFactionID = target.factionID;
    19.             rumor.impact = -10;
    20.             rumor.aggression = 10;
    21.             rumor.actorPowerLevel = actor.GetPowerLevel();
    22.             rumor.traits = new float[] { -10, 10, -10 };
    23.             rumor.customData = DeedType.Verbal; // Assign custom data.
    24.             target.EvaluateRumor(rumor, target); // Tell the target to evaluate the deed.
    25.         }
    26.     }
    27. }
    On the target FactionMember, you can add a script that has a custom evaluation function:

    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.LoveHate;
    3.  
    4. public class CustomDeedEvaluator : MonoBehaviour
    5. {
    6.     private FactionMember factionMember;
    7.  
    8.     private void Start()
    9.     { // Connect our custom evaluation function:
    10.         factionMember = GetComponent<FactionMember>();
    11.         factionMember.EvaluateRumor = CustomEvaluateRumor;
    12.     }
    13.  
    14.     private Rumor CustomEvaluateRumor(Rumor rumor, FactionMember source)
    15.     {
    16.         Rumor result = factionMember.DefaultEvaluateRumor(rumor, source);
    17.         DeedType deedType = (DeedType)rumor.customData;
    18.         // Here, do additional processing based on deedType:
    19.         if (deedType == DeedType.Verbal)
    20.         {
    21.             Debug.Log("Deed was verbal. Reducing pleasure by 10.");
    22.             result.pleasure -= 10;
    23.         }
    24.         return result;
    25.     }
    26. }
     
    hopeful likes this.
  26. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Thanks a lot for your answer.
    I will try.
    Like I said, I liked your product, it is quite transparent and just changeable.

    Alexander.
     
    TonyLi likes this.
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Thanks! :)
     
  28. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Yes, it seems customData is a good starting point.
    I’ll consider how to embed the extension.

    Alexander.
     
  29. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    I understand correctly?
    The processing of the CommitDeed action itself only puts the action on the m_witnessQueue queue.
    Therefore, there is still nothing to process.
    In WitnessDeed, this is ExecuteEvents.Execute <IWitnessDeedEventHandler> (gameObject, null, (x, y) => x.OnWitnessDeed (newRumor));
    So the best point for handler is OnWitnessDeed.
    This is the first place I can start creating and processing my customData.
    In doing so, I remain within your processing chain. Further on it the modified customData will be spread.

    Later, I can further process it through CustomEvaluateRumor.

    Alexander.
     
  30. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Does not work :-(

    Code (CSharp):
    1.  
    2. var tempRumor = Rumor.GetNew(deed);
    3.                 tempRumor.confidence = 100;
    4.                 var newRumor = EvaluateRumor(tempRumor, this);
    5.                 Rumor.Release(tempRumor);
    6.                 if (newRumor != null)
    7.                 {
    8.                     ExecuteEvents.Execute<IWitnessDeedEventHandler>(gameObject, null, (x, y) => x.OnWitnessDeed(newRumor));
    9.  
    Evaluation of an action occurs earlier than the action itself.

    OnWitnessDeed this is the action itself.
    EvaluateRumor assessment of this action.
    Event logic is broken. Evaluation precedes the action itself.

    Alexander.
     
    Last edited: Mar 29, 2020
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    @Xsanf - Please provide a replacement EvaluateRumor function like in my code example above.

    IWitnessDeedEvent is called after the deed is evaluated. Its purpose is to let a script know that a deed has just been evaluated. You can't use it to evaluate the deed.
     
  32. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    I understand correctly?

    I do not need two entry points to separately obtain information that the action has been completed.
    Since the Deed is evaluated not at the time of commission but at the time of rumors.
    And this can greatly diverge in time from the execution of the action.

    One processing point of CustomEvaluateRumor is enough for me.

    I get in CustomEvaluateRumor Deed as rumor.tag.
    There I have access to the "source" context of the character.
    This allows you to conduct other assessment.
    After that, I can place its result in customData.
    This will allow me to access it (customData) in other components, such as a dialog system or PlayMaker.
    There I can get my assessment from customData.
    CustomData remains in the rumor processing chain.

    Alexander.
     
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    @Xsanf - Yes, that's correct.
     
  34. Xsanf

    Xsanf

    Joined:
    Mar 12, 2015
    Posts:
    10
    Thanks, I will try.
     
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Emerald AI Integration Updated

    The Love/Hate Extras page has an updated integration package for Emerald AI 2.4.
     
    Akshara likes this.
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.7 Released

    Love/Hate 1.10.7 is now available on the Asset Store!

    Version 1.10.7 Release Notes:
    • Fixed: PositionSaver on NavMeshAgents didn't restore rotation.
    • Improved: Added UIButtonKeyTrigger.monitorInput property, option to visually simulate pressed state.
    • Save System: Added support for async saving; SaveSystem.SaversRestartGame() is now public.
    • Emerald AI: Updated integration for version 2.4.

    NOTE: Unity has requested Asset Store publishers to submit new releases with a minimum of Unity 2018.4. The next release of Love/Hate will require Unity 2018.4 or higher.
     
    hopeful likes this.
  37. Omogonos

    Omogonos

    Joined:
    Apr 21, 2020
    Posts:
    2
    Is there any way of adding extra custom sliders to PAD so we can emotion models based on more parameters?
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Hi @Omogonos - PAD is an established psychological model with defined meanings. I'm not sure it makes sense to change it directly. However, you could add extra values on the side by adding a script that implements IModifyPadDeedEventHandler. The script can maintain extra values and update them when IModifyPadDeedEventHandler.OnModifyPad is called.

    Alternatively, you could customize the code in Pad.cs to add new values. But requires maintaining your customizations to Love/Hate scripts.

    In either case, you'll probably want to also assign a replacement function to FactionMember.EvaluateRumor to do something with your extra values.
     
  39. Omogonos

    Omogonos

    Joined:
    Apr 21, 2020
    Posts:
    2
    Awesome! Thanks I'll try that.
    I need the mercenary band (and probably others) faith in/loyalty to the player to be a factor in how they interact with the player and their overall mood.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    The faith in/loyalty to the player is a relationship type. You can add as many relationship types as you want, no extra scripting required.
     
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.8 Released

    Love/Hate 1.10.8 is now available on the Asset Store!

    Release Notes:
    • Fixed: If faction member was destroyed while queued to evaluate a deed, it could throw a NullReferenceException.
    • Fixed: Improved trait alignment formula for accuracy.
    • Fixed: New Input System integration ignores joystick keycodes.
    • Fixed: New Input System could report ArgumentNullException in first frame on WebGL.
    • Improved: Added DeselectPreviousOnPointerEnter component.
    • Improved: Added InputDeviceManager.isInput Allowed.
    • Text Tables: Added ability to import text table into another.
    • Save System: Changed: Savers' Save Across Scene Changes checkbox is now ticked by default.
    • Save System: DestructibleSaver.RecordDestruction is now public.
    • Save System: Added saveDataApplied C# event; added OnDataApplied() event to SaveSystemEvents.
    • Save System: Improved singleton management.
    • Save System: Fixed: LoadEnded event is always called when scene loads ends, not just if events were assigned at design time.
    • Emerald AI: Updated for 2.4.0.1.
     
    hopeful and digiross like this.
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate Video Tutorials

    Your new introductory videos are available on the Love/Hate Video Tutorials page, starting with:

     
    skinwalker likes this.
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    FAQ: Love/Hate & Dialogue System for Unity

    Having received a few questions about the difference between the relationship systems in Love/Hate and the Dialogue System for Unity, especially regarding interactive conversations, I thought I'd post a FAQ answer here:

    The Dialogue System has a simple relationship system in which you can manually adjust relationship values between characters, typically as a result of the player's conversation choices. (More info: Manual, Relationship Functions)

    Love/Hate does not do branching conversations, but it can integrate with the Dialogue System for branching conversations. Love/Hate's relationship system is more sophisticated. In Love/Hate, games can not only adjust relationship values as a result of the player's conversation's choices, but they can also automatically adjust relationship values as a result of regular gameplay actions.

    Love/Hate was inspired by something that bothered me about Mass Effect 1 (which is otherwise one of my top games of all time). Mass Effect 1 has a hard-coded event on one planet: If you run over too many space monkeys with your Mako on one specific planet, a companion NPC will get upset. But, since this is hard-coded, if you run over space monkeys on any other planet the companion NPC will not take notice. This is because the event was specially hard-coded by the writer. In Love/Hate, you can define information about regular gameplay actions, and nearby characters will automatically judge those actions when the player performs them. This way you don't have to hard-code specific events in specific game locations. (More info: Manual, Video Tutorials)

    If your game doesn't need that level of detail, then you can get by with just the Dialogue System. If you do want that level of detail, get both assets and use the free Dialogue System integration included in Love/Hate.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.9 Released!

    Version 1.10.9 is now available on the Asset Store!

    It contains updates to Adventure Creator and PlayMaker integration.
     
    docsavage and skinwalker like this.
  45. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love /Hate 1.10.10 Released!

    Version 1.10.10 of Love/Hate is now available on the Asset Store.
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.11 Released!

    Version 1.10.11 of Love/Hate is now available on the Asset Store. This update includes improvements to input handling and the save system.
     
    skinwalker likes this.
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584
    Love/Hate 1.10.12 Released!

    Version 1.10.12 of Love/Hate is now available on the Asset Store. This update fixes a bug in CSV exports.
     
    BackwoodsGaming likes this.
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,584

    Attached Files:

unityunity