RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Client limitation workaround: Dynamic backpacks

warlocke

Wanderer
Client limitation workaround: Dynamic backpacks

Hey folks,

I've run into a snag on a system for instanced stealing backpacks that I've been working on. In order to make a pack display to the player, it has to be on the creature in question's top layer. I'm using a custom container (let's say StealPack:Backpack) on Layer.Unused_x9. Anyway, here's the problem;

Since these packs are generated upon the player attempting to steal from the mobile, it has to be created and then dropped onto the target mobile on that unused layer. The problem is that it never displays (using StealPack.DisplayTo(PlayerMobile)) the FIRST time. It will display on subsequent steal attempts, but never the first time. I suspect this is a client limitation, and the best workaround I can come up with is to write a timer to open the pack a second later, but I'd rather not have that delay...

Anyone have any ideas?
 

warlocke

Wanderer
Loophole: Do not keep bumping (implying repetition) - Only doing this once, after that I'm just assuming that no one has the slightest clue and I'm screwed ;)
 

daat99

Moderator
Staff member
warlocke said:
Loophole: Do not keep bumping (implying repetition) - Only doing this once, after that I'm just assuming that no one has the slightest clue and I'm screwed ;)
There are a lot of people on different time zones in this forum.
Wait untill 4 days before you try to bump or repost it.
 

warlocke

Wanderer
Here's some test code:
'add demonknight set cantwalk true
'st (target demonknight - pack should display here, but doesn't)
'st (target demonknight - pack displays on second attempt only)



Code:
using Server;
using System;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;

namespace Server {

	public class StealSysTest {
		
		static StealSysTest() {
			
		}
		public static void Initialize() {
			Commands.Register("st",AccessLevel.GameMaster,new CommandEventHandler( StealTest_OnCommand ));
		}
		[Usage("ST")]
		[Description("Command used to debug instanced stealing system - ST stands for 'Steal Test'")]
		public static void StealTest_OnCommand( CommandEventArgs e ) {
			e.Mobile.Target = new STTarg();
		}
		
		public class STTarg : Target {
			public STTarg() : base( -1, true, TargetFlags.None )
			{
			}

			protected override void OnTarget( Mobile from, object o )
			{
				BaseCreature targ;
				if (o is BaseCreature) {
					targ = o as BaseCreature;
					Item test = targ.FindItemOnLayer(Layer.Unused_x9);
					if (test == null) {
						Backpack bp = new Backpack();
						bp.Layer = Layer.Unused_x9;
						bp.Movable = false;
						targ.AddItem(bp);
						bp.DisplayTo(from);
					} else {
						((Backpack)test).DisplayTo(from);
					}
					from.SendMessage("You should see a backpack");
				}
			}
		}
	}
	
	
}
 

Seg

Wanderer
try removing the test == null portion, and see if it works just as ((Backpack)test).DisplayTo(from);

and/or add a from.sendmessage(); message in the test == null portion just to double check that the code is executing
 

warlocke

Wanderer
test == null is necessary - otherwise you'd be adding new backpacks every round.
the code is valid, it seems to be a client limitation (possibly a delay between the backpack being exposed to the client and the DisplayTo method?)
 

Seg

Wanderer
I just saying remove
Code:
if (test == null) {
						Backpack bp = new Backpack();
						bp.Layer = Layer.Unused_x9;
						bp.Movable = false;
						targ.AddItem(bp);
						bp.DisplayTo(from);
					}
and just leave
((Backpack)test).DisplayTo(from);
 

warlocke

Wanderer
Got it!

from.Send( new Network.MobileIncoming( from, targ ) );

might have to send to all playermobiles in range, but otherwise, it works!

=)
 
Top