Beispiel #1
0
        public override void OnPositionChanging(Point3D newPos)
        {
            int visRange = 18;            //Configuration.GetInt( "VisRange" );

            ArrayList list = new ArrayList(World.Mobiles.Values);

            for (int i = 0; i < list.Count; i++)
            {
                Mobile m = (Mobile)list[i];
                if (m != this && Utility.Distance(m.Position, newPos) > visRange)
                {
                    m.Remove();
                }
            }

            list = new ArrayList(World.Items.Values);
            for (int i = 0; i < list.Count; i++)
            {
                Item item = (Item)list[i];
                if (item.Deleted || item.Container != null)
                {
                    continue;
                }

                int dist = Utility.Distance(item.GetWorldPosition(), newPos);
                if (item != this.Holding && dist > visRange)
                {
                    item.Remove();
                }
            }

            base.OnPositionChanging(newPos);
        }
Beispiel #2
0
        public override void OnPositionChanging(Point3D newPos)
        {
            List <Mobile> mlist = new List <Mobile>(World.Mobiles.Values);

            for (int i = 0; i < mlist.Count; i++)
            {
                Mobile m = mlist[i];
                if (m != this)
                {
                    if (!Utility.InRange(m.Position, newPos, VisRange))
                    {
                        m.Remove();
                    }
                    else
                    {
                        Targeting.CheckLastTargetRange(m);
                    }
                }
            }

            mlist = null;


            List <Item>    ilist = new List <Item>(World.Items.Values);
            ScavengerAgent s     = ScavengerAgent.Instance;

            for (int i = 0; i < ilist.Count; i++)
            {
                Item item = ilist[i];
                if (item.Deleted || item.Container != null)
                {
                    continue;
                }

                int dist = Utility.Distance(item.GetWorldPosition(), newPos);
                if (item != DragDropManager.Holding && (dist > MultiVisRange || (!item.IsMulti && dist > VisRange)))
                {
                    item.Remove();
                }
                else if (!IsGhost && Visible && dist <= 2 && s.Enabled && item.Movable)
                {
                    s.Scavenge(item);
                }
            }

            ilist = null;

            base.OnPositionChanging(newPos);
        }
Beispiel #3
0
        public override void OnPositionChanging(Point3D oldPos)
        {
            AutoOpenDoors();

            List <Mobile> mlist = new List <Mobile>(World.Mobiles.Values);

            for (int i = 0; i < mlist.Count; i++)
            {
                Mobile m = mlist[i];
                if (m != this)
                {
                    if (!Utility.InRange(m.Position, Position, VisRange))
                    {
                        m.Remove();
                    }
                    else
                    {
                        Targeting.CheckLastTargetRange(m);
                    }
                }
            }

            mlist = null;


            List <Item> ilist = new List <Item>(World.Items.Values);

            for (int i = 0; i < ilist.Count; i++)
            {
                Item item = ilist[i];
                if (item.Deleted || item.Container != null)
                {
                    continue;
                }

                int dist = Utility.Distance(item.GetWorldPosition(), Position);
                if (item != DragDropManager.Holding && (dist > MultiVisRange || (!item.IsMulti && dist > VisRange)))
                {
                    item.Remove();
                }
            }

            ilist = null;

            base.OnPositionChanging(oldPos);
        }
Beispiel #4
0
        public static Item FindUndressBag(Item item)
        {
            Item undressBag = World.Player.Backpack;

            for (int i = 0; i < m_List.Count; i++)
            {
                DressList list = m_List[i];
                if (list != null && (list.Items.Contains(item.Serial) || list.Items.Contains(item.ItemID)))
                {
                    if (list.m_UndressBag.IsValid)
                    {
                        Item bag = World.FindItem(list.m_UndressBag);
                        if (bag != null && (bag.RootContainer == World.Player ||
                                            (bag.RootContainer == null && Utility.InRange(bag.GetWorldPosition(),
                                                                                          World.Player.Position, 2))))
                        {
                            undressBag = bag;
                        }
                    }

                    break;
                }
            }

            return(undressBag);
        }
Beispiel #5
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 (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);
        }
Beispiel #6
0
        public static ProcStatus ProcessNext(int numPending)
        {
            if (m_Pending != Serial.Zero)
            {
                if (m_Lifted + TimeSpan.FromMinutes(2) < DateTime.UtcNow)
                {
                    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)
                        {
                            Client.Instance.SendToServer(new DropRequest(m_Pending, Point3D.MinusOne,
                                                                         World.Player.Backpack.Serial));
                        }
                        else
                        {
                            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.");
                        ScavengerAgent.Instance.Uncache(item.Serial);
                        return(ProcStatus.Nothing);
                    }
                }

                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)
                    {
                        Client.Instance.SendToServer(new EquipRequest(lr.Serial, dr.Serial, dr.Layer));
                    }
                    else
                    {
                        Client.Instance.SendToServer(new DropRequest(lr.Serial, dr.Point, dr.Serial));
                    }
                }
                else
                {
                    m_Pending = lr.Serial;
                    m_Lifted  = DateTime.UtcNow;
                }

                return(ProcStatus.Success);
            }
            else
            {
                Log("No lift to be done?!");
                return(ProcStatus.Nothing);
            }
        }
Beispiel #7
0
        public override void OnPositionChanging(Point3D oldPos)
        {
            if (!IsGhost)
            {
                StealthSteps.OnMove();
            }

            AutoOpenDoors(false);

            List <Mobile> mlist = new List <Mobile>(World.Mobiles.Values);

            for (int i = 0; i < mlist.Count; i++)
            {
                Mobile m = mlist[i];
                if (m != this)
                {
                    if (!Utility.InRange(m.Position, Position, VisRange))
                    {
                        m.Remove();
                    }
                    else
                    {
                        Targeting.CheckLastTargetRange(m);
                    }
                }
            }

            mlist = null;


            List <Item>    ilist = new List <Item>(World.Items.Values);
            ScavengerAgent s     = ScavengerAgent.Instance;

            for (int i = 0; i < ilist.Count; i++)
            {
                Item item = ilist[i];
                if (item.Deleted || item.Container != null)
                {
                    continue;
                }

                int dist = Utility.Distance(item.GetWorldPosition(), Position);
                if (item != DragDropManager.Holding && (dist > MultiVisRange || (!item.IsMulti && dist > VisRange)))
                {
                    item.Remove();
                }
                else if (!IsGhost && Visible && dist <= 2 && s.Enabled && item.Movable)
                {
                    s.Scavenge(item);
                }
            }

            ilist = null;

            if (Engine.MainWindow != null && Engine.MainWindow.MapWindow != null)
            {
                Engine.MainWindow.SafeAction(f => f.MapWindow.PlayerMoved());
            }

            base.OnPositionChanging(oldPos);
        }
Beispiel #8
0
        public static bool DoLastTarget()
        {
            TargetInfo targ;

            if (Config.GetBool("SmartLastTarget") && Client.Instance.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") && 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);
        }
Beispiel #9
0
        internal static bool DoAutoTarget()
        {
            TargetInfo targ;

            targ = m_AutoTarget;

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

            Point3D pos;

            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 = AutoTargetAction;
                }
                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);
        }
Beispiel #10
0
 public Point3D GetWorldPosition()
 {
     Assistant.Point3D     assistantPoint = m_AssistantItem.GetWorldPosition();
     RazorEnhanced.Point3D enhancedPoint  = new RazorEnhanced.Point3D(assistantPoint);
     return(enhancedPoint);
 }