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?
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!
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!
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.
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!
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;
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If I call the faction ID, how can I check the sympathy rating?
Thanks for the help so far
Is it possible to initiate battle ai from code?
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.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
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).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!