Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using CommonBehaviors.Actions;
- using Styx;
- using Styx.Helpers;
- using Styx.Logic.BehaviorTree;
- using Styx.Logic.Combat;
- using Styx.Logic.Inventory.Frames.LootFrame;
- using Styx.WoWInternals;
- using Styx.WoWInternals.WoWObjects;
- using TreeSharp;
- using Action = TreeSharp.Action;
- namespace SimpleFish
- {
- class SimpleFish : BotBase
- {
- public Dictionary<string, int> FishedItems = new Dictionary<string, int>();
- public DateTime StartTime = DateTime.Now;
- public override string Name
- {
- get { return "Simple Fish"; }
- }
- public override PulseFlags PulseFlags
- {
- get { return Styx.PulseFlags.All; }
- }
- public override void Start()
- {
- StartTime = DateTime.Now;
- FishedItems.Clear();
- base.Start();
- }
- public override void Stop()
- {
- Logging.Write("Fished for " + (DateTime.Now - StartTime) + ", looted:");
- foreach (KeyValuePair<string, int> item in FishedItems)
- Logging.Write(" - " + item.Key + " x " + item.Value);
- base.Stop();
- }
- private Composite _root;
- public override Composite Root
- {
- get
- {
- return _root ?? (_root = new PrioritySelector(
- ctx => ObjectManager.GetObjectsOfType<WoWGameObject>().FirstOrDefault(obj => obj.SubType == WoWGameObjectType.FishingBobber && obj.CreatedByGuid == StyxWoW.Me.Guid),
- new Decorator(ret => !StyxWoW.IsInGame || !StyxWoW.IsInWorld || !StyxWoW.Me.IsValid,
- new ActionAlwaysSucceed()),
- new Decorator(ret => StyxWoW.Me.Combat,
- new PrioritySelector(
- new Decorator(ctx => RoutineManager.Current.CombatBehavior != null,
- RoutineManager.Current.CombatBehavior),
- new Action(ret => RoutineManager.Current.Combat()))),
- new Decorator(ret => StyxWoW.Me.BagsFull,
- new Sequence(
- new Action(ret => Logging.Write("Bags full, stopping bot...")),
- new Action(ret => TreeRoot.Stop()))),
- new Decorator(ret => StyxWoW.Me.Inventory.Equipped.MainHand != null && StyxWoW.Me.Inventory.Equipped.MainHand.ItemInfo.WeaponClass != WoWItemWeaponClass.FishingPole,
- new Sequence(
- new Action(ret => Logging.Write("No fishing pole equipped, stopping bot...")),
- new Action(ret => TreeRoot.Stop()))),
- new Decorator(ret => LootFrame.Instance.IsVisible,
- new Sequence(
- new Action(ret => {
- for (int i = 0; i < LootFrame.Instance.LootItems; i++)
- {
- string item = LootFrame.Instance.LootInfo(i).LootName;
- int count = LootFrame.Instance.LootInfo(i).LootQuantity;
- if (FishedItems.ContainsKey(item))
- FishedItems[item] = FishedItems[item] + count;
- else
- FishedItems.Add(item, count);
- }
- }),
- new Action(ret => Lua.DoString("for i=1, GetNumLootItems() do LootSlot(i) ConfirmLootSlot(i) end CloseLoot()")))),
- new Decorator(ret => StyxWoW.GlobalCooldown,
- new ActionAlwaysSucceed()),
- new Decorator(ctx => ctx != null && ((WoWGameObject)ctx).SubObj != null && ((WoWFishingBobber)((WoWGameObject)ctx).SubObj).IsBobbing,
- new Sequence(
- new Action(ret => Thread.Sleep(new Random().Next(250, 350))),
- new Action(ctx => ((WoWGameObject)ctx).Interact()),
- new Wait(3, ret => LootFrame.Instance.IsVisible, new ActionAlwaysSucceed()))),
- new Decorator(ret => StyxWoW.Me.IsCasting || StyxWoW.Me.IsMoving || StyxWoW.Me.IsSwimming || StyxWoW.Me.Mounted,
- new ActionAlwaysSucceed()),
- new Sequence(
- new Action(ret => Thread.Sleep(new Random().Next(250, 350))),
- new Action(ret => SpellManager.Cast("Fishing")),
- new Wait(3, ret => StyxWoW.Me.IsCasting, new ActionAlwaysSucceed()))
- ));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment