示例#1
0
        internal async Task UseItem()
        {
            if (_obj != null)
            {
                while (CanUseItem)
                {
                    if (Item != null)
                    {
                        if (_obj.NpcId == ItemTarget)
                        {
                            Navigator.Stop();

                            if (Me.IsMounted)
                            {
                                await Dismount();
                            }

                            if (!Actionmanager.DoAction(Item.ActionType, Item.RawItemId, _obj) && Item.CanUse(_obj))
                            {
                                Log("Using {0} on {1}.", Item.Name, _obj.Name);
                                Item.UseItem(_obj);
                                await ShortCircuit(_obj, false, false, 5000);
                            }
                        }
                    }
                    await Coroutine.Yield();
                }
            }
            else
            {
                return;
            }
        }
示例#2
0
        protected override async Task <bool> CustomLogic()
        {
            if (Target != null)
            {
                await MoveAndStop(Target.Location, Distance, "Moving to " + Target.Name, true);

                if (InPosition(Target.Location, Distance))
                {
                    if (Target.IsTargetable && Target.IsVisible)
                    {
                        Target.Face();
                        Log("Using {0} on {1}.", Spell.LocalizedName, Target.Name);
                        StatusText = "Using " + Spell.LocalizedName + " on " + Target.Name;

                        if (!Actionmanager.DoAction(Spell.Id, Target) && Actionmanager.CanCast(Spell, Target))
                        {
                            Actionmanager.DoAction(Spell.Id, Target);
                        }
                        else
                        if (!Actionmanager.DoActionLocation(Spell.Id, Target.Location) && Actionmanager.CanCastLocation(Spell, Target.Location))
                        {
                            Actionmanager.DoActionLocation(Spell.Id, Target.Location);
                        }

                        await ShortCircuit(Target, PersistentObject, IgnoreCombat, 5000);
                    }
                }
            }

            return(false);
        }
示例#3
0
        private async Task UseItem()
        {
            if (TargetForUseItem != null)
            {
                while (CanUseItem)
                {
                    if (Item != null)
                    {
                        if (TargetForUseItem.NpcId == ItemTarget)
                        {
                            Navigator.Stop();

                            if (Me.IsMounted)
                            {
                                await Dismount();
                            }

                            if (!Actionmanager.DoAction(Item.ActionType, Item.RawItemId, TargetForUseItem) && Item.CanUse(TargetForUseItem))
                            {
                                Log("Using {0} on {1}.", Item.Name, TargetForUseItem.Name);
                                Item.UseItem(TargetForUseItem);
                                await Coroutine.Wait(6000, () => !Me.IsCasting && (TargetForUseItem as BattleCharacter).HasAura(LacksAuraId));
                            }
                        }
                    }
                    await Coroutine.Yield();
                }
            }
            else
            {
                return;
            }
        }
示例#4
0
        protected async Task <bool> Convert()
        {
            if (GatheringManager.WindowOpen)
            {
                Log("Waiting for gathering window to close");
                Thread.Sleep(2000);
            }

            if (FishingManager.State != FishingState.None)
            {
                Log("Stop fishing");
                Actionmanager.DoAction("Quit", Core.Me);
                await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
            }

            await CommonTasks.StopAndDismount();

            if (ItemIds != null && ItemIds.Length > 0)
            {
                foreach (var id in ItemIds)
                {
                    await ConvertByItemId((uint)id, (ushort)MaxWait, NqOnly);
                }
            }

            return(_done = true);
        }
        public override async Task <bool> ExecuteRotation(ExGatherTag tag)
        {
            if (Core.Player.CurrentGP > 399)
            {
                await Wait();

                Actionmanager.DoAction(293U, Core.Player);
            }

            return(await base.ExecuteRotation(tag));
        }
 protected Composite Behavior()
 {
     return(new PrioritySelector(
                new Decorator(ret => Condition != null && !ConditionCheck(),
                              new Action(ret => _done = true)),
                new Decorator(ret => QuestId != 0 && StepId != 0 && QuestLogManager.GetQuestById(QuestId).Step > StepId,
                              new Action(r =>
     {
         _done = true;
     })
                              ),
                new Decorator(ret => Core.Player.IsMounted,
                              CommonBehaviors.Dismount()
                              ),
                new Decorator(ret => Talk.DialogOpen,
                              new Action(r =>
     {
         Talk.Next();
     })
                              ),
                new Decorator(ret => casted,
                              new Sequence(
                                  new Sleep(3, 5),
                                  new Action(r => casted = false)
                                  )
                              ),
                new Decorator(ret => Core.Me.Location.Distance(Position) <= Distance && IsFinished,
                              new Action(ret => _done = true)),
                new Decorator(ret => Core.Me.Location.Distance(Position) <= Distance && !casted,
                              new Action(r =>
     {
         Navigator.PlayerMover.MoveStop();
         if (!Core.Player.IsCasting)
         {
             GameObjectManager.GetObjectByNPCId(NPC).Face();
             if (Actionmanager.DoAction(SpellID, GameObjectManager.GetObjectByNPCId(NPC)))
             {
                 Actionmanager.DoAction(SpellID, GameObjectManager.GetObjectByNPCId(NPC));
                 casted = true;
             }
             else
             {
                 Actionmanager.DoActionLocation(SpellID, Core.Player.Location);
                 casted = true;
             }
         }
     })
                              ),
                CommonBehaviors.MoveAndStop(ret => Position, Distance, stopInRange: true, destinationName: Name),
                new ActionAlwaysSucceed()
                ));
 }
