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!

Skill Ball - Final

Kamron

Knight
Its not a matter if the file is bigger or not... the fact is that once you add these different flavors of skillball to the one singular item, it (maybe not noticable on a small shard) uses alot of resources.

Yes I can also add a skill floor/ceiling for skillballs. This would include single skill being selected to raise, as well as skill total, or in percent based on skill cap (to have it only work with newbies).
 

Heftiger

Wanderer
Yes, I think if you just implemented a cieling that could be editied within the script, it would allow me, and probably many others, to do what they wanted with your system.
 

Heftiger

Wanderer
This is the script I have set up right, now. How could I set a cap of 80 (IE: When using a skillball a skill will never go over 80)

Code:
//	RunUO script: Skill Ball
//	Copyright (c) 2003 by Wulf C. Krueger <[email protected]>
//
//	This script is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; version 2 of the License applies.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	Please do NOT remove or change this header.

//	Official Defiance(c) skillball - by [Dev]Kamron aka XxSP1DERxX - [email][email protected][/email]

//	"Shr"edited by NoIdeaNoClue to fully take advantage of the powerscroll/cap system. Renamed to
//	SkillBall10 for the +10 bonus (edit the bonus to whatever you like). All leftover skill points
//	from this ball, will be gone (only goes to the players cap).

using System;
using Server.Network;
using Server.Items;
using Server.Gumps;
using System.Collections;

namespace Server.Items
{
	public class SkillBall10 : Item
	{
		private int m_SkillBonus = 10;
		private string m_BaseName = "a skill ball +";
		public bool GumpOpen = false;

		[CommandProperty( AccessLevel.GameMaster )] 
		public int SkillBonus
		{
			get { return m_SkillBonus; }
			set 
			{ 
				m_SkillBonus = value;

				this.Name = m_BaseName + Convert.ToString(m_SkillBonus); 
			}
		}

		[Constructable]
		public SkillBall10( int SkillBonus ) : base( 6249 )
		{
			m_SkillBonus = SkillBonus;
			Name = m_BaseName + Convert.ToString(SkillBonus); 
		}

		[Constructable]
		public SkillBall10() : base( 6249 )
		{
			Name = m_BaseName + Convert.ToString(SkillBonus); 
		}

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

		public override void OnDoubleClick( Mobile from )
		{
			if ( (this.SkillBonus == 0) && (from.AccessLevel < AccessLevel.GameMaster) ) 
			{
				from.SendMessage("This skill ball isn't charged. Please page for a GM.");
				return;
			}
			else if ( (from.AccessLevel >= AccessLevel.GameMaster) && (this.SkillBonus == 0) ) 
			{
				from.SendGump( new PropertiesGump( from, this ) );
				return;
			}

			if ( !IsChildOf( from.Backpack ) ) 
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			else if (!GumpOpen) 
			{
				GumpOpen = true;
				from.SendGump( new SkillBallGump10( from, this ) );
			}
			else if (GumpOpen)
				from.SendMessage("You're already using the ball.");
		}

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

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

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

			int version = reader.ReadInt();

			switch (version) 
			{
				case 0 : 
				{
					m_SkillBonus = reader.ReadInt();
					break;
				}
			}
		}
	}
}

namespace Server.Gumps
{
	public class SkillBallGump10 : Gump
	{
		private const int FieldsPerPage = 14;

		private Skill m_Skill;
		private SkillBall10 m_skb;

		public SkillBallGump10 ( Mobile from, SkillBall10 skb ) : base ( 20, 30 )
		{
			m_skb = skb;
			
			AddPage ( 0 );
			AddBackground( 0, 0, 260, 351, 5054 );
			
			AddImageTiled( 10, 10, 240, 23, 0x52 );
			AddImageTiled( 11, 11, 238, 21, 0xBBC );
			
			AddLabel( 65, 11, 0, "Skills you can raise" );
			
			AddPage( 1 );
			
			int page = 1;
			int index = 0;
			
			Skills skills = from.Skills;
			
			int number;
			if ( Core.AOS )
				number = 0;
			else
				number = 3;
			
			for ( int i = 0; i < ( skills.Length - number ); ++i ) 
			{
				if ( index >= FieldsPerPage ) 
				{
					AddButton( 231, 13, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page + 1 );
					 
					++page;
					index = 0;
					 
					AddPage( page );
					 
					AddButton( 213, 13, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page - 1 );
				}
			  
				Skill skill = skills[i];
			  
				if ( skill.Base < skill.Cap )				
				{	 
					AddImageTiled( 10, 32 + (index * 22), 240, 23, 0x52 );
					AddImageTiled( 11, 33 + (index * 22), 238, 21, 0xBBC );
					 
					AddLabelCropped( 13, 33 + (index * 22), 150, 21, 0, skill.Name );
					AddImageTiled( 180, 34 + (index * 22), 50, 19, 0x52 );
					AddImageTiled( 181, 35 + (index * 22), 48, 17, 0xBBC );
					AddLabelCropped( 182, 35 + (index * 22), 234, 21, 0, skill.Base.ToString( "F1" ) );
					 
					if ( from.AccessLevel >= AccessLevel.Player )
						AddButton( 231, 35 + (index * 22), 0x15E1, 0x15E5, i + 1, GumpButtonType.Reply, 0 );
					else
						AddImage( 231, 35 + (index * 22), 0x2622 );
					 
					++index;
				}
			}
		}
	  
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			
			if ( (from == null) || (m_skb.Deleted) )
				return;

			m_skb.GumpOpen = false;

			if ( info.ButtonID > 0 ) 
			{
				m_Skill = from.Skills[(info.ButtonID-1)];
			  
				if ( m_Skill == null )
					return;
			
				double count = from.Skills.Total / 10;
				double cap = from.SkillsCap / 10;
				ArrayList decreased = new ArrayList();
				double decreaseamount = 0.0;
				double bonuscopy = m_skb.SkillBonus;
				if ( (count + bonuscopy) > cap ) 
				{
					for (int i = 0;i < from.Skills.Length;i++ )
					{
						if (from.Skills[i].Lock == SkillLock.Down)
						{
							decreased.Add(from.Skills[i]);
							decreaseamount += from.Skills[i].Base;
							break;
						}
					}
					if (decreased.Count == 0)
					{
						from.SendMessage("You have exceeded the skill cap and do not have any skills set to be decreased.");
						return;
					}
				}
				if (m_Skill.Base + bonuscopy > m_Skill.Cap) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");
				}
				

				else if (m_Skill.Base + bonuscopy <= m_Skill.Cap) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base += bonuscopy;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base += bonuscopy;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");

				}
				else 
					from.SendMessage("You have to choose another skill.");
			}
		}
	}
}
 

NoIdeaNoClue

Wanderer
Heftiger said:
This is the script I have set up right, now. How could I set a cap of 80 (IE: When using a skillball a skill will never go over 80)

Code:
//	RunUO script: Skill Ball
//	Copyright (c) 2003 by Wulf C. Krueger <[email protected]>
//
//	This script is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; version 2 of the License applies.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	Please do NOT remove or change this header.

//	Official Defiance(c) skillball - by [Dev]Kamron aka XxSP1DERxX - [email][email protected][/email]

//	"Shr"edited by NoIdeaNoClue to fully take advantage of the powerscroll/cap system. Renamed to
//	SkillBall10 for the +10 bonus (edit the bonus to whatever you like). All leftover skill points
//	from this ball, will be gone (only goes to the players cap).

using System;
using Server.Network;
using Server.Items;
using Server.Gumps;
using System.Collections;

namespace Server.Items
{
	public class SkillBall10 : Item
	{
		private int m_SkillBonus = 10;
		private string m_BaseName = "a skill ball +";
		public bool GumpOpen = false;

		[CommandProperty( AccessLevel.GameMaster )] 
		public int SkillBonus
		{
			get { return m_SkillBonus; }
			set 
			{ 
				m_SkillBonus = value;

				this.Name = m_BaseName + Convert.ToString(m_SkillBonus); 
			}
		}

