What the fight module knows about a fight, how it works out the turns it can play, how it scores them and weighs the danger, and the limits that keep a fight going, so you can read its turn log and tune a profile.
The fight module doesn't follow a script of moves written for each class. Before each action, it looks at the fight as it is, works out what the character can really do, plays whole turns out on a copy of the fight, and picks the one its profile scores best. This page explains how, so you can read the turn log and know which profile setting changes what.
What it knows
The module reads the fight from two sources.
The game's messages, the same ones the Dofus client reads: every fighter's team, cell, life, shield, AP, MP, characteristics, resistances, states and active effects, who is invisible, every spell's cooldown and how often it was cast, the glyphs and traps on the ground, the round and whose turn it is. The character's own spells, at their levels, come with the fight's start.
The game data of the bot's game version: what each spell costs, its range, its zone and its effects, which targets it touches, the monsters' spells at each grade, the weapon the character holds, and the fight map's cells and line of sight.
When a piece is missing, it estimates with less rather than stopping. An enemy whose spells the game data doesn't have is counted as hitting bare-handed, and a fight map it can't read is played as if every cell were open. A decision always comes out.
It doesn't know what it can't see either: a fighter that is invisible is never aimed at until the game shows it again.
What the character can do
For each cell the character can walk to, the module works out the walk's cost: the MP of the path, and the AP and MP the enemies next to it would take when it leaves their side (tackle), with the game's own formula. A cell it would be stopped on is out of reach.
From each of those cells, it checks every spell and the weapon the way the game does: AP, range with the character's range bonus, the effects that change a spell's range and the spell bonuses of its equipment, line of sight, casting in a line or a diagonal, cooldowns, casts per turn and per target, the states a spell needs or forbids, the free cell a spell needs, and the summon limit.
For each cast it can make, it works out what happens on every fighter in the spell's zone: damage with its rolls and the spell's bonuses, the caster's characteristics and the target's resistances, critical hits by their chance, erosion and shields, heals, pushes and the damage of hitting an obstacle, AP and MP taken, states, summons, and the spells an effect casts in turn. These are the rules the Dofus client uses to preview a spell, so the module and your client agree on what a cast does.
The danger
Before choosing, the module works out how dangerous each cell would be at the end of the turn: how much the enemies could deal the character there on their next turn. It takes the worst case. Each enemy is counted from every cell it can walk to, with every spell it will have off cooldown by then, as many casts as its AP allows, the most damage per AP first.
The glyphs on the map count too, as the game plays them: a glyph acts on a fighter whose turn ends in it, and on one whose turn starts in it, before it can move. So a cell in a glyph that would hurt the character is as dangerous as what the glyph would deal it.
The profile's Risk turns that into a limit:
| Risk | Where the module avoids ending a turn |
|---|---|
| 0 to 99 | Where the enemies could kill the character, and where they could deal it more than risk percent of its life. At 50, the default: more than half its life. |
| 100 | Nowhere: the character fights as if danger didn't exist. |
The danger beyond that limit counts against a turn as safety. Killing an enemy removes its share of the danger, so a turn that kills a threat before stepping in front of it is worth more than one that doesn't.
Planning a turn
The module plays turns out on copies of the fight: walk, cast, cast again, walk, end the turn. Each action is played with its expected result, so a push really moves the target, a kill really removes the enemy, and the next cast sees it.
Traps play as in the game: a fighter that walks or is pushed into one sets it off, its spell plays, and its walk or push stops there. So the module never walks into a trap that would hurt the character, and it counts pushing an enemy into a trap of its side.
It doesn't try every possible turn, there are far too many. At each step it keeps the 6 best turns started so far, extends each with the best next actions, and goes up to 5 actions deep, within 2000 actions per decision. Then it plays only the first action of the best turn, waits for the server's answer, and decides again from the fight as it now is. The rest of the turn it chose is always among what it weighs then, so deciding again can find a better turn but never loses a good one. A spell that rolled low, a dodge or a push that went differently doesn't throw the rest of the turn off.
The work is bounded by these counts, never by time. The same fight and the same profile give the same decision on a slow PC and a fast one, and a decision takes a few milliseconds to a second, up to a few seconds for a high-level summoner weighing what each of its summons would do, depending on the character's spells. The module thinks while it waits before playing, so this rarely slows the fight.
How a turn is scored
A turn's score adds up what it does, each part weighted by the profile:
| Term | What counts |
|---|---|
| Damage | The damage dealt, expected: critical hits counted by their chance, capped at what the target has left in life and shield. |
| Kill | An enemy killed: half its maximum life, plus the danger it no longer poses. |
| Heal | Life healed, up to what is missing. |
| Control | Enemies hindered: AP and MP taken, characteristics lowered, pushed, put in a state. |
| Buff | Lasting help to its side: a buff or a shield on an ally, or on the character when it outlasts its turn. A buff that only lasts the character's own turn counts for what it lets the character do in that turn, so it's cast when it enables something. |
| Summon | A creature summoned: what its own next turn can do, which comes right after the character's. That's its best cast from where it lands or a cell it can walk to, with its own spells, counted at half. Only that one turn counts, since the enemies may kill it next: a summon that can't do much next turn is worth little, and hitting the enemy wins. |
| Safety | Minus the danger left beyond what the risk accepts. |
| Position | How well the cell the turn ends on suits the profile: its distance from the enemies, out of their sight to hide. |
| Unused AP | Minus the AP left over, or spent on casts that did nothing. |
| Harm to allies | Minus the damage and hindering done to its own side. |
| Traps and glyphs | What the traps and glyphs the turn lays will do to the enemies: a glyph's effect on the enemies standing in it, as their turn starts, or half of it for a glyph acting as their turn ends, since they may walk out first; a trap's effect on the enemy that can walk into it on its way to the character, at half, since whether it does is the monster's choice. |
A summon counts for half of a fighter of its kind, in every term: it dies with its summoner, so killing the summoner is often worth more.
The role sets the weights, and a profile can change any of them with Weights:
| Role | Damage and kill | Heal | Control | Buff | Summon | Safety, position, unused AP, traps and glyphs | Harm to allies |
|---|---|---|---|---|---|---|---|
| Damage | 1 | 0.5 | 1 | 1 | 1 | 1 | 5 |
| Tank | 1 | 0.5 | 1.5 | 1 | 1 | 1 | 5 |
| Support | 0.7 | 1 | 2 | 2 | 1 | 1 | 5 |
| Healer | 0.5 | 2 | 1 | 1.5 | 1 | 1 | 5 |
The profile then shifts single casts and targets:
| Setting | Effect on the score |
|---|---|
| A spell's Use | Prefer ×1.5, Avoid ×0.5, Never: never cast. The weapon's Use does the same for weapon hits. |
| Elements | A cast of a favoured element ×1.2. |
| Focus, a monster's Focus, a focus rule | Hitting the focused enemy ×2. A monster set to Last ×0.5, to Ignore ×0: hitting it counts nothing. Several focuses on one enemy multiply. |
Where the turn ends
Once nothing is left worth casting, the turn ends where the profile wants the character to stand:
- Range sets the distance it fights at. Melee is in contact, Long range the reach of its longest damaging spell, Mid range half of it. Automatic, the default, reads the character's damaging spells: when most of them reach 2 cells or less it plays melee, from 6 cells long range, mid range in between.
- Positioning sets how it gets there: keep that distance, charge, hold, kite or hide. Profile settings describes each.
- A monster's Keep away and the movement rules (Retreat, Approach, Keep distance) add their own goal.
Through all of it, the danger limit holds: the module doesn't walk where the character can be killed when another cell does almost as well.
Placement
Before the fight, with Placement set to Automatic and the character's spells known, the module scores each starting cell of its team the way it scores a turn: it plans the first turn from there, and takes away the danger beyond the risk, should the monsters play first. With Close, it picks the cell nearest the enemies, and with Far the farthest from them. Before it knows the character's spells, Automatic goes by range: close for melee, far for long range, 4 cells from the nearest enemy otherwise. The character's spells are known from its previous fight, so only the first fight after Asterobot starts is placed that way.
Limits that keep a fight going
- One action at a time. The module sends an action, then waits for the server's answer before deciding the next. It never sends an action twice.
- 3 seconds without an answer means the server didn't take the action. The module drops that spell, or walks from that cell, for the rest of the turn, and decides again without it. The turn log marks it Not answered.
- 30 actions per turn at most, after which the turn ends.
- 2 seconds of margin. Its last decision goes out at least 2 seconds before the turn's time runs out, so a rule's delay never costs the turn.
- Always an action. When nothing is worth doing, it ends the turn.
What it doesn't weigh yet
- Walls, portals, runes, and the glyph-auras that follow their caster: they count as nothing. Nor does the danger count the traps and glyphs the enemies could lay on their next turn.
- The spells of an enemy's summons: the module doesn't know which monster a summon is yet, so it counts them as hitting bare-handed.
- Challenges. See Coming soon.