Beispiel #1
0
        //---------------------------------------------------------------------------------------------

        protected void World_CharacterAppeared(object sender, CharacterAppearedEventArgs e)
        {
            World.CharacterAppeared -= World_CharacterAppeared;
            UOCharacter appeared = new UOCharacter(e.Serial);

            if (appeared.Model == 0x0053 && !appeared.Renamable)
            {
                if (CalExtension.Abilities.GolemMaster.AdaHammer.Exist)
                {
                    Targeting.ResetTarget();
                    UO.WaitTargetObject(appeared);
                    CalExtension.Abilities.GolemMaster.AdaHammer.Use();

                    if (!Game.IsMob(appeared) && !Game.IsMobRenamed(appeared))
                    {
                        appeared.Click();
                        Game.Wait(200);

                        if (appeared.RequestStatus(200))
                        {
                            Game.Rename(appeared);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void World_CharacterAppeared(object sender, CharacterAppearedEventArgs e)
        {
            UOCharacter ch = new UOCharacter(e.Serial);

            if (String.IsNullOrEmpty(ch.Name))
            {
                ch.RequestStatus(250);
            }

            StatusMultipleItem itm = new StatusMultipleItem(e.Serial);

            this.Controls.Add(itm);
            //this.name.Text +=  ch.Name + Environment.NewLine;

            this.Invalidate();
        }
Beispiel #3
0
        public void TameCharacter(UOCharacter character, int maxTries, bool keepDisttance)//, Robot r)
        {
            Game.CurrentGame.CurrentPlayer.SwitchWarmode();

            Robot r = new Robot();

            r.UseTryGoOnly     = true;
            r.SearchSuqareSize = 20;

            UOItem currentStaff = EnsuredTamingStaff;
            int    tries        = 0;

            Game.PrintMessage(String.Format("{0}, {1}, {2}, {3}, {4}", character.Exist, character.RequestStatus(500), character.Hits, character.Distance, UO.Dead));

            while (character.Exist && character.RequestStatus(500) && character.Hits > 0 && character.Distance < 6 && !UO.Dead)
            {
                UO.DeleteJournal();

                bool end  = false;
                bool kill = false;

                if (character.Distance > 2 && keepDisttance)
                {
                    r.GoTo(new UOPositionBase(character.X, character.Y, 0), 2, 2);
                    Game.Wait(500);
                }
                UO.Say("Baf");
                Game.Wait();

                UO.UseSkill("Hiding");
                Game.Wait();
                IRequestResult result = UO.WaitTargetObject(character.Serial);
                currentStaff.Use();
                //Game.Wait(500);
                SkillValue tamingValue = SkillsHelper.GetSkillValue("AnimalTaming");
                UOItem     robe        = World.Player.Layers[Layer.OuterTorso];
                Game.PrintMessage("RV: " + tamingValue.RealValue + " / " + robe.Exist);

                using (JournalEventWaiter jew = new JournalEventWaiter(true,
                                                                       "You can't see the target",
                                                                       "Ochoceni se nezdarilo",
                                                                       "Your taming failed",
                                                                       "byl tamnut",
                                                                       "not tamable",
                                                                       "You are not able to tame",
                                                                       "Jsi moc daleko",
                                                                       "Jeste nemuzes pouzit hulku",
                                                                       "toto zvire nelze ochocit",
                                                                       "Toto zvire nedokazes ochocit",
                                                                       "You are not able to tame this animal"

                                                                       ))
                {
                    if (jew.Wait(15000))
                    {
                        if (Journal.Contains(true, "Ochoceni se nezdarilo"))
                        {
                            Game.PrintMessage("Try - Ochoceni se nezdarilo");
                        }
                        else if (Journal.Contains(true, "Your taming failed"))
                        {
                            Game.PrintMessage("Try - Your taming failed");
                        }
                        else if (Journal.Contains(true, "Jeste nemuzes pouzit hulku"))
                        {
                            Game.PrintMessage("Try - Jeste nemuzes pouzit hulku");
                            Game.Wait(6000);
                        }
                        else if (Journal.Contains(true, "Jsi moc daleko"))
                        {
                            if (keepDisttance)
                            {
                                bool go = r.GoTo(new UOPositionBase(character.X, character.Y, 0), 1, 10);
                                if (!go)
                                {
                                    end = true;
                                }
                                Game.Wait();
                                Game.PrintMessage("Try - Jsi moc daleko: " + go);
                            }
                        }
                        else if (Journal.Contains(true, "You can't see the target"))
                        {
                            UO.WaitTargetCancel();
                            Game.Wait();
                            UO.Press(System.Windows.Forms.Keys.Escape);
                            Game.Wait();
                            Game.CurrentGame.CurrentPlayer.SwitchWarmode();
                            Game.Wait();
                            bool go = r.GoTo(new UOPositionBase(character.X, character.Y, 0), 1, 10);
                            if (!go)
                            {
                                end = true;
                            }
                            Game.Wait();

                            Game.PrintMessage("Try - You can't see the target go: " + go);
                        }
                        else if (Journal.Contains(true, "byl tamnut"))// && currentStaff.Color == TamingStaff.Color)
                        {
                            Game.PrintMessage("End - byl tamnut");
                            end = true;
                        }
                        else if (Journal.Contains(true, "not tamable") || Journal.Contains(true, "toto zvire nelze ochocit"))
                        {
                            character.Click();
                            Game.Wait(500);
                            character.RequestStatus(500);

                            bool isTrofejAnimal = false;// TrofejKlamaci.Contains(character.Model);

                            foreach (Graphic g in TrofejKlamaci)
                            {
                                if (g == character.Model)
                                {
                                    isTrofejAnimal = true;
                                }
                            }


                            if (isTrofejAnimal && character.Notoriety != Notoriety.Innocent && character.Notoriety != Notoriety.Invulnerable && character.Notoriety != Notoriety.Guild)//krysa/hind/bear/goat/snake atd)TODO
                            {
                                kill = true;
                                //zabit / riznout / vylotit
                                Game.PrintMessage("Kill - not tamable " + character.Model);
                            }
                            else
                            {
                                Game.PrintMessage("End - not tamable");
                                end = true;
                            }
                        }
                        else if (Journal.Contains(true, "Toto zvire nedokazes ochocit") || Journal.Contains(true, "You are not able to tame this animal"))
                        {
                            if (World.Player.Backpack.AllItems.FindType(0x1F03).Exist)
                            {
                                World.Player.Backpack.AllItems.FindType(0x1F03).Use();
                                Game.Wait(500);
                            }
                            else if (World.Player.Backpack.AllItems.FindType(0x1F01).Exist)
                            {
                                World.Player.Backpack.AllItems.FindType(0x1F01).Use();
                                Game.Wait(500);
                            }

                            if (tries > 1)
                            {
                                Game.PrintMessage("End - Nelze ochocit " + character.Serial);
                                end = true;
                            }

                            Game.Wait(3500);
                        }
                        else
                        {
                            Game.Wait(1000);
                        }
                    }
                    else
                    {
                        if (Game.CurrentGame.WorldSave())
                        {
                            Game.Wait(60000);
                            Game.PrintMessage("Try - WordSave" + character.Serial);
                        }
                        else
                        {
                            if (tries > 1)
                            {
                                Game.PrintMessage("End - JEW timeout " + character.Serial);
                                end = true;
                            }
                        }
                    }

                    if (tries > maxTries)// && currentStaff.Color == TrainTamingStaff.Color)
                    {
                        end = true;
                    }

                    if (tamingValue.RealValue < 1000 && maxTries < 100)
                    {
                        bool switchToTrain  = false;
                        bool switchToTaming = false;
                        if (tries == 0)
                        {
                            if ((Journal.Contains(true, "nenauc") || Journal.Contains(true, "You Cannot learn anything more")) && robe.Exist)
                            {
                                robe.Move(1, World.Player.Backpack);
                                Game.Wait();
                                switchToTrain = true;
                            }

                            if (!Journal.Contains(true, "nenauc"))
                            {
                                switchToTrain = true;
                            }
                        }
                        else if (tries == 1)
                        {
                            if (Journal.Contains(true, "nenauc") || Journal.Contains(true, "You Cannot learn anything more"))
                            {
                                switchToTaming = true;

                                Game.PrintMessage("robe.Exist:" + robe.Exist);

                                if (robe.Exist)
                                {
                                    robe.Use();
                                    Game.Wait();
                                }
                            }
                        }

                        if (switchToTrain)
                        {
                            if (World.Player.Backpack.AllItems.FindType(TrainTamingStaff.Graphic, TrainTamingStaff.Color).Exist)
                            {
                                currentStaff = World.Player.Backpack.AllItems.FindType(TrainTamingStaff.Graphic, TrainTamingStaff.Color);
                            }
                            else if (World.Player.Layers.FindType(TrainTamingStaff.Graphic, TrainTamingStaff.Color).Exist)
                            {
                                currentStaff = World.Player.Backpack.AllItems.FindType(TrainTamingStaff.Graphic, TrainTamingStaff.Color);
                            }

                            Game.Wait();
                        }


                        if (switchToTaming)
                        {
                            currentStaff = EnsuredTamingStaff;
                            Game.Wait();
                        }
                    }
                    if (tries > 2)
                    {
                        if (Journal.Contains(true, "nenauc") || currentStaff.Color == TamingStaffCharged.Color && !World.Player.Layers[Layer.OuterTorso].Exist)
                        {
                            if (World.Player.Backpack.AllItems.FindType(0x1F03).Exist)
                            {
                                World.Player.Backpack.AllItems.FindType(0x1F03).Use();
                                Game.Wait();
                            }
                            else if (World.Player.Backpack.AllItems.FindType(0x1F01).Exist)
                            {
                                World.Player.Backpack.AllItems.FindType(0x1F01).Use();
                                Game.Wait(500);
                            }
                        }
                    }

                    if (kill)
                    {
                        this.KillCharacter(character);
                    }

                    if (end)
                    {
                        Game.PrintMessage("While - end: " + tries);
                        //   doneList.Remove(character.Serial);
                        break;
                    }
                }
                tries++;
                Game.PrintMessage("While - cyklus pokus: " + tries);
            }

            foreach (UOItem item in World.Ground)
            {
                if (item.Distance < 5)
                {
                    bool isKlamak = false;
                    foreach (Graphic g in Taming2.ShrinkKlamaci)
                    {
                        if (item.Graphic == g)
                        {
                            isKlamak = true;
                        }
                    }

                    if (Array.IndexOf(ItemLibrary.ShrinkKlamaci.GraphicArray, item.Graphic) > -1 || Array.IndexOf(ShrinkKlamaci, item.Graphic) > -1 || isKlamak)
                    {
                        item.Move(1, (ushort)(World.Player.X + 1), (ushort)(World.Player.Y + 1), item.Z);
                        Game.Wait(150);
                        item.Move(1, World.Player.Backpack, 30, 30);
                        Game.Wait(150);
                    }
                }
            }

            Game.PrintMessage("While - END");
            if (World.Player.Backpack.AllItems.FindType(0x1F03).Exist)
            {
                World.Player.Backpack.AllItems.FindType(0x1F03).Use();
                Game.Wait(250);
            }
            else if (World.Player.Backpack.AllItems.FindType(0x1F01).Exist)
            {
                World.Player.Backpack.AllItems.FindType(0x1F01).Use();
                Game.Wait(250);
            }
        }
Beispiel #4
0
        public void MobKill(int resetTimer)
        {
            ResetTimerDefault = resetTimer;
            Game.CurrentGame.CurrentPlayer.EnsureWarMode();

            List <MobKillInfo> mobQueue = this.MobQueue;

            MobKillInfo current = null;
            MobKillInfo last    = null;

            int startIndex = 0;

            for (int i = 0; i < mobQueue.Count; i++)
            {
                MobKillInfo k = mobQueue[i];
                if (lastMob.IsValid && lastMob == k.Mob.Serial)
                {
                    //Game.PrintMessage("startIndex " + startIndex + " / " + Game.RenameSufix(k.Mob.Name), Game.Val_GreenBlue);
                    if (i < mobQueue.Count - 1)
                    {
                        startIndex = i + 1;
                        lastMob    = Serial.Invalid;
                    }
                    else
                    {
                        last = k;//new MobKillInfo(new UOCharacter(lastMob), resetTimer);
                    }
                }

                if (k.CommandCount == 0 && k.Mob.Serial != k.GetEnemyOrDefault().Serial)
                {
                    //Game.PrintMessage("New FOUND " + k.Mob.Name + " / " + i, Game.Val_GreenBlue);
                    current = mobQueue[i];
                    break;
                }
            }

            if (current == null)
            {
                for (int i = startIndex; i < mobQueue.Count; i++)
                {
                    MobKillInfo k = mobQueue[i];
                    if (k.NeedCommand())
                    {
                        //Game.PrintMessage("New OLD " + k.Mob.Name + " / " + i, Game.Val_GreenBlue);
                        current = k;
                        break;
                    }
                }
            }

            if (current == null && last != null && last.NeedCommand())
            {
                current = last;
            }

            //Game.PrintMessage("Mobs [" + mobQueue.Count + "]", Game.Val_GreenBlue);

            string  command  = null;
            UOColor sayColor = Game.Val_LightGreen;

            UOCharacter finalEnemy = new UOCharacter(Serial.Invalid);

            if (current != null)
            {
                command = current.Mob.Name + " kill";
                current.CommandCount++;
                current.LastCommandTime = DateTime.Now;
                sayColor = Game.GetAlieColorByHits(current.Mob.Serial);
                current.Mob.PrintMessage(Game.RenameSufix(current.Mob.Name) + (!String.IsNullOrEmpty(current.CommandReasonCode) && Game.Debug ? " [" + current.CommandReasonCode + "]" : ""), sayColor);//zatim pro debug

                if (!current.Enemy.ExistCust())
                {
                    current.Enemy = current.GetEnemy();
                }

                finalEnemy = current.Enemy;

                lastMob = current.Mob.Serial;
            }
            else if (mobQueue.Count == 0)
            {
                command = "all kill";
            }

            if (!String.IsNullOrEmpty(command) && finalEnemy.ExistCust() && finalEnemy.Distance < 22)
            {
                Targeting.ResetTarget();
                Game.RunScriptCheck(250);
                Game.Wait(50);
                UO.WaitTargetObject(finalEnemy);

                UO.Say(sayColor, command);
            }

            if (finalEnemy.ExistCust())
            {
                if (finalEnemy.Hits < 0)
                {
                    finalEnemy.RequestStatus(150);
                }



                finalEnemy.PrintMessage(String.Format(">>{0}/{1}<<", finalEnemy.Hits, finalEnemy.MaxHits), Game.GetEnemyColorByHits(finalEnemy.Serial));
                new StatusBar().Show(finalEnemy.Serial);
            }
        }
Beispiel #5
0
        public CallbackResult OnNextTarget(byte[] data, CallbackResult prevResult)
        {
            PacketReader reader = new PacketReader(data);

            if (reader.ReadByte() != 0x11)
            {
                throw new Exception("Invalid packet passed to OnNextTarget method.");
            }
            ushort blockSize = reader.ReadUInt16();
            uint   serial    = reader.ReadUInt32();

            if (serial == Aliases.Self)
            {
                return(CallbackResult.Normal);
            }
            Aliases.SetObject("laststatus", serial);
            UOCharacter cil = World.GetCharacter(serial);

            if (cil.Hits < 0 || cil.Hits > 10000)
            {
                cil.RequestStatus(20);
                return(CallbackResult.Normal);
            }
            else
            {
                ushort color = 0;
                string not   = cil.Notoriety.ToString();
                switch (not)
                {
                case "Criminal":
                    color = 0x0026;
                    break;

                case "Enemy":
                    color = 0x0031;
                    break;

                case "Guild":
                    color = 0x0B50;
                    break;

                case "Innocent":
                    color = 0x0058;
                    break;

                case "Murderer":
                    color = 0x0026;
                    break;

                case "Neutral":
                    color = 0x03BC;
                    break;

                case "Unknown":
                    color = 0x03BC;
                    break;

                default:
                    color = Phoenix.Env.DefaultInfoColor;
                    break;
                }
                UO.Print(color, "{0} : {1}/{2} ({3})", cil.Name, cil.Hits, cil.MaxHits, cil.Distance);
                return(CallbackResult.Normal);
            }
        }
Beispiel #6
0
        private void UpdateStats()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(UpdateStats));
                return;
            }

            if (mobile.Name != null)
            {
                name.Text = mobile.Name;
            }

            //UO.Print("P: " + String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits));

            if (mobile.MaxHits > -1)
            {
                hits.Text         = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
                healthBar.Hits    = mobile.Hits;
                healthBar.MaxHits = mobile.MaxHits;
                healthBar.Poison  = mobile.Poisoned;
                healthBar.Unknown = false;
                statusNeeded      = false;


                if (this.StatusType == StatusType.Player)
                {
                }
                else
                {
                    lastMaxHits = mobile.MaxHits;
                }
            }
            else
            {
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                }
                else
                {
                    if ((DateTime.Now - initTime).TotalSeconds > 20 && mobile.Hits <= 1)
                    {
                        WindowManager.GetDefaultManager().BeginInvoke(Close);
                        return;
                    }
                }
            }

            Notoriety n = mobile.Notoriety;

            if (mobile.Distance > 18)
            {
                n = Notoriety.Unknown;
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                }
            }

            HueEntry notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
            ushort   noto  = notoh.Colors[12];

            if (statDown)
            {
                noto = DataFiles.Hues.Get(0x01c0).Colors[12];
            }
            else
            {
                if (this.StatusType == StatusType.Mob)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }

                if (this.StatusType == StatusType.Player && Game.IsHealOn)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];

                    if (CalebConfig.HealMoby && Game.CurrentGame.HasAliveAlie)
                    {
                        noto = DataFiles.Hues.Get(0x000d).Colors[12];
                    }
                }
            }

            //1c0

            BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));

            // Do we need status?
            if (healthBar.Unknown)
            {
                statusNeeded = true;
            }

            // Request if mob is visible
            if (statusNeeded && mobile.Distance < 19 && DateTime.Now - lastRequest < TimeSpan.FromSeconds(10))
            {
                statusNeeded = false;
                lastRequest  = DateTime.Now;
                mobile.RequestStatus();
            }
        }
