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_checkso 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 = trueinextendpicks the direct one.
What a build is
The fields extend takes. All are optional; ids are as in the game's API.
namespecstraitsspecs.utility_skillsspecial_skillscombat.equip_weapon_skill, from slot 6 on.legend_skillsweapon_sets{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_linkdirecttrue 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.
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.self.root.self.cc_group.self.cc_group.self.idle_group, with no target.false by default.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)
endThe 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() endnil, to run nothing). settings is read every tick, so a live config table works.on_damage.on_stop.enabledccauto_healreviveEach 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,
enabledis 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 (
shutdownputs it back); - out of combat, calls
idle; - uses the heal skill below
auto_heal, and revives a downed ally in reach whenreviveis on; - with an attackable target selected:
cc_rotationwhenccis on, its break bar is up andcc_skills_availablesays so; otherwiserotation, orhandle_target_invulnwhen 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.queuedacr.engines.directdirect = true. The Rust ACRs call it the legacy engine.ms milliseconds, sharing the engine's skill tracking. Keep it in the build's executor field: self.executor = acr.engines.direct:with_cd(70).