示例#7
0
        internal static async Task <bool> Cast(uint id, int delay)
        {
            //TODO: check affinity, cost type, spell type, and add more informational logging and procedures to casting
            //Wait till we can cast the spell
            SpellData spellData;

            if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[id]))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }

            var result = Actionmanager.DoAction(id, Core.Player);

            var ticks = 0;

            while (result == false && ticks++ < 5 && Behaviors.ShouldContinue)
            {
                result = Actionmanager.DoAction(id, Core.Player);
                await Coroutine.Yield();
            }

            if (result)
            {
                Logger.Instance.Info("Casted Ability -> {0}", spellData.Name);
            }
            else
            {
                Logger.Instance.Error("Failed to cast Ability -> {0}", spellData.Name);
            }

            //Wait till we can cast again
            if (GatheringManager.ShouldPause(spellData))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }
            if (delay > 0)
            {
                await Coroutine.Sleep(delay);
            }
            else
            {
                await Coroutine.Yield();
            }

            return(result);
        }
示例#8
0
        internal static async Task <bool> CastAura(uint spellId, int delay, int auraId = -1)
        {
            var result = false;

            if (auraId == -1 || !Core.Player.HasAura(auraId))
            {
                SpellData spellData;
                if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[spellId]))
                {
                    await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(DataManager.SpellCache[spellId]));
                }

                result = Actionmanager.DoAction(spellId, Core.Player);
                var ticks = 0;
                while (result == false && ticks++ < 5 && Behaviors.ShouldContinue)
                {
                    result = Actionmanager.DoAction(spellId, Core.Player);
                    await Coroutine.Yield();
                }

                if (result)
                {
                    Logger.Instance.Info("Casted Aura -> {0}", spellData.Name);
                }
                else
                {
                    Logger.Instance.Error("Failed to cast Aura -> {0}", spellData.Name);
                }

                //Wait till we have the aura
                await Coroutine.Wait(3500, () => Core.Player.HasAura(auraId));

                if (delay > 0)
                {
                    await Coroutine.Sleep(delay);
                }
                else
                {
                    await Coroutine.Yield();
                }
            }

            return(result);
        }
示例#9
0
        public override async Task <bool> ExecuteRotation(ExGatherTag tag)
        {
            if (Core.Player.CurrentGP < 400 || tag.GatherItemIsFallback)
            {
                return(true);
            }

            await Wait();

            var ward = WardSkills.FirstOrDefault(w => Actionmanager.CanCast(w, Core.Player));

            if (ward > 0)
            {
                Actionmanager.DoAction(ward, Core.Player);
                await IncreaseChance(tag);
            }

            return(true);
        }
示例#10
0
文件: Chanko.cs 项目: Ninjutsu/Chanko
        private static async Task <bool> EatFood()
        {
            if (Settings.Instance.Id == 0 || !InventoryManager.FilledSlots.ContainsFooditem(Settings.Instance.Id))
            {
                Logging.Write(Colors.Aquamarine, "[Chanko] No food selected, check your settings");
                return(false);
            }

            if (GatheringManager.WindowOpen)
            {
                Logging.Write(Colors.Aquamarine, "[Chanko] Waiting for gathering window to close");
                return(false);
            }

            var item = InventoryManager.FilledSlots.GetFoodItem(Settings.Instance.Id);

            if (item == null)
            {
                return(false);
            }

            if (FishingManager.State != FishingState.None)
            {
                Logging.Write(Colors.Aquamarine, "[Chanko] Stop fishing");
                Actionmanager.DoAction("Quit", Core.Me);
                await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
            }

            if (Core.Me.IsMounted)
            {
                Logging.Write(Colors.Aquamarine, "[Chanko] Dismounting to eat");
                await CommonTasks.StopAndDismount();
            }

            Logging.Write(Colors.Aquamarine, "[Chanko] Eating " + item.EnglishName);
            item.UseItem();
            await Coroutine.Wait(5000, () => Core.Me.HasAura(_buff));

            return(true);
        }
示例#11
0
文件: Bait.cs 项目: unfaiyted/ExBuddy
        public async Task <bool> SelectBait(
            uint baitId,
            ushort baitDelay = 200,
            ushort maxWait   = 2000,
            bool closeWindow = true)
        {
            if (!IsValid)
            {
                Actionmanager.DoAction(288, GameObjectManager.LocalPlayer);
                await Refresh(maxWait);

                await Behaviors.Sleep(maxWait);
            }

            var result   = SendActionResult.None;
            var attempts = 0;

            while ((result != SendActionResult.Success || FishingManager.SelectedBaitItemId != baitId) && attempts++ < 3 &&
                   Behaviors.ShouldContinue)
            {
                result = SetBait(baitId);
                if (result == SendActionResult.InjectionError)
                {
                    await Behaviors.Sleep(500);
                }

                await Behaviors.Wait(maxWait, () => FishingManager.SelectedBaitItemId == baitId);
            }

            if (closeWindow)
            {
                await CloseInstanceGently(interval : 500);
            }

            return(result > SendActionResult.InjectionError);
        }
