APPROVED: Powerscroll combine bag

LordGaav
Adept Scribe
Posts: 49
Joined: Fri Sep 12, 2008 4:09 pm

Re: APPROVED: Powerscroll combine bag

Post by LordGaav »

Finished improving the code. Now all that's left is a test on my own test server, and away we go.
LordGaav
Adept Scribe
Posts: 49
Joined: Fri Sep 12, 2008 4:09 pm

Re: APPROVED: Powerscroll combine bag

Post by LordGaav »

Cleaned up version, take a look.

Code: Select all

using System;
using System.Collections;
using Server.Multis;
using Server.Mobiles;
using Server.Network;

namespace Server.Items
{
    public class PowerscrollBag : BaseContainer
    {
        private Mobile speaker = null;

        #region default stuff
        public override int DefaultGumpID { get { return 0x3D; } }
        public override int DefaultDropSound { get { return 0x48; } }

        public override Rectangle2D Bounds
        {
            get { return new Rectangle2D(29, 34, 108, 94); }
        }

        [Constructable]
        public PowerscrollBag() : base(0xE76)
        {
            Weight = 2.0;
            Hue = 86;
        }

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

        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 override bool OnDragDropInto(Mobile from, Item item, Point3D p)
        {   
            // Check if this action passes BaseContainer's check
            if (!base.OnDragDropInto(from, item, p))
            {
                return false;
            }
            else
            {
                // Item is a PowerScroll
                if (item is PowerScroll)
                {
                    // Recast Item
                    PowerScroll scroll = (PowerScroll)item;
                    int power = (int) Math.Round(scroll.Value);
                    // If scroll value is withing normal values
                    if (power == 105 || power == 110 || power == 115)
                    {
                        // Start counting
                        this.speaker = from;
                        this.countPowerScrolls(scroll.Skill, scroll.Value);
                        this.speaker = null;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }                
            }
        }

        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            return this.OnDragDropInto(from, dropped, new Point3D());
        }

        /**
         * Count all PowerScrolls of a given type.
         */
        private void countPowerScrolls(SkillName skill, double power)
        {
            // Loop through all Items in this Bag
            int count = 0;
            foreach (Item i in this.Items)
            {
                // If this item is a PowerScroll
                if (i is PowerScroll)
                {
                    // Recast Item
                    PowerScroll scroll = (PowerScroll) i;
                    // If this PowerScroll is the same as the one that was dropped
                    if (scroll.Skill == skill && scroll.Value == power)
                    {
                        // Add one
                        count++;
                    }
                }
            }

            Console.WriteLine("Counted: " + count.ToString() + "x " + skill.ToString() + " scrolls (" + power.ToString() + ")");

            // Check if transformation threshold has been reached
            this.transformPowerScrolls(skill, power, count);
        }

        /**
         * Transforms lesser PowerScrolls into greater ones, if the threshold has been reached.
         * 
         * Transformation thresholds:
         * 105 -> 110 PS: 7x
         * 110 -> 115 PS: 7x
         * 115 -> 120 PS: 5x
         */
        private void transformPowerScrolls(SkillName skill, double power, int count)
        {
            // We don't care about doubles
            switch ((int)(Math.Round(power)))
            {
                case 105:
                    if (count >= 7)
                    {
                        this.speaker.PublicOverheadMessage(MessageType.System, 0x22, true, "Upgrading " + skill + " Power Scrolls with a power of " + power);
                        this.AddItem(new PowerScroll(skill, 110));
                        this.removePowerScrolls(skill, power);
                    }
                    break;
                case 110:
                    if (count >= 7)
                    {
                        this.speaker.PublicOverheadMessage(MessageType.System, 0x22, true, "Upgrading " + skill + " Power Scrolls with a power of " + power);
                        this.AddItem(new PowerScroll(skill, 115));
                        this.removePowerScrolls(skill, power);
                    }
                    break;
                case 115:
                    if (count >= 5)
                    {
                        this.speaker.PublicOverheadMessage(MessageType.System, 0x22, true, "Upgrading " + skill + " Power Scrolls with a power of " + power);
                        this.AddItem(new PowerScroll(skill, 120));
                        this.removePowerScrolls(skill, power);
                    }
                    break;
                default:
                    break;
            }
        }

