Damage Formula
When selecting a potion item type or skill, you can input a damage formula. However, you can also use this field to execute other actions (e.g., awarding items, skills, or gold). Here's an explanation of how this works:
a
(attacker): Represents the entity initiating the action (e.g., player, NPC).b
(defender): Represents the entity receiving the action (e.g., player, enemy).Both
a
andb
areScriptUnit
objects.For items,
b
does not exist, and you can uselevel
to get the item's level.For states, only
a
andb
exist.For skills,
level
refers to the skill's level.
Variable
a.id
a playerID
a.type
a Type (0=player, 1=event, 2=monster)
a.name
a Name
a.x
a position X
a.y
a position Y
a.atk
a Attack
a.def
a Defense
a.magicAtk
a MagicAttack
a.magicDef
a MagicDefense
a.agi
A gility
a.luk
a Lucky
a.maxHP
a maxHP
a.maxMP
a maxMP
a.hp
a currentHP
a.mp
a currentMP
Function
a.SpawnAt(x, y)
Move a to the coordinates x, y.
a.SpawnAtField(mapID, x, y)
Move a to the coordinates x, y on the map with ID mapID.
a.RespawnAt(x, y)
Teleport a to the coordinates x, y.
a.SetVar(id, value)
Change the variable with ID id of a to value.
a.GetVar(id)
Retrieve the variable with ID id from a.
a.AddSkill(id, level)
Add a skill with ID id and level level to a.
a.AddItem(id, count)
Add count items with ID id to a.
a.AddGameMoney(amount)
Add gold to a.
b.RemoveSkill(id)
Remove a skill with ID id from b.
b.RemoveItem(id, count)
Consume count items with ID id from b.
b.UseGameMoney(amount)
Deduct amount gold from b.
b.StartGlobalEvent(id)
Call the global event with ID id.
b.AddBuff(id)
Applies the state with the specified ID to b.
b.RemoveBuff(id)
Removes the state with the specified ID from b.
Practical Examples
Damage Calculation Examples:
Basic Damage Formula: Damage = Attacker's attack - Defender's defense
Random Damage: Generates random damage between 10 and 50
Custom Actions:
Steal Gold from Defender:
Remove Items or Gold from Attacker:
Conditional Formulas:
Critical Damage Calculation: Apply
(a.atk * 2)
for critical hits; otherwise,(a.atk)
Skill-Specific Damage:
Damage Based on Skill Level: Damage =
a.magicAtk - b.magicDef + level + 1
Item-Specific Actions:
Grant a Skill with an Item: When using an item, grant
Skill ID 0
atLevel 1
toa
State Effects:
Continuous Damage from States: Apply 10 damage over time (minimum of 2 seconds)
Last updated