Effects¶
Responsibility¶
The effect subsystem defines timed status types and per-creature effect instances: duration, intensity, body-part scope, source, modifiers, messages, immunity, removal, and migration of renamed effect IDs.
Entry points¶
Read src/effect.h, src/effect.cpp, and src/effect_source.*. Static JSON enters
effect_type; a creature's effects_map stores instances; EOC integration is a separate
contract in effect_on_condition.
Data ownership¶
The registry owns effect_type definitions. Each Creature owns its effects_map; an
effect references a type and owns instance duration, intensity, body scope, and source data.
Dependencies¶
Effects depend on IDs, body parts, damage and character modifiers, events, messages, immunity rules, EOC, source serialization, and creature turn processing.
Lifecycle¶
Types load and finalize; an instance is added or refreshed, processed each turn, changes intensity or duration, fires relevant behavior, and expires or is explicitly removed/migrated.
Invariants¶
Type IDs resolve; duration and intensity respect type bounds; body-scoped keys do not collide; source data remains valid; removal does not invalidate an active iteration; migrations are acyclic and preserve old saves.
Extension points¶
Prefer effect JSON, modifiers, and EOC hooks. Add native behavior only when it is reusable and cannot be declared, then centralize it and test immunity, add, process, and remove paths.
Serialization¶
Effect instances and effect_source serialize in the save layer; definitions load from JSON.
New fields need defaults, and an ID rename needs an explicit effect_migration.
Tests¶
Use effect and creature-effect tests plus focused character/monster tests. Cover duration and intensity edges, body parts, immunity, sources, removal during processing, and round trips.
Performance¶
Every active creature processes effects. Keep per-turn work proportional to active instances, avoid repeated type lookups/formatting, and do not rebuild the whole map for one changed effect.
CCB divergence¶
CCB effect definitions and EOC use may differ from upstream despite shared IDs. Port both data and native semantics only after checking migrations, saves, and CCB tests.
Technical debt¶
Effects mix declarative modifiers with native special cases. Prefer explicit, testable data or event hooks and track any remaining hard-coded ID behavior as compatibility debt.