ACRs

Writing a build

The Acr class, the runner and the engines.

A build is a class made from acr.Acr. extend takes what the build is (its name, specializations, traits, skills and weapons), and the class's build method makes its nodes. Calling the class makes the build: MyBuild(settings) runs build(settings) once.

A small build

A fire scepter/focus elementalist: the scepter and focus skills by priority, Signet of Fire when it's on, and Arcane Wave for break bars. Save it as acrs/fire_scepter.lua, then add it to the registry and the config.

local acr = require("acr")
local Skill, NodeGroup, Ground = acr.Skill, acr.NodeGroup, acr.Ground
local widgets = acr.widgets

local SCEPTER_FIRE_1, SCEPTER_FIRE_2, SCEPTER_FIRE_3 = 5508, 5692, 5675
local FOCUS_FIRE_4 = 5497
local SIGNET_OF_FIRE = 5542
local ARCANE_WAVE = 5638

local FireScepter = acr.Acr:extend({
    name = "Fire Scepter",
    weapon_sets = { { inventory.WEAPON_TYPE_SCEPTER, inventory.WEAPON_TYPE_FOCUS } },
})

function FireScepter:build(settings)
    self.settings = settings

    self.root = NodeGroup()
        :push(10, Skill(SCEPTER_FIRE_2):skill_range())
        :push(9, Skill(FOCUS_FIRE_4):skill_range())
        :push(8, Skill(SCEPTER_FIRE_3):skill_range():skill_radius())
        :push(7, Skill(SIGNET_OF_FIRE)
            :enabled(settings, "signet_of_fire")
            :facing_check()
            :skill_range())
        :push(1, Skill(SCEPTER_FIRE_1):skill_range():facing_check():no_casting_check())

    self.cc_group = NodeGroup()
        :push(10, Skill(ARCANE_WAVE)
            :ground_targeted(Ground.MINIMIZE_DISTANCE)
            :skill_radius()
            :skill_range())
end

function FireScepter:draw_settings()
    widgets.skill_toggle(self.settings, "signet_of_fire", SIGNET_OF_FIRE)
end

return FireScepter
  • The auto attack has the lowest priority, so it runs when nothing else can, and no_casting_check so it's sent again while it's being cast.
  • Signet of Fire is an instant cast, so it runs next to whatever normal skill is picked; see what runs.
  • :enabled(settings, "signet_of_fire") reads the setting every time, so the toggle in the Settings window takes effect at once.
  • The build uses the queued engine, the default. direct = true in extend picks the direct one.

What a build is

The fields extend takes. All are optional; ids are as in the game's API.

name
The name in the ACR window.
specs
The three specialization ids, in order. Equipped by the window's traits button.
traits
The nine trait ids: three per specialization, in the order of specs.
utility_skills
The heal, three utility and elite skill ids, in bar order. Equipped by the traits button; the window warns about other skills on the bar.
special_skills
Other skills the traits button equips, with combat.equip_weapon_skill, from slot 6 on.
legend_skills
Revenant legends. Not equipped yet.
weapon_sets
The weapons the build plays: a list of sets, each {main, off} or {two_handed} as inventory.WEAPON_TYPE_*. The runner only prepares the skill bar on these weapons, and the window shows an error on others. Empty for any weapons.
build_link
A gw2skills.net link, opened by the window's website button.
direct
true to run on the direct engine, without a skill queue, instead of the queued one.

What a build does

Every method has a default; override the ones you need. build makes the nodes, and the defaults of rotation, cc_rotation and idle run them.

Makes the nodes, once. Put the rotation in self.root (a NodeGroup or NodeTree), crowd control in self.cc_group, and what to do out of combat in self.idle_group. Keep settings in self for draw_settings.
In combat, with a target that can be attacked. Runs self.root.
Whether any crowd control can be used on the target now. Checks self.cc_group.
The target's break bar is up and crowd control is available. Runs self.cc_group.
Out of combat. Runs self.idle_group, with no target.
Extra invulnerability checks for this build, on top of acr.targeting's. The encounters checks go here. false by default.
The target is invulnerable. Does nothing by default.
In combat with nothing selected. Does nothing by default.
Every tick, before anything else, even while the rotation is off. Keep timers and state up to date here.
Draws the build's own settings in the Settings window, usually with acr.widgets.
engine()engine
The engine the build's nodes run on: self.executor if the build made one, otherwise the queued or direct engine.

An overridden method runs the groups itself, with group:execute(self:engine(), target). For example, a build whose pet acts alongside the rotation:

function PowerMechanist:rotation(target)
    local engine = self:engine()
    self.mech:execute(engine, target)
    self.root:execute(engine, target)
end

The runner

acr.Runner plays one build. The template's app.lua makes one, gives it the build picked for your profession, and calls it from the callbacks:

local runner = acr.Runner.new(MyBuild(settings), config_api.cfg().acr)

function on_tick() runner:tick() end
function on_damage(event) runner:on_damage(event) end
function on_stop() runner:shutdown() end
A runner for a build (or nil, to run nothing). settings is read every tick, so a live config table works.
Runs the build. Call it every tick.
Swaps the build, for example when the player picks another one.
Lets the engines count hits. Call it from on_damage.
Puts back the ground targeting mode the runner changed. Call it from on_stop.
settings
enabled
Run the rotation.
cc
Use crowd control on break bars.
auto_heal
Use the heal skill below this health percent; 0 for never.
revive
Revive downed allies in reach.

Each tick the runner:

  • calls the build's handle_daemon, whether or not the rotation is on;
  • stops there while there's no character, you're gliding, dead, enabled is off, or you're using skills by hand;
  • on the build's weapons, selects an auto attack if none is, and switches ground targeting to fast (shutdown puts it back);
  • out of combat, calls idle;
  • uses the heal skill below auto_heal, and revives a downed ally in reach when revive is on;
  • with an attackable target selected: cc_rotation when cc is on, its break bar is up and cc_skills_available says so; otherwise rotation, or handle_target_invuln when it's invulnerable;
  • in combat with nothing selected, calls handle_no_target.

Engines

An engine checks whether a node can run (on the bar, ready, not already casting, in range, facing) and sends it to the game. Every build shares the two in acr.engines.

acr.engines.queued
The default. Sends the next skill while the current one is still being cast, timed so it starts the moment the cast ends. A skill is sent at most once every 40 ms.
acr.engines.direct
No skill queue: sends each skill straight away, once it can start now, at most one every 150 ms, and waits out casts that mustn't be cut short. Picked with direct = true. The Rust ACRs call it the legacy engine.
An executor of its own that sends orders at most every ms milliseconds, sharing the engine's skill tracking. Keep it in the build's executor field: self.executor = acr.engines.direct:with_cd(70).
Whether the node can run now.
Runs the node, if nothing queued is in the way.