Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 11-09-2006, 05:23 AM   #1 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default Snooping the pack of the mount someone is riding

I added packs to all mounts (execpt ethereals of course) and am trying to think of a way to add the snooping in.

So far I have come up with this:
A thief can single click a mounted player to bring up the "Open Paperdoll" context menu. From there, they can snoop the mounted players pack.
A thief can double click a mounted player to attempt to snoop the MOUNTS pack.

The problem is, Im not sure where to do this. I thought it would be in the playermobile.cs in the OnDoubleClick override.
At the moment, it looks like this:

Code:
public override void OnDoubleClick( Mobile from )
{
	if ( this == from && !Warmode )
	{
		IMount mount = Mount;
		if ( mount != null && !DesignContext.Check( this ) )
			return;
	}
	base.OnDoubleClick( from );
}
and I am thinking of something along these lines (and adding snooping it later):
Code:
public override void OnDoubleClick( Mobile from )
{
	IMount mount = Mount;
	if ( this == from && !Warmode )
	{
		if ( mount != null && !DesignContext.Check( this ) )
			return;
	}
	if ( this != from && this.Mount != null )
	{				
		BaseCreature themount = mount as BaseCreature;
		TryPackOpen( themount, from );
	}
	base.OnDoubleClick( from );
}

public static void TryPackOpen( BaseCreature animal, Mobile from )
{
	if ( animal.IsDeadPet )
		return;

	Container item = animal.Backpack;

	if ( item != null )
		from.Use( item );
}
Im sure that that code won't work (and Im scripting blind at the moment). Should I be looking in a file other than the PlayerMobile.cs to get this idea to work?
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-09-2006, 08:33 AM   #2 (permalink)
Forum Master
 
Joeku's Avatar
 
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
Default

Code:
public override void OnDoubleClick( Mobile from )
{
	IMount mount = from.Mount;

	if ( this == from && !Warmode )
	{
		if ( mount != null && !DesignContext.Check( this ) )
			return;
	}

	if ( this != from && mount != null )
	{			
		BaseCreature theMount = mount as BaseCreature;

		if( theMount != null )
			this.TryPackOpen( theMount );
	}

	base.OnDoubleClick( from );
}

public void TryPackOpen( BaseCreature animal )
{
	if ( animal.IsDeadPet )
		return;

	Container item = animal.Backpack;

	if ( item != null )
		this.Use( item );
}
Joeku is offline   Reply With Quote
Old 11-10-2006, 03:35 AM   #3 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

I finally got around to testing it, it compiles fine, but does the same as I had before. If you double click someone with a pack mount, it just opens their paperdoll.

Im doing some in depth testing now to see exactly what its doing. Ill post more info once Im done with that
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-10-2006, 04:24 AM   #4 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

I put messages in all areas to see what was being done, but not a single message popped up. It looks like the whole ondoubleclick block is ignored.

What other possibilities are open to get this working?
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-10-2006, 04:56 AM   #5 (permalink)
Forum Newbie
 
Join Date: Nov 2003
Posts: 21
Default

maybe make it a context menu instead of onDDclick
__________________
Majere is offline   Reply With Quote
Old 11-10-2006, 09:35 AM   #6 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

Ok, Im trying to accomplish this through a command "[snoop"

This compiles fine, I can target players, but when I target a player riding a mount that has a pack, it says:

you glance casually into the animals pack.
you try to peek.

Which leads me to believe that
from.Use( item ); is not working as It should be, or I have the wrong command entirely. Thoughts?
I have also tried item.DisplayTo( from ); with no luck.

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

namespace Server.Commands 
{ 
	public class Snoop 
	{ 
		public static void Initialize() 
		{ 
			CommandSystem.Register( "snoop", AccessLevel.Player, new CommandEventHandler( Snoop_OnCommand ) ); 
		} 		
		
		[Usage( "snoop" )] 
		[Description( "Use this command to attempt to snoop from a players mount while they are on it!")]
		public static void Snoop_OnCommand( CommandEventArgs e ) 
		{			
				e.Mobile.Target = new SnoopTarget();		
		}

		private class SnoopTarget : Target
		{
			public SnoopTarget() : base( -1, true, TargetFlags.None )
			{
			}

			protected override void OnTarget( Mobile from, object target )
			{
				if ( target is PlayerMobile	)
				{
					PlayerMobile dude = target as PlayerMobile;
					IMount mount = ((PlayerMobile)target).Mount;
				
					if ( mount != null )
					{			
						BaseCreature theMount = mount as BaseCreature;
				
						if( theMount != null )
						{
							from.SendMessage("you glance casually into the animals pack.");
							if ( theMount.IsDeadPet )
								return;
						
							Container item = theMount.Backpack;
						
							if ( item != null )
							{
								from.Use( item );
								from.SendMessage("you try to peek.");
							}
							else
							{
								from.SendMessage("you dont see a pack");
							}
						}
					}
				}
			}
		}
	} 
}
__________________
Aeternum Shard

Last edited by Jarrod; 11-10-2006 at 10:29 AM.
Jarrod is offline   Reply With Quote
Old 11-10-2006, 12:04 PM   #7 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

Im sure Im overlooking something trivial here... anyone?
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-10-2006, 04:17 PM   #8 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

Im trying a second command that is identical to the current snooping skill handler.
It does everything its supposed to EXCEPT opening the mounts pack. The players fail and gain snooping as if it were a regular snoop attempt, and when they succeed, nothing happens.

What is causing "cont.DisplayTo( from );" to not be executed?

Code:
using System; 
using Server; 
using Server.Misc;
using Server.Items; 
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server.Targeting;
using System.Collections; 

