Hello, I am attempting to increase the range at which corpses can be looted by the player so one does not have to stand almost directly on top of a corpse to interact with it.

So far I have made it to where I can open the corpse's container at greater range. However, when attempting to pick up an item within the container I am unable to until I move back to about default range.

In order to accomplish what I have, I have modified corpse.cs and container.cs so anything using the instruction " from.InRange(GetWorldLocation(), x" x being the distance I want and from being the mobile that double-clicked the corpse/container.

The question is, how to I increase the range at which a player mobile can pick up an item, using the mouse cursor? An aside, when I'm out of default range and the play move it also closes the container, bonus for help with that :D
 
Below are the two places of edited in container.cs

Code:
public override void OnDoubleClick(Mobile from)
        {
            if (from.IsStaff() || from.InRange(GetWorldLocation(), 5))
            {
                DisplayTo(from);
            }
            else
            {
                from.SendLocalizedMessage(500446); // That is too far away.
            }
        }

Code:
public override void OnDoubleClickSecureTrade(Mobile from)
        {
            if (from.InRange(GetWorldLocation(), 5))
            {
                DisplayTo(from);

                SecureTradeContainer cont = GetSecureTradeCont();

                if (cont != null)
                {
                    SecureTrade trade = cont.Trade;

                    if (trade != null && trade.From.Mobile == from)
                    {
                        DisplayTo(trade.To.Mobile);
                    }
                    else if (trade != null && trade.To.Mobile == from)
                    {
                        DisplayTo(trade.From.Mobile);
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(500446); // That is too far away.
            }

Below here is where I edited corpse.cs
 
You need to look in the core. Server / Item.cs

Item.cs

This is one example of where else you would need to edit.

Code:
public virtual bool OnDroppedOnto(Mobile from, Item target)
        {
            if (Deleted || from.Deleted || target.Deleted || from.Map != target.Map || from.Map == null || target.Map == null)
            {
                return false;
            }
            else if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(target.GetWorldLocation(), 2))
            {
                return false;
            }
            else if (!from.CanSee(target) || !from.InLOS(target))
            {
                return false;
            }
            else if (!target.IsAccessibleTo(from))
            {
                return false;
            }
            else if (!from.OnDroppedItemOnto(this, target))
            {
                return false;
            }
            else if (Nontransferable && from.Player && target != from.Backpack && !from.IsStaff())
            {
                HandleInvalidTransfer(from);
                return false;
            }
            else
            {
                return target.OnDragDrop(from, this);
            }
        }

Remember after you update Item.cs you need to re-compile your core.
 
Code:
 public virtual bool DropToItem(Mobile from, Item target, Point3D p)
        {
            if (Deleted || from.Deleted || target.Deleted || from.Map != target.Map || from.Map == null || target.Map == null)
            {
                return false;
            }

            object root = target.RootParent;

            if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(target.GetWorldLocation(), 2))
            {
                return false;
            }
[doublepost=1493500633][/doublepost]This was only looked at quickly. No idea what other consequences this could have, since it is a core edit.
[doublepost=1493500768][/doublepost]Those were the only two spots I could see in Item.cs

You also need to look in Mobile.cs also in the core. Find this method and edit the TWO (2) to whatever you want.

Code:
public virtual void Lift(Item item, int amount, out bool rejected, out LRReason reject)
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if (item == null)
            {
                return;
            }

            Mobile from = this;
            NetState state = m_NetState;

            if (from.IsStaff() || Core.TickCount - from.NextActionTime >= 0)
            {
                if (from.CheckAlive())
                {
                    from.DisruptiveAction();

                    if (from.Holding != null)
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(item.GetWorldLocation(), 2))
                    {
                        reject = LRReason.OutOfRange;
                    }
[doublepost=1493500836][/doublepost]Honestly you may NOT have to edit Item.cs for what you want to achieve.

Try editing the Lift method in the Mobile.cs script I posted above. That might fix your issue. The less edits you need to make in the core the better.
 
Okay, with those edits, there were a few in item.cs under server, I can now drop things the distance I want but I cannot interact with containers from that distance and I still cannot pick up anything from the distance I'm looking for. Forgive my ignorance if there is more under server I need to change, all of my practice thus far has been under scripts. I'm very close to having this I just can't find the last few things to change. The game doesn't give me any errors or text to search for either. I've been on this one problem for a few hours now. Still pretty new to the whole ServUO system.
 
Did you see what I posted above?

I will re-post.


Code:
public virtual void Lift(Item item, int amount, out bool rejected, out LRReason reject)
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if (item == null)
            {
                return;
            }

            Mobile from = this;
            NetState state = m_NetState;

            if (from.IsStaff() || Core.TickCount - from.NextActionTime >= 0)
            {
                if (from.CheckAlive())
                {
                    from.DisruptiveAction();

                    if (from.Holding != null)
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(item.GetWorldLocation(), 2))
                    {
                        reject = LRReason.OutOfRange;
                    }


Honestly you may NOT have to edit Item.cs for what you want to achieve.

Try editing the Lift method in the Mobile.cs script I posted above. That might fix your issue. The less edits you need to make in the core the better.
 
Dang, I really thought that'd be it, I change it there and below in mobile.cs still cannot lift from the corpse container.

Code:
public virtual bool OnDragDrop(Mobile from, Item dropped)
        {
            if (from == this)
            {
                Container pack = Backpack;

                if (pack != null)
                {
                    dropped.GridLocation = 0x0;
                    return dropped.DropToItem(from, pack, new Point3D(-1, -1, 0));
                }

                return false;
            }

            if (from.InRange(Location, 5))
            {
                return OpenTrade(from, dropped);
            }
 
Does it let you lift the item? Only bouncing it back when you try to drop in your backpack? Or does it not even let you lift it. How far away are you trying to be? Are you in Line of sight?
 
Only about 4-5 "spaces" away, I do have LOS, and I can drop things about 4-5 "spaces" away from me. I cannot lift anything that far away (even with the mobile.cs edits) and I cannot lift from a container.

It's not lifting at all, staying right where it is.
 
JUST to rule this out.

Server/Network = Packets.cs

Code:
 public sealed class LiftRej : Packet
    {
        public LiftRej(LRReason reason)
            : base(0x27, 2)
        {
            m_Stream.Write((byte)reason);
        }
    }


Try changing the 2 there. See what happens. If nothing set back right away. Could even crash.
 
JUST to rule this out.

Server/Network = Packets.cs

Code:
 public sealed class LiftRej : Packet
    {
        public LiftRej(LRReason reason)
            : base(0x27, 2)
        {
            m_Stream.Write((byte)reason);
        }
    }


Try changing the 2 there. See what happens. If nothing set back right away. Could even crash.


Same result, here turn down volume, i forgot to mute it, (http://sendvid.com/pod0xfip) is a short vid on what I am getting. I am using the Compile.WIN.bat to recompile. Just so you know I'm not being a dingus lol.
 
How about single items? I see you trying to drag gold but just a single item too will freeze up? ALSO I did not know you were trying to do it with EC.

Do me a favor try with the CC too since your players will use both.
 
My apologies, yes it is EC, I can try with classic and see if the same is happening. Yes, single item just stay, but that came through poorly on video.
 
Just making sure I did not need to look at the gumps that come up when dragging stacked items, like gold.

Let me know how CC handles it. It could be an EC specific issue which I would be limited in my ability to help.
 
How about single items? I see you trying to drag gold but just a single item too will freeze up? ALSO I did not know you were trying to do it with EC.

Do me a favor try with the CC too since your players will use both.

Okay, Classic is a bit different, I can take out items from the corpse container, I can drop items and pick them up from the ground, I CANNOT put an item in a container from the desired distance. Interesting. Does seem to be an EC issue. Aside from placing item back in.
 
Okay now we are getting somewhere.

Please re-set the Packets.cs edit I had you do. That is not needed yet, though I feel it may be a packet issue at some point.
[doublepost=1493503724][/doublepost]Then retry.

With the edits in Item.cs. Mobile.cs. Corpse.cs and Container.cs do some tests.

Can you drag from an unlocked chest?

Can you drag from a chest and or a corpse and drop in another chest?

What about your player backpack.

Maybe you ONLY want to be able to drag from a Corpse and not containers? All things to consider.
 
Wonderful idea! So heres the update. I got a wooden box from the provision to test with. On both EC and CC I am able to place and take items from the desired distance. So the problems are only with corpses/mobiles it seems. The problem with them being only slightly different on the different clients.
[doublepost=1493509250][/doublepost]Well, friend, thank you for the help. Unfortunately, this has me stumped. I've been at this problem pretty much all day lol.

At this point, since the two clients are behaving differently and the amount of work that's already been put into this has yielded little results I'm going to go ahead and put this on the back burner for now. This was a quality of life improvement anyway; not necessary for the shard to work.

Thank you again, if you happen to find anything else let me know, for now, all the variables have been set back to 2 and the shard is running fine with no hick-ups on both clients. :)
 
Back