Ejemplo n.º 1
0
        internal static ProcStatus ProcessNext(int numPending)
        {
            if (m_Pending != Serial.Zero)
            {
                if (m_Lifted + TimeSpan.FromMinutes(2) < DateTime.Now)
                {
                    Item i = World.FindItem(m_Pending);

                    Log("Lift timeout, forced drop to pack for {0}", m_Pending);

                    if (World.Player != null)
                    {
                        World.Player.SendMessage(MsgLevel.Force, LocString.ForceEndHolding);

                        if (World.Player.Backpack != null)
                        {
                            Assistant.Client.Instance.SendToServer(new DropRequest(m_Pending, Point3D.MinusOne, World.Player.Backpack.Serial));
                        }
                        else
                        {
                            Assistant.Client.Instance.SendToServer(new DropRequest(m_Pending, World.Player.Position, Serial.Zero));
                        }
                    }

                    m_Holding     = m_Pending = Serial.Zero;
                    m_HoldingItem = null;
                    m_Lifted      = DateTime.MinValue;
                }
                else
                {
                    return(ProcStatus.KeepWaiting);
                }
            }

            if (m_Front >= m_Back)
            {
                m_Front = m_Back = 0;
                return(ProcStatus.Nothing);
            }

            LiftReq lr = m_LiftReqs[m_Front];

            if (numPending > 0 && lr != null && lr.DoLast)
            {
                return(ProcStatus.ReQueue);
            }

            m_LiftReqs[m_Front] = null;
            m_Front++;

            if (lr != null)
            {
                Log("Lifting {0}", lr);

                Item item = World.FindItem(lr.Serial);
                if (item != null && item.Container == null)
                {                 // if the item is on the ground and out of range then dont grab it
                    if (Utility.Distance(item.GetWorldPosition(), World.Player.Position) > 3)
                    {
                        Log("Item is too far away... uncaching.");
                        return(ProcStatus.Nothing);
                    }
                }

                Assistant.Client.Instance.SendToServer(new LiftRequest(lr.Serial, lr.Amount));

                m_LastID        = lr.Id;
                m_Holding       = lr.Serial;
                m_HoldingItem   = World.FindItem(lr.Serial);
                m_ClientLiftReq = lr.FromClient;

                DropReq dr = DequeueDropFor(lr.Serial);
                if (dr != null)
                {
                    m_Pending = Serial.Zero;
                    m_Lifted  = DateTime.MinValue;

                    Log("Dropping {0} to {1}", lr, dr.Serial);

                    if (dr.Serial.IsMobile && dr.Layer > Layer.Invalid && dr.Layer <= Layer.LastUserValid)
                    {
                        Assistant.Client.Instance.SendToServer(new EquipRequest(lr.Serial, dr.Serial, dr.Layer));
                    }
                    else
                    {
                        Assistant.Client.Instance.SendToServer(new DropRequest(lr.Serial, dr.Point, dr.Serial));
                    }
                }
                else
                {
                    m_Pending = lr.Serial;
                    m_Lifted  = DateTime.Now;
                }

                return(ProcStatus.Success);
            }
            else
            {
                Log("No lift to be done?!");
                return(ProcStatus.Nothing);
            }
        }
