Start here · 8 min read

Who calls what? The DPB execution model

Understand initialization, enabling, ticking and asynchronous work before adding behavior.

After this lesson

You can explain why a method runs, where game reads belong, and who must stop or dispose work.

Download DPB1 source kit ↓ 8 complete projects · source only · .NET Framework 4.8 (net48)

The selected bot owns the execution loop#

DPB drives the selected bot. The bot decides whether to call plugin, routine and mover managers, or selected components directly. A plugin is not guaranteed periodic work merely because it is enabled.

AcademyBot deliberately drives only the named Academy components. This avoids activating unrelated installed extensions during the exercise. A name check is a teaching boundary, not a security boundary.

A general-purpose bot can call PluginManager.Start/Tick/Stop, RoutineManager.Start/Tick/Stop and PlayerMoverManager.Start/Tick/Stop. That also means taking responsibility for the enabled or selected components it drives.

text
DPB
└─ selected IBot.Start / Tick / Stop
   ├─ plugins the bot chooses to drive
   ├─ selected routine and mover, if the bot calls them
   └─ bot coroutine
      ├─ task priorities
      ├─ explicit Logic requests
      └─ yield back to DPB

The callbacks have different jobs#

  • Initialize / Deinitialize: prepare and release extension-level resources. Do not assume a character or area exists here.
  • Enable / Disable: an IPlugin becomes available or unavailable. Register and unregister plugin subscriptions here.
  • Start / Stop: the running bot session begins or ends. Reset per-run state; dispose your coroutine and pending work on Stop.
  • Tick: short, repeatable work. Check readiness, update a small amount of state and return quickly.
  • Logic: a caller asks for a particular behavior by ID and awaits its result. Selecting a routine does not automatically call its combat logic.
  • Message: synchronous communication by ID. It is not the right place for a long asynchronous game action.
Keep in mind

IPlugin does not include Tick, Start or Stop. Add ITickEvents and/or IStartStopEvents explicitly when needed. IBot, IRoutine and IPlayerMover already include their tick and start/stop contracts.

Return values are part of the contract#

  • MessageResult.Unprocessed: this component did not recognize or handle the message.
  • LogicResult.Unprovided: this component did not provide the requested behavior. Do not return Provided for unknown IDs.
  • ITask.Run() == true: this task handled the current iteration. With UntilHandled, later tasks wait until another iteration.
  • IPlayerMover.MoveTowards() == true in the Academy example: the movement request was accepted. It does not mean arrival.
  • LokiPoe.InGameState.UseResult.None: no reported error submitting that skill request. It is not a damage, hit or kill event.

A coroutine cooperates with DPB#

An async method returns a Task. A DPB Coroutine is the host that resumes that work from bot ticks. The examples create one on Start, resume it from Tick and dispose it on Stop.

Yield returns control to DPB; Sleep waits cooperatively for a bounded duration. Neither means a new thread is reading game objects. After an await, check current state again.

Do not use Thread.Sleep, a busy while loop, .Wait(), .Result or async void in the bot loop. Do not move game reads into Task.Run to make them seem asynchronous. That loses the normal execution context and can leave work running after Stop.

No player is a normal state#

Character selection, loading, disconnection and death are normal transitions. Before reading player state, check IsInGame and Me. Before actions also check that the player is alive, that the relevant UI/data is ready and that the caller owns an input session.

Game objects are views of changing state. Keep simple values such as a destination or an identifier when useful, then reacquire current objects after a wait. Do not keep a Monster or Item wrapper forever and assume it still represents the same live object.

Keep building

Look up a specific DPB1 API →
Download integrity and validation scope

Source kit: 26 files, 30,747 bytes. No client binaries or credentials.

SHA-256: f3d229e4e090feadc8713639c7e4c62fe3c6fb5aa54460af87829e0369ba5e95

Compile baseline: DPB1 0.3.29.47 / DPB2 0.4.5.88. Compilation is not a live game test. Follow the lesson's manual checks in your own test setup.