Exemple #1
0
        protected async Task <bool> Gardening()
        {
            var watering = GardenManager.Plants.Where(r => !Blacklist.Contains(r) && r.Distance2D(Core.Player) < 5).ToArray();

            foreach (var plant in watering)
            {
                //Water it if it needs it or if we have fertilized it 5 or more times.
                if (AlwaysWater || GardenManager.NeedsWatering(plant))
                {
                    var result = GardenManager.GetCrop(plant);
                    if (result != null)
                    {
                        Log("Watering {0} {1:X}", result, plant.ObjectId);
                        plant.Interact();
                        if (await Coroutine.Wait(5000, () => Talk.DialogOpen))
                        {
                            Talk.Next();
                            if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
                            {
                                if (await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                                {
                                    //Harvest drops it down to two
                                    if (SelectString.LineCount == 4)
                                    {
                                        SelectString.ClickSlot(1);
                                        await Coroutine.Sleep(PostInteractDelay);
                                    }
                                    else
                                    {
                                        Log("Plant is ready to be harvested");
                                        SelectString.ClickSlot(1);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Log("GardenManager.GetCrop returned null {0:X}", plant.ObjectId);
                    }
                }
            }
            var plants = GardenManager.Plants.Where(r => r.Distance2D(Core.Player) < 5).ToArray();

            foreach (var plant in plants)
            {
                var result = GardenManager.GetCrop(plant);
                if (result != null)
                {
                    Log("Fertilizing {0} {1:X}", GardenManager.GetCrop(plant), plant.ObjectId);
                    plant.Interact();
                    if (await Coroutine.Wait(5000, () => Talk.DialogOpen))
                    {
                        Talk.Next();
                        if (await Coroutine.Wait(5000, () => SelectString.IsOpen))
                        {
                            if (await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                            {
                                //Harvest drops it down to two
                                if (SelectString.LineCount == 4)
                                {
                                    SelectString.ClickSlot(0);
                                    if (await Coroutine.Wait(2000, () => GardenManager.ReadyToFertilize))
                                    {
                                        if (GardenManager.Fertilize() == FertilizeResult.Success)
                                        {
                                            LogVerbose("Plant with objectId {0:X} was fertilized", plant.ObjectId);
                                            await Coroutine.Sleep(PostInteractDelay);
                                        }
                                    }
                                    else
                                    {
                                        LogVerbose("Plant with objectId {0:X} not able to be fertilized, trying again later", plant.ObjectId);
                                    }
                                }
                                else
                                {
                                    LogVerbose("Plant is ready to be harvested");
                                    SelectString.ClickSlot(1);
                                }
                            }
                        }
                    }
                }
            }
            return(_done = true);
        }
Exemple #2
0
        //public static void Log(string text, params object[] args) { Logger.Info(text, args); }

        public static async Task <bool> Main(Vector3 gardenLoc)
        {
            var watering = GardenManager.Plants.Where(r => !Blacklist.Contains(r) && r.Distance2D(gardenLoc) < 10).ToArray();

            foreach (var plant in watering)
            {
                //Water it if it needs it or if we have fertilized it 5 or more times.
                if (AlwaysWater || GardenManager.NeedsWatering(plant))
                {
                    var result = GardenManager.GetCrop(plant);
                    if (result != null)
                    {
                        Log($"Watering {result} {plant.ObjectId:X}");
                        await Navigation.FlightorMove(plant.Location);

                        plant.Interact();
                        if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                        {
                            continue;
                        }
                        Talk.Next();
                        if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                        {
                            continue;
                        }
                        if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                        {
                            continue;
                        }
                        if (SelectString.LineCount == 4)
                        {
                            SelectString.ClickSlot(1);
                            await Coroutine.Sleep(2300);
                        }
                        else
                        {
                            Log("Plant is ready to be harvested");
                            SelectString.ClickSlot(1);
                            await Coroutine.Sleep(1000);
                        }
                    }
                    else
                    {
                        Log($"GardenManager.GetCrop returned null {plant.ObjectId:X}");
                    }
                }
            }
            var plants = GardenManager.Plants.Where(r => r.Distance2D(gardenLoc) < 10).ToArray();

            foreach (var plant in plants)
            {
                var result = GardenManager.GetCrop(plant);
                if (result == null)
                {
                    continue;
                }
                Log($"Fertilizing {GardenManager.GetCrop(plant)} {plant.ObjectId:X}");
                await Navigation.FlightorMove(plant.Location);

                plant.Interact();
                if (!await Coroutine.Wait(5000, () => Talk.DialogOpen))
                {
                    continue;
                }
                Talk.Next();
                if (!await Coroutine.Wait(5000, () => SelectString.IsOpen))
                {
                    continue;
                }
                if (!await Coroutine.Wait(5000, () => SelectString.LineCount > 0))
                {
                    continue;
                }
                if (SelectString.LineCount == 4)
                {
                    SelectString.ClickSlot(0);
                    if (await Coroutine.Wait(2000, () => GardenManager.ReadyToFertilize))
                    {
                        if (GardenManager.Fertilize() != FertilizeResult.Success)
                        {
                            continue;
                        }
                        Log($"Plant with objectId {plant.ObjectId:X} was fertilized");
                        await Coroutine.Sleep(2300);
                    }
                    else
                    {
                        Log($"Plant with objectId {plant.ObjectId:X} not able to be fertilized, trying again later");
                    }
                }
                else
                {
                    Log("Plant is ready to be harvested");
                    SelectString.ClickSlot(1);
                    await Coroutine.Sleep(1000);
                }
            }
            return(true);
        }