Ejemplo n.º 2
0
        public static bool ClientPacket(Packet p)
        {
            if (Playing)
            {
                if (p == null || World.Player == null)
                {
                    return(false);
                }
                switch (p.PacketID)
                {
                case 0x02:                         // Movement Req
                {
                    Direction dir = (Direction)p.ReadByte();
                    byte      seq = p.ReadByte();

                    ClientCommunication.ForceSendToClient(new MoveReject(seq, World.Player));
                    World.Player.Resync();
                    break;
                }

                case 0x06:                         // Double Click
                {
                    Serial s = p.ReadUInt32();

                    Mobile m;
                    if ((s.Value & 0x80000000) != 0 || s == World.Player.Serial)
                    {
                        m = World.Player;
                    }
                    else
                    {
                        m = World.FindMobile(s);
                    }

                    if (m != null)
                    {
                        string name = m.Name;
                        if (name == null || name == "")
                        {
                            name = "<No Data>";
                        }
                        ClientCommunication.ForceSendToClient(new DisplayPaperdoll(m, name));
                    }
                    break;
                }

                case 0x07:                                                 // Lift Req
                {
                    ClientCommunication.ForceSendToClient(new LiftRej(5)); //inspecific
                    break;
                }

                case 0x09:                         // single click
                {
                    Serial s = p.ReadUInt32();

                    if (s.IsMobile)
                    {
                        Mobile m = World.FindMobile(s);
                        if (m != null && m.Name != null && m.Name != "")
                        {
                            int hue;
                            switch (m.Notoriety)
                            {
                            case 1: hue = 0x059; break;

                            case 2: hue = 0x03F; break;

                            case 3:
                            case 4: hue = 0x3B2; break;

                            case 5: hue = 0x090; break;

                            case 6: hue = 0x022; break;

                            case 7: hue = 0x035; break;

                            default: hue = 0x481; break;
                            }
                            ClientCommunication.ForceSendToClient(new UnicodeMessage(s, m.Body, MessageType.Label, hue, 3, "ENU", "", m.Name));
                        }
                    }
                    else if (s.IsItem)
                    {
                        Item i = World.FindItem(s);
                        if (i != null && i.Name != null && i.Name != "")
                        {
                            ClientCommunication.ForceSendToClient(new UnicodeMessage(s, i.ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", i.Name));
                        }
                    }
                    break;
                }

                case 0x34:                         // Mobile Info Query
                {
                    p.ReadInt32();                 // 0xEDEDEDED
                    int    type = p.ReadByte();
                    Mobile m    = World.FindMobile(p.ReadUInt32());
                    if (m == null)
                    {
                        break;
                    }

                    switch (type)
                    {
                    case 0x04:                                     // Stats
                    {
                        if (m == World.Player)
                        {
                            ClientCommunication.ForceSendToClient(new MobileStatusExtended(World.Player));
                            ClientCommunication.ForceSendToClient(new StatLockInfo(World.Player));
                        }
                        else
                        {
                            if (m.Hits == 0 && (m.HitsMax == 0 || m.HitsMax == 1))
                            {
                                m.HitsMax = 1;
                                if (m.Name == null || m.Name == "")
                                {
                                    m.Name = "<No Data>";
                                }
                            }
                            else if (m.Name == null || m.Name == "" || m.Name == "<No Data>")
                            {
                                m.Name = "<No Name>";
                            }

                            ClientCommunication.ForceSendToClient(new MobileStatusCompact(m));
                        }
                        break;
                    }

                    case 0x05:
                    {
                        ClientCommunication.ForceSendToClient(new SkillsList());
                        break;
                    }
                    }

                    break;
                }

                case 0x6C:                         // target
                {
                    p.ReadByte();                  // type
                    uint tid = p.ReadUInt32();
                    p.ReadByte();                  // flags
                    Serial s = p.ReadUInt32();

                    if (tid == Targeting.LocalTargID)
                    {
                        ClientCommunication.ForceSendToClient(new UnicodeMessage(0xFFFFFFFF, -1, MessageType.Regular, 0x25, 3, Language.CliLocName, "System", String.Format("Serial Number is {0}", s)));
                    }
                    break;
                }

                case 0xAD:                         // speech
                {
                    p.MoveToData();
                    Command.OnSpeech(p, new PacketHandlerEventArgs());
                    break;
                }

                case 0xBF:                         // Extended Packet
                {
                    ushort subType = p.ReadUInt16();

                    switch (subType)
                    {
                    case 0x1E:                                     // QueryDesignDetails (custom house)
                    {
                        Item i = World.FindItem(p.ReadUInt32());
                        if (i != null && i.HousePacket != null)
                        {
                            ClientCommunication.ForceSendToClient(new Packet(i.HousePacket, i.HousePacket.Length, true));
                        }
                        break;
                    }
                    }
                    break;
                }
                }

                return(false);
            }
            else if (m_Recording)
            {
                if (p == null)
                {
                    return(true);
                }

                switch (p.PacketID)
                {
                case 0xB1:                         // gump response
                    p.ReadInt32();                 // skip serial

                    WritePacket(new CloseGump(p.ReadUInt32()));
                    break;
                }

                return(true);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 3
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") && Client.Instance.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);
        }
Ejemplo n.º 4
0
        public void Dress()
        {
            if (World.Player == null)
            {
                return;
            }

            int         skipped = 0, gone = 0, done = 0;
            List <Item> list         = new List <Item>();
            bool        remConflicts = Config.GetBool("UndressConflicts");

            if (World.Player.Backpack == null)
            {
                World.Player.SendMessage(LocString.NoBackpack);
                return;
            }

            if (Macros.MacroManager.AcceptActions)
            {
                Macros.MacroManager.Action(new Macros.DressAction(Name));
            }

            ScriptManager.AddToScript($"dress '{Name}'");

            for (int i = 0; i < Items.Count; i++)
            {
                Item item = null;
                if (Items[i] is Serial)
                {
                    item = World.FindItem((Serial)Items[i]);
                    if (item == null)
                    {
                        gone++;
                    }
                    else
                    {
                        list.Add(item);
                    }
                }
                else if (Items[i] is ItemID)
                {
                    ItemID id = (ItemID)Items[i];

                    // search to make sure they are not already wearing this...
                    item = World.Player.FindItemByID(id);
                    if (item != null)
                    {
                        skipped++;
                    }
                    else
                    {
                        item = World.Player.Backpack.FindItemByID(id);
                        if (item == null)
                        {
                            gone++;
                        }
                        else
                        {
                            list.Add(item);
                        }
                    }
                }
            }

            foreach (Item item in list)
            {
                if (item.Container == World.Player)
                {
                    skipped++;
                }
                else if (item.IsChildOf(World.Player.Backpack) || item.RootContainer == null)
                {
                    Layer layer = GetLayerFor(item);
                    if (layer == Layer.Invalid || layer > Layer.LastUserValid)
                    {
                        continue;
                    }

                    if (remConflicts)
                    {
                        Item conflict = World.Player.GetItemOnLayer(layer);
                        if (conflict != null)
                        {
                            DragDropManager.DragDrop(conflict, FindUndressBag(conflict));
                        }

                        // try to also undress conflicting hand(s)
                        if (layer == Layer.RightHand)
                        {
                            conflict = World.Player.GetItemOnLayer(Layer.LeftHand);
                        }
                        else if (layer == Layer.LeftHand)
                        {
                            conflict = World.Player.GetItemOnLayer(Layer.RightHand);
                        }
                        else
                        {
                            conflict = null;
                        }

                        if (conflict != null && (conflict.IsTwoHanded || item.IsTwoHanded))
                        {
                            DragDropManager.DragDrop(conflict, FindUndressBag(conflict));
                        }
                    }

                    DragDropManager.DragDrop(item, World.Player, layer);
                    done++;
                }
            }

            if (done > 0)
            {
                World.Player.SendMessage(LocString.DressQueued, done);
            }
            if (skipped > 0)
            {
                World.Player.SendMessage(LocString.AlreadyDressed, skipped);
            }
            if (gone > 0)
            {
                World.Player.SendMessage(LocString.ItemsNotFound, gone);
            }
        }
Ejemplo n.º 5
0
        public static bool ServerPacket(Packet p)
        {
            if (Playing)
            {
                return(false);                // dont allow the client to recv server packets.
            }
            else if (m_Recording && p != null)
            {
                if (World.Player == null)
                {
                    Stop();
                    return(true);
                }

                switch (p.PacketID)
                {
                case 0x21:                         // Movement Reject
                case 0x27:                         // Lift Reject
                case 0x6C:                         // Target
                case 0x7C:                         // Menu
                case 0x88:                         // Display paper doll
                case 0xB2:                         // Chat Message
                case 0xBA:                         // Quest Arrow
                    return(true);

                case 0x22:                         // Movement Ack
                {
                    // replace movement ack with a force walk
                    byte seq = p.ReadByte();
                    if (World.Player.HasWalkEntry(seq))
                    {
                        WritePacket(new ForceWalk(World.Player.GetMoveEntry(seq).Dir & Direction.Mask));
                        //WritePacket( new MobileUpdate( World.Player ) );
                    }
                    return(true);
                }

                case 0xBF:
                {
                    short type = p.ReadInt16();
                    switch (type)
                    {
                    case 0x06:                                    // party stuff
                    {
                        byte subType = p.ReadByte();

                        if (subType == 0x03 || subType == 0x04)
                        {
                            Mobile from = World.FindMobile(p.ReadUInt32());
                            string msg  = p.ReadUnicodeStringSafe();

                            string send = String.Format("[{0}]: {1}", from != null && from.Name != null && from.Name.Length > 0 ? from.Name : "Party", msg);

                            WritePacket(new UnicodeMessage(Serial.MinusOne, 0, MessageType.System, 0x3b2, 3, "ENU", "Party", send));
                        }
                        return(true);
                    }

                    case 0x1D:                                     // House Revision info
                    {
                        Item i = World.FindItem(p.ReadUInt32());
                        if (i != null)
                        {
                            i.HouseRevision = p.ReadInt32();

                            if (!m_HouseDataWritten.Contains(i.Serial))
                            {
                                if (i.HousePacket == null)
                                {
                                    i.MakeHousePacket();
                                }
                                if (i.HousePacket != null)
                                {
                                    m_HouseDataWritten.Add(i.Serial);
                                    // WritePacket( p );
                                    WritePacket(new Packet(i.HousePacket, i.HousePacket.Length, true));
                                    return(true);
                                }
                            }
                        }

                        break;
                    }
                    }
                    break;
                }

                case 0xD8:                         // Custom House data
                {
                    p.ReadByte();                  // Compression
                    p.ReadByte();                  // Unknown
                    Serial s = p.ReadUInt32();

                    m_HouseDataWritten.Add(s);
                    break;
                }
                }

                WritePacket(p);
                return(true);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 6
0
        public bool UpdateContainer()
        {
            if (!(m_Parent is Serial) || Deleted)
            {
                return(true);
            }

            object o       = null;
            Serial contSer = (Serial)m_Parent;

            if (contSer.IsItem)
            {
                o = World.FindItem(contSer);
            }
            else if (contSer.IsMobile)
            {
                o = World.FindMobile(contSer);
            }

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

            m_Parent = o;

            if (m_Parent is Item)
            {
                ((Item)m_Parent).AddItem(this);
            }
            else if (m_Parent is Mobile)
            {
                ((Mobile)m_Parent).AddItem(this);
            }

            if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver)))
            {
                bool exempt = SearchExemptionAgent.IsExempt(this);
                if (!exempt)
                {
                    Counter.Count(this);
                }

                if (m_IsNew)
                {
                    if (m_AutoStack)
                    {
                        AutoStackResource();
                    }

                    if (IsContainer && !exempt && (!IsPouch || !Config.GetBool("NoSearchPouches")) && Config.GetBool("AutoSearch"))
                    {
                        PacketHandlers.IgnoreGumps.Add(this);
                        PlayerData.DoubleClick(this);

                        for (int c = 0; c < Contains.Count; c++)
                        {
                            Item icheck = (Item)Contains[c];
                            if (icheck.IsContainer && !SearchExemptionAgent.IsExempt(icheck) && (!icheck.IsPouch || !Config.GetBool("NoSearchPouches")))
                            {
                                PacketHandlers.IgnoreGumps.Add(icheck);
                                PlayerData.DoubleClick(icheck);
                            }
                        }
                    }
                }
            }
            m_AutoStack = m_IsNew = false;

            return(true);
        }
Ejemplo n.º 7
0
        public void Undress()
        {
            if (World.Player == null)
            {
                return;
            }

            int  count      = 0;
            Item undressBag = World.Player.Backpack;

            if (undressBag == null)
            {
                World.Player.SendMessage(LocString.NoBackpack);
                return;
            }

            if (Macros.MacroManager.AcceptActions)
            {
                Macros.MacroManager.Action(new Macros.UnDressAction(Name));
            }

            if (ScriptManager.Recording)
            {
                ScriptManager.AddToScript($"undress '{Name}'");
            }

            if (m_UndressBag.IsValid)
            {
                Item bag = World.FindItem(m_UndressBag);
                if (bag != null && (bag.RootContainer == World.Player ||
                                    (bag.RootContainer == null && Utility.InRange(bag.GetWorldPosition(),
                                                                                  World.Player.Position, 2))))
                {
                    undressBag = bag;
                }
                else
                {
                    World.Player.SendMessage(LocString.UndressBagRange);
                }
            }

            for (int i = 0; i < Items.Count; i++)
            {
                Item item = null;
                if (Items[i] is Serial)
                {
                    item = World.FindItem((Serial)Items[i]);
                }
                else if (Items[i] is ItemID)
                {
                    item = World.Player.FindItemByID((ItemID)Items[i]);
                }

                if (item == null || DragDropManager.CancelDragFor(item.Serial) || item.Container != World.Player)
                {
                    continue;
                }
                else
                {
                    DragDropManager.DragDrop(item, undressBag);
                    count++;
                }
            }

            World.Player.SendMessage(LocString.UndressQueued, count);
        }
Ejemplo n.º 8
0
        internal 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)
            {
                return(false);
            }

            Item free = null, pack = World.Player.Backpack;

            if (s.IsItem && pack != null && RazorEnhanced.Settings.General.ReadBool("PotionEquip"))
            {
                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)
                    {
                        DragDropManager.DragDrop(free, pack);
                    }
                }
            }

            DragDropManager.DoubleClick(s);

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

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

            return(false);
        }
