Exemplo n.º 1
0
        //---------------------------------------------------------------------------------------------

        public static TargetAliasResult ParseTargets(params string[] targets)
        {
            List <string> finalTargets = new List <string>();

            if (targets != null)
            {
                foreach (string target in targets)
                {
                    if (!String.IsNullOrEmpty(target))
                    {
                        finalTargets.AddRange(target.Split(new char[] { ',', '|', ';' }, StringSplitOptions.RemoveEmptyEntries));
                    }
                }

                foreach (string target in finalTargets)
                {
                    TargetAliasResult serial = Targeting.ParseTarget(target);
                    UOObject          o      = new UOObject(serial);

                    if (serial.IsStatic || (serial.IsValid && o.Exist && o.Distance < 28))
                    {
                        // System.Diagnostics.Debug.WriteLine("Target: " + target + " - success [" + serial + ", " + o.Distance + ", " + o.Name + "]", "Caleb");
                        return(serial);
                    }
                    //else
                    //  System.Diagnostics.Debug.WriteLine("Target: " + target + " - fail [" + serial + ", " + o.Distance + ", " + o.Name + "]", "Caleb");
                }
            }
            return(Serial.Invalid);
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------------------------

        private static TargetAliasResult ParseTarget(string targetName, Serial defaultValue)
        {
            if (targetName != null)
            {
                Serial target = Serial.Invalid;

                if (targetName.ToLower() == "self")
                {
                    return(Aliases.Self);
                }
                if (targetName.ToLower() == "lasttarget")
                {
                    return(Aliases.LastTarget);
                }
                if (targetName.ToLower() == "lastattack")
                {
                    return(Aliases.LastAttack);
                }
                if (targetName.ToLower() == "lastobject")
                {
                    return(Aliases.LastObject);
                }
                if (targetName.ToLower() == "laststatusmanual")
                {
                    return(Game.CurrentGame.IsAlie(target) ? (Serial)Serial.Invalid : Aliases.GetObject("LastStatusManual"));
                }
                if (targetName.ToLower() == "laststatus")
                {
                    return(Aliases.GetObject("LastStatusManual"));
                }
                if (targetName.ToLower() == "hover")
                {
                    return(Game.CurrentGame.CurrentHoverStatus);
                }
                if (targetName.ToLower() == "mount")
                {
                    return(Mount._Mount);
                }

                if (targetName.ToLower() == "selfmoving")
                {
                    if (Game.PlayerMoving)
                    {
                        return(Aliases.Self);
                    }
                    else
                    {
                        return(defaultValue);
                    }
                }
                if (targetName.ToLower() == "onestepwest")
                {
                    TargetAliasResult r = new TargetAliasResult()
                    {
                        X = (ushort)(World.Player.X - 1), Y = World.Player.Y, Z = World.Player.Z
                    };
                    return(r);
                }
                if (targetName.ToLower() == "onestepeast")
                {
                    TargetAliasResult r = new TargetAliasResult()
                    {
                        X = (ushort)(World.Player.X + 1), Y = World.Player.Y, Z = World.Player.Z
                    };
                    return(r);
                }

                if (targetName.StartsWith("tilerel"))
                {
                    string   relCoord = targetName.Replace("tilerel", "");
                    string[] coords   = relCoord.Split(new char[] { '.' });

                    ushort x = World.Player.X;
                    ushort y = World.Player.Y;
                    sbyte  z = World.Player.Z;


                    if (coords.Length > 0)
                    {
                        x = (ushort)(x + Utils.ToNullInt(coords[0]).GetValueOrDefault(x));
                    }
                    if (coords.Length > 1)
                    {
                        y = (ushort)(y + Utils.ToNullInt(coords[1]).GetValueOrDefault(y));
                    }
                    if (coords.Length > 2)
                    {
                        z = (sbyte)(z + Utils.ToNullInt(coords[2]).GetValueOrDefault(z));
                    }

                    TargetAliasResult r = new TargetAliasResult()
                    {
                        X = x, Y = y, Z = z
                    };
                    return(r);
                }


                UOCharacter t = new UOCharacter(target);

                if (target.IsValid && t.Exist && t.Distance < 35)
                {
                    if (targetName.ToLower() == "hovera")
                    {
                        if (Game.CurrentGame.IsAlie(target))
                        {
                            return(Game.CurrentGame.CurrentHoverStatus);
                        }
                    }

                    if (targetName.ToLower() == "hovere")
                    {
                        if (t.Notoriety == Notoriety.Enemy || t.Notoriety == Notoriety.Murderer || t.Notoriety == Notoriety.Criminal)
                        {
                            return(Game.CurrentGame.CurrentHoverStatus);
                        }
                    }
                }

                if (targetName.ToLower() == "nearestcorpse")
                {
                    UOItem[] arr = World.Ground.Where(i => i.Graphic == 0x2006 && i.Distance <= 2).OrderBy(i => i.Distance).ToArray();
                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower() == "nearestenemy")
                {
                    UOCharacter[] arr = World.Characters.Where(i => i.Notoriety == Notoriety.Enemy || i.Notoriety == Notoriety.Murderer || i.Serial == Aliases.LastAttack).OrderBy(i => i.Distance).ToArray();

                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower() == "onestepenemy")
                {
                    UOCharacter[] arr = World.Characters.Where(i => i.Serial != World.Player.Serial && !Game.CurrentGame.IsAlie(i.Serial) && !Game.CurrentGame.IsHealAlie(i.Serial) && !Game.IsMob(i.Serial) && !i.Renamable && i.Distance <= 1.5).OrderBy(i => i.Distance).ToArray();

                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }


                if (targetName.ToLower().StartsWith("enemydmax"))
                {
                    string max  = targetName.ToLower().Replace("enemydmax", "");
                    int    maxD = Utils.ToNullInt(max).GetValueOrDefault(2);

                    UOCharacter[] arr = World.Characters.Where(i => i.Serial != World.Player.Serial && !Game.CurrentGame.IsAlie(i.Serial) && !Game.CurrentGame.IsHealAlie(i.Serial) && !Game.IsMob(i.Serial) && !i.Renamable && i.Distance <= maxD).OrderBy(i => i.Distance).ToArray();

                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower() == "nearestghost")
                {
                    UOCharacter[] arr = Healing.GetGhosts().OrderBy(i => i.Distance).ToArray();
                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower() == "onestepghost")
                {
                    UOCharacter[] arr = Healing.GetGhosts().Where(i => i.Distance <= 1).OrderBy(i => i.Distance).ToArray();
                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower().StartsWith("ghostdmax"))
                {
                    string max  = targetName.ToLower().Replace("ghostdmax", "");
                    int    maxD = Utils.ToNullInt(max).GetValueOrDefault(3);

                    UOCharacter[] arr = Healing.GetGhosts().Where(i => i.Distance <= maxD).OrderBy(i => i.Distance).ToArray();

                    if (arr.Length > 0)
                    {
                        return(arr[0].Serial);
                    }
                }

                if (targetName.ToLower() == "nexthealalie")
                {
                    string max  = targetName.ToLower().Replace("nexthealalie", "");
                    int    maxD = Utils.ToNullInt(max + String.Empty).GetValueOrDefault(25);

                    List <CharHealPriority> chhpList = Healing.GetCharHealPriorityList(maxD, false, Game.MergeLists <UOCharacter>(Game.CurrentGame.Alies, Game.CurrentGame.HealAlies));
                    var sortedList = chhpList.Where(c => !alieHealSkip.Contains(c.Char.Serial)).ToList();

                    if (sortedList.Count == 0)
                    {
                        alieHealSkip.Clear();
                        sortedList = chhpList;
                    }

                    if (sortedList.Count > 0)
                    {
                        alieHealSkip.Add(sortedList[0].Char.Serial);
                        return(sortedList[0].Char.Serial);
                    }
                }

                target = Aliases.GetObject(targetName);
                if (target.IsValid && new UOCharacter(target).ExistCust())
                {
                    return(target);
                }
            }

            return(defaultValue);
        }