예제 #1
0
        public override void Start()
        {
            try
            {
                Specialisation          = WoWSpec.None;
                NamedComposite.Sequence = "";
                TreeRoot.TicksPerSecond = 8;
                ProfileManager.LoadEmpty();
                //_oldRoutine = RoutineManager.Current; //Save it so we can restore it later
                RoutineManager.Current = new ProxyRoutine();

                Lua.Events.RemoveFilter("COMBATLOG_EVENT_UNFILTERED");

                Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", UNIT_SPELLCAST_SUCCEEDED);
                Lua.Events.AttachEvent("COMBATLOG_EVENT_UNFILTERED", COMBATLOG_EVENT_UNFILTERED);

                Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", ContextChange);
                Lua.Events.AttachEvent("PLAYER_LOGOUT", ContextChange);
                Lua.Events.AttachEvent("PLAYER_TALENT_UPDATE", ContextChange);
                Lua.Events.AttachEvent("UNIT_AURA", PlayerAuras.UNIT_AURA);
                Lua.Events.AttachEvent("UNIT_AURA", PetAuras.UNIT_AURA);
                ContextChange(null, null);

                RegisterHotkeys();
            }
            catch (Exception e)
            {
                SimcraftImpl.Write(e.ToString());
            }
        }
예제 #2
0
        public Composite CombatIteration()
        {
            return(new Action(delegate
            {
                //if (iterationCounter%7 == 0)

                /*if (console != null %% console.Va)console.BeginInvoke((System.Action)(() =>
                 * {
                 *
                 *      console.reset();
                 *
                 * }));*/

                //console.BeginInvoke(new Delegate(console,"reset"));
                //console.reset();
                //Write(Me.Pet.);

                combatIterationCount++;

                IterationTimer.Restart();

                if (SpellIsTargeting)
                {
                    SimcraftImpl.Write("Wanting to click: " + clickUnit);
                    //Write("Clicking: " + clickUnit.Location + " " + iterationCounter);
                    SpellManager.ClickRemoteLocation(clickUnit.Location);
                    clickUnit = null;
                }

                //Write("u:{0} b:{1} f:{2}", unholy.current, death.current, frost.current);

                //OverrideSpell.Pulse();
                return RunStatus.Failure;
            }));
        }
예제 #3
0
        public void ContextChange(object sender, LuaEventArgs args)
        {
            talent.Reset();
            glyph.Reset();
            spell.Reset();
            line_cds.Clear();
            PlayerAuras.Reset();
            PetAuras.Reset();

            _class = StyxWoW.Me.Class;
            //_spec = Me.Specialization;

            var oldctx = Context;

            Context = (StyxWoW.Me.CurrentMap.IsArena || StyxWoW.Me.CurrentMap.IsBattleground)
                ? WoWContext.PvP
                : WoWContext.PvE;
            if (Context != oldctx)
            {
                SimcraftImpl.Write("Switching to " + Context + " Mode");
            }

            ooc = DateTime.Now;
            RebuildBehaviors();
        }
예제 #4
0
        protected override void OnShown(EventArgs e)
        {
            listBox1.Items.Clear();
            SimcraftImpl.GenerateApls(SimcraftImpl.SimcraftProfilePath);

            /*if (Directory.Exists(@"Bots\Simcraft\Trunk\"))
             *
             * else
             *  SimcraftImpl.GenerateApls(@"Bots\Simcraft\Profiles\");*/
            foreach (var apl in SimcraftImpl.apls)
            {
                //if (apl.Key.Match(StyxWoW.Me.Class, StyxWoW.Me.Specialization, WoWContext.PvE))
                //{
                if (apl.Value.Class == StyxWoW.Me.Class)
                {
                    listBox1.Items.Add(apl.Value);
                }
                //SimcraftImpl.Write("Selecting: " + apl.Value.Name);
                //apl.Value.CreateBehavior();
                //return;
                //}
            }
            //SimcraftImpl.apls
            base.OnShown(e);
        }