Ejemplo n.º 9
0
        public static bool DoLastTarget()
        {
            if (FromGrabHotKey)
            {
                return(true);
            }

            TargetInfo targ;

            if (IsSmartTargetingEnabled())
            {
                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") && Client.Instance.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
            {
                Client.Instance.SendToServer(new TargetResponse(targ));
            }
            return(true);
        }
Ejemplo n.º 10
0
        internal bool UpdateContainer()
        {
            if (!(m_Parent is Serial) || Deleted)
            {
                return(true);
            }

            object o       = null;
            Serial contSer = (Serial)m_Parent;

            if (contSer.IsItem)
            {
                o = World.FindItem(contSer);
            }
            else if (contSer.IsMobile)
            {
                o = World.FindMobile(contSer);
            }

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

            m_Parent = o;

            if (m_Parent is Item)
            {
                ((Item)m_Parent).AddItem(this);
            }
            else if (m_Parent is Mobile)
            {
                ((Mobile)m_Parent).AddItem(this);
            }

            if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver)))
            {
                if (m_IsNew)
                {
                    if (m_AutoStack)
                    {
                        AutoStackResource();
                    }

                    if (RazorEnhanced.Settings.General.ReadBool("AutoSearch") &&
                        IsContainer &&
                        !(IsPouch && RazorEnhanced.Settings.General.ReadBool("NoSearchPouches")) &&
                        !this.IsBagOfSending
                        )
                    {
                        PacketHandlers.IgnoreGumps.Add(this);
                        PlayerData.DoubleClick(this);

                        for (int c = 0; c < Contains.Count; c++)
                        {
                            Item icheck = (Item)Contains[c];
                            if (icheck.IsContainer)
                            {
                                if (icheck.IsPouch && RazorEnhanced.Settings.General.ReadBool("NoSearchPouches"))
                                {
                                    continue;
                                }
                                if (icheck.IsBagOfSending)
                                {
                                    continue;
                                }
                                PacketHandlers.IgnoreGumps.Add(icheck);
                                PlayerData.DoubleClick(icheck);
                            }
                        }
                    }
                }
            }
            m_AutoStack = m_IsNew = false;

            return(true);
        }
