Пример #1
0
    def add_effect(self,
                   name: str,
                   args: str,
                   duration: int = -1,
                   concentration: bool = False,
                   parent=None,
                   end: bool = False):
        """
        Adds an effect to the combatant.

        :param str name: The name of the effect to add.
        :param str args: The effect arguments to add (same syntax as init effect).
        :param int duration: The duration of the effect, in rounds.
        :param bool concentration: Whether the effect requires concentration.
        :param parent: The parent of the effect.
        :type parent: :class:`~cogs5e.funcs.scripting.combat.SimpleEffect`
        :param bool end: Whether the effect ticks on the end of turn.
        """
        existing = self._combatant.get_effect(name, True)
        if existing:
            existing.remove()
        effectObj = Effect.new(self._combatant.combat,
                               self._combatant,
                               duration=duration,
                               name=name,
                               effect_args=args,
                               concentration=concentration,
                               tick_on_end=end)
        if parent:
            effectObj.set_parent(parent._effect)
        self._combatant.add_effect(effectObj)
Пример #2
0
    async def effect(self, ctx, name: str, effect_name: str, *args):
        """Attaches a status effect to a combatant.
        [args] is a set of args that affects a combatant in combat.
        __**Valid Arguments**__
        -dur [duration] - sets the duration of the effect, in rounds
        conc - makes effect require conc
        end - makes effect tick on end of turn
        -t [target] - specifies more combatants to add this effect to
        __Attacks__
        -b [bonus] (see !a)
        -d [damage bonus] (see !a)
        -attack "[hit]|[damage]|[description]" - Adds an attack to the combatant
        __Resists__
        -resist [resist] - gives the combatant resistance
        -immune [immune] - gives the combatant immunity
        -vuln [vulnability] - gives the combatant vulnerability
        -neutral [neutral] - removes immune/resist/vuln
        __General__
        -ac [ac] - modifies ac temporarily; adds if starts with +/- or sets otherwise
        -sb [save bonus] - Adds a bonus to saving throws"""
        combat = await Combat.from_ctx(ctx)
        args = argparse(args)

        targets = []
        first_target = await combat.select_combatant(name)
        if first_target is None:
            await ctx.send("Combatant not found.")
            return
        targets.append(first_target)

        for i, t in enumerate(args.get('t')):
            target = await combat.select_combatant(t, f"Select target #{i + 1}.", select_group=True)
            if isinstance(target, CombatantGroup):
                targets.extend(target.get_combatants())
            else:
                targets.append(target)

        duration = args.last('dur', -1, int)
        conc = args.last('conc', False, bool)
        end = args.last('end', False, bool)

        embed = EmbedWithAuthor(ctx)
        for combatant in targets:
            if effect_name.lower() in (e.name.lower() for e in combatant.get_effects()):
                out = "Effect already exists."
            else:
                effectObj = Effect.new(combat, combatant, duration=duration, name=effect_name, effect_args=args,
                                       concentration=conc, tick_on_end=end)
                result = combatant.add_effect(effectObj)
                out = "Added effect {} to {}.".format(effect_name, combatant.name)
                if result['conc_conflict']:
                    conflicts = [e.name for e in result['conc_conflict']]
                    out += f"\nRemoved {', '.join(conflicts)} due to concentration conflict!"
            embed.add_field(name=combatant.name, value=out)
        await ctx.send(embed=embed, delete_after=10 * len(targets))
        await combat.final()
