I recommend reading my Basic Skill first because it will provide some additional background about skill building.
This post will be a brief look at the basic elements of a Passive skill. Like the discussion of Elemental Boon prior to this, I will focus on existing skills.
Passive skills in TL2 traditionally have the following characteristics:
- They don't have tiers
- They activate “automatically”
There are a few different types of Passive skills. While there are no hard and fast ways to categorize them, from a code perspective they can mostly be broken down into the following major categories:
- Mastery Skills: These simply provide a bonus to a global stat. Among the easiest types to set up and maintain.
- Callback Skills: These skills implement a conditional callback to another skill. Based on Triggers or on Cast Skill On affixes.
- Stat-Based Skills: These set up a custom stat. Difficulty varies considerably.
- Pulsing Skills: Rare but they do exist. Main example is Embermage Elemental Attunement.
This post will focus on Mastery Skills first. The skill we'll look at is Dodge Mastery from the Outlander. Here's its in-game text:
Basically, this skill grants a base 4% chance to Dodge. Each additional rank then adds another 2% chance to dodge.
Let's start by looking at the skill's core code:
<STRING>NAME:Dodge Mastery <TRANSLATE>DISPLAYNAME:Dodge Mastery <TRANSLATE>BASE_DESCRIPTION:Your acrobatic training increases your odds of dodging a blow. <STRING>SKILL_ICON:skillicon_dodgemastery <STRING>SKILL_ICON_INACTIVE:skillicon_dodgemastery_gray <STRING>ACTIVATION_TYPE:PASSIVE <STRING>TARGET_TYPE:SELF <FLOAT>RANDOMRANGE:0 <FLOAT>TURNRATEOVERRIDE:-1 <STRING>REQUIREMENT_GRAPH:SKILLTIER1_PASSIVE <BOOL>SHOW_IN_BUFFLIST:0 <BOOL>CAN_BE_SILENCED:0 <INTEGER>LEVEL_REQUIRED:0 <INTEGER>MAXLEVEL:15 <INTEGER64>UNIQUE_GUID:5943168319702415288
If you've read the post about Active skills, most of this should already be familiar. Note a few changed features though. There is no Animation, because Passives don't use them. The ACTIVATION_TYPE is set to PASSIVE instead of NORMAL. This tells TL2 not to create a button for the player to press, and also forces this skill to activate the moment the player appears in game. There are other conditions that will force a Passive skill to re-apply itself. For example, changing gear or entering a new zone. SHOW_IN_BUFFLIST:0 hides the Dodge Mastery icon from showing up in the players buff bar, where it would show up all the time because this skill has no conditions.
Next up, take a look at the skill levels.
[LEVEL1] <FLOAT>RANDOMRANGE:0 [EVENT_START] [AFFIXES] <INTEGER>AFFIXLEVEL:2 <STRING>TARGET:SELF <STRING>AFFIX:WANDERER_DODGE_MASTERY [/AFFIXES] [/EVENT_START] [EVENT_END] [AFFIXESREMOVE] <STRING>TARGET:SELF <INTEGER>AFFIXLEVEL:2 <STRING>AFFIX:WANDERER_DODGE_MASTERY [/AFFIXESREMOVE] [/EVENT_END] [/LEVEL1]
Here we have an EVENT_START and EVENT_END. - EVENT_START is normally called when the Passive activates. This means: after taking a new rank, after zoning into a new area, after changing gear, and a few other possibilities. EVENT_START is where you will put any code associated with applying the passive to the player. - EVENT_END is called when the passive is removed. This means mainly: after taking a new rank (the current rank's EVENT_END is called prior to the new rank's EVENT_START), after respeccing.
(NOTE: There is no EVENT_TRIGGER here, unlike the last skill we looked at. EVENT_TRIGGER is normally called from the skills animation, and Passives don't (normally) have Animations. If we put an EVENT_TRIGGER here instead of EVENT_START nothing would happen, but TL2 would still show description in the preview text as if it would. It's a pretty common error to mix up EVENT_START and EVENT_TRIGGER so be sure to pay attention to which one you are using.)
In terms of the skill code itself, what we have is relatively straight forward. The EVENT_START applies an affix called WANDERER_DODGE_MASTERY. The EVENT_END removes it. Simple and clean. You may be wondering what the <INTEGER>AFFIXLEVEL:2 means. Let's take a look at the actual affix to see.
(NOTE: You can view and edit Affixes either from the Affix editor or edit the text files directly. Here I've chosen to show the text file version).
<STRING>NAME:WANDERER_DODGE_MASTERY <INTEGER>RANK:0 <INTEGER>MIN_SPAWN_RANGE:0 <INTEGER>MAX_SPAWN_RANGE:999 <FLOAT>DURATION:0 <INTEGER>WEIGHT:0 <INTEGER>SLOTS_OCCUPY:0 [EFFECT] <STRING>ACTIVATION:PASSIVE <STRING>DURATION:ALWAYS <STRING>TYPE:DODGE CHANCE BONUS <STRING>GRAPHOVERRIDE:MASTERY_GRAPH <FLOAT>MIN:50 <FLOAT>MAX:50 [/EFFECT]
The keys to understanding this affix are: - The ACTIVATION is set to PASSIVE (as opposed to DYNAMIC or TRANSFER). - <STRING>DURATION:ALWAYS means the affix lasts indefinitely once applied. If we want to remove it later, we have to do so explicitly (hence the [AFFIXESREMOVE] object in EVENT_END the code we just looked at.)* - DODGE CHANCE BONUS is the type of effect we're applying. - <STRING>GRAPHOVERRIDE:MASTERY_GRAPH is a reference to a graph object. When a Graph is set by an affix, TL2 uses the graph to determine the value of the affix. The value of X on the graph is based on the AFFIXLEVEL of the AFFIXES object that set up the Affix. (In this case, it was <INTEGER>AFFIXLEVEL:2). Y is the final amount used for the affix.
*(A DURATION of “ALWAYS” on a PASSIVE Effect means “forever until removed.” A DURATION of “ALWAYS” on a DYNAMIC Effect seems to mean “for the duration of this Affix, as specified in the <FLOAT>DURATION at the Affix level.”)
Take a look at the MASTERY GRAPH (you can see it by opening the graphs editor).
We can see that on the base MASTERY GRAPH, each point X results in 4 points Y.
There's one more thing we need to look at. What do these two settings on the affix do?
Min and Max change functions depending on whether a Graph is set. If no graph is set, Min and Max are the exact values to use–they don't change. But since we have a graph set, Min and Max instead function as percentages. So, in this case, they mean “50% of the Y value on the graph.” Or, in other words, a bonus of 2$ Dodge per rank instead of 4%.
(Bonus: You may have noticed that rank 1 of this power grants 4% Dodge where all other ranks grant 2%. This bit of trickery is easy to understand: Level 1 of Dodge Mastery actually uses a <INTEGER>AFFIXLEVEL:2. Every level after this just increases the level by 1. TL2 doesn't care what the “real” level of the spell is, only the value you pass in the AFFIXLEVEL. You could specify an AFFIXLEVEL of 999 and (as long as the graph stretched that far) TL2 would process it just like it was level 999 of the skill.)
Continue the Walkthrough with Passive Skill: Wand Chaos