Skip to content

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:

MemberWhat it does
evaluate(argument: Variant = null) -> boolThe question. argument is what the caller offers: usually an Entity, an Encounter, or a StatConditionContext
get_description() -> StringA readable description for the editor and for debugging
get_function_description() -> StringThe same with {field} placeholders, used by the dialogs that edit a condition inline
is_valid() -> boolIs it configured well enough to run?
get_expected_argument_type() -> StringWhat 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
CheckLogicThe comparison enum shared by number conditions: EQUAL, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL, NOT_EQUAL, CONTAINS, NOT_CONTAINS

The three families ​

FamilyBase classArgumentOverride
GeneralConditionWhatever the caller gives, usually nothingevaluate
EntityEntityConditionAn Entityevaluate_entity(entity)
EncounterEncounterConditionAn Encounterevaluate_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:

EntityTargetResolves to
ARGUMENT_ENTITYThe argument itself, when it is an Entity
ARGUMENT_ENTITY_TARGETargument.target
CURRENT_PLAYERPlayerUtility.get_current_player()
SUMMONERargument.summoner, when the argument is a Pet
UNIQUE_IDThe entity registered under target_entity_id in the object registry (needs the system hub)
OPPONENTThe other side of the hit, for conditions on stat effects (see below)
ANY_PLAYER, ALL_PLAYERNot 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 ​

OwnerPropertyType
EventconditionsArray[Condition]: all must be true. get_failed_conditions lists the failed ones
IfAction (event action)conditionsArray[Condition]
StatEffectconditionsArray[Condition]: all must be true, on top of the active trigger. Evaluated with a StatConditionContext
ConditionConditionalEffectconditions, logic, check_onArray[Condition], all or any, on the target or the originator. The effect instance gives them the system hub
CombatAction, BehaviorReaction, CombatReaction, PhaseTransitionconditionsArray[EntityCondition]
TaskScheduleactivation_conditionsArray[EntityCondition]
BehaviorTaskexecution_conditionsArray[EntityCondition]
EncounterReaction, EncounterActionconditionsArray[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 under res://addons/chroniclenode/data_classes/conditions/ (general/, entity/, encounter/). Project lists every condition script in your own folder res://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 folders res://src/conditions/ and res://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 ​

  1. Make a script in res://src/conditions/ that extends EntityCondition (or Condition, or EncounterCondition), with @tool and a class_name.
  2. Add @export properties for its settings.
  3. Override evaluate_entity(entity), and get_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_kills

The classes ​

Base classes ​

ClassWhat it is
ConditionBase class for all conditions that evaluate game state.
EncounterConditionBase class for conditions that evaluate encounter state.
EntityConditionBase class for conditions that evaluate entity state.

Entity ​

ClassWhat it is
AbilityCooldownReadyConditionChecks if a specific ability is off cooldown and ready to use.
AlliesInRangeConditionChecks if a minimum number of allies are within a specified range.
AlliesInRangeHealthConditionChecks if minimum number of allies in range are above/below health threshold Consolidates HealthAbove and HealthBelow conditions with encounter support.
AlliesInRangeWithEffectConditionChecks if minimum number of allies in range have/don't have specific effect Now supports encounter-aware searching and inverted logic.
CastingStateConditionChecks if the entity or target is currently casting/not casting.
CombatStateConditionChecks if the target entity is in combat or not.
EncounterDurationConditionChecks if the current encounter has been running for a specific duration.
EncounterFactionBalanceConditionChecks the faction balance in the current encounter.
EnemiesInRangeConditionChecks if a minimum number of enemies are within a specified range.
EnemiesInRangeHealthConditionChecks if minimum number of enemies in range are above/below health threshold Consolidates HealthAbove and HealthBelow conditions with encounter support.
EnemiesInRangeWithEffectConditionChecks if minimum number of enemies in range have/don't have specific effect Now supports encounter-aware searching and inverted logic.
EntitiesInRangeHealthConditionChecks if minimum number of entities in range are above/below health threshold
EntitiesInRangeWithEffectConditionChecks if minimum number of entities in range have/don't have specific effect
EntityDistanceToEntityConditionChecks distance between the target entity and another specific entity.
EntityDistanceToInteractableConditionChecks distance between the target entity and a specific interactable object.
EntityHasTagConditionChecks the type tags of an entity ("Undead", "Beast" ...).
EquippedWeaponTypeConditionChecks the weapons an entity holds: "holds a one-handed weapon".
HasCurrencyConditionCheck if the entity holds an amount of a currency (money, or anything a game counts as a currency: a quest track, a token)
HasEffectConditionChecks if the entity or target has a specific effect active.
HasEquippedConditionCheck if entity has specific equipment items equipped Evaluates whether the entity has the required equipment items currently equipped
HasItemConditionCheck if entity has specific items in their inventory Evaluates whether the entity has the required items and quantities
HasTargetConditionChecks if the entity has a valid target.
HealthPercentConditionChecks if the entity's health is above/below a specified percentage.
IsAliveConditionChecks if the target entity is alive or dead.
IsLevelConditionChecks if the target entity meets a level requirement.
IsPlayerClassConditionChecks if the target entity is a Player with a specific class ID.
MetadataConditionCheck entity metadata with flexible operations and type handling
MovementStateConditionChecks whether the entity is standing still, moving, in the air or on the ground.
ProficiencyConditionChecks the level of an entity in a proficiency: "has Lockpicking 25 or more", "is untrained in swords".
TargetDistanceBetweenConditionChecks if the target is within a specified distance range (between min and max).
TargetDistanceConditionChecks if the target is closer/farther than a specified range.
TargetIsPlayerConditionChecks if the target is a player entity.
TimeOfDayConditionIs it between two hours of the game day?
WearingArmorClassConditionChecks the armor an entity wears: "wears at least three pieces of plate".
WorldPositionDistanceBetweenConditionChecks if the entity is within a specified distance range from a world position.
WorldPositionDistanceConditionChecks if the entity is within range or farther than a world position.

Encounter ​

ClassWhat it is
CombatDurationConditionChecks if the group has been in combat for a specified duration
DistanceFromPositionConditionChecks if group is within certain distance of a position
EncounterActiveStateConditionChecks if an encounter is in a specific active state.
EncounterCombatStateConditionChecks if an encounter is in a specific combat state.
EncounterEntityCountConditionChecks if an encounter has a specific number of entities alive/dead.
GroupHealthPercentageConditionChecks if the group's average health percentage meets specified criteria
GroupMembersAliveConditionChecks if the number of alive group members meets specified criteria
PlayersInAreaConditionChecks if a minimum number of players are within the encounter area

Events ​

ClassWhat it is
LocalVariableBoolConditionChecks if a local boolean variable in an event meets certain criteria
LocalVariableFloatConditionChecks if a local float variable in an event meets certain criteria
LocalVariableIntConditionChecks if a local integer variable in an event meets certain criteria
LocalVariableStringConditionChecks if a local string variable in an event meets certain criteria

General ​

ClassWhat it is
ChestContainsItemConditionCheck if a container contains specific items Evaluates whether a chest/container has the required items and quantities
DoorStateConditionCheck door state and accessibility Evaluates door-specific conditions like open/closed state and lock status
EventActiveEntityConditionChecks if a specific event is currently active
EventCompletedEntityConditionChecks if a specific event has been completed
GameTimeConditionChecks if the current game time meets specified criteria.
GlobalVariableConditionUniversal condition for checking global variables of any type
GroundWeatherConditionChecks 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.
InteractableHealthConditionChecks if a destructible interactable's health meets certain criteria.
OrConditionA composite condition that passes if a specified number of its child conditions pass.
PartyIncludesClassConditionChecks if the party includes a specific character class.
PartySizeConditionChecks if the party size meets certain criteria.
PlayerInZoneConditionChecks whether the party is in a zone.
PlayerTriggerAreaPresenceConditionChecks if players are present in a specific trigger area
QuestActiveEntityConditionChecks if a specific quest is currently active
QuestCompletedEntityConditionChecks if a specific quest has been completed
RandomChanceConditionChecks if a random roll succeeds based on percentage chance.
ShelteredConditionChecks 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.
SwitchStateConditionCheck if a switch is in the desired state Evaluates switch-specific conditions like ON/OFF state
TriggerAreaPresenceConditionChecks if entities are present in a specific trigger area