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 08-08-2008, 12:55 PM   #26 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Yes, I added a PlayerMobile property called Umbarian, and declared it as an integer, like this:

Code:
#region Custom Umbarian Edit
		private int m_Umbarian;

		[CommandProperty( AccessLevel.GameMaster )] 
		public int Umbarian
		{
      		get { return m_Umbarian; }
      		set{ m_Umbarian = value; InvalidateProperties(); }
		}
		#endregion
Then, when they click the join button, it is set to 1, and when they click the resign button, it is set to 0. then in other scripts where I need to check if the player is in the guild, I just use:

Code:
if ( Umbarian == 1 )
Idealy I would like it to be a bool (true or false) . However Playermobile hates me changing its properties, because I always manage to screw up the serialization / deserialization by mistake and that is a mission to fix.

If you are willing to give me some ideas on how you think it would be best, and some tips on how to do it without messing up the ser / deser that would be super.

PS: on a sidenote, how can I stop players from being able to drop their guild robe to the floor, forcing it to always either be in their backpack, or on their paperdoll only. This would also have to prevent them from putting it in their bank, and in bags in house.

Thanks and Regards
__________________
legendsofkaine.page.tl

Last edited by typhoonbot; 08-08-2008 at 12:57 PM. Reason: Spelling error
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 02:23 PM   #27 (permalink)
Forum Expert
 
vermillion2083's Avatar
 
Join Date: Jun 2005
Location: Lansing, MI
Age: 25
Posts: 1,042
Send a message via ICQ to vermillion2083 Send a message via MSN to vermillion2083
Default

That is what is terrific about doing it with the dictionary in the stone itself, you don’t need to alter playermobile at all! All you have to do is add a method like this to the guild stone class:

Code:
		public bool IsThiefGuildMember( Mobile from ) 
		{
			return m_UmbarianRooster.ContainsKey( from );
		}
Then from ANY other script on the server, if you want to perform a check to see if a person is in the thieves guild you just use this method:

Code:
		if( StoneClassName.IsThiefGuildMember( from ) )
		{
			// What is allowed if they are a member
		}
From any script you can call the thieves guild stone to see if the person is a member of the guild (in the dictionary) if they are then it will allow them to perform the action, if not then you do an else statement and send them the error message.

As for moving things to the world, I am pretty sure it is possible, I know there is a method somewhere that is triggered when an item is dropped onto the ground, but I wouldn’t recommend going through all the trouble. You would have to add checks for trading between players, moving it to the world, dropping it into contains (bank boxes, secure boxes, trash cans, etc) ondeath movements, etc. Personally it just seems like way too much effort to keep someone from dropping a cloak. The way we have the code written now it doesn’t matter what they do with it, the guild system always knows where it is at and can remove it. The only thing I would suggest is making the robe only be wearable by the person it was originally assigned to.

To do this just script the custom robe, and give it a Mobile m_Owner; value. When you add the robe set the person its being given to as the owner on creation:

Code:
UmbraRobe robe = new UmbraRobe();
Robe.Owner = from;
From.AddToPack( robe );
You can easily accomplish a system like this without ever touching the playermobile, which is a good idea so that in the future if new releases are released from RunUO you won’t have to go through the playermobile and re add all the modifications you’ve made over time. Let me know if you need any help with what I have provided above, good luck Typhoon!
__________________
Father Time
Life's journey is not to arrive at the grave safely in a well preserved body, but rather to skid in sideways, totally worn out, shouting "Holy Hell......What a ride!!!"

Server: UO: Extinction
ICQ: 146563794
FatherTime@UOExtinction.com
UO: Extinction homepage
UO: Extinction forum
vermillion2083 is offline   Reply With Quote
Old 08-08-2008, 03:38 PM   #28 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

I think I can safely rule out the fact that I will ever be upgrading my version of RunUO. I have made countless modifications to Distros I cant even remember all the places. as well as my entire world being perfectly decorated and spawned just the way I want it. It would simply be WAY to much effort to locate every single MOD I have ever done, and redo it in a new version. Perhaps I should have kept a log of the changes I made.

Any, thanks for the help above, I will put it to practice now. Then it's on to designing the gump, and getting that to work

regards
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 03:41 PM   #29 (permalink)
Forum Expert
 
