Direct relationships between chars?

Announcements, support questions, and discussion for Love/Hate.
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Direct relationships between chars?

Post by incursio »

Hello, picked this asset up the other day and so far I'm loving it! I do have one question though. Is it possible to have faction-level relationships, as well as separate relationships between members of two different factions?

In my game, there are many "nations". Some nations are grouped together into larger factions, while others are not. I can obviously track the relationship between the factions, but sometimes, nations will need to have separate relationships with members of another faction (or sort of an "independent faction", if that makes any sense.

The only way that I can sort of see it working now would be to have two faction managers - one for the larger game factions, and a separate one where every nation is in its own faction. Would that be the preferred or recommended approach?

Thanks in advance for any thoughts or ideas!

Cheers.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Direct relationships between chars?

Post by Tony Li »

Hi,

Thanks for using Love/Hate!

If I understand your intent correctly, you can use a single faction database and faction manager.

Let's take a concrete (albeit historically inaccurate) example with these factions:

Factions:
  • Rome: nation
    • Marc Antony: member of Rome
  • Egypt: nation
    • Cleopatra: member of Egypt
Rome and Egypt are rivals who hate each other:

Relationships:
  • Rome: Egypt=-80
  • Egypt: Rome=-80
Marc Antony, being a member of Rome, would by default have affinity -80 for Cleopatra because she's a member of Egypt. But they're lovers, so he likes her and dislikes Egypt a little less:

Relationships:
  • Rome: Egypt=-80
    • Marc Antony: Egypt=-50, Cleopatra=+80
  • Egypt: Rome=-80
    • Cleopatra: Marc Antony=+80
Romans have lost a little love for Marc Antony for being under Cleopatra's sway, but they're also a little smitten by Cleopatra's beauty despite her being a member of Egypt. Egypt, on the other hand, hates Marc Antony even more than they hate Rome in general because he stealing their queen. So the final relationships are:

Relationships:
  • Rome: Egypt=-80, Marc Antony=+60, Cleopatra=+40
    • Marc Antony: Egypt=-50, Cleopatra=+80 (inherited/default: Rome=+100)
  • Egypt: Rome=-80, Marc Antony=-100 (inherited/default: Cleopatra=+100 as member of Egypt)
    • Cleopatra: Marc Antony=+80 (inherited/default: Egypt=+100, Rome=-80 as member of Egypt)
Does that help, or am I completely off base?
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

Hey - thanks for the informative response!

Yes, it does make sense. Just trying now to figure out how to do this via the API, since my factions are largely dynamic. I've no problem managing the affinity between factions, just not sure how to do it between faction members directly. I will research some more tonight and see where it leads me.

Cheers.
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

I think I discovered the trick ...

Code: Select all

SetPersonalAffinity(int subjectFactionID, float affinity);
Didn't see this the first time through the code. Looks like I can call this directly from a FactionMember object and set their relationship to faction independently from the relationship their current faction has with the subject faction.

But still, since it needs a factionID as the first argument, I would need to have each nation have it's own separate faction away from the larger grouped factions - unless I am missing an API call somewhere that would allow me to set a FactionMember's affinity directly with some other FactionMember object.

Cheers.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Direct relationships between chars?

Post by Tony Li »

Each nation needs its own faction. Relationships are defined between factions. Any entity (a character, a nation, or a group of nations) that is in a relationship needs a unique faction.

Faction members belong to a faction. If the faction has a relationship to another faction, then all faction members have that relationship. When you're defining factions, it's usually best to define a unique faction for every unique character (faction member) and set up parents.

If a set of NPCs are interchangeable, they can share the same faction. For example, it probably isn't worthwhile to maintain unique sets of relationships for every single cannon fodder goblin in a dungeon. Just assign their faction members to the same Goblins faction. The Goblin King, however, might merit its own faction if its interactions with other factions have the potential to be different from other goblins. The parent of the Goblin King's faction would be Goblins.

Building on the previous Marc Antony/Cleopatra example, let's say there are several Germanic tribes: Vandals, Ostrogoths, and Visigoths. As a whole, they are Germania. You'd define the factions like this:
  • Germania
    • Vandals: parents=Germania
    • Ostrogoths: parents=Germania
    • Visigoths: parents=Germania
Now let's say Romans don't make a distinction betwen the Germanic tribes. They dislike them all:
  • Rome: Germania=-60
Now say there is a Visigoth NPC named Segeric. If he is an important NPC, it would be a good idea to give him his own faction whose parent faction is Visigoths. Otherwise, if his relationships are interchangeable with any other Visigoth, you could just assign the Visigoths faction to his FactionMember component.

Here's how Love/Hate determines how Marc Antony feels about Segeric:
  • Marc Antony doesn't have a personal relationship to Segeric.
  • Next, he checks his parents (and grandparent factions, etc.) for a personal relationship to Segeric. None exists.
  • Next, he checks his own faction and his parents for personal relationships to any of Segeric's parents. Here, he finds that his parent faction (Rome) has a relationship to Segeric's grandparent faction (Segeric > Visigoths > Germania). So Marc Antony has -60 affinity to Segeric.
If Segeric were to save Marc Antony's life in the Black Forest, Marc Antony might get a positive personal affinity to Segeric. But this doesn't mean that all Romans would feel the same way, nor would Marc Antony feel any different about Germania in general. The relationship would be specific from Marc Anthony to Segeric.

I hope that helps. If I can provide any more details, please let me know.

Here are some helpful scripting links:
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

Yep that helps quite a bit! Thanks for the incredibly informative and substantive replies in this thread!

Cheers.
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

On a related note, I'm curious how you would model the countries involved in say, World War I? You had x number of countries in the Central Powers, y number of countries in the Allied Powers, and a whole ton of "neutral" countries. Obviously the Central and Allied factions would dislike each other extremely.

Would you make a "Neutral" faction as the parent, and plop all the neutral countries into their own factions under that? And have a Central Alliance faction, with the participating members of that faction under that in their own unique factions? Same for Allied, etc.

Examples:

Germany hates England - and vice-versa.
England loves the USA - and vice versa.
Denmark is a neutral country. Other neutral countries may like/dislike them, and the same for the members of the 2 primary factions. But likewise, they don't have the same relationship with every other neutral country.

Cheers.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Direct relationships between chars?

Post by Tony Li »

That's a good question, and I think it depends on what you're trying to model.

Unless it's important that all neutral countries share some specific traits and/or relationships, I'd probably leave all neutral countries unparented. If some of them formed their own group, you could create a new faction (e.g., Olive-Producing Countries) at runtime and set it as their parent. Or if Denmark decided to join the Allies, you could set Allied Powers as its parent.

Or you could define factions for groupings that aren't specific to the World War I powers, such as a Nordic Countries faction.

A faction can have multiple parents, too, so Sweden could be a member of Nordic Countries and Central Powers.

I didn't mention this previously, but when a faction has multiple parents and no personal relationship to a target, it averages the parents' relationships to the target.
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

Perfect! Thanks so much!

Cheers.
incursio
Posts: 8
Joined: Mon Mar 07, 2016 10:46 am

Re: Direct relationships between chars?

Post by incursio »

Ok, not quite done haha! :D

So I have things set up currently with the Axis and Allied factions, and all other countries just in their unique/unparented factions. The Axis and Allied nations all have unique factions underneath the two main factions. Check!

When I do this, as a quick test:

Code: Select all

factionManager.GetAffinity( judgeFactionName, subjectFactionName );
between 2 members of say, the Allied faction, it returns 0. According to the class reference, GetAffinity() should check the parents, no? I would think it would return 100 or what not. Do I need to explicitly set the initial affinity level (not personal affinity)?
Post Reply