		[Constructable]
		public SkillBall10( int SkillBonus ) : base( 6249 )
		{
			m_SkillBonus = SkillBonus;
			Name = m_BaseName + Convert.ToString(SkillBonus); 
		}

		[Constructable]
		public SkillBall10() : base( 6249 )
		{
			Name = m_BaseName + Convert.ToString(SkillBonus); 
		}

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

		public override void OnDoubleClick( Mobile from )
		{
			if ( (this.SkillBonus == 0) && (from.AccessLevel < AccessLevel.GameMaster) ) 
			{
				from.SendMessage("This skill ball isn't charged. Please page for a GM.");
				return;
			}
			else if ( (from.AccessLevel >= AccessLevel.GameMaster) && (this.SkillBonus == 0) ) 
			{
				from.SendGump( new PropertiesGump( from, this ) );
				return;
			}

			if ( !IsChildOf( from.Backpack ) ) 
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			else if (!GumpOpen) 
			{
				GumpOpen = true;
				from.SendGump( new SkillBallGump10( from, this ) );
			}
			else if (GumpOpen)
				from.SendMessage("You're already using the ball.");
		}

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

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

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

			int version = reader.ReadInt();

			switch (version) 
			{
				case 0 : 
				{
					m_SkillBonus = reader.ReadInt();
					break;
				}
			}
		}
	}
}

namespace Server.Gumps
{
	public class SkillBallGump10 : Gump
	{
		private const int FieldsPerPage = 14;

		private Skill m_Skill;
		private SkillBall10 m_skb;

		public SkillBallGump10 ( Mobile from, SkillBall10 skb ) : base ( 20, 30 )
		{
			m_skb = skb;
			
			AddPage ( 0 );
			AddBackground( 0, 0, 260, 351, 5054 );
			
			AddImageTiled( 10, 10, 240, 23, 0x52 );
			AddImageTiled( 11, 11, 238, 21, 0xBBC );
			
			AddLabel( 65, 11, 0, "Skills you can raise" );
			
			AddPage( 1 );
			
			int page = 1;
			int index = 0;
			
			Skills skills = from.Skills;
			
			int number;
			if ( Core.AOS )
				number = 0;
			else
				number = 3;
			
			for ( int i = 0; i < ( skills.Length - number ); ++i ) 
			{
				if ( index >= FieldsPerPage ) 
				{
					AddButton( 231, 13, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page + 1 );
					 
					++page;
					index = 0;
					 
					AddPage( page );
					 
					AddButton( 213, 13, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page - 1 );
				}
			  
				Skill skill = skills[i];
			  
				if ( skill.Base < skill.Cap )				
				{	 
					AddImageTiled( 10, 32 + (index * 22), 240, 23, 0x52 );
					AddImageTiled( 11, 33 + (index * 22), 238, 21, 0xBBC );
					 
					AddLabelCropped( 13, 33 + (index * 22), 150, 21, 0, skill.Name );
					AddImageTiled( 180, 34 + (index * 22), 50, 19, 0x52 );
					AddImageTiled( 181, 35 + (index * 22), 48, 17, 0xBBC );
					AddLabelCropped( 182, 35 + (index * 22), 234, 21, 0, skill.Base.ToString( "F1" ) );
					 
					if ( from.AccessLevel >= AccessLevel.Player )
						AddButton( 231, 35 + (index * 22), 0x15E1, 0x15E5, i + 1, GumpButtonType.Reply, 0 );
					else
						AddImage( 231, 35 + (index * 22), 0x2622 );
					 
					++index;
				}
			}
		}
	  
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			
			if ( (from == null) || (m_skb.Deleted) )
				return;

			m_skb.GumpOpen = false;

