Add custom targeting classes to extend targeting functionality.
Custom targeting is used by single, group and raycast targeting to select or filter the used targets. It’s not used by the player selecting targets, only when the system selects a target (e.g. auto targeting or by non-player combatants). Custom targeting is used after auto target conditions (i.e. only if auto target isn’t used or didn’t find a target).
Custom targeting is part of the target selection setup, i.e. either directly in abilities and items or in target selection templates.
Own Custom Targeting Classes #
You can add your own custom targeting classes by extending from the BaseCustomTargetType class.
The class requires the implementation of the GetSingleTarget and GetGroupTarget functions, which are used for single target selection and group target selection. Both functions get the BaseAction they’re used for and the available targets (list of combatants) passed on as parameters.
Additionally, the class has to add the EditorSettingsInfo attribute to add editor information for the type selection dropdown of the custom targeting settings.
Dummy Class Example #
Below you’ll find an empty class to base your own code on:
using UnityEngine; using GamingIsLove.Makinom; using System.Collections.Generic; namespace GamingIsLove.ORKFramework { // the name and description displayed in dropdown selections [EditorSettingInfo("Name", "Description")] public class YourCustomTargetType : BaseCustomTargetType { // add your settings public YourCustomTargetType() { } public override string ToString() { // returns text for foldout information return "Your Class"; } public override Combatant GetSingleTarget(BaseAction action, List<Combatant> targets) { // return a single target return targets.Count > 0 ? targets[0] : null; } public override List<Combatant> GetGroupTarget(BaseAction action, List<Combatant> targets) { // return a list of targets for group targeting return targets; } } }
Class Example: Status Value Sorted #
The Status Value Sorted implementation uses targets based on status value sorting, e.g. sorting by lowest HP.
The GetSingleTarget function will return the target with the lowest or highest value (depending on the setup).
The GetGroupTarget function will return the list of targets sorted from lowest to highest or highest to lowest value (depending on the setup).
using UnityEngine; using GamingIsLove.Makinom; using System.Collections.Generic; namespace GamingIsLove.ORKFramework { [EditorSettingInfo("Status Value Sorted", "The targets are sorted by a defined status value.\n" + "Single targeting uses the target with the lowest/highest value.")] public class StatusValueSortedCustomTargetType : BaseCustomTargetType { [EditorHelp("Status Value", "Select the status value that will be used to sort.\n" + "The combatants will be sorted from lowest to highest value.", "")] public AssetSelection<StatusValueAsset> status = new AssetSelection<StatusValueAsset>(); [EditorHelp("Used Value", "Select which value will be used:\n" + "- Current Value: The current value of the status value.\n" + "- Base Value: The base value of the status value (without bonuses).\n" + "- Min Value: The minimum value of the status value.\n" + "- Max Value: The maximum value of the status value.\n" + "- Display Value: The currently displayed value of the status value (e.g. when using 'Count To Value').\n" + "- Preview Value: The preview value, displaying changes when an equipment would be equipped.\n" + "- Preview Max Value: The preview maximum value, displaying changes when an equipment would be equipped.\n" + "- Preview Min Value: The preview minimum value, displaying changes when an equipment would be equipped.\n" + "- Last Change Value: The last value used to change the status value.\n" + "- Last Combined Change Value: The combined value of the last changes to the status value.\n" + "- Last Combined Change Value Positive: The combined value of the last positive changes to the status value.\n" + "- Last Combined Change Value Negative: The combined value of the last negative changes to the status value.", "")] public StatusValueGetValue usedValue = StatusValueGetValue.CurrentValue; [EditorHelp("Inverse Order", "Inverse the sorting - sorts from highest to lowest value.", "")] public bool inverseOrder = false; public StatusValueSortedCustomTargetType() { } public override string ToString() { return (this.inverseOrder ? "Highest " : "Lowest ") + this.status.ToString(); } public override Combatant GetSingleTarget(BaseAction action, List<Combatant> targets) { if(targets.Count > 0) { targets.Sort(new StatusValueSorter(this.status.StoredAsset.Settings, this.usedValue, this.inverseOrder)); return targets[0]; } return null; } public override List<Combatant> GetGroupTarget(BaseAction action, List<Combatant> targets) { targets.Sort(new StatusValueSorter(this.status.StoredAsset.Settings, this.usedValue, this.inverseOrder)); return targets; } } }