### Attack Examples in Avrae Source: https://avrae.readthedocs.io/en/latest/cheatsheets/pc_combat Illustrative examples of using the !attack command with various arguments, including specifying targets, number of attacks, and advantage. ```text !attack dagger -t KO1 -rr 2 # attacks KO1 with a dagger twice !attack longbow -t WY1 adv # attacks WY1 with a longbow at advantage !attack "fire breath" -t BA1 -t BA2 # makes BA1 and BA2 make saves against a breath weapon ``` -------------------------------- ### Get Help for Avrae Commands Source: https://avrae.readthedocs.io/en/latest/cheatsheets/get_started The !help command provides information about other commands available in Avrae. Users can specify a command to get detailed help for that specific command. ```plaintext !help ``` ```plaintext !help ``` -------------------------------- ### Start Combat with !i begin Source: https://avrae.readthedocs.io/en/latest/_sources/cheatsheets/dm_combat.rst Initiates combat in a Discord channel. Avrae will post a summary message, pin it, and provide a reminder for players to add themselves to combat. ```discord commands !i begin ``` -------------------------------- ### Avrae Alias Definition and Initialization Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/aliasing_tut.rst Provides a complete example of an Avrae alias definition, including the initial command to invoke it. It shows the setup of variables, character data retrieval, conditional creation of custom counters, the core alias logic, and the preparation of embed output. ```text !alias orc-relentless embed #Define variables for later use cc = "Relentless Endurance" desc = "When you are reduced to 0 hit points but not killed outright, you can drop to 1 hit point instead." rest = "You can’t use this feature again until you finish a long rest." hasHP = "You have not been reduced to 0 hit points." noCC = "You do not have this ability." ch=character() #Create the counter if it should exist but doesn't already if ch.race.lower() == "half-orc": ch.create_cc_nx(cc, 0, 1, "long", "bubble", None, None, cc, desc+" "+rest) #Logic of the alias. Check for all the necessary conditions succ = "tries to use" if ch.cc_exists(cc) and ch.get_cc(cc) and not ch.hp: succ = "uses" D = desc ch.mod_cc(cc, -1) ch.set_hp(1) elif ch.hp: D = hasHP elif ch.cc_exists(cc): D = rest else: D = noCC #Prepare the output T = f"{name} {succ} {cc}!" F = f"{cc}|{ch.cc_str(cc) if ch.cc_exists(cc) else '*None*'}" -title "{{T}}" -desc "{{D}}" -f "{{F}}" -color -thumb ``` -------------------------------- ### Cast Spell Examples in Avrae Source: https://avrae.readthedocs.io/en/latest/cheatsheets/pc_combat Examples demonstrating the usage of the !cast command for spells, including targeting multiple creatures, specifying spell level, and casting spells with spaces in their names. ```text !cast bless -t Rook -t Edmund -l 3 # casts Bless at 3rd level on Rook and Edmund, and attaches an effect to automatically add 1d4 !cast "fire bolt" -t BA3 # casts Fire Bolt at BA3 ``` -------------------------------- ### HP Modification Examples in Avrae Source: https://avrae.readthedocs.io/en/latest/cheatsheets/pc_combat Practical examples of using the HP modification commands, showing how to deal damage, set current HP, grant temporary HP, and heal using dice notation. ```text !g hp -5 # deals 5 damage !g hp set 100 # sets the character's HP to 100 !g thp 11 # gives the character 11 temp HP !g hp +2d4+2 # heals for 2d4+2 HP ``` -------------------------------- ### Avrae Attack Automation Example Source: https://avrae.readthedocs.io/en/latest/automation_ref A basic example of an attack automation in Avrae, targeting all creatures and applying damage on a hit. ```json [ { "type": "target", "target": "each", "effects": [ { "type": "attack", "attackBonus": "dexterityMod + proficiencyBonus", "hit": [ { "type": "damage", "damage": "1d10[piercing]" } ], "miss": [] } ] } ] ``` -------------------------------- ### Interacting with Attacks using AliasAttackList Source: https://avrae.readthedocs.io/en/latest/aliasing/api Provides examples of how to use the AliasAttackList class to manage a creature's attacks. This includes getting the total number of attacks, iterating through each attack, accessing attacks by index, and obtaining a string representation of all attacks. ```python len(creature._attacks) for attack in creature._attacks: print(attack) creature._attacks[0] str(creature._attacks) ``` -------------------------------- ### Attack Effect Example Source: https://avrae.readthedocs.io/en/latest/automation_ref An example demonstrating how to create an Attack effect, which can include damage on hit and other effects on miss. ```APIDOC ## POST /api/effects/attack ### Description Creates an Attack effect, typically used within a Target effect to simulate an attack roll. It defines actions to be taken on a successful hit and optionally on a miss. ### Method POST ### Endpoint /api/effects/attack ### Parameters #### Request Body - **type** (string) - Required - Must be 'attack'. - **attackBonus** (IntExpression) - Optional - Modifiers to the attack roll (e.g., 'dexterityMod + proficiencyBonus'). - **hit** (Effect[]) - Required - A list of effects to execute if the attack hits. - **miss** (Effect[]) - Optional - A list of effects to execute if the attack misses. ### Request Example ```json [ { "type": "target", "target": "each", "effects": [ { "type": "attack", "attackBonus": "dexterityMod + proficiencyBonus", "hit": [ { "type": "damage", "damage": "1d10[piercing]" } ], "miss": [] } ] } ] ``` ### Response #### Success Response (200) - **effect_id** (string) - The unique identifier for the created effect. #### Response Example ```json { "effect_id": "atk_e5f6g7h8" } ``` ``` -------------------------------- ### Avrae Servalias Example (drac2) Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/aliasing_tut.rst This is a complete example of an Avrae servalias command that constructs an embed. It involves fetching global variables, manipulating lists, rolling dice, and formatting the output string for the embed title. ```drac2 G = get_gvar("68c31679-634d-46de-999b-4e20b1f8b172") L = [x.split(",") for x in G.split("\n\n")] I = [x.pop(roll(f'1d{len(x)}-1')).title() for x in L] aL = L[0] + L[1] add = [aL.pop(roll(f'1d{len(aL)-1}')).title() for x in range(int("&1&".strip("&")))] I = [I[0], I[1]] + add + [I[2]] I = " ".join(I) ``` -------------------------------- ### Import Character Sheet to Avrae Source: https://avrae.readthedocs.io/en/latest/cheatsheets/get_started Imports a character sheet from various platforms into Avrae. This command requires a publicly viewable sharing URL of the character sheet. ```plaintext !import https://ddb.ac/characters/... ``` ```plaintext !import https://v1.dicecloud.com/character/... ``` ```plaintext !import https://dicecloud.com/character/... ``` ```plaintext !import https://docs.google.com/spreadsheets/d/... ``` -------------------------------- ### Start Avrae Embed Command Source: https://avrae.readthedocs.io/en/latest/aliasing/aliasing_tut This initiates the Avrae embed command, which is used to create formatted text boxes within Avrae. Refer to '!help embed' for more details on its usage. ```avrae embed ``` -------------------------------- ### Advance Combat Turn with !i next Source: https://avrae.readthedocs.io/en/latest/_sources/cheatsheets/dm_combat.rst Advances the combat to the next turn in the initiative order, starting the combat if it hasn't begun. Players are responsible for running their own actions on their turn. ```discord commands !i next ``` -------------------------------- ### Draconic Exception Handling Example (Text) Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/api.rst This example shows how to use try-except blocks in Draconic to handle potential errors during code execution. It demonstrates catching specific exceptions like 'ValueError' and 'TypeError' by providing their names as strings, and also shows how to catch any exception with a bare 'except'. ```text !test some_string = "123" try: return int(some_string) except ("ValueError", "TypeError"): return "I couldn't parse an int!" ``` -------------------------------- ### Create Servalias for Insult Command Source: https://avrae.readthedocs.io/en/latest/aliasing/aliasing_tut This code snippet defines a servalias named 'insult' that calls the 'embed' command. This is the initial setup for the custom command. ```avrae !servalias insult embed ``` -------------------------------- ### SimpleEffect Passive Effects Example (Text) Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/api.rst An example of the dictionary structure for passive effects applied to a combatant. It shows optional attributes like attack advantage and damage bonuses. ```text { attack_advantage: int to_hit_bonus: str damage_bonus: str magical_damage: bool silvered_damage: bool resistances: List[Resistance] immunities: List[Resistance] vulnerabilities: List[Resistance] ignored_resistances: List[Resistance] ac_value: int ac_bonus: int max_hp_value: int max_hp_bonus: int save_bonus: str save_adv: List[str] save_dis: List[str] check_bonus: str } Each attribute in the dictionary is optional and may not be present. ``` -------------------------------- ### Get Initiative Metadata Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates retrieving initiative metadata using the `SimpleCombat.get_metadata()` method in Python. This function accesses the key-value store associated with an ongoing initiative, useful for retrieving combatant-specific data. ```python SimpleCombat.get_metadata("key") ``` -------------------------------- ### Avrae API - W Section Source: https://avrae.readthedocs.io/en/latest/genindex Details methods and properties starting with 'W' in the Avrae API. ```APIDOC ## Avrae API - W Section ### Description This section details various classes, methods, and properties within the Avrae API that begin with the letter 'W'. It specifically covers the 'wisdom' attribute related to base stats and skills. ### Methods and Properties - **wisdom** (AliasBaseStats property) - (AliasSkills attribute) ``` -------------------------------- ### Avrae API - S Section Source: https://avrae.readthedocs.io/en/latest/genindex Details methods and properties starting with 'S' in the Avrae API. ```APIDOC ## Avrae API - S Section ### Description This section details various classes, methods, and properties within the Avrae API that begin with the letter 'S'. It covers functionalities related to spells, combat, character stats, and more. ### Methods and Properties - **sab** (AliasSpellbook property) - **Save** (built-in class) - **save()** (SimpleCombatant method) - **save_adv** (PassiveEffects attribute) - **save_as** (IEffect attribute) - **save_bonus** (PassiveEffects attribute) - **save_dis** (PassiveEffects attribute) - **saves** (AliasCharacter property) - (AliasStatBlock property) - (SimpleCombatant property) - **servsettings()** (AliasGuild method) - **set()** (AliasCustomCounter method) - **set_ac()** (SimpleCombatant method) - **set_cc()** (AliasCharacter method) - **set_coins()** (AliasCoinpurse method) - **set_context()** (ParsedArguments method) - **set_cvar()** (AliasCharacter method) - **set_cvar_nx()** (AliasCharacter method) - **set_group()** (SimpleCombatant method) - **set_hp()** (AliasCharacter method) - (AliasStatBlock method) - (SimpleCombatant method) - **set_init()** (SimpleCombatant method) - (SimpleGroup method) - **set_maxhp()** (SimpleCombatant method) - **set_metadata()** (SimpleCombat method) - **set_name()** (SimpleCombatant method) - **set_note()** (SimpleCombatant method) - **set_parent()** (SimpleEffect method) - **set_round()** (SimpleCombat method) - **set_slots()** (AliasSpellbook method) - **set_temp_hp()** (AliasCharacter method) - (AliasStatBlock method) - (SimpleCombatant method) - **set_uvar()** (in module aliasing.evaluators.ScriptingEvaluator) - **set_uvar_nx()** (in module aliasing.evaluators.ScriptingEvaluator) - **SetVariable** (built-in class) - **sheet_type** (AliasCharacter property) - **signature()** (in module aliasing.evaluators.ScriptingEvaluator) - **silvered_damage** (PassiveEffects attribute) - **SimpleCombat** (class in aliasing.api.combat) - **SimpleCombatant** (class in aliasing.api.combat) - **SimpleEffect** (class in aliasing.api.combat) - **SimpleGroup** (class in aliasing.api.combat) - **SimpleRollResult** (class in aliasing.api.functions) - **skills** (AliasCharacter property) - (AliasStatBlock property) - (SimpleCombatant property) - **sleightOfHand** (AliasSkills attribute) - **slot** (SpellSlotReference attribute) - **slots_str()** (AliasSpellbook method) - **snippet** (AliasAction property) - **sortBy** (Target attribute) - **sp** (AliasCoinpurse attribute) - **spell_mod** (AliasSpellbook property) - **spellbook** (AliasCharacter property) - (AliasStatBlock property) - (SimpleCombatant property) - **spells** (AliasSpellbook property) - **SpellSlotReference** (built-in class) - **sqrt()** (built-in function) - **stacking** (IEffect attribute) - **stat** (Save attribute) - **stats** (AliasCharacter property) - (AliasStatBlock property) - (SimpleCombatant property) - **stealth** (AliasSkills attribute) - **str** (AliasAttack attribute) - (AliasAttackList attribute) - (AliasCoinpurse attribute) - **str()** (built-in function) - **strength** (AliasBaseStats property) - (AliasSkills attribute) - **style** (ButtonInteraction attribute) - **succeed()** (AliasDeathSaves method) - **success** (Check attribute) - (Save attribute) - **successes** (AliasDeathSaves property) - **sum()** (built-in function) - **survival** (AliasSkills attribute) ``` -------------------------------- ### Set Avrae Command Prefix Source: https://avrae.readthedocs.io/en/latest/cheatsheets/get_started Allows users to change the command prefix for Avrae to avoid conflicts with other bots. This is an optional step after inviting Avrae to your server. ```plaintext !prefix ``` -------------------------------- ### Avrae Argument Expansion: %* Source: https://avrae.readthedocs.io/en/latest/aliasing/api Shows how to use the '%*' placeholder in Avrae aliases to expand all arguments into separate words. This is useful when you want to treat each argument as an individual string. ```draconic echo %*& words ``` -------------------------------- ### Perform Skill Checks, Saves, and Attacks with Avrae Source: https://avrae.readthedocs.io/en/latest/cheatsheets/get_started Commands to perform common D&D actions within Discord using Avrae. These commands allow for rolling skill checks, saving throws, and weapon attacks. ```plaintext !check arcana ``` ```plaintext !save dexterity ``` ```plaintext !attack longsword ``` -------------------------------- ### Draconic Module Structure Example (Python) Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/api.rst This code snippet demonstrates the recommended format for writing Draconic modules. It includes comments for module description, constants, and functions, along with docstrings for detailed explanations. Modules should not be wrapped in delimiters like . ```python # recommended_module_name # This is a short description about what the module does. # # SOME_CONSTANT: some documentation about what this constant is # some_function(show, the, args): some short documentation about what this function does # and how to call it # wow, this is long! use indentation if you need multiple lines # but otherwise longer documentation should go in the function's """docstring""" SOME_CONSTANT = 3.141592 def some_function(show, the, args): """Here is where the longer documentation about the function can go.""" pass ``` -------------------------------- ### Importing a Single Module in Draconic Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates how to import a single module using the `using()` function in Draconic. The imported module is aliased to a namespace for access to its contents. Ensure the module address is correct. ```draconic !alias hello-world echo using( hello="50943a96-381b-427e-adb9-eea8ebf61f27" ) return hello.hello() ``` -------------------------------- ### Avrae Attack Effect Example Source: https://avrae.readthedocs.io/en/latest/_sources/automation_ref.rst An example of a basic attack effect within Avrae's JSON automation structure. This effect targets all entities and applies an attack. ```json [ { "type": "target", "target": "each", "effects": [ { "type": "attack" } ] } ] ``` -------------------------------- ### Sum Items in Iterable (Python) Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/api.rst Sums the items of an iterable, optionally starting with a given value (defaults to 0). The iterable's items are typically numbers, and the start value cannot be a string. ```python sum(iterable[, start]) ``` -------------------------------- ### Automation Reference - Basic Structure Source: https://avrae.readthedocs.io/en/latest/automation_ref Explains the fundamental structure of Avrae's automation system, which is composed of a tree of effects or nodes. ```APIDOC ## Automation Reference - Basic Structure ### Description An automation run is made up of a list of _effects_ (AKA _automation node_), each of which may have additional _effects_ that it runs under certain conditions. This recursive structure is called the _automation tree_. **Glossary** * **automation engine**: The Automation Engine is the code responsible for reading the automation tree and executing it against the current game state. It handles rolling the dice, checking against your targets’ armor classes, modifying hit points, and other game mechanics. * **automation tree**: The automation tree (sometimes just called “automation”) is the program that the Automation Engine runs. It’s made up of multiple nodes that all link together to make an attack, action, spell, or more. * **effect** / **node**: A single step of automation - usually, this is a D&D game mechanic like rolling to hit, making a saving throw, or dealing damage, but this can also be used in more programmatic ways to help set up other nodes. ``` -------------------------------- ### Generating Number Sequences (Python) Source: https://avrae.readthedocs.io/en/latest/aliasing/api The range() function generates a sequence of numbers. It can take a stop value, or start, stop, and step values. The step defaults to 1, and start defaults to 0. A step of zero raises a ValueError. ```python list(range(5)) # Returns: [0, 1, 2, 3, 4] list(range(2, 8)) # Returns: [2, 3, 4, 5, 6, 7] list(range(1, 10, 2)) # Returns: [1, 3, 5, 7, 9] ``` -------------------------------- ### Get Argument Values from ParsedArguments Source: https://avrae.readthedocs.io/en/latest/aliasing/api The `get` method retrieves a list of all values for a specified argument. It supports default values, type casting for each value in the list, and optionally includes ephemeral arguments. If the argument is not found, the default value is returned. ```python def get(_arg_ , _default=None_ , _type_= _, _ephem=False_) -> list: """ Gets a list of all values of an argument. Parameters ---------- arg (_str_) – The name of the arg to get. default – The default value to return if the arg is not found. Not cast to type. type_ (_type_) – The type that each value in the list should be returned as. ephem (_bool_) – Whether to add applicable ephemeral arguments to the returned list. Returns ------- The relevant argument list. Return type ----------- list """ pass ``` -------------------------------- ### Set Initiative Metadata Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates setting initiative metadata using the `SimpleCombat.set_metadata()` method in Python. Initiative metadata is a key-value store attached to an ongoing initiative in a channel, used for programmatic information about combatants. ```python SimpleCombat.set_metadata("key", "value") ``` -------------------------------- ### Importing Multiple Modules in Draconic Source: https://avrae.readthedocs.io/en/latest/aliasing/api Shows how to import multiple modules simultaneously in Draconic using the `using()` function. Each module is assigned a unique alias for independent access to their functions and constants. This allows for combining functionality from different sources. ```draconic !alias hello-world echo using( hello="50943a96-381b-427e-adb9-eea8ebf61f27", hello_utils="0bbddb9f-c86f-4af8-9e04-1964425b1554" ) return f"{hello.hello('you')}\n{hello_utils.hello_to_my_character()}" ``` -------------------------------- ### Generate Random Integer Source: https://avrae.readthedocs.io/en/latest/_sources/aliasing/api.rst Generates a random integer within a specified range. It supports optional start, stop, and step parameters. Raises ValueError if the step is zero. The range is inclusive of the start and exclusive of the stop. ```python randint(stop) randint(start, stop[, step]) ``` -------------------------------- ### SimpleEffect Methods Source: https://avrae.readthedocs.io/en/latest/aliasing/api This section details the methods of the SimpleEffect class, including how to set a parent effect. ```APIDOC ## SimpleEffect Methods ### Description Methods available for manipulating SimpleEffect objects. ### Methods - **set_parent(_parent_)** - Sets the parent effect of this effect. - **Parameters**: - **parent** (`SimpleEffect`) - The parent. ``` -------------------------------- ### Generate Random Integers with randint Source: https://avrae.readthedocs.io/en/latest/aliasing/api Generates a random integer within a specified range. The function supports defining a start, stop, and optional step value. If start is omitted, it defaults to 0. If step is omitted, it defaults to 1. A ValueError is raised if the step is zero. ```python randint(_stop_) randint(_start_ , _stop_[, _step_]) ``` -------------------------------- ### Create Global Variable (Gvar) via Command Source: https://avrae.readthedocs.io/en/latest/aliasing/api Illustrates creating a global variable (gvar) using the Avrae command-line interface. Gvars are uniquely named and accessible anywhere. This command creates a new gvar with the specified value. ```bash !gvar create ``` -------------------------------- ### Draconic Argument Parsing Source: https://avrae.readthedocs.io/en/latest/index Demonstrates how Draconic handles argument parsing, allowing commands to accept and process user-provided input. ```draconic @command("attack", {target: "@target"}) ``` -------------------------------- ### Sum Iterable Source: https://avrae.readthedocs.io/en/latest/aliasing/api Sums the items of an iterable, optionally starting from a specified value. ```APIDOC ## Sum Iterable ### Description Sums the items of an iterable, optionally starting from a specified value. The iterable's items are normally numbers, and the start value is not allowed to be a string. ### Method N/A (This is a function description, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for this function" } ``` ### Response #### Success Response (200) - **total** (number) - The sum of the iterable's items and the start value. #### Response Example ```json { "example": "10" } ``` ``` -------------------------------- ### AliasResistances Class Documentation Source: https://avrae.readthedocs.io/en/latest/aliasing/api Documentation for the AliasResistances class, managing a statblock's resistances, immunities, vulnerabilities, and explicit neural damage types. It includes methods to check for immunity, neutrality, resistance, and vulnerability to specific damage types. ```python class _AliasResistances: """A statblock’s resistances, immunities, vulnerabilities, and explicit neural damage types.""" @property def _immune(self) -> list[Resistance]: """A list of damage types that the stat block is immune to.""" pass def is_immune(self, _damage_type: str) -> bool: """Whether or not this AliasResistances contains any immunities that apply to the given damage type string.""" pass def is_neutral(self, _damage_type: str) -> bool: """Whether or not this AliasResistances contains any neutrals that apply to the given damage type string.""" pass def is_resistant(self, _damage_type: str) -> bool: """Whether or not this AliasResistances contains any resistances that apply to the given damage type string.""" pass def is_vulnerable(self, _damage_type: str) -> bool: """Whether or not this AliasResistances contains any vulnerabilities that apply to the given damage type string.""" pass @property def _neutral(self) -> list[Resistance]: """A list of damage types that the stat block ignores in damage calculations.""" pass @property def _resist(self) -> list[Resistance]: """A list of damage types that the stat block is resistant to.""" pass @property def _vuln(self) -> list[Resistance]: """A list of damage types that the stat block is vulnerable to.""" pass ``` -------------------------------- ### Working with Class Levels using AliasLevels Source: https://avrae.readthedocs.io/en/latest/aliasing/api Explains how to interact with the AliasLevels class to manage a creature's class levels. This includes iterating through classes and their corresponding levels, retrieving the total level, and getting the number of levels in a specific class with an optional default value. ```python for cls, level in creature._levels: print(f"Class: {cls}, Level: {level}") creature._levels._total_level creature._levels.get('Fighter') creature._levels.get('Wizard', 0) ``` -------------------------------- ### Get Epoch Time Source: https://avrae.readthedocs.io/en/latest/aliasing/api Returns the current time in seconds since the UNIX epoch. ```APIDOC ## Get Epoch Time ### Description Returns the time in seconds since the UNIX epoch (Jan 1, 1970, midnight UTC) as a floating point number. ### Method N/A (This is a function description, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for this function" } ``` ### Response #### Success Response (200) - **epoch_time** (float) - The time in seconds since the UNIX epoch. #### Response Example ```json { "example": "1678886400.1234567" } ``` ``` -------------------------------- ### Importing Modules Source: https://avrae.readthedocs.io/en/latest/aliasing/api Imports Draconic global variables as modules into the current namespace. ```APIDOC ## Importing Modules ### Description Imports Draconic global variables as modules into the current namespace. This should typically be the first statement in a code block if imports are used. Use caution and import only from trusted sources. ### Method `using(**imports)` ### Parameters - `**imports` - Variable number of keyword arguments, where each keyword is the name to assign the imported module and the value is the module identifier. ### Example ```python >>> using( ... hello="50943a96-381b-427e-adb9-eea8ebf61f27" ... ) >>> hello.hello() "Hello world!" ``` ``` -------------------------------- ### Avrae API - T Section Source: https://avrae.readthedocs.io/en/latest/genindex Details methods and properties starting with 'T' in the Avrae API. ```APIDOC ## Avrae API - T Section ### Description This section details various classes, methods, and properties within the Avrae API that begin with the letter 'T'. It covers functionalities related to targeting, temporary hit points, text manipulation, and combat turns. ### Methods and Properties - **Target** (built-in class) - **target** (Target attribute) - **target_self** (IEffect attribute) - **temp_hp** (AliasCharacter property) - (AliasStatBlock property) - (SimpleCombatant property) - **TempHP** (built-in class) - **Text** (built-in class) - **text** (Text attribute) - **thumb** (AttackModel attribute) - **tick_on_caster** (IEffect attribute) - **ticks_on_end** (SimpleEffect attribute) - **time()** (built-in function) - **title** (AliasCustomCounter property) - (Text attribute) - **to_hit_bonus** (PassiveEffects attribute) - **topic** (AliasChannel property) - **total** (AliasCoinpurse property) - (SimpleRollResult attribute) - **total_level** (AliasLevels property) - **turn_num** (SimpleCombat attribute) - **type** (SimpleCombatant attribute) - (SimpleGroup attribute) - **typeId** (AbilityReference attribute) - **typeof()** (in module aliasing.api.functions) ``` -------------------------------- ### Context Models API Source: https://avrae.readthedocs.io/en/latest/aliasing/api Provides context information about the environment where an alias is invoked. ```APIDOC ## Context Models ### AliasContext Class #### Description Used to expose information about the context, such as guild name, channel name, author name, and current prefix to alias authors. - **Properties** - `alias` (str) - The name the alias was invoked with. - `author` (`AliasAuthor`) - The user that ran the alias. - `channel` (`AliasChannel`) - The channel the alias was run in. - `guild` (`AliasGuild` or None) - The Discord guild the alias was run in, or None if run in DMs. - `message_id` (int) - The ID of the message the alias was invoked with. - `prefix` (str) - The prefix used to run the alias. ### AliasGuild Class #### Description Represents the Discord guild (server) an alias was invoked in. - **Properties** - `id` (int) - The ID of the guild. - `name` (str) - The name of the guild. #### Methods ##### `servsettings()` Retrieves and returns the dict of server settings. Not present when retrieving from verify_signature. - **Returns** A dict of server settings. - **Return type** dict or None ``` -------------------------------- ### Accessing Creature Stats with AliasStatBlock Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates how to access various properties of a creature's stat block using the AliasStatBlock class. This includes retrieving armor class, current and maximum HP, creature type, and name. It also shows how to access more complex data structures like attacks, levels, resistances, saves, skills, spellbook, and base stats. ```python creature._ac creature._hp creature._max_hp creature._creature_type creature._name creature._attacks creature._levels creature._resistances creature._saves creature._skills creature._spellbook creature._stats ``` -------------------------------- ### Avrae API - V Section Source: https://avrae.readthedocs.io/en/latest/genindex Details methods and properties starting with 'V' in the Avrae API. ```APIDOC ## Avrae API - V Section ### Description This section details various classes, methods, and properties within the Avrae API that begin with the letter 'V'. It covers functionalities related to values, verbs, verification, and vulnerabilities. ### Methods and Properties - **value** (AliasCustomCounter property) - (AliasSkill property) - (SetVariable attribute) - **verb** (AliasAttack property) - (AttackModel attribute) - (ButtonInteraction attribute) - **verify_signature()** (in module aliasing.evaluators.ScriptingEvaluator) - **vroll()** (in module aliasing.api.functions) - **vuln** (AliasResistances property) - **vulnerabilities** (PassiveEffects attribute) ``` -------------------------------- ### Add Generic Combatants with !i add Source: https://avrae.readthedocs.io/en/latest/_sources/cheatsheets/dm_combat.rst Adds generic combatants without a character sheet, such as lair actions or homebrew monsters. Requires an initiative modifier and a name. Can hide stats like HP and AC using the '-h' flag. ```discord commands !i add [arguments] ``` ```discord commands !i add -h ``` ```discord commands !i add 20 "Lair Action" -p ``` ```discord commands !i add 0 Longboat -ac 15 -hp 300 ``` -------------------------------- ### Avrae API - U Section Source: https://avrae.readthedocs.io/en/latest/genindex Details methods and properties starting with 'U' in the Avrae API. ```APIDOC ## Avrae API - U Section ### Description This section details various classes, methods, and properties within the Avrae API that begin with the letter 'U'. It covers functionalities related to conditional logic, updating arguments, and user variables. ### Methods and Properties - **unless** (Resistance attribute) - **update()** (ParsedArguments method) - **update_nx()** (ParsedArguments method) - **upstream** (AliasCharacter property) - **use_slot()** (AliasSpellbook method) - **UseCounter** (built-in class) - **using()** (in module aliasing.evaluators.ScriptingEvaluator) - **uvar_exists()** (in module aliasing.evaluators.ScriptingEvaluator) ``` -------------------------------- ### Avrae List Literal: &ARGS& Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates the use of the '&ARGS&' placeholder in Avrae aliases to represent all provided arguments as a list. This is useful for processing multiple arguments within Draconic code. ```draconic echo &ARGS& ``` -------------------------------- ### Ending Your Turn Source: https://avrae.readthedocs.io/en/latest/cheatsheets/pc_combat Advances the combat turn to the next participant. ```APIDOC ## POST /i next ### Description Ends the current combatant's turn and advances to the next person in the initiative order. ### Method POST ### Endpoint `/i next` ### Parameters None ### Request Example ```json { "command": "!i next" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation that the turn has ended. #### Response Example ```json { "message": "Turn ended. It is now [Next Combatant]'s turn." } ``` ``` -------------------------------- ### Avrae Alias Example: Orc Relentless Endurance Source: https://avrae.readthedocs.io/en/latest/aliasing/aliasing_tut This is a complete example of an Avrae alias that implements the 'Orc Relentless Endurance' racial trait. It includes defining variables, checking conditions using if/elif/else, modifying character state (HP and custom counters), and formatting an embed message for output. The alias uses custom counters and checks character HP to determine if the ability can be used. ```python #Define variables for later use cc = "Relentless Endurance" desc = "When you are reduced to 0 hit points but not killed outright, you can drop to 1 hit point instead." rest = "You can’t use this feature again until you finish a long rest." hasHP = "You have not been reduced to 0 hit points." noCC = "You do not have this ability." ch=character() #Create the counter if it should exist but doesn't already if ch.race.lower() == "half-orc": ch.create_cc_nx(cc, 0, 1, "long", "bubble", None, None, cc, desc+" "+rest) #Logic of the alias. Check for all the necessary conditions succ = "tries to use" if ch.cc_exists(cc) and ch.get_cc(cc) and not ch.hp: succ = "uses" D = desc ch.mod_cc(cc, -1) ch.set_hp(1) elif ch.hp: D = hasHP elif ch.cc_exists(cc): D = rest else: D = noCC #Prepare the output T = f"{name} {succ} {cc}!" F = f"{cc}|{ch.cc_str(cc) if ch.cc_exists(cc) else '*None*'}" ``` -------------------------------- ### SimpleCombat Metadata API Source: https://avrae.readthedocs.io/en/latest/aliasing/api Manage metadata associated with a SimpleCombat instance. This includes setting, getting, and deleting key-value pairs. ```APIDOC ## SimpleCombat Metadata API ### Description Provides methods to interact with the metadata of a SimpleCombat object, allowing for storage and retrieval of arbitrary key-value data. ### Methods #### `delete_metadata(k: str) -> Optional[str]` Removes a key from the metadata. - **Parameters** - **k** (str) - Required - The metadata key to remove. - **Returns** - Optional[str] - The removed value or `None` if the key is not found. - **Example** ```python combat.delete_metadata("Test") ``` #### `get_metadata(k: str, default=None) -> str` Gets a metadata value for the passed key or returns `default` if the name is not set. - **Parameters** - **k** (str) - Required - The metadata key to get. - **default** - Optional - What to return if the name is not set. - **Returns** - str - The metadata value associated with the key. - **Example** ```python combat.get_metadata("Test") ``` #### `set_metadata(k: str, v: str)` Assigns a metadata key to the passed value. Maximum size of the metadata is 100k characters, key and item inclusive. - **Parameters** - **k** (str) - Required - The metadata key to set. - **v** (str) - Required - The metadata value to set. - **Example** ```python combat.set_metadata("Test", dump_json({"Status": ["Mario", 1, 2]})) ``` ``` -------------------------------- ### Avrae Argument Expansion: &1& Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates the use of '&1&' in Avrae aliases to reference the first argument. This is useful for directly accessing and manipulating specific arguments within your alias. ```draconic echo &1& was the first arg ``` -------------------------------- ### Accessing Base Stats with AliasBaseStats Source: https://avrae.readthedocs.io/en/latest/aliasing/api Demonstrates how to retrieve individual ability scores (strength, dexterity, constitution, intelligence, wisdom, charisma) and the proficiency bonus from an AliasBaseStats object. It also shows how to get the integer value of a specific stat and its corresponding modifier. ```python stats._strength stats._dexterity stats._constitution stats._intelligence stats._wisdom stats._charisma stats._prof_bonus stats.get('strength') stats.get_mod('dexterity') ``` -------------------------------- ### Get Object Type Name (Python) Source: https://avrae.readthedocs.io/en/latest/aliasing/api Returns the string name of the type of a given object. This is a utility function for introspection. ```python def typeof(inst): """ Returns the name of the type of an object. Parameters inst – The object to find the type of. Returns The type of the object. """ return type(inst).__name__ ``` -------------------------------- ### Combine Insult Components with Additional Random Elements Source: https://avrae.readthedocs.io/en/latest/aliasing/aliasing_tut This Avrae script combines pre-selected insult components with additional randomly chosen elements. The number of additional elements is determined by the first argument passed to the command, with a default of one. ```avrae aL = L[0] + L[1] add = [aL.pop(roll(f'1d{len(aL)-1}')).title() for x in range(int("&1&".strip("&")))] I = [I[0], I[1]] + add + [I[2]] ``` -------------------------------- ### Start Drac2 Code Block Source: https://avrae.readthedocs.io/en/latest/aliasing/aliasing_tut This signifies the beginning of a code block that will contain the logic for the Avrae alias, written in Drac2. ```drac2 ``` -------------------------------- ### Python Scripting: Writing Modules Source: https://avrae.readthedocs.io/en/latest/index This snippet shows the basic structure of writing a Python module that can be imported and used within Avrae's scripting environment. ```python def my_function(arg1, arg2): # Function logic here return result ``` -------------------------------- ### Attacking Source: https://avrae.readthedocs.io/en/latest/cheatsheets/pc_combat Perform attacks against targets during combat. This command can be used even when it's not your turn. ```APIDOC ## POST /attack ### Description Initiates an attack against one or more targets. This command works both during and outside of your turn. ### Method POST ### Endpoint `/attack -t [arguments]` ### Parameters #### Query Parameters - **** (string) - Required - The name of the attack to perform. - **-t ** (string) - Required - The name of the target. Can be specified multiple times for multi-target attacks. - **adv/dis** (flag) - Optional - Grants advantage/disadvantage on the attack roll. - **-rr <#>** (integer) - Optional - Rolls the attack a specified number of times. ### Request Example ```json { "command": "!attack dagger -t KO1 -rr 2" } ``` ### Response #### Success Response (200) - **results** (array) - Details of the attack rolls and outcomes. #### Response Example ```json { "results": [ { "target": "KO1", "attack_roll": "1d20+5", "damage_roll": "1d4+3" } ] } ``` ```