Skip to main content
Glama

apply_effect

Apply SRD conditions or custom effects to characters in D&D 5e campaigns. Use standard templates for conditions like blinded or poisoned, or create custom effects with specific modifiers for gameplay management.

Instructions

Apply an ActiveEffect to a character (SRD condition or custom effect).

For SRD conditions (blinded, charmed, deafened, exhaustion, frightened, grappled, incapacitated, invisible, paralyzed, petrified, poisoned, prone, restrained, stunned), uses the standard condition template.

For custom effects, creates a new ActiveEffect with the provided modifiers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
character_name_or_idYesCharacter name, ID, or player name.
effect_nameYesEffect name (SRD condition like 'blinded', 'poisoned', or custom name)
sourceNoSource of the effect (e.g., 'Poison trap', 'Hold Person spell')
durationNoDuration in rounds. None for permanent effects.
custom_modifiersNoJSON list of custom modifiers, e.g. '[{"stat":"attack_roll","operation":"add","value":2}]'

Implementation Reference

  • The implementation of `EffectsEngine.apply_effect` which adds an effect to a character's list of active effects, handling stackability and unique ID generation.
    def apply_effect(character: "Character", effect: ActiveEffect) -> ActiveEffect:
        """Apply an active effect to a character.
    
        Creates a deep copy of the effect with a unique ID and adds it to the
        character's active_effects list. Non-stackable effects with the same name
        will not be duplicated; the existing one is kept.
    
        Args:
            character: The character to apply the effect to.
            effect: The effect template to apply.
    
        Returns:
            The applied ActiveEffect instance (with unique ID), or the existing
            one if a non-stackable duplicate was found.
        """
        # Check for non-stackable duplicates
        if not effect.stackable:
            for existing in character.active_effects:
                if existing.name == effect.name:
                    return existing
    
        # Deep copy to avoid shared state between characters
        applied = deepcopy(effect)
        applied.id = random(length=8)
        character.active_effects.append(applied)
        return applied
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Polloinfilzato/dm20-protocol'

If you have feedback or need assistance with the MCP directory API, please join our Discord server