示例#12
0
        protected async Task <bool> TurnIn()
        {
            foreach (var slot in InventoryManager.FilledSlots)
            {
                // Adamantite
                // Chysahl Green
                // Thunderbolt Eel
                // Eventite Jade
                // Periwinkle
                // Tiny Axolotl
                if ((slot.RawItemId == 12538 && slot.Collectability >= 530) ||
                    (slot.RawItemId == 12900 && slot.Collectability >= 530) ||
                    (slot.RawItemId == 12828 && slot.Collectability >= 834) ||
                    (slot.RawItemId == 13760 && slot.Collectability >= 515) ||
                    (slot.RawItemId == 13762 && slot.Collectability >= 515) ||
                    (slot.RawItemId == 12774 && slot.Collectability >= 326))
                {
                    _haveItem = true;
                }
            }

            if (_haveItem)
            {
                Log("Start");
                if (GatheringManager.WindowOpen)
                {
                    Log("Waiting for gathering window to close");
                    Thread.Sleep(2000);
                }

                if (FishingManager.State != FishingState.None)
                {
                    Log("Stop fishing");
                    Actionmanager.DoAction("Quit", Core.Me);
                    await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
                }

                if (WorldManager.ZoneId != 478)
                {
                    await TeleportTo(478, 75);
                }

                var destination = new Vector3(-18.48964f, 206.4994f, 53.98175f);

                if (Core.Me.Distance(destination) > CharacterSettings.Instance.MountDistance && !Core.Me.IsMounted)
                {
                    while (!Core.Me.IsMounted)
                    {
                        await CommonTasks.MountUp();
                    }
                }
                while (Core.Me.Distance(destination) > 1f)
                {
                    var sprintDistance = Math.Min(20.0f, CharacterSettings.Instance.MountDistance);

                    Navigator.MoveTo(destination);
                    await Coroutine.Yield();

                    if (Core.Me.Distance(destination) > sprintDistance && !Core.Me.IsMounted)
                    {
                        Actionmanager.Sprint();
                        await Coroutine.Sleep(500);
                    }
                }
                if (Core.Me.Distance(destination) <= 1f)
                {
                    await CommonTasks.StopAndDismount();
                }

                GameObjectManager.GetObjectByNPCId(1012229).Interact();
                await Coroutine.Wait(5000, () => SelectIconString.IsOpen);

                SelectIconString.ClickSlot(0);
                await Coroutine.Sleep(2000);

                foreach (var item in InventoryManager.FilledSlots)
                {
                    // Adamantite
                    if (item.RawItemId == 12538 && item.Collectability >= 530)
                    {
                        Log("Attempting to Turn In Adamantite Ore");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 8);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                    // Chysahl Green
                    if (item.RawItemId == 12900 && item.Collectability >= 530)
                    {
                        Log("Attempting to Turn In Chysahl Green");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 9);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                    // Thunderbolt Eel
                    if (item.RawItemId == 12828 && item.Collectability >= 834)
                    {
                        Log("Attempting to Turn In Thunderbolt Eel");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 10);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                    // Eventite Jade
                    if (item.RawItemId == 13760 && item.Collectability >= 515)
                    {
                        Log("Attempting to Turn In Eventite Jade");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 19);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                    // Periwinkle
                    if (item.RawItemId == 13762 && item.Collectability >= 515)
                    {
                        Log("Attempting to Turn In Periwinkle");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 20);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                    // Tiny Axolotl
                    if (item.RawItemId == 12774 && item.Collectability >= 326)
                    {
                        Log("Attempting to Turn In Tiny Axolotl");
                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 21);
                        await Coroutine.Sleep(1000);

                        RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
                        await Coroutine.Wait(1000, () => Request.IsOpen);

                        item.Handover();
                        await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);

                        Request.HandOver();
                        await Coroutine.Sleep(2000);
                    }
                }
                RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(1, 3, uint.MaxValue);
                _haveItem = false;
                await Coroutine.Sleep(500);

                Log("Done");
            }
            else
            {
                Log("Nothing to Turn In");
            }
            return(_done = true);
        }
示例#13
0
 internal bool DoAbility(Abilities ability)
 {
     return(Actionmanager.DoAction((uint)ability, ExProfileBehavior.Me));
 }
