Is there an way to know & track when a combatant attacks a faction and when sympathy changes occur between factions?
  • Currently not, but I can add event handlers to register to in the next update.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • That would be great!
    Thank you Nicholas :)
  • I just got the latest ORK3 release, did you manage to get in the tracking when a combatant attacks a faction and when sympathy changes occur between factions?
  • Yes - ORK.Game.Faction has multiple event handlers you can register to. Beside getting notified of sympathy changes, you can also get notified when e.g. a member of a faction was killed, etc.

    For combatants, you can also register to get notified if a combatant was attacked by another combatant:
    combatant.Battle.AttackedByCombatant
    combatant being the instance of the combatant.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I tried looking into FactionHandler.cs but I'm having a hard time understanding how to use it properly.
    How do I know register the handler and know, for example, when the sympathy between factionA and factionB has changed and what's the current value between the 2 factions?
  • You need a function like this that you register with the handler:
    public void YourFunction(FactionSetting changed, FactionSetting origin)
    {
    // do your stuff
    }


    You register the function to the handler like this:
    ORK.Game.Faction.SympathyChanged += YourFunction;

    And you can get the sympathy between 2 factions like this:
    float sympathy = ORK.Game.Faction.GetSympathy(faction, faction2);
    faction and faction2 are of type FactionSetting - you can e.g. get a faction via it's editor index like this:
    FactionSetting faction = ORK.Factions.Get(index);
    Or, directly from a combatant via combatant.Faction.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Perfect, thank you Nicholas!
  • I noticed that the notification combatant.Battle.AttackedByCombatant to notify a combatant being attacked by another combatant is working only the first attack but not on the following ones.
    Is that normal or did I set something wrong on my code?

    private Combatant target;
    public void Start()
    {
    target = ORKComponentHelper.GetCombatant(this.gameObject);
    if (target != null)
    target.Battle.AttackedByCombatant += this.NotifyAttack;
    }

    public void NotifyAttack(Combatant attacker)
    {
    Debug.Log( this.gameObject.name + " was attacked by " + attacker.GetName());
    }
  • That's by design - it only fires the first time a combatant attacks, when a new combatant is registered as an attacker.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited August 2022
    Oh, I see..
    Is there a way to be notified whenever a combatant is attacked?
    My first instinct would be unregistering and re-registering the old notification and registering a new one each time a new notification is received but I am not sure it would work.
    Something along this line...

    private Combatant target;
    public void Start()
    {
    target = ORKComponentHelper.GetCombatant(this.gameObject);
    if (target != null)
    target.Battle.AttackedByCombatant += this.NotifyAttack;
    }

    public void NotifyAttack(Combatant attacker)
    {
    Debug.Log( this.gameObject.name + " was attacked by " + attacker.GetName());
    // Do my things
    ReRegisterNotifyAttack();
    }
    public void ReRegisterNotifyAttack()
    {
    target.Battle.AttackedByCombatant -= this.NotifyAttack;
    target = ORKComponentHelper.GetCombatant(this.gameObject);
    target.Battle.AttackedByCombatant += this.NotifyAttack;
    }

    otherwise maybe adding the same component (the class only includes only the NotifyAttack code) and deleting the current component that has been "used"? That approach though I am afraid might create performance issues..
    Post edited by ChimpLogik on
  • No, re-registering doesn't help with this. The combatant remembers who attacked and only notifies the first time an attack happend (i.e. a new attacker is added to the list).

    If you wan to get notified on every attack, you can either handle that in your action's schematics or via your health stat's change schematics.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hmm I'll have to dig more into the schematics, maybe there is a way to modify the sympathy between factions whenever an attack is received from a specific combatant and not just when the combatant dies.
    That would be a great way around this problem...


  • There's the Change Faction Sympathy node for that :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I flashed out some scenarios but even changing the Faction Sympathy will eventually require to know each time a combatant is attacked and get the faction of the attacker.
    I saw there's a Set Attacked By Node in the schematic but I haven't quite figured out a way to use it :(

    Perhaps I haven't approached the problem from the right angle.
    I have some special combatants belonging to faction A and I'd like to know whenever they are under repeated attack by the player so they can respond differently. Is there any other way to detect that?
  • The Set Attacked By node uses the same functionality as a combatant attacking someone (for the first time), so that'll only work if the combatant hasn't attacked the other combatant yet.

    As said above, you can just do this via schematics - e.g. a Call Function node to call some custom functioanlity you have.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.