Conditional casting

Get your trial key

New user ? Check guides​ or ask the discord bot

ComMan
ROS BOT
Joined: 03/20/2014 - 17:34
Fri, 03/05/2021 - 15:26 #1


Custom conditions are a vast and complex topic. We strongly recommend to not start scripting with too many conditions

ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Introduction

Conditional casting feature allows the addition of custom conditions to all custom script actions.
Conditional casting results in a more fine-grained way of configuring when the bot is casting skills.

Without custom conditions, a skill can be configured to be cast when:

  • a certain time has passed since a particular action was executed (timer field)
  • enough resource (primary or secondary) is available (resource settings)
  • health or a resource is below a certain trehsold (buff health or resource)
  • a skill is not active (buff without force recast) or still active (buff with force recast)
  • a mob is attacked (attack/elite/whirlwind)
  • a destructible object is to be destroyed (break items)
  • a movement activity is executed (Walk, approach, evade or town movement)

All the above options still exist with custom conditions. However the custom condition is now checked additionally and the action is triggered only if the custom condition that you configured evaluates to True
ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Listing the currently active powers

Diablo 3 works internally with so-called PowerSNOs. In order to list all powers that are currently active, the Tools/Conditional window of the bot can be used.
Open the window and then press 'Dump active skills'; an editor window will open which contains all powers which are currently active.

  • The first line is a header row which contains names of all columns: Type,StackCount,Bucket,Power,Translation
  • Type: either Rune, Buff, EndTick or Cooldown (influences which functions can be used for a particular power, see below)
  • StackCount: contains the current stack count of a power (for example relevant for certain weapons and gems)
  • Bucket: the slot used by the power (it is common than several buckets are used to model different aspects of a power) or the Rune index
  • Power: the name of the power
  • Translation: a human-readable translation of the power (this is not always available)

Tips

  • Certain powers are only active for a short time. In solo mode, you can pause the game by pressing ESC to freeze the current game state and then dump all powers more easily.
  • Power names in the bot are case insensitive.
  • Powershell users may use Import-Csv .\dumpowers.csv|ogv command for quick filtering operations

ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

An alternative way to get the power name of a particular skill or item

Go to Blizzard's D3 game guide website, select a class, browse the skill's icon of interest. Inspect the element background-image, e.g.:

background-image: url('https://blzmedia-a.akamaihd.net/d3/icons/skills/64/p6_necro_bonespikes.png'); width: 64px; height: 64px

P6_Necro_BoneSpikes is the power name of the skill.
The same trick can be used for items as well.

Power skills and items catalogue

Script writers who don't want to go through the cumbersome skill dump process for finding out the relevant power names can take a look at this Google spreadsheet: https://docs.google.com/spreadsheets/d/1P-eqyoBgvqy-qqGIElTtWousXIXDzZGX...
It lists many relevant powers for all classes (WIP).
ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Operators for evaluating expressions

A custom condition is a boolean expression. It can be written as the combination of boolean or numerical operators, functions that consume powers/buckets, brackets and integer values.

  • Supported boolean operators
    • Logical AND: &
    • Logical OR: |
    • Logical NOT: !
  • Supported numerical operators
    • Equal: ==
    • Not equal: !=
    • Less than: <
    • Less than or equal: <=
    • Greater than: >
    • Greater than or equal: >=
  • Brackets: ( )

Expressions are evaluated from left to right, there is no particular operator precedence. For enforcing a precedence, brackets have to be used.
ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Supported functions for working with powers

  • True() - evaluates to TRUE
  • False() - evaluates to FALSE
  • Health(), Primary(), Secondary() - functions for health and resource, can be used with absolute values or %
  • Cooldown(power) - returns the cooldown duration left in ms
  • Rune(power) - returns the currently configured rune index of the given power
  • IsBuffActive(bucket, power) - evaluates to TRUE or FALSE depending on if a particular power is active
  • BuffStackCount(bucket, power) - returns the stack count of a particular power
  • BuffTimeLeft(bucket, power) - returns the remaining time (in ms) a particular power is in effect
  • ChargeCount(power) - returns the charges count for a particular power (version 3.910 or higher)

The functions IsBuffActive(), BuffStackCount() and BuffTimeLeft() have the same parameters and overloads.
There is currently no Toughness() function available.
The evaluation of expressions is optimized, once the result of a boolean expression sequence is clear, the remaining terms will no longer be evaluated.

  • Examples:
    • False() & B & C & D & E => returns FALSE
    • False() & B | C | D | E => returns FALSE
    • True() | B & C & D & E => returns TRUE
    • True() | B | C | D | E => returns TRUE

