Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using CommonBehaviors.Actions;
- using Styx;
- using Styx.Logic;
- using Styx.Logic.Combat;
- using Styx.Logic.Pathing;
- using Styx.WoWInternals;
- using Styx.WoWInternals.WoWObjects;
- using TreeSharp;
- using Action = TreeSharp.Action;
- namespace StratFarm
- {
- class StratFarm : BotBase
- {
- private WoWPoint EndPoint = new WoWPoint(4033.356, -3411.379, 115.796);
- private WoWPoint StartPoint = new WoWPoint(3587.068, -3637.105, 138.4687);
- private WoWPoint Outside = new WoWPoint(3233.309, -4047.673, 108.4394);
- private WoWPoint ZoneIn = new WoWPoint(3236.226, -4055.726, 108.4661);
- private int[] Gates = new int[] { 175368, 175357, 175356 };
- private int[] Enemies = new int[] { 10437, 10436, 10438, 10417, 10416, 10439, 11030, 10394 };
- private int Acolytes = 10399;
- private int Baron = 45412;
- private bool InstanceReset = false;
- private bool CanKillBaron = false;
- private DateTime WaitTime = DateTime.Now;
- private DateTime JumpTime = DateTime.Now;
- Random r = new Random();
- public override void Initialize()
- {
- Styx.Logic.LootTargeting.Instance.IncludeTargetsFilter += new IncludeTargetsFilterDelegate(Instance_IncludeTargetsFilter);
- }
- public override void Start()
- {
- Lua.Events.AttachEvent("CHAT_MSG_SYSTEM", CHAT_MSG_SYSTEM);
- }
- public override void Stop()
- {
- Lua.Events.DetachEvent("CHAT_MSG_SYSTEM", CHAT_MSG_SYSTEM);
- }
- void CHAT_MSG_SYSTEM(object context, LuaEventArgs args)
- {
- foreach (object obj in args.Args)
- {
- if (obj.ToString().Contains("too many inst"))
- {
- MoveTo(Outside);
- SpellManager.Cast("Shadowmeld");
- WaitTime = DateTime.Now + TimeSpan.FromMinutes(5);
- }
- }
- }
- void Instance_IncludeTargetsFilter(List<WoWObject> incomingUnits, HashSet<WoWObject> outgoingUnits)
- {
- foreach (WoWObject obj in incomingUnits)
- {
- if (obj.Entry == Baron)
- {
- outgoingUnits.Add(obj);
- }
- }
- }
- public override string Name
- {
- get { return "StratFarm"; }
- }
- public override PulseFlags PulseFlags
- {
- get { return Styx.PulseFlags.All; }
- }
- WoWMovement.MovementDirection[] movedirs = new WoWMovement.MovementDirection[] {
- WoWMovement.MovementDirection.JumpAscend, WoWMovement.MovementDirection.StrafeLeft, WoWMovement.MovementDirection.StrafeRight
- };
- void MoveTo(WoWPoint p)
- {
- if (DateTime.Now > JumpTime)
- {
- WoWMovement.Move(movedirs[r.Next(0, movedirs.Length + 1)], TimeSpan.FromMilliseconds(250 + r.Next(500)));
- JumpTime = DateTime.Now + TimeSpan.FromMilliseconds(1000 + r.Next(4000));
- }
- Navigator.MoveTo(p);
- }
- private Composite Combat()
- {
- return new PrioritySelector(ctx => ObjectManager.GetObjectsOfType<WoWUnit>(false, false).Where(u => u.IsAlive && u.IsHostile && u.IsTargetingMeOrPet && u.Combat),
- // make sure we have a target
- new Decorator(ret => !StyxWoW.Me.GotTarget,
- new Action(ctx => {
- WoWUnit unit = ((IEnumerable<WoWUnit>)ctx).FirstOrDefault();
- if (unit != null)
- unit.Target();
- })),
- // move within 10 yards (or move if not in LOS)
- new Decorator(ret => StyxWoW.Me.CurrentTarget.Distance > 10 || !StyxWoW.Me.CurrentTarget.InLineOfSightOCD,
- new Action(ret => MoveTo(StyxWoW.Me.CurrentTarget.Location))),
- // holy nova if more than 3 mobs on us
- new Decorator(ctx => ((IEnumerable<WoWUnit>)ctx).Count(u => u.Distance < 10) > 1,
- new Action(ret => SpellManager.Cast("Holy Nova"))),
- // stop moving to cast
- new Decorator(ret => StyxWoW.Me.IsMoving,
- new Action(ret => Navigator.PlayerMover.MoveStop())),
- // sw:d
- new Decorator(ret => StyxWoW.Me.CurrentTarget.HealthPercent < 25 && SpellManager.CanCast("Shadow Word: Death"),
- new Action(ret => SpellManager.Cast("Shadow Word: Death"))),
- // face target
- new Decorator(ret => !StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget, 70f),
- new Action(ret => StyxWoW.Me.CurrentTarget.Face())),
- // spike if we can
- new Decorator(ret => SpellManager.CanCast("Mind Spike"),
- new Action(ret => SpellManager.Cast("Mind Spike"))),
- // wand if we can't
- new Decorator(ret => StyxWoW.Me.AutoRepeatingSpellId != 5019,
- new Action(ret => SpellManager.Cast("Shoot")))
- );
- }
- private Composite _root;
- public override Composite Root
- {
- get
- {
- return _root ?? (_root =
- new PrioritySelector(
- // if we need to wait
- new Decorator(ret => WaitTime > DateTime.Now,
- new ActionAlwaysSucceed()),
- // if we're on a loading screen or something
- new Decorator(ret => !StyxWoW.IsInGame || !StyxWoW.IsInWorld || !StyxWoW.Me.IsValid || StyxWoW.Me.IsCasting,
- new ActionAlwaysSucceed()),
- // we should never be dead but eh, w/e
- Bots.Grind.LevelBot.CreateDeathBehavior(),
- // looting
- new Decorator(ret => LootFrame.Instance.IsVisible,
- new Action(ret => Lua.DoString("for i=1, GetNumLootItems() do LootSlot(i) ConfirmLootSlot(i) end CloseLoot()"))),
- // if we're in epl, reset instances and run back in
- new Decorator(ret => StyxWoW.Me.ZoneId == 139,
- new PrioritySelector(
- new Decorator(ret => !InstanceReset,
- new Action(ret =>
- {
- Lua.DoString("ResetInstances()");
- InstanceReset = true;
- CanKillBaron = false;
- })),
- new Action(ret => MoveTo(ZoneIn)))),
- // reset the instance reset thingy
- new Decorator(ret => InstanceReset,
- new Action(ret => InstanceReset = false)),
- // if we're running into a gate, use it
- new PrioritySelector(ctx =>
- {
- foreach (int id in Gates)
- {
- WoWGameObject obj = ObjectManager.GetObjectsOfType<WoWGameObject>().FirstOrDefault(e => e.Entry == id && !Blacklist.Contains(e));
- if (obj != null && obj.CanUseNow() && obj.CanUse())
- {
- Blacklist.Add(obj, TimeSpan.FromMilliseconds(500));
- return obj;
- }
- }
- return null;
- },
- new Decorator(ctx => ctx != null,
- new Action(ctx => ((WoWGameObject)ctx).Interact()))),
- // run to the bosses
- new PrioritySelector(ctx =>
- {
- double maxdist = double.MaxValue;
- WoWUnit enemy = null;
- foreach (int id in Enemies)
- {
- foreach (WoWUnit unit in ObjectManager.GetObjectsOfType<WoWUnit>().Where(e => e.Entry == id))
- {
- if (unit == null)
- {
- continue;
- }
- else if (!unit.IsAlive)
- {
- if (unit.Entry == 10394)
- {
- CanKillBaron = true;
- }
- WoWUnit a = ObjectManager.GetObjectsOfType<WoWUnit>().FirstOrDefault(e => e.Entry == Acolytes && e.IsAlive && e.Location.Distance(unit.Location) < 60);
- if (a != null)
- {
- enemy = a;
- goto endloop;
- }
- }
- else if (unit.Distance < maxdist || enemy == null)
- {
- maxdist = unit.Distance;
- enemy = unit;
- }
- }
- }
- endloop:
- if (enemy != null && StyxWoW.Me.CurrentTargetGuid != enemy.Guid)
- {
- enemy.Target();
- }
- return enemy;
- },
- new Decorator(ctx => ctx != null && ((WoWUnit)ctx).IsAlive,
- Combat())),
- // move to outside barons house if we can't kill him yet
- new Decorator(ret => !CanKillBaron && StyxWoW.Me.Location.Distance(EndPoint) > 10,
- new Action(ret => MoveTo(EndPoint))),
- // kill baron
- new PrioritySelector(ctx => ObjectManager.GetObjectsOfType<WoWUnit>(false, false).FirstOrDefault(e => e.Entry == Baron),
- new Decorator(ctx => ctx != null && ((WoWUnit)ctx).IsAlive,
- new PrioritySelector(
- new Decorator(ctx => StyxWoW.Me.CurrentTargetGuid != ((WoWUnit)ctx).Guid,
- new Action(ctx => ((WoWUnit)ctx).Target())),
- Combat())),
- new Decorator(ctx => ctx != null && ((WoWUnit)ctx).Lootable,
- new Action(ctx => ((WoWUnit)ctx).Interact()))),
- // failsafe
- new Decorator(ret => !CanKillBaron,
- new Action(ret => CanKillBaron = true)),
- // run back towards start
- new Action(ret => MoveTo(StartPoint))
- ));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment