Data/Behaviors/Veterancy

## Veterancy

(Editor Screenshot) needs pic of some hero with levels

### Description

The behavior that allows units to gain levels and associated benefits from experience gained through abilities, triggered quest rewards, dealing/taking damage or killing units. On level up points can be awarded to Learn abilities for use in upgrading abilities.

### Hint

* If you want your unit to get stronger if it kills a lot of stuff or want to make a hero you need this.
* Gaining experience fills the veterancy behavior itself. Enabling it after it was disabled will already show the exp gained, as the behavior could gather XP while disabled.
* Modify unit effect can only modify the XP of 1 veterancy behavior at the time (and only the first indexed one if no Veterancy is specified), while killing units boosts all veterancy behaviors together.
* A veterancy behavior can pop the level up events from actors, even when disabled (including Show the part from requirement). In summary, the role of the veterancy behavior is simply to monitor the unit's current experience, and boost the chosen stats accordingly.
* The Show part of a requirement is very important, since it works exclusively for hiding or not the XP bar. Apparently, it also prevents the stats from being given. A secondary hidden Veterancy behavior could compensate for that issue, which seems to be a bug.
* Damage received/dealt component of this behavior are relevant, as they can cross the line of a dying unit. For example, if you kill a Zergling 35 life with an attacking dealing 700 damage, the extra 665 damage is still accounted into XP.
* 2 Minimal conditions to have a Veterancy Behavior work:
	1. In triggers "Enable/Disable Mlee Option For Player" must disable the **XP Gain Disabled** option OR have the **Grant Level Kill XP** unit flag enabled on each unit that can give exp to this behavior. In that sense, veterancy behaviors are considered as receivers while the killed unit is the giver. Take note that the trigger way requires a 2 second delay after game's initialization in order to work properly.
	2. In data, in the Advanced Gama Data Table, there is the **Gameplay Data** Tab. The Default SC2 Gameplay Settings should appear. Set the Veterancy Search Radius and the Search Filters to match with the needs of the mod. If only a single unit can gain exp, set those values to nothing.
* There is a glitch (perhaps lack of content) that may break the veterancy XP gained from damage dealt. It would seem that a Veterancy behavior cannot scale XP to the real damage dealt, even if the damage of that effect is caped. For example, your unit has an effect-target ability with an effect dealing 10,000 damage, while its "Maximum" field is set at "1" (clamps the damage to 1), the veterancy will still give XP worth 10,000 damage, even if the target unit only received 1 damage in the end. This is also true for damage duplication such as Damage Inherit effect from Damage effects or Attack Modifier behaviors.

## Fields Description

### None - Level

Set the max level of a hero.

* This field is also upgradable, which allows modders to change max ability levels at runtime.
* This field defaults to 0, which will fallback the level system to how it worked before.

### None - Min Veterancy XP Bonus Per Level

* If the size of the VeterancyLevelArray is smaller than the number in the Levels field, the game will automatically generate the “min XP” of the extra levels based on these factors.
* The formula used is as follows where X is the level and F(X) is the min XP of the level:
	+ F(X) = F(X-1) \* MinVeterancyXPPreviousValueFactor + MinVeterancyXPLevelFactor \* X + MinVeterancyXPBonusPerLevel
* This is only used when the Level X is greater than the size of VeterancyLevelArray. Otherwise, it will directly grab the min XP from the VeterancyLevelArray table.

### None - XP Receive Fraction

This field is a Structure Array, which allows users to specify a target filter and an accumulate-able fraction value for each array.

* Whenever a hero receives XP, the game will check the target filters on the victim unit and apply the XP fraction if the victim matches any of the filters.
* Combined with the Accumulators, users will be able to easily create XP formulas such as “summoned units grant half XP” or “Heroes gain reduced XP from creeps based on the current level of the Hero”.

### Ability - Veterancy Flags

* **Combine Experience:** makes the amount of experience in the Behavior - Veterancy Levels - Minimum Experience field required to reach the next level add onto the combined amount of all previous levels. This allows for easier calibration of an experience curve
* **Combine Experience:** (to be completed)
* **Combine Numeric Modifications:** makes all numbers in various fields gained by levels stack with others from the same field
* **Global:** (to be completed)
* **Max Level Leech:** means that all experience gained by this unit when max level is shared among valid targets

### Behavior - Alignment

* Determines the colour of the UI - Icon
* Negative colours the icon red
* Neutral leaves the icon unaltered
* Positive colours the icon green

### Behavior - Categories

* Permanent
* Restorable
* Temporary
* These are Filters, used kind of like Unit Attributes. Used by Behavior - Modification - Behavior Categories Disabled/Enabled fields of other behaviours.

### Behavior - Experience Fraction

* Determines the amount of experience gained based on experience source
* Damage Dealt is the fraction of experience gained by dealing damage (also affected by the Behavior - Damage Dealt (Veterancy) field of the Units data type)
* Damage Taken is the fraction of expperience gained by taking damage (also affected by the Behavior - Damage Dealt (Veterancy) field of the Units data type)
* Kills is the amount of experience gained by killing units (Affected by the Combat - Kill experience field of the Units data type)
* Can be negative numbers so it is possible to lose experience

### Behavior - Requirements

* Requirements from the Requirements data type that disable the behaviour if they return false

### Behavior - Share Filters

* The filters for determining what other units with the Veterancy behaviour can share experience gained by the owner of this behaviour

### Behavior - Target Filters

* Filters for determining what attributes of units attacking or being attacked by the owner of this behaviour give experience

### **Behavior - Veterancy Levels - Modification**

Since most modification fields are the same as Buff behavior (and attribute), we'll encover only the fields that are unique to the veterancy

* The importance is to understand that once a Level is acquired, its bonuses stack with further level(s) modification charts.
* These following fields are part of the "Behavior" category and are present on each sub-chart (such as None, Ability, Movement, Behavior, Combat, etc).
* There is a subtle section aside from Behavior which is named "None" (non-related to the "none" sub-chart) which only has one mofication. See at the bottom.

#### Level

Represents each modification chart (such as buff) related to the level.

* You need level 0 to start off completing the level 1. That being said, one can modify the Minimum experience to 0 to remove levels starting by level 0.

#### Info Icon

* The Icon texture meant to be shown at each level of veterancy
* (Not Sure) if it is able to be seen since it does not appear with attributes included

#### Level Gain Effect

As the same makes this field pretty obvious, it is unfortunatly broken and has no effect.

#### Level Loss Effect

As the previous field, this one is broken as well and has no effect.

#### Minimum Experience

* The amount of extra experience needed to reach the next level
* If the Combine Experience flag is enabled then the experience amount is added onto that of the previous levels.
* A total of 524,287 experience is the maximum able to be reached without overflowing.

### [None Chart]

#### Rank Name Shema

Text string that will replace the bar level's text which is usually Level 0, Level 1, etc.

* The level that has this string modified will only have it applied after reaching a further level.

## Related

* Learn
* Abilities
* Behaviors
* Buff Behavior
* Attribute
* Effects
* Units
* Weapons