Skip to content

๐Ÿ“š Variables โ€‹

When provided mechanics do not provide enough configurability you can always use variables to recode some more complex script. Variables can be used to store temporary data or even do complex numeric or vector computations for advanced particle effects for instance.

Internal & Custom Variables โ€‹

There are two types of variables. First, internal variables or reserved variables have names which are reserved by MythicLib. They are used all of the time by MythicLib, and you cannot create custom variables with reserved variables names. You can access these variables using <caster> or <targetLocation> for instance.

VariableTypeUsage
sourcepositionLocation where the script was cast
targetLocationpositionThe target location if it exists
casterplayerPlayer who cast the script
attackattackMetadataThe attack which triggered the skill if it exists
statstatMapThe stat map of the caster BY THE TIME he cast the script
targetentityThe skill target if it exists
randomrandomAn extra module to generate random numbers. See below

On the other hand, custom variables are initialized and can be manipulated by the user. You can access them using <var.your_variable_name>, use them in numeric formulas or just like PAPI placeholders in any mechanic or condition. MythicLib comes with many mechanics that let you initialize and edit your custom variables. The full list is available here.

You cannot use a

Scopes โ€‹

Custom variables have scopes. This feature is very important since it determines if the variable is specific to the player, if it should be accessible by any player and if it should be saved when a script eventually runs its last mechanic.

Internal variables don't need scopes.

There are three variables scopes available:

  • SERVER (a server variable is the same for all players and all scripts)
  • PLAYER (a player variable is the same for all scripts ran by a specific player)
  • SKILL (the default scope. A skill/script variable will be lost when the script runs its last mechanic).

You only need to provide the scope of your variable when editing or initializing it. When fetching the value of a custom variable using <var.custom_var_name>, there might be multiple variables with the same name but different scopes (one per scope, at most). In this case, priority is SKILL > PLAYER > SERVER (lowest scopes first).

Types โ€‹

Variables are typed: <source> is a location (where the script is ran from) whereas <target> is an entity (the skill target, if it exists). Variables also have subvariables: for instance, you can access the location of an entity using <entity_variable.location> which has the effect of transforming an entity variable into a location variable.

A subvariable is also a variable which means you can use multiple dots to access subvariables of subvariables etc. to get the data wanted: <caster.location.world.name>

Here is the list of all the currently supported variable types, as well as their subvariables

Variable types โ€‹

AttackMetadata โ€‹

SubvariableTypeDescription
damagedoubleAmount of damage being dealt
damage_<type>doubleAmount of damage of given damage type being dealt

AttributeMap โ€‹

This is useful if you want to access some player's vanila attribute values. Example use: <caster.attribute.max_health>.

Vanilla attributes shall not be mistaken for player stats which are added by the MMO plugins. Some of these stats are based on vanilla attributes, but not all of them. For instance, weapon crit chance is a custom stat which isn't based on any vanilla attribute so you can't access it using this variable type. You'll need to use the statMap variable type: <caster.stat.critical_strike_chance>. However since attack damage is based on a vanilla attribute, <caster.stat.attack_damage> will NOT return the correct value, because it only takes into account stat modifiers registered in MythicLib and not external attribute modifiers!

SubvariableTypeDescription
max_healthdouble//
follow_rangedouble//
knockback_resistancedouble//
movement_speeddouble//
flying_speeddouble//
attack_damagedouble//
attack_knockbackdouble//
attack_speeddouble//
armordouble//
armor_toughnessdouble//
luckdouble//
armor_toughnessdouble//

CooldownMap โ€‹

Cooldown maps are used to store a player's cooldown values. Cooldowns are used by MythicLib for damage mitigation (block, parrying, dodging) and for skill cooldowns, and by MMOItems for item cooldowns. You can access the cooldown map of the player casting the script using <caster.cooldown>.