예제 #5
0
 public Composite IterationEnd()
 {
     return(new Action(delegate
     {
         IterationTimer.Stop();
         iterationTotal += IterationTimer.ElapsedMilliseconds;
         //if (IterationTimer.ElapsedMilliseconds > 1) Write(DateTime.Now.Millisecond+": "+IterationTimer.ElapsedMilliseconds+"");
         if (combatIterationCount % 150 == 0)
         {
             SimcraftImpl.Write("avgIte: " + (iterationTotal / combatIterationCount));
         }
         //Write(""+IterationTimer.ElapsedMilliseconds);
     }));
 }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            SimCSettings.currentSettings.Cooldowns.key = (Keys)cdKey.SelectedItem;
            SimCSettings.currentSettings.Execution.key = (Keys)exKey.SelectedItem;
            SimCSettings.currentSettings.Burst.key     = (Keys)BKey.SelectedItem;
            SimCSettings.currentSettings.Aoe.key       = (Keys)AoeKey.SelectedItem;

            SimCSettings.currentSettings.Cooldowns.mod = (ModifierKeys)cdMod.SelectedItem;
            SimCSettings.currentSettings.Execution.mod = (ModifierKeys)exMod.SelectedItem;
            SimCSettings.currentSettings.Burst.mod     = (ModifierKeys)bMod.SelectedItem;
            SimCSettings.currentSettings.Aoe.mod       = (ModifierKeys)aoeMod.SelectedItem;

            SimCSettings.Save();
            SimcraftImpl.UnregisterHotkeys();
            SimcraftImpl.RegisterHotkeys();
            Close();
        }
예제 #7
0
        public static void GenerateApls(String folder)
        {
            apls.Clear();
            inst.actions.Reset();

            if (current_action_list != null)
            {
                current_action_list.Unload();
            }


            SimcraftImpl.Write("Compiling Action Lists");

            foreach (var filename in Directory.GetFiles(folder))
            {
                if (!filename.EndsWith(".simc"))
                {
                    continue;
                }
                String contents   = File.ReadAllText(filename);
                var    currentApl = ActionPrioriyList.FromString(contents);
                if (currentApl.Class != Me.Class)
                {
                    continue;
                }

                var code      = currentApl.ToCode();
                var classname = RandomString(10);
                code = code.Replace("public class SimcraftRota", "public class " + classname);

                //SimcraftImpl.Write(code);

                Assembly asm = RuntimeCodeCompiler.CompileCode(code);

                Behavior attributes =
                    (Behavior)asm.GetTypes()[0].GetMembers()[0].GetCustomAttributes(typeof(Behavior), true).First();

                currentApl.Assembly = asm;

                SimcraftImpl.Write("New Apl: " + currentApl.Name);

                apls[currentApl.ToString()] = currentApl;
            }
        }
예제 #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            SimcraftImpl.GenerateApls(SimcraftImpl.SimcraftProfilePath);
            listBox1.Items.Clear();

            foreach (var apl in SimcraftImpl.apls)
            {
                //if (apl.Key.Match(StyxWoW.Me.Class, StyxWoW.Me.Specialization, WoWContext.PvE))
                //{
                if (apl.Value.Class == StyxWoW.Me.Class)
                {
                    listBox1.Items.Add(apl.Value);
                }
                //SimcraftImpl.Write("Selecting: " + apl.Value.Name);
                //apl.Value.CreateBehavior();
                //return;
                //}
            }
        }
예제 #9
0
 public static void Load()
 {
     try
     {
         SimcraftImpl.Write("Loading configuration");
         var reader =
             new XmlSerializer(typeof(SimCSettings));
         var file =
             new StreamReader(Path.Combine(Settings.CharacterSettingsDirectory, "SimCSettings.xml"));
         currentSettings = (SimCSettings)reader.Deserialize(file);
         SimcraftImpl.Write("Configuration successfully loaded.");
     }
     catch
     {
         SimcraftImpl.Write("Failed to load configuration, creating default configuration.");
         //Write("Exception: " + e);
         _currentSettings = DefaultConfig();
     }
 }
예제 #10
0
파일: Caching.cs 프로젝트: jodysaliba/simpl
        public MagicValueType this[String propertyName]
        {
            get
            {
                if (Retrieve() == null)
                {
                    return(new MagicValueType(0));
                }
                var guid = Retrieve().Guid;

                if (!Cache.ContainsKey(guid))
                {
                    Cache[guid] = NewProxyCacheEntry();
                }
                object val = Cache[guid][propertyName].Value;

                SimcraftImpl.LogDebug(bossname + " Property: " + propertyName + " : " + val);

                if (val is Decimal)
                {
                    return(new MagicValueType(Convert.ToDecimal(val)));
                }
                if (val is bool)
                {
                    return(new MagicValueType((bool)val));
                }
                if (val is int)
                {
                    return(new MagicValueType(Convert.ToDecimal(val)));
                }
                if (val is double)
                {
                    return(new MagicValueType(Convert.ToDecimal(val)));
                }
                if (val is MagicValueType)
                {
                    return((MagicValueType)val);
                }
                throw new ConstraintException("Unsupported Caching Types");
            }
        }
예제 #11
0
 public DiseaseProxy(SimcraftImpl simc)
 {
     this.simc = simc;
 }
예제 #12
0
파일: SimcraftTop.cs 프로젝트: aash/simpl
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count "+dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {

                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache = new ProxyCacheEntry();
                inst = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff = new DebuffProxy(() => conditionUnit);
                talent = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target = new TargetProxy(() => conditionUnit);
                runic_power = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease = new DiseaseProxy(this);
                blood = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus = new SetBonusProxy();
                prev_gcd = new PrevGcdProxy();
                prev = new PrevGcdProxy();
                pet = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal = new SealProxy();
                actions = new ActionProxy();
                stat = new StatProxy();
                obliterate = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g = BaseGcd();
                    g = g / ((100+spell_haste)/ 100);
                    return new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem);
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000/15;
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return Lua.GetReturnVal<double>("return GetTime()",0);
                });

                var s = new spell_data_t();
                s.name = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id = 138130;
                dbc.Spells.Add(138130, s);

                GenerateApls(SimcraftProfilePath);

                var settings = SimCSettings.currentSettings;
                if (settings.Specs.ContainsKey(Me.Specialization))
                {
                    var aplFileName = settings.Specs[Me.Specialization];
                    try
                    {
                        var apl = apls[aplFileName];
                        apl.CreateBehavior();
                        apl.PrintResolutionTable();
                        current_action_list = apl;
                    }
                    catch (KeyNotFoundException)
                    {
                        throw new ApplicationException(
                            string.Format("settings are incorrect for current spec {0}, it reference unexistent file {1}",
                            Me.Specialization, aplFileName));
                    }
                }
                else
                {
                    try
                    {
                        var apl = apls.Values.First(o => o.Class == Me.Class);
                        var filename = apls.Keys.First(k => apls[k] == apl);
                        settings.Specs[Me.Specialization] = filename;
                        SimCSettings.Save();
                        Write(string.Format("Settings does not tell which *.simc " +
                            "use for current spec({0}) so picking most appropriate: {1}",
                            Me.Specialization, filename));
                        apl.CreateBehavior();
                        apl.PrintResolutionTable();
                        current_action_list = apl;
                    }
                    catch (Exception)
                    {
                        throw new ApplicationException(
                            string.Format("There's not *.simc for current spec({0})",
                            Me.Specialization));
                    }
                }
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }
예제 #13
0
파일: SimcraftTop.cs 프로젝트: Pi1at/simpl
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count "+dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {

                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache = new ProxyCacheEntry();
                inst = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff = new DebuffProxy(() => conditionUnit);
                talent = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target = new TargetProxy(() => conditionUnit);
                runic_power = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease = new DiseaseProxy(this);
                blood = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus = new SetBonusProxy();
                prev_gcd = new PrevGcdProxy();
                prev = new PrevGcdProxy();
                pet = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal = new SealProxy();
                actions = new ActionProxy();
                stat = new StatProxy();
                obliterate = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g = BaseGcd();
                    g = g / ((100+spell_haste)/ 100);
                    return new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem);
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000/15;
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return Lua.GetReturnVal<double>("return GetTime()",0);
                });

                var s = new spell_data_t();
                s.name = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id = 138130;
                dbc.Spells.Add(138130, s);

            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }
예제 #14
0
        private void UNIT_SPELLCAST_SUCCEEDED(object sender, LuaEventArgs args)
        {
            //Logging.Write(args.EventName);
            //Write("bc: "+pet.buff.beast_cleave.up);
            //Write("ff: " + buff.frenzy.stack);

            //(Write("rav"+talent.ravager.enabled);
            //Write("ava:"+talent.avatar.enabled);

            /* var sw = new Stopwatch();
             * sw.Restart();
             *
             *
             * string cc = "local can_cast = {};";
             *
             * int i = 0;
             *
             * foreach (var sp in current_action_list.spells)
             * {
             *  cc += "u, m = IsUsableSpell(\""+"Kill Command"+"\"); can_cast["+i+"] = u;";
             *  i++;
             * }
             * cc += "return unpack(can_cast);";
             *
             * Lua.GetReturnValues(cc);
             *
             * Logging.Write(""+sw.ElapsedTicks+" checked spells "+i);*/

            if (args.Args[0].ToString().Equals("player"))
            {
                uint spellid = uint.Parse(args.Args[4].ToString());

                if (!dbc.Spells.ContainsKey(spellid))
                {
                    return;
                }

                LastSpellCast = dbc.Spells[spellid];

                prev.spell = LastSpellCast;

                LogDebug("Cast: " + LastSpellCast.name);

                if (LastSpellCast.id == 78203)
                {
                    var s = new Stopwatch();
                    s.Start();
                    apparitions.Add(s);
                }

                if (LastSpellCast.id == 8092)
                {
                    if (conditionUnit != null)
                    {
                        conditionUnit.ApplyMindHarvest();
                    }
                }

                if (LastSpellCast.id == 20271)
                {
                    last_judgment_target = conditionUnit;
                }

                if (LastSpellCast.gcd > 0)
                {
                    prev_gcd.spell = LastSpellCast;
                }

                if (LastSpellCast.name.Contains("Seal of"))
                {
                    seal.active = LastSpellCast.token.Split('_')[2];
                }


                if (talent.steady_focus.enabled)
                {
                    if (LastSpellCast.id == 77767)
                    {
                        BuffProxy.cShots++;
                        if (BuffProxy.cShots == 2)
                        {
                            BuffProxy.cShots = 0;
                            SimcraftImpl.Write(DateTime.Now + ": Steady Shots!");
                        }
                    }
                    if (CobraReset.Contains(LastSpellCast.id) && BuffProxy.cShots > 0)
                    {
                        BuffProxy.cShots = 0;
                    }
                }
            }
        }
예제 #15
0
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count " + dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {
                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache  = new ProxyCacheEntry();
                inst       = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health       = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy       = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus        = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi          = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage         = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff         = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff       = new DebuffProxy(() => conditionUnit);
                talent       = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown     = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell        = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target         = new TargetProxy(() => conditionUnit);
                runic_power    = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease        = new DiseaseProxy(this);
                blood          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy         = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph          = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus      = new SetBonusProxy();
                prev_gcd       = new PrevGcdProxy();
                prev           = new PrevGcdProxy();
                pet            = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana           = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power     = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal           = new SealProxy();
                actions        = new ActionProxy();
                stat           = new StatProxy();
                obliterate     = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g   = BaseGcd();
                    g       = g / ((100 + spell_haste) / 100);
                    return(new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem));
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return(SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000 / 15);
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return(Lua.GetReturnVal <double>("return GetTime()", 0));
                });


                var s = new spell_data_t();
                s.name  = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id    = 138130;
                dbc.Spells.Add(138130, s);
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }