Modding:AI Task seekentity

From Vintage Story Wiki

This task AI causes the entity to move towards the nearest target entity. By default it will try a direct path to the target. Possibly, if it cannot reach the target, it may try to circle around the target, but the code is a mess, and this may be an unfinished feature.

If the entity was recently hurt, then it will specifically target the entity that hurt it (assuming retaliation is enabled). If it cannot reach it retaliation target, then it will try a tactical retreat for 20 seconds.

If leapAtTarget is enabled, then it will occasionally leap at the target. With the default leap multiplier, the code tries to jump such that it reaches the target entity in half a second. However, the jump calculation does not take gravity into account, so it often misses the target vertically. Due to the entity's step height, the jump behavior does allow it to successfully leap over canyons.

Once the entity is sufficiently close to its target, this behavior stops. This is to prevent the entity from overlapping with its target.

After the task locks onto a target, it will continue following that target until the task stops due to any of its many conditions.

Subclasses

Properties

AiTaskBase partial compliance properties

In addition to the standard properties from AiTaskBase, this task respects the AiTaskBase partial compliance properties.

  • mincooldown
  • maxcooldown
  • initialmincooldown
  • initialmaxcooldown
  • whenSwimming
  • whenInEmotionState
  • whenNotInEmotionState

AiTaskBaseTargetable properties

It inherits the properties from AiTaskBaseTargetable.

  • friendlyTarget
  • retaliateAttacks
  • triggerEmotionState
  • skipEntityCodes
  • entityCodes

AiTaskSeekEntity properties

These are the properties specific to seekentity and its subclasses.

leapAtTarget: (boolean, default false)
whether to occasionally jump at the target.
leapAnimation: (string, default "jump")
Animation to play when the entity jumps. It also stops the run and walk animations when it starts the leap animation.
leapChance: (float, default 1.0)
Chance to leap at the target when all other conditions are met. Leaps have a cool down. So with the default value of 1.0 (and if leaps are enabled), then the entity will leap when it first engages the target, then wait for the cool down before leaping again.
leapHeightMul: (float, default 1.0)
Multiply the vertical velocity that is added to the target during a leap. The default velocity is how long it to take to reach the player (such that the entity and target entity's feet are at the same level) in half a second, assuming no gravity. So due to gravity, the entity falls short of the target. Setting this property greater than 1.0 may let it reach the target.
moveSpeed: (float, default 0.02)
the control force for movement. Higher values will let the entity go faster.
extraTargetDistance: (float, default 0)
Stop when the entity's bounding box is at least this close to the target's bounding box. Typically a value greater than 0 is used when the entity's shape is larger than their bounding box, to prevent the entity's shape from overlapping with the target's shape.
seekingRange: (float, default 25)
how many blocks away the entity can sense targets, when it is warm outside. AiTaskBaseTargetable describes how this seeking range is further reduced for players.
belowTempSeekingRange: (float, default 25)
how many blocks away the entity can sense targets, when it is cold outside. AiTaskBaseTargetable describes how this seeking range is further reduced for players.
belowTempThreshold: (float, default -999)
when the outside temperature is less than or equal to this, belowTempSeekingRange is used. Otherwise seekingRange is used. Wolves use this to simulate being hungrier in the winter and willing to search further.
maxFollowTime: (float, default 60)
only lock onto an entity for at most this long. After this time plus a cooldown, the entity will again find the closest entity (which may be the same as the last one) and seek it.
alarmHerd: (boolean, default false)
when the target is part of a herd, send it a "seekEntity" notification when this entity first targets it.
retaliateAttacks: (boolean, default true)
whether to immediately target whatever last hurt this entity. If the entity has not been hurt recently, then the default targeting logic runs.
executionChance: (float, default 0.1)
chance per frame to try to lock onto a target (assuming it has not already locked onto a target). whenInEmotionState property overrides this. This chance is further reduced by a hard coded 50%.
searchWaitMs: (int, default 4000)
after attempting to lock onto a target, prevent it from trying again for at least this long. Trying to lock onto an entity is computationally expensive. So this prevents entities with unreachable targets from overloading the system.


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 ItemEntityEntity BehaviorsBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsCollectible 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