Ejemplo n.º 1
0
        public static bool ImbueWeapon(String spellname, string slotname, int slotid)
        {
            bool retval;

            FTWLogger.log(Color.YellowGreen, "ImbueWeapon {0} {1} {2}", spellname, slotname, slotid);
            if (!SpellManager.HasSpell(spellname))
            {
                FTWLogger.log(Color.YellowGreen, "Don't have spell");
                retval = false;
            }
            else if (FTWCoreStatus.OnCooldown(spellname, true))
            {
                retval = false;
            }
            else
            {
                FTWLogger.log(Color.YellowGreen, "Imbuing {0} weapon with '{1}'", slotname, spellname);
                Lua.DoString(string.Format("CancelItemTempEnchantment({0})", slotid));
                Thread.Sleep(1000);
                FTWCoreActions.On_Cast(string.Format("Me.ImbueWeapon{0}", slotid), spellname, StyxWoW.Me, false, false);
                Thread.Sleep(1000);
                FTWCoreStatus.SaveCooldown(spellname);
                retval = true;
            }
            return(retval);
        }
Ejemplo n.º 2
0
        public bool EvaluateRules(String desiredsection)
        {
            FTWLogger.log("HasAura = " + StyxWoW.Me.HasAura("Serendipity"));
            FTWLogger.log("HasMyAura = " + StyxWoW.Me.HasMyAura("Serendipity"));

            string fnname = string.Format("FTWCore.EvaluateRules {0}", desiredsection);

            MyTimer.Start(fnname);

            FTWProps.mode = desiredsection;
            string result = string.Empty;

            List <String> origlines = FTWProps.rules[FTWProps.ClassAndSpec].Split('\n').ToList();

            // Replace left side of conditions with current values
            String s;

            MyTimer.Start("FTWCore.EvaluateRules.Replace");
            using (StyxWoW.Memory.AcquireFrame())
            {
                this.StartReplace();
                s = FTWProps.rules[FTWProps.ClassAndSpec];
                s = this.Replace("Me", s, StyxWoW.Me);
                s = this.Replace("Target", s, StyxWoW.Me.CurrentTarget);
                s = this.Replace("Tank", s, FTWProps.tank);
                s = this.Replace("Healer", s, FTWProps.healer);
                s = this.Replace("Heal", s, FTWProps.healTarget);
                s = this.Replace("Pet", s, StyxWoW.Me.Pet);
                s = this.Replace("Cleanse", s, FTWProps.cleanseTarget);
                s = this.Replace("Revive", s, FTWProps.reviveTarget);
                s = this.Replace("Add", s, FTWProps.add);
            }
            MyTimer.Stop("FTWCore.EvaluateRules.Replace");

            MyTimer.Start("FTWCore.EvaluateRules.Remainder");
            List <String> lines = s.Split('\n').ToList();

            lines.Add("@END OF FILE");

            for (int i = 0; i < lines.Count; i++)
            {
                lines[i] = lines[i].Replace("\n", "").Replace("\r", "");
            }
            for (int i = 0; i < origlines.Count; i++)
            {
                origlines[i] = origlines[i].Replace("\n", "").Replace("\r", "");
            }

            string        section    = null;
            string        action     = null;
            List <string> conditions = new List <string>();
            List <string> output     = new List <string>();

            for (int i = 0; i < lines.Count; i++)
            {
                // Skip blank lines
                if (lines[i].Replace("\t", "").Trim().Length == 0 || lines[i].Trim().StartsWith("--"))
                {
                    continue;
                }

                if (section == desiredsection)
                {
                    // Only process lines in the correct section
                    if (lines[i].StartsWith("\t"))
                    {
                        // New condition
                        conditions.Add(lines[i]);
                        output.Add(string.Format("{0:D3} {1} {2}", i + 1, origlines[i].Replace("\t", "    ").Replace("\"", "'"), lines[i].Replace("\t", "    ").Replace("\"", "'")));
                    }
                    else
                    {
                        // Finish off old action
                        bool ConditionsMatch = true;
                        if (action != null)
                        {
                            foreach (string check in conditions)
                            {
                                if (ConditionsMatch)
                                {
                                    //FTWLogger.debug(check + " - " + action + " - " + i);
                                    ConditionsMatch = EvaluateCondition(check, action, i);
                                }
                            }
                            if (!ConditionsMatch)
                            {
                                result = "SKIPPED";
                            }
                            else if (FTWCoreActions.ExecuteAction(action))
                            {
                                result = "TRUE";
                            }
                            else
                            {
                                result = "FALSE";
                            }

                            output.Add(string.Format("        {0}", result));
                            if (result == "TRUE")
                            {
                                //foreach (string xx in output)
                                //    FTWLogger.debug(xx);
                                MyTimer.Stop("FTWCore.EvaluateRules.Remainder");
                                MyTimer.Stop(fnname);
                                return(true);
                            }
                            //else
                            //{
                            //foreach (string xx in output)
                            //    FTWLogger.debug(result + " - " + xx);
                            //}
                            //if (action == "StopCasting")
                            //    foreach (string xx in output)
                            //        FTWLogger.debug(xx);
                        }
                        output = new List <string>();
                        conditions.Clear();
                        action = null;

                        // New action
                        if (!lines[i].StartsWith("@"))
                        {
                            action = lines[i];
                            output.Add(string.Format("{0:D3} {1}", i + 1, action));
                        }
                    }
                }
                if (lines[i].StartsWith("@"))
                {
                    // New section
                    section = lines[i];
                }
            }

            MyTimer.Stop("FTWCore.EvaluateRules.Remainder");
            MyTimer.Stop(fnname);
            return(false);
        }