Beispiel #7
0
        //---------------------------------------------------------------------------------------------

        private void World_CharacterAppeared(object sender, CharacterAppearedEventArgs e)
        {
            if (e.Serial == World.Player.Serial)
            {
                return;
            }

            if (!(CalebConfig.Rename == RenameType.OnAppeared || CalebConfig.Rename == RenameType.Booth))
            {
                return;
            }

            UOCharacter ch          = new UOCharacter(e.Serial);
            bool        requestStat = false;

            if (ch.Hits < 0)
            {
                //hallucination sychr

                bool badBody =
                    World.Player.Model != 0x0190 && //Male
                    World.Player.Model != 0x0191 && //Female
                    World.Player.Model != 0x00D4;   //Grizly //TODO srnka //Drak

                if (badBody)
                {
                    if (Magery.CastingSpellInfo != null)
                    {
                        if (
                            (
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonCreature ||
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonAirElemental ||
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonDaemon ||
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonFireElemental ||
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonWaterElemental ||
                                Magery.CastingSpellInfo.Spell == StandardSpell.SummonEarthElemental
                            ) &&
                            Magery.CastingSpellInfo.CastRunDuration < 5500)
                        {
                            requestStat = true;
                        }
                    }


                    //Vyhozeni klamaka
                }

                if (MobMaster.LasTimeUseKlamak.HasValue && (DateTime.Now - MobMaster.LasTimeUseKlamak.Value).TotalMilliseconds < 1000 && !ch.Renamable)
                {
                    requestStat = true;
                }
            }

            if (!Game.IsPossibleMob(ch))
            {
                return;
            }

            if (Rename.IsMobRenamed(ch.Serial))
            {
                return;
            }

            if (Game.IsPossibleMob(ch) && MobMaster.LasTimeUseKlamak.HasValue && (DateTime.Now - MobMaster.LasTimeUseKlamak.Value).TotalMilliseconds < 1000 && !ch.Renamable)
            {
                requestStat = true;
            }

            if (requestStat)
            {
                ch.RequestStatus(200);
            }

            if (!Rename.RenameCharacter(ch.Serial))
            {
                if (ch.Name == null || !Rename.IsMobRenamed(ch.Serial))
                {
                    ch.Changed += mob_Changed;
                }
            }

            if (Rename.IsMobRenamed(ch.Serial))
            {
                new StatusBar().Show(ch.Serial);
                return;
            }
        }
