# The Define Tag

The DEFINE tag is used to create new variables and set their initial values. In addition to the entry for the tag itself this page will go into the details of using variables, formulas and math operators.

Tag Name: DEFINE:x|y

Variables Used (x): Text (Name of variable)

Variables Used (y): Number or Formula (Can be a formula involving pre-defined variables, numbers, operators and user-defined-variables.)

What it does:

- Creates a new variable with the name specified and sets its initial value to the number or formula given.
- Many classes use PREVAR tags, which are pre-requisites based upon variable values.
- These values are calculated by getting the value of the variable with the highest DEFINE value, and then adding any BONUS: tags which apply to it.
- For example, if a class had PREVARGT:Hopscotch,3 would mean that the character only qualifies for the class if they have a Hopscotch value higher than 3 (GT = Greater Than).
- PCGen scans the characters race, templates, classes, feats, skills, deity, domains and equipped items for DEFINE: tags that match this variable name.
- If it finds more than one, it keeps the one with the higher value.
- PCGen then scans the same list of items and looks for those with BONUS:VAR|Hopscotch tags and after figuring out which ones stack, adds those to the highest define value.
- The resulting value is then compared to the PREVARGT's requirement, which is 3 in this case, and PCGen then indicates if the character meets this requirement or not.
- BONUS:VAR tags which reference variables which have not been DEFINEd have no effect and the value of that variable will effectively remain at 0.
- The standard use of DEFINE in PCGen release files is to use only one DEFINE per variable and to initially set the value at 0 and ajust it with BONUS:VAR tags as needed.

Example:

`DEFINE:MonkeyChop|2`

Creates a new variable named MonkeyChop and sets the initial value to 2.

`DEFINE:MonkeySwing|TL/2`

Creates a new variable named MonkeySwing and sets the initial value to half the characters total level.

## Variables

For those unfamiliar with computer programming or higher math a variable is a symbol which represents a quantity that is not fixed. Most peoples first introduction to variables is in algebra where you might be given a problem such as x+y=z. This is a formula, the x,y and z are variables. PCGen uses variables and formulas for a wide variety of purposes through out the program, some are created in LST files while others are pre-defined, that is they are hard coded and can be used in any formula in any LST file in any game mode. Pre-defined variables are listed below.

Variable Names:

- You can create variable names any way you like - but we recommend using no spaces and a name that is both descriptive and unlikely to conflict with a variable name used in another source for a different purpose. Capitalizing the first letter of each word used in the variable name makes it more readable and more easily identified as a variable. Using all caps to name a variable should be reserved for pre-defined variables that are hard-coded.
- Sometimes the same variable name will be used in different sources if they work together (this happens when one class is based on a class from a different source).
- Certain variables are pre-defined, be careful not to use any of those names when creating your variables.

## Pre-defined Variables

`ACCHECK`

This is the total AC Check penalty from armor and shield.

`ARMORACCHECK`

This is the total AC Check penalty from armor.

`BAB`

For classes which have O (for Other) as their BAB progression, you can use a formula for their BAB progression. e.g. DEFINE:BAB|2*CL would be +2 per class-level.

`BASESPELLSTAT`

This is the mod for the class's base spell stat.

`BL=name`

This will return the Bonus Spellcaster Levels to the class specified, which usually come from Prestige classes. For example, lets say you have 2 levels Mystic Theurge which add to both your Cleric and Wizard levels, 3 levels of Archmage which add to your Wizard level, and 1 level of Loremaster which adds to your Cleric level. BL=Wizard would return 5 and BL=Cleric would return 3. Replace { with ( and } with ). e.g. BL=Cleric {Special} would return the bonus levels of Cleric (Special) since ( and ) have other meanings in DEFINE variables. If used within a JEP formula you will need to enclose it in a variable function e.g. var("BL=Cleric {Special}")

`CASTERLEVEL`

CASTERLEVEL is a special variable for use within some Spell tags. See the CASTERLEVEL tag entry on the Spell tag page.

`CHA`

This is the character's CHA modifier.

`CHASCORE`

This is the character's actual Charisma score.

`CON`

This is the character's CON modifier.

`CONSCORE`

This is the character's actual Constitution score.

`COUNT[CLASSES]`

This is the character's number of classes.

`COUNT[DOMAINS]`