        /**
         * Removes all PowerScrolls of a given type
         */
        private void removePowerScrolls(SkillName skill, double power)
        {
            for (int i = (this.Items.Count - 1); i >= 0; i--)
            {
                Item item = (Item)this.Items[i];
                if (item is PowerscrollBag)
                {
                    PowerScroll s = (PowerScroll)item;
                    if (s.Skill == skill && s.Value == power)
                    {
                        item.Delete();
                    }
                }
            }
        }
    }
}
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: APPROVED: Powerscroll combine bag

Post by +Colibri »

I will post my corrections tomorrow, but I have a feeling you didn't test this in action :wink: Last few lines, there's a "if item is PowerscrollBag" where it should be "if item is Powerscroll".
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
User avatar
Harabakc
Legendary Scribe
Posts: 467
Joined: Thu Jun 22, 2006 2:43 pm

Re: APPROVED: Powerscroll combine bag

Post by Harabakc »

Since I'm being kind of lazy, and I don't want to re-skim the whole thread to find the correct amount, I'm just going to say 10 in place of the actual number of 110s needed to make a 115 and 115s to make 120s.

Is this setup so that when you put 10 110s in it you get a random 115, or you put 10 of the same 110 to get a 115 of the same type? And same question with the 115s - 120s.
Lyandrin
Elder Scribe
Posts: 136
Joined: Mon Sep 08, 2008 3:40 am
Location: Stockholm, Sweden
Contact:

Re: APPROVED: Powerscroll combine bag

Post by Lyandrin »

Harabakc wrote:Since I'm being kind of lazy, and I don't want to re-skim the whole thread to find the correct amount, I'm just going to say 10 in place of the actual number of 110s needed to make a 115 and 115s to make 120s.

Is this setup so that when you put 10 110s in it you get a random 115, or you put 10 of the same 110 to get a 115 of the same type? And same question with the 115s - 120s.
Yeah thats a thought really, I'm interested in knowing this aswell :), what if you get your hands on 10 115 animal lore PSes for example, you combine them all and out comes 120 Camping PS. Such a thing would make me cry for real :(
LordGaav
Adept Scribe
Posts: 49
Joined: Fri Sep 12, 2008 4:09 pm

Re: APPROVED: Powerscroll combine bag

Post by LordGaav »

+Colibri wrote:I will post my corrections tomorrow, but I have a feeling you didn't test this in action :wink: Last few lines, there's a "if item is PowerscrollBag" where it should be "if item is Powerscroll".
True, I only changed that to use the "is xxx" syntax before posting, so a small typo here. I used the ItemID == 0x... before that.
Harabakc wrote:Since I'm being kind of lazy, and I don't want to re-skim the whole thread to find the correct amount, I'm just going to say 10 in place of the actual number of 110s needed to make a 115 and 115s to make 120s.

Is this setup so that when you put 10 110s in it you get a random 115, or you put 10 of the same 110 to get a 115 of the same type? And same question with the 115s - 120s.
... Once more, you put a x amount of powerscrolls in the bag. those scrolls need to be of the same skill and same power. you then get a powerscroll with the same skill, but upgraded power. so 10x 110 BS -> 1x 115 BS for example.
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: APPROVED: Powerscroll combine bag

Post by +Colibri »

Yea i was thinking it should be x10 too, but i think that's too hard. Even 7 is a big number. But you need 5 115 or 120s to upgrade, and yes it will be possible to get a 125 PS of any of the fighting skills (like the essences), meaning you can go up to 135 in these skills.
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
Lyandrin
Elder Scribe
Posts: 136
Joined: Mon Sep 08, 2008 3:40 am
Location: Stockholm, Sweden
Contact:

Re: APPROVED: Powerscroll combine bag

Post by Lyandrin »

omg! 135 parrying O.o
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: APPROVED: Powerscroll combine bag

Post by +Colibri »

Yep, but not 125 taming or 135 taming :)
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
Lyandrin
Elder Scribe
Posts: 136
Joined: Mon Sep 08, 2008 3:40 am
Location: Stockholm, Sweden
Contact:

Re: APPROVED: Powerscroll combine bag

Post by Lyandrin »

you wouldnt really need that high taming anyway :P

150 blacksmithing would be nice though :D

This sounds like a really good and fun thing to have though, is any decision made on how players can obtain the bag?
would it be a bag found in TC or would you need to craft it using powerscrolls and bod books or something?
User avatar
Harabakc
Legendary Scribe
Posts: 467
Joined: Thu Jun 22, 2006 2:43 pm