			if ( info.ButtonID > 0 ) 
			{
				m_Skill = from.Skills[(info.ButtonID-1)];
			  
				if ( m_Skill == null )
					return;
			
				double count = from.Skills.Total / 10;
				double cap = from.SkillsCap / 10;
				ArrayList decreased = new ArrayList();
				double decreaseamount = 0.0;
				double bonuscopy = m_skb.SkillBonus;
				if ( (count + bonuscopy) > cap ) 
				{
					for (int i = 0;i < from.Skills.Length;i++ )
					{
						if (from.Skills[i].Lock == SkillLock.Down)
						{
							decreased.Add(from.Skills[i]);
							decreaseamount += from.Skills[i].Base;
							break;
						}
					}
					if (decreased.Count == 0)
					{
						from.SendMessage("You have exceeded the skill cap and do not have any skills set to be decreased.");
						return;
					}
				}
				if (m_Skill.Base + bonuscopy > m_Skill.Cap) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");
				}
				

				else if (m_Skill.Base + bonuscopy <= m_Skill.Cap) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base += bonuscopy;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base += bonuscopy;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");

				}
				else 
					from.SendMessage("You have to choose another skill.");
			}
		}
	}
}

*******************************************
Change:
Code:
private int m_SkillBonus = 10;
To:
Code:
private int m_SkillBonus = 80;

Then change:
Code:
if ( skill.Base < skill.Cap )
To:
Code:
if ( skill.Base < 80 )

Then change:
Code:
if (m_Skill.Base + bonuscopy > m_Skill.Cap) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base = m_Skill.Cap;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");
				}
To:
Code:
if (m_Skill.Base + bonuscopy > 80) 
				{
					if ((cap - count) + decreaseamount >= bonuscopy)
					{
						if (cap - count >= bonuscopy)
						{
							m_Skill.Base = 80.0;
							bonuscopy = 0;	
						}
						else
						{
							m_Skill.Base = 80.0;
							bonuscopy -= cap - count;

							foreach( Skill s in decreased)
							{
								if (s.Base >= bonuscopy)
								{
									s.Base -= bonuscopy;
									bonuscopy = 0;
								}
								else
								{
									bonuscopy -= s.Base;
									s.Base = 0;
								}
							
								if (bonuscopy == 0)
									break;
							}
						}
						m_skb.Delete();
					}
					else
						from.SendMessage("You must have enough skills set down to compensate for the skill gain.");
				}

And a final time at:
Code:
else if (m_Skill.Base + bonuscopy <= m_Skill.Cap)
To:
Code:
else if (m_Skill.Base + bonuscopy <= 80)

That should do it...
Let me know if it don't work. I would've rather put the code to change in bold lettering but I don't know how to change the format of the text in mid sentence.
 

Heftiger

Wanderer
Ok one more question. If I set the object to not be movable will it create problems in their pack if the die or otherwise? If so, when I insert the item into their bank, how can i make it where they can use it without it being in their pack.
 

NoIdeaNoClue

Wanderer
Heftiger said:
Ok one more question. If I set the object to not be movable will it create problems in their pack if the die or otherwise? If so, when I insert the item into their bank, how can i make it where they can use it without it being in their pack.
To get it to work in a bankbox:

Change:
Code:
if ( !IsChildOf( from.Backpack ) ) 
	from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
To:
Code:
if ( !IsChildOf( from.BankBox ) ) 
	from.SendMessage( "That must be in your bankbox to use it" );

I'm not sure about the non-movable problems as I have not tested them.
 

Tannis

Knight
The author is still around, but this is in the Archives because it's an older script, meaning he might not be supporting it anymore. Try editing it yourself, and if you can't get it to work, post what you've tried along with your errors in the Script Support forum.
 

BillyTheKid

Wanderer
Should be posted in 2.0

Really nice item, ive tested it of almost any way possible on my 2.0 server and its 100% compatible with it and should be added in the script submission as a 2.0 script :)
 

kat20

Sorceror
ok so here is probably rather a dumb question. I want to make it where people can raise 7 skills, so if i understand it right all I have to do is raise the skill gain to 700 and it will basicaly fill up 7 skills to 100? If you could let me know Id appreciate it. Thank You
 

kat20

Sorceror
Thanks that is very nice, Its very simple to use there are many different ways you can use it. Thanks Much:)
 
Top