vermillion2083's Avatar
 
Join Date: Jun 2005
Location: Lansing, MI
Age: 25
Posts: 1,042
Send a message via ICQ to vermillion2083 Send a message via MSN to vermillion2083
Default

My pleasure. That's what I do, rather then keeping a log I just relocate any distro file I modify to a folder in my custom scripts folder called "Modified distros". It has the same file tree structure as the non modified to make finding scripts I have modified easier.

I hear you about the converting. I went through that when I went from 1.0 to 2.0, lesson learned.
__________________
Father Time
Life's journey is not to arrive at the grave safely in a well preserved body, but rather to skid in sideways, totally worn out, shouting "Holy Hell......What a ride!!!"

Server: UO: Extinction
ICQ: 146563794
FatherTime@UOExtinction.com
UO: Extinction homepage
UO: Extinction forum
vermillion2083 is offline   Reply With Quote
Old 08-08-2008, 04:00 PM   #30 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Okay, quick question before I go ahead with making the changes above. if I just remove all instances of the Umbarian property in the Playermobile.cs (including the ser/ deser) will it give an error asking to delete all playermobiles like I have experienced before ?
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 04:50 PM   #31 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

Why don't you make custom class and play with serialization for better understanding? Why don't just sit and learn a thing instead of asking the same questions for the fourth time?
Soteric is offline   Reply With Quote
Old 08-08-2008, 05:07 PM   #32 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Because, playing around on a server that has been running for a while sometimes doesnt end so well

What I will do is: make a test server, and practice a bit on that...Thanks for the tip
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 05:52 PM   #33 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Ok, I have removed the umbarian property, and added in those changes vermillion

next problem: some errors I am getting that I cant seem to manage to deal with.

Errors:
+ Mobiles/PlayerMobile.cs:
CS0120: Line 3786: An object reference is required for the nonstatic field,
method, or property 'Server.Items.UmbarianStone.IsThiefGuildMember(Ser ver.Mobile
)'
+ Skills/Stealing.cs:
CS0120: Line 58: An object reference is required for the nonstatic field, me
thod, or property 'Server.Items.UmbarianStone.IsThiefGuildMember(Ser ver.Mobile)'


Here is that line in the PlayerMobile.cs:

Code:
if( UmbarianStone.IsThiefGuildMember( this ) )
Here is that line in stealing.cs:

Code:
if( !UmbarianStone.IsThiefGuildMember( from ) )
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 06:13 PM   #34 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

Post your stealing.cs
Soteric is offline   Reply With Quote
Old 08-08-2008, 06:17 PM   #35 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Here is the whole TryStealItem Method:

Code:
private Item TryStealItem( Item toSteal, ref bool caught )
			{
				Mobile from = m_Thief;
				Item stolen = null;

				object root = toSteal.RootParent;

				StealableArtifactsSpawner.StealableInstance si = null;
				if ( toSteal.Parent == null || !toSteal.Movable )
					si = StealableArtifactsSpawner.GetStealableInstance( toSteal );

				
				if( !UmbarianStone.IsThiefGuildMember( from ) )
				{
					m_Thief.SendMessage(37, "You must be in the Umbarian Shadows thief guild to steal.");
					m_Thief.Hidden = false;
					m_Thief.Criminal = true;
				}
				else if ( !IsEmptyHanded( m_Thief ) )
				{
					m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
				}
				else if ( !m_Thief.CanSee( toSteal ) )
				{
					m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
				}
				else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, toSteal, false, true ) )
				{
					m_Thief.SendLocalizedMessage( 1048147 ); // Your backpack can't hold anything else.
				}
				#region Sigils
				else if ( toSteal is Sigil )
				{						
					PlayerState pl = PlayerState.Find( m_Thief );
					Faction faction = ( pl == null ? null : pl.Faction );

					Sigil sig = (Sigil) toSteal;

					if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
					{
						m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
					}
					else if ( root != null ) // not on the ground
					{
						m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
					}
					else if ( faction != null )
					{
						if ( !m_Thief.CanBeginAction( typeof( IncognitoSpell ) ) )
						{
							m_Thief.SendLocalizedMessage( 1010581 ); //	You cannot steal the sigil when you are incognito
						}
						else if ( DisguiseGump.IsDisguised( m_Thief ) )
						{
							m_Thief.SendLocalizedMessage( 1010583 ); //	You cannot steal the sigil while disguised
						}
						else if ( !m_Thief.CanBeginAction( typeof( PolymorphSpell ) ) )
						{
							m_Thief.SendLocalizedMessage( 1010582 ); //	You cannot steal the sigil while polymorphed				
						}
						else if ( TransformationSpell.UnderTransformation( m_Thief ) )
						{
							m_Thief.SendLocalizedMessage( 1061622 ); // You cannot steal the sigil while in that form.
						}
						else if ( Spells.Ninjitsu.AnimalForm.UnderTransformation( m_Thief ) )
						{
							m_Thief.SendLocalizedMessage( 1063222 ); // You cannot steal the sigil while mimicking an animal.
						}
						else if ( pl.IsLeaving )
						{
							m_Thief.SendLocalizedMessage( 1005589 ); // You are currently quitting a faction and cannot steal the town sigil
						}
						else if ( sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction )
						{
							m_Thief.SendLocalizedMessage( 1005590 ); //	You cannot steal your own sigil
						}
						else if ( sig.IsPurifying )
						{
							m_Thief.SendLocalizedMessage( 1005592 ); // You cannot steal this sigil until it has been purified
						}
						else if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, 80.0, 80.0 ) )
						{
							if ( Sigil.ExistsOn( m_Thief ) )
							{
								m_Thief.SendLocalizedMessage( 1010258 ); //	The sigil has gone back to its home location because you already have a sigil.
							}
							else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, sig, false, true ) )
							{
								m_Thief.SendLocalizedMessage( 1010259 ); //	The sigil has gone home because your backpack is full
							}
							else
							{
								if ( sig.IsBeingCorrupted )
									sig.GraceStart = DateTime.Now; // begin grace period

								m_Thief.SendLocalizedMessage( 1010586 ); // YOU STOLE THE SIGIL!!!   (woah, calm down now)

								if ( sig.LastMonolith != null )
									sig.LastMonolith.Sigil = null;

								sig.LastStolen = DateTime.Now;

								return sig;
							}
						}
						else
						{
							m_Thief.SendLocalizedMessage( 1005594 ); //	You do not have enough skill to steal the sigil
						}
					}
					else
					{
						m_Thief.SendLocalizedMessage( 1005588 ); //	You must join a faction to do that
					}
				}
				#endregion
				else if ( si == null && ( toSteal.Parent == null || !toSteal.Movable ) )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( Core.AOS && si == null && toSteal is Container )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
				{
					m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
				}
				else if ( si != null && m_Thief.Skills[SkillName.Stealing].Value < 100.0 )
				{
					m_Thief.SendLocalizedMessage( 1060025, "", 0x66D ); // You're not skilled enough to attempt the theft of this item.
				}
				else if ( toSteal.Parent is Mobile )
				{
					m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
				}
				else if ( root == m_Thief )
				{
					m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
				}
				else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
				{
				}
				else if ( root is Corpse )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else
				{
					double w = toSteal.Weight + toSteal.TotalWeight;

					if ( w > 10 )
					{
						m_Thief.SendMessage( "That is too heavy to steal." );
					}
					else
					{
						if ( toSteal.Stackable && toSteal.Amount > 1 )
						{
							int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

							if ( maxAmount < 1 )
								maxAmount = 1;
							else if ( maxAmount > toSteal.Amount )
								maxAmount = toSteal.Amount;

							int amount = Utility.RandomMinMax( 1, maxAmount );

							if ( amount >= toSteal.Amount )
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
									stolen = toSteal;
							}
							else
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
								{
									stolen = Mobile.LiftItemDupe( toSteal, toSteal.Amount - amount );

									if ( stolen == null )
										stolen = toSteal;
								}
							}
						}
						else
						{
							int iw = (int)Math.Ceiling( w );
							iw *= 10;

							if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
								stolen = toSteal;
						}

						if ( stolen != null )
						{
							m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
							m_Thief.Criminal = true;
							m_Thief.Hidden = false;
							
							#region Exp Gain
							
							if ( !(toSteal is StealingTokenOne) || !(toSteal is StealingTokenTwo) || !(toSteal is StealingTokenThree) && ((PlayerMobile)m_Thief).Level >= 20  )
							{
								((PlayerMobile)m_Thief).Exp += 250;
								m_Thief.SendMessage(68, "You receive 250 experience for the successful steal.");
							}
							
							#endregion
							
							if ( si != null )
							{
								toSteal.Movable = true;
								si.Item = null;
							}
						}
						else
						{
							m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
							m_Thief.CriminalAction( true );
							m_Thief.Hidden = false;
						}

						caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
					}
				}

				return stolen;
			}
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-08-2008, 06:56 PM   #36 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

