Predefined Actions - IsaacMulcahy/RPG-AI-SYSTEM-WIKI GitHub Wiki

This wiki has now moved to here. This will be kept for a while and will eventually be removed.

Overview

Predefined actions also refereed to as actions are functions which define how the interaction takes place within the Scene. They return a nullable boolean value to show the three possible states they can be in; successfully completed, still taking place and failed. This is then used by the Controllers to select the next behavior.

List of Predefined Actions

  • IDLE
  • MOUNT
  • DISMOUNT
  • AWAIT FOR MOUNT FILLED
  • LOCATE
  • LOCATE OWNED - This is being removed
  • LOCATE RANDOM OWNED
  • PICK UP
  • DROP OFF
  • FOLLOW ROUTE
  • FOLLOW ROUTE REVERSE
  • LOCATE IN ZONE 1
  • LOCATE IN ZONE 2
  • RANDOM LOCATION IN ZONE 1
  • RANDOM LOCATION IN ZONE 2
  • LOCATION_ENTRANCE

Locating logic

The location logic is mostly the same for all three functions but has some differences. The main method in which they work is they try to find Item's within '25' (default, can be changed in Actions, if owned it only uses the list of the workplaces and doesn't care about distance) of the NPC location of the specific type. The list is then used to figure out which one the NPC should head to dependent on the function, if it is not specified in the name then it'll be the closest that is used. With Zones it is the closest to the AI which is within the Zone.

Pick Up & Drop Off

This allows for the NPC to pick up, carry objects objects around and place down elsewhere. This works by looking for the closest not InUse item which is within '5' (can be changed in actions). It is then made a child of the GameObject which is either the object which has been assigned to the right or left hand (Set in the AI Databoard) and gravity is turned off. The small distance means it is recommend to use a 'LOCATE' action before doing calling the 'PICK UP'. On 'Drop off' the item parent is set to null and gravity is turned on.

Mount Actions

The mount actions allow for the NPCs to be able to use different means of transportation. It works by using the generic Mount class which defines where the NPCs use the Mount from. The first one added is the one in charge of controlling the Mount. It also contains how many are using it currently and the maximum amount.

Mount works by checking if the NPC is within '5' and if so it'll make sure the Mount is not full. If it isn't full then the NPC is teleported to an unused control point. The Mount boolean for being controlled is set to true and a reference is added to the mount for the current NPC

Waiting works by not completing the Action until the mount return true from the 'IsFull' check

Dismount works by cleaning up the Mount (remove the user reference) and cleaning the NPC databoard up by setting back the local settings mounted and inControlOfMount

Location Entrance

The NPC will walk to the entrance of the location to do with the current active controller, this is used for making NPCs turn up to work at the start of the day for example when the Work Controller is in use

Controllers

  • Work - Workplace entrance
  • Need - Home entrance

Custom Actions

To use this feature, it must be via code, you will need to create a Civil-AI-System ‘Action’ object and set it to the databoard current action (using ‘SetCurrentAction’). Then set the flag ‘hasAction’ and ‘customAction’ to ‘true’. By doing this the NPC will do the action given to them and when it is completed it will continue with the traditional logic of the controllers and system.