All pastes #954287 Raw Edit

Unbenannt

public text v1 · immutable
#954287 ·published 2008-03-23 20:29 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using LavishVMAPI;
using LavishScriptAPI;
using ISXWoW;

namespace AutoRogue
{
    public partial class AutoRogue : Form
    {
        enum RogueSpells { Shiv, SinisterStrike, SliceAndDice, Garrote, Rupture, Stealth, Evasion, Vanish, AdrenalineRush, BladeFlurry, None, Eviscerate, Hemorrhage, WoTF };
        Dictionary<RogueSpells, WoWSpell> spellBook = new Dictionary<RogueSpells, WoWSpell>();
        RogueSpells nextSpell = RogueSpells.None;

        ISXWoW.ISXWoW isxwow = new ISXWoW.ISXWoW();

        FrameLockManager flm = new FrameLockManager();

        public AutoRogue()
        {
            InitializeComponent();
            flm.Lock();
            spellBook.Add(RogueSpells.Shiv, WoWSpell.Get("Shiv"));
            spellBook.Add(RogueSpells.SinisterStrike, WoWSpell.Get("Sinister Strike"));
            spellBook.Add(RogueSpells.SliceAndDice, WoWSpell.Get("Slice and Dice"));
            spellBook.Add(RogueSpells.Garrote, WoWSpell.Get("Garrote"));
            spellBook.Add(RogueSpells.Rupture, WoWSpell.Get("Rupture"));
            spellBook.Add(RogueSpells.Stealth, WoWSpell.Get("Stealth"));
            spellBook.Add(RogueSpells.Evasion, WoWSpell.Get("Evasion"));
            spellBook.Add(RogueSpells.Vanish, WoWSpell.Get("Vanish"));
            spellBook.Add(RogueSpells.AdrenalineRush, WoWSpell.Get("Adrenaline Rush"));
            spellBook.Add(RogueSpells.BladeFlurry, WoWSpell.Get("Blade Flurry"));
            spellBook.Add(RogueSpells.Eviscerate, WoWSpell.Get("Eviscerate"));
            spellBook.Add(RogueSpells.Hemorrhage, WoWSpell.Get("Hemorrhage"));
            spellBook.Add(RogueSpells.WoTF, WoWSpell.Get("Will of the Forsaken"));
            flm.Unlock();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread AutoRogue = new Thread(Rogue);
            AutoRogue.Start();
        }

        private bool HasBuff(string name)
        {
            flm.Lock();
            bool isValid = isxwow.Me.Buff(name).IsValid;
            flm.Unlock();
            return isValid;
        }

        private bool CanCast(RogueSpells spell)
        {
            flm.Lock();
            if (spellBook[spell].IsValid && spellBook[spell].Cooldown == 0 && !isxwow.Me.IsCasting && isxwow.Me.GlobalCooldown == 0)
            {
                if (isxwow.Me.Power >= spellBook[spell].PowerCost && isxwow.Me.CurrentTarget.Distance <= 5)
                {
                    flm.Unlock();
                    return true;
                }
            }
            flm.Unlock();
            return false;
        }

        private bool CastSpell(RogueSpells spell)
        {
            if (CanCast(spell))
            {
                return spellBook[spell].Cast();
            }
            return false;
        }

        private void UpdateText(string text)
        {
            richLogBox.AppendText("[" + DateTime.Now.ToShortTimeString() + "] " + text + System.Environment.NewLine);

        }
        public delegate void UpdateTextCallback(string text);

        private RogueSpells ChooseNextAttack()
        {
            // heal kick

            flm.Lock();

            if (!isxwow.Me.CurrentTarget.IsValid)
                return RogueSpells.None;

            if (isxwow.Me.CurrentTarget.Dead)
                return RogueSpells.None;

            if (!isxwow.Me.CurrentTarget.Attackable)
                return RogueSpells.None;

            WoWBuff rupture = isxwow.Me.CurrentTarget.Buff("Rupture");
            WoWBuff snd = isxwow.Me.Buff("Slice and Dice");

            /*
            // stealth if possible
            if (!HasBuff("Stealth") && !isxwow.Me.IsInCombat)
            {
                return RogueSpells.Stealth;
            }
            */

            // opener
            if (HasBuff("Stealth"))
            {
                return RogueSpells.Garrote;
            }

            // 11/28/22 Rotation mit 5s/5r
            if (!HasBuff("Stealth") && isxwow.Me.IsInCombat)
            {
                /*if (isxwow.Me.HasEffect(WoWEffect.Asleep) || isxwow.Me.HasEffect(WoWEffect.Charmed) || isxwow.Me.HasEffect(WoWEffect.Fleeing) || isxwow.Me.HasEffect(WoWEffect.Horrified) || isxwow.Me.HasEffect(WoWEffect.Seduced))
                {
                    return RogueSpells.WoTF;
                }*/

                if (isxwow.Me.HealthPercent < 35)
                {
                    return RogueSpells.Evasion;
                }

                if ((!HasBuff("Slice and Dice")) && isxwow.Me.ComboPoints >= 1) // keep snd up at all costs
                {
                    return RogueSpells.SliceAndDice;
                }

                if (CanCast(RogueSpells.BladeFlurry))
                {
                    return RogueSpells.BladeFlurry;
                }

                if (isxwow.Me.ComboPoints == 5 && !rupture.IsValid) // rupture as 5cp finisher
                {
                    return RogueSpells.Rupture;
                }

                if (isxwow.Me.ComboPoints < 5 || isxwow.Me.Power >= 90) // main spell to build up cp's with
                {
                    return RogueSpells.Hemorrhage;
                }
            }

            return RogueSpells.None;
        }

        private void Rogue()
        {
            flm.Lock();
            GuidList<WoWUnit> theBoss = GuidList<WoWUnit>.New("-units", "-worldboss");
            flm.Unlock();

            // buff weapons MH: DP, OH: IP
            // to be done later

            // combat loop
            while (true)
            {
                nextSpell = ChooseNextAttack();
                /*if (isxwow.Me.CurrentTarget.Dead && !isxwow.Me.IsInCombat)
                {
                    break;
                }*/
                if (nextSpell != RogueSpells.None)
                    if (CastSpell(nextSpell))
                        richLogBox.BeginInvoke(new UpdateTextCallback(this.UpdateText), new object[] { "Casting: " + spellBook[nextSpell].Name });
                flm.Unlock();
                Thread.Sleep(100);
            }

        }
    }
}