Conditions: how they are built ​
A condition is a Resource with one job: answer true or false for some part of the game state. Like a requirement it is stored inside the resource that uses it and has no id of its own. The Basic guide explains how to use them.
The base class ​
Condition extends Resource:
| Member | What it does |
|---|---|
evaluate(argument: Variant = null) -> bool | The question. argument is what the caller offers: usually an Entity, an Encounter, or a StatConditionContext |
get_description() -> String | A readable description for the editor and for debugging |
get_function_description() -> String | The same with {field} placeholders, used by the dialogs that edit a condition inline |
is_valid() -> bool | Is it configured well enough to run? |
get_expected_argument_type() -> String | What evaluate expects, for editor hints ("Entity", "Encounter", "None") |
set_system_hub(hub) | Gives the condition the systems of the game, for conditions that look things up by id. The caller sets it before evaluate |
CheckLogic | The comparison enum shared by number conditions: EQUAL, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL, NOT_EQUAL, CONTAINS, NOT_CONTAINS |
The three families ​
| Family | Base class | Argument | Override |
|---|---|---|---|
| General | Condition | Whatever the caller gives, usually nothing | evaluate |
| Entity | EntityCondition | An Entity | evaluate_entity(entity) |
| Encounter | EncounterCondition | An Encounter | evaluate_encounter(encounter) |
Do not override evaluate in an entity or encounter condition. The base class first picks the entity (or encounter) to ask about from the target setting, returns false when there is none, and only then calls your function.
Entity targets ​
EntityCondition.entity_target chooses the entity from the argument. get_target_entity(argument) resolves it:
EntityTarget | Resolves to |
|---|---|
ARGUMENT_ENTITY | The argument itself, when it is an Entity |
ARGUMENT_ENTITY_TARGET | argument.target |
CURRENT_PLAYER | PlayerUtility.get_current_player() |
SUMMONER | argument.summoner, when the argument is a Pet |
UNIQUE_ID | The entity registered under target_entity_id in the object registry (needs the system hub) |
OPPONENT | The other side of the hit, for conditions on stat effects (see below) |
ANY_PLAYER, ALL_PLAYER | Not one entity but the whole party: evaluate asks every member of the party (get_party_members, from the system hub or the current player) and is true when at least one member passes (ANY_PLAYER) or every member passes (ALL_PLAYER). With no party it is false |
EncounterCondition.encounter_target works the same way: ARGUMENT_ENCOUNTER (an Encounter, or the encounter of an Entity), CURRENT_ACTIVE, NEAREST and UNIQUE_ID (encounter_id).
Conditions on stat effects ​
A stat effect evaluates its conditions with a StatConditionContext as the argument: owner (the entity that has the stat), opponent (the other side of the hit being calculated, null outside a hit) and the system hub. EntityCondition understands it: ARGUMENT_ENTITY is the owner and OPPONENT is the opponent, so "damage against Undead" is an EntityHasTagCondition with the target OPPONENT.
Combining ​
OrCondition holds an Array[Condition] and passes when at least min_required of them pass. With min_required 1 it is "or", with as many as it holds it is "and". It gives its children the system hub.
Where conditions are stored and evaluated ​
| Owner | Property | Type |
|---|---|---|
Event | conditions | Array[Condition]: all must be true. get_failed_conditions lists the failed ones |
IfAction (event action) | conditions | Array[Condition] |
StatEffect | conditions | Array[Condition]: all must be true, on top of the active trigger. Evaluated with a StatConditionContext |
ConditionConditionalEffect | conditions, logic, check_on | Array[Condition], all or any, on the target or the originator. The effect instance gives them the system hub |
CombatAction, BehaviorReaction, CombatReaction, PhaseTransition | conditions | Array[EntityCondition] |
TaskSchedule | activation_conditions | Array[EntityCondition] |
BehaviorTask | execution_conditions | Array[EntityCondition] |
EncounterReaction, EncounterAction | conditions | Array[EncounterCondition] |
How the editors list them ​
- The add-condition dialog (
ConditionalEditDialog) has four categories. General, Entity and Encounter list every script of the matching folder underres://addons/chroniclenode/data_classes/conditions/(general/,entity/,encounter/). Project lists every condition script in your own folderres://src/conditions/, of any kind. The name in the list is the file name without_condition. - The list of a stat effect shows the entity conditions of
conditions/entity/and of the project foldersres://src/conditions/andres://src/stat_conditions/(StatClassScanner.find_conditions), so a condition you write there is offered without touching the addon. - The event variable conditions in
conditions/event/are made by the event editor, which is where those variables exist.
Writing your own condition ​
- Make a script in
res://src/conditions/that extendsEntityCondition(orCondition, orEncounterCondition), with@tooland aclass_name. - Add
@exportproperties for its settings. - Override
evaluate_entity(entity), andget_entity_description()for the text the editor shows.
The Project category of the add-condition dialog and the list of a stat effect (for entity conditions) find a script in res://src/conditions/ by themselves. res://src/stat_conditions/ still works for stat effects.
gdscript
@tool
class_name HasManyKillsCondition extends EntityCondition
## Checks that the entity has killed a number of enemies
@export var minimum_kills: int = 10
func evaluate_entity(entity: Entity) -> bool:
return int(entity.get_meta("kills", 0)) >= minimum_kills
func get_entity_description() -> String:
return "Has at least %d kills" % minimum_killsThe classes ​
Base classes ​
| Class | What it is |
|---|---|
| Condition | Base class for all conditions that evaluate game state. |
| EncounterCondition | Base class for conditions that evaluate encounter state. |
| EntityCondition | Base class for conditions that evaluate entity state. |
Entity ​
| Class | What it is |
|---|---|
| AbilityCooldownReadyCondition | Checks if a specific ability is off cooldown and ready to use. |
| AlliesInRangeCondition | Checks if a minimum number of allies are within a specified range. |
| AlliesInRangeHealthCondition | Checks if minimum number of allies in range are above/below health threshold Consolidates HealthAbove and HealthBelow conditions with encounter support. |
| AlliesInRangeWithEffectCondition | Checks if minimum number of allies in range have/don't have specific effect Now supports encounter-aware searching and inverted logic. |
| CastingStateCondition | Checks if the entity or target is currently casting/not casting. |
| CombatStateCondition | Checks if the target entity is in combat or not. |
| EncounterDurationCondition | Checks if the current encounter has been running for a specific duration. |
| EncounterFactionBalanceCondition | Checks the faction balance in the current encounter. |
| EnemiesInRangeCondition | Checks if a minimum number of enemies are within a specified range. |
| EnemiesInRangeHealthCondition | Checks if minimum number of enemies in range are above/below health threshold Consolidates HealthAbove and HealthBelow conditions with encounter support. |
| EnemiesInRangeWithEffectCondition | Checks if minimum number of enemies in range have/don't have specific effect Now supports encounter-aware searching and inverted logic. |
| EntitiesInRangeHealthCondition | Checks if minimum number of entities in range are above/below health threshold |
| EntitiesInRangeWithEffectCondition | Checks if minimum number of entities in range have/don't have specific effect |
| EntityDistanceToEntityCondition | Checks distance between the target entity and another specific entity. |
| EntityDistanceToInteractableCondition | Checks distance between the target entity and a specific interactable object. |
| EntityHasTagCondition | Checks the type tags of an entity ("Undead", "Beast" ...). |
| EquippedWeaponTypeCondition | Checks the weapons an entity holds: "holds a one-handed weapon". |
| HasCurrencyCondition | Check if the entity holds an amount of a currency (money, or anything a game counts as a currency: a quest track, a token) |
| HasEffectCondition | Checks if the entity or target has a specific effect active. |
| HasEquippedCondition | Check if entity has specific equipment items equipped Evaluates whether the entity has the required equipment items currently equipped |
| HasItemCondition | Check if entity has specific items in their inventory Evaluates whether the entity has the required items and quantities |
| HasTargetCondition | Checks if the entity has a valid target. |
| HealthPercentCondition | Checks if the entity's health is above/below a specified percentage. |
| IsAliveCondition | Checks if the target entity is alive or dead. |
| IsLevelCondition | Checks if the target entity meets a level requirement. |
| IsPlayerClassCondition | Checks if the target entity is a Player with a specific class ID. |
| MetadataCondition | Check entity metadata with flexible operations and type handling |
| MovementStateCondition | Checks whether the entity is standing still, moving, in the air or on the ground. |
| ProficiencyCondition | Checks the level of an entity in a proficiency: "has Lockpicking 25 or more", "is untrained in swords". |
| TargetDistanceBetweenCondition | Checks if the target is within a specified distance range (between min and max). |
| TargetDistanceCondition | Checks if the target is closer/farther than a specified range. |
| TargetIsPlayerCondition | Checks if the target is a player entity. |
| TimeOfDayCondition | Is it between two hours of the game day? |
| WearingArmorClassCondition | Checks the armor an entity wears: "wears at least three pieces of plate". |
| WorldPositionDistanceBetweenCondition | Checks if the entity is within a specified distance range from a world position. |
| WorldPositionDistanceCondition | Checks if the entity is within range or farther than a world position. |
Encounter ​
| Class | What it is |
|---|---|
| CombatDurationCondition | Checks if the group has been in combat for a specified duration |
| DistanceFromPositionCondition | Checks if group is within certain distance of a position |
| EncounterActiveStateCondition | Checks if an encounter is in a specific active state. |
| EncounterCombatStateCondition | Checks if an encounter is in a specific combat state. |
| EncounterEntityCountCondition | Checks if an encounter has a specific number of entities alive/dead. |
| GroupHealthPercentageCondition | Checks if the group's average health percentage meets specified criteria |
| GroupMembersAliveCondition | Checks if the number of alive group members meets specified criteria |
| PlayersInAreaCondition | Checks if a minimum number of players are within the encounter area |
Events ​
| Class | What it is |
|---|---|
| LocalVariableBoolCondition | Checks if a local boolean variable in an event meets certain criteria |
| LocalVariableFloatCondition | Checks if a local float variable in an event meets certain criteria |
| LocalVariableIntCondition | Checks if a local integer variable in an event meets certain criteria |
| LocalVariableStringCondition | Checks if a local string variable in an event meets certain criteria |
General ​
| Class | What it is |
|---|---|
| ChestContainsItemCondition | Check if a container contains specific items Evaluates whether a chest/container has the required items and quantities |
| DoorStateCondition | Check door state and accessibility Evaluates door-specific conditions like open/closed state and lock status |
| EventActiveEntityCondition | Checks if a specific event is currently active |
| EventCompletedEntityCondition | Checks if a specific event has been completed |
| GameTimeCondition | Checks if the current game time meets specified criteria. |
| GlobalVariableCondition | Universal condition for checking global variables of any type |
| GroundWeatherCondition | Checks how wet the ground is or how much snow lies on it (what the terrain shows): "the snow is at least half" opens a pass, "the ground is dry" lets a fire be lit. |
| InteractableHealthCondition | Checks if a destructible interactable's health meets certain criteria. |
| OrCondition | A composite condition that passes if a specified number of its child conditions pass. |
| PartyIncludesClassCondition | Checks if the party includes a specific character class. |
| PartySizeCondition | Checks if the party size meets certain criteria. |
| PlayerInZoneCondition | Checks whether the party is in a zone. |
| PlayerTriggerAreaPresenceCondition | Checks if players are present in a specific trigger area |
| QuestActiveEntityCondition | Checks if a specific quest is currently active |
| QuestCompletedEntityCondition | Checks if a specific quest has been completed |
| RandomChanceCondition | Checks if a random roll succeeds based on percentage chance. |
| ShelteredCondition | Checks whether the party's view is inside a shelter (a ShelterVolume): "the party is under a roof" lets a camp be made, "the party is in the open" starts a storm quest. |
| SwitchStateCondition | Check if a switch is in the desired state Evaluates switch-specific conditions like ON/OFF state |
| TriggerAreaPresenceCondition | Checks if entities are present in a specific trigger area |