Exemple #1
0
            //---------------------------------------------------------------------------------------------

            private void Mob_Changed(object sender, ObjectChangedEventArgs e)
            {
                if (Game.Debug)
                {
                    Game.PrintMessage("Mob_Changed: " + Rename.RenameSufix(this.Mob.Name) + (String.Format("{0:n1}", (DateTime.Now - LastChangedTime).TotalMilliseconds)));
                }

                LastChangedTime = DateTime.Now;
            }
Exemple #2
0
            //---------------------------------------------------------------------------------------------

            public bool NeedCommand()
            {
                UOPositionBase ep = new UOPositionBase(GetEnemyOrDefault().X, GetEnemyOrDefault().Y, 0);
                UOPositionBase mp = new UOPositionBase(Mob.X, Mob.Y, 0);


                this.ZeroPosition = Robot.GetRelativeVectorLength(mp, ep) == 0;
                this.ToFar        = Robot.GetRelativeVectorLength(mp, ep) > 1.5;
                this.NotLookingAt = !Robot.LookingDirectlyAt(mp, ep, Mob.Direction);
                this.Dragon       = IsDragon(this.Mob);
                this.TimerReset   = (DateTime.Now - LastCommandTime).TotalMilliseconds > resetTimer;
                this.ChangeReset  = (DateTime.Now - LastChangedTime).TotalMilliseconds > 8500;

                bool result = this.IsAliveReach && GetEnemyOrDefault().Serial != this.Mob.Serial &&
                              (
                    this.ZeroPosition ||
                    this.ToFar ||
                    this.NotLookingAt ||
                    this.Dragon ||
                    this.TimerReset ||
                    this.ChangeReset
                              );

                if (result)
                {
                    if (this.ZeroPosition)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Pozice 0 [" + this.CommandCount + "]", Game.Val_GreenBlue);
                        }

                        this.CommandReasonCode = "Z";
                    }
                    else if (this.NotLookingAt)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Nekouka [" + this.CommandCount + "]", Game.Val_GreenBlue);
                        }
                        this.CommandReasonCode = "N";
                    }
                    else if (this.ToFar)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Je Daleko [" + this.CommandCount + "]", Game.Val_GreenBlue);
                        }
                        this.CommandReasonCode = "F";
                    }
                    else if (this.Dragon)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Drak [" + this.CommandCount + "]", Game.Val_GreenBlue);
                        }
                        this.CommandReasonCode = "D";
                    }
                    else if (this.TimerReset)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Casovac [" + this.CommandCount + "] " + (String.Format("{0:n1}", (DateTime.Now - LastCommandTime).TotalMilliseconds)), Game.Val_GreenBlue);
                        }
                        this.CommandReasonCode = "T";
                    }
                    else if (this.ChangeReset)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage(Rename.RenameSufix(Mob.Name) + " - Change [" + this.CommandCount + "] " + (String.Format("{0:n1}", (DateTime.Now - LastChangedTime).TotalMilliseconds)), Game.Val_GreenBlue);
                        }
                        this.CommandReasonCode = "C";
                    }
                }

                return(result);
            }
Exemple #3
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.MobName + " kill";
                current.CommandCount++;
                current.LastCommandTime = DateTime.Now;
                sayColor = Game.GetAlieColorByHits(current.Mob.Serial);
                current.Mob.PrintMessage(Rename.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);
            }
        }