Ejemplo n.º 11
0
        private static void WorldItem(PacketReader p)
        {
            Item item;
            uint serial = p.ReadUInt32();

            item = World.FindItem(serial & 0x7FFFFFFF);
            if (item == null)
            {
                World.AddItem(item = new Item(serial & 0x7FFFFFFF));
            }

            item.Container = null;
            if (World.Player.Holding == item)
            {
                World.Player.Holding = null;
            }

            ushort itemID = p.ReadUInt16();

            item.ItemID = (ushort)(itemID & 0x7FFF);

            if ((serial & 0x80000000) != 0)
            {
                item.Amount = p.ReadUInt16();
            }
            else
            {
                item.Amount = 0;
            }

            if ((itemID & 0x8000) != 0)
            {
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());
            }

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();

            if ((x & 0x8000) != 0)
            {
                item.Direction = p.ReadByte();
            }
            else
            {
                item.Direction = 0;
            }

            short z = p.ReadSByte();

            item.Position = new Point3D(x & 0x3FFF, y & 0x3FFF, z);

            if ((y & 0x8000) != 0)
            {
                item.Hue = p.ReadUInt16();
            }
            else
            {
                item.Hue = 0;
            }

            byte flags = 0;

            if ((y & 0x4000) != 0)
            {
                flags = p.ReadByte();
            }

            item.ProcessPacketFlags(flags);

            Item.UpdateContainers();
        }
