Guest User

Untitled

a guest
Nov 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using CommonBehaviors.Actions;
  6. using Styx;
  7. using Styx.Helpers;
  8. using Styx.Logic.BehaviorTree;
  9. using Styx.Logic.Combat;
  10. using Styx.Logic.Inventory.Frames.LootFrame;
  11. using Styx.WoWInternals;
  12. using Styx.WoWInternals.WoWObjects;
  13. using TreeSharp;
  14. using Action = TreeSharp.Action;
  15.  
  16. namespace SimpleFish
  17. {
  18.     class SimpleFish : BotBase
  19.     {
  20.  
  21.         public Dictionary<string, int> FishedItems = new Dictionary<string, int>();
  22.         public DateTime StartTime = DateTime.Now;
  23.  
  24.         public override string Name
  25.         {
  26.             get { return "Simple Fish"; }
  27.         }
  28.  
  29.         public override PulseFlags PulseFlags
  30.         {
  31.             get { return Styx.PulseFlags.All; }
  32.         }
  33.  
  34.         public override void Start()
  35.         {
  36.             StartTime = DateTime.Now;
  37.             FishedItems.Clear();
  38.             base.Start();
  39.         }
  40.  
  41.         public override void Stop()
  42.         {
  43.             Logging.Write("Fished for " + (DateTime.Now - StartTime) + ", looted:");
  44.             foreach (KeyValuePair<string, int> item in FishedItems)
  45.                 Logging.Write(" - " + item.Key + " x " + item.Value);
  46.  
  47.             base.Stop();
  48.         }
  49.  
  50.         private Composite _root;
  51.         public override Composite Root
  52.         {
  53.             get
  54.             {
  55.                 return _root ?? (_root = new PrioritySelector(
  56.                     ctx => ObjectManager.GetObjectsOfType<WoWGameObject>().FirstOrDefault(obj => obj.SubType == WoWGameObjectType.FishingBobber && obj.CreatedByGuid == StyxWoW.Me.Guid),
  57.  
  58.                     new Decorator(ret => !StyxWoW.IsInGame || !StyxWoW.IsInWorld || !StyxWoW.Me.IsValid,
  59.                         new ActionAlwaysSucceed()),
  60.  
  61.                     new Decorator(ret => StyxWoW.Me.Combat,
  62.                         new PrioritySelector(
  63.                             new Decorator(ctx => RoutineManager.Current.CombatBehavior != null,
  64.                                 RoutineManager.Current.CombatBehavior),
  65.                             new Action(ret => RoutineManager.Current.Combat()))),
  66.  
  67.                     new Decorator(ret => StyxWoW.Me.BagsFull,
  68.                         new Sequence(
  69.                             new Action(ret => Logging.Write("Bags full, stopping bot...")),
  70.                             new Action(ret => TreeRoot.Stop()))),
  71.  
  72.                     new Decorator(ret => StyxWoW.Me.Inventory.Equipped.MainHand != null && StyxWoW.Me.Inventory.Equipped.MainHand.ItemInfo.WeaponClass != WoWItemWeaponClass.FishingPole,
  73.                         new Sequence(
  74.                             new Action(ret => Logging.Write("No fishing pole equipped, stopping bot...")),
  75.                             new Action(ret => TreeRoot.Stop()))),
  76.  
  77.                     new Decorator(ret => LootFrame.Instance.IsVisible,
  78.                         new Sequence(
  79.                             new Action(ret => {
  80.                                 for (int i = 0; i < LootFrame.Instance.LootItems; i++)
  81.                                 {
  82.                                     string item = LootFrame.Instance.LootInfo(i).LootName;
  83.                                     int count = LootFrame.Instance.LootInfo(i).LootQuantity;
  84.                                     if (FishedItems.ContainsKey(item))
  85.                                         FishedItems[item] = FishedItems[item] + count;
  86.                                     else
  87.                                         FishedItems.Add(item, count);
  88.                                 }
  89.                             }),
  90.                             new Action(ret => Lua.DoString("for i=1, GetNumLootItems() do LootSlot(i) ConfirmLootSlot(i) end CloseLoot()")))),
  91.  
  92.                     new Decorator(ret => StyxWoW.GlobalCooldown,
  93.                         new ActionAlwaysSucceed()),
  94.  
  95.                     new Decorator(ctx => ctx != null && ((WoWGameObject)ctx).SubObj != null && ((WoWFishingBobber)((WoWGameObject)ctx).SubObj).IsBobbing,
  96.                         new Sequence(
  97.                             new Action(ret => Thread.Sleep(new Random().Next(250, 350))),
  98.                             new Action(ctx => ((WoWGameObject)ctx).Interact()),
  99.                             new Wait(3, ret => LootFrame.Instance.IsVisible, new ActionAlwaysSucceed()))),
  100.  
  101.                     new Decorator(ret => StyxWoW.Me.IsCasting || StyxWoW.Me.IsMoving || StyxWoW.Me.IsSwimming || StyxWoW.Me.Mounted,
  102.                         new ActionAlwaysSucceed()),
  103.  
  104.                     new Sequence(
  105.                         new Action(ret => Thread.Sleep(new Random().Next(250, 350))),
  106.                         new Action(ret => SpellManager.Cast("Fishing")),
  107.                         new Wait(3, ret => StyxWoW.Me.IsCasting, new ActionAlwaysSucceed()))
  108.                     ));
  109.             }
  110.         }
  111.     }
  112. }
Add Comment
Please, Sign In to add comment