Esempio n. 1
0
        //---------------------------------------------------------------------------------------------

        public void CastSpell(string spellName, string target, bool useScrool, bool useSwitchHeadScrool, bool silence, bool forceScrool)
        {
            if (String.IsNullOrEmpty(spellName))
            {
                World.Player.PrintMessage("[Zvol kouzlo..]", MessageType.Error);
            }
            else
            {
                if (Necromancy.IsNecroSpell(spellName))
                {
                    Necromancy.Current.CastNecroSpell(spellName, target);
                }
                else
                {
                    StandardSpell sp;
                    if (Magery.ParseSpell(spellName, out sp))
                    {
                        this.CastSpell(sp, Targeting.ParseTargets((target == null ? "" : target).Split(',')), useScrool, useSwitchHeadScrool, silence, forceScrool);
                    }
                    else
                    {
                        Game.PrintMessage("Cast: " + spellName + " - Neexistuje!!!");
                    }
                }
            }
        }
Esempio n. 2
0
        //---------------------------------------------------------------------------------------------

        protected void OnInit()
        {
            if (Current == null)
            {
                Current = this;
            }
            this.SyncRoot = new object();
        }
Esempio n. 3
0
        //---------------------------------------------------------------------------------------------

        public static UOColor GetSpellPrintColor(string spellName)
        {
            StandardSpell sp;

            if (Magery.ParseSpell(spellName, out sp) && Magery.SpellPrinColor.ContainsKey(sp))
            {
                return(Magery.SpellPrinColor[sp]);
            }

            return(new UOColor(0x096));
        }
Esempio n. 4
0
        //---------------------------------------------------------------------------------------------

        public void MoveSpellNext(int direction, List <StandardSpell> switchCol)
        {
            if (switchCol == null)
            {
                switchCol = Magery.GetStandardSpells();             //Nebo all
            }
            int index = 0;

            try
            {
                StandardSpell sp;
                if (Magery.ParseSpell(this.SelectedSpell, out sp))
                {
                    index = UOExtensions.Utils.GetSwitchIndex(switchCol.IndexOf(sp), direction, switchCol.Count);
                }
            }
            catch { index = 0; }
            this.SelectedSpellSet = switchCol[index].ToString();
        }
Esempio n. 5
0
        public void CastSummonCreature(string summonName, TargetAliasResult target)
        {
            Game.RunScript(5000);
            Targeting.ResetTarget();

            CurrentCastingSummon = summonName;
            //World.Player.PrintMessage(summonName);
            Journal.Clear();

            if (!target.IsValid || !new UOObject(target).Exist)
            {
                target = Game.CurrentGame.CurrentHoverStatus;
            }

            if (!target.IsStatic && (!target.IsValid || !new UOObject(target).Exist || new UOObject(target).Distance > 25))
            {
                Magery.TrySetCastingSpell(new CastSpellInfo(StandardSpell.SummonCreature, false, false));
                UO.SummonCreature(summonName);
            }
            else
            {
                Magery.TrySetCastingSpell(new CastSpellInfo(StandardSpell.SummonCreature, false, true));
                UIManager.WaitForMenu(new MenuSelection("What do you want to summon ?", summonName));
                target.WaitTarget();
                UO.Cast("Summ. Creature");

                if (Journal.WaitForText(true, 150, "You can't see the target", "Target is not in line of sight"))
                {
                    if (Journal.Contains(true, "You can't see the target"))
                    {
                        Game.PrintMessage("Cant SEE: " + target + " / " + new UOCharacter(target).Exist + " / " + new UOCharacter(target).Name);
                    }
                    else if (Journal.Contains(true, "Target is not in line of sight"))
                    {
                        UO.PrintObject(target, Game.Val_LightPurple, "[Not in sight]");
                    }
                }
            }
        }
Esempio n. 6
0
        //---------------------------------------------------------------------------------------------

        public static List <StandardSpell> GetStandardSpells(params string[] spellNames)
        {
            List <StandardSpell> list = new List <StandardSpell>();

            if (spellNames.Length == 0 || (spellNames.Length == 1 && spellNames[0].ToLower() == "all"))
            {
                foreach (int val in Enum.GetValues(typeof(StandardSpell)))
                {
                    list.Add((StandardSpell)val);
                }
            }
            else
            {
                foreach (string name in spellNames)
                {
                    StandardSpell spell;
                    if (Magery.ParseSpell(name.Trim(), out spell) && !list.Contains(spell))
                    {
                        list.Add(spell);
                    }
                }
            }
            return(list);
        }
