Hello,
I’m new to scripting and I am trying to get the faction of a game object via code. I can select the game game object but I’m unsure on how to get the faction and rating from the combatant. Can anyone point me in the right direction?

Thanks
  • Essentially, I just want to check if the selected object is an enemy or not, but I need to do this via code.
  • edited October 2022
    If you just want to see if it's an enemy of the player:
    if(ORK.Game.ActiveGroup.IsEnemy(combatant))
    combatant naturally being the instance of the combatant you're checking.

    Otherwise, faction ID of a combatant can be accessed via it's group:
    int id = combatant.Group.FactionID;
    Post edited by gamingislove on
    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!
  • Legend, thank you
  • What if the the combatant isn’t a player, and I want to check if 2 separate combatants are enemies to each other?

    If I call the faction ID, how can I check the sympathy rating?

    Thanks for the help so far
  • I’ve solved that, thank you.

    Is it possible to initiate battle ai from code?
  • Depends on what you mean by initiate.

    If you want a combatant so select an action via battle AI, you can call this function:
    combatant.Actions.ChooseAuto(true);
    Pass on true to start a new turn or false to not do so.

    Or, call the Choose function, which is the regular action selection start, which prompts the battle menu, etc. for player combatants and has AI controlled combatants use battle AI.
    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 October 2022
    Thanks for that. Essentially, I’m looking at implementing a different ai solution as the in built system doesn’t seem to work correctly under certain circumstances. I’m trying to disable and activate the internal ai so I can merge it with my own.
    Post edited by cookereptiles on
  • Ah, in that case, I'd recommend calling your custom AI to select actions in a turn start event of your combatant.
    If the custom AI adds the actions to the combatant as it's next action(s), ORK's action selection will automatically use them instead of the battle AI. You can add actions to be used like this:
    combatant.Actions.AddNextAction(action, NextBattleActionChange.Add);
    action is an instance of a BaseAction (e.g. an AbilityAction for using an ability).
    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!
  • Thanks, I’ll give it a try
Sign In or Register to comment.