What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Help!] Anyone who know why it doesn't heal the right faction at this CC?

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:
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);
 
try getting rid of the lines of code that says "where !unit.IsHorde"
the "!" I believe is a call for the resurrect or w/e the cc is trying to use to ignore that type of unit.
 
That didnt change anything :(

I just want it to heal hordes, i mean i love this profile.. that one thing fucks it all up
 
It could be an error with one of the sub files that the cc calls on for further instructions I.e helpers

Do u also play alliance toons?

I had an issue a couple weeks back similar to yours because my mainis an ally Druid but I also have a lvl39 twink Tauren Druid. And my cc would work on the horde toon.

What I did to get around this is I have 2 separate hb installs one for alliance one for horde
I am guessing that w/e hb does when first initially launched with a class/faction it auto writes some logic into one of the sub folders. I scanned through all my sub folders and could never find any errors. So I did what I used to do and have duplicate install of a program so it caches what I want it to for each so there can be no way for conflicting data stored in caches.

Since going to this setup I have no issues. It might not work for you and maybe a dev or something can further help u out. If you catch them while they are in irc they usually help just be nice to them.
 
I dont have any alliance toons though, but I could try to rewrite the whole thing on a new CS file. I've read through the codes probably 10 times now and i cant find the fault.. So it might be as you described it!

Cheers
 
Back
Top