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!

The original Shrink System & Everything related

ASayre

RunUO Developer
Original Shrink System & Everything related 3/16

Summary:
The original Shrink system, with Shrink Potions, hitching posts, [shrink and more. Added suport for latest beta features like Pet Bonding, with more customization.

Description:
I can't guarantee anythign will work, didn't test all the updated changes so post bugs and stuff.

Also interface for other scripts to use the Shrink system, look at the script for it.

Please report any bugs, etc, etc.

IF YOU HAVE A PROBLEM WITH A PET LOST FOREVER

It means, you're using an old version of Morexton's MEga Spawner, or the Shrink system. Or, it means that it was shrunken when the above weren't updated.


3/16 I believe finally fixed pet loss bug.. This won't fix old pets, but any new pets SHOULD work as intended. Please report any new bugs. Sorry for that bug lasting and not being caught.

Installation:
Just put in script folder, and Volia. GM's can [shrink and players can use shrink potions or hitching Posts.
 

Attachments

  • Shrink V 2.3.zip
    5.1 KB · Views: 3,326

ditmar

Wanderer
Ok I will be testing this, I am getting sick of the pets shrunk forever bug which has to do with bonded pets that are shrunk i think. Another important thing is will it also save the stats of trained pets ? Bonded or tamed.
 

ditmar

Wanderer
Okay,

The firtst problem already started after not even starting to use the script. It wants me to wipe all ShrinkItems from the shard. As i will get a lot of angry players that will want to kill me, I will not do that. Let me post the script i currently use(its a pretty old one) :

HitchingPost.cs
Code:
using System; 
using Server; 
using Server.Targeting; 

namespace Server.Items 
{ 
   [Flipable( 0x14E8, 0x14E7 )] 
   public class HitchingPost : AddonComponent 
   { 
      #region Constructors 
      [Constructable] 
      public HitchingPost() : this( 0x14E7 ) 
      { 
      } 

      [Constructable] 
      public HitchingPost( int itemID ) : base( itemID ) 
      { 
      } 
       
      public HitchingPost( Serial serial ) : base( serial ) 
      { 
      } 
      #endregion 

      public override void OnDoubleClick( Mobile from ) 
      { 
         if( from.InRange( this.GetWorldLocation(), 2 ) == false ) 
         { 
            from.SendLocalizedMessage( 500486 );   //That is too far away. 
         } 
         else 
         { 
            from.Target=new HitchingPostTarget( this ); 
            from.SendMessage( "What do you wish to shrink?" ); 
         } 
      } 

      private class HitchingPostTarget : Target 
      { 
         private HitchingPost m_Post; 

         public HitchingPostTarget( Item i ) : base( 3, false, TargetFlags.None ) 
         { 
            m_Post=(HitchingPost)i; 
         } 
          
         protected override void OnTarget( Mobile from, object targ ) 
         { 
            if ( !(m_Post.Deleted) ) 
            { 
               ShrinkFunctions.Shrink( from, targ ); 
            } 

            return; 
         } 
      } 
        

      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 


   public class HitchingPostEastAddon : BaseAddon 
   { 
      public override BaseAddonDeed Deed{ get{ return new HitchingPostEastDeed(); } } 

      [Constructable] 
      public HitchingPostEastAddon() 
      { 
         AddComponent( new HitchingPost( 0x14E7 ), 0, 0, 0); 
      } 

      public HitchingPostEastAddon( Serial serial ) : base( serial ) 
      { 
      } 

      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 

   public class HitchingPostEastDeed : BaseAddonDeed 
   { 
      public override BaseAddon Addon{ get{ return new HitchingPostEastAddon(); } } 

      [Constructable] 
      public HitchingPostEastDeed() 
      { 
         Name="Hitching Post (east)"; 
      } 

      public HitchingPostEastDeed( Serial serial ) : base( serial ) 
      { 
      } 

      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 

    
   public class HitchingPostSouthAddon : BaseAddon 
   { 
      public override BaseAddonDeed Deed{ get{ return new HitchingPostSouthDeed(); } } 

      [Constructable] 
      public HitchingPostSouthAddon() 
      { 
         AddComponent( new HitchingPost( 0x14E8 ), 0, 0, 0); 
      } 

      public HitchingPostSouthAddon( Serial serial ) : base( serial ) 
      { 
      } 

      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 

   public class HitchingPostSouthDeed : BaseAddonDeed 
   { 
      public override BaseAddon Addon{ get{ return new HitchingPostSouthAddon(); } } 

      [Constructable] 
      public HitchingPostSouthDeed() 
      { 
         Name="Hitching Post (south)"; 
      } 

      public HitchingPostSouthDeed( Serial serial ) : base( serial ) 
      { 
      } 

      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 

}

Shrink.cs
Code:
using System; 
using Server; 
using Server.Items; 
using Server.Mobiles; 

namespace Server 
{ 
   public class ShrinkFunctions 
   { 
      public static bool Shrink( Mobile from, object targ, bool restricted ) 
      { 
         String errorString = null; 
         int errorLocalizedMessage = 0; 
         if ( from == targ ) 
            errorString = "You can't shrink yourself!"; 
         else if ( !(targ is BaseCreature) ) 
            errorString = "You can't shrink that!"; 
         else 
         { 
            BaseCreature t=(BaseCreature)targ; 

            #region Shrink Restrictions 
            if ( !restricted ) 
            { 
               //Don't check anything if not a restricted Shrink 
            } 
            else if( t.Summoned ) 
            { 
               errorString = "You cannot shrink summoned creatures."; 
            } 
            else if ( t.Combatant != null && t.InRange( t.Combatant, 12 ) && t.Map == t.Combatant.Map ) 
            { 
               errorString = "You cannot shrink your pet while it is in combat."; 
            } 
            else if (!(t.Controled && t.ControlMaster==from)) 
            { 
               errorLocalizedMessage = 1042562;   //That is not your pet! 
               errorString = "That is not your pet!"; 
            } 
            else if ( (t is PackLlama || t is PackHorse || t is Beetle) && (t.Backpack != null && t.Backpack.Items.Count > 0) ) 
            { 
               errorLocalizedMessage = 1042563; //Unload the pet first 
               errorString = "Unload the pet first"; 
            } 
            #endregion 

            ShrinkItem shrunkenPet = new ShrinkItem( t ); 

            if ( (errorString==null) && ( errorLocalizedMessage == 0 ) ) 
            { 
               //If no errors, proceed. 
             
               if ( from != null ) 
               { 
                  from.SendMessage( "You shrink the pet" ); 
                  if ( !from.AddToBackpack ( shrunkenPet ) ) 
                  { 
                     shrunkenPet.MoveToWorld( new Point3D( from.X, from.Y, from.Z ), from.Map ); 
                     from.SendMessage( "Your backpack is full so the shrunken pet falls to the ground" ); 
                  } 
               } 
               else 
               { 
                  shrunkenPet.MoveToWorld( new Point3D( t.X, t.Y, t.Z ), t.Map );  // place shrunken pet at current location 
               } 

               t.Controled = true;   //To make it so It won't still be a part of a spawner. 
                
               SendAway( t ); 

               return true; 

            } 
         } 

         if( from != null ) //if From is NOT null, send error Message. 
         { 
             
            if ( errorLocalizedMessage != 0 ) 
            { 
               from.SendLocalizedMessage( errorLocalizedMessage ); 
            } 
            else 
            { 
               from.SendMessage( errorString ); 
            } 
         } 
         return false; 

      } 

      public static bool Shrink( Mobile from, object targ ) 
      {    
         return Shrink( from, targ, true ); 
      } 

      public static bool Shrink( object targ ) 
      { 
         return Shrink( null, targ, false ); 
      } 

      private static void SendAway( BaseCreature b ) 
      { 
         b.SetControlMaster( null ); 
         b.SummonMaster = null; 
         b.Internalize(); 
         b.Controled = true;   //T' make it so It won't still be associated with a spawner.  Only relevent with Unrestricted shrink 
      } 
   } 
}

ShrinkCmd.cs
Code:
using System; 
using System.Reflection; 
using Server.Items; 
using Server.Targeting; 
using Server.Mobiles; 
using System.Collections; 

namespace Server.Scripts.Commands 
{ 
   public class ShrinkCmd 
   { 
      public static void Initialize() 
      { 
         Server.Commands.Register( "Shrink", AccessLevel.GameMaster, new CommandEventHandler( Shrink_OnCommand ) ); 
      }    
      
      [Usage( "Shrink" )] 
      [Description( "Shrinks a targeted Mobile" )] 

      public static void Shrink_OnCommand( CommandEventArgs e ) 
      { 
         e.Mobile.Target = new ShrinkCmdTarget(); 
         e.Mobile.SendMessage( "What do you wish to shrink?" ); 
      }    


      private class ShrinkCmdTarget : Target 
      { 
         public ShrinkCmdTarget() : base( 15, false, TargetFlags.None ) 
         { 
         } 

         protected override void OnTarget( Mobile from, object targ ) 
         { 
            ShrinkFunctions.Shrink( from, targ, false ); 
         } 
      } 
   } 
}

ShrinkItem.cs
Code:
using System; 
using Server.Items; 
using Server.Mobiles; 

namespace Server.Items 
{ 
	public class ShrinkItem : Item 
	{ 
		private BaseCreature m_link; 
		private bool m_toDeletePet; 

		public ShrinkItem( Serial serial ) : base( serial ) 
		{
		}

		public ShrinkItem( BaseCreature c ) 
		{ 
			m_link=c; 
			if ( !(c.Body==400 || c.Body==401) ) 
				Hue=c.Hue; 

			Name = c.Name + " [shrunk]"; 
			ItemID = ShrinkTable.Lookup( c );
		} 

		public override void OnDoubleClick( Mobile from ) 
		{ 
			if ( m_link == null || m_link.Deleted ) 
				return; 

			if ( !Movable ) 
				return; 

			if( from.InRange( this.GetWorldLocation(), 2 ) == false ) 
			{ 
				from.SendLocalizedMessage( 500486 );   //That is too far away. 
				return; 
			} 
			else if( !from.CheckAlive() ) 
			{ 
				from.SendLocalizedMessage( 1060190 );   //You cannot do that while dead! 
			} 
			else if ( from.Followers + m_link.ControlSlots > from.FollowersMax ) 
			{ 
				from.SendMessage( "You have too many followers to unshrink that creature." ); 
				return; 
			} 
			else 
			{ 
				bool alreadyOwned = m_link.Owners.Contains( from ); 
				if (!alreadyOwned)
				{
					m_link.Owners.Add( from );
					m_link.IsBonded = false;
				}

				m_link.SetControlMaster( from ); 

				m_link.Location=from.Location; 
				m_link.Map=from.Map; 

				m_link.ControlTarget = from; 
				m_link.ControlOrder = OrderType.Follow; 

				m_link = null;
				Consume(); 
			} 
		} 

		public override void OnAfterDelete() 
		{ 
			if ( m_link != null )
				m_link.Delete();
		} 

		public override void Serialize( GenericWriter writer ) 
		{ 
			base.Serialize( writer ); 

			writer.Write( (int) 0 ); // version 

			writer.Write( m_link ); 
		} 

		public override void Deserialize( GenericReader reader ) 
		{ 
			base.Deserialize( reader ); 

			int version = reader.ReadInt(); 

			switch ( version ) 
			{ 
				case 0: 
				{ 
					m_link = (BaseCreature)reader.ReadMobile(); 

					break; 
				} 
			} 
		} 
	} 
}

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

namespace Server.Items 
{ 
   public class ShrinkPotion : Item 
   { 

      #region Constructors 
      public ShrinkPotion( Serial serial ) : base( serial ) 
      { 
      } 
      [Constructable] 
      public ShrinkPotion() : base( 0xF0C ) 
      { 
        Hue=1152; 
	Name="a Shrink potion"; 
      } 
      #endregion 

      public override void OnDoubleClick( Mobile from ) 
      { 
         if ( !Movable ) 
            return; 
         else if( from.InRange( this.GetWorldLocation(), 2 ) == false ) 
         { 
            from.SendLocalizedMessage( 500486 );   //That is too far away. 
            return; 
         } 

         Container pack = from.Backpack; 

         if ( !(Parent == from || ( pack != null && Parent == pack )) ) //If not in pack. 
         { 
            from.SendLocalizedMessage( 1042001 );   //That must be in your pack to use it. 
            return; 
         } 
         from.Target=new ShrinkPotionTarget( this ); 
         from.SendMessage( "What do you wish to shrink?" ); 
      } 


      private class ShrinkPotionTarget : Target 
      { 
         private ShrinkPotion m_Potion; 

         public ShrinkPotionTarget( Item i ) : base( 3, false, TargetFlags.None ) 
         { 
            m_Potion=(ShrinkPotion)i; 
         } 
          
         protected override void OnTarget( Mobile from, object targ ) 
         { 
            if ( !(m_Potion.Deleted) ) 
            { 
               if ( ShrinkFunctions.Shrink( from, targ ) ) 
               { 
                  m_Potion.Delete(); 
               } 
            } 

            return; 
         } 
      } 


      #region Serialization 
      public override void Serialize( GenericWriter writer ) 
      { 
         base.Serialize( writer ); 

         writer.Write( (int) 0 ); // version 
      } 

      public override void Deserialize( GenericReader reader ) 
      { 
         base.Deserialize( reader ); 

         int version = reader.ReadInt(); 
      } 
      #endregion 
   } 
}

I hope you can help me do something so i can use your script but do not have to wipe all the current shrunk pets.

Thanks in advance.
 

ASayre

RunUO Developer
Errr... Well, your problem deosnt' seem to stem from my script directly... It looks like you modified it or something... Your serialization functions aren't the same as my copy of the old ones... And don''t tell me I jsut updated it and forgot cause the backup file hasn't changed since 8 months ago ;-)

But if you need help getting it to work for your modifications... PM me and I'll help yas.
 

Asmodaeus

Wanderer
Philantrop said:
The old one had frequent "Your pet is lost forever." problems on my shard. Has that been fixed?

This is a very serious issue on my shard as well. I have tried pet summoning balls, and they just plain suck in one form or fashion. Shrink pots OWN, and my players LOVE them.
Philantrop is stating a very serious problem. I have done my best to find it myself, by checking out the BaseCreature.cs and the actual shrink scripts themselves.
There is a line in the ShrinkItem.cs that has the line "Your pet is lost forever" and the author put that in there as a default incase something goes "wrong". My guess is that if the player loses the link between thier shrunken pet and themselves, for whatever reason (maybe when the pet is sent to "limbo" while it is shrunk) it gives you that responce.
The only way I see to get rid of the problem, is to make it so that your pet doesn't have any kind of loyalty at all, just existant. I took out the "Your pet is lost forever" section completely, but I fear that when the link is broken between the two (player and pet) and they try to unshrink it, the server will just crash instead of giving that responce.

Plz find a way to fix this! These scripts play a very important role on my shard! Thanks in advance!

P.S> Forgot to mention: When the "pet is lost forever" and thrown away (deleted) it crashes the server. (just in case it hasn't been stated yet)
 

ASayre

RunUO Developer
Then post a crash log.

The pet is lost forever bug happened back when there was a bug that also affected the RunUO distro with spawned animals, & taming them & shrinking before they were removed from the spawner. Pets still form then were lost , this was a fail safe. If it happens NOW on new shrunk stuff, please post steps to reproduce it.

Edit: I see what you mean 'bout when it's thrown away.. I'll fix it. but a crashlog would still help
 

ASayre

RunUO Developer
Okays, I think I located the problem, big error on my part, I had the line that created the Shrink potion create it before it checked for errors. Since it was created, when THAT item got deleted whichc noone had, it deleted the pet also, thus causing the real shrink item that a player had after making it sucessful to have the link become null. This didn't show up in testing cause I didn't test on rela shard and it'd take mroe than one time of shrinking it and a subsequent deletion of that item that Didn't happen right away.

The change int eh script, (one line) won't fix other ones unfournately, but, IT'll prevent it from happening again.
 

02moorem

Wanderer
undefined


ok i need some help how do i get i scrpits to work on my shard im not shore wich folder to put them in item or ...... ? :confused:
 

Asmodaeus

Wanderer
ASayre8 said:
Okays, I think I located the problem, big error on my part, I had the line that created the Shrink potion create it before it checked for errors. Since it was created, when THAT item got deleted whichc noone had, it deleted the pet also, thus causing the real shrink item that a player had after making it sucessful to have the link become null. This didn't show up in testing cause I didn't test on rela shard and it'd take mroe than one time of shrinking it and a subsequent deletion of that item that Didn't happen right away.

The change int eh script, (one line) won't fix other ones unfournately, but, IT'll prevent it from happening again.

Thank you soo much! Has the .zip been updated?
 

ASayre

RunUO Developer
Oops, sorry for not responding, yup, I updated the zip and stuff. Glad it's working for you! :)
 

Chandral

Wanderer
Hi there. I thought I'd let you know that the "your pet is lost forever" thing is still out there. I had a player last night page me about it. She had a dragon she had shrunk ealrier yesterday and when she tried to unshrink it she got the imfamous message of it being lost forever. I ended up having to delete the dragon and give her a new one.

Just thought you should know. I hope I dont start getting alot of pages on this as I love the shrink script and would hate to have to delete it.
 

ASayre

RunUO Developer
Okays, the problems with everything has been discovered...

Morexton & I isolated the problem to a single line of code in his MegaSpawner system whicch wuold delete pets which were on teh Internal Map. Since that's where Shrunken pets go, It'd delete the pets and leave the item still there in the world.

Morexton's Next version of his mega spawner SHOULD fix these bugs once and for all. Although current shrinkItems where the pet has already ben deleted CANNOT be fixed, all Newly shrunken stuff should work. (won't also fix ones deleted pets from the other bbug fixed a month ago, but you shoudl've updated by now =P)
 

ASayre

RunUO Developer
Toxxx said:
Do you know a way to dupe the item-shrink?

No, it won't work because if you dupe it, you would have to dupe the mobile along with the item. and you can't dupe mobiles ;-)
 
H

hudel

Guest
congratulations

Hello, nice script. In my first test-session it worked fine for me. Thanks for sharinh it.
I have one question: when I disable the hitchig post in the distibution, what will be then? Is this the hitching post for doom?
 
Top