Ejemplo n.º 1
0
        /// <summary>
        /// Assigns debuff spells from the Poet's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Poet.</param>
        public PoetDebuffCommands(PoetClient self) : base(self)
        {
            _self = self;

            _atoneSpell      = _self.Spells.KeySpells.Atone;
            _removeVeilSpell = _self.Spells.KeySpells.RemoveVeil;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether or not a spell target is currently off-screen. This is used to
        /// determine whether or not a spell can be cast on the target if attempted. Please
        /// note that this is unreliable when the caster is off-center in the map due to being
        /// near one or more of its edges. In that case, it is quite possible for a target to
        /// be on-screen but still be out of range for spells. There is some risk of the bot
        /// getting stuck repeatedly attempting to cast a spell on a multibox group member
        /// target that it thinks is within range. There is also risk of the bot thinking it
        /// successfully cast a spell on an external group member or NPC target when it did
        /// not. It is best practice to keep the caster centered within the screen as often as
        /// possible.
        /// </summary>
        /// <param name="targetUid">The UID of the target.</param>
        /// <param name="targetableSpell">Any targetable spell.</param>
        /// <returns>True if the target is off-screen; false otherwise.</returns>
        public async Task <bool> IsTargetOffScreen(uint targetUid, KeySpell targetableSpell)
        {
            if (targetableSpell == null)
            {
                throw new ArgumentNullException(nameof(targetableSpell), "Cannot determine whether or not a target is off-screen without a targetable spell.");
            }

            Targeting.Item  = targetUid;
            Targeting.Spell = targetUid;

            if (targetUid == Self.Uid)
            {
                return(false);
            }

            var spellOrItemKey = targetableSpell.IsOrbSpell
                ? "u"
                : "Z";

            var keys = $"{Keys.Esc}{spellOrItemKey}{targetableSpell.Letter}{Keys.Esc}";

            Send(keys);

            await Task.Delay(20);

            if (targetableSpell.IsOrbSpell)
            {
                return(Targeting.Item == Self.Uid);
            }

            return(Targeting.Spell == Self.Uid);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Assigns Harden Armor, Sanctuary, and Valor spells from the Poet's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Poet.</param>
 public CasterAsvCommands(PoetClient self)
 {
     _self             = self;
     _hardenArmorSpell = self.Spells.KeySpells.HardenArmor;
     _sanctuarySpell   = self.Spells.KeySpells.Sanctuary;
     _valorSpell       = self.Spells.KeySpells.Valor;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Assigns mana restoration spells from a Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        protected CasterManaCommands(MageClient self)
        {
            Self = self;

            InvokeSpell  = self.Spells.KeySpells.Invoke;
            InvokeStatus = self.Status.Invoke;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Assigns attack spells from the Warrior's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Warrior.</param>
 public WarriorAttackCommands(WarriorClient self) : base(self)
 {
     _berserkSpell    = self.Spells.KeySpells.Berserk;
     _berserkStatus   = self.Status.Berserk;
     _whirlwindSpell  = self.Spells.KeySpells.Whirlwind;
     _whirlwindStatus = self.Status.Whirlwind;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Assigns attack spells from the Rogue's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Rogue.</param>
 public RogueAttackCommands(RogueClient self) : base(self)
 {
     _ambushSpell           = self.Spells.KeySpells.Ambush;
     _desperateAttackSpell  = self.Spells.KeySpells.DesperateAttack;
     _desperateAttackStatus = self.Status.DesperateAttack;
     _lethalStrikeSpell     = self.Spells.KeySpells.LethalStrike;
     _lethalStrikeStatus    = self.Status.LethalStrike;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// /// Assigns spells and items from the Warrior's spell and item inventories.
        /// </summary>
        /// <param name="self">The game client data for the Warrior.</param>
        protected PeasantCommands(WarriorClient self)
        {
            Self          = self;
            _gatewaySpell = self.Spells.KeySpells.Gateway;

            Items    = new PeasantItemCommands(self);
            Movement = new PeasantMovementCommands(self);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// /// Assigns spells and items from the Peasant's spell and item inventories.
        /// </summary>
        /// <param name="self">The game client data for the Peasant.</param>
        public PeasantCommands(PeasantClient self)
        {
            Self          = self;
            _gatewaySpell = self.Spells.KeySpells.Gateway;

            Items    = new PeasantItemCommands(self);
            Movement = new PeasantMovementCommands(self);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Assigns debuff and debuff cure spells from a Poet's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Poet.</param>
        protected CasterDebuffCommands(PoetClient self)
        {
            _self = self;

            _cureParalysisSpell = self.Spells.KeySpells.CureParalysis;
            CurseSpell          = self.Spells.KeySpells.Curse;
            _purgeSpell         = self.Spells.KeySpells.Purge;
            _removeCurseSpell   = self.Spells.KeySpells.RemoveCurse;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Assigns spells from the Warrior's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Warrior.</param>
        public WarriorCommands(WarriorClient self) : base(self)
        {
            _spotTrapsSpell  = self.Spells.KeySpells.SpotTraps;
            _spotTrapsStatus = self.Status.SpotTraps;

            Attacks = new WarriorAttackCommands(self);
            Buffs   = new WarriorBuffCommands(self);
            Heal    = new PeasantHealCommands(self);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Assigns attack spells from the Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        public MageAttackCommands(MageClient self) : base(self)
        {
            _self = self;

            _hellfireSpell  = self.Spells.KeySpells.Hellfire;
            _hellfireStatus = self.Status.Hellfire;
            _infernoSpell   = self.Spells.KeySpells.Inferno;
            _infernoStatus  = self.Status.Inferno;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Assigns buff spells from the Rogue's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Rogue.</param>
 public RogueBuffCommands(RogueClient self) : base(self)
 {
     _invisibleSpell     = self.Spells.KeySpells.Invisible;
     _invisibleStatus    = self.Status.Invisible;
     _mightSpell         = self.Spells.KeySpells.Might;
     _mightStatus        = self.Status.Might;
     _shadowFigureSpell  = self.Spells.KeySpells.ShadowFigure;
     _shadowFigureStatus = self.Status.ShadowFigure;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Assigns buff spells from the Warrior's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Warrior.</param>
        protected FighterBuffCommands(WarriorClient self)
        {
            Self        = self;
            _rageSpell  = self.Spells.KeySpells.Rage;
            _rageStatus = self.Status.Rage;

            _enchantSpell = self.Spells.KeySpells.Enchant;
            _furySpell    = self.Spells.KeySpells.Fury;
            _furyStatus   = self.Status.Fury;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Assigns spells from the Poet's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Poet.</param>
        public PoetCommands(PoetClient self) : base(self)
        {
            _hardenBodySpell  = self.Spells.KeySpells.HardenBody;
            _hardenBodyStatus = self.Status.HardenBody;

            Attacks = new PoetAttackCommands(self);
            Debuffs = new PoetDebuffCommands(self);
            Heal    = new PoetHealCommands(self);
            Mana    = new PoetManaCommands(self);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Assigns debuff spells from the Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        public MageDebuffCommands(MageClient self) : base(self)
        {
            _self = self;

            _blindSpell    = self.Spells.KeySpells.Blind;
            _dozeSpell     = self.Spells.KeySpells.Doze;
            _paralyzeSpell = self.Spells.KeySpells.Paralyze;
            _sleepSpell    = self.Spells.KeySpells.Sleep;
            _venomSpell    = self.Spells.KeySpells.Venom;
        }
Ejemplo n.º 16
0
        private static async Task RestoreManaForSpell(TkClient itemUser, KeySpell spell, Restoration manaRestorationItem)
        {
            await itemUser.Activity.WaitForCommandCooldown();

            var currentMana = (int)itemUser.Self.Mana.Current;

            if (currentMana < spell.Cost)
            {
                await UseManaRestorationItem(itemUser, manaRestorationItem, spell.Cost - currentMana);
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Assigns buff spells from the Warrior's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Warrior.</param>
 public WarriorBuffCommands(WarriorClient self) : base(self)
 {
     _backstabSpell  = self.Spells.KeySpells.Backstab;
     _backstabStatus = self.Status.Backstab;
     _blessingSpell  = self.Spells.KeySpells.Blessing;
     _blessingStatus = self.Status.Blessing;
     _flankSpell     = self.Spells.KeySpells.Flank;
     _flankStatus    = self.Status.Flank;
     _potenceSpell   = self.Spells.KeySpells.Potence;
     _potenceStatus  = self.Status.Potence;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Assigns mana restoration spells from a Poet's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Poet.</param>
        protected CasterManaCommands(PoetClient self)
        {
            Self = self;

            InvokeSpell  = self.Spells.KeySpells.Invoke;
            InvokeStatus = self.Status.Invoke;

            if (InvokeSpell == null)
            {
                Log.Warning($"{self.Self.Name} does not have an Invoke spell. Mana restoration item consumption will be very high.");
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Assigns mana restoration spells from a Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        public MageManaCommands(MageClient self) : base(self)
        {
            if (Self.Inventory.KeyItems.InvokeOrb != null)
            {
                _mageInvokeOrb    = new KeySpell(Self.Inventory.KeyItems.InvokeOrb);
                _mageInvokeStatus = self.Status.MageInvoke;
            }

            if (InvokeSpell == null && _mageInvokeOrb == null)
            {
                Log.Warning($"{self.Self.Name} does not have an Invoke spell. Mana restoration item consumption will be very high.");
            }
        }
        public void TestDisplayName(string unalignedName, string alignedName, string expectedDisplayName)
        {
            var actualDisplayName = new KeySpell(unalignedName, alignedName, 0).DisplayName;

            Console.WriteLine($@"Actual: {actualDisplayName}");
            Console.WriteLine($@"Expect: {expectedDisplayName}");

            var result = actualDisplayName == expectedDisplayName;

            Console.WriteLine($@"Result: {result}");

            Assert.IsTrue(result);
        }
Ejemplo n.º 21
0
        public static async Task <bool> CastTargetableSpell(
            TkClient caster,
            KeySpell spell,
            uint targetUid,
            string targetName,
            bool isLowCostSpell = false)
        {
            if (spell == null || await caster.IsTargetOffScreen(targetUid, spell))
            {
                return(false);
            }

            return(await CastSpell(caster, spell, isLowCostSpell, targetName));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Assigns debuff spells from the Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        public MageDebuffCommands(MageClient self) : base(self)
        {
            _self = self;

            _blindSpell    = self.Spells.KeySpells.Blind;
            _dozeSpell     = self.Spells.KeySpells.Doze;
            _paralyzeSpell = self.Spells.KeySpells.Paralyze;
            _sleepSpell    = self.Spells.KeySpells.Sleep;
            _venomSpell    = self.Spells.KeySpells.Venom;

            _scourgeOrb = self.Inventory.KeyItems.ScourgeOrb == null
                ? null
                : new KeySpell(self.Inventory.KeyItems.ScourgeOrb);
        }
Ejemplo n.º 23
0
        public static async Task <bool> CastInvisibleSpell(
            TkClient caster,
            KeySpell spell,
            InvisibleStatus status)
        {
            var didCastSpell = await CastSpell(caster, spell, true);

            if (didCastSpell)
            {
                status.ResetStatusCooldown();
            }

            return(didCastSpell);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Assigns attack spells from the Mage's spell inventory.
        /// </summary>
        /// <param name="self">The game client data for the Mage.</param>
        public MageAttackCommands(MageClient self) : base(self)
        {
            _self = self;

            _hellfireSpell  = self.Spells.KeySpells.Hellfire;
            _hellfireStatus = self.Status.Hellfire;
            _infernoSpell   = self.Spells.KeySpells.Inferno;
            _infernoStatus  = self.Status.Inferno;

            if (self.Inventory.KeyItems.SulSlashOrb == null)
            {
                return;
            }

            _sulSlashOrb    = new KeySpell(self.Inventory.KeyItems.SulSlashOrb);
            _sulSlashStatus = self.Status.SulSlash;
        }
Ejemplo n.º 25
0
        public static async Task <bool> CastTargetableSpell(
            TkClient caster,
            KeySpell spell,
            Npc target,
            bool isLowCostSpell = false)
        {
            if (await CastTargetableSpell(caster, spell, target.Uid, $"NPC {target.Uid}", isLowCostSpell))
            {
                return(true);
            }

            if (spell != null) // Indicates that the target is off-screen without having to repeat the relatively inefficient IsTargetOffScreen() check
            {
                caster.Npcs.Remove(target);
            }

            return(false);
        }
Ejemplo n.º 26
0
        public static async Task <bool> CastAetheredSpell(
            TkClient caster,
            KeySpell spell,
            BuffStatus status,
            bool isLowCostSpell = false)
        {
            if (status.IsActive)
            {
                return(false);
            }

            var didCastSpell = await CastSpell(caster, spell, isLowCostSpell);

            if (didCastSpell)
            {
                status.ResetStatusCooldown();
            }

            return(didCastSpell);
        }
Ejemplo n.º 27
0
        public static async Task <bool> CastRage(
            TkClient caster,
            KeySpell spell,
            RageStatus status)
        {
            if (status.IsActive)
            {
                return(false);
            }

            var didCastSpell = await CastSpell(caster, spell);

            // ReSharper disable once InvertIf
            if (didCastSpell)
            {
                status.ResetStatusCooldown();
                status.CurrentRageLevel++;
            }

            return(didCastSpell);
        }
Ejemplo n.º 28
0
        public static async Task <bool> CastAetheredTargetableSpell(
            TkClient caster,
            KeySpell spell,
            BuffStatus status,
            uint targetUid,
            string targetName,
            bool isLowCostSpell = false)
        {
            if (status.IsActive)
            {
                return(false);
            }

            var didCastSpell = await CastTargetableSpell(caster, spell, targetUid, targetName, isLowCostSpell);

            if (didCastSpell)
            {
                status.ResetStatusCooldown();
            }

            return(didCastSpell);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Assigns heal spells from the Poet's spell inventory.
 /// </summary>
 /// <param name="self">The game client data for the Poet.</param>
 public PoetHealCommands(PoetClient self) : base(self)
 {
     _self         = self;
     _restoreSpell = _self.Spells.KeySpells.Restore;
 }
Ejemplo n.º 30
0
 public static async Task RestoreMinorManaForSpell(TkClient itemUser, KeySpell spell)
 {
     await RestoreManaForSpell(itemUser, spell, itemUser.Inventory.KeyItems.MinorManaRestoration);
 }