Ejemplo n.º 1
0
        public override void OnTerminate()
        {
            foreach (string ev in EventSubscription)
                Manager.Events.Remove(ev, HandleFishingEvents);

            CurrentState = FishingState.Lure;
            Fishing = null;
            Print("Fishing season is over! You did however catch {0} fishes.", Fishes);
        }
Ejemplo n.º 2
0
        public override void OnTick()
        {
            if (!Manager.ObjectManager.IsInGame)
                return;

            if ((DateTime.Now - SleepTimer).TotalMilliseconds < 200)
                return;
            SleepTimer = DateTime.Now;

            switch (CurrentState)
            {
                case FishingState.Lure:
                    //if (!HasBait)
                    //{
                    //    // Implement applying lure
                    //}
                    ProfessionInfo fish = API.Profession.Fishing;
                    if (fish != null)
                    {
                        if (fish.Level >= (fish.MaxLevel - 25) && fish.MaxLevel < 450)
                        {
                            CurrentState = FishingState.Training;
                            return;
                        }
                    }
                    CurrentState = FishingState.Cast;
                    break;

                case FishingState.Cast:
                    Print("Casting Fishing Pole");
                    Fishing.Cast();
                    CurrentState = FishingState.Fishing;
                    break;

                case FishingState.Fishing:
                    if (IsFishing)
                    {
                        if (IsBobbing)
                            CurrentState = FishingState.Loot;
                    }
                    else
                        CurrentState = FishingState.Lure;
                    break;

                case FishingState.Loot:
                    Print("Getting Fishing Bobber");
                    Bobber.Interact();
                    LootTimer = DateTime.Now;
                    CurrentState = FishingState.Looting;
                    break;

                case FishingState.Looting:
                    TimeSpan span = DateTime.Now - LootTimer;
                    if (span.TotalSeconds > 3)
                    {
                        Print("No loot? Back to fishing then!");
                        CurrentState = FishingState.Lure;
                    }
                    break;

                    // TODO: Clean up, add dynamic fishing trainer locator.
                case FishingState.Training:
                    if (Trainer == null || !Trainer.IsValid)
                    {
                        // Marcia Chase, Dalaran - Neutral.
                        Trainer =
                            Manager.ObjectManager.Objects.Where(x => x.IsValid && x.IsUnit)
                                .OfType<WoWUnit>()
                                .FirstOrDefault(u => u.Entry == 28742);
                        return;
                    }

                    if (Trainer.Distance > 6f)
                    {
                        if (Manager.Movement.Destination == Trainer.Location)
                            Sleep(100);
                        Manager.Movement.PathTo(Trainer.Location);
                        return;
                    }

                    if (!API.Gossip.IsShown && !API.Trainer.IsShown)
                    {
                        Trainer.Interact();
                        return;
                    }

                    if (API.Gossip.IsShown)
                    {
                        GossipOption opt = API.Gossip.Options.FirstOrDefault(g => g.Gossip == GossipType.Trainer);
                        if (opt != null)
                            opt.Select();
                        return;
                    }

                    if (API.Trainer.IsShown)
                    {
                        API.Trainer.BuyAllAvailable();
                        Fishing = null;
                        Manager.Spellbook.Update = true;
                        CurrentState = FishingState.Lure;
                        return;
                    }

                    CurrentState = FishingState.Lure;

                    break;
            }
        }
Ejemplo n.º 3
0
        public override void OnStart()
        {
            if (!Manager.ObjectManager.IsInGame)
                return;

            Manager.Spellbook.Update = true;
            CurrentState = FishingState.Lure;
            Fishes = 0;
            Fishing = Manager.Spellbook["Fishing"];
            if (Fishing == null || !Fishing.IsValid)
            {
                Print("You don't know fishing!");
                Stop();
            }

            foreach (string ev in EventSubscription)
                Manager.Events.Register(ev, HandleFishingEvents);
        }