namespace Server.Commands 
{ 
	public class SnoopTwo 
	{ 
		public static void Initialize() 
		{ 
			CommandSystem.Register( "snooptwo", AccessLevel.Player, new CommandEventHandler( SnoopTwo_OnCommand ) ); 
		} 		
		
		[Usage( "snooptwo" )] 
		[Description( "Use this command to attempt to snooptwo from a players mount while they are on it!")]
		public static void SnoopTwo_OnCommand( CommandEventArgs e ) 
		{			
				e.Mobile.Target = new SnoopTwoTarget();		
		}		
		
		public static bool CheckSnoopAllowed( Mobile from, Mobile to )
		{
			Map map = from.Map;

			if ( to.Player )
				return from.CanBeHarmful( to, false, true ); // normal restrictions

			if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
				return true; // felucca you can snoop anybody

			GuardedRegion reg = (GuardedRegion) to.Region.GetRegion( typeof( GuardedRegion ) );

			if ( reg == null || reg.IsDisabled() )
				return true; // not in town? we can snoop any npc

			BaseCreature cret = to as BaseCreature;

			if ( to.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
				return false; // in town we cannot snoop blue human npcs

			return true;
		}

		private class SnoopTwoTarget : Target
		{
			public SnoopTwoTarget() : base( -1, true, TargetFlags.None )
			{
			}

			protected override void OnTarget( Mobile from, object target )
			{
				if ( target is PlayerMobile	)
				{
					PlayerMobile dude = target as PlayerMobile;
					BaseCreature mount = dude.Mount as BaseCreature;
					Container cont = mount.Backpack;
					if ( cont != null)
					{				
						if ( from.AccessLevel > AccessLevel.Player || from.InRange( cont.GetWorldLocation(), 1 ) )
						{
							Mobile root = cont.RootParent as Mobile;
			
							if ( root != null && !root.Alive )
								return;
			
							if ( root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player )
							{
								from.SendLocalizedMessage( 500209 ); // You can not peek into the container.
								return;
							}
			
							if ( root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed( from, root ) )
							{
								from.SendLocalizedMessage( 1001018 ); // You cannot perform negative acts on your target.
								return;
							}
			
							if ( root != null && from.AccessLevel == AccessLevel.Player && from.Skills[SkillName.Snooping].Value < Utility.Random( 100 ) )
							{
								Map map = from.Map;
			
								if ( map != null )
								{
									string message = String.Format( "You notice {0} attempting to peek into {1}'s belongings.", from.Name, root.Name );
			
									IPooledEnumerable eable = map.GetClientsInRange( from.Location, 8 );
			
									foreach ( NetState ns in eable )
									{
										if ( ns != from.NetState )
											ns.Mobile.SendMessage( message );
									}
			
									eable.Free();
								}
							}
			
							if ( from.AccessLevel == AccessLevel.Player )
								Titles.AwardKarma( from, -4, true );
			
							if ( from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill( SkillName.Snooping, cont, 0.0, 100.0 ) )
							{
								if ( cont is TrapableContainer && ((TrapableContainer)cont).ExecuteTrap( from ) )
									return;
			
								cont.DisplayTo( from );
							}
							else
							{
								from.SendLocalizedMessage( 500210 ); // You failed to peek into the container.
							}
						}
						else
						{
							from.SendLocalizedMessage( 500446 ); // That is too far away.
						}
					}
				}
			}
		}
	} 
}
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-12-2006, 06:30 AM   #9 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

I still need assistance with this. Has anyone been able to check into it?
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-12-2006, 03:50 PM   #10 (permalink)
Forum Expert
 
pacolaco2's Avatar
 
Join Date: Mar 2005
Age: 17
Posts: 1,117
Send a message via AIM to pacolaco2 Send a message via MSN to pacolaco2 Send a message via Yahoo to pacolaco2
Default

Quote:
Originally Posted by Jarrod
I still need assistance with this. Has anyone been able to check into it?
Have you tried looking at the way people snoop pack animals?
__________________
Vaughn Peterson,
Kate Maclellan,
Drew Cook,
William Soverino,
rest in peace.
pacolaco2 is offline   Reply With Quote
Old 11-12-2006, 04:17 PM   #11 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

yes, thats where the routines are from. Something appears to be wrong with the cont.DisplayTo( from ); function in this case. Im guessing it has something to do with a distance check, but I cant be sure.
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-13-2006, 07:50 AM   #12 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

Quick question, when a player mounts an animal, does it go to map.internal?
If yes, then I think that there might not be a feasible way of snooping from that mounts pack.

This would also mean that all of the above posted code is in fact, correct IF the mount were not in the internal map.

I hope that RunUO doesnt use the old "horse barn" method, but if so, then distance is the issue in this case.
__________________
Aeternum Shard
Jarrod is offline   Reply With Quote
Old 11-13-2006, 08:16 AM   #13 (permalink)
Forum Master
 
Joeku's Avatar
 
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
Default

Quote:
Originally Posted by Jarrod
Quick question, when a player mounts an animal, does it go to map.internal?
If yes, then I think that there might not be a feasible way of snooping from that mounts pack.

This would also mean that all of the above posted code is in fact, correct IF the mount were not in the internal map.

I hope that RunUO doesnt use the old "horse barn" method, but if so, then distance is the issue in this case.
I didn't think of that, but yes you're correct.
It actually goes to the mobile's "Mount Layer" but that's still the internal map.
So... yeah. You can't do this the conventional way. You'll probably have to edit Backpack.cs and override the IsAccessibleTo method.
Joeku is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5