Пример #3
0
    async def effect(self,
                     ctx,
                     name: str,
                     effect_name: str,
                     *,
                     args: str = ''):
        """Attaches a status effect to a combatant.
        [args] is a set of args that affects a combatant in combat.
        __**Valid Arguments**__
        -dur [duration]
        conc (makes effect require conc)
        end (makes effect tick on end of turn)
        __Attacks__
        -b [bonus] (see !a)
        -d [damage bonus] (see !a)
        -attack "[hit]|[damage]|[description]" (Adds an attack to the combatant)
        __Resists__
        -resist [resist] (gives the combatant resistance)
        -immune [immune] (gives the combatant immunity)
        -vuln [vulnability] (gives the combatant vulnerability)
        -neutral [neutral] (removes immune/resist/vuln)
        __General__
        -ac [ac] (modifies ac temporarily; adds if starts with +/- or sets otherwise)
        -sb [save bonus] (Adds a bonus to saving throws)"""
        combat = await Combat.from_ctx(ctx)
        combatant = await combat.select_combatant(name)
        if combatant is None:
            await ctx.send("Combatant not found.")
            return

        if effect_name.lower() in (e.name.lower()
                                   for e in combatant.get_effects()):
            return await ctx.send("Effect already exists.", delete_after=10)

        if isinstance(combatant, PlayerCombatant):
            args = argparse(args, combatant.character)
        else:
            args = argparse(args)
        duration = args.last('dur', -1, int)
        conc = args.last('conc', False, bool)
        end = args.last('end', False, bool)

        effectObj = Effect.new(combat,
                               combatant,
                               duration=duration,
                               name=effect_name,
                               effect_args=args,
                               concentration=conc,
                               tick_on_end=end)
        result = combatant.add_effect(effectObj)
        out = "Added effect {} to {}.".format(effect_name, combatant.name)
        if result['conc_conflict']:
            conflicts = [e.name for e in result['conc_conflict']]
            out += f"\nRemoved {', '.join(conflicts)} due to concentration conflict!"
        await ctx.send(out, delete_after=10)
        await combat.final()
Пример #4
0
 def add_effect(self, name: str, args: str, duration: int = -1, concentration: bool = False, parent=None,
                end: bool = False):
     existing = self._combatant.get_effect(name, True)
     if existing:
         existing.remove()
     effectObj = Effect.new(self._combatant.combat, self._combatant, duration=duration, name=name, effect_args=args,
                            concentration=concentration, tick_on_end=end)
     if parent:
         effectObj.set_parent(parent._effect)
     self._combatant.add_effect(effectObj)
Пример #5
0
 async def setup(self, ctx, state_map):
     combat = await ctx.get_combat()
     pc = await get_pc(ctx)
     effect_obj = Effect.new(
         combat,
         pc,
         name="Future Lunch",
         duration=-1,
         effect_args=argparse('-vuln piercing -vuln acid'),
         desc="A hungry tarrasque has your scent!")
     pc.add_effect(effect_obj)
     await ctx.send(f"Added effect Future Lunch to {pc.name}.")
     await combat.final()
Пример #6
0
    def add_effect(self,
                   name: str,
                   args: str,
                   duration: int = -1,
                   concentration: bool = False,
                   parent=None,
                   end: bool = False,
                   desc: str = None):
        """
        Adds an effect to the combatant.

        :param str name: The name of the effect to add.
        :param str args: The effect arguments to add (same syntax as [!init effect](https://avrae.io/commands#init-effect)).
        :param int duration: The duration of the effect, in rounds.
        :param bool concentration: Whether the effect requires concentration.
        :param parent: The parent of the effect.
        :type parent: :class:`~aliasing.api.combat.SimpleEffect`
        :param bool end: Whether the effect ticks on the end of turn.
        :param str desc: A description of the effect.
        """  # noqa: E501
        name, args, duration = str(name), str(args), int(duration)
        if desc is not None:
            desc = str(desc)

        existing = self._combatant.get_effect(name, True)
        if existing:
            existing.remove()
        effectObj = Effect.new(self._combatant.combat,
                               self._combatant,
                               duration=duration,
                               name=name,
                               effect_args=args,
                               concentration=concentration,
                               tick_on_end=end,
                               desc=desc)
        if parent:
            effectObj.set_parent(parent._effect)
        self._combatant.add_effect(effectObj)
        self._update_effects()