Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Styx.Combat.CombatRoutine;
- using Styx.WoWInternals.WoWObjects;
- using Styx.WoWInternals;
- using Styx.Logic.Combat;
- using Styx.Helpers;
- using Styx.Logic.Pathing;
- using Styx;
- using Styx.Logic;
- namespace Druidhealz
- {
- class Druidhealz : CombatRoutine
- {
- private WoWUnit lastCast;
- private WoWUnit tank;
- private Random rng;
- public override void Pulse()
- {
- if (Me != null && Me.IsValid && Me.IsAlive && Me.IsInInstance)
- {
- tank = GetTank();
- if (tank == null)
- {
- tank = Me;
- }
- Combat();
- }
- }
- public override void Combat()
- {
- if (StyxWoW.GlobalCooldown)
- return;
- else if (CancelHeal())
- return;
- else if (Self())
- return;
- else if (Healing())
- return;
- else if (Cleansing())
- return;
- else if (Swarm())
- return;
- else if (Buff())
- return;
- }
- private bool Swarm()
- {
- //if (!isAuraActive("Judgements of the Pure"))
- //{
- WoWUnit u = (from unit in ObjectManager.GetObjectsOfType<WoWUnit>(false, false)
- where unit.IsHostile
- where !unit.Dead
- where unit.CurrentTargetGuid == tank.Guid
- where unit.Distance < 40
- where unit.InLineOfSight
- select unit
- ).FirstOrDefault();
- if (u != null && (!Me.Combat) && CC("Insect Swarm", u))
- {
- C("Insect Swarm", u);
- return true;
- }
- //}
- return false;
- }
- private bool MoveTo(WoWUnit u)
- {
- if (!Me.IsMoving && u != null && u.Distance > 20)
- {
- Navigator.MoveTo(NextTo(u));
- return true;
- }
- else
- {
- return false;
- }
- }
- private WoWPoint NextTo(WoWUnit u)
- {
- if (rng == null)
- {
- rng = new Random();
- }
- return WoWMathHelper.CalculatePointAtSide(u.Location, u.Rotation, rng.Next(10), rng.Next(2) == 1);
- }
- private bool CancelHeal()
- {
- //Logging.Write("in CancelHeal");
- if (Me.IsCasting && (lastCast != null && !lastCast.Dead && lastCast.HealthPercent >= 85))
- {
- Logging.Write("Cancelling cast " + lastCast);
- lastCast = null;
- SpellManager.StopCasting();
- return true;
- }
- else if (Me.IsCasting)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private WoWPlayer GetTank()
- {
- foreach (WoWPlayer p in Me.PartyMembers)
- {
- if (IsTank(p))
- {
- return p;
- }
- }
- return null;
- }
- private string DeUnicodify(string s)
- {
- StringBuilder sb = new StringBuilder();
- byte[] bytes = Encoding.UTF8.GetBytes(s);
- foreach (byte b in bytes)
- {
- if (b != 0)
- sb.Append("\\" + b);
- }
- return sb.ToString();
- }
- private bool IsTank(WoWPlayer p)
- {
- return Lua.GetReturnValues("return UnitGroupRolesAssigned('" + DeUnicodify(p.Name) + "')").First() == "TANK";
- }
- private bool Self()
- {
- if (Me.HealthPercent < 80 && CC("Barkskin"))
- {
- C("Barksin");
- return true;
- }
- else if (Me.ManaPercent <= 50 && CC("Innervate"))
- {
- C("Innervate");
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool Healing()
- {
- //Logging.Write("in Healing");
- WoWPlayer tar = GetHealTarget();
- if (tar != null)
- {
- if (tar.Distance > 40 || !tar.InLineOfSight)
- {
- Logging.Write("moving to " + tar);
- MoveTo(tar);
- return true;
- }
- else
- {
- String s = null;
- bool needCast = false;
- double hp = tar.HealthPercent;
- else if (tar.Guid == tank.Guid && (!tar.ActiveAuras.ContainsKey("Lifebloom") || tar.ActiveAuras["lifebloom"].StackCount < 3 || tar.ActiveAuras["lifebloom"].TimeLeft.Milliseconds <= 1500 ) && Me.CanCast("LifeBloom"))
- {
- if(tar.HealthPercent < 50)
- {
- Return;
- }
- else if(tar.HealthPercent > 50)
- s = "Lifebloom";
- }
- if (hp < 90 && !isAuraActive("Rejuvenation", tar))
- {
- s = "Rejuvenation";
- }
- else if (hp < 80 && !isAuraActive("Wild Growth", tar))
- {
- s = "Wild Growth";
- }
- else if (hp < 65 && isAuraActive("Rejuvenation", tar))
- {
- s = "Swiftmend";
- }
- else if (hp < 40)
- {
- s = "Nature's Swiftness";
- }
- else if (Me.IsMoving)
- {
- Logging.Write("stopmove");
- WoWMovement.MoveStop();
- return true;
- }
- else if (isAuraActive("Nature's Swiftness"))
- {
- s = "Healing Touch";
- needCast = true;
- }
- else if (hp < 75 && !isAuraActive("Regrowth", tar))
- {
- s = "Regrowth";
- needCast = true;
- }
- if (s != null && CC(s, tar))
- {
- if (!C(s, tar))
- {
- Logging.Write("castfail move to " + tar);
- }
- if (!needCast)
- {
- MoveTo(tar);
- }
- return true;
- }
- else
- {
- MoveTo(tar);
- return false;
- }
- }
- }
- else
- {
- return false;
- }
- }
- private bool CC(string spell, WoWUnit target)
- {
- return SpellManager.CanCast(spell, target);
- }
- private bool CC(string spell)
- {
- return SpellManager.CanCast(spell);
- }
- private void ChainSpells(params string[] spells)
- {
- string macro = "";
- foreach (string s in spells)
- {
- macro += "CastSpellByName(\"" + s + "\", true);";
- }
- Lua.DoString(macro);
- }
- private bool C(string spell, WoWUnit target)
- {
- if (SpellManager.Cast(spell, target))
- {
- Logging.Write("cast " + spell + " " + target);
- lastCast = target;
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool C(string spell)
- {
- Logging.Write("selfcast " + spell);
- lastCast = null;
- return SpellManager.Cast(spell);
- }
- private bool Cleansing()
- {
- WoWPlayer p = GetCleanseTarget();
- if (p != null)
- {
- if (p.Distance > 40 || !p.InLineOfSight)
- {
- MoveTo(p);
- return true;
- }
- else if (CC("Remove Corruption", p))
- {
- C("Remove Corruption", p);
- return true;
- }
- else
- {
- Logging.Write("no Remove Corruption " + p);
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- private WoWPlayer GetCleanseTarget()
- {
- return (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(true, true)
- orderby unit.HealthPercent ascending
- where !unit.Dead
- where !unit.IsGhost
- where unit.Distance < 80
- where NeedsCleanse(unit)
- select unit).FirstOrDefault();
- }
- private bool NeedsCleanse(WoWPlayer p)
- {
- foreach (WoWAura a in p.ActiveAuras.Values)
- {
- if (a.IsHarmful && Me.ManaPercent > 80)
- {
- WoWDispelType t = a.Spell.DispelType;
- if (t == WoWDispelType.Curse || t == WoWDispelType.Magic || t == WoWDispelType.Poison)
- {
- return true;
- }
- }
- }
- return false;
- }
- private WoWPlayer GetHealTarget()
- {
- return (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(true, true)
- orderby unit.HealthPercent ascending
- where !unit.Dead
- where !unit.IsGhost
- where unit.IsPet
- where unit.Distance < 80
- where unit.HealthPercent < 100
- select unit).FirstOrDefault();
- }
- private IEnumerable<WoWPlayer> GetResurrectTargets()
- {
- return (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false, false)
- orderby unit.Distance ascending
- where unit.Dead
- where unit.IsInMyPartyOrRaid
- where !unit.IsGhost
- where unit.Distance < 100
- select unit);
- }
- private bool Resurrecting()
- {
- foreach (WoWPlayer p in GetResurrectTargets())
- {
- if (Blacklist.Contains(p.Guid, true))
- {
- continue;
- }
- else
- {
- if (p.Distance > 40 || !p.InLineOfSight)
- {
- Logging.Write("moving to res " + p);
- MoveTo(p);
- return true;
- }
- else if (CC("Revive", p) && C("Revive", p))
- {
- Logging.Write("added " + p + " to res blacklist for 15s");
- Blacklist.Add(p, new TimeSpan(0, 0, 15));
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- return false;
- }
- private bool Buff()
- {
- if (Resurrecting())
- {
- return true;
- }
- if (!isAuraActive("Mark of the Wild"))
- {
- C("Mark of the Wild");
- return true;
- }
- foreach (WoWPlayer p in Me.PartyMembers)
- {
- if (p.Distance > 40 || p.Dead || p.IsGhost)
- continue;
- else if (!isAuraActive("Blessing of Kings", p) && !isAuraActive("Mark of the Wild", p))
- {
- C("Mark of the Wild", p);
- return true;
- }
- }
- return false;
- }
- private bool isAuraActive(string name)
- {
- return isAuraActive(name, Me);
- }
- private bool isAuraActive(string name, WoWUnit u)
- {
- return u.ActiveAuras.ContainsKey(name);
- }
- public override sealed string Name { get { return "Druidhealz"; } }
- public override WoWClass Class { get { return WoWClass.Druid; } }
- private static LocalPlayer Me { get { return ObjectManager.Me; } }
- public override bool NeedRest
- {
- get
- {
- if (Me.ManaPercent < 30 &&
- !Me.Auras.ContainsKey("Drink")) //To prevent food spam.
- {
- Logging.Write("Need Drink");
- return true;
- }
- return false;
- }
- }
- public override void Rest()
- {
- // this ought never get run over level 3
- if (Me.ManaPercent < 50)
- {
- Styx.Logic.Common.Rest.Feed(); //these arent needed.
- }
- }
- public override bool NeedPullBuffs { get { Pulse(); return false; } }
- public override bool NeedCombatBuffs { get { Pulse(); return false; } }
- public override bool NeedPreCombatBuffs { get { Pulse(); return false; } }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement