ORK Framework Logo - RPG Editor for Unity
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK

Getting Started

7
  • Introduction
  • First Steps
  • Game Starters
  • Components Overview
  • Player/Camera Controls
  • Game Over
  • Support: Sending Test Projects

Editor

9
  • Editor Overview
  • Base/Control Section
  • Game Section
  • UI Section
  • Templates Section
  • Status Section
  • Inventory Section
  • Combatants Section
  • Battles Section

Features

15
  • Animations
  • Areas & Teleports
  • Combatant Triggers
  • Control Maps
  • Difficulties
  • Factions
  • Formations
  • Formula Nodes
  • Logs
  • Loot
  • Move AI
  • Quests
  • Research Trees
  • Schematic Nodes
  • Shortcut Slots

Status System

8
  • Status Values
  • Status Effects
  • Attack/Defence Modifiers
  • Abilities
  • Combatants
  • Classes
  • Status Bonuses
  • Status Conditions

Inventory System

7
  • Inventory System Overview
  • Currencies
  • Items
  • Equipment
  • AI Behaviours/Rulesets
  • Crafting Recipes
  • Shops

Battle System

19
  • Battle Systems
  • Adding Battles to Scenes
  • Calculating Action Results
  • Battle Menus
  • Battle AI
  • Battle AI Nodes
  • Battle Ranges
  • Battle Camera
  • Target Selection
  • Battle Spots
  • Battle Texts
  • Battle End & Loot Dialogues
  • Action Combos
  • Damage Types
  • Cursor Prefab Components
  • Grid Battles
  • Adding Battle Grids to Scenes
  • Battle Grid Highlights
  • Battle Grid Formations

UI System

28
  • UI System Overview
  • Start Menu
  • Option Categories
  • Menu Screens
  • Notifications
  • Combatant Selections
  • Quantity Selections
  • Text Display Settings
  • Cursor Settings
  • Console (In-Game)
  • Menu Requirements
  • HUDs: Content Providers
  • HUDs: Conditions
  • HUDs: Click Actions
  • HUDs: Text Content
  • HUDs: Value Bar Content
  • HUDs: Status Values
  • HUDs: Status Effects
  • HUDs: Attack Modifiers
  • HUDs: Defence Modifiers
  • HUDs: Shortcuts
  • HUDs: Abilities
  • HUDs: Equipment
  • HUDs: Class Slots
  • HUDs: AI Behaviours
  • HUDs: AI Rulesets
  • HUDs: Quests
  • Timebar HUD

Scripting

8
  • Scripting Overview
  • Access Handler
  • Code Extensions
  • Custom Settings
  • Custom Targeting
  • Combatant Scripting
  • Custom Nodes
  • Custom Component Save Data
  • Home
  • Guide
  • Documentation
  • Scripting
  • Custom Targeting
View Categories

Custom Targeting

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;
        }
    }
}

 

Scripting

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
Table of Contents
  • Own Custom Targeting Classes
    • Dummy Class Example
    • Class Example: Status Value Sorted
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK
  • Contact
  • Blog
  • Makinom
  • gamingislove.com
Categories
  • News (70)
  • ORK 2 (137)
    • Tutorial (137)
      • Game tutorial (50)
      • Gameplay (32)
      • How-to (55)
  • Release (152)
Search

© 2015 Gaming is Love e.U.

Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!