Beispiel #8
0
        public static MobRenameInfo RenameCharacter(Serial serial, int maxTries)
        {
            UOCharacter   ch         = new UOCharacter(serial);
            MobRenameInfo renameInfo = EnsureRegisterRenameInfo(serial);//Game.renamedHt[serial] != null ? (MobRenameInfo)Game.renamedHt[serial] : new MobRenameInfo();

            if (renameInfo.Success || renameInfo.Tries >= maxTries)
            {
                return(renameInfo);
            }

            renameInfo.Tries++;

            bool check = false;

            check = !String.IsNullOrEmpty(ch.Name);

            if (!check)
            {
                if (Game.Debug)
                {
                    Game.PrintMessage("Rename Check - Name EMPTY");
                }
                check = ch.RequestStatus(250 + Core.CurrentLatency);
            }

            if (!check)
            {
                if (Game.Debug)
                {
                    Game.PrintMessage("Rename Check - !RequestStatus");
                }

                ch.Click();
                Game.Wait(150);
                check = !String.IsNullOrEmpty(ch.Name) && ch.RequestStatus(250);
            }

            renameInfo.OriginalName = ch.Name;

            if (check)
            {
                string playerCode = Rename.PlayerShortCode;

                if ((ch.Name + String.Empty).StartsWith(playerCode))
                {
                    renameInfo.NewName = ch.Name;
                    renameInfo.Success = true;
                }
                else if (ch.Renamable || Game.IsPossibleMob(ch) && ch.Distance <= 4)//Uvidime, ty klamaky nejak casti blbnou oproti summum
                {
                    var chars  = "abcdefghijklmnopqrstuvwxyz1234567890";
                    var random = new Random();
                    var result = new string(
                        Enumerable.Repeat(chars, 5)
                        .Select(s => s[random.Next(s.Length)])
                        .ToArray());

                    result = playerCode + result;
                    if (result.Length > 1)
                    {
                        result = result.Substring(0, result.Length - 2) + result[result.Length - 2].ToString().ToUpper() + result[result.Length - 1].ToString().ToUpper();
                    }
                    renameInfo.NewName = result;
                    renameInfo.Success = ch.Rename(result);


                    if (Game.Debug)
                    {
                        Game.PrintMessage("Rename : " + renameInfo.Success + " [" + result + "]/[" + renameInfo.OriginalName + "]");
                    }

                    Game.Wait(Core.CurrentLatency);

                    if (renameInfo.Success)
                    {
                        byte[] data = PacketBuilder.CharacterSpeechUnicode(ch.Serial, ch.Model, result, SpeechType.Regular,
                                                                           SpeechFont.Normal, Game.Val_PureWhite,
                                                                           "[ " + result + " ]");
                        Core.SendToClient(data, true);
                    }
                }
            }
            else if (Game.Debug)
            {
                Game.PrintMessage("!Rename Check");
            }

            if (renameInfo.Success)
            {
                new StatusBar().Show(ch.Serial);
            }

            return(renameInfo);
        }
