Modding:Entity Behavior taskai: Difference between revisions

From Vintage Story Wiki
(Start the page)
 
(→‎Debugging: create a table with all tasks)
Line 16: Line 16:


Entity debug info has to be turned on on both the server (with <code>/entity debug 1</code>) and client side (with <code>.clientconfig showentitydebuginfo 1</code>). With just the server side, the server sends the extra debug information to the client, but the client does not display it. With just the client side, it will display the active animations, but it will not get the task status from the server.
Entity debug info has to be turned on on both the server (with <code>/entity debug 1</code>) and client side (with <code>.clientconfig showentitydebuginfo 1</code>). With just the server side, the server sends the extra debug information to the client, but the client does not display it. With just the client side, it will display the active animations, but it will not get the task status from the server.
== All Tasks ==
{| class="wikitable"
|-
! Task Name
! Explanation
! style="width: 8em" |Example entities
! style="width: 15em" |Properties
|-
| [[Modding:AI_Task_bellalarm|bellalarm]]
|
|
|
|-
| [[Modding:AI_Task_butterflychase|butterflychase]]
|
|
|
|-
| [[Modding:AI_Task_butterflyfeedonflowers|butterflyfeedonflowers]]
|
|
|
|-
| [[Modding:AI_Task_butterflyflee|butterflyflee]]
|
|
|
|-
| [[Modding:AI_Task_butterflyrest|butterflyrest]]
|
|
|
|-
| [[Modding:AI_Task_butterflywander|butterflywander]]
|
|
|
|-
| [[Modding:AI_Task_cometoowner|cometoowner]]
|
|
|
|-
| [[Modding:AI_Task_eidolonmeleeattack|eidolonmeleeattack]]
|
|
|
|-
| [[Modding:AI_Task_eidolonslam|eidolonslam]]
|
|
|
|-
| [[Modding:AI_Task_fishmovefast|fishmovefast]]
|
|
|
|-
| [[Modding:AI_Task_fishoutofwater|fishoutofwater]]
|
|
|
|-
| [[Modding:AI_Task_fleeentity|fleeentity]]
|
|
|
|-
| [[Modding:AI_Task_flycircle|flycircle]]
|
|
|
|-
| [[Modding:AI_Task_flyswoopattack|flyswoopattack]]
|
|
|
|-
| [[Modding:AI_Task_getoutofwater|getoutofwater]]
|
|
|
|-
| [[Modding:AI_Task_gotoentity|gotoentity]]
|
|
|
|-
| [[Modding:AI_Task_idle|idle]]
|
|
|
|-
| [[Modding:AI_Task_jealousmeleeattack|jealousmeleeattack]]
|
|
|
|-
| [[Modding:AI_Task_jealousseekentity|jealousseekentity]]
|
|
|
|-
| [[Modding:AI_Task_lookaround|lookaround]]
|
|
|
|-
| [[Modding:AI_Task_lookatentity|lookatentity]]
|
|
|
|-
| [[Modding:AI_Task_meleeattack|meleeattack]]
|
|
|
|-
| [[Modding:AI_Task_meleeattacktargetingentity|meleeattacktargetingentity]]
|
|
|
|-
| [[Modding:AI_Task_seekblockandlay|seekblockandlay]]
|
|
|
|-
| [[Modding:AI_Task_seekentity|seekentity]]
|
|
|
|-
| [[Modding:AI_Task_seekfoodandeat|seekfoodandeat]]
|
|
|
|-
| [[Modding:AI_Task_seektargetingentity|seektargetingentity]]
|
|
|
|-
| [[Modding:AI_Task_stayclosetoentity|stayclosetoentity]]
|
|
|
|-
| [[Modding:AI_Task_stayclosetoguardedentity|stayclosetoguardedentity]]
|
|
|
|-
| [[Modding:AI_Task_throwatentity|throwatentity]]
|
|
|
|-
| [[Modding:AI_Task_useinventory|useinventory]]
|
|
|
|-
| [[Modding:AI_Task_wander|wander]]
|
|
|
|}
{{Navbox/contentmodding}}

Revision as of 05:58, 7 October 2024

This server side entity behavior runs one or more tasks for the entity. The tasks are assigned through the aitasks property as part of applying the behavior to the entity.

Tasks are either active (aka executing or running) or inactive. Each task is assigned a slot, in the range 0 to 7. Multiple tasks are often assigned to the same slot, but only one task can be active per slot.

Tasks are assigned a priority. The behavior will run the highest priority task that is able to run for the slot. When there are multiple tasks with the same priority, the task's order in the list is used as a tie-breaker, where entries earlier in the list are preferred.

Sometimes a higher priority task is initially unable to run, but later is able to run, which causes the current active task to be cancelled and replaced with the higher priority task. When considering whether to cancel an active task, its cancel priority is considered instead of its regular priority. Setting the cancel priority high allows an otherwise low priority task to run to completion once it starts.

For example, the locust has the meleeattack at priority 3 on slot 0, and seekentity at priority 1.5 (and cancel priority 1.5) on slot 0. Initially when the player is not in range, meleeattack is unable to run, because its ShouldExecute method returns false when the target entity is out of melee attack range. So the seekentity task is run first, even though it is lower priority. After the seekentity task gets the locust within range of the player, the meleeattack task is able to run. So the seekentity task is canceled and replaced with meleeattack, because they share the same slot. After the attack, meleeattack enters cooldown and becomes inactive. So the seekentity task resumes.

Debugging

Ram with the seekfoodandeat task active at priority 1.35

Turning on entitydebuginfo puts a text box above each entity. The text box shows the active tasks (along with their priority and cancel priority), emotional state, and currently running animations.

Entity debug info has to be turned on on both the server (with /entity debug 1) and client side (with .clientconfig showentitydebuginfo 1). With just the server side, the server sends the extra debug information to the client, but the client does not display it. With just the client side, it will display the active animations, but it will not get the task status from the server.

All Tasks

Task Name Explanation Example entities Properties
bellalarm
butterflychase
butterflyfeedonflowers
butterflyflee
butterflyrest
butterflywander
cometoowner
eidolonmeleeattack
eidolonslam
fishmovefast
fishoutofwater
fleeentity
flycircle
flyswoopattack
getoutofwater
gotoentity
idle
jealousmeleeattack
jealousseekentity
lookaround
lookatentity
meleeattack
meleeattacktargetingentity
seekblockandlay
seekentity
seekfoodandeat
seektargetingentity
stayclosetoentity
stayclosetoguardedentity
throwatentity
useinventory
wander


Content Modding
Basics Content Mods Developing a Content Mod Packaging & Release
Tutorials
Concepts Modding Concepts Modinfo Variants Domains Patching Remapping World Properties
Moddable Assets
Uncategorized
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository