Beispiel #1
0
        public bool CastSpell(spell_data_t spell, WoWUnit u, int LC, String Reason)
        {
            if (!ValidUnit(u) || u == null)
            {
                return(false);
            }

            if (!SpecialRequirementsCheck(spell))
            {
                return(false);
            }

            //if (SpellManager.CanCast(spell.name, u))

            if (SpellManager.Cast(spell.name, u))
            {
                LogDebug(spell.name + " Success!");
                return(true);
            }
            else
            {
                LogDebug(spell.name + " failed due to Cast");
                return(false);
            }

            LogDebug(spell.name + " failed due to CanCast?");
            return(false);
        }
Beispiel #2
0
 public static WoWAura GetAura(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
 {
     //if (aura == null) return null;
     if (unit != null)
     {
         LogDebug("Looking for " + aura.name);
         WoWAura wantedAura = null;
         var     mismatch   = 0;
         foreach (var a in unit.GetAllAuras())
         {
             LogDebug(a.Name + " " + a.IsActive + " " + a.TimeLeft.TotalSeconds + " " + Me.HasAura((int)a.SpellId));
             if (a.SpellId == aura.id &&
                 (!fromMyAura || a.CreatorGuid == Me.Guid || (Me.Pet != null && a.CreatorGuid == Me.Pet.Guid)))
             {
                 return(a);
             }
             if (a.Name.Equals(aura.name) && a.IsActive)
             {
                 mismatch = a.SpellId;
             }
         }
         if (mismatch > 0 &&
             !Mismatches.Contains("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
                                  aura.id + " / " + mismatch))
         {
             Mismatches.Add("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
                            aura.id + " / " + mismatch);
             Write("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
                   aura.id + " / " + mismatch);
         }
     }
     return(null);
 }
Beispiel #3
0
 public static IEnumerable <WoWUnit> UnfriendlyUnitsInSpellRange(spell_data_t s)
 {
     return
         (UnfriendlyUnits.Where(
              u =>
              u.Location.Distance(StyxWoW.Me.CurrentTarget.Location) <
              s.max_range + StyxWoW.Me.CurrentTarget.CombatReach));
 }
Beispiel #4
0
        public static List <Effect> GetAllSpellEffects(spell_data_t t)
        {
            var ret = new List <Effect>();

            foreach (var ef in t.effects)
            {
                ret.Add(dbc.Effects[ef]);
            }
            return(ret);
        }
Beispiel #5
0
        public static bool GetAuraUp(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
        {
            var wantedAura = GetAura(unit, aura, fromMyAura);

            if (wantedAura == null || !wantedAura.IsActive)
            {
                return(false);
            }
            return(true);
        }
Beispiel #6
0
        public static bool GetSpellOnCooldown(spell_data_t spell)
        {
            var s = GetSpell(spell);

            if (s == default(WoWSpell))
            {
                return(false);
            }
            return(s.Cooldown);
        }
Beispiel #7
0
        public static TimeSpan GetAuraTimeLeft(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
        {
            var wantedAura = GetAura(unit, aura, fromMyAura);

            if (wantedAura == null || !wantedAura.IsActive)
            {
                return(TimeSpan.Zero);
            }
            return(wantedAura.TimeLeft);
        }
Beispiel #8
0
        public static int GetAuraStacks(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
        {
            var wantedAura = GetAura(unit, aura, fromMyAura);

            if (wantedAura == null || !wantedAura.IsActive)
            {
                return(0);
            }
            return((int)wantedAura.StackCount);
        }
Beispiel #9
0
        public static TimeSpan GetSpellCooldown(spell_data_t spell)
        {
            var s = GetSpell(spell);

            if (s == default(WoWSpell))
            {
                return(TimeSpan.MaxValue);
            }
            return(s.CooldownTimeLeft);
        }
Beispiel #10
0
        public static bool CancelAura(spell_data_t aura, bool fromMyAura = false)
        {
            var wantedAura = GetAura(Me, aura, fromMyAura);

            if (wantedAura == null || !wantedAura.IsActive)
            {
                return(false);
            }
            wantedAura.TryCancelAura();
            return(true);
        }
Beispiel #11
0
 public bool SpecialRequirementsCheck(spell_data_t spell)
 {
     if (spell.name.Equals("Plague Leech"))
     {
         return(debuff.frost_fever.up && debuff.blood_plague.up);
     }
     if (spell.name.Equals("Blood Tap"))
     {
         return(buff.blood_charge.stack >= 5);
     }
     return(true);
 }
Beispiel #12
0
        public static WoWSpell GetSpell(spell_data_t spell)
        {
            SpellFindResults results;

            if (SpellManager.FindSpell((int)spell.id, out results))
            {
                if (results.Override != null)
                {
                    return(results.Override);
                }
                return(results.Original);
            }

            return(default(WoWSpell));
        }
Beispiel #13
0
        public Composite CycleTargets(String _spell, UnitCriteriaDelegate criteria, String Reason = "")
        {
            NameCount++;

            //Write("looking for spell: " + _spell);
            var actualSpell = LearnedSpellFromToken(_spell);

            if (actualSpell == null)
            {
                Write("Couldnt find " + _spell + " in our spellbook or in the Simcraft table");
                return(new ActionAlwaysFail());
            }

            return(new NamedComposite("" + NameCount, _spell,
                                      new Action(delegate
            {
                CycleTarget = null;
                conditionName = NameCount;
                _conditionSpell = actualSpell;
                foreach (var w in actives)
                {
                    conditionUnit = w;
                    if (criteria(w) && (CanCast(actualSpell.name, w, true)))
                    {
                        CycleTarget = w;
                        return RunStatus.Failure;
                    }
                }

                return RunStatus.Failure;
            }),
                                      new Decorator(ret => CycleTarget != null,
                                                    new Action(delegate
            {
                if (CastSpell(actualSpell, CycleTarget, 3, Reason))
                {
                    //LogDebug(_spell + " " + Reason + " => SUCCESS!");
                    return RunStatus.Success;
                }
                return RunStatus.Failure;
            }))));
        }
Beispiel #14
0
 public static bool IsChanneled(this spell_data_t t)
 {
     return(test_flag(t.attr1, 2));
 }
Beispiel #15
0
        public static void Main()
        {
            dbc = Serializer.DeSerializeObject("db.dbc");


            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;
            }


            int    c   = 0;
            String akk = "";

            SimcNames.Populate();


            //var u = new SimcNames.SpecList { new SimcNames.SpecPair(WoWSpec.None, 1), };

            /*foreach (var s in SimcNames.spells.Keys)
             * {
             * if (SimcNames.spells[s].Count == 0)  Console.WriteLine("spell::"+s);
             * }
             *
             * foreach (var s in SimcNames.debuffs.Keys)
             * {
             *  if (SimcNames.debuffs[s].Count == 0) Console.WriteLine("debuff::" + s);
             * }
             *
             * foreach (var s in SimcNames.buffs.Keys)
             * {
             *  if (SimcNames.buffs[s].Count == 0) Console.WriteLine("buff::" + s);
             * }*/


            //var attr = dbc.Spells[SimcNames.spells["sinister_strike"].First().V2].attr1;


            foreach (var s in dbc.Spells.Values)
            {
                if (s.IsChanneled() && SimcNames.spells.ContainsKey(s.token))
                {
                    Console.WriteLine(s.name);
                }
            }

            Console.ReadKey();

            /*String content = "";
             * foreach (var s in SimcNames.spells.Keys)
             * {
             *  if (!dbc.Spells.RelationContainsKey(s))
             *  {
             *      content += "spells[\"" + s + "\"]=new SpecList();" + Environment.NewLine;
             *      continue;
             *  }
             *  string arr = "";
             *
             *  foreach (var e in GetAllSpells(s))
             *  {
             *      arr += "new SpecPair(WoWSpec.None, "+e.id+"),";
             *
             *  }
             *  content += "spells[\"" + s + "\"]=new SpecList{" +arr+ "};" + Environment.NewLine;
             * }
             *
             * foreach (var s in SimcNames.buffs.Keys)
             * {
             *  if (!dbc.Spells.RelationContainsKey(s))
             *  {
             *      content += "buffs[\"" + s + "\"]=new SpecList();" + Environment.NewLine;
             *      continue;
             *  }
             *  string arr = "";
             *
             *  foreach (var e in GetAllSpells(s))
             *  {
             *      arr += "new SpecPair(WoWSpec.None, " + e.id + "),";
             *
             *  }
             *  content += "buffs[\"" + s + "\"]=new SpecList{" + arr + "};" + Environment.NewLine;
             * }
             *
             * foreach (var s in SimcNames.debuffs.Keys)
             * {
             *  if (!dbc.Spells.RelationContainsKey(s))
             *  {
             *      content += "debuffs[\"" + s + "\"]=new SpecList();" + Environment.NewLine;
             *      continue;
             *  }
             *  string arr = "";
             *
             *  foreach (var e in GetAllSpells(s))
             *  {
             *      arr += "new SpecPair(WoWSpec.None, " + e.id + "),";
             *
             *  }
             *  content += "debuffs[\"" + s + "\"]=new SpecList{" + arr + "};" + Environment.NewLine;
             * }
             *
             * File.WriteAllText("a.txt",content);
             *
             * Console.WriteLine(c);
             *
             * //Console.WriteLine(FindBuff("steady_focus").tooltip);
             *
             * //Console.WriteLine(e.Spells[lid].name + " " + e.Spells[lid].desc);*/
        }
Beispiel #16
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());
            }
        }
Beispiel #17
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;
                    }
                }
            }
        }
Beispiel #18
0
        public Composite Cast(String _spell, CanRunDecoratorDelegate del, GetUnitDelegate getTarget, String Reason)
        {
            NameCount++;

            WoWUnit _target;

            var actualSpell = LearnedSpellFromToken(_spell);

            if (actualSpell == null)
            {
                Write("Couldnt find " + _spell + " in our spellbook or in the Simcraft table");
                return(new ActionAlwaysFail());
            }



            return(new NamedComposite("" + NameCount, actualSpell.name,
                                      new Action(delegate
            {
                _target = getTarget();
                //if (_target != null && _target != Target1()) Write("Checking diff target");

                conditionName = NameCount;
                _conditionSpell = actualSpell;

                conditionUnit = _target;
                if (conditionUnit == null || conditionUnit == default(WoWUnit))
                {
                    conditionUnit = Me.CurrentTarget;
                }

                return RunStatus.Failure;
            }),
                                      new Decorator(_ret =>
            {
                if (actualSpell.gcd > 0 && SpellManager.GlobalCooldown)
                {
                    LogDebug("GCD Skip: " + actualSpell.name);
                    return false;
                }
                var d = del ?? (ret => true);
                try
                {
                    LogDebug(actualSpell.name + " if=" + Reason);
                    var r = d(_ret);
                    LogDebug(actualSpell.name + " => " + r);
                    if (!r)
                    {
                        return false;
                    }
                    return (CanCast(actualSpell.name, conditionUnit));
                }
                catch (Exception e)
                {
                    //Write(conditionName + " " + _spell + " " + e.ToString());
                    return false;
                }
            },
                                                    new Action(delegate
            {
                clickUnit = conditionUnit;
                //if (SpellManager.CanCast(spell.name, conditionUnit))
                if (CastSpell(actualSpell, conditionUnit, 3, Reason))
                {
                    //if (actualSpell.name.Contains("Fire")) Write("fire:"+conditionUnit.Guid.GetFriendlyString());
                    //LogDebug(_spell +  " => SUCCESS!");
                    start_line_cd();
                    return RunStatus.Success;
                }
                else
                {
                    LogDebug(_spell + " => FAIL!");
                }
                return RunStatus.Failure;
            }))));
        }