Data/Requirements

## Introduction

* Requirements are sets of conditions that you can set to restrict the use or visibility of an ability, behavior, validator or command card button, these conditions include but are not limited to behaviors being set, abilities being enabled and upgrades being researched.
* Requirements can be constructed as a tree or as an expression, for beginners the tree view is recommended.

## Use & Show

### Use

* Requirement nodes under the **Use** branch of the requirement tree must return true for abilities to be used even if not visible in the command card, for behaviors to be enabled and for **Player Requirement** validators to return true

### Show

* Requirement nodes under the **Show** branch of the requirement tree must return true for abilities with a **Restricted** button state to appear in the command card.
* Often used by **Research** abilities to hide upgrade buttons once queued.
* Note that abilities can still be used by triggers and **Issue Order** effects even if they are not visible so it is advisable to also disable use of the ability via a duplicate requirement branch under **Use**.

## Format of Nodes

* Type: The type of node the specific node has been set to
* Alias: The name of the ability/behavior/unit/upgrade to be queried
	+ Can use **Tech Alias** values to refer to groups of units but needs to be entered in under **Expression** view
* State: The status of the alias subject required for the node to count it
	+ **Completed:** Counts the number of the alias active on the map at the current time
	+ **Completed at Unit:** Counts the number of the alias active on the map at the current time belonging to the unit querying with this requirement
	+ **In Progress:** Counts the number of the alias active on the map but are not yet completed
	+ **In Progress at Unit:** Counts the number of the alias active on the map but are not yet completed belonging to the unit querying with this requirement
	+ **In Progress or Better:** Counts the number of the alias active on the map but are not yet completed and those that are
	+ **In Progress or Better at Unit:** Counts the number of the alias active on the map but are not yet completed and those that are belonging to the unit querying with this requirement
	+ **Kills:** Counts the number of the alias killed by the player
	+ **Killed:** Counts the number of units killed by the alias belonging to the player
	+ **Peak:** Counts the maximum number of the alias that was owned by the player even if that number is no longer being reached
	+ **Queued:** Counts the number of the alias queued but not yet completed
	+ **Queued at Unit:** Counts the number of the alias queued but not yet completed belonging to the unit querying with this requirement
	+ **Queued or Better:** Counts the number of the alias queued but not yet completed and those that are
	+ **Queued or Better at Unit:** Counts the number of the alias queued but not yet completed and those that are belonging to the unit querying with this requirement
	+ **Queued Or Better Or Revivable:** When counting tech units, this will include reviving and revivable heroes. This is very useful when implementing hero training restrictions. For example, if you have the restriction, “You cannot train more than 3 heroes”, you probably don’t want to only count living heroes.
	+ **Total:** Counts the combined number of the alias to have existed under control of the player
* Value: Numerical value or slot integer to be counted

## Node Types

### Ability Allowed

* Terminal node
* Related to Triggers "Allow" action.

### And

* Logic node
* Requires all nodes under it to return true for it to return true

### Behavior Allowed

* Terminal node
* Related to Triggers "Allow" action.

### Can be Supressed

* Use: Allows the **Use** section to be ignored by any behavior with the "Suppress Requirements" State Flag on (as long as the behavior remains on the unit dealing with the requirement)
* Show: Allows the **Show** section to be ignored by any behavior with the "Suppress Requirements" State Flag on (as long as the behavior remains on the unit dealing with the requirement)

### Constant

* Terminal node
* Numeric value for use in maths functions and comparing the counts of other nodes against

### Count Ability

* Terminal node
* Counts the current level of an ability
* The first level counts as 0

### Count Behavior

* Terminal node
* Counts the number of behavior stacks on the unit
	+ There is a problematic when using "Completed at unit". As it is unclear if this is a bug or intented by Blizzard, using the Completed at unit will work different in some cases:
		1. Using only X Behavior Completed at unit will cause the requirement to return true if the behavior is "present" on the unit or not. This means, even if disabled, the requirement will return true (this seems false if the behavior is disabled by another buff disabling it, so it only concerns the said behavior's requirement).
		2. Using an operator ""Equals" or ""Greater" or "Less" or etc., with X Behavior Completed at unit and a constant, will determine the amount of active stacks of the behavior. This means that a stack requires the behavior to be enabled in order to be considered "active". Another way to put it, is that this will cause the behavior to be true if enabled (if using for example the "Greater or Equals than" Constant 1),

### Count Unit

* Terminal node
* Counts the number of units owned by a player

### Count Upgrade

* Terminal node
* Counts the level of upgrades researched

### Division

* Maths node
* Divides the numeric value of the upper node under it by the lower nodes under it

### Equals

* Logic node
* Returns true if the numeric value of both nodes under it are the same

### Exclusive Or

* Logic node
* Returns true if either of the two nodes under it return true but returns false if neither or both return true

### Greater Than

* Logic node
* Returns true if the numeric value of the upper node under it is greater than the lower node under it

### Greater Than Or Equal To

* Logic node
* Returns true if the numeric value of the upper node under it is greater than or equals the lower node under it

### Less Than

* Logic node
* Returns true if the numeric value of the upper node under it is less than the lower node under it

### Less Than Or Equal To

* Logic node
* Returns true if the numeric value of the upper node under it is less than or equals the lower node under it

### Modulus

* Maths node
* Gives the remainder of the numeric value of the upper node under it divided by the lower node under it
* Example: Upper node has a value of 7 while the lower node has a value of 2 would return a value of 1 while if the lower node had a value of 4 it would return a value of 3
* http://en.wikipedia.org/wiki/Modulo\_operation

### Multiplication

* Maths node
* Multiplies the numeric values of all nodes under it

### Not

* Logic node
* Returns true only if the node under it returns false

### Not Equal To

* Logic node
* Returns true if the numeric values of both nodes under it are not equal to each other

### Odd Number

* Logic node
* Returns true if the numeric value of the node under it returns a value that is odd
* For even numbers combine with a **Not** node

### Or

* Logic node
* Returns true if any of the nodes under it returns true

### Sum

* Maths node
* Adds the numeric values of all nodes beneath it together

### Unit Allowed

* Terminal node
* Related to Triggers "Allow" action.

### Upgrade Allowed

* Terminal node
* Related to Triggers "Allow" action.

## Constructing requirement trees

* New nodes can be added by right clicking the **Use** folder, the **Show** folder or a previous node that you want to place the new node under and clicking the **Add Requirement Node** button. Some node types have limits as to how many nodes you can have under them.
* Logic and maths nodes work by comparing the upper node to the lower node.
* Start the requirement with And, Or and Not nodes followed by comparative logic nodes. Under the comparative logic nodes use maths nodes to apply weighting to the values of your terminal nodes. Use the terminal nodes to count what you want the requirement to count and use constants to compare against or add weighting as needed
* There is no subtraction node so you need to add the amount you would have subtracted to the other side of the logic function (a+c=b is the same as a=b-c)