-
Notifications
You must be signed in to change notification settings - Fork 2
Conditionals
Note
For beginners, this page is best viewed side by side with the Skill Commands page.
Info in any Lythos or Cobalt Wiki page may be unnecessary, disorganized, outdated, inaccurate, missing, etc, so we highly encourage you to edit pages to improve them!
Assume everything is straight from the game unless stated otherwise & if there are any restrictions, you can code mod your way out of them.
Please use Astra.
While testing your Astra/XML/TXT edits & your game is running, please use the Cobalt reload feature! It's a huge time save!
The condition field is the second most important/complicated attribute type a skill can have. It determines the conditions required for the skill to activate, if any. If the logical expression listed in the condition field is TRUE (fulfilled), the skill will be able to activate.
The conditional field can be as complicated or simple as required, there are also often multiple ways to get the same result. It can involve multiple logical operators, such as AND, OR, NOT and more. The condition attribute can also be left empty if you’d like your skill to always be active - an empty conditional is typically used in stat boosting skills like Speed +3.
Condition
Because the condition field is essentially a logical expression there are seemingly infinite possible usages of the attribute; trying to list all possible usages is pointless. Instead, some examples of increasing complexity will be broken down to illustrate the basic format for conditionals, as well as the basic process required to translate and understand them on your own.
—————
Example 1: Unyielding (SID_不屈)
At start of player phase, if HP is 20% or less, restores 20% of unit's max HP.
The conditional for this skill is:
Condition="HP100 <= MaxHP20"
As a reminder, in XML < is ‘<’. This and more are defined in the Operators section.
In programming, the ‘<=’ operator means ‘less than OR equal to’.
The operator ‘*’ is for multiplication.
Essentially, the condition takes the unit’s current HP and turns it into a percentage by multiplying it by 100. Multiplying the MaxHP by 20 does the same, but only returns 20% of the total value. Knowing this, the condition could be translated to:
HP% <= MaxHP20%
In plain English, this means:
If the current HP% is Less than or Equal To 20% of unit MaxHP
If this condition is met, the skill will activate.
—————
Example 2: Break Defenses (SID_ブレイク時追撃)
If unit's attack breaks foe, unit makes an extra attack at 50% damage.
The conditional for this skill is: Condition="攻撃結果(ブレイク) && スキル所持("追撃不可") == 0"
Cleaned to be more readable: (these changes have to be reverted to work in-game) Condition="攻撃結果(ブレイク) && スキル所持(“追撃不可”) == 0"
You’ll notice that there is Japanese text in this conditional. The variable names in this game are all in Japanese, you can find translations for them here. (Thank you, Araragi)
Translating the variable names we get: (again these changes would have to be reverted) Condition=”BattleSceneResult(Break) && UnitSkill(“Cannot Follow Up”) == 0”
If you have basic programming knowledge you can probably infer how this skill works already. Even if you don’t, you should try and understand it yourself before reading on.
You can typically identify logical operators as they consist of two repeating symbols. Again, these are defined in full at the bottom of this document, with other common term definitions, under the Miscellaneous section. As a reminder:
- && is a logical AND, which requires the connected operands to be true before it also returns TRUE
In this instance, both the first and second sections of the conditional must be true for the && to return true.
- == is an equality operator that requires the connected operands to be equal before it returns TRUE
In this instance, the unit must not have the skill “Cannot Follow Up” for the == to return true.
It’s important to understand that, generally speaking, 0 = FALSE and 1 = TRUE.
The function UnitSkill(“Cannot Follow Up”), which checks whether the unit has a corresponding skill, will output a 0 (FALSE) or a 1 (TRUE).
Finally, you should understand why “Cannot Follow Up” must be enclosed with quotation marks while Break does not. ‘Cannot Follow Up’ is a reference to another skill, and is thus a string. Break is, instead, a named value in the code and doesn’t require quotation marks.
So re-examining the translated conditional, in plain english it reads:
If battle results in a break AND the unit does not have the skill “Cannot Follow Up”
If this condition is met, the skill will activate.
There are various operators you can use in conditions and/or skill functions.
Including the operators in Operation, you can use % & these logical operators.
| Symbol | Operator | Description |
|---|---|---|
| % | Modulus | Returns the remainder when dividing one value by another. |
| && | Logical AND | Returns true only if both operands are true. |
| || | Logical OR | Returns true if either operand is true. |
| ^ | Logical XOR | Returns true if only one but not both of the operands. Unused in Engage. |
| == | Comparison Operator | Returns true if both operands are equal |
| > | Greater Than | If the left operand is greater than the right operand, returns true. In x>y, if x is greater than y, returns true. |
| < | Less Than | If the left operand is less than the right operand, returns true. In x<y, if x is less than y, returns true. |
| >= | Greater Than/Equal To | If the left operand is greater than or equal to the right operand, returns true. |
| <= | Less Than/Equal To | If the left operand is less than or equal to the right operand, returns true. |
| != | Not Equal To | If the left operand is not equal to the right operand, equals true. |
XML Symbols, not an issue if using Astra or EngageXml to view & edit.
Certain special symbols are not translated when viewing the raw text of an XML document.
These are the symbols and their definitions:
| Special Character | Format |
|---|---|
| < (less-than) | < |
| > (greater-than) | > |
| & (ampersand) | & |
| ' (apostrophe) | ' |
| " (double-quote) | " |
It should be noted that this is still easily readable, as all symbols are just their English names abbreviated and surrounded by ‘&’ and ‘;’.
Inequality symbols may also be combined with ‘=’ like so:
<= | <=
<= | >=
Here are some very basic explanations of common math commands you may see or are usable in the skills file. Mainly for people who are familiar with the mathematical concepts, but not with the programming terminology. If you don’t understand any of them, look for resources online.
x etc can be a number, or an expression that is calculated before the function is performed.
Some functions, such as min & max, may only accept 2 inputs, so you need to nest the two stats.
If you want to check for 3 stats like Strength, Magic & Dexterity, you'd write it like this:
| Function | Description |
|---|---|
min(x, y..) |
Returns the smallest listed value. |
max(x, y..) |
Returns the largest listed value. |
round(x) |
Rounds a number to the nearest integer. |
abs(x) |
Returns the absolute value of a number (the signless value). |
int(x) |
Rounds down a number to the nearest integer. |
sqrt(x) |
Returns the square root of a number. |
pow(x, y) |
Raises number (x) to a specified power (y) and returns the result. |
log(x, y) |
Returns the logarithm of a number (x) with a specified base (y). |
exp(x) |
Returns the exponential of x if put as the power of e (~2.71828). |
strlen([string]) |
Returns the length of the string. |
rand(x, y) |
Returns a random number where x and y are the range. (Inclusive) |
There are more math functions you can use here.
Badrack Obabman - Info
Lythos, the Engage modding Wiki • Resources • Getting Started • Cobalt Wiki * Discord Server
Getting Started
Modding guides
- Game data
- Models and Unity
- Animations
- Audio
-
Maps
- Dumping Vanilla Maps
- Playable Area
- MapSetting
-
Terrain
- Terrainpaint
- Props
- CameraSet
- Exporting
-
LightSet
- Lightmaps & Environmental Lighting
- PostProcessSet
- Post-Battle Exploration
- HubRoot
- HubCollision
Documentation