Ejemplo n.º 12
0
        private static void MobileIncoming(PacketReader p)
        {
            Serial  serial   = p.ReadUInt32();
            ushort  body     = p.ReadUInt16();
            Point3D position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte());

            if (Utility.Distance(World.Player.Position, position) > 18)
            {
                return;
            }

            Mobile m = World.FindMobile(serial);

            if (m == null)
            {
                World.AddMobile(m = new Mobile(serial));
            }

            bool wasHidden = !m.Visible;

            m.Body      = body;
            m.Position  = position;
            m.Direction = (Direction)p.ReadByte();
            m.Hue       = p.ReadUInt16();
            bool wasPoisoned = m.Poisoned;

            m.ProcessPacketFlags(p.ReadByte());
            byte oldNoto = m.Notoriety;

            m.Notoriety = p.ReadByte();

            while (true)
            {
                serial = p.ReadUInt32();
                if (!serial.IsItem)
                {
                    break;
                }

                Item item = World.FindItem(serial);
                if (item == null)
                {
                    World.AddItem(item = new Item(serial));
                }

                if (World.Player.Holding == item)
                {
                    World.Player.Holding = null;
                }

                ushort id = p.ReadUInt16();
                item.ItemID = (ushort)(id & 0x3FFF);
                item.Layer  = p.ReadByte();

                if ((id & 0x8000) != 0)
                {
                    item.Hue = p.ReadUInt16();
                }
                else
                {
                    item.Hue = 0;
                }

                item.Container = m;
            }
            Item.UpdateContainers();
        }
