Creating a Continuous Behaviour Script

A ContinuousBehaviorScript is a module that defines recurring behavior logic for an AI agent. This logic is executed based on a specified frequency set when initializing the agent.

When the behavior runs, the aiAgent instance is passed as a parameter to allow access to its methods and data.


Requirements

The behavior module must implement the following structure:

local replicatedStorage = game:GetService("ReplicatedStorage") local aiCommandMap = require(replicatedStorage.AIAgentModule.AICommandMap)

local module = {}

-- Called before the behavior is run function module.InitializeBehavior() -- Perform any setup required before the behavior starts end

-- Called before each behavior execution cycle -- Return true to run the behavior, false to skip function module.BehaviorConditionsCheck(aiAgent: AIAgent): boolean -- Add logic to determine if behavior should run return true end

-- Called when conditions pass; executes behavior logic function module.RunContinuousBehavior(aiAgent: AIAgent) -- Add your custom behavior script here -- Sends current game state to the AI server -- Expects a response which may include a message or command local response, status = aiAgent.SendQueryToAgent({ aiAgent.GetGameState() }) if not response then return false end -- Executes command based on AI response if response.command then local commandResponse = aiCommandMap[response.command.functionName](response.command.parameters) end end return module

Last updated