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

Getting Started

  • Introduction
  • First Steps
  • Game Starters
  • Components Overview
  • Player/Camera Controls
  • Game Over

Editor

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

Features

  • 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

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

Inventory System

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

Battle System

  • 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

  • UI System Overview
  • Start Menu
  • 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

  • Scripting Overview
  • Access Handler
  • Code Extensions
  • Combatant Scripting
  • Custom Nodes
  • Custom Component Save Data
  • Home
  • Guide
  • Documentation
  • Scripting
  • Custom Nodes

Custom Nodes

Table of Contents
  • Battle AI Nodes
    • Node Execution
    • Example

Learn how to write custom nodes.

Adding custom nodes to schematics, formulas or battle AI doesn’t require implementing them in a plugin or ORK/Makinom’s source code – you can just add them in a script file in your Unity project.

For base information on custom nodes and writing custom nodes for schematics and formulas, please see the Makinom custom nodes documentation.

Battle AI Nodes #

You can create custom nodes by deriving from the BaseAINode or BaseAICheckNode classes. For examples it’s best to check out the available node implementations.

Deriving from BaseAINode will make it a node with a single Next slot, the connection to the next node is stored in the int field next.

public class NewAINode : BaseAINode

Deriving from BaseAICheckNode (which descends from BaseAINode) will make a node with a Success and a Failed slot – the Success connection is stored in the int field next, the Failed connection is stored in the int field nextFail.

public class NewAINode : BaseAICheckNode

You can also create multi-slot nodes, please see the Makinom custom nodes documentation for details.

Using battle AI nodes should use the battle AI node namespace.

using GamingIsLove.ORKFramework.AI.Nodes;

Or, implement the node in the namespace (not required).

namespace GamingIsLove.ORKFramework.AI.Nodes

Node Execution #

The most crucial part of the node is the Execute function, which will be used when the node is executed by the battle AI. This function will handle whatever you want to do with your node – and it must set which node (index) will be executed next and either return an action that was found or null if none was found.

public override BaseAction Execute(ref int currentNode, BattleAICall call)
{
    currentNode = this.next;
    return null;
}

The currentNode parameter will hold the node that is executed next, so set it to what slot of the node should be used next (e.g. via the next or nextFail fields).

The function returns a BaseAction – the base implementation of a battle action. Returning an action can end the battle AI (depending on the combatant’s AI setup), so return null if no action is found.

The call also has access to user of the battle AI, found targets and other information of the battle AI call, as well as local variables and selected data.

Example #

In total, a node class can look like this:

using UnityEngine;
using System.Collections.Generic;
using GamingIsLove.Makinom;

namespace GamingIsLove.ORKFramework.AI.Nodes
{
    // INFO: The 'EditorHelp' attribute manages the name and description of the node.
    [EditorHelp("Node Name", "The description of your node.", "")]
    // INFO: The 'NodeInfo' attribute manages in which section the node can be found in the add node selection.
    [NodeInfo("Section")]
    public class NewAINode : BaseAINode
    {
        // INFO: Place your settings here.

        public NewAINode()
        {

        }

        // INFO: This code will be executed when the node is executed.
        public override BaseAction Execute(ref int currentNode, BattleAICall call)
        {
            currentNode = this.next;
            return null;
        }

        // INFO: This returns the text displayed in the node's info area.
        public override string GetNodeDetails()
        {
            return "Node info text";
        }

        // INFO: This property handles the color of your node in the node editor.
        public override Color EditorColor
        {
            get
            {
                return Maki.EditorSettings.baseNodeColor;
            }
        }
    }
}

This node doesn’t do much, though. You can add your settings in the class and do whatever needs to be done in the Execute function.

Please note that your custom node doesn’t need to be in the GamingIsLove.ORKFramework.AI.Nodes namespace, it can be placed in any namespace (or none at all).

Scripting
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on May 21, 2022
Table of Contents
  • Battle AI Nodes
    • Node Execution
    • Example
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK
  • Contact
  • Blog
  • Makinom
  • gamingislove.com
Categories
  • News (60)
  • ORK 2 (137)
    • Tutorial (137)
      • Game tutorial (50)
      • Gameplay (32)
      • How-to (55)
  • Release (130)
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!