Ejemplo n.º 13
0
        public static bool DoLastTarget()
        {
            TargetInfo targ;

            if (Config.GetBool("SmartLastTarget"))
            {
                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))
                {
                    return(false);
                }
                else
                {
                    pos = new Point3D(targ.X, targ.Y, targ.Z);
                }
            }

            if (Config.GetBool("RangeCheckLT") && (pos == Point3D.Zero || !Utility.InRange(World.Player.Position, pos, Config.GetInt("LTRange"))))
            {
                if (Config.GetBool("QueueTargets"))
                {
                    m_QueueTarget = LastTargetAction;
                }
                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);
        }
Ejemplo n.º 14
0
        internal static bool DoLastTarget()
        {
            TargetInfo targ;

            if (Engine.MainWindow.SmartLastTarget.Checked)
            {
                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 (RazorEnhanced.Settings.General.ReadBool("RangeCheckLT") && (pos == Point3D.Zero || !Utility.InRange(World.Player.Position, pos, RazorEnhanced.Settings.General.ReadInt("LTRange"))))
            {
                if (RazorEnhanced.Settings.General.ReadBool("QueueTargets"))
                {
                    m_QueueTarget = LastTargetAction;
                }
                World.Player.SendMessage(MsgLevel.Warning, LocString.LTOutOfRange);
                return(false);
            }

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

            CancelClientTarget(false);
            m_HasTarget = false;

            targ.TargID = m_CurrentID;

            if (m_Intercept)
            {
                OneTimeResponse(targ);
            }
            else
            {
                Assistant.Client.Instance.SendToServer(new TargetResponse(targ));
            }
            return(true);
        }