Create modifiers that only activate when specific criteria are met.
Overview
The Conditions System allows you to create modifiers with conditional activation. A modifier can have multiple conditions that must be satisfied before its effects apply.
Check modifier presence: "Has Burning debuff", "Does NOT have Shield buff".
Condition Evaluation: Conditions are evaluated when the modifier is applied. Generated Helper classes include CanApply[ModifierName]() methods that check conditions before application.
AttributeCondition
Evaluates conditions based on attribute values. Supports both absolute value comparisons and percentage-based comparisons.
Properties
Property
Type
Description
attributeName
string
Name of the attribute to check
comparison
ComparisonType
How to compare the value
threshold
float
Value to compare against
logicOperator
LogicOperator
How to combine with other conditions
ComparisonType Enum
12 comparison types are available, split between absolute and percentage modes:
Absolute Comparisons
GreaterThan - value > threshold
LessThan - value < threshold
EqualTo - value == threshold
GreaterOrEqual - value >= threshold
LessOrEqual - value <= threshold
NotEqual - value != threshold
Percentage Comparisons
GreaterThanPercent - % > threshold
LessThanPercent - % < threshold
EqualToPercent - % == threshold
GreaterOrEqualPercent - % >= threshold
LessOrEqualPercent - % <= threshold
NotEqualPercent - % != threshold
Percentage Mode: Percentage comparisons use the attribute's GetPercentage() method, which returns (currentValue / maxValue) * 100. A threshold of 25 means 25% of max.
Examples
// Berserker Rage: Activate when Health < 25%
new AttributeCondition
{
attributeName = "Health",
comparison = ComparisonType.LessThanPercent,
threshold = 25f,
logicOperator = LogicOperator.And
}
// Execute: Activate when Health == 0 (absolute value)
new AttributeCondition
{
attributeName = "Health",
comparison = ComparisonType.EqualTo,
threshold = 0f,
logicOperator = LogicOperator.And
}
// Full Mana Bonus: Activate when Mana >= 100%
new AttributeCondition
{
attributeName = "Mana",
comparison = ComparisonType.GreaterOrEqualPercent,
threshold = 100f,
logicOperator = LogicOperator.And
}
// High Level Bonus: Activate when Level > 50
new AttributeCondition
{
attributeName = "Level",
comparison = ComparisonType.GreaterThan,
threshold = 50f,
logicOperator = LogicOperator.And
}
ModifierCondition
Evaluates conditions based on whether specific modifiers are active on the target. Essential for synergy effects and combo systems.
Name vs Tag: Specify either targetModifierName OR targetModifierTag, not both. Name-based conditions check exact matches; tag-based conditions check any modifier with that tag.
Examples
// Fire Mastery: +50% damage when target has "Burning"
new ModifierCondition
{
conditionType = ModifierConditionType.HasModifier,
targetModifierName = "Burning",
logicOperator = LogicOperator.And
}
// Expose Weakness: Only applies if target has no "Shield"
new ModifierCondition
{
conditionType = ModifierConditionType.DoesNotHaveModifier,
targetModifierName = "Shield",
logicOperator = LogicOperator.And
}
// Curse Amplifier: +25% curse damage when target has any curse
new ModifierCondition
{
conditionType = ModifierConditionType.HasModifierTag,
targetModifierTag = "curse",
logicOperator = LogicOperator.And
}
// Pure State: Bonus when target has no debuffs
new ModifierCondition
{
conditionType = ModifierConditionType.DoesNotHaveModifierTag,
targetModifierTag = "debuff",
logicOperator = LogicOperator.And
}
Logic Operators
Combine multiple conditions using logic operators to create complex activation requirements.
LogicOperator Enum
Operator
Description
Example
And
Both this AND previous must be true
Health < 25% AND Mana > 50%
Or
Either this OR previous can be true
Health < 25% OR Stamina < 25%
Not
Inverts the condition result
NOT (Health > 90%)
Evaluation Order
Conditions are evaluated in order, applying logic operators left to right:
Conditions: [A, B, C]
Logic: [And, Or, And]
Evaluation: ((A AND B) OR C)
Complex Condition Example
Desperate Measures
Activate when: (Health < 25% AND has "Burning") OR (Stamina < 10%)
// Condition 1: Health < 25%
new AttributeCondition
{
attributeName = "Health",
comparison = ComparisonType.LessThanPercent,
threshold = 25f,
logicOperator = LogicOperator.And // Start of chain
}
// Condition 2: Has "Burning" modifier
new ModifierCondition
{
conditionType = ModifierConditionType.HasModifier,
targetModifierName = "Burning",
logicOperator = LogicOperator.And // Health < 25% AND Burning
}
// Condition 3: OR Stamina < 10%
new AttributeCondition
{
attributeName = "Stamina",
comparison = ComparisonType.LessThanPercent,
threshold = 10f,
logicOperator = LogicOperator.Or // (Health < 25% AND Burning) OR Stamina < 10%
}
Real-World Condition Patterns
Low Health Trigger
Common pattern for "last stand" abilities.
Health < 25% (percentage)
Resource Threshold
Activate when you have enough resources.
Mana >= 50 (absolute)
Full Resource Bonus
Bonus when at full capacity.
Stamina >= 100% (percentage)
Status Effect Synergy
Bonus damage against burning targets.
Target HasModifier "Burning"
Combo Finisher
Requires combo stacks to activate.
HasModifier "Combo" (x3 stacks)
Clean State Requirement
Only works without debuffs.
DoesNotHaveModifierTag "debuff"
Level Gate
High-level ability requirement.
Level >= 30 (absolute)
Dual Threshold
Multiple resource conditions.
Health < 50% AND Stamina > 75%
Generated Condition Checking
When you create a conditional modifier in the wizard, the generated Helper class includes automatic condition checking:
// Generated in BerserkerRageHelper.cs
public static bool CanApplyBerserkerRage(GameObject target)
{
if (target == null) return false;
var container = target.GetComponent<ISimpleAttributeDataSource>();
if (container == null) return false;
// Check attribute conditions
var healthAttr = GetAttributeHybrid(container, "Health");
if (healthAttr == null) return false;
// Condition: Health < 25%
if (!(healthAttr.GetPercentage() < 25f)) return false;
// Check modifier conditions
if (!SimpleModifierTracker.HasModifierByName(container, "Burning")) return false;
return true;
}
Use this method to check conditions before applying:
if (BerserkerRageHelper.CanApplyBerserkerRage(player))
{
BerserkerRageHelper.ApplyBerserkerRage(player);
}
Best Practices
Use Percentage for Health/Mana
Percentage comparisons scale with max values. "Health < 25%" works regardless of max health.
Use Absolute for Levels/Counts
Levels, stack counts, and currency should use absolute comparisons. "Level >= 30" not "Level >= 30%".
Tag-Based for Categories
Use HasModifierTag for category checks: "any curse", "any buff". Use HasModifier for specific effects.
Keep Conditions Simple
Complex condition chains are hard to debug. Consider splitting into multiple modifiers if logic gets complicated.