示例#14
0
        public async Task <bool> Cast(GameObject target = null)
        {
            #region Target
            if (target == null)
            {
                switch (CastType)
                {
                case CastType.Location:
                    if (!Core.Player.HasTarget)
                    {
                        return(false);
                    }
                    target = Core.Player.CurrentTarget;
                    break;

                case CastType.Target:
                    if (!Core.Player.HasTarget)
                    {
                        return(false);
                    }
                    target = Core.Player.CurrentTarget;
                    break;

                default:
                    target = Core.Player;
                    break;
                }
            }
            #endregion

            #region Recent Spell Check
            RecentSpell.RemoveAll(t => DateTime.UtcNow > t);

            if (RecentSpell.ContainsKey(target.ObjectId.ToString("X") + "-" + Name))
            {
                return(false);
            }
            #endregion

            #region Pet Exception
            if (SpellType == SpellType.Pet)
            {
                if (Core.Player.Pet == null)
                {
                    return(false);
                }
                if (Pet.PetMode != PetMode.Obey)
                {
                    await Coroutine.Wait(1000, () => Pet.DoAction("Obey", Core.Player));
                }
                if (!Pet.CanCast(Name, target))
                {
                    return(false);
                }
                if (!await Coroutine.Wait(5000, () => Pet.DoAction(Name, target)))
                {
                    return(false);
                }
                Ultima.LastSpell = this;
                #region Recent Spell Add
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(Name).AdjustedCastTime + TimeSpan.FromSeconds(5);
                RecentSpell.Add(key, val);
                #endregion
                Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);
                return(true);
            }
            #endregion

            #region Ninjutsu Exception
            if (SpellType == SpellType.Ninjutsu)
            {
                if (BotManager.Current.IsAutonomous &&
                    Core.Player.HasTarget)
                {
                    switch (Actionmanager.InSpellInRangeLOS(2247, target))
                    {
                    case SpellRangeCheck.ErrorNotInLineOfSight:
                        Navigator.MoveTo(target.Location);
                        return(true);

                    case SpellRangeCheck.ErrorNotInRange:
                        Navigator.MoveTo(target.Location);
                        return(true);

                    case SpellRangeCheck.ErrorNotInFront:
                        if (!target.InLineOfSight())
                        {
                            Navigator.MoveTo(target.Location);
                            return(true);
                        }
                        target.Face();
                        return(true);
                    }
                    if (MovementManager.IsMoving &&
                        target.InLineOfSight() &&
                        Core.Player.Distance(target) <= 15 &&
                        Core.Player.IsFacing(target))
                    {
                        Navigator.PlayerMover.MoveStop();
                    }
                }
                if (!await Coroutine.Wait(1000, () => Actionmanager.DoAction(ID, target)))
                {
                    return(false);
                }
                Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);
                return(true);
            }
            #endregion

            #region Player Movement
            if (BotManager.Current.IsAutonomous &&
                Core.Player.HasTarget)
            {
                switch (Actionmanager.InSpellInRangeLOS(ID, target))
                {
                case SpellRangeCheck.ErrorNotInLineOfSight:
                    Navigator.MoveTo(target.Location);
                    return(false);

                case SpellRangeCheck.ErrorNotInRange:
                    Navigator.MoveTo(target.Location);
                    return(false);

                case SpellRangeCheck.ErrorNotInFront:
                    if (!target.InLineOfSight())
                    {
                        Navigator.MoveTo(target.Location);
                        return(false);
                    }
                    target.Face();
                    return(false);
                }
                if (MovementManager.IsMoving &&
                    target.InLineOfSight() &&
                    Core.Player.Distance(target) <= (DataManager.GetSpellData(ID).Range + Core.Player.CombatReach + target.CombatReach) &&
                    Core.Player.IsFacing(target))
                {
                    Navigator.PlayerMover.MoveStop();
                }
            }
            #endregion

            #region CanCast Check
            if (!Actionmanager.CanCast(ID, target))
            {
                return(false);
            }

            if (MovementManager.IsMoving &&
                DataManager.GetSpellData(ID).AdjustedCastTime.TotalMilliseconds > 0)
            {
                if (!BotManager.Current.IsAutonomous)
                {
                    return(false);
                }
                Navigator.PlayerMover.MoveStop();
            }
            #endregion

            #region Off-GCD Check
            if (GCDType == GCDType.Off)
            {
                if (Core.Player.CurrentJob == ClassJobType.Arcanist ||
                    Core.Player.CurrentJob == ClassJobType.Scholar ||
                    Core.Player.CurrentJob == ClassJobType.Summoner)
                {
                    if (Core.Player.ClassLevel >= 38 &&
                        Core.Player.CurrentManaPercent > 40 &&
                        DataManager.GetSpellData(163).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Archer ||
                    Core.Player.CurrentJob == ClassJobType.Bard)
                {
                    if (DataManager.GetSpellData(97).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Conjurer ||
                    Core.Player.CurrentJob == ClassJobType.WhiteMage)
                {
                    if (DataManager.GetSpellData(119).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Gladiator ||
                    Core.Player.CurrentJob == ClassJobType.Paladin)
                {
                    if (DataManager.GetSpellData(9).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Lancer ||
                    Core.Player.CurrentJob == ClassJobType.Dragoon)
                {
                    if (DataManager.GetSpellData(75).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Marauder ||
                    Core.Player.CurrentJob == ClassJobType.Warrior)
                {
                    if (DataManager.GetSpellData(31).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Pugilist ||
                    Core.Player.CurrentJob == ClassJobType.Monk)
                {
                    if (DataManager.GetSpellData(53).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Rogue ||
                    Core.Player.CurrentJob == ClassJobType.Ninja)
                {
                    if (DataManager.GetSpellData(2240).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
                if (Core.Player.CurrentJob == ClassJobType.Thaumaturge ||
                    Core.Player.CurrentJob == ClassJobType.BlackMage)
                {
                    if (DataManager.GetSpellData(142).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                }
            }
            #endregion

            #region DoAction
            if (CastType == CastType.Location)
            {
                if (!await Coroutine.Wait(1000, () => Actionmanager.DoActionLocation(ID, target.Location)))
                {
                    return(false);
                }
            }
            else
            {
                if (!await Coroutine.Wait(1000, () => Actionmanager.DoAction(ID, target)))
                {
                    return(false);
                }
            }
            #endregion
            Ultima.LastSpell = this;
            #region Recent Spell Add
            if (SpellType != SpellType.Damage &&
                SpellType != SpellType.Behind &&
                SpellType != SpellType.Flank)
            {
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(5);
                RecentSpell.Add(key, val);
            }
            #endregion
            Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);
            await Coroutine.Wait(3000, () => !Actionmanager.CanCast(ID, target));

            return(true);
        }
示例#15
0
        protected async Task <bool> Sell()
        {
            if (GatheringManager.WindowOpen)
            {
                Log("Waiting for gathering window to close");
                Thread.Sleep(2000);
            }

            if (FishingManager.State != FishingState.None)
            {
                Log("Stop fishing");
                Actionmanager.DoAction("Quit", Core.Me);
                await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
            }

            IEnumerable <BagSlot> items;

            if (ItemIds != null)
            {
                items =
                    InventoryManager.FilledSlots.
                    Where(bs => Array.Exists(ItemIds, e => e == bs.RawItemId) && bs.IsSellable);
            }
            else
            {
                Log("You didn't specify anything to sell.");

                return(_done = true);
            }

            var bagSlots = items as BagSlot[] ?? items.ToArray();
            var numItems = bagSlots.Count();

            if (numItems == 0)
            {
                Log("None of the items you requested can be sold.");

                return(_done = true);
            }

            if (WorldManager.ZoneId != 129)
            {
                await TeleportTo(129, 8);
            }

            var destination = new Vector3(-132.198f, 18.2f, 26.07081f);

            while (Core.Me.Distance(destination) > 1f)
            {
                var sprintDistance = Math.Min(20.0f, CharacterSettings.Instance.MountDistance);

                Navigator.MoveTo(destination);
                await Coroutine.Yield();

                if (Core.Me.Distance(destination) > sprintDistance && !Core.Me.IsMounted && !Core.Me.HasAura(50))
                {
                    Actionmanager.Sprint();
                    await Coroutine.Sleep(500);
                }
            }

            GameObjectManager.GetObjectByNPCId(1001204).Interact();
            await Coroutine.Wait(5000, () => Shop.Open);

            if (Shop.Open)
            {
                var i = 1;

                foreach (var bagSlot in bagSlots)
                {
                    string name = bagSlot.Name;

                    Log("Attempting to sell item {0} (\"{1}\") of {2}.", i++, name, numItems);

                    var result = await CommonTasks.SellItem(bagSlot);

                    if (result != SellItemResult.Success)
                    {
                        Log("Unable to sell \"{0}\" due to {1}.", name, result);

                        continue;
                    }

                    await Coroutine.Wait(SellTimeout * 1000, () => !bagSlot.IsFilled || !bagSlot.Name.Equals(name));

                    if (bagSlot.IsFilled && bagSlot.Name.Equals(name))
                    {
                        Log("Timed out awaiting sale of \"{0}\" ({1} seconds).", name, SellTimeout);
                    }
                    else
                    {
                        Log("\"{0}\" sold.", name);
                    }
                    await Coroutine.Sleep(500);
                }

                Shop.Close();
                await Coroutine.Wait(2000, () => !Shop.Open);
            }

            return(_done = true);
        }
示例#16
0
        public async Task <bool> Cast(GameObject target = null)
        {
            #region Target
            if (target == null)
            {
                switch (CastType)
                {
                case CastType.TargetLocation:
                    if (!Core.Player.HasTarget)
                    {
                        return(false);
                    }
                    target = Core.Player.CurrentTarget;
                    break;

                case CastType.Target:
                    if (!Core.Player.HasTarget)
                    {
                        return(false);
                    }
                    target = Core.Player.CurrentTarget;
                    break;

                default:
                    target = Core.Player;
                    break;
                }
            }
            #endregion

            #region Recent Spell Check
            RecentSpell.RemoveAll(t => DateTime.UtcNow > t);

            if (RecentSpell.ContainsKey(target.ObjectId.ToString("X") + "-" + Name))
            {
                return(false);
            }
            #endregion

            #region Bard Song Check

            if (Core.Player.CurrentJob == ClassJobType.Bard &&
                SpellType == SpellType.Buff)
            {
                if (Core.Player.HasAura(135, true) ||
                    Core.Player.HasAura(137, true))
                {
                    return(false);
                }
            }

            #endregion

            #region AoE Check

            if (SpellType == SpellType.AoE &&
                Ultima.UltSettings.SmartTarget)
            {
                var EnemyCount = Helpers.EnemyUnit.Count(eu => eu.Distance2D(target) - eu.CombatReach - target.CombatReach <= DataManager.GetSpellData(ID).Radius);

                switch (Core.Player.CurrentJob)
                {
                case ClassJobType.Arcanist:
                case ClassJobType.Scholar:
                case ClassJobType.Summoner:
                    if (EnemyCount < 2)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Archer:
                case ClassJobType.Bard:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Astrologian:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Conjurer:
                case ClassJobType.WhiteMage:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.DarkKnight:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Gladiator:
                case ClassJobType.Paladin:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Lancer:
                case ClassJobType.Dragoon:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Machinist:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Marauder:
                case ClassJobType.Warrior:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Pugilist:
                case ClassJobType.Monk:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Rogue:
                case ClassJobType.Ninja:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Thaumaturge:
                case ClassJobType.BlackMage:
                    if (EnemyCount < 3)
                    {
                        return(false);
                    }
                    break;
                }
            }

            #region Cone Check

            if (ID == 106 || ID == 41 || ID == 70)
            {
                if (!Helpers.InView(Core.Player.Location, Core.Player.Heading, target.Location))
                {
                    return(false);
                }
            }

            #endregion

            #region Rectangle Check

            if (ID == 86)
            {
                if (!Core.Player.IsFacing(target))
                {
                    return(false);
                }
            }

            #endregion

            #endregion

            #region Pet Exception
            if (SpellType == SpellType.Pet)
            {
                if (Core.Player.Pet == null)
                {
                    return(false);
                }

                if (Pet.PetMode != PetMode.Obey)
                {
                    if (!await Coroutine.Wait(1000, () => Pet.DoAction("Obey", Core.Player)))
                    {
                        return(false);
                    }
                    Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: Pet Obey");
                }

                #region IsMounted Check

                if (Core.Player.IsMounted)
                {
                    return(false);
                }

                #endregion

                #region CanCast

                if (!Pet.CanCast(Name, target))
                {
                    return(false);
                }

                #endregion

                #region DoAction

                if (!await Coroutine.Wait(5000, () => Pet.DoAction(Name, target)))
                {
                    return(false);
                }

                #endregion

                Ultima.LastSpell = this;

                #region Recent Spell Add
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(Name).AdjustedCastTime + TimeSpan.FromSeconds(5);
                RecentSpell.Add(key, val);
                #endregion

                Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);

                return(true);
            }
            #endregion

            #region Card Exception

            if (SpellType == SpellType.Card)
            {
                if (!await Coroutine.Wait(1000, () => Actionmanager.DoAction(ID, target)))
                {
                    return(false);
                }
                Ultima.LastSpell = this;
                #region Recent Spell Add
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(3590).AdjustedCastTime + TimeSpan.FromSeconds(5);
                RecentSpell.Add(key, val);
                #endregion
                Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);
                return(true);
            }

            #endregion

            #region CanAttack Check

            if (!target.CanAttack &&
                CastType != CastType.Self)
            {
                switch (SpellType)
                {
                case SpellType.Damage:
                case SpellType.DoT:
                case SpellType.Movement:
                case SpellType.Cooldown:
                case SpellType.Interrupt:
                case SpellType.Execute:
                case SpellType.Knockback:
                case SpellType.Debuff:
                case SpellType.Flank:
                case SpellType.Behind:
                    return(false);
                }
            }

            #endregion

            #region Ninjutsu Exception

            if (SpellType == SpellType.Ninjutsu ||
                SpellType == SpellType.Mudra)
            {
                #region Player Movement

                if (BotManager.Current.IsAutonomous)
                {
                    switch (Actionmanager.InSpellInRangeLOS(2247, target))
                    {
                    case SpellRangeCheck.ErrorNotInLineOfSight:
                        Navigator.MoveTo(target.Location);
                        return(false);

                    case SpellRangeCheck.ErrorNotInRange:
                        Navigator.MoveTo(target.Location);
                        return(false);

                    case SpellRangeCheck.ErrorNotInFront:
                        if (!target.InLineOfSight())
                        {
                            Navigator.MoveTo(target.Location);
                            return(false);
                        }
                        target.Face();
                        return(false);

                    case SpellRangeCheck.Success:
                        if (MovementManager.IsMoving)
                        {
                            Navigator.PlayerMover.MoveStop();
                        }
                        break;
                    }
                }

                #endregion

                #region IsMounted Check

                if (Core.Player.IsMounted)
                {
                    return(false);
                }

                #endregion

                #region CanCast

                if (Ultima.UltSettings.QueueSpells)
                {
                    if (!Actionmanager.CanCastOrQueue(DataManager.GetSpellData(ID), target))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!Actionmanager.CanCast(ID, target))
                    {
                        return(false);
                    }
                }

                #endregion

                #region Wait For Animation

                if (Ultima.LastSpell.ID != null &&
                    Ultima.LastSpell.SpellType != SpellType.Ninjutsu &&
                    Ultima.LastSpell.SpellType != SpellType.Mudra)
                {
                    await Coroutine.Wait(1000, () => DataManager.GetSpellData(Ultima.LastSpell.ID).Cooldown.TotalMilliseconds <= DataManager.GetSpellData(Ultima.LastSpell.ID).AdjustedCooldown.TotalMilliseconds - 1000);
                }

                #endregion

                #region DoAction

                if (!await Coroutine.Wait(1000, () => Actionmanager.DoAction(ID, target)))
                {
                    return(false);
                }

                #endregion

                #region Wait For Cast Completion

                await Coroutine.Wait(2000, () => !Actionmanager.CanCast(ID, target));

                #endregion

                Ultima.LastSpell = this;

                #region Recent Spell Add

                if (SpellType == SpellType.Mudra)
                {
                    var key = target.ObjectId.ToString("X") + "-" + Name;
                    var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(1);
                    RecentSpell.Add(key, val);
                }

                #endregion

                Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);

                return(true);
            }

            #endregion

            #region HasSpell Check

            if (!Actionmanager.HasSpell(ID))
            {
                return(false);
            }

            #endregion

            #region Player Movement

            if (BotManager.Current.IsAutonomous)
            {
                switch (Actionmanager.InSpellInRangeLOS(ID, target))
                {
                case SpellRangeCheck.ErrorNotInLineOfSight:
                    Navigator.MoveTo(target.Location);
                    return(false);

                case SpellRangeCheck.ErrorNotInRange:
                    Navigator.MoveTo(target.Location);
                    return(false);

                case SpellRangeCheck.ErrorNotInFront:
                    if (!target.InLineOfSight())
                    {
                        Navigator.MoveTo(target.Location);
                        return(false);
                    }
                    target.Face();
                    return(false);

                case SpellRangeCheck.Success:
                    if (CastType == CastType.TargetLocation &&
                        Core.Player.Distance2D(target) + Core.Player.CombatReach + target.CombatReach > 25)
                    {
                        Navigator.MoveTo(target.Location);
                        await Coroutine.Wait(1000, () => Core.Player.Distance2D(target) + Core.Player.CombatReach + target.CombatReach <= 25);

                        return(false);
                    }
                    Navigator.PlayerMover.MoveStop();
                    break;
                }

                if (Core.Player.HasTarget &&
                    !MovementManager.IsMoving &&
                    Core.Player.IsMounted)
                {
                    Logging.Write(Colors.Yellow, @"[Ultima] Dismounting...");
                    Actionmanager.Dismount();
                    await Coroutine.Sleep(1000);
                }
            }

            #endregion

            #region IsMounted Check

            if (Core.Player.IsMounted)
            {
                return(false);
            }

            #endregion

            #region CanCast Check

            switch (CastType)
            {
            case CastType.TargetLocation:
            case CastType.SelfLocation:
                if (!Actionmanager.CanCastLocation(ID, target.Location))
                {
                    return(false);
                }
                break;

            default:
                if (Ultima.UltSettings.QueueSpells)
                {
                    if (!Actionmanager.CanCastOrQueue(DataManager.GetSpellData(ID), target))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!Actionmanager.CanCast(ID, target))
                    {
                        return(false);
                    }
                }
                break;
            }

            if (MovementManager.IsMoving &&
                DataManager.GetSpellData(ID).AdjustedCastTime.TotalMilliseconds > 0)
            {
                if (!BotManager.Current.IsAutonomous)
                {
                    return(false);
                }
                Navigator.PlayerMover.MoveStop();
            }

            #endregion

            #region InView Check

            if (GameSettingsManager.FaceTargetOnAction == false &&
                CastType == CastType.Target &&
                SpellType != SpellType.Heal &&
                SpellType != SpellType.Defensive &&
                !Helpers.InView(Core.Player.Location, Core.Player.Heading, target.Location))
            {
                return(false);
            }

            #endregion

            #region Off-GCD Check
            if (GCDType == GCDType.Off)
            {
                switch (Core.Player.CurrentJob)
                {
                case ClassJobType.Arcanist:
                case ClassJobType.Scholar:
                case ClassJobType.Summoner:
                    if (Core.Player.ClassLevel >= 38 &&
                        Core.Player.CurrentManaPercent > 40 &&
                        DataManager.GetSpellData(163).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Archer:
                case ClassJobType.Bard:
                    if (DataManager.GetSpellData(97).Cooldown.TotalMilliseconds <= 700)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Astrologian:
                    if (DataManager.GetSpellData(3596).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Conjurer:
                case ClassJobType.WhiteMage:
                    if (DataManager.GetSpellData(119).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.DarkKnight:
                    if (DataManager.GetSpellData(3617).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Gladiator:
                case ClassJobType.Paladin:
                    if (DataManager.GetSpellData(9).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Lancer:
                case ClassJobType.Dragoon:
                    if (DataManager.GetSpellData(75).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Machinist:
                    if (DataManager.GetSpellData(2866).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Marauder:
                case ClassJobType.Warrior:
                    if (DataManager.GetSpellData(31).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Pugilist:
                case ClassJobType.Monk:
                    if (DataManager.GetSpellData(53).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Rogue:
                case ClassJobType.Ninja:
                    if (DataManager.GetSpellData(2240).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;

                case ClassJobType.Thaumaturge:
                case ClassJobType.BlackMage:
                    if (DataManager.GetSpellData(142).Cooldown.TotalMilliseconds <= 1000)
                    {
                        return(false);
                    }
                    break;
                }
            }
            #endregion

            #region Cleric Stance Check

            if (Actionmanager.HasSpell(122))
            {
                switch (Core.Player.HasAura("Cleric Stance"))
                {
                case true:
                    if (SpellType == SpellType.Heal)
                    {
                        await Coroutine.Wait(1000, () => Actionmanager.DoAction(122, Core.Player));

                        Logging.Write(Colors.OrangeRed, @"[Ultima] Removing Cleric Stance");
                        await Coroutine.Wait(3000, () => !Core.Player.HasAura(145));
                    }
                    break;

                case false:
                    if (SpellType == SpellType.Damage ||
                        SpellType == SpellType.DoT)
                    {
                        await Coroutine.Wait(1000, () => Actionmanager.DoAction(122, Core.Player));

                        Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: Cleric Stance");
                        await Coroutine.Wait(3000, () => Core.Player.HasAura(145));
                    }
                    break;
                }
            }

            #endregion

            #region DoAction
            switch (CastType)
            {
            case CastType.TargetLocation:
                if (Ultima.UltSettings.RandomCastLocation)
                {
                    var rndx   = (target.CombatReach * _rnd.NextDouble() * GetMultiplier());
                    var rndz   = (target.CombatReach * _rnd.NextDouble() * GetMultiplier());
                    var rndxz  = new Vector3((float)rndx, 0f, (float)rndz);
                    var tarloc = target.Location;
                    var rndloc = tarloc + rndxz;

                    if (!await Coroutine.Wait(1000, () => Actionmanager.DoActionLocation(ID, rndloc)))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!await Coroutine.Wait(1000, () => Actionmanager.DoActionLocation(ID, target.Location)))
                    {
                        return(false);
                    }
                }
                break;

            case CastType.SelfLocation:
                if (Ultima.UltSettings.RandomCastLocation)
                {
                    var rndx   = ((1f * _rnd.NextDouble() + 1f) * GetMultiplier());
                    var rndz   = ((1f * _rnd.NextDouble() + 1f) * GetMultiplier());
                    var rndxz  = new Vector3((float)rndx, 0f, (float)rndz);
                    var tarloc = target.Location;
                    var rndloc = tarloc + rndxz;

                    if (!await Coroutine.Wait(1000, () => Actionmanager.DoActionLocation(ID, rndloc)))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!await Coroutine.Wait(1000, () => Actionmanager.DoActionLocation(ID, target.Location)))
                    {
                        return(false);
                    }
                }
                break;

            default:
                if (!await Coroutine.Wait(1000, () => Actionmanager.DoAction(ID, target)))
                {
                    return(false);
                }
                break;
            }
            #endregion

            #region Wait For Cast Completion

            switch (CastType)
            {
            case CastType.SelfLocation:
            case CastType.TargetLocation:
                await Coroutine.Wait(3000, () => !Actionmanager.CanCastLocation(ID, target.Location));

                break;

            default:
                await Coroutine.Wait(3000, () => !Actionmanager.CanCast(ID, target));

                break;
            }

            #endregion

            Ultima.LastSpell = this;

            #region Recent Spell Add
            if (SpellType != SpellType.Damage &&
                SpellType != SpellType.Heal &&
                SpellType != SpellType.AoE &&
                SpellType != SpellType.Behind &&
                SpellType != SpellType.Flank)
            {
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(5);
                RecentSpell.Add(key, val);
            }
            if (SpellType == SpellType.Heal)
            {
                var key = target.ObjectId.ToString("X") + "-" + Name;
                var val = DateTime.UtcNow + DataManager.GetSpellData(ID).AdjustedCastTime + TimeSpan.FromSeconds(3);
                RecentSpell.Add(key, val);
            }
            #endregion

            Logging.Write(Colors.OrangeRed, @"[Ultima] Ability: " + Name);

            return(true);
        }
示例#17
0
        private async Task <bool> DoControlLogic()
        {
            if (!initialized)
            {
                init();
            }



            var npc = GuardianNPC;


            if (npc != null && NeedToMove == false)
            {
                if (npc.Location.DistanceSqr(Core.Player.Location) > LeashSquared)
                {
                    if (Core.Player.CurrentHealthPercent < 50)
                    {
                        NeedToMove = true;
                    }

                    if (!Core.Player.InCombat)
                    {
                        NeedToMove = true;
                    }
                }
            }


            if (Core.Player.CurrentHealthPercent <= 30)
            {
                foreach (var potion in Potions)
                {
                    if (Actionmanager.ItemUseable(potion, null))
                    {
                        Logging.Write("[SimpleDuty] Player below 30% heath using potion id {0}", potion);
                        Actionmanager.DoAction(ActionType.Item, potion, null);
                        break;
                    }
                }
            }

            while (NeedToMove)
            {
                if (QuestLogManager.InCutscene)
                {
                    continue;
                }

                if (NeedToMove && (npc == null || !npc.IsValid || npc.Location.Distance2D(Core.Player.Location) <= 6))
                {
                    NeedToMove = false;
                }
                else
                {
                    await movementComposite.ExecuteCoroutine(npc);
                }
            }

            return(false);
        }