Beispiel #9
0
        //---------------------------------------------------------------------------------------------

        private void UpdateStats()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(UpdateStats));
                return;
            }

            if (mobile.Name != null)
            {
                name.Text = mobile.Name;
            }

            bool isDmg = lastMaxHits > mobile.MaxHits && mobile.MaxHits > -1;

            if (mobile.MaxHits > -1)
            {
                hits.Text         = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
                healthBar.Hits    = mobile.Hits;
                healthBar.MaxHits = mobile.MaxHits;
                healthBar.Poison  = mobile.Poisoned;
                healthBar.Unknown = false;
                statusNeeded      = false;

                if (this.StatusType == StatusType.Player)
                {
                    mana.Text       = String.Format("{0}/{1}", mobile.Mana, mobile.MaxMana);
                    manaBar.Mana    = mobile.Mana;
                    manaBar.MaxMana = mobile.MaxMana;
                    manaBar.Unknown = false;

                    stam.Text          = String.Format("{0}/{1}", mobile.Stamina, mobile.MaxStamina);
                    staminaBar.Stam    = mobile.Stamina;
                    staminaBar.MaxStam = mobile.MaxStamina;
                    staminaBar.Unknown = false;

                    ar.Text     = String.Format("ar: {0}", World.Player.Armor);
                    weight.Text = String.Format("w: {0}", World.Player.Weight);
                }
                else
                {
                    UpdatePositionAndDirection();

                    lastMaxHits = mobile.MaxHits;
                }
            }
            else
            {
                healthBar.Unknown = true;

                if (this.StatusType == StatusType.Player)
                {
                    staminaBar.Unknown = true;
                    manaBar.Unknown    = true;
                }
                else
                {
                    if (this.chbxKeep.Checked)
                    {
                        UpdatePositionAndDirection();
                    }
                    else
                    {
                        int limit = 8;

                        if ((DateTime.Now - initTime).TotalSeconds > limit && mobile.Hits <= 1)
                        {
                            WindowManager.GetDefaultManager().BeginInvoke(Close);
                            return;
                        }
                    }
                }
            }

            Notoriety n = mobile.Notoriety;

            if (mobile.Distance > 18)
            {
                n = Notoriety.Unknown;
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                    staminaBar.Unknown = true;
                    manaBar.Unknown    = true;
                }
            }

            HueEntry notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
            ushort   noto  = notoh.Colors[12];

            if (statDown && this.chbxAlie.Checked)
            {
                noto = DataFiles.Hues.Get(0x01c0).Colors[12];
            }
            else
            {
                if (this.StatusType == StatusType.Mob)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }

                if (this.StatusType == StatusType.Player && Game.IsHealOn)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }
            }

            if (!DefaultColor.HasValue || !MouseHovering)
            {
                if (this.StatusType == StatusType.Player)
                {
                    BackColor = Color.Black;
                }
                else
                {
                    BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));
                }

                if (!DefaultColor.HasValue)
                {
                    DefaultColor = CurrentColor = BackColor;
                }
            }

            if (healthBar.Unknown)
            {
                statusNeeded = true;
            }

            // Request if mob is visible
            if (statusNeeded && mobile.Distance < 22 && DateTime.Now - lastRequest < TimeSpan.FromSeconds(10))
            {
                statusNeeded = false;
                lastRequest  = DateTime.Now;
                mobile.RequestStatus();
            }

            //if (this.currentWrapper != null)
            //{
            //  if ((DateTime.Now - initTime).TotalSeconds > 2 && (this.healthBar.Unknown || this.mobile.Hits <= 0 || this.mobile.Distance > 18))
            //  {
            //    WindowManager.GetDefaultManager().BeginInvoke(Close);
            //    return;
            //  }
            //  else
            //    this.currentWrapper.UpdateLayout();
            //}
        }