Tips

  • The rune order reported by the Rune() function is not the same as displayed in the game, so make sure to double-check a particular rune index via the dump functionality of the bot.
  • IsBuffActive() can also be used to check for existence of an item, set power, or skill. This can be used to check if a certain item or skill is equipped which allows to create scripts for different build variants (e.g., bounty, rift, grift). To further facilitate different build variants, the Rune() function can be used to ensure that a particular rune of a given skill is equipped.
    • Examples:
      • IsBuffActive(0, item or set name)
      • IsBuffActive(0, skill name)
  • IsBuffActive(P6_Necro_BoneArmor) => auto detects the bucket depending on the skill position
  • IsBuffActive(P6_Necro_BoneArmor, P6_ItemPassive_Unique_Ring_066) => get P6_ItemPassive_Unique_Ring_066 state with P6_Necro_BoneArmor bucket
  • BuffTimeLeft(P6_Necro_BoneArmor, P6_ItemPassive_Unique_Ring_066) < 1000 => if Nayr's buff attached to bone armor will expire in less that a second

Not supported yet

  • Pets
  • Querying the selected monster (e.g. SelectedMonster_IsBuffActive(), SelectedMonster_BuffStackCount(), SelectedMonster_BuffTimeLeft())

ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Testing custom conditions

It is necessary to test custom conditions in the conditional window of the bot before copying it to the custom condition field of an action. The conditional window can be accessed via the Tools/Conditional menu.

Using custom conditions in a script

If a custom condition works fine in the test field of the conditional window, it can be safely copied to the custom condition field of an action.

ci-uqkeUdWQQIx6OFYm9BPQylSwuKJsMcUtarMLC

Custom condition examples

Probably the most descriptive and powerfull part of this documentation

A few conditions of interest

  • Checks if the player is not in town: 

!IsBuffActive(0, ActorInTownBuff)

  • Checks if the invulnerability buff is active which is usually present at the beginning of a new level and which disappears after a keystroke or mouse click: 

IsBuffActive(0, ActorInvulBuff)

  • Checks if the player is busy casting a town portal or interacting with a Triune Monument, a captured Iron Wolf, an iron cage of a Prisoner of the Cult, a Stonefort catapult, a Demon Gate, or a Bone Cage

IsBuffActive(0, UseStoneOfRecall) | IsBuffActive(0, Axe_Operate_Gizmo)

  • Checks if the player doesn't have any weapons equipped

IsBuffActive(0, BareHandedPassive)

  • Checks if the Empowered Shrine buff is active

IsBuffActive(0, Shrine_Desecrated_Reloaded)

  • Checks if the Channeling Pylon buff is active

IsBuffActive(0, Pages_Buff_Infinite_Casting)

  • Checks if any skill (incl. the potion) is currently on cooldown

IsBuffActive(0, Cooldown)

  • Checks if at least 3 skills are on cooldown

BuffStackCount(0, Cooldown) >= 3

  • Checks if a DH build uses the Awareness passive skill

IsBuffActive(0, X1_DemonHunter_Passive_Awareness)

  • Checks if the Awareness passive skill of a DH is proc'ed

IsBuffActive(1, X1_DemonHunter_Passive_Awareness)

  • Checks if the player is affected by the Oculus ring buff

IsBuffActive(2, ItemPassive_Unique_Ring_922_x1)

  • Checks if the Focus ring buff will expire in less than one second

BuffTimeLeft(1, ItemPassive_Unique_Ring_735_x1) < 1000

  • Checks if the Focus ring is equipped and if the Focus buff will expire in less than one second

IsBuffActive(0, ItemPassive_Unique_Ring_735_x1) & (BuffTimeLeft(1, ItemPassive_Unique_Ring_735_x1) < 1000)

  • Checks if the Momentum buff of the Gears of Dreadlands set is less than 17

BuffStackCount(10, P69_ItemPassive_Unique_Ring_010) < 17

  • Checks if dashing strike charges count is equal or greater than 1

ChargeCount(X1_Monk_DashingStrike) >= 1

 

Convention of Elements

Power name: P2_ItemPassive_Unique_Ring_038
The sequence of elements w.r.t. their bucket number is as follows:

  1. Arcane
  2. Cold
  3. Fire
  4. Holy
  5. Lightning
  6. Physical
  7. Poison

The relevant Conditional Function to use is 

BuffTimeLeft( element, P2_ItemPassive_Unique_Ring_038 )

Note: result ranges from 0 to 4000 ms

This can be used to determine "if it is in that elemental cycle" or "how much time left in that cycle".
Assume you are botting a LON Thorn Sader. You want to cast all the buff skills during Lightning COE Cycle: 

BuffTimeLeft( 5, P2_ItemPassive_Unique_Ring_038) > 2000

And cast Bombardement at the very last second such that it will all fall down during the next Cycle (Physical): 