Re: APPROVED: Powerscroll combine bag

Post by Harabakc »

Personally, I would prefer it to be random results, and a non-specific input requirement.

If you make the input any type of 110s then the result has to be random. In fact, if you're going to go any input scrolls I think the requirement should be 12 for 110s and 10 for 115s. The random result would require a total of 22 scrolls to create a 120, which while there would might be more *total* 120s entering the economy there's no guarantee of what they would be. For the specific type requirements I think 7/5 would be better.

The reason being any chance of a random result has a *chance* of better scrolls, therefor higher requirement(even if it's less restrictive). But getting 7/5 of single type would indeed be a pain, even for me(specifically the 5 115s).

The 120+ scrolls would be interesting, I'm just not sure it's particularly necessary. Maybe as a result of having the any input/random result bag would be that you would need a separate bag to handle the 120+ scrolls, but I don't think that would be a problem. I care less about that part then I do just being to turn all these scrolls I've had for a couple years into something useful.
Llexa
Legendary Scribe
Posts: 294
Joined: Mon May 08, 2006 3:42 pm

Re: APPROVED: Powerscroll combine bag

Post by Llexa »

I would prefer it like what I think hara is saying b/c I don't have time to read it all right now :P

7 random 110's = (1) 115 of random skill

7 random 115's = (1) 120 of a random skill

5 random 120's = (1) 125 of random (within parameters) skill

The idea of having to have (7) 115 swords, and you simply get a 120 swords is a little too specific I think.

Could have a set rule though, that:

You can add (7) crafting random scrolls (of all 110's, all 115's...) and get (1) random crafting scroll (of the proper value)

You can add (7) non crafting random scrolls (of all 110's, all 115's...) and get (1) random non crafting scroll (of the proper value).

So, if one adds a crafting scroll to the bag, they cannot also add the other variety, and would just get some kind of warning message. (Also, obviously scrolls would be removable, until the exact amount has been placed and all would disappear.)

That way, you at least get a scroll in the broadly related category.



<3 Llexa
"We push and we push away,
For fear of facing our mistakes.
So we call it judgment,
And watch our friends, our world, ourselves... go comatose, inside."
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: APPROVED: Powerscroll combine bag

Post by +Colibri »

:( But we already have it scripted...

Anyway, here's the script with corrections:

Code: Select all

using System;
using System.Collections;
using Server.Multis;
using Server.Mobiles;
using Server.Network;

namespace Server.Items
{
	public class PowerScrollBag : BaseContainer
	{
		#region default stuff
		public override int DefaultGumpID { get { return 0x3D; } }
		public override int DefaultDropSound { get { return 0x48; } }

		public override Rectangle2D Bounds
		{
			get { return new Rectangle2D(29, 34, 108, 94); }
		}

		[Constructable]
		public PowerScrollBag() : base(0xE76)
		{
			Weight = 2.0;
			Hue = 86;
		}

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

		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 override bool OnDragDropInto(Mobile from, Item item, Point3D p)
		{   
			// Check if this action passes BaseContainer's check
			if ( !base.OnDragDropInto(from, item, p) )
				return false;
			
			// Recast Item
			PowerScroll scroll = (PowerScroll)item;
			if ( scroll == null )
				return false;
				
			int power = (int) Math.Round(scroll.Value);
			
			// If scroll value is withing normal values
			if ( !( power == 105 || power == 110 || power == 115 || power == 120 ) )
				return false;

			// Start counting
			this.countPowerScrolls( from, scroll.Skill, scroll.Value);
			return true;
		}

		public override bool OnDragDrop(Mobile from, Item dropped)
		{
			return this.OnDragDropInto(from, dropped, new Point3D());
		}

		/**
	* Count all PowerScrolls of a given type.
	*/
		private void countPowerScrolls( Mobile from, SkillName skill, double power )
		{
			// Loop through all Items in this Bag
			int count = 0;
			foreach (Item i in this.Items)
			{
				// If this item is a PowerScroll
				if (i is PowerScroll)
				{
					// Recast Item
					PowerScroll scroll = (PowerScroll) i;
					// If this PowerScroll is the same as the one that was dropped
					if (scroll.Skill == skill && scroll.Value == power)
					{
						// Add one
						count++;
					}
				}
			}

			//Console.WriteLine("Counted: " + count.ToString() + "x " + skill.ToString() + " scrolls (" + power.ToString() + ")");

			// Check if transformation threshold has been reached
			this.transformPowerScrolls( from, skill, power, count );
		}

		/**
	* Transforms lesser PowerScrolls into greater ones, if the threshold has been reached.
	*
	* Transformation thresholds:
	* 105 -> 110 PS: 7x
	* 110 -> 115 PS: 7x
	* 115 -> 120 PS: 5x
	* 120 -> 125 PS: 5x
	*/
		private void transformPowerScrolls( Mobile from, SkillName skill, double power, int count )
		{
			// We don't care about doubles
			switch ((int)(Math.Round(power)))
			{
				case 105:
					if (count >= 7)
					{
						from.SendMessage("Upgrading " + SkillInfo.Table[(int)skill].Name + " power scrolls with the power of " + power);
						this.DropItem(new PowerScroll(skill, 110));
						this.removePowerScrolls( from, skill, power, 7);
					}
				break;
				
				case 110:
					if (count >= 7)
					{
						from.SendMessage( "Upgrading " + SkillInfo.Table[(int)skill].Name + " power scrolls with the power of " + power);
						this.DropItem(new PowerScroll(skill, 115));
						this.removePowerScrolls( from, skill, power, 7);
					}
				break;
				
				case 115:
					if (count >= 5)
					{
						from.SendMessage( "Upgrading " + SkillInfo.Table[(int)skill].Name + " power scrolls with the power of " + power);
						this.DropItem(new PowerScroll(skill, 120));
						this.removePowerScrolls( from, skill, power, 5);
					}
				break;
					
				case 120:
					if (count >= 5)
					{
						from.SendMessage("Upgrading " + SkillInfo.Table[(int)skill].Name + " power scrolls with the power of " + power);
						this.DropItem(new PowerScroll(skill, 125));
						this.removePowerScrolls( from, skill, power, 5);
					}
				break;	
				
				default:
				break;
			}
		}

		/**
		* Removes all PowerScrolls of a given type
		*/
		private void removePowerScrolls( Mobile from, SkillName skill, double power, int number)
		{
			int count = 0;
			
			for (int i = (this.Items.Count - 1); i >= 0; i--)
            {
                Item item = (Item)this.Items[i];
				if ( !( item is PowerScroll ) )
					continue;
					
				PowerScroll scroll = (PowerScroll)item;
				if (scroll.Skill == skill && scroll.Value == power && count < number )
				{
					count++;
					item.Delete();
				}
			}
			
			
			Effects.SendLocationParticles( EffectItem.Create( from.Location, from.Map, EffectItem.DefaultDuration ), 0, 0, 0, 0, 0, 5060, 0 );
			Effects.PlaySound( from.Location, from.Map, 0x243 );

			Effects.SendMovingParticles( new Entity( Serial.Zero, new Point3D( from.X - 6, from.Y - 6, from.Z + 15 ), from.Map ), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );
			Effects.SendMovingParticles( new Entity( Serial.Zero, new Point3D( from.X - 4, from.Y - 6, from.Z + 15 ), from.Map ), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );
			Effects.SendMovingParticles( new Entity( Serial.Zero, new Point3D( from.X - 6, from.Y - 4, from.Z + 15 ), from.Map ), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );

			Effects.SendTargetParticles( from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100 );

		}
	
		public void Say( string args ) 
		{ 
			PublicOverheadMessage( MessageType.Regular, 0x3B2, false, args ); 
		} 	

	}

}
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
User avatar
Harabakc
Legendary Scribe
Posts: 467
Joined: Thu Jun 22, 2006 2:43 pm

Re: APPROVED: Powerscroll combine bag

Post by Harabakc »

Well the reason for my post was to figure out how it's currently working. If I looked at the code long enough I could probably figure out how it's setup but I won't pretend to be a scripting expert, so I just posted. Plus I figured it would be better to post now then after it's already on server.
User avatar
+Colibri
Administrator
Posts: 3958
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: APPROVED: Powerscroll combine bag

Post by +Colibri »

Well i'll keep this one open... erm... well i'd still make it that if you put all same skill in there it gives you that same skill, so if you want a random one you'd have to put in at least one different powerscroll of same value.

The code needs to be pretty much rewritten. If anyone wants to do it then great, if not then i'll get around to it sooner or later.
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
Locked