Beispiel #10
0
        protected void RefreshForms()
        {
            if (refreshing)
            {
                return;
            }

            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(RefreshForms));
                return;
            }

            refreshing = true;
            try
            {
                List <Serial> refresSerials  = new List <Serial>();
                List <Serial> currentChars   = new List <Serial>();
                WindowManager defaultManager = WindowManager.GetDefaultManager();
//        IEnumerable<StatusForm> statusForms = defaultManager.OwnedWindows.OfType<StatusForm>();

                if (this.Auto)
                {
                    currentChars.AddRange(GetCurrentChars(this.WrapperType).ToArray());//World.Characters.Where(ch => this.WrapperType == StatusWrapper.GetWrapperType(ch.Serial) && ch.Serial != World.Player.Serial).OrderBy(ch => ch.GetDistance()).Select(ch => ch.Serial).ToList();
                }
                List <StatusForm> forms = WindowManager.GetDefaultManager().OwnedWindows.OfType <StatusForm>().Where(f => this.WrapperType == StatusWrapper.GetWrapperType(f.MobileId) && !currentChars.Contains(f.MobileId)).ToList();
                foreach (StatusForm sf in forms)
                {
                    if (sf.Manual)
                    {
                        currentChars.Insert(0, sf.MobileId);
                    }
                    else
                    {
                        currentChars.Add(sf.MobileId);
                    }
                }

                for (int i = 0; i < Math.Min(currentChars.Count, this.MaxBars); i++)
                {
                    UOCharacter ch = new UOCharacter(currentChars[i]);
                    if (ch.Hits <= 0 || String.IsNullOrEmpty(ch.Name))
                    {
                        ch.RequestStatus(100);
                    }

                    StatusForm sf = WindowManager.GetDefaultManager().OwnedWindows.OfType <StatusForm>().Where(f => f.MobileId == ch.Serial).FirstOrDefault();

                    if (sf != null || this.Auto)
                    {
                        bool add = (sf == null || !sf.DisableWrapper) && ch.Distance < 25 && ch.Hits > 0 && ch.Exist || sf != null && (sf.Keep || sf.IsNew || sf.MouseHovering) && !sf.DisableWrapper;

                        if (add)
                        {
                            refresSerials.Add(ch.Serial);

                            if (sf == null)
                            {
                                defaultManager.CreateWindow(delegate()
                                {
                                    var f          = new StatusForm(ch.Serial);
                                    f.Transparency = true;
                                    return(f);
                                });
                            }
                        }
                        else if (sf != null && !sf.DisableWrapper && !sf.Keep && !sf.MouseHovering)
                        {
                            if (defaultManager.InvokeRequired)
                            {
                                defaultManager.BeginInvoke(sf.Close);
                            }
                            else
                            {
                                sf.Close();
                            }
                        }
                    }
                }

                if (this.Auto)
                {
                    List <StatusForm> delete = WindowManager.GetDefaultManager().OwnedWindows.OfType <StatusForm>().Where(sf => sf.MobileId != World.Player.Serial && StatusWrapper.GetWrapperType(sf.MobileId) == this.WrapperType && !refresSerials.Contains(sf.MobileId) && !sf.DisableWrapper && !sf.Keep && !sf.MouseHovering).ToList();
                    foreach (StatusForm sf in delete)
                    {
                        if (defaultManager.InvokeRequired)
                        {
                            defaultManager.BeginInvoke(sf.Close);
                        }
                        else
                        {
                            sf.Close();
                        }
                    }
                }

                int y = this.Location.Y + this.Height;
                int x = this.Location.X;

                Dictionary <int, Serial> slots = new Dictionary <int, Serial>();
                List <int> slotPointer         = new List <int>();

                for (int i = 0; i < this.MaxBars; i++)
                {
                    int slotY = y + (i * StatusForm.DefaultHeight);
                    slotPointer.Add(slotY);
                    slots.Add(slotY, (Serial)Serial.Invalid);
                }

                StatusForm disabledSlot = WindowManager.GetDefaultManager().OwnedWindows.OfType <StatusForm>().Where(f => refresSerials.Contains(f.MobileId) && f.MouseHovering).FirstOrDefault();

                if (disabledSlot != null && slots.ContainsKey(disabledSlot.Location.Y))
                {
                    slots[disabledSlot.Location.Y] = disabledSlot.MobileId;
                }

                refresSerials = SortChars(refresSerials);

                for (int i = 0; i < refresSerials.Count; i++)
                {
                    Serial     s  = refresSerials[i];
                    StatusForm sf = WindowManager.GetDefaultManager().OwnedWindows.OfType <StatusForm>().Where(f => f.MobileId == s).FirstOrDefault();

                    if (sf != null)
                    {
                        for (int u = 0; u < slotPointer.Count; u++)
                        {
                            int    slotY  = slotPointer[u];
                            Serial slotId = slots[slotY];

                            if (!slotId.IsValid && slots.Values.Count(sv => sv == sf.MobileId) == 0 || slotId == sf.MobileId)
                            {
                                if (sf.Location.X != x || sf.Location.Y != slotY)
                                {
                                    sf.Location = new Point(x, slotPointer[u]);
                                    sf.Invalidate();
                                }

                                slots[slotY] = sf.MobileId;
                                break;
                            }
                        }
                    }

                    ////if (sf != null)
                    ////{
                    //for (int u = 0; u < slotPointer.Count; u++)
                    //{
                    //  int slotY = slotPointer[u];
                    //  Serial slotId = slots[slotY];

                    //  if (!slotId.IsValid && slots.Values.Count(sv => sv == s) == 0 || slotId == s)
                    //  {


                    //    if (sf == null || sf.Location.X != x || sf.Location.Y != slotY)
                    //    {
                    //      if (sf == null)
                    //      {
                    //        sf = (StatusForm)defaultManager.CreateWindow(delegate ()
                    //        {
                    //          var f = new StatusForm(s);
                    //          f.Transparency = true;
                    //          f.Location = new Point(x, slotPointer[u]);
                    //          return f;
                    //        });
                    //      }
                    //      else
                    //      {
                    //        //??? co stim ????
                    //        sf.Location = new Point(x, slotPointer[u]);
                    //        if (defaultManager.InvokeRequired)
                    //        {
                    //          //do nothing?
                    //          defaultManager.BeginInvoke(sf.Invalidate);
                    //        }
                    //        else
                    //          sf.Invalidate();
                    //      }
                    //    }

                    //    slots[slotY] = sf.MobileId;
                    //    break;
                    //  }
                    //}
                    ////}
                }

                this.registeredSerials = refresSerials;
            }
            catch //(Exception e)
            {
                Game.PrintMessage("Chyba v zalozkach", MessageType.Error);
            }
            finally
            {
                refreshing = false;
            }
        }