Skip to main content

Affects overview

An affect is a typed record on a character with a point, value, duration, flag, and cost. Use it for a buff, debuff, item blend, or other state that must expire, persist, stack, or appear to viewers.

This forge module registers a type and grants a 10 minute movement bonus.

affect.add_name_definition("MY_BUFF", 700)
affect.add_no_save(affect.name_map.MY_BUFF)

local function grant_speed(ch, amount)
ch:add_affect(affect.name_map.MY_BUFF, point.MOV_SPEED, amount, 0, 600, 0, true)
end

local function revoke_speed(ch)
ch:remove_affect(affect.name_map.MY_BUFF)
end

Call grant_speed(ch, 20) with a character to increase movement speed by 20. The engine undoes the bonus on expiry; this type is not saved. Register names at the top level of a forge game environment or a module it loads. Check the id before using it; see registration.

Glossary​

TermMeaning
Affect / typeA record on a character / its numeric kind. Multiple records can share a type.
PointA character property changed by the record, such as movement speed.
Apply versus pointAn apply id is converted to a point by some helpers. Other calls take the point directly; apply_on in returned data holds a point.
Flag / AFF bitA bit number in the separate character flag channel. 0 sets no bit.
MacroA named set of affect types used for classification.
BroadcastableA type whose affect state is sent to characters' viewers as well as the owner.
No-saveA type excluded from database persistence.
No-clear-on-deathA type kept when death clears affects.
ForgeA Lua module environment that runs registration and game scripts; see Forge setup.
Avatar / virtual characterA character represented as virtual to the engine; its affects reach viewers like any character's and are saved to the session cache.
OverrideAn add option that replaces a matching record instead of always appending one.
match_exactAn override option that requires the same point.
Source VIDThe runtime character identifier associated with the source of an affect.
Real-timeA duration that also elapses while the player is offline.

Three places shape an affect​

Lua registers types and adds or removes records. affect_config.yaml classifies types for persistence, death, broadcast, and macros. The client registers the particle and icon for types that need a visible presentation. A server affect works without a client effect.

MaterialLocation or surface
Lua registration and useA forge game environment, its modules, or quests; character methods need a character.
affect_config.yaml, items_affect.yamlIn your locale base folder.
affect_classAn AFFECT node in a skill file.
Client presentationClient Python effect registration and AFFECT_DATA_DICT.

File locations vary by codebase. Registrations and configuration load at boot.

Find the detail you need​

PageContents
RegistrationId ranges, configuration, macros, item and skill declarations, load order.
Lua APIFunctions, character methods, arguments, constants, and flags.
ClientParticles, icons, client state, and events.
BehaviourLifetime, saving, override, and broadcast.
ExamplesWorking registration and usage patterns.
PitfallsSymptoms, causes, and fixes.