Exemple #1
0
        public static void MiniHealOrCureSelf()
        {
            Spell s = null;

            if (!ClientCommunication.AllowBit(FeatureBit.BlockHealPoisoned))
            {
                s = Get(1, 4);                   // mini heal
            }
            else
            {
                if (World.Player.Poisoned)
                {
                    s = Get(2, 3);                       // cure
                }
                else
                {
                    s = Get(1, 4);                       // mini heal
                }
            }

            if (s != null)
            {
                if (World.Player.Poisoned || World.Player.Hits < World.Player.HitsMax)
                {
                    Targeting.TargetSelf(true);
                }
                ClientCommunication.SendToServer(new CastSpellFromMacro((ushort)s.GetID()));
                s.Cast();
            }
        }
Exemple #2
0
        public static void ClosestHumanoidTarget(params int[] noto)
        {
            if (!ClientCommunication.AllowBit(FeatureBit.ClosestTargets))
            {
                return;
            }

            ArrayList list = new ArrayList();

            foreach (Mobile m in World.MobilesInRange(12))
            {
                if (m.Body != 0x0190 && m.Body != 0x0191 && m.Body != 0x025D && m.Body != 0x025E)
                {
                    continue;
                }

                if ((!FriendsAgent.IsFriend(m) || (noto.Length > 0 && noto[0] == 0)) &&
                    !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    for (int i = 0; i < noto.Length; i++)
                    {
                        if (noto[i] == m.Notoriety)
                        {
                            list.Add(m);
                            break;
                        }
                    }

                    if (noto.Length == 0)
                    {
                        list.Add(m);
                    }
                }
            }

            Mobile closest     = null;
            double closestDist = double.MaxValue;

            foreach (Mobile m in list)
            {
                double dist = Utility.DistanceSqrt(m.Position, World.Player.Position);

                if (dist < closestDist || closest == null)
                {
                    closestDist = dist;
                    closest     = m;
                }
            }

            if (closest != null)
            {
                SetLastTargetTo(closest);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }
Exemple #3
0
        public static void HealOrCureSelf()
        {
            Spell s = null;

            if (!ClientCommunication.AllowBit(FeatureBit.BlockHealPoisoned))
            {
                if (World.Player.Hits + 30 < World.Player.HitsMax && World.Player.Mana >= 12)
                {
                    s = Get(4, 5);                       // greater heal
                }
                else
                {
                    s = Get(1, 4);                       // mini heal
                }
            }
            else
            {
                if (World.Player.Poisoned && ClientCommunication.AllowBit(FeatureBit.BlockHealPoisoned))
                {
                    s = Get(2, 3);                       // cure
                }
                else if (World.Player.Hits + 2 < World.Player.HitsMax)
                {
                    if (World.Player.Hits + 30 < World.Player.HitsMax && World.Player.Mana >= 12)
                    {
                        s = Get(4, 5);                           // greater heal
                    }
                    else
                    {
                        s = Get(1, 4);                           // mini heal
                    }
                }
                else
                {
                    if (World.Player.Mana >= 12)
                    {
                        s = Get(4, 5);                           // greater heal
                    }
                    else
                    {
                        s = Get(1, 4);                           // mini heal
                    }
                }
            }

            if (s != null)
            {
                if (World.Player.Poisoned || World.Player.Hits < World.Player.HitsMax)
                {
                    Targeting.TargetSelf(true);
                }
                s.Cast(s.GetID());
            }
        }
Exemple #4
0
        public static void RandomHumanoidTarget(params int[] noto)
        {
            if (!ClientCommunication.AllowBit(FeatureBit.RandomTargets))
            {
                return;
            }

            ArrayList list = new ArrayList();

            foreach (Mobile m in World.MobilesInRange(12))
            {
                if (m.Body != 0x0190 && m.Body != 0x0191 && m.Body != 0x025D && m.Body != 0x025E)
                {
                    continue;
                }

                if ((!FriendsAgent.IsFriend(m) || (noto.Length > 0 && noto[0] == 0)) &&
                    !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    for (int i = 0; i < noto.Length; i++)
                    {
                        if (noto[i] == m.Notoriety)
                        {
                            list.Add(m);
                            break;
                        }
                    }

                    if (noto.Length == 0)
                    {
                        list.Add(m);
                    }
                }
            }

            if (list.Count > 0)
            {
                SetLastTargetTo((Mobile)list[Utility.Random(list.Count)]);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }
Exemple #5
0
        private static void EndPlayback()
        {
            m_PlayTimer = null;

            m_Playing = false;
            ClientCommunication.SetAllowDisconn(true);
            //ClientCommunication.SetDeathMsg( "You are dead." );

            PlayerData player;

            using (BinaryReader reader = new BinaryReader(m_TempWriter.BaseStream))
            {
                reader.BaseStream.Seek(0, SeekOrigin.Begin);
                player = World.Player = new PlayerData(reader, PlayerVersion);
            }
            m_TempWriter.Close();

            player.Contains.Clear();
            World.AddMobile(player);

            DoLogin(player);

            tbPos.Enabled = btnClose.Enabled = btnPlay.Enabled = btnStop.Enabled = btnRec.Enabled = true;
            tbPos.Value   = tbPos.Minimum;

            m_Elapsed = TimeSpan.Zero;
            UpdateTimeText();

            ClientCommunication.SendToClient(new MoveReject(World.Player.WalkSequence, World.Player));
            ClientCommunication.SendToServer(new ResyncReq());
            World.Player.Resync();
            ClientCommunication.RequestTitlebarUpdate();

            if (ClientCommunication.AllowBit(FeatureBit.LightFilter) && World.Player != null)
            {
                World.Player.LocalLightLevel = 0;

                ClientCommunication.SendToClient(new GlobalLightLevel(0));
                ClientCommunication.SendToClient(new PersonalLightLevel(World.Player));
            }
        }
Exemple #6
0
        public static void CheckLastTargetRange(Mobile m)
        {
            if (World.Player == null)
            {
                return;
            }

            if (m_HasTarget && m != null && m_LastTarget != null && m.Serial == m_LastTarget.Serial && m_QueueTarget == LastTargetAction)
            {
                if (Config.GetBool("RangeCheckLT") && ClientCommunication.AllowBit(FeatureBit.RangeCheckLT))
                {
                    if (Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                    {
                        if (m_QueueTarget())
                        {
                            ClearQueue();
                        }
                    }
                }
            }
        }
Exemple #7
0
        public static void CheckTextFlags(Mobile m)
        {
            if (Config.GetBool("SmartLastTarget") && ClientCommunication.AllowBit(FeatureBit.SmartLT))
            {
                bool harm = m_LastHarmTarg != null && m_LastHarmTarg.Serial == m.Serial;
                bool bene = m_LastBeneTarg != null && m_LastBeneTarg.Serial == m.Serial;
                if (harm)
                {
                    m.OverheadMessage(0x90, String.Format("[{0}]", Language.GetString(LocString.HarmfulTarget)));
                }
                if (bene)
                {
                    m.OverheadMessage(0x3F, String.Format("[{0}]", Language.GetString(LocString.BeneficialTarget)));
                }
            }

            if (m_LastTarget != null && m_LastTarget.Serial == m.Serial)
            {
                m.OverheadMessage(0x3B2, String.Format("[{0}]", Language.GetString(LocString.LastTarget)));
            }
        }
Exemple #8
0
        public static bool IsLastTarget(Mobile m)
        {
            if (m != null)
            {
                if (Config.GetBool("SmartLastTarget") && ClientCommunication.AllowBit(FeatureBit.SmartLT))
                {
                    if (m_LastHarmTarg != null && m_LastHarmTarg.Serial == m.Serial)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (m_LastTarget != null && m_LastTarget.Serial == m.Serial)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #9
0
        public static bool DoubleClick(object clicked, bool silent)
        {
            Serial s;

            if (clicked is Mobile)
            {
                s = ((Mobile)clicked).Serial.Value;
            }
            else if (clicked is Item)
            {
                s = ((Item)clicked).Serial.Value;
            }
            else if (clicked is Serial)
            {
                s = ((Serial)clicked).Value;
            }
            else
            {
                s = Serial.Zero;
            }

            if (s != Serial.Zero)
            {
                Item free = null, pack = World.Player.Backpack;
                if (s.IsItem && pack != null && Config.GetBool("PotionEquip") && ClientCommunication.AllowBit(FeatureBit.AutoPotionEquip))
                {
                    Item i = World.FindItem(s);
                    if (i != null && i.IsPotion && i.ItemID != 3853) // dont unequip for exploison potions
                    {
                        // dont worry about uneqipping RuneBooks or SpellBooks
                        Item left  = World.Player.GetItemOnLayer(Layer.LeftHand);
                        Item right = World.Player.GetItemOnLayer(Layer.RightHand);

                        if (left != null && (right != null || left.IsTwoHanded))
                        {
                            free = left;
                        }
                        else if (right != null && right.IsTwoHanded)
                        {
                            free = right;
                        }

                        if (free != null)
                        {
                            if (DragDropManager.HasDragFor(free.Serial))
                            {
                                free = null;
                            }
                            else
                            {
                                DragDropManager.DragDrop(free, pack);
                            }
                        }
                    }
                }

                ActionQueue.DoubleClick(silent, s);

                if (free != null)
                {
                    DragDropManager.DragDrop(free, World.Player, free.Layer, true);
                }

                if (s.IsItem)
                {
                    World.Player.m_LastObj = s;
                }
            }

            return(false);
        }
Exemple #10
0
        public void MoveReq(Direction dir, byte seq)
        {
            m_OutstandingMoves++;
            FastWalkKey++;

            MoveEntry e = new MoveEntry();

            m_MoveInfo[seq] = e;

            e.IsStep = (dir & Direction.Mask) == (Direction & Direction.Mask);
            e.Dir    = dir;

            ProcessMove(dir);               // shouldnt this be in MoveAck?!?

            e.Position = Position;

            if (Body != 0x03DB && !IsGhost && ((int)(e.Dir & Direction.Mask)) % 2 == 0 && Config.GetBool("AutoOpenDoors") && ClientCommunication.AllowBit(FeatureBit.AutoOpenDoors))
            {
                int x = Position.X, y = Position.Y, z = Position.Z;

                foreach (Item i in World.Items.Values)
                {
                    if (i.Position.X == x && i.Position.Y == y && i.IsDoor && i.Position.Z - 15 <= z && i.Position.Z + 15 >= z && (m_LastDoor != i.Serial || m_LastDoorTime + TimeSpan.FromSeconds(1) < DateTime.UtcNow))
                    {
                        m_LastDoor     = i.Serial;
                        m_LastDoorTime = DateTime.UtcNow;
                        m_OpenDoorReq.Start();
                        break;
                    }
                }
            }

            /*if ( m_OutstandingMoves < 5 && !Macros.WalkAction.IsMacroWalk( seq ) && Config.GetBool( "SmoothWalk" ) )
             * {
             *      e.FilterAck = true;
             *      ClientCommunication.SendToClient( new MoveAcknowledge( seq, Notoriety ) );
             * }
             * else
             * {
             *      e.FilterAck = false;
             * }*/

            e.FilterAck = false;

            m_WalkSeq = (byte)(seq >= 255 ? 1 : seq + 1);
        }
Exemple #11
0
        private void Cast()
        {
            if (Config.GetBool("SpellUnequip") && ClientCommunication.AllowBit(FeatureBit.UnequipBeforeCast))
            {
                Item pack = World.Player.Backpack;
                if (pack != null)
                {
                    // dont worry about uneqipping RuneBooks or SpellBooks
                    Item item = World.Player.GetItemOnLayer(Layer.RightHand);
#if DEBUG
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA && !item.IsVirtueShield)
#else
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA)
#endif
                    {
                        DragDropManager.Drag(item, item.Amount);
                        DragDropManager.Drop(item, pack);
                    }

                    item = World.Player.GetItemOnLayer(Layer.LeftHand);
#if DEBUG
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA && !item.IsVirtueShield)
#else
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA)
#endif
                    {
                        DragDropManager.Drag(item, item.Amount);
                        DragDropManager.Drop(item, pack);
                    }
                }
            }

            for (int i = 0; i < Counter.List.Count; i++)
            {
                ((Counter)Counter.List[i]).Flag = false;
            }

            if (Config.GetBool("HighlightReagents"))
            {
                for (int r = 0; r < Reagents.Length; r++)
                {
                    for (int i = 0; i < Counter.List.Count; i++)
                    {
                        Counter c = (Counter)Counter.List[i];
                        if (c.Enabled && c.Format.ToLower() == Reagents[r])
                        {
                            c.Flag = true;
                            break;
                        }
                    }
                }

                if (m_UnflagTimer != null)
                {
                    m_UnflagTimer.Stop();
                }
                else
                {
                    m_UnflagTimer = new UnflagTimer();
                }
                m_UnflagTimer.Start();
            }

            ClientCommunication.RequestTitlebarUpdate();
            ClientCommunication.PostSpellCast(this.Number);

            if (World.Player != null)
            {
                World.Player.LastSpell  = GetID();
                LastCastTime            = DateTime.Now;
                Targeting.SpellTargetID = 0;
            }
        }
Exemple #12
0
        public static bool DoLastTarget()
        {
            TargetInfo targ;

            if (Config.GetBool("SmartLastTarget") && ClientCommunication.AllowBit(FeatureBit.SmartLT))
            {
                if (m_AllowGround && m_LastGroundTarg != null)
                {
                    targ = m_LastGroundTarg;
                }
                else if (m_CurFlags == 1)
                {
                    targ = m_LastHarmTarg;
                }
                else if (m_CurFlags == 2)
                {
                    targ = m_LastBeneTarg;
                }
                else
                {
                    targ = m_LastTarget;
                }

                if (targ == null)
                {
                    targ = m_LastTarget;
                }
            }
            else
            {
                if (m_AllowGround && m_LastGroundTarg != null)
                {
                    targ = m_LastGroundTarg;
                }
                else
                {
                    targ = m_LastTarget;
                }
            }

            if (targ == null)
            {
                return(false);
            }

            Point3D pos = Point3D.Zero;

            if (targ.Serial.IsMobile)
            {
                Mobile m = World.FindMobile(targ.Serial);
                if (m != null)
                {
                    pos = m.Position;

                    targ.X = pos.X;
                    targ.Y = pos.Y;
                    targ.Z = pos.Z;
                }
                else
                {
                    pos = Point3D.Zero;
                }
            }
            else if (targ.Serial.IsItem)
            {
                Item i = World.FindItem(targ.Serial);
                if (i != null)
                {
                    pos = i.GetWorldPosition();

                    targ.X = i.Position.X;
                    targ.Y = i.Position.Y;
                    targ.Z = i.Position.Z;
                }
                else
                {
                    pos    = Point3D.Zero;
                    targ.X = targ.Y = targ.Z = 0;
                }
            }
            else
            {
                if (!m_AllowGround && (targ.Serial == Serial.Zero || targ.Serial >= 0x80000000))
                {
                    World.Player.SendMessage(MsgLevel.Warning, LocString.LTGround);
                    return(false);
                }
                else
                {
                    pos = new Point3D(targ.X, targ.Y, targ.Z);
                }
            }

            if (Config.GetBool("RangeCheckLT") && ClientCommunication.AllowBit(FeatureBit.RangeCheckLT) && (pos == Point3D.Zero || !Utility.InRange(World.Player.Position, pos, Config.GetInt("LTRange"))))
            {
                if (Config.GetBool("QueueTargets"))
                {
                    m_QueueTarget = LastTargetAction;
                }
                World.Player.SendMessage(MsgLevel.Warning, LocString.LTOutOfRange);
                return(false);
            }

            if (CheckHealPoisonTarg(m_CurrentID, targ.Serial))
            {
                return(false);
            }

            CancelClientTarget();
            m_HasTarget = false;

            targ.TargID = m_CurrentID;

            if (m_Intercept)
            {
                OneTimeResponse(targ);
            }
            else
            {
                ClientCommunication.SendToServer(new TargetResponse(targ));
            }
            return(true);
        }
Exemple #13
0
        private static bool CheckHealPoisonTarg(uint targID, Serial ser)
        {
            if (World.Player == null)
            {
                return(false);
            }

            if (targID == m_SpellTargID && ser.IsMobile && (World.Player.LastSpell == Spell.ToID(1, 4) || World.Player.LastSpell == Spell.ToID(4, 5)) && Config.GetBool("BlockHealPoison") && ClientCommunication.AllowBit(FeatureBit.BlockHealPoisoned))
            {
                Mobile m = World.FindMobile(ser);

                if (m != null && m.Poisoned)
                {
                    World.Player.SendMessage(MsgLevel.Warning, LocString.HealPoisonBlocked);
                    return(true);
                }
            }

            return(false);
        }