Ejemplo n.º 1
0
 void StatusForm_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (mobile.Notoriety == Notoriety.Enemy || mobile.Notoriety == Notoriety.Murderer)
     {
         World.Player.ChangeWarmode(WarmodeChange.War);
         UO.Attack(mobile.Serial);
     }
     else
     {
         if (World.Player.Warmode)
         {
             UO.Attack(mobile.Serial);
         }
         else
         {
             mobile.Use();
         }
     }
 }
Ejemplo n.º 2
0
        public bool UseMount()
        {
            var currChars = World.Characters.Where(ch => ch.Serial != World.Player.Serial && ch.Distance <= 6).ToArray();
            var newChars  = World.Characters.Where(ch => ch.Serial != World.Player.Serial && ch.Distance <= 6).ToArray();
            var diff      = newChars.Where(ch => currChars.Count(cch => cch.Serial == ch.Serial) == 0).ToArray();

            UOItem currentMount  = World.Player.Layers[Layer.Mount];
            Serial originalMount = _Mount;

            bool dismount = currentMount.ExistCust();

            _Mount = Serial.Invalid;

            if (dismount)
            {
                UOColor currentColor = currentMount.Color;
                World.Player.Use();
                Game.Wait(100);

                newChars = World.Characters.Where(ch => ch.Serial != World.Player.Serial && ch.Distance <= 6).ToArray();
                diff     = newChars.Where(ch => currChars.Count(cch => cch.Serial == ch.Serial) == 0).ToArray();
                diff     = diff.OrderBy(ch => ch.Distance).ThenBy(ch => (ch.Color == currentColor ? 0 : 1)).ToArray();

                if (diff.Count() > 0)
                {
                    _Mount = diff.ToArray()[0].Serial;
                }
            }
            else
            {
                UOCharacter curr = new UOCharacter(originalMount);

                if (!curr.ExistCust())
                {
                    UOItem shrink = new UOItem(Serial.Invalid);
                    foreach (UOItem itm in World.Player.Backpack.AllItems)
                    {
                        if (ItemLibrary.ShrinkMountTypes.Count(uot => uot.Graphic == itm.Graphic) > 0)
                        {
                            shrink = itm;
                            break;
                        }
                    }

                    List <UOCharacter> m = new List <UOCharacter>();

                    if (HasHumanBody)//nemam haluze
                    {
                        m.AddRange(currChars.
                                   Where(ch => !denyMounts.Contains(ch.GetUniqueKey()) && !skipMounts.Contains(ch.GetUniqueKey()) && ItemLibrary.MountTypes.Count(mt => mt.Graphic == ch.Model) > 0).
                                   OrderBy(ch => (ch.Renamable ? 0 : 1)).
                                   ThenBy(ch => ch.Distance).ToArray());
                    }
                    else
                    {
                        m.AddRange(currChars.
                                   Where(ch => !denyMounts.Contains(ch.GetUniqueKey()) && !skipMounts.Contains(ch.GetUniqueKey())).
                                   OrderBy(ch => (ch.Renamable ? 0 : 1)).
                                   ThenBy(ch => ItemLibrary.MountTypes.Count(mt => mt.Graphic == ch.Model) > 0 ? 0 : 1).
                                   ThenBy(ch => ch.Distance).ToArray());
                    }

                    if (m.Count > 0)
                    {
                        _Mount = m[0].Serial;
                    }
                    else
                    {
                        if (shrink.Exist)
                        {
                            Game.CurrentGame.CurrentPlayer.SwitchWarmode();
                            shrink.Use();
                            Game.Wait(150);

                            newChars = World.Characters.Where(ch => ch.Serial != World.Player.Serial && ch.Distance <= 6).ToArray();
                            diff     = newChars.Where(ch => currChars.Count(cch => cch.Serial == ch.Serial) == 0).ToArray();
                            diff     = diff.OrderBy(ch => ch.Distance).ToArray();

                            if (diff.Count() > 0)
                            {
                                _Mount = diff.ToArray()[0].Serial;
                            }
                        }
                        skipMounts.Clear();
                    }
                }
                else
                {
                    _Mount = originalMount;
                }

                curr = new UOCharacter(_Mount);
                Journal.Clear();

                if (curr.ExistCust())
                {
                    curr.Use();

                    if (Journal.WaitForText(true, 150, "You dont own that horse"))
                    {
                        curr.PrintMessage("[ deny add ]");
                        denyMounts.Add(curr.GetUniqueKey());
                        _Mount = Serial.Invalid;
                    }
                    else if (!World.Player.Layers[Layer.Mount].ExistCust())
                    {
                        if (curr.Serial == originalMount && new UOCharacter(originalMount).Exist)
                        {
                            curr.PrintMessage("[ mount ]");
                        }
                        else
                        {
                            curr.PrintMessage("[ skip add ]");
                            skipMounts.Add(curr.GetUniqueKey());
                            _Mount = Serial.Invalid;
                        }
                    }
                }
                else
                {
                    World.Player.PrintMessage("[ neni mount ]");
                }
            }

            return(_Mount.IsValidCust());
        }