Esempio n. 7
0
        //---------------------------------------------------------------------------------------------

        /// <summary>
        /// Obecne kouzleni hlava + svitky, svitky omezena podpora na to co je SpellScrool, co chybi napsat dodela. Nefunguje na nekro kouzla. Pokud je kouzlo vypsano nad hlavou zelene = SVITEK
        /// </summary>
        /// <param name="spell">Kouzlo</param>
        /// <param name="target">Cil = pokud Serial.Invalid resp. null tak vyhodi tercik</param>
        /// <param name="useScrool">Pouzij svitek, pokud je, jinak hlava</param>
        /// <param name="useSwitchHeadScrool">Stridej svitek a hlavu, tj. uchovava si ke kazdemu kouzlo co bylo kouzleno naposled</param>
        /// <param name="silence">Nevypise nad hlavu jmeno kouzla + lvl, pouziva se v kodu kde chcete si vypadt neco extra</param>
        /// <param name="forceScrool">Vynutit svite, pokud neni svitek tak nekouzli a v CastResiltInfu vrat FALSe</param>
        /// <returns></returns>
        public CastResultInfo CastSpell(StandardSpell spell, Serial target, bool useScrool, bool useSwitchHeadScrool, bool silence, bool forceScrool)
        {
            Game.CheckStopBanding();
            Targeting.ResetTarget();
            Journal.Clear();

            CastResultInfo info = new CastResultInfo();

            info.Usage = useScrool ? CastUsage.Scrool : CastUsage.Head;

            if (htSwitch == null)
            {
                htSwitch = new Hashtable();
            }

            int circle = GetSpellCircle(spell);

            UOCharacter ch = new UOCharacter(target);

            if (ch.Exist && String.IsNullOrEmpty(ch.Name))
            {
                ch.Click();
                Game.Wait(50, true);
            }

            if (spell == StandardSpell.SummonCreature && !String.IsNullOrEmpty(this.selectedSummon))
            {
                Game.RunScript(5000);
                this.CastSummonCreature(this.selectedSummon, target);
            }
            else
            {
                if (htSwitch[spell] == null)
                {
                    htSwitch[spell] = info.Usage;
                }
                else if (useSwitchHeadScrool && !forceScrool)
                {
                    CastUsage currentUsage = (CastUsage)htSwitch[spell];
                    if (currentUsage == CastUsage.Head)
                    {
                        info.Usage = CastUsage.Scrool;
                    }
                    else
                    {
                        info.Usage = CastUsage.Head;
                    }
                }

                bool waitForScrool = false;
                if (info.Usage == CastUsage.Scrool && lastScrool.HasValue)
                {
                    double currentTimeout = GetScroolTimeout();
                    double currentTime    = (DateTime.Now - lastScrool.Value).TotalSeconds;

                    if (currentTime < currentTimeout)
                    {
                        waitForScrool = true;
                        if (!forceScrool)
                        {
                            info.Usage = CastUsage.Head;
                        }
                        Game.PrintMessage(String.Format("Scroll za! {0:N1}s", currentTimeout - currentTime));
                    }
                }

                //TODO zjistit Flag na jsem parnutej
                if (info.Usage == CastUsage.Scrool && !waitForScrool)
                {
                    if (SpellScrool.ContainsKey(spell) && World.Player.Backpack.AllItems.FindType(SpellScrool[spell]).Exist)
                    {
                        if (!target.IsValid || !new UOObject(target).Exist)
                        {
                            Magery.TrySetCastingSpell(new CastSpellInfo(spell, true, silence));
                            World.Player.Backpack.AllItems.FindType(SpellScrool[spell]).Use();

                            if (!Journal.WaitForText(true, 250, "You can't reach that", "You can't cast", "You can't read that"))
                            {
                                lastScrool   = DateTime.Now.AddMilliseconds(-250);
                                info.Usage   = CastUsage.Scrool;
                                info.Success = true;
                            }
                            else if (!forceScrool)
                            {
                                info.Usage = CastUsage.Head;
                            }
                        }
                        else
                        {
                            Magery.TrySetCastingSpell(new CastSpellInfo(spell, true, silence));

                            UO.WaitTargetObject(target);
                            World.Player.Backpack.AllItems.FindType(SpellScrool[spell]).Use();

                            if (!Journal.WaitForText(true, 250, "You can't reach that", "You can't cast", "You can't read that"))
                            {
                                lastScrool   = DateTime.Now.AddMilliseconds(-250);
                                info.Usage   = CastUsage.Scrool;
                                info.Success = true;
                            }
                            else if (!forceScrool)
                            {
                                info.Usage = CastUsage.Head;
                            }
                        }
                    }
                    else if (!forceScrool)
                    {
                        info.Usage = CastUsage.Head;
                    }
                }

                ushort color = CalStatusMessage.Val_InfoColor;
                //if (info.Usage == CastUsage.Scrool)
                //{
                //  color = Game.Val_Green;
                //  if (!silence)
                //    World.Player.PrintMessage(spell + " [" + World.Player.Backpack.AllItems.FindType(SpellScrool[spell]).Amount + "ks]", color);
                //}

                htSwitch[spell] = info.Usage;

                if (info.Usage == CastUsage.Head)
                {
                    //Game.RunScript(Magery.GetCircleRunscriptTime(Magery.GetSpellCircle(spell)));

                    if (!target.IsValid || !new UOObject(target).Exist || new UOObject(target).Distance > 30)
                    {
                        Magery.TrySetCastingSpell(new CastSpellInfo(spell, false, silence));
                        UO.Cast(spell);
                    }
                    else
                    {
                        Magery.TrySetCastingSpell(new CastSpellInfo(spell, false, silence));
                        UO.Cast(spell, target);

                        if (Journal.WaitForText(true, 150, "You can't see the target", "Target is not in line of sight"))
                        {
                            if (Journal.Contains(true, "You can't see the target"))
                            {
                                info.CantSee = true;

                                Game.PrintMessage("Cant SEE: " + target + " / " + new UOCharacter(target).Exist + " / " + new UOCharacter(target).Name);

                                info.Success = CastSpell(spell, Serial.Invalid, useScrool, useSwitchHeadScrool, silence, forceScrool).Success;
                            }
                            else if (Journal.Contains(true, "Target is not in line of sight"))
                            {
                                info.NoInLineOfSight = true;

                                new UOObject(target).PrintMessage("[Not in sight]", Game.Val_LightPurple);
                            }
                        }
                        else
                        {
                            if (ch.Exist && !silence &&
                                (spell == StandardSpell.Harm ||
                                 spell == StandardSpell.FlameStrike ||
                                 spell == StandardSpell.MagicArrow ||
                                 spell == StandardSpell.Lightning ||
                                 spell == StandardSpell.Clumsy ||
                                 spell == StandardSpell.Curse ||
                                 spell == StandardSpell.EnergyBolt ||
                                 spell == StandardSpell.Feeblemind ||
                                 spell == StandardSpell.MindBlast ||
                                 spell == StandardSpell.Paralyze)
                                )
                            {
                                if (target != World.Player.Serial)
                                {
                                    new UOObject(target).PrintMessage(String.Format("[{0}/{1}]", ch.Hits, ch.MaxHits), ch.Notoriety == Notoriety.Murderer || ch.Notoriety == Notoriety.Enemy ? Game.GetEnemyColorByHits(target) : Game.GetAlieColorByHits(target));
                                }
                            }
                        }
                    }

                    if (Journal.WaitForText(true, 100, "The spell is not in your spellbook"))
                    {
                        info.Success        = false;
                        info.NotInSpellBook = true;
                        Targeting.ResetTarget();
                    }
                    else if (!info.CantReach)
                    {
                        info.Success = true;
                    }
                }
                else
                {
                    Game.PrintMessage(spell + ": " + World.Player.Backpack.AllItems.FindType(SpellScrool[spell]).Amount + "");
                }
            }


            return(info);
        }
Esempio n. 8
0
        //---------------------------------------------------------------------------------------------

        public void MoveSpellNext(int direction, params string[] spells)
        {
            this.MoveSpellNext(direction, Magery.GetStandardSpells(spells));
        }