Пример #1
0
        public override bool WantToDoSomething()
        {
            if (GObjectList.GetNearestAttacker(0) != null)
            {
                return(false);
            }

            GUnit prevMonster = monster;

            monster = FindMobToLoot();
            if (monster != prevMonster)
            {
                lootTask = null;
                walkTask = null;
            }

            if (walkTask != null)
            {
                // check result of walking
                if (walkTask.MoveResult != EasyMover.MoveResult.Moving &&
                    walkTask.MoveResult != EasyMover.MoveResult.GotThere)
                {
                    PPather.WriteLine("Can't reach " + monster.Name + ". blacklist. " + walkTask.MoveResult);
                    ppather.Blacklist(monster);
                    return(false);
                }
            }


            // at my pos and at target pos
            if (monster != null && !ppather.IsItSafeAt(null, monster))
            {
                PPather.WriteLine("It is not safe at: " + monster.Name);
                DidLoot(monster);                 // ignore that
                monster = null;
            }
            if (monster != null && !ppather.IsItSafeAt(null, GContext.Main.Me))
            {
                monster = null;
            }

            return(monster != null);
        }
Пример #2
0
        public override bool Do()
        {
            GPlayerSelf Me = GContext.Main.Me;

            Helpers.Mount.Dismount();
            ppather.Face(monster);

            if (monster.SetAsTarget(false))
            {
                GUnit         target = monster;
                GCombatResult res;
                do
                {
                    ppather.UnBlacklist(target);
                    ppather.TargetIs(target);
                    target.TouchHealthDrop();
                    ppather.StartCombat();
                    res = ppather.KillTarget(target, Me.IsInCombat);
                    PPather.WriteLine("Kill result is: " + res);
                    if (res == GCombatResult.Bugged || res == GCombatResult.OtherPlayerTag)
                    {
                        // TODO make sure to wait out evaders that are attackign us, they usually stop after a few seconds
                        if (res == GCombatResult.Bugged)
                        {
                            GSpellTimer t = new GSpellTimer(3000);
                            while (Me.IsInCombat && !t.IsReadySlow)
                            {
                                ;
                            }
                        }
                        ppather.Blacklist(target);
                    }
                    if (res == GCombatResult.Died)
                    {
                        return(true);                        // sigh
                    }
                    if (res == GCombatResult.Success ||
                        res == GCombatResult.SuccessWithAdd)
                    {
                        ppather.Killed(target);
                    }

                    if (res == GCombatResult.SuccessWithAdd)
                    {
                        target = Me.Target;
                    }
                    else
                    {
                        target.Refresh(true);
                        Thread.Sleep(100);

                        // wait for combat flag to expire unless we have attackers
                        {
                            GSpellTimer t = new GSpellTimer(2000);
                            while (Me.IsInCombat && GObjectList.GetNearestAttacker(0) == null && !t.IsReadySlow)
                            {
                                ;
                            }
                            //PPather.WriteLine("t: " + (2000 - t.TicksLeft));
                        }
                        if (ppather.IsItSafeAt(null, GContext.Main.Me) && !Me.IsInCombat)
                        {
                            if (GContext.Main.Me.Target != null)
                            {
                                GContext.Main.ClearTarget();
                            }
                            ppather.Rest();
                        }
                    }
                } while (res == GCombatResult.SuccessWithAdd && target != null);
            }
            else
            {
                PPather.WriteLine("!Warning:Can not target monster " + monster.Name);
                ppather.Blacklist(monster);
            }

            return(true);            // !?!?
        }