Cooldown maps have an infinite amount of subvariables. Using subvariable some_key will return a double corresponding to the remaining cooldown for the given cooldown key. For instance, <caster.cooldown.mmoitem_small_mana_pot> will return the remaining cooldown for the MMOItem with ID SMALL_MANA_POT.

The following table lists all the keys used by MMOCore and MMOItems (don't use the same otherwise they'll interfere!), if you're a developer working against MythicLib you can literally use any.

You can also use %mythiclib_cooldown_<cooldown_key>% to retrieve the player's current cooldown using placeholders from PlaceholderAPI. Example: %mythiclib_cooldown_skill_fireball%

SubvariableTypeDescription
mmoitem_<lower_case_item_id>doubleRemaining item cooldown or 0
<cooldown_reference>doubleIf the MMOItem has a cooldown reference, use it instead of the above.
skill_<lower_case_skill_id>doubleRemaining skill cooldown or 0
dodgedoubleRemaining dodging cooldown or 0
parrydoubleRemaining parrying cooldown or 0
blockdoubleRemaining dodge cooldown or 0
weapon_critdoubleRemaining weapon crit strike cooldown or 0
skill_critdoubleRemaining skill crit strike cooldown or 0

Double โ€‹

Numeric value.

SubvariableTypeDescription
intintegerThe whole part of that number

Entity โ€‹

Any entity that is NOT a player. Players share many subvariables with the Entity variable type but have a few extra properties.

SubvariableTypeDescription
idintegerThe entity id
uuidstringThe entity UUID
typestringThe entity type (ZOMBIE, GHAST etc. full list)
locationpositionThe entity current loc
bb_centerpositionThe center position of that entity given its bounding box
eye_locationpositionThe position of the eyes of the entity
healthdoubleThe current entity health bar
lookingpositionA vector pointing towards where the entity is looking
velocitypositionThe instantaneous entity velocity
heightdoubleThe entity height
attributeattributeMapThe entity attribute map
fire_ticksintThe amount of ticks during which the entity will be on fire (0 if not on fire)

Integer โ€‹

A round number. No subvariables!

Player โ€‹

A player entity. Players share many subvariables with the Entity variable type but have a few extra properties.

SubvariableTypeDescription
------Any from the Entity variable type
statstatMapThe player's stat map
cooldowncooldownMapThe player's cooldown map
namestringThe player name

Position โ€‹

Positions/locations/vectors are all pretty much synonyms. A position is defined by a world + three coordinates (X, Y and Z). Positions are both used to describe player location (in that case you are using the world subvariable) and to make vector computation (the world subvariable is therefore useless).

SubvariableTypeDescription
worldworldPosition world
xdoubleX coordinate
ydoubleY coordinate
zdoubleZ coordinate
lengthdoubleVector length computation
biomestringBiome name
altitudedoubleComputes altitude of position

StatMap โ€‹

Stat maps are used to store all the stat modifiers from a specific player. You can access the script runner's stat map using <caster.stat>. Then retrieve the stat value using <caster.stat.skill_critical_strike_chance> for instance.

Vanilla attributes shall not be mistaken for player stats which are added by the MMO plugins. Some of these stats are based on vanilla attributes, but not all of them. For instance, weapon crit chance is a custom stat which isn't based on any vanilla attribute so you can't access it using this variable type. You'll need to use the statMap variable type: <caster.stat.critical_strike_chance>. However since attack damage is based on a vanilla attribute, <caster.stat.attack_damage> will NOT return the correct value, because it only takes into account stat modifiers registered in MythicLib and not external attribute modifiers!

String โ€‹

SubvariableTypeDescription
uppercasestringSame string in upper case
lowercasedoubleSame string in lower case

Random โ€‹

SubvariableTypeDescription
uniformdoubleDecimal number sampled uniformly between 0 and 1
intintA random integer
boolbooleanA random boolean (true or false), uniformly
gaussiandoubleDecimal number sampled from a standard gaussian distribution

World โ€‹

SubvariableTypeDescription
timeintCurrent time in the world
namestringWorld name

Powered by VitePress