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!

Custom Skill Window

Tabain

Sorceror
Custom Skill Window

This is the code for opening your own custom skill window when the player presses the skills button on the paperdoll.

Code:
using System;
using System.Collections.Generic;
using System.Text;

using Server.Network;
using Server.Mobiles;

namespace Server
{
	public class CustomSkillWindow
	{
		public static void Initialize()
		{
			PacketHandlers.Register( 0x34, 10, true, new OnPacketReceive( RequestSkillsAndStatsGump ) );
			PacketHandlers.Register6017( 0x34, 10, true, new OnPacketReceive( RequestSkillsAndStatsGump ) );
		}

		public static void RequestSkillsAndStatsGump( NetState state, PacketReader pvSrc )
		{
			pvSrc.ReadInt32();
			int selectionByte = pvSrc.ReadByte();
			Mobile from = World.FindMobile( pvSrc.ReadInt32() );
			if ( from == null )
				return;

			switch ( selectionByte ) {
				case 4:

					from.OnStatsQuery( state.Mobile );
					break;
				case 5:
					if ( !( from is PlayerMobile ) )
						return;

					OpenSkillWindow( from as PlayerMobile );
					break;
				default:
					Console.Write( "Error:  recieved invalid packet type 0x34" );
					break;
			}
		}


		public static void OpenSkillWindow( PlayerMobile player )
		{
			//This is where you add a call to the gump you want to open when the player clicks the skill button
			//new CustomSkillGump( player );
			player.SendMessage( "I am a custom skill window!" );
		}
	}
}

You then build CustomSkillGump like any other gump. To fire a skill, something like player.UseSkill(theSkillID) in the button response will make the player use the skill with that ID. For example, player.UseSkill(SkillName.Stealth) would make the player try to stealth.

Edit: Changed it so it will actually compile if you copy/paste it into a file in your customs folder. Keep in mind this will block the original skill window from opening completely, and it will instead execute your code.
 
Top