BuffTimeLeft( 5, P2_ItemPassive_Unique_Ring_038) > 0 & BuffTimeLeft( 5, P2_ItemPassive_Unique_Ring_038) < 1000

Nayr Black Death

Power name: P6_ItemPassive_Unique_Ring_066
One can equip a maximum of 6 skills on the skillbar, for a maximum of 6 Nayr stack buffs.
The game assigns a buff timer accessible through

BuffTimeLeft(bucket, P6_ItemPassive_Unique_Ring_066)

where bucket (1~6) is the slot in which to check for the buff. The bot provides a shortcut wherein the skill slot of any given skill can be auto-detected

To check if Death Nova's buff for Nayr is still active: 

BuffTimeLeft(P6_Necro_BloodNova, P6_ItemPassive_Unique_Ring_066) > 0

To check if Death Nova's buff for Nayr is about to expire: 

BuffTimeLeft(P6_Necro_BloodNova, P6_ItemPassive_Unique_Ring_066) < 1000

Optimally, one would want to cast all the Nayr Buffs during Physical Cycle: 

BuffTimeLeft(6, P2_ItemPassive_Unique_Ring_038) > 0 & BuffTimeLeft(P6_Necro_BloodNova, P6_ItemPassive_Unique_Ring_066) < 8000

Taeguk gem

Checks if the Taeguk gem is equipped and has 10 stacks: 

IsBuffActive(0, ItemPassive_Unique_Gem_015_x1) & BuffStackCount(1, ItemPassive_Unique_Gem_015_x1) == 10

DevOPS
Joined: 08/11/2019 - 05:04
Fri, 03/05/2021 - 20:07

Very interesting :)


luoxu
Joined: 11/25/2019 - 01:19
Sat, 03/06/2021 - 06:19

已阅


zhangyilinzyl
Joined: 07/10/2020 - 07:38
Sun, 03/07/2021 - 21:31

seems interesting


elleluinous
Joined: 04/15/2018 - 11:22
Sun, 03/07/2021 - 23:15

你们上


bnuhenry
Joined: 06/03/2018 - 05:25
Mon, 03/08/2021 - 22:27

硬吹思婷,in English, means INTERESTING,这种用法太底层了,你们需要开发对用户友好的界面,in English, the way to set these conditions seems too complicated, move one step foward to develop selector which including skill pickers or number inputer can make us understand easier, well, lot of work


diabot
Joined: 01/02/2016 - 08:38
Tue, 03/09/2021 - 13:13

If you do not have a software development background, then custom conditions might be a bit hard to swallow. However, there is the above guide available which explains the concept, and there is Discord where you can ask questions.

Since the main purpose of custom conditions is to allow a more fine-grained control over when the bot is casting skills and since the infos to decide when to cast a skill have to come from somewhere, working with custom conditions will always be more complicated than using actions only. The main topic is how to do that in context of a script.
D3Helper was following a more GUI centered approach, whereas RB models conditions via textual expressions. Instead of only connecting all terms via logical AND (like D3H does), RB supports boolean AND, OR, NOT, and brackets. This helps to simplify the expressions significantly and avoids having many condition in one skill which are almost identical (in D3H, there usually is an overlap in the condition groups which belong to a skill). I clearly prefer RB's implementation of conditions over D3H.

What could be improved in RB is the dump functionality. Instead of outputting all PowerSNOs via Notepad, RB should have a dedicated window similar to D3H where changes are highlighted. That would make it much easier to identify the relevant PowerSNOs.


varimon
DONATOR
Joined: 01/01/2015 - 19:52
Wed, 03/10/2021 - 11:40

this isnt that hard you scrubs. using the example you can get started quite easily. works great for Band of Might buff. I've already removed all the redundancy i had built in just to keep him alive


vigd
DONATOR
Joined: 06/04/2014 - 09:01
Mon, 03/15/2021 - 22:53

@diabot just remember that less than ~50 people have d3helper so 99.999% of people will have no idea what any of that means


Need Support? Discord here. Need Scripts? here. Like my content? Support me here.

diabot
Joined: 01/02/2016 - 08:38
Tue, 03/16/2021 - 06:25

Until D3 switched to 64-bit only (in 2018 or so), D3H was publically available and quite popular, see https://d3helper.freeforums.net. I guess that lots of people still remember it.


zhzhyhxl
Joined: 03/20/2018 - 02:19
Wed, 03/17/2021 - 08:14

Hollow ComMan.
Can u ask or maybe pay someone to translate the guide into Chinese?


zhzhyhxl
Joined: 03/20/2018 - 02:19
Wed, 03/17/2021 - 08:16

他娘的憋半天有没有语法错误兄弟们?


scc99991
Joined: 03/23/2018 - 10:11
Thu, 04/08/2021 - 02:26

so,can u translate it into chinese?


Advertisements

Advertisements