If there can be only one UmbarianStone in the world make IsThiefGuildMember and UmbarianRooster dictionary (or List or whatever it is) static. Though it's not good making guilds this way...
Soteric is offline   Reply With Quote
Old 08-09-2008, 03:42 AM   #37 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

-EDIT-

Okay, sorry for this noob question (what I tried just gave errors)

How do I make those static
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-09-2008, 03:46 AM   #38 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

Just add static modifier:
Code:
private bool MyMethod() // non-static method
{
}

private static bool AnotherMethod() // static method
{
}
Same with variables
Soteric is offline   Reply With Quote
Old 08-09-2008, 04:23 AM   #39 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

I I learn something new every day thanks to you guys
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-09-2008, 06:14 AM   #40 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Uhm, I want to add "Umbarian Shadows Guild" to the discription under the Players name.

so Using the GetProperties method in playermobile.cs I did this:

Code:
public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			ArrayList strings = new ArrayList( );
		
			strings.Add("Level: " + this.Level.ToString());
			
			if( UmbarianStone.IsThiefGuildMember( this ) )
			{
				strings.Add("Umbarian Shadows Guild");
			}
	
			
			if ( SicknessType != SickType.None )
			{
				strings.Add("Sick: " + this.SicknessType.ToString());
			}
			
			string toAdd = "";
			int amount = strings.Count;
			int current = 1;

			foreach( string str in strings )
			{
				toAdd += str;

				if( current != amount )
					toAdd += "\n";

				++current;
			}

			if( toAdd != "" )
				list.Add( 1070722, toAdd );
		}
Server compiles fine, and both the sickness, and level work, but not the Umbarian Shadows Guild.

Why isnt it working

regards
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-09-2008, 08:09 AM   #41 (permalink)
Forum Expert
 
Vorspire's Avatar
 
Join Date: Jan 2005
Location: Newcastle, United Kingdom
Age: 21
Posts: 2,298
Send a message via ICQ to Vorspire Send a message via MSN to Vorspire Send a message via Skype™ to Vorspire
Default

I think the problem will be in this
Code:
UmbarianStone.IsThiefGuildMember( this )
Can you post that mehod for us?
__________________

WWW.RPK-UO.COM - The WoW-UO Cross-Over Shard
Vorspire is offline   Reply With Quote
Old 08-11-2008, 12:29 PM   #42 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Sure thing:

here it is:


Code:
 public static bool IsThiefGuildMember( Mobile from ) 
		{
			return m_UmbarianRoster.ContainsKey( from );
		}
regards
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-13-2008, 03:23 PM   #43 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Hey guys, I still await a reply to this. Soz to nag but I wanna get this sytem sorted once and forall
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Old 08-13-2008, 03:34 PM   #44 (permalink)
Forum Novice
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 772
Send a message via ICQ to Soteric
Default

Do some research work. Find out what cause trouble: empty Dictionary, incorrect work of GetProperties() method or anything else. Add some Console.WriteLine method calls to your code and see what code sections don't work the way you want them

Didn't dig too deep into your code but it seems fine. Maybe kind of liitle bug anywhere but noone except you here is able to run this code and make any debug work

Last edited by Soteric; 08-13-2008 at 03:36 PM.
Soteric is offline   Reply With Quote
Old 08-13-2008, 04:03 PM   #45 (permalink)
Forum Novice
 
typhoonbot's Avatar
 
Join Date: Dec 2006
Posts: 480
Default

Thanks for the reply man
__________________
legendsofkaine.page.tl
typhoonbot is offline   Reply With Quote
Reply

Bookmarks

Tags
player


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