Skip to content

Combat Scripts ​

The Combat Scripts editor (Behaviors > Combat Scripts).
The Combat Scripts editor (Behaviors > Combat Scripts).

A combat script says how an entity fights: how it looks for a target, how it closes in, what it does when it is in range, and how it reacts to what happens. You give a script to an NPC, to a placed NPC, or to a player class (for the party members the AI controls).

An NPC with no combat script still fights: it uses a simple one that spams its basic attack and then its abilities in turn.

The states of a fight ​

A fighting entity is always in one state. The script chooses which states it uses, and what it does in the Attacking state; the other states are handled by the game.

StateWhat the entity is doing
InactiveNot in a fight. It idles, and it goes back here when the target is too far (it leashes)
Target searchIt has no target. An NPC picks the enemy with the most threat (or the nearest, when the project does not use threat). It then searches a while, and gives up
ChasingIt moves towards the target until it is in range of its attack. It routes around obstacles and finds a spot with line of sight
AttackingIt is in range and fights. This is where the script's attack logic runs
FollowingIt follows another entity: a companion behind the player, a pet behind its summoner
Player commandIt does what the player ordered (move to a point) and then returns to what it was doing
FleeIt runs away from the one who made it afraid, for as long as the effect lasts
DisorientedIt wanders at random where it stands, for as long as the effect lasts
IncapacitatedStunned: no movement and no action, until the effect ends
DeadDefeated

Crowd control effects put an entity in Flee, Disoriented or Incapacitated by themselves.

Fields ​

FieldWhat it doesDefault
Auto basic attackWhen the attack logic has nothing to do, use the basic attackon
Basic attack intervalSeconds between basic attacks0.5
Uses target search / chasing / attacking / following / player commandWhich states the script uses. Switch off chasing for a turret that never moves. Switch on following for a petsearch, chasing, attacking
Attack logic typeSimple, Priority, Timeline or Tactical, belowSimple
Attack state logicThe logic itself, whose fields change with the type
Phase systemOptional: boss phasesnone
Global reactionsReactions that work in any statenone

Attack logic ​

The logic is a small AI. Each kind suits one style of fight.

TypeForHow it decides
SimpleMost enemiesIt makes an action for each active ability by itself and cycles through them. Fields: Min first delay, Max first delay (a random wait before the first action, 2 to 5 s), Rest after action (3 s)
PriorityA caster that should use a special ability when something is trueA list of actions. Each has a priority and conditions; the highest-priority action whose conditions hold and that is ready is used. Fields: the Actions list, Min/Max first delay (5 to 7 s), Rest after action (0.5 s)
TimelineA scripted bossThe actions run at set times: 0 s fireball, 10 s summon adds, 20 s run to the center. Fields: Timeline actions, Action times (one for each action), Loop timeline (on)
TacticalAn action-RPG enemy that moves aroundIt manages its distance and picks actions by range. See below
CompanionA party member the AI controlsEvery 0.6 s it uses the first ready active ability that fits: an enemy ability on the target, an ally ability on the most hurt member below 70 % health. Fields: Decision interval (0.6), Heal threshold (0.7). Used by companions by default

Tactical logic ​

FieldWhat it doesDefault
Preferred range, Min range, Max rangeThe distance it likes to keep. Closer than the minimum it backs off, farther than the maximum it closes in6, 3, 10
Circle probabilityThe chance to circle the target when it is at a good range0.3
Reposition cooldownSeconds between thinking about moving3
Retreat after combo, Retreat distanceBack away after a comboon, 8
Melee actions, Ranged actions, Repositioning actionsActions used within the preferred range, beyond it, and to move (retreat, strafe, keep distance)

Combat actions ​

An action is a thing to do. Every action has:

FieldWhat it doesDefault
PriorityHigher is checked first in a priority list0
ConditionsConditions that must hold for the action to run: "health below 50 %", "target has no Poison"none
Action cooldownSeconds before the action can run again, independent of the ability's own cooldown0
Interrupt castingThe action can cut short a cast in progressoff

The kinds:

ActionWhat it does
Use AbilityUses an ability on the current target. The most common action
Use Ability at PointUses a ground-targeted ability at a position
ComboRuns a list of actions in order: slash, delay, sweep, delay, smash
DelayWaits a number of seconds (inside a combo)
Wait for ConditionPauses until a condition is true, with an optional timeout
Face TargetTurns to the target without moving
Move to PointRuns to a fixed world position (the arena center)
Move to Ally PositionMoves to an ally: the nearest, the most hurt, or by another rule
RetreatMoves away from the target by a distance
Keep DistanceHolds a distance, moving closer or farther, for ranged enemies
StrafeCircles the target while still facing it
Say or EmoteSays a line or does an emote in the fight (the boss roars at half health). See Chat > Lines
Switch to Highest ThreatGoes back to the target the threat table prefers
Switch to Enemy, Switch to AllyPicks another target by criteria: nearest, lowest health, with or without an effect
Clear TargetDrops the target and searches again
Call for HelpShouts: allies within a range join the fight, and an optional effect plays
Spawn NPCSpawns a creature at a position or at the caster (adds, reinforcements)
Spawn InteractableSpawns an interactable (a totem, a trap)
Spawn World EffectSpawns a ground effect
Trigger EventTriggers an event of the world
Set Music State, Set Music Intensity, Play StingerChange the state or the intensity of the Dynamic Music that plays in the fight, or play one of its stingers: put them in the on enter actions of a boss phase
Activate QuestStarts a quest

Phases (boss fights) ​

A phase system is a list of phases. A boss with three phases is the system with three entries, entered one after another as the fight goes on.

Field of a phaseWhat it does
Phase nameFor you
Phase attack logicThe attack logic used while the phase is on
Phase transitionWhen the phase ends: a list of entity conditions (health below 60 %, a time passed, an event) and whether all or any of them must be true
On enter actions, On exit actionsActions run when the phase begins and ends: summon adds, shout, become immune

Reactions ​

A reaction runs actions when something happens, at any moment of the fight, without waiting for the attack logic.

FieldWhat it doesDefault
Reaction nameFor you
Trigger eventDamage taken, Damage dealt, Health below percent, Ally died, Enemy died, Target changed, Effect gained, Effect lost, Ability used (by the target)Damage taken
Health threshold percentFor Health below percent30
ConditionsExtra conditionsnone
Reaction actionsThe actions to run
Reaction cooldownSeconds before it can fire again0

"When an ally dies, call for help" and "below 30 % health, retreat and heal" are reactions.

Examples ​

You wantBuild
A wolfNo script. It chases and bites
A caster that heals itself when lowPriority logic: Use Ability: Heal with priority 100 and the condition "health below 40 %", then Use Ability: Bolt with priority 10
A boss with a patternTimeline logic, or a phase system of three phases, each with its own logic, and an on enter action that summons adds
An archer that kitesTactical logic with a preferred range of 10, Keep Distance and Retreat as repositioning actions, Use Ability: Arrow as the ranged action
A turretA script that does not use chasing
A pet that followsUses following on

See also ​