This is the character's number of domains.

`COUNT[FEATNAME=name]`

This is the number of feats of the given name. Great for multiple feats that grant bonuses based on the number of times taken.

`COUNT[FEATS]`

This is the character's number of optionally chosen feats (not automatic or virtual).

`COUNT[FEATSALL]`

This is the character's total number of feats (includes automatic and virtual).

`COUNT[FEATTYPE=type]`

This is the character's number of feats matching specified type.

`COUNT[FOLLOWERS]`

This is the character's number of Followers.

`COUNT[LANGUAGES]`

This is the character's number of languages.

`COUNT[SA]`

This is the character's number of unique special abilities.

`COUNT[SKILLS]`

This is the character's number of skills.

`COUNT[SPELLCLASSES]`

This is the character's number of spellcasting classes.

`COUNT[STATS]`

This is the number of defined stats.

`CL`

Class Level of this class.

`CL=name`

Class Level of the named class.

`CLASS=name`

Returns a 1 if the character has the named class, otherwise 0. Replace { with ( and } with ). e.g. CLASS=Ranger {Special} would check for Ranger (Special) since ( and ) have other meanings in DEFINE variables. If used within a JEP formula you will need to enclose it in a variable function e.g. var("CLASS=Ranger {Special}")

`CLASSLEVEL=name`

Class Level of the named class, replacing ( with { and ) with }. e.g. CLASSLEVEL=Warrior {Ruby} would return the level of Warrior (Ruby) since ( and ) have other meanings in DEFINE variables. If used within a JEP formula you will need to enclose it in a variable function e.g. var("CLASSLEVEL=Warrior {Ruby}")

`DEX`

This is the character's DEX modifier.

`DEXSCORE`

This is the character's actual Dexterity score.

`ENCUMBERANCE`

This is a value representing the character's current encumbrance level (0=Light, 1=Medium 2=Heavy, 3=Over-Loaded).

`GRAPPLESIZEMOD`

This is the character's Grappling Size Mod.

`HASDEITY:`

This returns 1 if the character has the named deity, otherwise 0.

`HASFEAT:`

This returns 1 if the character has the named feat, otherwise 0.

`HD`

This is the character's HD (Starting HD or Monster HD. Not HD from classes).

`HIDESIZEMOD`

This is the character's Hide Size Mod.

`INT`

This is the character's INT modifier.

`INTSCORE`

This is the character's actual Intelligence score.

`MOVEBASE`

This is the character's racial-based movement.

`SHIELDACCHECK`

This is the total AC Check penalty from shields.

`SIZE`

This is a value representing the character's current size. Fine=0, Diminutive=1, Tiny=2, Small=3, Medium=4, Large=5, Huge=6, Gargantuan=7, Colossal=8.

`SIZEMOD`

This is the modifier for the character's current size.

`SKILLRANK=name`

This is the character's Ranks in the named skill replacing ( with { and ) with }. e.g. SKILLRANK=Craft {Woodworking} would return the ranks of Craft (Woodworking) since ( and ) have other meanings in DEFINE variables. If used within a JEP formula you will need to enclose it in a variable function e.g. var("SKILLRANK=Craft {Woodworking}")

`SKILLTOTAL=name`

This is the character's total in the named skill replacing ( with { and ) with }. e.g. SKILLTOTAL=Craft {Woodworking} would return the total of Craft (Woodworking) since ( and ) have other meanings in DEFINE variables. If used within a JEP formula you will need to enclose it in a variable function e.g. var("SKILLTOTAL=Craft {Woodworking}")

`SPELLLEVEL`

This is a global variable that is set by the spell's level.

`STR`

This is the character's STR modifier.

`STRSCORE`

This is the character's actual Strength score.

`TL`

Total Level of character.

`VARDEFINED:`

This returns 1 if the character has the named variable, otherwise 0.

`WEIGHT.CARRIED`

is the weight of all carried equipment.

`WEIGHT.EQUIPPED`

is the weight of all equipped items.

`WEIGHT.PC`

is the weight of the PC.

`WEIGHT.TOTAL`

is the weight of all carried items and PC.

`WIS`

This is the character's WIS modifier.

`WISSCORE`

This is the character's actual Wisdom score.

## Math Operators and Formulas

Note: This information has been moved to the Math Operators and Formulas page.