예제 #1
0
        GUnit FindMobToLoot()
        {
            // Find stuff to loot
            GUnit closest = null;

            GMonster[] monsters = GObjectList.GetMonsters();
            foreach (GMonster monster in monsters)
            {
                if ((monster.IsLootable || (monster.IsSkinnable && Skin)) &&
                    ShouldLoot(monster))
                {
                    if (closest == null || monster.DistanceToSelf < closest.DistanceToSelf)
                    {
                        closest = monster;
                    }
                }
            }
            return(closest);
        }
예제 #2
0
        GUnit FindMobToPull()
        {
            // TODO better elite/max level decision, this at least prevents
            // attacking flight masters
            int minLevel = nodetask.GetValueOfId("MinLevel").GetIntValue();
            int maxLevel = nodetask.GetValueOfId("MaxLevel").GetIntValue();

            // TODO add active pvp option
            // int doPvp = ...;

            // Find stuff to pull
            GUnit closest = null;

            GMonster[] monsters = GObjectList.GetMonsters();
            foreach (GMonster monster in monsters)
            {
                if (!monster.IsDead &&
                    (!monster.IsTagged || monster.IsTargetingMe || monster.IsTargetingMyPet) &&
                    !ppather.IsBlacklisted(monster) && !PPather.IsPlayerFaction(monster) &&
                    (!monster.IsPlayer /*|| (doPvp && (GPlayer)monster).IsPVP)*/) &&
                    !PPather.IsStupidItem(monster))
                {
                    double dangerd = (double)DangerDistance + ((monster.IsElite ? 1.25 : 1.0) * (monster.Level - GContext.Main.Me.Level));
                    if (monster.Reaction == GReaction.Hostile &&
                        !monster.IsElite &&
                        minLevel <= monster.Level &&
                        monster.Level <= maxLevel &&
                        monster.DistanceToSelf < dangerd &&
                        Math.Abs(monster.Location.Z - GContext.Main.Me.Location.Z) < 15.0)
                    {
                        if (closest == null || monster.DistanceToSelf < closest.DistanceToSelf)
                        {
                            closest = monster;
                        }
                    }
                }
            }
            return(closest);
        }
예제 #3
0
        public virtual GUnit FindMobToPull()
        {
            // Find stuff to pull
            GUnit closest = null;

            GMonster[] monsters = GObjectList.GetMonsters();
            GPlayer[]  players  = /*doPvp ? */ GObjectList.GetPlayers() /* new GPlayer[] { }*/;
            // maybe use GObjectList.GetUnits() instead

            List <GUnit> units = new List <GUnit>();

            units.AddRange(monsters);
            units.AddRange(players);

            float me_z = GContext.Main.Me.Location.Z;

            foreach (GUnit unit in units)
            {
                //PPather.WriteLine(
                //    string.Format("Considering {0}, D={1}, P={2}, R={3}, TM={4}, TP={5}, BL={6}, V={7}",
                //    unit.Name,
                //    unit.IsDead.ToString()[0],
                //    unit.IsPlayer.ToString()[0],
                //    unit.Reaction.ToString()[0],
                //    unit.IsTargetingMe.ToString()[0],
                //    unit.IsTargetingMyPet.ToString()[0],
                //    ppather.IsBlacklisted(unit).ToString()[0],
                //    IsValidTarget(unit).ToString()[0]));


                if (!unit.IsDead && unit.Reaction != GReaction.Friendly &&
                    ((unit.IsPlayer || !((GMonster)unit).IsTagged) || unit.IsTargetingMe || unit.IsTargetingMyPet) &&
                    unit.DistanceToSelf < Distance &&
                    !ppather.IsBlacklisted(unit) && IsValidTarget(unit) &&
                    !IsPet(players, unit) &&
                    !PPather.IsStupidItem(unit))
                {
                    if (skipMobsWithAdds)
                    {
                        List <GMonster> closeUnits = ppather.CheckForMobsAtLoc(unit.Location, addsDistance);
                        if (closeUnits.Count >= addsCount)
                        {
                            continue;
                        }
                    }

                    Location ml = new Location(unit.Location);
                    float    dz = (float)Math.Abs(ml.Z - me_z);
                    if (dz < 30.0f)
                    {
                        if (PPather.world.IsUnderwaterOrInAir(ml))
                        {
                            PPather.WriteLine(unit.Name + " is underwater or flying");
                            ppather.Blacklist(unit);
                        }
                        else
                        {
                            // replace closest if unit is closer but do not replace closest if
                            // closest is a player and unit is not a player
                            if (closest == null || (unit.DistanceToSelf < closest.DistanceToSelf && (!closest.IsPlayer || unit.IsPlayer)))
                            {
                                closest = unit;
                            }
                        }
                    }
                }
            }

            //PPather.WriteLine("Returning unit: " + (closest == null ? "null" : closest.Name));
            return(closest);
        }