Shaddar
Active Member
- Joined
- Mar 23, 2011
- Messages
- 719
- Reaction score
- 56
If someone could look through this CC and tell me why it only attempts to heal alliance ( eventhough im horde) so i could fix that!
It seems like it doesnt even try to heal other people then alliance, which causes me to spamheal myself..
heres the CC profile:
It seems like it doesnt even try to heal other people then alliance, which causes me to spamheal myself..
heres the CC profile:
Code:
using System.Threading;
using System.Diagnostics;
using System.Globalization;
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 subject4
{
class subject4 : 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 (Buff())
return;
else if (Swarm())
return;
else if (CancelHeal())
return;
else if (Self())
return;
else if (Healing())
return;
else if (Cleansing())
return;
}
private bool Swarm()
{
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("Moonfire", u))
{
C("Moonfire", u);
return true;
}
if (u != null && (!Me.Combat) && CC("Insect Swarm", u))
{
C("Insect Swarm", u);
return true;
}
return false;
}
private bool CancelHeal()
{
if (Me.IsCasting && (lastCast != null && !lastCast.Dead && lastCast.HealthPercent >= 90))
{
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 <= 75 && CC("Tree of Life"))
{
C("Tree of Life");
return true;
}
else if (Me.HealthPercent < 60 && CC("Barkskin"))
{
C("Barkskin");
return true;
}
else if (Me.ManaPercent <= 50 && CC("Innervate"))
{
C("Innervate");
return true;
}
else
{
return false;
}
}
private bool Healing()
{
WoWPlayer tar = GetHealTarget();
if (tar != null)
{
if (tar.Distance > 40 || !tar.InLineOfSight)
{
Logging.Write("moving to " + tar);
return true;
}
else
{
String s = null;
bool needCast = false;
double hp = tar.HealthPercent;
if (hp < 50 && CC("Tranquility") && !isAuraActive("Tranquility", tar))
{
s = "Tranquility";
}
else if (hp < 80 && CC("Swiftmend") && isAuraActive("Rejuvenation", tar))
{
s = "Swiftmend";
}
else if (hp < 80 && CC("Swiftmend") && isAuraActive("Regrowth", tar))
{
s = "Swiftmend";
}
else if (hp < 90 && !isAuraActive("Rejuvenation", tar))
{
s = "Rejuvenation";
}
else if (hp < 90 && !isAuraActive("Wild Growth", tar))
{
s = "Wild Growth";
}
else if (hp < 90 && CC("Wild Growth") && !isAuraActive("Wild Growth", tar))
{
s = "Wild Growth";
}
else if (hp < 89 && !isAuraActive("Regrowth", tar))
{
s = "Regrowth";
}
else if (hp < 65 && !isAuraActive("Healing Touch", tar))
{
s = "Healing Touch";
}
if (s != null && CC(s, tar))
{
if (!C(s, tar))
{
Logging.Write("castfail move to " + tar);
}
if (!needCast)
{
}
return true;
}
else
{
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)
{
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.IsHorde
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 > 50)
{
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.IsHorde
where !unit.Dead
where !unit.IsGhost
where unit.Distance < 200
where unit.HealthPercent < 95
select unit).FirstOrDefault();
}
private IEnumerable<WoWPlayer> GetResurrectTargets()
{
return (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false, false)
orderby unit.Distance ascending
where !unit.IsHorde
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);
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 if (CC("Rebirth", p) && C("Rebirth", 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()
{
foreach (WoWPlayer p in Me.PartyMembers)
{
if (Resurrecting())
{
return true;
}
if (!isAuraActive("Mark of the Wild"))
{
C("Mark of the Wild");
return true;
}
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);