#W# Initial Commit: Avatars Conquest

This commit is contained in:
WarrentyExpired 2026-07-04 10:35:30 -04:00
commit 5df497787a
7510 changed files with 416048 additions and 0 deletions

View file

@ -0,0 +1,548 @@
using System;
using System.Collections.Generic;
using Server;
namespace Server.Engines.Chat
{
public class Channel
{
private string m_Name;
private string m_Password;
private List<ChatUser> m_Users, m_Banned, m_Moderators, m_Voices;
private bool m_VoiceRestricted;
private bool m_AlwaysAvailable;
public Channel( string name )
{
m_Name = name;
m_Users = new List<ChatUser>();
m_Banned = new List<ChatUser>();
m_Moderators = new List<ChatUser>();
m_Voices = new List<ChatUser>();
}
public Channel( string name, string password ) : this( name )
{
m_Password = password;
}
public string Name
{
get
{
return m_Name;
}
set
{
SendCommand( ChatCommand.RemoveChannel, m_Name );
m_Name = value;
SendCommand( ChatCommand.AddChannel, m_Name );
SendCommand( ChatCommand.JoinedChannel, m_Name );
}
}
public string Password
{
get
{
return m_Password;
}
set
{
string newValue = null;
if ( value != null )
{
newValue = value.Trim();
if ( String.IsNullOrEmpty( newValue ) )
newValue = null;
}
m_Password = newValue;
}
}
public bool Contains( ChatUser user )
{
return m_Users.Contains( user );
}
public bool IsBanned( ChatUser user )
{
return m_Banned.Contains( user );
}
public bool CanTalk( ChatUser user )
{
return ( !m_VoiceRestricted || m_Voices.Contains( user ) || m_Moderators.Contains( user ) );
}
public bool IsModerator( ChatUser user )
{
return m_Moderators.Contains( user );
}
public bool IsVoiced( ChatUser user )
{
return m_Voices.Contains( user );
}
public bool ValidatePassword( string password )
{
return ( m_Password == null || Insensitive.Equals( m_Password, password ) );
}
public bool ValidateModerator( ChatUser user )
{
if ( user != null && !IsModerator( user ) )
{
user.SendMessage( 29 ); // You must have operator status to do this.
return false;
}
return true;
}
public bool ValidateAccess( ChatUser from, ChatUser target )
{
if ( from != null && target != null && from.Mobile.AccessLevel < target.Mobile.AccessLevel )
{
from.Mobile.SendMessage( "Your access level is too low to do this." );
return false;
}
return true;
}
public bool AddUser( ChatUser user )
{
return AddUser( user, null );
}
public bool AddUser( ChatUser user, string password )
{
if ( Contains( user ) )
{
user.SendMessage( 46, m_Name ); // You are already in the conference '%1'.
return true;
}
else if ( IsBanned( user ) )
{
user.SendMessage( 64 ); // You have been banned from this conference.
return false;
}
else if ( !ValidatePassword( password ) )
{
user.SendMessage( 34 ); // That is not the correct password.
return false;
}
else
{
if ( user.CurrentChannel != null )
user.CurrentChannel.RemoveUser( user ); // Remove them from their current channel first
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.JoinedChannel, m_Name );
SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
m_Users.Add( user );
user.CurrentChannel = this;
if ( user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!m_AlwaysAvailable && m_Users.Count == 1) )
AddModerator( user );
SendUsersTo( user );
return true;
}
}
public void RemoveUser( ChatUser user )
{
if ( Contains( user ) )
{
m_Users.Remove( user );
user.CurrentChannel = null;
if ( m_Moderators.Contains( user ) )
m_Moderators.Remove( user );
if ( m_Voices.Contains( user ) )
m_Voices.Remove( user );
SendCommand( ChatCommand.RemoveUserFromChannel, user, user.Username );
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.LeaveChannel );
if ( m_Users.Count == 0 && !m_AlwaysAvailable )
RemoveChannel( this );
}
}
public void AdBan( ChatUser user )
{
AddBan( user, null );
}
public void AddBan( ChatUser user, ChatUser moderator )
{
if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
return;
if ( !m_Banned.Contains( user ) )
m_Banned.Add( user );
Kick( user, moderator, true );
}
public void RemoveBan( ChatUser user )
{
if ( m_Banned.Contains( user ) )
m_Banned.Remove( user );
}
public void Kick( ChatUser user )
{
Kick( user, null );
}
public void Kick( ChatUser user, ChatUser moderator )
{
Kick( user, moderator, false );
}
public void Kick( ChatUser user, ChatUser moderator, bool wasBanned )
{
if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
return;
if ( Contains( user ) )
{
if ( moderator != null )
{
if ( wasBanned )
user.SendMessage( 63, moderator.Username ); // %1, a conference moderator, has banned you from the conference.
else
user.SendMessage( 45, moderator.Username ); // %1, a conference moderator, has kicked you out of the conference.
}
RemoveUser( user );
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
SendMessage( 44, user.Username ) ; // %1 has been kicked out of the conference.
}
if ( wasBanned && moderator != null )
moderator.SendMessage( 62, user.Username ); // You are banning %1 from this conference.
}
public bool VoiceRestricted
{
get
{
return m_VoiceRestricted;
}
set
{
m_VoiceRestricted = value;
if ( value )
SendMessage( 56 ); // From now on, only moderators will have speaking privileges in this conference by default.
else
SendMessage( 55 ); // From now on, everyone in the conference will have speaking privileges by default.
}
}
public bool AlwaysAvailable
{
get
{
return m_AlwaysAvailable;
}
set
{
m_AlwaysAvailable = value;
}
}
public void AddVoiced( ChatUser user )
{
AddVoiced( user, null );
}
public void AddVoiced( ChatUser user, ChatUser moderator )
{
if ( !ValidateModerator( moderator ) )
return;
if ( !IsBanned( user ) && !IsModerator( user ) && !IsVoiced( user ) )
{
m_Voices.Add( user );
if ( moderator != null )
user.SendMessage( 54, moderator.Username ); // %1, a conference moderator, has granted you speaking priviledges in this conference.
SendMessage( 52, user, user.Username ); // %1 now has speaking privileges in this conference.
SendCommand( ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username );
}
}
public void RemoveVoiced( ChatUser user, ChatUser moderator )
{
if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
return;
if ( !IsModerator( user ) && IsVoiced( user ) )
{
m_Voices.Remove( user );
if ( moderator != null )
user.SendMessage( 53, moderator.Username ); // %1, a conference moderator, has removed your speaking priviledges for this conference.
SendMessage( 51, user, user.Username ); // %1 no longer has speaking privileges in this conference.
SendCommand( ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username );
}
}
public void AddModerator( ChatUser user )
{
AddModerator( user, null );
}
public void AddModerator( ChatUser user, ChatUser moderator )
{
if ( !ValidateModerator( moderator ) )
return;
if ( IsBanned( user ) || IsModerator( user ) )
return;
if ( IsVoiced( user ) )
m_Voices.Remove( user );
m_Moderators.Add( user );
if ( moderator != null )
user.SendMessage( 50, moderator.Username ); // %1 has made you a conference moderator.
SendMessage( 48, user, user.Username ); // %1 is now a conference moderator.
SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
}
public void RemoveModerator( ChatUser user )
{
RemoveModerator( user, null );
}
public void RemoveModerator( ChatUser user, ChatUser moderator )
{
if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
return;
if ( IsModerator( user ) )
{
m_Moderators.Remove( user );
if ( moderator != null )
user.SendMessage( 49, moderator.Username ); // %1 has removed you from the list of conference moderators.
SendMessage( 47, user, user.Username ); // %1 is no longer a conference moderator.
SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
}
}
public void SendMessage( int number )
{
SendMessage( number, null, null, null );
}
public void SendMessage( int number, string param1 )
{
SendMessage( number, null, param1, null );
}
public void SendMessage( int number, string param1, string param2 )
{
SendMessage( number, null, param1, param2 );
}
public void SendMessage( int number, ChatUser initiator )
{
SendMessage( number, initiator, null, null );
}
public void SendMessage( int number, ChatUser initiator, string param1 )
{
SendMessage( number, initiator, param1, null );
}
public void SendMessage( int number, ChatUser initiator, string param1, string param2 )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
if ( user == initiator )
continue;
if ( user.CheckOnline() )
user.SendMessage( number, param1, param2 );
else if ( !Contains( user ) )
--i;
}
}
public void SendIgnorableMessage( int number, ChatUser from, string param1, string param2 )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
if ( user.IsIgnored( from ) )
continue;
if ( user.CheckOnline() )
user.SendMessage( number, from.Mobile, param1, param2 );
else if ( !Contains( user ) )
--i;
}
}
public void SendCommand( ChatCommand command )
{
SendCommand( command, null, null, null );
}
public void SendCommand( ChatCommand command, string param1 )
{
SendCommand( command, null, param1, null );
}
public void SendCommand( ChatCommand command, string param1, string param2 )
{
SendCommand( command, null, param1, param2 );
}
public void SendCommand( ChatCommand command, ChatUser initiator )
{
SendCommand( command, initiator, null, null );
}
public void SendCommand( ChatCommand command, ChatUser initiator, string param1 )
{
SendCommand( command, initiator, param1, null );
}
public void SendCommand( ChatCommand command, ChatUser initiator, string param1, string param2 )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
if ( user == initiator )
continue;
if ( user.CheckOnline() )
ChatSystem.SendCommandTo( user.Mobile, command, param1, param2 );
else if ( !Contains( user ) )
--i;
}
}
public void SendUsersTo( ChatUser to )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
ChatSystem.SendCommandTo( to.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
}
}
private static List<Channel> m_Channels = new List<Channel>();
public static List<Channel> Channels
{
get
{
return m_Channels;
}
}
public static void SendChannelsTo( ChatUser user )
{
for ( int i = 0; i < m_Channels.Count; ++i )
{
Channel channel = m_Channels[i];
if ( !channel.IsBanned( user ) )
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddChannel, channel.Name, "0" );
}
}
public static Channel AddChannel( string name )
{
return AddChannel( name, null );
}
public static Channel AddChannel( string name, string password )
{
Channel channel = FindChannelByName( name );
if ( channel == null )
{
channel = new Channel( name, password );
m_Channels.Add( channel );
}
ChatUser.GlobalSendCommand( ChatCommand.AddChannel, name, "0" ) ;
return channel;
}
public static void RemoveChannel( string name )
{
RemoveChannel( FindChannelByName( name ) );
}
public static void RemoveChannel( Channel channel )
{
if ( channel == null )
return;
if ( m_Channels.Contains( channel ) && channel.m_Users.Count == 0 )
{
ChatUser.GlobalSendCommand( ChatCommand.RemoveChannel, channel.Name ) ;
channel.m_Moderators.Clear();
channel.m_Voices.Clear();
m_Channels.Remove( channel );
}
}
public static Channel FindChannelByName( string name )
{
for ( int i = 0; i < m_Channels.Count; ++i )
{
Channel channel = m_Channels[i];
if ( channel.m_Name == name )
return channel;
}
return null;
}
public static void Initialize()
{
AddStaticChannel( "Newbie Help" );
}
public static void AddStaticChannel( string name )
{
AddChannel( name ).AlwaysAvailable = true;
}
}
}

View file

@ -0,0 +1,174 @@
using System;
using Server;
using Server.Misc;
using Server.Network;
using Server.Accounting;
namespace Server.Engines.Chat
{
public class ChatSystem
{
private static bool m_Enabled = true;
public static bool Enabled
{
get{ return m_Enabled; }
set{ m_Enabled = value; }
}
public static void Initialize()
{
PacketHandlers.Register( 0xB5, 0x40, true, new OnPacketReceive( OpenChatWindowRequest ) );
PacketHandlers.Register( 0xB3, 0, true, new OnPacketReceive( ChatAction ) );
}
public static void SendCommandTo( Mobile to, ChatCommand type )
{
SendCommandTo( to, type, null, null );
}
public static void SendCommandTo( Mobile to, ChatCommand type, string param1 )
{
SendCommandTo( to, type, param1, null );
}
public static void SendCommandTo( Mobile to, ChatCommand type, string param1, string param2 )
{
if ( to != null )
to.Send( new ChatMessagePacket( null, (int)type + 20, param1, param2 ) );
}
public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
{
Mobile from = state.Mobile;
if ( !m_Enabled )
{
from.SendMessage( "The chat system has been disabled." );
return;
}
pvSrc.Seek( 2, System.IO.SeekOrigin.Begin );
string chatName = pvSrc.ReadUnicodeStringSafe( ( 0x40 - 2 ) >> 1 ).Trim();
Account acct = state.Account as Account;
string accountChatName = null;
if ( acct != null )
accountChatName = acct.GetTag( "ChatName" );
if ( accountChatName != null )
accountChatName = accountChatName.Trim();
if ( accountChatName != null && accountChatName.Length > 0 )
{
if ( chatName.Length > 0 && chatName != accountChatName )
from.SendMessage( "You cannot change chat nickname once it has been set." );
}
else
{
if ( chatName == null || chatName.Length == 0 )
{
SendCommandTo( from, ChatCommand.AskNewNickname );
return;
}
if ( NameVerification.Validate( chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote ) && chatName.ToLower().IndexOf( "system" ) == -1 )
{
// TODO: Optimize this search
foreach ( Account checkAccount in Accounts.GetAccounts() )
{
string existingName = checkAccount.GetTag( "ChatName" );
if ( existingName != null )
{
existingName = existingName.Trim();
if ( Insensitive.Equals( existingName, chatName ) )
{
from.SendMessage( "Nickname already in use." );
SendCommandTo( from, ChatCommand.AskNewNickname );
return;
}
}
}
accountChatName = chatName;
if ( acct != null )
acct.AddTag( "ChatName", chatName );
}
else
{
from.SendLocalizedMessage( 501173 ); // That name is disallowed.
SendCommandTo( from, ChatCommand.AskNewNickname );
return;
}
}
SendCommandTo( from, ChatCommand.OpenChatWindow, accountChatName );
ChatUser.AddChatUser( from );
}
public static ChatUser SearchForUser( ChatUser from, string name )
{
ChatUser user = ChatUser.GetChatUser( name );
if ( user == null )
from.SendMessage( 32, name ); // There is no player named '%1'.
return user;
}
public static void ChatAction( NetState state, PacketReader pvSrc )
{
if ( !m_Enabled )
return;
try
{
Mobile from = state.Mobile;
ChatUser user = ChatUser.GetChatUser( from );
if ( user == null )
return;
string lang = pvSrc.ReadStringSafe( 4 );
int actionID = pvSrc.ReadInt16();
string param = pvSrc.ReadUnicodeString();
ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );
if ( handler != null )
{
Channel channel = user.CurrentChannel;
if ( handler.RequireConference && channel == null )
{
user.SendMessage( 31 ); /* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
}
else if ( handler.RequireModerator && !user.IsModerator )
{
user.SendMessage( 29 ); // You must have operator status to do this.
}
else
{
handler.Callback( user, channel, param );
}
}
else
{
Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param );
}
}
catch ( Exception e )
{
Console.WriteLine( e );
}
}
}
}

View file

@ -0,0 +1,24 @@
using System;
namespace Server.Engines.Chat
{
public delegate void OnChatAction( ChatUser from, Channel channel, string param );
public class ChatActionHandler
{
private bool m_RequireModerator;
private bool m_RequireConference;
private OnChatAction m_Callback;
public bool RequireModerator{ get{ return m_RequireModerator; } }
public bool RequireConference{ get{ return m_RequireConference; } }
public OnChatAction Callback{ get{ return m_Callback; } }
public ChatActionHandler( bool requireModerator, bool requireConference, OnChatAction callback )
{
m_RequireModerator = requireModerator;
m_RequireConference = requireConference;
m_Callback = callback;
}
}
}

View file

@ -0,0 +1,359 @@
using System;
namespace Server.Engines.Chat
{
public class ChatActionHandlers
{
private static ChatActionHandler[] m_Handlers;
static ChatActionHandlers()
{
m_Handlers = new ChatActionHandler[0x100];
Register( 0x41, true, true, new OnChatAction( ChangeChannelPassword ) );
Register( 0x58, false, false, new OnChatAction( LeaveChat ) );
Register( 0x61, false, true, new OnChatAction( ChannelMessage ) );
Register( 0x62, false, false, new OnChatAction( JoinChannel ) );
Register( 0x63, false, false, new OnChatAction( JoinNewChannel ) );
Register( 0x64, true, true, new OnChatAction( RenameChannel ) );
Register( 0x65, false, false, new OnChatAction( PrivateMessage ) );
Register( 0x66, false, false, new OnChatAction( AddIgnore ) );
Register( 0x67, false, false, new OnChatAction( RemoveIgnore ) );
Register( 0x68, false, false, new OnChatAction( ToggleIgnore ) );
Register( 0x69, true, true, new OnChatAction( AddVoice ) );
Register( 0x6A, true, true, new OnChatAction( RemoveVoice ) );
Register( 0x6B, true, true, new OnChatAction( ToggleVoice ) );
Register( 0x6C, true, true, new OnChatAction( AddModerator ) );
Register( 0x6D, true, true, new OnChatAction( RemoveModerator ) );
Register( 0x6E, true, true, new OnChatAction( ToggleModerator ) );
Register( 0x6F, false, false, new OnChatAction( AllowPrivateMessages ) );
Register( 0x70, false, false, new OnChatAction( DisallowPrivateMessages ) );
Register( 0x71, false, false, new OnChatAction( TogglePrivateMessages ) );
Register( 0x72, false, false, new OnChatAction( ShowCharacterName ) );
Register( 0x73, false, false, new OnChatAction( HideCharacterName ) );
Register( 0x74, false, false, new OnChatAction( ToggleCharacterName ) );
Register( 0x75, false, false, new OnChatAction( QueryWhoIs ) );
Register( 0x76, true, true, new OnChatAction( Kick ) );
Register( 0x77, true, true, new OnChatAction( EnableDefaultVoice ) );
Register( 0x78, true, true, new OnChatAction( DisableDefaultVoice ) );
Register( 0x79, true, true, new OnChatAction( ToggleDefaultVoice ) );
Register( 0x7A, false, true, new OnChatAction( EmoteMessage ) );
}
public static void Register( int actionID, bool requireModerator, bool requireConference, OnChatAction callback )
{
if ( actionID >= 0 && actionID < m_Handlers.Length )
m_Handlers[actionID] = new ChatActionHandler( requireModerator, requireConference, callback );
}
public static ChatActionHandler GetHandler( int actionID )
{
if ( actionID >= 0 && actionID < m_Handlers.Length )
return m_Handlers[actionID];
return null;
}
public static void ChannelMessage( ChatUser from, Channel channel, string param )
{
if ( channel.CanTalk( from ) )
channel.SendIgnorableMessage( 57, from, from.GetColorCharacter() + from.Username, param ); // %1: %2
else
from.SendMessage( 36 ); // The moderator of this conference has not given you speaking priviledges.
}
public static void EmoteMessage( ChatUser from, Channel channel, string param )
{
if ( channel.CanTalk( from ) )
channel.SendIgnorableMessage( 58, from, from.GetColorCharacter() + from.Username, param ); // %1 %2
else
from.SendMessage( 36 ); // The moderator of this conference has not given you speaking priviledges.
}
public static void PrivateMessage( ChatUser from, Channel channel, string param )
{
int indexOf = param.IndexOf( ' ' );
string name = param.Substring( 0, indexOf );
string text = param.Substring( indexOf + 1 );
ChatUser target = ChatSystem.SearchForUser( from, name );
if ( target == null )
return;
if ( target.IsIgnored( from ) )
from.SendMessage( 35, target.Username ); // %1 has chosen to ignore you. None of your messages to them will get through.
else if ( target.IgnorePrivateMessage )
from.SendMessage( 42, target.Username ); // %1 has chosen to not receive private messages at the moment.
else
target.SendMessage( 59, from.Mobile, from.GetColorCharacter() + from.Username, text ); // [%1]: %2
}
public static void LeaveChat( ChatUser from, Channel channel, string param )
{
ChatUser.RemoveChatUser( from );
}
public static void ChangeChannelPassword( ChatUser from, Channel channel, string param )
{
channel.Password = param;
from.SendMessage( 60 ); // The password to the conference has been changed.
}
public static void AllowPrivateMessages( ChatUser from, Channel channel, string param )
{
from.IgnorePrivateMessage = false;
from.SendMessage( 37 ); // You can now receive private messages.
}
public static void DisallowPrivateMessages( ChatUser from, Channel channel, string param )
{
from.IgnorePrivateMessage = true;
from.SendMessage( 38 ); /* You will no longer receive private messages.
* Those who send you a message will be notified that you are blocking incoming messages.
*/
}
public static void TogglePrivateMessages( ChatUser from, Channel channel, string param )
{
from.IgnorePrivateMessage = !from.IgnorePrivateMessage;
from.SendMessage( from.IgnorePrivateMessage ? 38 : 37 ); // See above for messages
}
public static void ShowCharacterName( ChatUser from, Channel channel, string param )
{
from.Anonymous = false;
from.SendMessage( 39 ); // You are now showing your character name to any players who inquire with the whois command.
}
public static void HideCharacterName( ChatUser from, Channel channel, string param )
{
from.Anonymous = true;
from.SendMessage( 40 ); // You are no longer showing your character name to any players who inquire with the whois command.
}
public static void ToggleCharacterName( ChatUser from, Channel channel, string param )
{
from.Anonymous = !from.Anonymous;
from.SendMessage( from.Anonymous ? 40 : 39 ); // See above for messages
}
public static void JoinChannel( ChatUser from, Channel channel, string param )
{
string name;
string password = null;
int start = param.IndexOf( '\"' );
if ( start >= 0 )
{
int end = param.IndexOf( '\"', ++start );
if ( end >= 0 )
{
name = param.Substring( start, end - start );
password = param.Substring( ++end );
}
else
{
name = param.Substring( start );
}
}
else
{
int indexOf = param.IndexOf( ' ' );
if ( indexOf >= 0 )
{
name = param.Substring( 0, indexOf++ );
password = param.Substring( indexOf );
}
else
{
name = param;
}
}
if ( password != null )
password = password.Trim();
if ( password != null && password.Length == 0 )
password = null;
Channel joined = Channel.FindChannelByName( name );
if ( joined == null )
from.SendMessage( 33, name ); // There is no conference named '%1'.
else
joined.AddUser( from, password );
}
public static void JoinNewChannel( ChatUser from, Channel channel, string param )
{
if ( (param = param.Trim()).Length == 0 )
return;
string name;
string password = null;
int start = param.IndexOf( '{' );
if ( start >= 0 )
{
name = param.Substring( 0, start++ );
int end = param.IndexOf( '}', start );
if ( end >= start )
password = param.Substring( start, end - start );
}
else
{
name = param;
}
if ( password != null )
password = password.Trim();
if ( password != null && password.Length == 0 )
password = null;
Channel.AddChannel( name, password ).AddUser( from, password );
}
public static void AddIgnore( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
from.AddIgnored( target );
}
public static void RemoveIgnore( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
from.RemoveIgnored( target );
}
public static void ToggleIgnore( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
if ( from.IsIgnored( target ) )
from.RemoveIgnored( target );
else
from.AddIgnored( target );
}
public static void AddVoice( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target != null )
channel.AddVoiced( target, from );
}
public static void RemoveVoice( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target != null )
channel.RemoveVoiced( target, from );
}
public static void ToggleVoice( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
if ( channel.IsVoiced( target ) )
channel.RemoveVoiced( target, from );
else
channel.AddVoiced( target, from );
}
public static void AddModerator( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target != null )
channel.AddModerator( target, from );
}
public static void RemoveModerator( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target != null )
channel.RemoveModerator( target, from );
}
public static void ToggleModerator( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
if ( channel.IsModerator( target ) )
channel.RemoveModerator( target, from );
else
channel.AddModerator( target, from );
}
public static void RenameChannel( ChatUser from, Channel channel, string param )
{
channel.Name = param;
}
public static void QueryWhoIs( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target == null )
return;
if ( target.Anonymous )
from.SendMessage( 41, target.Username ); // %1 is remaining anonymous.
else
from.SendMessage( 43, target.Username, target.Mobile.Name ); // %2 is known in the lands of Britannia as %2.
}
public static void Kick( ChatUser from, Channel channel, string param )
{
ChatUser target = ChatSystem.SearchForUser( from, param );
if ( target != null )
channel.Kick( target, from );
}
public static void EnableDefaultVoice( ChatUser from, Channel channel, string param )
{
channel.VoiceRestricted = false;
}
public static void DisableDefaultVoice( ChatUser from, Channel channel, string param )
{
channel.VoiceRestricted = true;
}
public static void ToggleDefaultVoice( ChatUser from, Channel channel, string param )
{
channel.VoiceRestricted = !channel.VoiceRestricted;
}
}
}

View file

@ -0,0 +1,44 @@
using System;
namespace Server.Engines.Chat
{
public enum ChatCommand
{
/// <summary>
/// Add a channel to top list.
/// </summary>
AddChannel = 0x3E8,
/// <summary>
/// Remove channel from top list.
/// </summary>
RemoveChannel = 0x3E9,
/// <summary>
/// Queries for a new chat nickname.
/// </summary>
AskNewNickname = 0x3EB,
/// <summary>
/// Closes the chat window.
/// </summary>
CloseChatWindow = 0x3EC,
/// <summary>
/// Opens the chat window.
/// </summary>
OpenChatWindow = 0x3ED,
/// <summary>
/// Add a user to current channel.
/// </summary>
AddUserToChannel = 0x3EE,
/// <summary>
/// Remove a user from current channel.
/// </summary>
RemoveUserFromChannel = 0x3EF,
/// <summary>
/// Send a message putting generic conference name at top when player leaves a channel.
/// </summary>
LeaveChannel = 0x3F0,
/// <summary>
/// Send a message putting Channel name at top and telling player he joined the channel.
/// </summary>
JoinedChannel = 0x3F1
}
}

View file

@ -0,0 +1,321 @@
using System;
using System.Collections.Generic;
using Server;
using Server.Accounting;
namespace Server.Engines.Chat
{
public class ChatUser
{
private Mobile m_Mobile;
private Channel m_Channel;
private bool m_Anonymous;
private bool m_IgnorePrivateMessage;
private List<ChatUser> m_Ignored, m_Ignoring;
public ChatUser( Mobile m )
{
m_Mobile = m;
m_Ignored = new List<ChatUser>();
m_Ignoring = new List<ChatUser>();
}
public Mobile Mobile
{
get
{
return m_Mobile;
}
}
public List<ChatUser> Ignored
{
get
{
return m_Ignored;
}
}
public List<ChatUser> Ignoring
{
get
{
return m_Ignoring;
}
}
public string Username
{
get
{
Account acct = m_Mobile.Account as Account;
if ( acct != null )
return acct.GetTag( "ChatName" );
return null;
}
set
{
Account acct = m_Mobile.Account as Account;
if ( acct != null )
acct.SetTag( "ChatName", value );
}
}
public Channel CurrentChannel
{
get
{
return m_Channel;
}
set
{
m_Channel = value;
}
}
public bool IsOnline
{
get
{
return ( m_Mobile.NetState != null );
}
}
public bool Anonymous
{
get
{
return m_Anonymous;
}
set
{
m_Anonymous = value;
}
}
public bool IgnorePrivateMessage
{
get
{
return m_IgnorePrivateMessage;
}
set
{
m_IgnorePrivateMessage = value;
}
}
public const char NormalColorCharacter = '0';
public const char ModeratorColorCharacter = '1';
public const char VoicedColorCharacter = '2';
public char GetColorCharacter()
{
if ( m_Channel != null && m_Channel.IsModerator( this ) )
return ModeratorColorCharacter;
if ( m_Channel != null && m_Channel.IsVoiced( this ) )
return VoicedColorCharacter;
return NormalColorCharacter;
}
public bool CheckOnline()
{
if ( IsOnline )
return true;
RemoveChatUser( this );
return false;
}
public void SendMessage( int number )
{
SendMessage( number, null, null );
}
public void SendMessage( int number, string param1 )
{
SendMessage( number, param1, null );
}
public void SendMessage( int number, string param1, string param2 )
{
if ( m_Mobile.NetState != null )
m_Mobile.Send( new ChatMessagePacket( m_Mobile, number, param1, param2 ) );
}
public void SendMessage( int number, Mobile from, string param1, string param2 )
{
if ( m_Mobile.NetState != null )
m_Mobile.Send( new ChatMessagePacket( from, number, param1, param2 ) );
}
public bool IsIgnored( ChatUser check )
{
return m_Ignored.Contains( check );
}
public bool IsModerator
{
get
{
return ( m_Channel != null && m_Channel.IsModerator( this ) );
}
}
public void AddIgnored( ChatUser user )
{
if ( IsIgnored( user ) )
{
SendMessage( 22, user.Username ); // You are already ignoring %1.
}
else
{
m_Ignored.Add( user );
user.m_Ignoring.Add( this );
SendMessage( 23, user.Username ); // You are now ignoring %1.
}
}
public void RemoveIgnored( ChatUser user )
{
if ( IsIgnored( user ) )
{
m_Ignored.Remove( user );
user.m_Ignoring.Remove( this );
SendMessage( 24, user.Username ); // You are no longer ignoring %1.
if ( m_Ignored.Count == 0 )
SendMessage( 26 ); // You are no longer ignoring anyone.
}
else
{
SendMessage( 25, user.Username ); // You are not ignoring %1.
}
}
private static List<ChatUser> m_Users = new List<ChatUser>();
private static Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
public static ChatUser AddChatUser( Mobile from )
{
ChatUser user = GetChatUser( from );
if ( user == null )
{
user = new ChatUser( from );
m_Users.Add( user );
m_Table[from] = user;
Channel.SendChannelsTo( user );
List<Channel> list = Channel.Channels;
for ( int i = 0; i < list.Count; ++i )
{
Channel c = list[i];
if ( c.AddUser( user ) )
break;
}
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
}
return user;
}
public static void RemoveChatUser( ChatUser user )
{
if ( user == null )
return;
for ( int i = 0; i < user.m_Ignoring.Count; ++i )
user.m_Ignoring[i].RemoveIgnored( user );
if ( m_Users.Contains( user ) )
{
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.CloseChatWindow );
if ( user.m_Channel != null )
user.m_Channel.RemoveUser( user );
m_Users.Remove( user );
m_Table.Remove( user.m_Mobile );
}
}
public static void RemoveChatUser( Mobile from )
{
ChatUser user = GetChatUser( from );
RemoveChatUser( user );
}
public static ChatUser GetChatUser( Mobile from )
{
ChatUser c;
m_Table.TryGetValue( from, out c );
return c;
}
public static ChatUser GetChatUser( string username )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
if ( user.Username == username )
return user;
}
return null;
}
public static void GlobalSendCommand( ChatCommand command )
{
GlobalSendCommand( command, null, null, null );
}
public static void GlobalSendCommand( ChatCommand command, string param1 )
{
GlobalSendCommand( command, null, param1, null );
}
public static void GlobalSendCommand( ChatCommand command, string param1, string param2 )
{
GlobalSendCommand( command, null, param1, param2 );
}
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator )
{
GlobalSendCommand( command, initiator, null, null );
}
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator, string param1 )
{
GlobalSendCommand( command, initiator, param1, null );
}
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator, string param1, string param2 )
{
for ( int i = 0; i < m_Users.Count; ++i )
{
ChatUser user = m_Users[i];
if ( user == initiator )
continue;
if ( user.CheckOnline() )
ChatSystem.SendCommandTo( user.m_Mobile, command, param1, param2 );
}
}
}
}

View file

@ -0,0 +1,20 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Chat
{
public class ChatSystem
{
public static void Initialize()
{
EventSink.ChatRequest += new ChatRequestEventHandler( EventSink_ChatRequest );
}
private static void EventSink_ChatRequest( ChatRequestEventArgs e )
{
e.Mobile.SendMessage( "Chat is not currently supported." );
}
}
}

View file

@ -0,0 +1,30 @@
using System;
using Server;
using Server.Network;
namespace Server.Engines.Chat
{
public sealed class ChatMessagePacket : Packet
{
public ChatMessagePacket( Mobile who, int number, string param1, string param2 ) : base( 0xB2 )
{
if ( param1 == null )
param1 = String.Empty;
if ( param2 == null )
param2 = String.Empty;
EnsureCapacity( 13 + ((param1.Length + param2.Length) * 2) );
m_Stream.Write( (ushort) (number - 20) );
if ( who != null )
m_Stream.WriteAsciiFixed( who.Language, 4 );
else
m_Stream.Write( (int) 0 );
m_Stream.WriteBigUniNull( param1 );
m_Stream.WriteBigUniNull( param2 );
}
}
}

View file

@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Engines.Craft
{
public enum CraftMarkOption
{
MarkItem,
DoNotMark,
PromptForMark
}
public class CraftContext
{
private List<CraftItem> m_Items;
private int m_LastResourceIndex;
private int m_LastGroupIndex;
private bool m_DoNotColor;
private CraftMarkOption m_MarkOption;
public List<CraftItem> Items { get { return m_Items; } }
public int LastResourceIndex{ get{ return m_LastResourceIndex; } set{ m_LastResourceIndex = value; } }
public int LastGroupIndex{ get{ return m_LastGroupIndex; } set{ m_LastGroupIndex = value; } }
public bool DoNotColor{ get{ return m_DoNotColor; } set{ m_DoNotColor = value; } }
public CraftMarkOption MarkOption{ get{ return m_MarkOption; } set{ m_MarkOption = value; } }
public CraftContext()
{
m_Items = new List<CraftItem>();
m_LastResourceIndex = -1;
m_LastGroupIndex = -1;
}
public CraftItem LastMade
{
get
{
if ( m_Items.Count > 0 )
return m_Items[0];
return null;
}
}
public void OnMade( CraftItem item )
{
m_Items.Remove( item );
if ( m_Items.Count == 10 )
m_Items.RemoveAt( 9 );
m_Items.Insert( 0, item );
}
}
}

View file

@ -0,0 +1,39 @@
using System;
namespace Server.Engines.Craft
{
public class CraftGroup
{
private CraftItemCol m_arCraftItem;
private string m_NameString;
private int m_NameNumber;
public CraftGroup( TextDefinition groupName )
{
m_NameNumber = groupName;
m_NameString = groupName;
m_arCraftItem = new CraftItemCol();
}
public void AddCraftItem( CraftItem craftItem )
{
m_arCraftItem.Add( craftItem );
}
public CraftItemCol CraftItems
{
get { return m_arCraftItem; }
}
public string NameString
{
get { return m_NameString; }
}
public int NameNumber
{
get { return m_NameNumber; }
}
}
}

View file

@ -0,0 +1,48 @@
using System;
namespace Server.Engines.Craft
{
public class CraftGroupCol : System.Collections.CollectionBase
{
public CraftGroupCol()
{
}
public int Add( CraftGroup craftGroup )
{
return List.Add( craftGroup );
}
public void Remove( int index )
{
if ( index > Count - 1 || index < 0 )
{
}
else
{
List.RemoveAt( index );
}
}
public CraftGroup GetAt( int index )
{
return ( CraftGroup ) List[index];
}
public int SearchFor( TextDefinition groupName )
{
for ( int i = 0; i < List.Count; i++ )
{
CraftGroup craftGroup = (CraftGroup)List[i];
int nameNumber = craftGroup.NameNumber;
string nameString = craftGroup.NameString;
if ( ( nameNumber != 0 && nameNumber == groupName.Number ) || ( nameString != null && nameString == groupName.String ) )
return i;
}
return -1;
}
}
}

View file

@ -0,0 +1,539 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class CraftGump : Gump
{
private Mobile m_From;
private CraftSystem m_CraftSystem;
private BaseTool m_Tool;
private CraftPage m_Page;
private const int LabelHue = 0x480;
private const int LabelColor = 0x7FFF;
private const int FontColor = 0xFFFFFF;
private enum CraftPage
{
None,
PickResource
}
/*public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool ): this( from, craftSystem, -1, -1, tool, null )
{
}*/
public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice ) : this( from, craftSystem, tool, notice, CraftPage.None )
{
}
private CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page ) : base( 40, 40 )
{
m_From = from;
m_CraftSystem = craftSystem;
m_Tool = tool;
m_Page = page;
CraftContext context = craftSystem.GetContext( from );
from.CloseGump( typeof( CraftGump ) );
from.CloseGump( typeof( CraftGumpItem ) );
AddPage( 0 );
AddBackground( 0, 0, 530, 437, 5054 );
AddImageTiled( 10, 10, 510, 22, 2624 );
AddImageTiled( 10, 292, 150, 45, 2624 );
AddImageTiled( 165, 292, 355, 45, 2624 );
AddImageTiled( 10, 342, 510, 85, 2624 );
AddImageTiled( 10, 37, 200, 250, 2624 );
AddImageTiled( 215, 37, 305, 250, 2624 );
AddAlphaRegion( 10, 10, 510, 417 );
if ( craftSystem.GumpTitleNumber > 0 )
AddHtmlLocalized( 10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false );
else
AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false );
AddHtmlLocalized( 10, 37, 200, 22, 1044010, LabelColor, false, false ); // <CENTER>CATEGORIES</CENTER>
AddHtmlLocalized( 215, 37, 305, 22, 1044011, LabelColor, false, false ); // <CENTER>SELECTIONS</CENTER>
AddHtmlLocalized( 10, 302, 150, 25, 1044012, LabelColor, false, false ); // <CENTER>NOTICES</CENTER>
AddButton( 15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 405, 150, 18, 1011441, LabelColor, false, false ); // EXIT
AddButton( 270, 402, 4005, 4007, GetButtonID( 6, 2 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 305, 405, 150, 18, 1044013, LabelColor, false, false ); // MAKE LAST
// Mark option
if ( craftSystem.MarkOption )
{
AddButton( 270, 362, 4005, 4007, GetButtonID( 6, 6 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false ); // MARK ITEM
}
// ****************************************
// Resmelt option
if ( craftSystem.Resmelt )
{
AddButton( 15, 342, 4005, 4007, GetButtonID( 6, 1 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 345, 150, 18, 1044259, LabelColor, false, false ); // SMELT ITEM
}
// ****************************************
// Repair option
if ( craftSystem.Repair )
{
AddButton( 270, 342, 4005, 4007, GetButtonID( 6, 5 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 305, 345, 150, 18, 1044260, LabelColor, false, false ); // REPAIR ITEM
}
// ****************************************
if ( notice is int && (int)notice > 0 )
AddHtmlLocalized( 170, 295, 350, 40, (int)notice, LabelColor, false, false );
else if ( notice is string )
AddHtml( 170, 295, 350, 40, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice ), false, false );
// If the system has more than one resource
if ( craftSystem.CraftSubRes.Init )
{
string nameString = craftSystem.CraftSubRes.NameString;
int nameNumber = craftSystem.CraftSubRes.NameNumber;
int resIndex = ( context == null ? -1 : context.LastResourceIndex );
Type resourceType = craftSystem.CraftSubRes.ResType;
if ( resIndex > -1 )
{
CraftSubRes subResource = craftSystem.CraftSubRes.GetAt( resIndex );
nameString = subResource.NameString;
nameNumber = subResource.NameNumber;
resourceType = subResource.ItemType;
}
int resourceCount = 0;
if ( from.Backpack != null )
{
Item[] items = from.Backpack.FindItemsByType( resourceType, true );
for ( int i = 0; i < items.Length; ++i )
resourceCount += items[i].Amount;
}
AddButton( 15, 362, 4005, 4007, GetButtonID( 6, 0 ), GumpButtonType.Reply, 0 );
if ( nameNumber > 0 )
AddHtmlLocalized( 50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false );
else
AddLabel( 50, 362, LabelHue, String.Format( "{0} ({1} Available)", nameString, resourceCount ) );
}
// ****************************************
CreateGroupList();
if ( page == CraftPage.PickResource )
CreateResList( false, from );
else if ( context != null && context.LastGroupIndex > -1 )
CreateItemList( context.LastGroupIndex );
}
public void CreateResList( bool opt, Mobile from )
{
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
for ( int i = 0; i < res.Count; ++i )
{
int index = i % 10;
CraftSubRes subResource = res.GetAt( i );
if ( index == 0 )
{
if ( i > 0 )
AddButton( 485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
AddPage( (i / 10) + 1 );
if ( i > 0 )
AddButton( 455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
CraftContext context = m_CraftSystem.GetContext( m_From );
AddButton( 220, 260, 4005, 4007, GetButtonID( 6, 4 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false );
}
int resourceCount = 0;
if ( from.Backpack != null )
{
Item[] items = from.Backpack.FindItemsByType( subResource.ItemType, true );
for ( int j = 0; j < items.Length; ++j )
resourceCount += items[j].Amount;
}
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 5, i ), GumpButtonType.Reply, 0 );
if ( subResource.NameNumber > 0 )
AddHtmlLocalized( 255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false );
else
AddLabel( 255, 60 + ( index * 20 ), LabelHue, String.Format( "{0} ({1})", subResource.NameString, resourceCount ) );
}
}
public void CreateMakeLastList()
{
CraftContext context = m_CraftSystem.GetContext( m_From );
if ( context == null )
return;
List<CraftItem> items = context.Items;
if ( items.Count > 0 )
{
for ( int i = 0; i < items.Count; ++i )
{
int index = i % 10;
CraftItem craftItem = items[i];
if ( index == 0 )
{
if ( i > 0 )
{
AddButton( 370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
AddHtmlLocalized( 405, 263, 100, 18, 1044045, LabelColor, false, false ); // NEXT PAGE
}
AddPage( (i / 10) + 1 );
if ( i > 0 )
{
AddButton( 220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
AddHtmlLocalized( 255, 263, 100, 18, 1044044, LabelColor, false, false ); // PREV PAGE
}
}
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 3, i ), GumpButtonType.Reply, 0 );
if ( craftItem.NameNumber > 0 )
AddHtmlLocalized( 255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false );
else
AddLabel( 255, 60 + (index * 20), LabelHue, craftItem.NameString );
AddButton( 480, 60 + (index * 20), 4011, 4012, GetButtonID( 4, i ), GumpButtonType.Reply, 0 );
}
}
else
{
// NOTE: This is not as OSI; it is an intentional difference
AddHtmlLocalized( 230, 62, 200, 22, 1044165, LabelColor, false, false ); // You haven't made anything yet.
}
}
public void CreateItemList( int selectedGroup )
{
if ( selectedGroup == 501 ) // 501 : Last 10
{
CreateMakeLastList();
return;
}
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
CraftGroup craftGroup = craftGroupCol.GetAt( selectedGroup );
CraftItemCol craftItemCol = craftGroup.CraftItems;
for ( int i = 0; i < craftItemCol.Count; ++i )
{
int index = i % 10;
CraftItem craftItem = craftItemCol.GetAt( i );
if ( index == 0 )
{
if ( i > 0 )
{
AddButton( 370, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1 );
AddHtmlLocalized( 405, 263, 100, 18, 1044045, LabelColor, false, false ); // NEXT PAGE
}
AddPage( (i / 10) + 1 );
if ( i > 0 )
{
AddButton( 220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10 );
AddHtmlLocalized( 255, 263, 100, 18, 1044044, LabelColor, false, false ); // PREV PAGE
}
}
AddButton( 220, 60 + (index * 20), 4005, 4007, GetButtonID( 1, i ), GumpButtonType.Reply, 0 );
if ( craftItem.NameNumber > 0 )
AddHtmlLocalized( 255, 63 + (index * 20), 220, 18, craftItem.NameNumber, LabelColor, false, false );
else
AddLabel( 255, 60 + (index * 20), LabelHue, craftItem.NameString );
AddButton( 480, 60 + (index * 20), 4011, 4012, GetButtonID( 2, i ), GumpButtonType.Reply, 0 );
}
}
public int CreateGroupList()
{
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
AddButton( 15, 60, 4005, 4007, GetButtonID( 6, 3 ), GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 63, 150, 18, 1044014, LabelColor, false, false ); // LAST TEN
for ( int i = 0; i < craftGroupCol.Count; i++ )
{
CraftGroup craftGroup = craftGroupCol.GetAt( i );
AddButton( 15, 80 + (i * 20), 4005, 4007, GetButtonID( 0, i ), GumpButtonType.Reply, 0 );
if ( craftGroup.NameNumber > 0 )
AddHtmlLocalized( 50, 83 + (i * 20), 150, 18, craftGroup.NameNumber, LabelColor, false, false );
else
AddLabel( 50, 80 + (i * 20), LabelHue, craftGroup.NameString );
}
return craftGroupCol.Count;
}
public static int GetButtonID( int type, int index )
{
return 1 + type + (index * 7);
}
public void CraftItem( CraftItem item )
{
int num = m_CraftSystem.CanCraft( m_From, m_Tool, item.ItemType );
if ( num > 0 )
{
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, num ) );
}
else
{
Type type = null;
CraftContext context = m_CraftSystem.GetContext( m_From );
if ( context != null )
{
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
int resIndex = ( context.LastResourceIndex );
if ( resIndex >= 0 && resIndex < res.Count )
type = res.GetAt( resIndex ).ItemType;
}
m_CraftSystem.CreateItem( m_From, item.ItemType, type, m_Tool, item );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID <= 0 )
return; // Canceled
int buttonID = info.ButtonID - 1;
int type = buttonID % 7;
int index = buttonID / 7;
CraftSystem system = m_CraftSystem;
CraftGroupCol groups = system.CraftGroups;
CraftContext context = system.GetContext( m_From );
switch ( type )
{
case 0: // Show group
{
if ( context == null )
break;
if ( index >= 0 && index < groups.Count )
{
context.LastGroupIndex = index;
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
}
break;
}
case 1: // Create item
{
if ( context == null )
break;
int groupIndex = context.LastGroupIndex;
if ( groupIndex >= 0 && groupIndex < groups.Count )
{
CraftGroup group = groups.GetAt( groupIndex );
if ( index >= 0 && index < group.CraftItems.Count )
CraftItem( group.CraftItems.GetAt( index ) );
}
break;
}
case 2: // Item details
{
if ( context == null )
break;
int groupIndex = context.LastGroupIndex;
if ( groupIndex >= 0 && groupIndex < groups.Count )
{
CraftGroup group = groups.GetAt( groupIndex );
if ( index >= 0 && index < group.CraftItems.Count )
m_From.SendGump( new CraftGumpItem( m_From, system, group.CraftItems.GetAt( index ), m_Tool ) );
}
break;
}
case 3: // Create item (last 10)
{
if ( context == null )
break;
List<CraftItem> lastTen = context.Items;
if ( index >= 0 && index < lastTen.Count )
CraftItem( lastTen[index] );
break;
}
case 4: // Item details (last 10)
{
if ( context == null )
break;
List<CraftItem> lastTen = context.Items;
if ( index >= 0 && index < lastTen.Count )
m_From.SendGump( new CraftGumpItem( m_From, system, lastTen[index], m_Tool ) );
break;
}
case 5: // Resource selected
{
if ( m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count )
{
int groupIndex = ( context == null ? -1 : context.LastGroupIndex );
CraftSubRes res = system.CraftSubRes.GetAt( index );
if ( SkillCheck.TradeSkill( m_From, system.MainSkill, false ) < res.RequiredSkill )
{
m_From.SendGump( new CraftGump( m_From, system, m_Tool, res.Message ) );
}
else
{
if ( context != null )
context.LastResourceIndex = index;
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
}
}
break;
}
case 6: // Misc. buttons
{
switch ( index )
{
case 0: // Resource selection
{
if ( system.CraftSubRes.Init )
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null, CraftPage.PickResource ) );
break;
}
case 1: // Smelt item
{
if ( system.Resmelt )
Resmelt.Do( m_From, system, m_Tool );
break;
}
case 2: // Make last
{
if ( context == null )
break;
CraftItem item = context.LastMade;
if ( item != null )
CraftItem( item );
else
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, 1044165, m_Page ) ); // You haven't made anything yet.
break;
}
case 3: // Last 10
{
if ( context == null )
break;
context.LastGroupIndex = 501;
m_From.SendGump( new CraftGump( m_From, system, m_Tool, null ) );
break;
}
case 4: // Toggle use resource hue
{
if ( context == null )
break;
context.DoNotColor = !context.DoNotColor;
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, null, m_Page ) );
break;
}
case 5: // Repair item
{
if ( system.Repair )
Repair.Do( m_From, system, m_Tool );
break;
}
case 6: // Toggle mark option
{
if ( context == null || !system.MarkOption )
break;
switch ( context.MarkOption )
{
case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;
case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;
case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
}
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, null, m_Page ) );
break;
}
}
break;
}
}
}
}
}

View file

@ -0,0 +1,244 @@
using System;
using Server.Gumps;
using Server.Network;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
namespace Server.Engines.Craft
{
public class CraftGumpItem : Gump
{
private Mobile m_From;
private CraftSystem m_CraftSystem;
private CraftItem m_CraftItem;
private BaseTool m_Tool;
private const int LabelHue = 0x480; // 0x384
private const int RedLabelHue = 0x20;
private const int LabelColor = 0x7FFF;
private const int RedLabelColor = 0x6400;
private const int GreyLabelColor = 0x3DEF;
private int m_OtherCount;
public CraftGumpItem( Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool ) : base( 40, 40 )
{
m_From = from;
m_CraftSystem = craftSystem;
m_CraftItem = craftItem;
m_Tool = tool;
from.CloseGump( typeof( CraftGump ) );
from.CloseGump( typeof( CraftGumpItem ) );
AddPage( 0 );
AddBackground( 0, 0, 530, 417, 5054 );
AddImageTiled( 10, 10, 510, 22, 2624 );
AddImageTiled( 10, 37, 150, 148, 2624 );
AddImageTiled( 165, 37, 355, 90, 2624 );
AddImageTiled( 10, 190, 155, 22, 2624 );
AddImageTiled( 10, 217, 150, 53, 2624 );
AddImageTiled( 165, 132, 355, 80, 2624 );
AddImageTiled( 10, 275, 155, 22, 2624 );
AddImageTiled( 10, 302, 150, 53, 2624 );
AddImageTiled( 165, 217, 355, 80, 2624 );
AddImageTiled( 10, 360, 155, 22, 2624 );
AddImageTiled( 165, 302, 355, 80, 2624 );
AddImageTiled( 10, 387, 510, 22, 2624 );
AddAlphaRegion( 10, 10, 510, 399 );
AddHtmlLocalized( 170, 40, 150, 20, 1044053, LabelColor, false, false ); // ITEM
AddHtmlLocalized( 10, 192, 150, 22, 1044054, LabelColor, false, false ); // <CENTER>SKILLS</CENTER>
AddHtmlLocalized( 10, 277, 150, 22, 1044055, LabelColor, false, false ); // <CENTER>MATERIALS</CENTER>
AddHtmlLocalized( 10, 362, 150, 22, 1044056, LabelColor, false, false ); // <CENTER>OTHER</CENTER>
if ( craftSystem.GumpTitleNumber > 0 )
AddHtmlLocalized( 10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false );
else
AddHtml( 10, 12, 510, 20, craftSystem.GumpTitleString, false, false );
AddButton( 15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 390, 150, 18, 1044150, LabelColor, false, false ); // BACK
AddButton( 270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 305, 390, 150, 18, 1044151, LabelColor, false, false ); // MAKE NOW
if ( craftItem.NameNumber > 0 )
AddHtmlLocalized( 330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false );
else
AddLabel( 330, 40, LabelHue, craftItem.NameString );
if ( craftItem.UseAllRes )
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1048176, LabelColor, false, false ); // Makes as many as possible at once
DrawItem();
DrawSkill();
DrawResource();
}
private bool m_ShowExceptionalChance;
public void DrawItem()
{
Type type = m_CraftItem.ItemType;
AddItem( 20, 50, CraftItem.ItemIDOf( type ) );
if ( m_CraftItem.IsMarkable( type ) )
{
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1044059, LabelColor, false, false ); // This item may hold its maker's mark
m_ShowExceptionalChance = true;
}
}
public void DrawSkill()
{
for ( int i = 0; i < m_CraftItem.Skills.Count; i++ )
{
CraftSkill skill = m_CraftItem.Skills.GetAt( i );
double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;
if ( minSkill < 0 )
minSkill = 0;
AddLabel( 170, 132 + (i * 20), LabelHue, SkillCheck.TradeName( skill.SkillToMake ) );
AddLabel( 430, 132 + (i * 20), LabelHue, String.Format( "{0:F1}", minSkill ) );
}
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
int resIndex = -1;
CraftContext context = m_CraftSystem.GetContext( m_From );
if ( context != null )
resIndex = ( context.LastResourceIndex );
bool allRequiredSkills = true;
double chance = m_CraftItem.GetSuccessChance( m_From, resIndex > -1 ? res.GetAt( resIndex ).ItemType : null, m_CraftSystem, ref allRequiredSkills );
double excepChance = m_CraftItem.GetExceptionalChance( m_CraftSystem, chance, m_From );
if ( chance < 0.0 )
chance = 0.0;
else if ( chance > 1.0 )
chance = 1.0;
AddHtmlLocalized( 170, 80, 250, 18, 1044057, LabelColor, false, false ); // Success Chance:
AddLabel( 430, 80, LabelHue, String.Format( "{0:F1}%", chance * 100 ) );
if ( m_ShowExceptionalChance )
{
if( excepChance < 0.0 )
excepChance = 0.0;
else if( excepChance > 1.0 )
excepChance = 1.0;
AddHtmlLocalized( 170, 100, 250, 18, 1044058, 32767, false, false ); // Exceptional Chance:
AddLabel( 430, 100, LabelHue, String.Format( "{0:F1}%", excepChance * 100 ) );
}
}
private static Type typeofBlankScroll = typeof( BlankScroll );
private static Type typeofSpellScroll = typeof( SpellScroll );
public void DrawResource()
{
bool retainedColor = false;
CraftContext context = m_CraftSystem.GetContext( m_From );
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
int resIndex = -1;
if ( context != null )
resIndex = ( context.LastResourceIndex );
bool cropScroll = ( m_CraftItem.Resources.Count > 1 )
&& m_CraftItem.Resources.GetAt( m_CraftItem.Resources.Count - 1 ).ItemType == typeofBlankScroll
&& typeofSpellScroll.IsAssignableFrom( m_CraftItem.ItemType );
for ( int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++ )
{
Type type;
string nameString;
int nameNumber;
CraftRes craftResource = m_CraftItem.Resources.GetAt( i );
type = craftResource.ItemType;
nameString = craftResource.NameString;
nameNumber = craftResource.NameNumber;
// Resource Mutation
if ( type == res.ResType && resIndex > -1 )
{
CraftSubRes subResource = res.GetAt( resIndex );
type = subResource.ItemType;
nameString = subResource.NameString;
nameNumber = subResource.GenericNameNumber;
if ( nameNumber <= 0 )
nameNumber = subResource.NameNumber;
}
// ******************
if ( !retainedColor && m_CraftItem.RetainsColorFrom( m_CraftSystem, type ) )
{
retainedColor = true;
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1044152, LabelColor, false, false ); // * The item retains the color of this material
AddLabel( 500, 219 + (i * 20), LabelHue, "*" );
}
if ( nameNumber > 0 )
AddHtmlLocalized( 170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false );
else
AddLabel( 170, 219 + (i * 20), LabelHue, nameString );
AddLabel( 430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString() );
}
if ( cropScroll )
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 360, 18, 1044379, LabelColor, false, false ); // Inscribing scrolls also requires a blank scroll and mana.
}
public override void OnResponse( NetState sender, RelayInfo info )
{
// Back Button
if ( info.ButtonID == 0 )
{
CraftGump craftGump = new CraftGump( m_From, m_CraftSystem, m_Tool, null );
m_From.SendGump( craftGump );
}
else // Make Button
{
int num = m_CraftSystem.CanCraft( m_From, m_Tool, m_CraftItem.ItemType );
if ( num > 0 )
{
m_From.SendGump( new CraftGump( m_From, m_CraftSystem, m_Tool, num ) );
}
else
{
Type type = null;
CraftContext context = m_CraftSystem.GetContext( m_From );
if ( context != null )
{
CraftSubResCol res = ( m_CraftSystem.CraftSubRes );
int resIndex = ( context.LastResourceIndex );
if ( resIndex > -1 )
type = res.GetAt( resIndex ).ItemType;
}
m_CraftSystem.CreateItem( m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem );
}
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,58 @@
using System;
namespace Server.Engines.Craft
{
public class CraftItemCol : System.Collections.CollectionBase
{
public CraftItemCol()
{
}
public int Add( CraftItem craftItem )
{
return List.Add( craftItem );
}
public void Remove( int index )
{
if ( index > Count - 1 || index < 0 )
{
}
else
{
List.RemoveAt( index );
}
}
public CraftItem GetAt( int index )
{
return ( CraftItem ) List[index];
}
public CraftItem SearchForSubclass( Type type )
{
for ( int i = 0; i < List.Count; i++ )
{
CraftItem craftItem = ( CraftItem )List[i];
if ( craftItem.ItemType == type || type.IsSubclassOf( craftItem.ItemType ) )
return craftItem;
}
return null;
}
public CraftItem SearchFor( Type type )
{
for ( int i = 0; i < List.Count; i++ )
{
CraftItem craftItem = ( CraftItem )List[i];
if ( craftItem.ItemType == type )
{
return craftItem;
}
}
return null;
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using Server;
namespace Server.Engines.Craft
{
[AttributeUsage( AttributeTargets.Class )]
public class CraftItemIDAttribute : Attribute
{
private int m_ItemID;
public int ItemID{ get{ return m_ItemID; } }
public CraftItemIDAttribute( int itemID )
{
m_ItemID = itemID;
}
}
}

View file

@ -0,0 +1,71 @@
using System;
namespace Server.Engines.Craft
{
public class CraftRes
{
private Type m_Type;
private int m_Amount;
private string m_MessageString;
private int m_MessageNumber;
private string m_NameString;
private int m_NameNumber;
public CraftRes( Type type, int amount )
{
m_Type = type;
m_Amount = amount;
}
public CraftRes( Type type, TextDefinition name, int amount, TextDefinition message ): this ( type, amount )
{
m_NameNumber = name;
m_MessageNumber = message;
m_NameString = name;
m_MessageString = message;
}
public void SendMessage( Mobile from )
{
if ( m_MessageNumber > 0 )
from.SendLocalizedMessage( m_MessageNumber );
else if ( !String.IsNullOrEmpty( m_MessageString ) )
from.SendMessage( m_MessageString );
else
from.SendLocalizedMessage( 502925 ); // You don't have the resources required to make that item.
}
public Type ItemType
{
get { return m_Type; }
}
public string MessageString
{
get { return m_MessageString; }
}
public int MessageNumber
{
get { return m_MessageNumber; }
}
public string NameString
{
get { return m_NameString; }
}
public int NameNumber
{
get { return m_NameNumber; }
}
public int Amount
{
get { return m_Amount; }
}
}
}

View file

@ -0,0 +1,32 @@
using System;
namespace Server.Engines.Craft
{
public class CraftResCol : System.Collections.CollectionBase
{
public CraftResCol()
{
}
public void Add( CraftRes craftRes )
{
List.Add( craftRes );
}
public void Remove( int index )
{
if ( index > Count - 1 || index < 0 )
{
}
else
{
List.RemoveAt( index );
}
}
public CraftRes GetAt( int index )
{
return ( CraftRes ) List[index];
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Server.Misc;
namespace Server.Engines.Craft
{
public class CraftSkill
{
private Trades m_SkillToMake;
private double m_MinSkill;
private double m_MaxSkill;
public CraftSkill( Trades skillToMake, double minSkill, double maxSkill )
{
m_SkillToMake = skillToMake;
m_MinSkill = minSkill;
m_MaxSkill = maxSkill;
}
public Trades SkillToMake
{
get { return m_SkillToMake; }
}
public double MinSkill
{
get { return m_MinSkill; }
}
public double MaxSkill
{
get { return m_MaxSkill; }
}
}
}

View file

@ -0,0 +1,32 @@
using System;
namespace Server.Engines.Craft
{
public class CraftSkillCol : System.Collections.CollectionBase
{
public CraftSkillCol()
{
}
public void Add( CraftSkill craftSkill )
{
List.Add( craftSkill );
}
public void Remove( int index )
{
if ( index > Count - 1 || index < 0 )
{
}
else
{
List.RemoveAt( index );
}
}
public CraftSkill GetAt( int index )
{
return ( CraftSkill ) List[index];
}
}
}

View file

@ -0,0 +1,58 @@
using System;
namespace Server.Engines.Craft
{
public class CraftSubRes
{
private Type m_Type;
private double m_ReqSkill;
private string m_NameString;
private int m_NameNumber;
private int m_GenericNameNumber;
private object m_Message;
public CraftSubRes( Type type, TextDefinition name, double reqSkill, object message ) : this( type, name, reqSkill, 0, message )
{
}
public CraftSubRes( Type type, TextDefinition name, double reqSkill, int genericNameNumber, object message )
{
m_Type = type;
m_NameNumber = name;
m_NameString = name;
m_ReqSkill = reqSkill;
m_GenericNameNumber = genericNameNumber;
m_Message = message;
}
public Type ItemType
{
get { return m_Type; }
}
public string NameString
{
get { return m_NameString; }
}
public int NameNumber
{
get { return m_NameNumber; }
}
public int GenericNameNumber
{
get { return m_GenericNameNumber; }
}
public object Message
{
get { return m_Message; }
}
public double RequiredSkill
{
get { return m_ReqSkill; }
}
}
}

View file

@ -0,0 +1,75 @@
using System;
namespace Server.Engines.Craft
{
public class CraftSubResCol : System.Collections.CollectionBase
{
private Type m_Type;
private string m_NameString;
private int m_NameNumber;
private bool m_Init;
public bool Init
{
get { return m_Init; }
set { m_Init = value; }
}
public Type ResType
{
get { return m_Type; }
set { m_Type = value; }
}
public string NameString
{
get { return m_NameString; }
set { m_NameString = value; }
}
public int NameNumber
{
get { return m_NameNumber; }
set { m_NameNumber = value; }
}
public CraftSubResCol()
{
m_Init = false;
}
public void Add( CraftSubRes craftSubRes )
{
List.Add( craftSubRes );
}
public void Remove( int index )
{
if ( index > Count - 1 || index < 0 )
{
}
else
{
List.RemoveAt( index );
}
}
public CraftSubRes GetAt( int index )
{
return ( CraftSubRes ) List[index];
}
public CraftSubRes SearchFor( Type type )
{
for ( int i = 0; i < List.Count; i++ )
{
CraftSubRes craftSubRes = ( CraftSubRes )List[i];
if ( craftSubRes.ItemType == type )
{
return craftSubRes;
}
}
return null;
}
}
}

View file

@ -0,0 +1,283 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public enum CraftECA
{
ChanceMinusSixty,
FiftyPercentChanceMinusTenPercent,
ChanceMinusSixtyToFourtyFive
}
public abstract class CraftSystem
{
private int m_MinCraftEffect;
private int m_MaxCraftEffect;
private double m_Delay;
private bool m_Resmelt;
private bool m_Repair;
private bool m_MarkOption;
private CraftItemCol m_CraftItems;
private CraftGroupCol m_CraftGroups;
private CraftSubResCol m_CraftSubRes;
public int MinCraftEffect { get { return m_MinCraftEffect; } }
public int MaxCraftEffect { get { return m_MaxCraftEffect; } }
public double Delay { get { return m_Delay; } }
public CraftItemCol CraftItems{ get { return m_CraftItems; } }
public CraftGroupCol CraftGroups{ get { return m_CraftGroups; } }
public CraftSubResCol CraftSubRes{ get { return m_CraftSubRes; } }
public abstract Trades MainSkill{ get; }
public virtual int GumpTitleNumber{ get{ return 0; } }
public virtual string GumpTitleString{ get{ return ""; } }
public virtual CraftECA ECA{ get{ return CraftECA.ChanceMinusSixty; } }
private Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
public abstract double GetChanceAtMin( CraftItem item );
public virtual bool RetainsColorFrom( CraftItem item, Type type )
{
return false;
}
public CraftContext GetContext( Mobile m )
{
if ( m == null )
return null;
if ( m.Deleted )
{
m_ContextTable.Remove( m );
return null;
}
CraftContext c = null;
m_ContextTable.TryGetValue( m, out c );
if ( c == null )
m_ContextTable[m] = c = new CraftContext();
return c;
}
public void OnMade( Mobile m, CraftItem item )
{
CraftContext c = GetContext( m );
if ( c != null )
c.OnMade( item );
}
public bool Resmelt
{
get { return m_Resmelt; }
set { m_Resmelt = value; }
}
public bool Repair
{
get{ return m_Repair; }
set{ m_Repair = value; }
}
public bool MarkOption
{
get{ return m_MarkOption; }
set{ m_MarkOption = value; }
}
public CraftSystem( int minCraftEffect, int maxCraftEffect, double delay )
{
m_MinCraftEffect = minCraftEffect;
m_MaxCraftEffect = maxCraftEffect;
m_Delay = delay;
m_CraftItems = new CraftItemCol();
m_CraftGroups = new CraftGroupCol();
m_CraftSubRes = new CraftSubResCol();
InitCraftList();
}
public virtual bool ConsumeOnFailure( Mobile from, Type resourceType, CraftItem craftItem )
{
return true;
}
public void CreateItem( Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem )
{
// Verify if the type is in the list of the craftable item
CraftItem craftItem = m_CraftItems.SearchFor( type );
if ( craftItem != null )
{
// The item is in the list, try to create it
// Test code: items like sextant parts can be crafted either directly from ingots, or from different parts
realCraftItem.Craft( from, this, typeRes, tool );
//craftItem.Craft( from, this, typeRes, tool );
}
}
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount )
{
return AddCraft( typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "" );
}
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message )
{
return AddCraft( typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, message );
}
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, Trades skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount )
{
return AddCraft( typeItem, group, name, skillToMake, minSkill, maxSkill, typeRes, nameRes, amount, "" );
}
public int AddCraft( Type typeItem, TextDefinition group, TextDefinition name, Trades skillToMake, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount, TextDefinition message )
{
CraftItem craftItem = new CraftItem( typeItem, group, name );
craftItem.AddRes( typeRes, nameRes, amount, message );
craftItem.AddSkill( skillToMake, minSkill, maxSkill );
DoGroup( group, craftItem );
return m_CraftItems.Add( craftItem );
}
private void DoGroup( TextDefinition groupName, CraftItem craftItem )
{
int index = m_CraftGroups.SearchFor( groupName );
if ( index == -1)
{
CraftGroup craftGroup = new CraftGroup( groupName );
craftGroup.AddCraftItem( craftItem );
m_CraftGroups.Add( craftGroup );
}
else
{
m_CraftGroups.GetAt( index ).AddCraftItem( craftItem );
}
}
public void SetManaReq( int index, int mana )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.Mana = mana;
}
public void SetStamReq( int index, int stam )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.Stam = stam;
}
public void SetHitsReq( int index, int hits )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.Hits = hits;
}
public void SetUseAllRes( int index, bool useAll )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.UseAllRes = useAll;
}
public void SetNeedHeat( int index, bool needHeat )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.NeedHeat = needHeat;
}
public void SetNeedOven( int index, bool needOven )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.NeedOven = needOven;
}
public void SetNeedMill( int index, bool needMill )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.NeedMill = needMill;
}
public void SetNeededExpansion( int index, Expansion expansion )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.RequiredExpansion = expansion;
}
public void AddRes( int index, Type type, TextDefinition name, int amount )
{
AddRes( index, type, name, amount, "" );
}
public void AddRes( int index, Type type, TextDefinition name, int amount, TextDefinition message )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.AddRes( type, name, amount, message );
}
public void AddSkill( int index, Trades skillToMake, double minSkill, double maxSkill )
{
CraftItem craftItem = m_CraftItems.GetAt(index);
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
}
public void ForceNonExceptional( int index )
{
CraftItem craftItem = m_CraftItems.GetAt( index );
craftItem.ForceNonExceptional = true;
}
public void SetSubRes( Type type, string name )
{
m_CraftSubRes.ResType = type;
m_CraftSubRes.NameString = name;
m_CraftSubRes.Init = true;
}
public void SetSubRes( Type type, int name )
{
m_CraftSubRes.ResType = type;
m_CraftSubRes.NameNumber = name;
m_CraftSubRes.Init = true;
}
public void AddSubRes( Type type, int name, double reqSkill, object message )
{
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, message );
m_CraftSubRes.Add( craftSubRes );
}
public void AddSubRes( Type type, int name, double reqSkill, int genericName, object message )
{
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, genericName, message );
m_CraftSubRes.Add( craftSubRes );
}
public void AddSubRes( Type type, string name, double reqSkill, object message )
{
CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, message );
m_CraftSubRes.Add( craftSubRes );
}
public abstract void InitCraftList();
public abstract void PlayCraftEffect( Mobile from );
public abstract int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item );
public abstract int CanCraft( Mobile from, BaseTool tool, Type itemType );
}
}

View file

@ -0,0 +1,36 @@
using System;
using Server;
using Server.Items;
namespace Server.Engines.Craft
{
public abstract class CustomCraft
{
private Mobile m_From;
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Type m_TypeRes;
private BaseTool m_Tool;
private int m_Quality;
public Mobile From{ get{ return m_From; } }
public CraftItem CraftItem{ get{ return m_CraftItem; } }
public CraftSystem CraftSystem{ get{ return m_CraftSystem; } }
public Type TypeRes{ get{ return m_TypeRes; } }
public BaseTool Tool{ get{ return m_Tool; } }
public int Quality{ get{ return m_Quality; } }
public CustomCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality )
{
m_From = from;
m_CraftItem = craftItem;
m_CraftSystem = craftSystem;
m_TypeRes = typeRes;
m_Tool = tool;
m_Quality = quality;
}
public abstract void EndCraftAction();
public abstract Item CompleteCraft( out int message );
}
}

View file

@ -0,0 +1,54 @@
using System;
using Server;
using Server.Gumps;
using Server.Items;
namespace Server.Engines.Craft
{
public class QueryMakersMarkGump : Gump
{
private int m_Quality;
private Mobile m_From;
private CraftItem m_CraftItem;
private CraftSystem m_CraftSystem;
private Type m_TypeRes;
private BaseTool m_Tool;
public QueryMakersMarkGump( int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool ) : base( 100, 200 )
{
from.CloseGump( typeof( QueryMakersMarkGump ) );
m_Quality = quality;
m_From = from;
m_CraftItem = craftItem;
m_CraftSystem = craftSystem;
m_TypeRes = typeRes;
m_Tool = tool;
AddPage( 0 );
AddBackground( 0, 0, 220, 170, 5054 );
AddBackground( 10, 10, 200, 150, 3000 );
AddHtmlLocalized( 20, 20, 180, 80, 1018317, false, false ); // Do you wish to place your maker's mark on this item?
AddHtmlLocalized( 55, 100, 140, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 125, 140, 25, 1011012, false, false ); // CANCEL
AddButton( 20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0 );
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
bool makersMark = ( info.ButtonID == 1 );
if ( makersMark )
m_From.SendLocalizedMessage( 501808 ); // You mark the item.
else
m_From.SendLocalizedMessage( 501809 ); // Cancelled mark.
m_CraftItem.CompleteCraft( m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null );
}
}
}

View file

@ -0,0 +1,230 @@
using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class Repair
{
public Repair()
{
}
public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
{
from.Target = new InternalTarget( craftSystem, tool );
from.SendLocalizedMessage( 1044276 ); // Target an item to repair.
}
private class InternalTarget : Target
{
private CraftSystem m_CraftSystem;
private BaseTool m_Tool;
public InternalTarget( CraftSystem craftSystem, BaseTool tool ) : base ( 2, false, TargetFlags.None )
{
m_CraftSystem = craftSystem;
m_Tool = tool;
}
private static void EndGolemRepair( object state )
{
((Mobile)state).EndAction( typeof( Golem ) );
}
private int GetWeakenChance( Mobile mob, Trades trade, int curHits, int maxHits )
{
// 40% - (1% per hp lost) - (1% per 10 craft skill)
return (40 + (maxHits - curHits)) - (int)((SkillCheck.TradeSkill( mob, trade, false ) ) / 10);
}
private bool CheckWeaken( Mobile mob, Trades trade, int curHits, int maxHits )
{
return ( GetWeakenChance( mob, trade, curHits, maxHits ) > Utility.Random( 100 ) );
}
private int GetRepairDifficulty( int curHits, int maxHits )
{
return (((maxHits - curHits) * 1250) / Math.Max( maxHits, 1 )) - 250;
}
private bool CheckRepairDifficulty( Mobile mob, Trades trade, int curHits, int maxHits )
{
double difficulty = GetRepairDifficulty( curHits, maxHits ) * 0.1;
return SkillCheck.TestTrade( mob, trade, difficulty - 25.0, difficulty + 25.0 );
}
private bool IsSpecialClothing( BaseClothing clothing )
{
// Armor repairable but not craftable
if( m_CraftSystem is DefTailoring )
{
return (clothing is BearMask)
|| (clothing is DeerMask);
}
return false;
}
private bool IsSpecialWeapon( BaseWeapon weapon )
{
// Weapons repairable but not craftable
if ( m_CraftSystem is DefTinkering )
{
return ( weapon is Cleaver )
|| ( weapon is Hatchet )
|| ( weapon is Pickaxe )
|| ( weapon is ButcherKnife )
|| ( weapon is SkinningKnife );
}
else if ( m_CraftSystem is DefCarpentry )
{
return ( weapon is Club )
|| ( weapon is BlackStaff );
}
else if ( m_CraftSystem is DefTailoring )
{
return ( weapon is Whip );
}
else if ( m_CraftSystem is DefBlacksmithy )
{
return ( weapon is Pitchfork );
}
return false;
}
protected override void OnTarget( Mobile from, object targeted )
{
int number;
if ( m_CraftSystem.CanCraft( from, m_Tool, targeted.GetType() ) == 1044267 )
{
number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
}
else if ( targeted is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)targeted;
Trades trade = m_CraftSystem.MainSkill;
int toWeaken = 0;
double skillLevel = SkillCheck.TradeSkill( from, trade, false );
if ( skillLevel >= 90.0 )
toWeaken = 1;
else if ( skillLevel >= 70.0 )
toWeaken = 2;
else
toWeaken = 3;
if ( m_CraftSystem.CraftItems.SearchForSubclass( weapon.GetType() ) == null && !IsSpecialWeapon( weapon ) )
{
number = 1044277; // That item cannot be repaired.
}
else if ( !weapon.IsChildOf( from.Backpack ) )
{
number = 1044275; // The item must be in your backpack to repair it.
}
else if ( weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints )
{
number = 1044281; // That item is in full repair
}
else if ( weapon.MaxHitPoints <= toWeaken )
{
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
}
else
{
if ( CheckWeaken( from, trade, weapon.HitPoints, weapon.MaxHitPoints ) )
{
weapon.MaxHitPoints -= toWeaken;
weapon.HitPoints = Math.Max( 0, weapon.HitPoints - toWeaken );
}
if ( CheckRepairDifficulty( from, trade, weapon.HitPoints, weapon.MaxHitPoints ) )
{
number = 1044279; // You repair the item.
m_CraftSystem.PlayCraftEffect( from );
weapon.HitPoints = weapon.MaxHitPoints;
}
else
{
number = 1044280; // You fail to repair the item.
m_CraftSystem.PlayCraftEffect( from );
}
}
}
else if ( targeted is BaseArmor )
{
BaseArmor armor = (BaseArmor)targeted;
Trades trade = m_CraftSystem.MainSkill;
int toWeaken = 0;
double skillLevel = SkillCheck.TradeSkill( from, trade, false );
if ( skillLevel >= 90.0 )
toWeaken = 1;
else if ( skillLevel >= 70.0 )
toWeaken = 2;
else
toWeaken = 3;
if ( m_CraftSystem.CraftItems.SearchForSubclass( armor.GetType() ) == null )
{
number = 1044277; // That item cannot be repaired.
}
else if ( !armor.IsChildOf( from.Backpack ) )
{
number = 1044275; // The item must be in your backpack to repair it.
}
else if ( armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints )
{
number = 1044281; // That item is in full repair
}
else if ( armor.MaxHitPoints <= toWeaken )
{
number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
}
else
{
if ( CheckWeaken( from, trade, armor.HitPoints, armor.MaxHitPoints ) )
{
armor.MaxHitPoints -= toWeaken;
armor.HitPoints = Math.Max( 0, armor.HitPoints - toWeaken );
}
if ( CheckRepairDifficulty( from, trade, armor.HitPoints, armor.MaxHitPoints ) )
{
number = 1044279; // You repair the item.
m_CraftSystem.PlayCraftEffect( from );
armor.HitPoints = armor.MaxHitPoints;
}
else
{
number = 1044280; // You fail to repair the item.
m_CraftSystem.PlayCraftEffect( from );
}
}
}
else if ( targeted is Item )
{
number = 1044277;
}
else
{
number = 500426; // You can't repair that.
}
CraftContext context = m_CraftSystem.GetContext( from );
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
}
}
}
}

View file

@ -0,0 +1,147 @@
using System;
using Server;
using Server.Targeting;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public enum SmeltResult
{
Success,
Invalid,
NoSkill
}
public class Resmelt
{
public Resmelt()
{
}
public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
{
int num = craftSystem.CanCraft( from, tool, null );
if ( num > 0 && num != 1044267 )
{
from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
}
else
{
from.Target = new InternalTarget( craftSystem, tool );
from.SendLocalizedMessage( 1044273 ); // Target an item to recycle.
}
}
private class InternalTarget : Target
{
private CraftSystem m_CraftSystem;
private BaseTool m_Tool;
public InternalTarget( CraftSystem craftSystem, BaseTool tool ) : base ( 2, false, TargetFlags.None )
{
m_CraftSystem = craftSystem;
m_Tool = tool;
}
private SmeltResult Resmelt( Mobile from, Item item, CraftResource resource )
{
try
{
if ( CraftResources.GetType( resource ) != CraftResourceType.Metal )
return SmeltResult.Invalid;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if ( info == null || info.ResourceTypes.Length == 0 )
return SmeltResult.Invalid;
CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor( item.GetType() );
if ( craftItem == null || craftItem.Resources.Count == 0 )
return SmeltResult.Invalid;
CraftRes craftResource = craftItem.Resources.GetAt( 0 );
if ( craftResource.Amount < 2 )
return SmeltResult.Invalid; // Not enough metal to resmelt
double difficulty = 0.0;
if ( difficulty > SkillCheck.TradeSkill( from, Trades.Mining, false ) )
return SmeltResult.NoSkill;
Type resourceType = info.ResourceTypes[0];
Item ingot = (Item)Activator.CreateInstance( resourceType );
if ( (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed) )
ingot.Amount = craftResource.Amount / 2;
else
ingot.Amount = 1;
item.Delete();
from.AddToBackpack( ingot );
from.PlaySound( 0x2A );
from.PlaySound( 0x240 );
return SmeltResult.Success;
}
catch
{
}
return SmeltResult.Invalid;
}
protected override void OnTarget( Mobile from, object targeted )
{
int num = m_CraftSystem.CanCraft( from, m_Tool, null );
if ( num > 0 )
{
if ( num == 1044267 )
{
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
if ( !anvil )
num = 1044266; // You must be near an anvil
else if ( !forge )
num = 1044265; // You must be near a forge.
}
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, num ) );
}
else
{
SmeltResult result = SmeltResult.Invalid;
bool isStoreBought = false;
int message;
if ( targeted is BaseArmor )
{
result = Resmelt( from, (BaseArmor)targeted, ((BaseArmor)targeted).Resource );
isStoreBought = !((BaseArmor)targeted).PlayerConstructed;
}
else if ( targeted is BaseWeapon )
{
result = Resmelt( from, (BaseWeapon)targeted, ((BaseWeapon)targeted).Resource );
isStoreBought = !((BaseWeapon)targeted).PlayerConstructed;
}
switch ( result )
{
default:
case SmeltResult.Invalid: message = 1044272; break; // You can't melt that down into ingots.
case SmeltResult.NoSkill: message = 1044269; break; // You have no idea how to work this metal.
case SmeltResult.Success: message = isStoreBought ? 500418 : 1044270; break; // You melt the item down into ingots.
}
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, message ) );
}
}
}
}
}

View file

@ -0,0 +1,159 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefAlchemy : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Alchemy; }
}
public override int GumpTitleNumber
{
get { return 1044001; } // <CENTER>ALCHEMY MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefAlchemy();
return m_CraftSystem;
}
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
private DefAlchemy() : base( 1, 1, 1.25 )// base( 1, 1, 3.1 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( 0x242 );
}
private static Type typeofPotion = typeof( BasePotion );
public static bool IsPotion( Type type )
{
return typeofPotion.IsAssignableFrom( type );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( IsPotion( item.ItemType ) )
{
from.AddToBackpack( new Bottle() );
return 500287; // You fail to create a useful potion.
}
else
{
return 1044043; // You failed to create the item, and some of your materials are lost.
}
}
else
{
from.PlaySound( 0x240 ); // Sound of a filling bottle
if ( IsPotion( item.ItemType ) )
{
if ( quality == -1 )
return 1048136; // You create the potion and pour it into a keg.
else
return 500279; // You pour the potion into a bottle...
}
else
{
return 1044154; // You create the item.
}
}
}
public override void InitCraftList()
{
int index = -1;
// Refresh Potion
index = AddCraft( typeof( RefreshPotion ), 1044530, 1044538, -25, 25.0, typeof( BlackPearl ), 1044353, 1, 1044361 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( TotalRefreshPotion ), 1044530, 1044539, 25.0, 75.0, typeof( BlackPearl ), 1044353, 5, 1044361 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Agility Potion
index = AddCraft( typeof( AgilityPotion ), 1044531, 1044540, 15.0, 65.0, typeof( Bloodmoss ), 1044354, 1, 1044362 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterAgilityPotion ), 1044531, 1044541, 35.0, 85.0, typeof( Bloodmoss ), 1044354, 3, 1044362 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Nightsight Potion
index = AddCraft( typeof( NightSightPotion ), 1044532, 1044542, -25.0, 25.0, typeof( SpidersSilk ), 1044360, 1, 1044368 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Heal Potion
index = AddCraft( typeof( LesserHealPotion ), 1044533, 1044543, -25.0, 25.0, typeof( Ginseng ), 1044356, 1, 1044364 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( HealPotion ), 1044533, 1044544, 15.0, 65.0, typeof( Ginseng ), 1044356, 3, 1044364 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterHealPotion ), 1044533, 1044545, 55.0, 105.0, typeof( Ginseng ), 1044356, 7, 1044364 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Strength Potion
index = AddCraft( typeof( StrengthPotion ), 1044534, 1044546, 25.0, 75.0, typeof( MandrakeRoot ), 1044357, 2, 1044365 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterStrengthPotion ), 1044534, 1044547, 45.0, 95.0, typeof( MandrakeRoot ), 1044357, 5, 1044365 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Poison Potion
index = AddCraft( typeof( LesserPoisonPotion ), 1044535, 1044548, -5.0, 45.0, typeof( Nightshade ), 1044358, 1, 1044366 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( PoisonPotion ), 1044535, 1044549, 15.0, 65.0, typeof( Nightshade ), 1044358, 2, 1044366 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterPoisonPotion ), 1044535, 1044550, 55.0, 105.0, typeof( Nightshade ), 1044358, 4, 1044366 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( DeadlyPoisonPotion ), 1044535, 1044551, 90.0, 140.0, typeof( Nightshade ), 1044358, 8, 1044366 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Cure Potion
index = AddCraft( typeof( LesserCurePotion ), 1044536, 1044552, -10.0, 40.0, typeof( Garlic ), 1044355, 1, 1044363 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( CurePotion ), 1044536, 1044553, 25.0, 75.0, typeof( Garlic ), 1044355, 3, 1044363 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterCurePotion ), 1044536, 1044554, 65.0, 115.0, typeof( Garlic ), 1044355, 6, 1044363 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
// Explosion Potion
index = AddCraft( typeof( LesserExplosionPotion ), 1044537, 1044555, 5.0, 55.0, typeof( SulfurousAsh ), 1044359, 3, 1044367 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( ExplosionPotion ), 1044537, 1044556, 35.0, 85.0, typeof( SulfurousAsh ), 1044359, 5, 1044367 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
index = AddCraft( typeof( GreaterExplosionPotion ), 1044537, 1044557, 65.0, 115.0, typeof( SulfurousAsh ), 1044359, 10, 1044367 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
}
}
}

View file

@ -0,0 +1,307 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefBlacksmithy : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Blacksmith; }
}
public override int GumpTitleNumber
{
get { return 1044002; } // <CENTER>BLACKSMITHY MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefBlacksmithy();
return m_CraftSystem;
}
}
public override CraftECA ECA{ get{ return CraftECA.ChanceMinusSixtyToFourtyFive; } }
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
private DefBlacksmithy() : base( 1, 1, 1.25 )// base( 1, 2, 1.7 )
{
/*
base( MinCraftEffect, MaxCraftEffect, Delay )
MinCraftEffect : The minimum number of time the mobile will play the craft effect
MaxCraftEffect : The maximum number of time the mobile will play the craft effect
Delay : The delay between each craft effect
Example: (3, 6, 1.7) would make the mobile do the PlayCraftEffect override
function between 3 and 6 time, with a 1.7 second delay each time.
*/
}
private static Type typeofAnvil = typeof( AnvilAttribute );
private static Type typeofForge = typeof( ForgeAttribute );
public static void CheckAnvilAndForge( Mobile from, int range, out bool anvil, out bool forge )
{
anvil = false;
forge = false;
Map map = from.Map;
if ( map == null )
return;
IPooledEnumerable eable = map.GetItemsInRange( from.Location, range );
foreach ( Item item in eable )
{
Type type = item.GetType();
bool isAnvil = ( type.IsDefined( typeofAnvil, false ) || item.ItemID == 4015 || item.ItemID == 4016 || item.ItemID == 0x2DD5 || item.ItemID == 0x2DD6 );
bool isForge = ( type.IsDefined( typeofForge, false ) || item.ItemID == 4017 || (item.ItemID >= 6522 && item.ItemID <= 6569) || item.ItemID == 0x2DD8 );
if ( isAnvil || isForge )
{
if ( (from.Z + 16) < item.Z || (item.Z + 16) < from.Z || !from.InLOS( item ) )
continue;
anvil = anvil || isAnvil;
forge = forge || isForge;
if ( anvil && forge )
break;
}
}
eable.Free();
for ( int x = -range; (!anvil || !forge) && x <= range; ++x )
{
for ( int y = -range; (!anvil || !forge) && y <= range; ++y )
{
StaticTile[] tiles = map.Tiles.GetStaticTiles( from.X+x, from.Y+y, true );
for ( int i = 0; (!anvil || !forge) && i < tiles.Length; ++i )
{
int id = tiles[i].ID;
bool isAnvil = ( id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6 );
bool isForge = ( id == 4017 || (id >= 6522 && id <= 6569) || id == 0x2DD8 );
if ( isAnvil || isForge )
{
if ( (from.Z + 16) < tiles[i].Z || (tiles[i].Z + 16) < from.Z || !from.InLOS( new Point3D( from.X+x, from.Y+y, tiles[i].Z + (tiles[i].Height/2) + 1 ) ) )
continue;
anvil = anvil || isAnvil;
forge = forge || isForge;
}
}
}
}
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckTool( tool, from ) )
return 1048146; // If you have a tool equipped, you must use that tool.
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
bool anvil, forge;
CheckAnvilAndForge( from, 2, out anvil, out forge );
if ( anvil && forge )
return 0;
return 1044267; // You must be near an anvil and a forge to smith items.
}
public override void PlayCraftEffect( Mobile from )
{
// no animation, instant sound
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
from.PlaySound( 0x2A );
}
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 0.7 ) )
{
m_From = from;
}
protected override void OnTick()
{
m_From.PlaySound( 0x2A );
}
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
/*
Synthax for a SIMPLE craft item
AddCraft( ObjectType, Group, MinSkill, MaxSkill, ResourceType, Amount, Message )
ObjectType : The type of the object you want to add to the build list.
Group : The group in wich the object will be showed in the craft menu.
MinSkill : The minimum of skill value
MaxSkill : The maximum of skill value
ResourceType : The type of the resource the mobile need to create the item
Amount : The amount of the ResourceType it need to create the item
Message : String or Int for Localized. The message that will be sent to the mobile, if the specified resource is missing.
Synthax for a COMPLEXE craft item. A complexe item is an item that need either more than
only one skill, or more than only one resource.
Coming soon....
*/
#region Ringmail
AddCraft( typeof( RingmailGloves ), 1011076, 1025099, 12.0, 62.0, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( RingmailLegs ), 1011076, 1025104, 19.4, 69.4, typeof( IronIngot ), 1044036, 16, 1044037 );
AddCraft( typeof( RingmailArms ), 1011076, 1025103, 16.9, 66.9, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( RingmailChest ), 1011076, 1025100, 21.9, 71.9, typeof( IronIngot ), 1044036, 18, 1044037 );
#endregion
#region Chainmail
AddCraft( typeof( ChainCoif ), 1011077, 1025051, 14.5, 64.5, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( ChainLegs ), 1011077, 1025054, 36.7, 86.7, typeof( IronIngot ), 1044036, 18, 1044037 );
AddCraft( typeof( ChainChest ), 1011077, 1025055, 39.1, 89.1, typeof( IronIngot ), 1044036, 20, 1044037 );
#endregion
#region Platemail
AddCraft( typeof( PlateArms ), 1011078, 1025136, 66.3, 116.3, typeof( IronIngot ), 1044036, 18, 1044037 );
AddCraft( typeof( PlateGloves ), 1011078, 1025140, 58.9, 108.9, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( PlateGorget ), 1011078, 1025139, 56.4, 106.4, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( PlateLegs ), 1011078, 1025137, 68.8, 118.8, typeof( IronIngot ), 1044036, 20, 1044037 );
AddCraft( typeof( PlateChest ), 1011078, 1046431, 75.0, 125.0, typeof( IronIngot ), 1044036, 25, 1044037 );
AddCraft( typeof( FemalePlateChest ), 1011078, 1046430, 44.1, 94.1, typeof( IronIngot ), 1044036, 20, 1044037 );
#endregion
#region Helmets
AddCraft( typeof( Bascinet ), 1011079, 1025132, 8.3, 58.3, typeof( IronIngot ), 1044036, 15, 1044037 );
AddCraft( typeof( CloseHelm ), 1011079, 1025128, 37.9, 87.9, typeof( IronIngot ), 1044036, 15, 1044037 );
AddCraft( typeof( Helmet ), 1011079, 1025130, 37.9, 87.9, typeof( IronIngot ), 1044036, 15, 1044037 );
AddCraft( typeof( NorseHelm ), 1011079, 1025134, 37.9, 87.9, typeof( IronIngot ), 1044036, 15, 1044037 );
AddCraft( typeof( PlateHelm ), 1011079, 1025138, 62.6, 112.6, typeof( IronIngot ), 1044036, 15, 1044037 );
#endregion
#region Shields
AddCraft( typeof( Buckler ), 1011080, 1027027, -25.0, 25.0, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( BronzeShield ), 1011080, 1027026, -15.2, 34.8, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( HeaterShield ), 1011080, 1027030, 24.3, 74.3, typeof( IronIngot ), 1044036, 18, 1044037 );
AddCraft( typeof( MetalShield ), 1011080, 1027035, -10.2, 39.8, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( MetalKiteShield ), 1011080, 1027028, 4.6, 54.6, typeof( IronIngot ), 1044036, 16, 1044037 );
AddCraft( typeof( ChaosShield ), 1011080, 1027107, 85.0, 135.0, typeof( IronIngot ), 1044036, 25, 1044037 );
AddCraft( typeof( OrderShield ), 1011080, 1027108, 85.0, 135.0, typeof( IronIngot ), 1044036, 25, 1044037 );
#endregion
#region Bladed
AddCraft( typeof( Broadsword ), 1011081, 1023934, 35.4, 85.4, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( Cutlass ), 1011081, 1025185, 24.3, 74.3, typeof( IronIngot ), 1044036, 8, 1044037 );
AddCraft( typeof( Dagger ), 1011081, 1023921, -0.4, 49.6, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( Katana ),1011081, 1025119, 44.1, 94.1, typeof( IronIngot ), 1044036, 8, 1044037 );
AddCraft( typeof( Kryss ), 1011081, 1025121, 36.7, 86.7, typeof( IronIngot ), 1044036, 8, 1044037 );
AddCraft( typeof( Longsword ), 1011081, 1023937, 28.0, 78.0, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( Rapier ), 1011081, 1025123, 45.3, 95.3, typeof( IronIngot ), 1044036, 6, 1044037 );
AddCraft( typeof( Scimitar ), 1011081, 1025046, 31.7, 81.7, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( VikingSword ), 1011081, 1025049, 24.3, 74.3, typeof( IronIngot ), 1044036, 14, 1044037 );
#endregion
#region Axes
AddCraft( typeof( Axe ), 1011082, 1023913, 34.2, 84.2, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( BattleAxe ), 1011082, 1023911, 30.5, 80.5, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( DoubleAxe ), 1011082, 1023915, 29.3, 79.3, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( GreatAxe ), 1011082, 1023909, 34.2, 84.2, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( LargeBattleAxe ), 1011082, 1025115, 28.0, 78.0, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( TwoHandedAxe ), 1011082, 1025187, 33.0, 83.0, typeof( IronIngot ), 1044036, 16, 1044037 );
AddCraft( typeof( WarAxe ), 1011082, 1025040, 39.1, 89.1, typeof( IronIngot ), 1044036, 16, 1044037 );
#endregion
#region Pole Arms
AddCraft( typeof( Bardiche ), 1011083, 1023917, 31.7, 81.7, typeof( IronIngot ), 1044036, 18, 1044037 );
AddCraft( typeof( Halberd ), 1011083, 1025183, 39.1, 89.1, typeof( IronIngot ), 1044036, 20, 1044037 );
AddCraft( typeof( Pike ), 1011083, 1029918, 47.0, 97.0, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( Scythe ), 1011083, 1029914, 39.0, 89.0, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( Spear ), 1011083, 1023938, 49.0, 99.0, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( WarFork ), 1011083, 1025125, 42.9, 92.9, typeof( IronIngot ), 1044036, 12, 1044037 );
AddCraft( typeof( Pitchfork ), 1011083, 1023720, 36.1, 86.1, typeof( IronIngot ), 1044036, 12, 1044037 );
#endregion
#region Bashing
AddCraft( typeof( HammerPick ), 1011084, 1025181, 34.2, 84.2, typeof( IronIngot ), 1044036, 16, 1044037 );
AddCraft( typeof( Mace ), 1011084, 1023932, 14.5, 64.5, typeof( IronIngot ), 1044036, 6, 1044037 );
AddCraft( typeof( Maul ), 1011084, 1025179, 19.4, 69.4, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( WarMace ), 1011084, 1025127, 28.0, 78.0, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( WarHammer ), 1011084, 1025177, 34.2, 84.2, typeof( IronIngot ), 1044036, 16, 1044037 );
#endregion
Resmelt = true;
Repair = true;
MarkOption = true;
}
}
public class ForgeAttribute : Attribute
{
public ForgeAttribute()
{
}
}
public class AnvilAttribute : Attribute
{
public AnvilAttribute()
{
}
}
}

View file

@ -0,0 +1,111 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefBowFletching : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Fletching; }
}
public override int GumpTitleNumber
{
get { return 1044006; } // <CENTER>BOWCRAFT AND FLETCHING MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefBowFletching();
return m_CraftSystem;
}
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.5; // 50%
}
private DefBowFletching() : base( 1, 1, 1.25 )// base( 1, 2, 1.7 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( 0x55 );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override CraftECA ECA{ get{ return CraftECA.FiftyPercentChanceMinusTenPercent; } }
public override void InitCraftList()
{
int index = -1;
// Materials
AddCraft( typeof( Kindling ), 1044457, 1023553, 0.0, 00.0, typeof( WoodBoard ), 1044041, 1, 1044351 );
index = AddCraft( typeof( Shaft ), 1044457, 1027124, 0.0, 40.0, typeof( WoodBoard ), 1044041, 1, 1044351 );
SetUseAllRes( index, true );
// Ammunition
index = AddCraft( typeof( Arrow ), 1044565, 1023903, 0.0, 40.0, typeof( Shaft ), 1044560, 1, 1044561 );
AddRes( index, typeof( Feather ), 1044562, 1, 1044563 );
SetUseAllRes( index, true );
index = AddCraft( typeof( Bolt ), 1044565, 1027163, 0.0, 40.0, typeof( Shaft ), 1044560, 1, 1044561 );
AddRes( index, typeof( Feather ), 1044562, 1, 1044563 );
SetUseAllRes( index, true );
// Weapons
AddCraft( typeof( Bow ), 1044566, 1025042, 30.0, 70.0, typeof( WoodBoard ), 1044041, 7, 1044351 );
AddCraft( typeof( Crossbow ), 1044566, 1023919, 60.0, 100.0, typeof( WoodBoard ), 1044041, 7, 1044351 );
AddCraft( typeof( HeavyCrossbow ), 1044566, 1025117, 80.0, 120.0, typeof( WoodBoard ), 1044041, 10, 1044351 );
MarkOption = true;
Repair = true;
}
}
}

View file

@ -0,0 +1,289 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefCarpentry : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Carpentry; }
}
public override int GumpTitleNumber
{
get { return 1044004; } // <CENTER>CARPENTRY MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefCarpentry();
return m_CraftSystem;
}
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.5; // 50%
}
private DefCarpentry() : base( 1, 1, 1.25 )// base( 1, 1, 3.0 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( 0x23D );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
int index = -1;
AddCraft( typeof( BarrelStaves ), 1044294, 1027857, 00.0, 25.0, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddCraft( typeof( BarrelLid ), 1044294, 1027608, 11.0, 36.0, typeof( WoodBoard ), 1044041, 4, 1044351 );
AddCraft( typeof( ShortMusicStand ), 1044294, 1044313, 78.9, 103.9, typeof( WoodBoard ), 1044041, 15, 1044351 );
AddCraft( typeof( TallMusicStand ), 1044294, 1044315, 81.5, 106.5, typeof( WoodBoard ), 1044041, 20, 1044351 );
AddCraft( typeof( Easle ), 1044294, 1044317, 86.8, 111.8, typeof( WoodBoard ), 1044041, 20, 1044351 );
index = AddCraft( typeof( FishingPole ), 1044294, 1023519, 68.4, 93.4, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Tailoring, 40.0, 45.0 );
AddRes( index, typeof( Cloth ), 1044286, 5, 1044287 );
// Furniture
AddCraft( typeof( FootStool ), 1044291, 1022910, 11.0, 36.0, typeof( WoodBoard ), 1044041, 9, 1044351 );
AddCraft( typeof( Stool ), 1044291, 1022602, 11.0, 36.0, typeof( WoodBoard ), 1044041, 9, 1044351 );
AddCraft( typeof( BambooChair ), 1044291, 1044300, 21.0, 46.0, typeof( WoodBoard ), 1044041, 13, 1044351 );
AddCraft( typeof( WoodenChair ), 1044291, 1044301, 21.0, 46.0, typeof( WoodBoard ), 1044041, 13, 1044351 );
AddCraft( typeof( FancyWoodenChairCushion ), 1044291, 1044302, 42.1, 67.1, typeof( WoodBoard ), 1044041, 15, 1044351 );
AddCraft( typeof( WoodenChairCushion ), 1044291, 1044303, 42.1, 67.1, typeof( WoodBoard ), 1044041, 13, 1044351 );
AddCraft( typeof( WoodenBench ), 1044291, 1022860, 52.6, 77.6, typeof( WoodBoard ), 1044041, 17, 1044351 );
AddCraft( typeof( WoodenThrone ), 1044291, 1044304, 52.6, 77.6, typeof( WoodBoard ), 1044041, 17, 1044351 );
AddCraft( typeof( Throne ), 1044291, 1044305, 73.6, 98.6, typeof( WoodBoard ), 1044041, 19, 1044351 );
AddCraft( typeof( Nightstand ), 1044291, 1044306, 42.1, 67.1, typeof( WoodBoard ), 1044041, 17, 1044351 );
AddCraft( typeof( WritingTable ), 1044291, 1022890, 63.1, 88.1, typeof( WoodBoard ), 1044041, 17, 1044351 );
AddCraft( typeof( YewWoodTable ), 1044291, 1044307, 63.1, 88.1, typeof( WoodBoard ), 1044041, 23, 1044351 );
AddCraft( typeof( LargeTable ), 1044291, 1044308, 84.2, 109.2, typeof( WoodBoard ), 1044041, 27, 1044351 );
AddCraft( typeof( StoneChair ), 1044291, 1024635, 55.0, 105.0, typeof( IronOre ), 1072392, 4, 1044513 );
AddCraft( typeof( MediumStoneTableEastDeed ), 1044291, 1044508, 65.0, 115.0, typeof( IronOre ), 1072392, 6, 1044513 );
AddCraft( typeof( MediumStoneTableSouthDeed ), 1044291, 1044509, 65.0, 115.0, typeof( IronOre ), 1072392, 6, 1044513 );
AddCraft( typeof( LargeStoneTableEastDeed ), 1044291, 1044511, 75.0, 125.0, typeof( IronOre ), 1072392, 9, 1044513 );
AddCraft( typeof( LargeStoneTableSouthDeed ), 1044291, 1044512, 75.0, 125.0, typeof( IronOre ), 1072392, 9, 1044513 );
// Containers
AddCraft( typeof( WoodenBox ), 1044292, 1023709, 21.0, 46.0, typeof( WoodBoard ), 1044041, 10, 1044351 );
AddCraft( typeof( SmallCrate ), 1044292, 1044309, 10.0, 35.0, typeof( WoodBoard ), 1044041, 8 , 1044351 );
AddCraft( typeof( MediumCrate ), 1044292, 1044310, 31.0, 56.0, typeof( WoodBoard ), 1044041, 15, 1044351 );
AddCraft( typeof( LargeCrate ), 1044292, 1044311, 47.3, 72.3, typeof( WoodBoard ), 1044041, 18, 1044351 );
AddCraft( typeof( WoodenChest ), 1044292, 1023650, 73.6, 98.6, typeof( WoodBoard ), 1044041, 20, 1044351 );
AddCraft( typeof( EmptyBookcase ), 1044292, 1022718, 31.5, 56.5, typeof( WoodBoard ), 1044041, 25, 1044351 );
AddCraft( typeof( FancyArmoire ), 1044292, 1044312, 84.2, 109.2, typeof( WoodBoard ), 1044041, 35, 1044351 );
AddCraft( typeof( Armoire ), 1044292, 1022643, 84.2, 109.2, typeof( WoodBoard ), 1044041, 35, 1044351 );
AddCraft( typeof( CratePlain ), 1044292, 1045025, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateCarpenter ), 1044292, 1045026, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateJewels ), 1044292, 1045027, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateWizard ), 1044292, 1045028, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateSmithing ), 1044292, 1045029, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateProvisions ), 1044292, 1045030, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateTailor ), 1044292, 1045031, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateMaps ), 1044292, 1045032, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateSailing ), 1044292, 1045033, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateInn ), 1044292, 1045034, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateArms ), 1044292, 1045035, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateStable ), 1044292, 1045036, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateFletcher ), 1044292, 1045037, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateMeat ), 1044292, 1045038, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateTinker ), 1044292, 1045039, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CratePotions ), 1044292, 1045040, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateFood ), 1044292, 1045041, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateGold ), 1044292, 1045042, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateBard ), 1044292, 1045043, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateWax ), 1044292, 1045044, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateBooks ), 1044292, 1045045, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateBows ), 1044292, 1045046, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateHealer ), 1044292, 1045047, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
AddCraft( typeof( CrateTavern ), 1044292, 1045048, 57.3, 82.3, typeof( WoodBoard ), 1044041, 22, 1044351 );
index = AddCraft( typeof( Keg ), 1044292, 1023711, 57.8, 82.8, typeof( BarrelStaves ), 1044288, 3, 1044253 );
AddRes( index, typeof( BarrelHoops ), 1044289, 1, 1044253 );
AddRes( index, typeof( BarrelLid ), 1044251, 1, 1044253 );
// Staves and Shields
AddCraft( typeof( ShepherdsCrook ), 1044295, 1023713, 78.9, 103.9, typeof( WoodBoard ), 1044041, 7, 1044351 );
AddCraft( typeof( QuarterStaff ), 1044295, 1023721, 73.6, 98.6, typeof( WoodBoard ), 1044041, 6, 1044351 );
AddCraft( typeof( GnarledStaff ), 1044295, 1025112, 78.9, 103.9, typeof( WoodBoard ), 1044041, 7, 1044351 );
AddCraft( typeof( WoodenShield ), 1044295, 1027034, 52.6, 77.6, typeof( WoodBoard ), 1044041, 9, 1044351 );
AddCraft( typeof( WoodenKiteShield ), 1044295, 1027032, 82.6, 97.6, typeof( WoodBoard ), 1044041, 12, 1044351 );
AddCraft( typeof( Club ), 1044295, 1025043, 53.9, 78.9, typeof( WoodBoard ), 1044041, 4, 1044351 );
// Instruments
index = AddCraft( typeof( LapHarp ), 1044293, 1023762, 63.1, 88.1, typeof( WoodBoard ), 1044041, 20, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 10, 1044287 );
index = AddCraft( typeof( Harp ), 1044293, 1023761, 78.9, 103.9, typeof( WoodBoard ), 1044041, 35, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 15, 1044287 );
index = AddCraft( typeof( Drums ), 1044293, 1023740, 57.8, 82.8, typeof( WoodBoard ), 1044041, 20, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 10, 1044287 );
index = AddCraft( typeof( Flute ), 1044293, 1023738, 68.4, 93.4, typeof( WoodBoard ), 1044041, 25, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
index = AddCraft( typeof( Lute ), 1044293, 1023763, 68.4, 93.4, typeof( WoodBoard ), 1044041, 25, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 10, 1044287 );
index = AddCraft( typeof( Pipes ), 1044293, 1023737, 68.4, 93.4, typeof( WoodBoard ), 1044041, 25, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
index = AddCraft( typeof( Tambourine ), 1044293, 1023741, 57.8, 82.8, typeof( WoodBoard ), 1044041, 15, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 10, 1044287 );
index = AddCraft( typeof( TambourineTassel ), 1044293, 1044320, 57.8, 82.8, typeof( WoodBoard ), 1044041, 15, 1044351 );
AddSkill( index, Trades.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 15, 1044287 );
// Misc
index = AddCraft( typeof( SmallBedSouthDeed ), 1044290, 1044321, 94.7, 119.8, typeof( WoodBoard ), 1044041, 100, 1044351 );
AddSkill( index, Trades.Tailoring, 75.0, 80.0 );
AddRes( index, typeof( Cloth ), 1044286, 100, 1044287 );
index = AddCraft(typeof(SmallBedEastDeed), 1044290, 1044322, 94.7, 119.8, typeof(WoodBoard), 1044041, 100, 1044351);
AddSkill( index, Trades.Tailoring, 75.0, 80.0 );
AddRes( index, typeof( Cloth ), 1044286, 100, 1044287 );
index = AddCraft(typeof(LargeBedSouthDeed), 1044290, 1044323, 94.7, 119.8, typeof(WoodBoard), 1044041, 150, 1044351);
AddSkill( index, Trades.Tailoring, 75.0, 80.0 );
AddRes( index, typeof( Cloth ), 1044286, 150, 1044287 );
index = AddCraft(typeof(LargeBedEastDeed), 1044290, 1044324, 94.7, 119.8, typeof(WoodBoard), 1044041, 150, 1044351);
AddSkill( index, Trades.Tailoring, 75.0, 80.0 );
AddRes( index, typeof( Cloth ), 1044286, 150, 1044287 );
AddCraft( typeof( DartBoardSouthDeed ), 1044290, 1044325, 15.7, 40.7, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddCraft( typeof( DartBoardEastDeed ), 1044290, 1044326, 15.7, 40.7, typeof( WoodBoard ), 1044041, 5, 1044351 );
index = AddCraft( typeof( PentagramDeed ), 1044290, 1044328, 100.0, 125.0, typeof( WoodBoard ), 1044041, 100, 1044351 );
AddSkill( index, Trades.Magery, 75.0, 80.0 );
AddRes( index, typeof( IronIngot ), 1044036, 40, 1044037 );
index = AddCraft( typeof( AbbatoirDeed ), 1044290, 1044329, 100.0, 125.0, typeof( IronOre ), 1072392, 100, 1044513 );
AddSkill( index, Trades.Magery, 50.0, 55.0 );
AddRes( index, typeof( IronIngot ), 1044036, 40, 1044037 );
AddCraft( typeof( Vase ), 1044290, 1022888, 52.5, 102.5, typeof( IronOre ), 1072392, 1, 1044513 );
AddCraft( typeof( LargeVase ), 1044290, 1022887, 52.5, 102.5, typeof( IronOre ), 1072392, 3, 1044513 );
AddCraft( typeof( StatueSouth ), 1044290, 1044505, 60.0, 120.0, typeof( IronOre ), 1072392, 3, 1044513 );
AddCraft( typeof( StatueNorth ), 1044290, 1044506, 60.0, 120.0, typeof( IronOre ), 1072392, 3, 1044513 );
AddCraft( typeof( StatueEast ), 1044290, 1044507, 60.0, 120.0, typeof( IronOre ), 1072392, 3, 1044513 );
AddCraft( typeof( StatuePegasus ), 1044290, 1044510, 70.0, 130.0, typeof( IronOre ), 1072392, 4, 1044513 );
// Blacksmithy
index = AddCraft( typeof( SmallForgeDeed ), 1044296, 1044330, 73.6, 98.6, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Blacksmith, 75.0, 80.0 );
AddRes( index, typeof( IronIngot ), 1044036, 75, 1044037 );
index = AddCraft( typeof( LargeForgeEastDeed ), 1044296, 1044331, 78.9, 103.9, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Blacksmith, 80.0, 85.0 );
AddRes( index, typeof( IronIngot ), 1044036, 100, 1044037 );
index = AddCraft( typeof( LargeForgeSouthDeed ), 1044296, 1044332, 78.9, 103.9, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Blacksmith, 80.0, 85.0 );
AddRes( index, typeof( IronIngot ), 1044036, 100, 1044037 );
index = AddCraft( typeof( AnvilEastDeed ), 1044296, 1044333, 73.6, 98.6, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Blacksmith, 75.0, 80.0 );
AddRes( index, typeof( IronIngot ), 1044036, 150, 1044037 );
index = AddCraft( typeof( AnvilSouthDeed ), 1044296, 1044334, 73.6, 98.6, typeof( WoodBoard ), 1044041, 5, 1044351 );
AddSkill( index, Trades.Blacksmith, 75.0, 80.0 );
AddRes( index, typeof( IronIngot ), 1044036, 150, 1044037 );
// Training
index = AddCraft( typeof( TrainingDummyEastDeed ), 1044297, 1044335, 68.4, 93.4, typeof( WoodBoard ), 1044041, 55, 1044351 );
AddSkill( index, Trades.Tailoring, 50.0, 55.0 );
AddRes( index, typeof( Cloth ), 1044286, 60, 1044287 );
index = AddCraft( typeof( TrainingDummySouthDeed ), 1044297, 1044336, 68.4, 93.4, typeof( WoodBoard ), 1044041, 55, 1044351 );
AddSkill( index, Trades.Tailoring, 50.0, 55.0 );
AddRes( index, typeof( Cloth ), 1044286, 60, 1044287 );
index = AddCraft( typeof( PickpocketDipEastDeed ), 1044297, 1044337, 73.6, 98.6, typeof( WoodBoard ), 1044041, 65, 1044351 );
AddSkill( index, Trades.Tailoring, 50.0, 55.0 );
AddRes( index, typeof( Cloth ), 1044286, 60, 1044287 );
index = AddCraft( typeof( PickpocketDipSouthDeed ), 1044297, 1044338, 73.6, 98.6, typeof( WoodBoard ), 1044041, 65, 1044351 );
AddSkill( index, Trades.Tailoring, 50.0, 55.0 );
AddRes( index, typeof( Cloth ), 1044286, 60, 1044287 );
// Tailoring
index = AddCraft( typeof( Dressform ), 1044298, 1044339, 63.1, 88.1, typeof( WoodBoard ), 1044041, 25, 1044351 );
AddSkill( index, Trades.Tailoring, 65.0, 70.0 );
AddRes( index, typeof( Cloth ), 1044286, 10, 1044287 );
index = AddCraft( typeof( SpinningwheelEastDeed ), 1044298, 1044341, 73.6, 98.6, typeof( WoodBoard ), 1044041, 75, 1044351 );
AddSkill( index, Trades.Tailoring, 65.0, 70.0 );
AddRes( index, typeof( Cloth ), 1044286, 25, 1044287 );
index = AddCraft( typeof( SpinningwheelSouthDeed ), 1044298, 1044342, 73.6, 98.6, typeof( WoodBoard ), 1044041, 75, 1044351 );
AddSkill( index, Trades.Tailoring, 65.0, 70.0 );
AddRes( index, typeof( Cloth ), 1044286, 25, 1044287 );
index = AddCraft( typeof( LoomEastDeed ), 1044298, 1044343, 84.2, 109.2, typeof( WoodBoard ), 1044041, 85, 1044351 );
AddSkill( index, Trades.Tailoring, 65.0, 70.0 );
AddRes( index, typeof( Cloth ), 1044286, 25, 1044287 );
index = AddCraft( typeof( LoomSouthDeed ), 1044298, 1044344, 84.2, 109.2, typeof( WoodBoard ), 1044041, 85, 1044351 );
AddSkill( index, Trades.Tailoring, 65.0, 70.0 );
AddRes( index, typeof( Cloth ), 1044286, 25, 1044287 );
// Cooking
index = AddCraft( typeof( Bonfire ), 1044299, 1044230, 84.7, 109.7, typeof( WoodBoard ), 1044041, 100, 1044351 );
AddRes( index, typeof( IronOre ), 1072392, 10, 1044513 );
index = AddCraft( typeof( StoneOvenEastDeed ), 1044299, 1044345, 68.4, 93.4, typeof( WoodBoard ), 1044041, 85, 1044351 );
AddSkill( index, Trades.Tinkering, 50.0, 55.0 );
AddRes( index, typeof( IronIngot ), 1044036, 125, 1044037 );
index = AddCraft( typeof( StoneOvenSouthDeed ), 1044299, 1044346, 68.4, 93.4, typeof( WoodBoard ), 1044041, 85, 1044351 );
AddSkill( index, Trades.Tinkering, 50.0, 55.0 );
AddRes( index, typeof( IronIngot ), 1044036, 125, 1044037 );
index = AddCraft( typeof( FlourMillEastDeed ), 1044299, 1044347, 94.7, 119.7, typeof( WoodBoard ), 1044041, 100, 1044351 );
AddSkill( index, Trades.Tinkering, 50.0, 55.0 );
AddRes( index, typeof( IronIngot ), 1044036, 50, 1044037 );
index = AddCraft( typeof( FlourMillSouthDeed ), 1044299, 1044348, 94.7, 119.7, typeof( WoodBoard ), 1044041, 100, 1044351 );
AddSkill( index, Trades.Tinkering, 50.0, 55.0 );
AddRes( index, typeof( IronIngot ), 1044036, 50, 1044037 );
AddCraft( typeof( WaterTroughEastDeed ), 1044299, 1044349, 94.7, 119.7, typeof( WoodBoard ), 1044041, 150, 1044351 );
AddCraft( typeof( WaterTroughSouthDeed ), 1044299, 1044350, 94.7, 119.7, typeof( WoodBoard ), 1044041, 150, 1044351 );
MarkOption = true;
Repair = true;
}
}
}

View file

@ -0,0 +1,89 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefCartography : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Cartography; }
}
public override int GumpTitleNumber
{
get { return 1044008; } // <CENTER>CARTOGRAPHY MENU</CENTER>
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefCartography();
return m_CraftSystem;
}
}
private DefCartography() : base( 1, 1, 1.25 )// base( 1, 1, 3.0 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( 0x249 );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
AddCraft( typeof( LocalMap ), 1044448, 1015230, 10.0, 70.0, typeof( BlankMap ), 1044449, 1, 1044450 );
AddCraft( typeof( CityMap ), 1044448, 1015231, 25.0, 85.0, typeof( BlankMap ), 1044449, 1, 1044450 );
AddCraft( typeof( SeaChart ), 1044448, 1015232, 35.0, 95.0, typeof( BlankMap ), 1044449, 1, 1044450 );
AddCraft( typeof( WorldMap ), 1044448, 1015233, 39.5, 99.5, typeof( BlankMap ), 1044449, 1, 1044450 );
}
}
}

View file

@ -0,0 +1,203 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefCooking : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Cooking; }
}
public override int GumpTitleNumber
{
get { return 1044003; } // <CENTER>COOKING MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefCooking();
return m_CraftSystem;
}
}
public override CraftECA ECA{ get{ return CraftECA.ChanceMinusSixtyToFourtyFive; } }
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
private DefCooking() : base( 1, 1, 1.25 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public override void PlayCraftEffect( Mobile from )
{
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
int index = -1;
/* Begin Ingredients */
index = AddCraft( typeof( SackFlour ), 1044495, 1024153, 0.0, 100.0, typeof( WheatSheaf ), 1044489, 2, 1044490 );
SetNeedMill( index, true );
index = AddCraft( typeof( Dough ), 1044495, 1024157, 0.0, 100.0, typeof( SackFlour ), 1044468, 1, 1044253 );
AddRes( index, typeof( BaseBeverage ), 1046458, 1, 1044253 );
index = AddCraft( typeof( SweetDough ), 1044495, 1041340, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( JarHoney ), 1044472, 1, 1044253 );
index = AddCraft( typeof( CakeMix ), 1044495, 1041002, 0.0, 100.0, typeof( SackFlour ), 1044468, 1, 1044253 );
AddRes( index, typeof( SweetDough ), 1044475, 1, 1044253 );
index = AddCraft( typeof( CookieMix ), 1044495, 1024159, 0.0, 100.0, typeof( JarHoney ), 1044472, 1, 1044253 );
AddRes( index, typeof( SweetDough ), 1044475, 1, 1044253 );
/* End Ingredients */
/* Begin Preparations */
index = AddCraft( typeof( UnbakedQuiche ), 1044496, 1041339, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Eggs ), 1044477, 1, 1044253 );
// TODO: This must also support chicken and lamb legs
index = AddCraft( typeof( UnbakedMeatPie ), 1044496, 1041338, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( RawRibs ), 1044482, 1, 1044253 );
index = AddCraft( typeof( UncookedSausagePizza ), 1044496, 1041337, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Sausage ), 1044483, 1, 1044253 );
index = AddCraft( typeof( UncookedCheesePizza ), 1044496, 1041341, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( CheeseWheel ), 1044486, 1, 1044253 );
index = AddCraft( typeof( UnbakedFruitPie ), 1044496, 1041334, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Pear ), 1044481, 1, 1044253 );
index = AddCraft( typeof( UnbakedPeachCobbler ), 1044496, 1041335, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Peach ), 1044480, 1, 1044253 );
index = AddCraft( typeof( UnbakedApplePie ), 1044496, 1041336, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Apple ), 1044479, 1, 1044253 );
index = AddCraft( typeof( UnbakedPumpkinPie ), 1044496, 1041342, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
AddRes( index, typeof( Pumpkin ), 1044484, 1, 1044253 );
/* End Preparations */
/* Begin Baking */
index = AddCraft( typeof( BreadLoaf ), 1044497, 1024156, 0.0, 100.0, typeof( Dough ), 1044469, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( Cookies ), 1044497, 1025643, 0.0, 100.0, typeof( CookieMix ), 1044474, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( Cake ), 1044497, 1022537, 0.0, 100.0, typeof( CakeMix ), 1044471, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( Muffins ), 1044497, 1022539, 0.0, 100.0, typeof( SweetDough ), 1044475, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( Quiche ), 1044497, 1041345, 0.0, 100.0, typeof( UnbakedQuiche ), 1044518, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( MeatPie ), 1044497, 1041347, 0.0, 100.0, typeof( UnbakedMeatPie ), 1044519, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( SausagePizza ), 1044497, 1044517, 0.0, 100.0, typeof( UncookedSausagePizza ), 1044520, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( CheesePizza ), 1044497, 1044516, 0.0, 100.0, typeof( UncookedCheesePizza ), 1044521, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( FruitPie ), 1044497, 1041346, 0.0, 100.0, typeof( UnbakedFruitPie ), 1044522, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( PeachCobbler ), 1044497, 1041344, 0.0, 100.0, typeof( UnbakedPeachCobbler ), 1044523, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( ApplePie ), 1044497, 1041343, 0.0, 100.0, typeof( UnbakedApplePie ), 1044524, 1, 1044253 );
SetNeedOven( index, true );
index = AddCraft( typeof( PumpkinPie ), 1044497, 1041348, 0.0, 100.0, typeof( UnbakedPumpkinPie ), 1046461, 1, 1044253 );
SetNeedOven( index, true );
/* End Baking */
/* Begin Barbecue */
index = AddCraft( typeof( CookedBird ), 1044498, 1022487, 0.0, 100.0, typeof( RawBird ), 1044470, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( ChickenLeg ), 1044498, 1025640, 0.0, 100.0, typeof( RawChickenLeg ), 1044473, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( Ham ), 1044498, 1022505, 0.0, 100.0, typeof( RawHam ), 1044499, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( FishSteak ), 1044498, 1022427, 0.0, 100.0, typeof( RawFishSteak ), 1044476, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( FriedEggs ), 1044498, 1022486, 0.0, 100.0, typeof( Eggs ), 1044477, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( LambLeg ), 1044498, 1025642, 0.0, 100.0, typeof( RawLambLeg ), 1044478, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( Ribs ), 1044498, 1022546, 0.0, 100.0, typeof( RawRibs ), 1044485, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
index = AddCraft( typeof( SlabOfBacon ), 1044498, 1022422, 0.0, 100.0, typeof( RawSlabOfBacon ), 1044574, 1, 1044253 );
SetNeedHeat( index, true );
SetUseAllRes( index, true );
/* End Barbecue */
}
}
}

View file

@ -0,0 +1,298 @@
using System;
using Server.Items;
using Server.Misc;
using Server.Spells;
namespace Server.Engines.Craft
{
public class DefInscription : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Inscribe; }
}
public override int GumpTitleNumber
{
get { return 1044009; } // <CENTER>INSCRIPTION MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefInscription();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item)
{
return 0.0; // 0%
}
private DefInscription()
: base(1, 1, 1.25)// base( 1, 1, 3.0 )
{
}
public override int CanCraft(Mobile from, BaseTool tool, Type typeItem)
{
if (tool == null || tool.Deleted || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool!
else if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use.
if (typeItem != null)
{
object o = Activator.CreateInstance(typeItem);
if (o is SpellScroll)
{
SpellScroll scroll = (SpellScroll)o;
Spellbook book = Spellbook.Find(from, scroll.SpellID);
bool hasSpell = (book != null && book.HasSpell(scroll.SpellID));
scroll.Delete();
return (hasSpell ? 0 : 1042404); // null : You don't have that spell!
}
else if (o is Item)
{
((Item)o).Delete();
}
}
return 0;
}
public override void PlayCraftEffect(Mobile from)
{
from.PlaySound(0x249);
}
private static Type typeofSpellScroll = typeof(SpellScroll);
public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item)
{
if (toolBroken)
from.SendLocalizedMessage(1044038); // You have worn out your tool
if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll
{
if (failed)
{
if (lostMaterial)
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if (quality == 0)
return 502785; // You were barely able to make this item. It's quality is below average.
else if (makersMark && quality == 2)
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if (quality == 2)
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
else
{
if (failed)
return 501630; // You fail to inscribe the scroll, and the scroll is ruined.
else
return 501629; // You inscribe the spell and put the scroll in your backpack.
}
}
private int m_Circle, m_Mana;
private enum Reg { BlackPearl, Bloodmoss, Garlic, Ginseng, MandrakeRoot, Nightshade, SulfurousAsh, SpidersSilk }
private Type[] m_RegTypes = new Type[]
{
typeof( BlackPearl ),
typeof( Bloodmoss ),
typeof( Garlic ),
typeof( Ginseng ),
typeof( MandrakeRoot ),
typeof( Nightshade ),
typeof( SulfurousAsh ),
typeof( SpidersSilk )
};
private int m_Index;
private void AddSpell(Type type, params Reg[] regs)
{
double minSkill, maxSkill;
switch (m_Circle)
{
default:
case 0: minSkill = -25.0; maxSkill = 25.0; break;
case 1: minSkill = -10.8; maxSkill = 39.2; break;
case 2: minSkill = 03.5; maxSkill = 53.5; break;
case 3: minSkill = 17.8; maxSkill = 67.8; break;
case 4: minSkill = 32.1; maxSkill = 82.1; break;
case 5: minSkill = 46.4; maxSkill = 96.4; break;
case 6: minSkill = 60.7; maxSkill = 110.7; break;
case 7: minSkill = 75.0; maxSkill = 125.0; break;
}
int index = AddCraft(type, 1044369 + m_Circle, 1044381 + m_Index++, minSkill, maxSkill, m_RegTypes[(int)regs[0]], 1044353 + (int)regs[0], 1, 1044361 + (int)regs[0]);
for (int i = 1; i < regs.Length; ++i)
AddRes(index, m_RegTypes[(int)regs[i]], 1044353 + (int)regs[i], 1, 1044361 + (int)regs[i]);
AddRes(index, typeof(BlankScroll), 1044377, 1, 1044378);
SetManaReq(index, m_Mana);
}
public override void InitCraftList()
{
m_Circle = 0;
m_Mana = 4;
AddSpell(typeof(ReactiveArmorScroll), Reg.Garlic, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(ClumsyScroll), Reg.Bloodmoss, Reg.Nightshade);
AddSpell(typeof(CreateFoodScroll), Reg.Garlic, Reg.Ginseng, Reg.MandrakeRoot);
AddSpell(typeof(FeeblemindScroll), Reg.Nightshade, Reg.Ginseng);
AddSpell(typeof(HealScroll), Reg.Garlic, Reg.Ginseng, Reg.SpidersSilk);
AddSpell(typeof(MagicArrowScroll), Reg.SulfurousAsh);
AddSpell(typeof(NightSightScroll), Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(WeakenScroll), Reg.Garlic, Reg.Nightshade);
m_Circle = 1;
m_Mana = 6;
AddSpell(typeof(AgilityScroll), Reg.Bloodmoss, Reg.MandrakeRoot);
AddSpell(typeof(CunningScroll), Reg.Nightshade, Reg.MandrakeRoot);
AddSpell(typeof(CureScroll), Reg.Garlic, Reg.Ginseng);
AddSpell(typeof(HarmScroll), Reg.Nightshade, Reg.SpidersSilk);
AddSpell(typeof(MagicTrapScroll), Reg.Garlic, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(MagicUnTrapScroll), Reg.Bloodmoss, Reg.SulfurousAsh);
AddSpell(typeof(ProtectionScroll), Reg.Garlic, Reg.Ginseng, Reg.SulfurousAsh);
AddSpell(typeof(StrengthScroll), Reg.Nightshade, Reg.MandrakeRoot);
m_Circle = 2;
m_Mana = 9;
AddSpell(typeof(BlessScroll), Reg.Garlic, Reg.MandrakeRoot);
AddSpell(typeof(FireballScroll), Reg.BlackPearl);
AddSpell(typeof(MagicLockScroll), Reg.Bloodmoss, Reg.Garlic, Reg.SulfurousAsh);
AddSpell(typeof(PoisonScroll), Reg.Nightshade);
AddSpell(typeof(TelekinisisScroll), Reg.Bloodmoss, Reg.MandrakeRoot);
AddSpell(typeof(TeleportScroll), Reg.Bloodmoss, Reg.MandrakeRoot);
AddSpell(typeof(UnlockScroll), Reg.Bloodmoss, Reg.SulfurousAsh);
AddSpell(typeof(WallOfStoneScroll), Reg.Bloodmoss, Reg.Garlic);
m_Circle = 3;
m_Mana = 11;
AddSpell(typeof(ArchCureScroll), Reg.Garlic, Reg.Ginseng, Reg.MandrakeRoot);
AddSpell(typeof(ArchProtectionScroll), Reg.Garlic, Reg.Ginseng, Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(CurseScroll), Reg.Garlic, Reg.Nightshade, Reg.SulfurousAsh);
AddSpell(typeof(FireFieldScroll), Reg.BlackPearl, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(GreaterHealScroll), Reg.Garlic, Reg.SpidersSilk, Reg.MandrakeRoot, Reg.Ginseng);
AddSpell(typeof(LightningScroll), Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(ManaDrainScroll), Reg.BlackPearl, Reg.SpidersSilk, Reg.MandrakeRoot);
AddSpell(typeof(RecallScroll), Reg.BlackPearl, Reg.Bloodmoss, Reg.MandrakeRoot);
m_Circle = 4;
m_Mana = 14;
AddSpell(typeof(BladeSpiritsScroll), Reg.BlackPearl, Reg.Nightshade, Reg.MandrakeRoot);
AddSpell(typeof(DispelFieldScroll), Reg.BlackPearl, Reg.Garlic, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(IncognitoScroll), Reg.Bloodmoss, Reg.Garlic, Reg.Nightshade);
AddSpell(typeof(MagicReflectScroll), Reg.Garlic, Reg.MandrakeRoot, Reg.SpidersSilk);
AddSpell(typeof(MindBlastScroll), Reg.BlackPearl, Reg.MandrakeRoot, Reg.Nightshade, Reg.SulfurousAsh);
AddSpell(typeof(ParalyzeScroll), Reg.Garlic, Reg.MandrakeRoot, Reg.SpidersSilk);
AddSpell(typeof(PoisonFieldScroll), Reg.BlackPearl, Reg.Nightshade, Reg.SpidersSilk);
AddSpell(typeof(SummonCreatureScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
m_Circle = 5;
m_Mana = 20;
AddSpell(typeof(DispelScroll), Reg.Garlic, Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(EnergyBoltScroll), Reg.BlackPearl, Reg.Nightshade);
AddSpell(typeof(ExplosionScroll), Reg.Bloodmoss, Reg.MandrakeRoot);
AddSpell(typeof(InvisibilityScroll), Reg.Bloodmoss, Reg.Nightshade);
AddSpell(typeof(MarkScroll), Reg.Bloodmoss, Reg.BlackPearl, Reg.MandrakeRoot);
AddSpell(typeof(MassCurseScroll), Reg.Garlic, Reg.MandrakeRoot, Reg.Nightshade, Reg.SulfurousAsh);
AddSpell(typeof(ParalyzeFieldScroll), Reg.BlackPearl, Reg.Ginseng, Reg.SpidersSilk);
AddSpell(typeof(RevealScroll), Reg.Bloodmoss, Reg.SulfurousAsh);
m_Circle = 6;
m_Mana = 40;
AddSpell(typeof(ChainLightningScroll), Reg.BlackPearl, Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(EnergyFieldScroll), Reg.BlackPearl, Reg.MandrakeRoot, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(FlamestrikeScroll), Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(GateTravelScroll), Reg.BlackPearl, Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(ManaVampireScroll), Reg.BlackPearl, Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
AddSpell(typeof(MassDispelScroll), Reg.BlackPearl, Reg.Garlic, Reg.MandrakeRoot, Reg.SulfurousAsh);
AddSpell(typeof(MeteorSwarmScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SulfurousAsh, Reg.SpidersSilk);
AddSpell(typeof(PolymorphScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
m_Circle = 7;
m_Mana = 50;
AddSpell(typeof(EarthquakeScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.Ginseng, Reg.SulfurousAsh);
AddSpell(typeof(EnergyVortexScroll), Reg.BlackPearl, Reg.Bloodmoss, Reg.MandrakeRoot, Reg.Nightshade);
AddSpell(typeof(ResurrectionScroll), Reg.Bloodmoss, Reg.Garlic, Reg.Ginseng);
AddSpell(typeof(SummonAirElementalScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
AddSpell(typeof(SummonDaemonScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(SummonEarthElementalScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
AddSpell(typeof(SummonFireElementalScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk, Reg.SulfurousAsh);
AddSpell(typeof(SummonWaterElementalScroll), Reg.Bloodmoss, Reg.MandrakeRoot, Reg.SpidersSilk);
int index = -1;
index = AddCraft(typeof(TanBook), 1074906, 1072870, 30.0, 106, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(BlueBook), 1074906, 1032440, 30.0, 106, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(BrownBook), 1074906, 1073383, 30.0, 106, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(RedBook), 1074906, 1032441, 30.0, 106, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Grimoire), 1074906, 1032431, 50.0, 116, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Lexicon), 1074906, 1032433, 50.0, 116, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Journal), 1074906, 1032430, 50.0, 116, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Diary), 1074906, 1032429, 50.0, 116, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Codex), 1074906, 1032432, 50.0, 116, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Tome), 1074906, 1072862, 60.0, 126, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
index = AddCraft(typeof(Spellbook), 1074906, 1023834, 70.0, 126, typeof(BlankScroll), 1044377, 10, 1044378);
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( Leather ), 1044462, 4, 1044463 );
MarkOption = true;
}
}
}

View file

@ -0,0 +1,226 @@
using System;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Craft
{
public class DefTailoring : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Tailoring; }
}
public override int GumpTitleNumber
{
get { return 1044005; } // <CENTER>TAILORING MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefTailoring();
return m_CraftSystem;
}
}
public override CraftECA ECA{ get{ return CraftECA.ChanceMinusSixtyToFourtyFive; } }
public override double GetChanceAtMin( CraftItem item )
{
return 0.5; // 50%
}
private DefTailoring() : base( 1, 1, 1.25 )// base( 1, 1, 4.5 )
{
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
public static bool IsNonColorable(Type type)
{
for (int i = 0; i < m_TailorNonColorables.Length; ++i)
{
if (m_TailorNonColorables[i] == type)
{
return true;
}
}
return false;
}
private static Type[] m_TailorNonColorables = new Type[]
{
typeof( OrcHelm )
};
private static Type[] m_TailorColorables = new Type[]
{
typeof( PlateHelm )
};
public override bool RetainsColorFrom( CraftItem item, Type type )
{
if ( type != typeof( Cloth ) && type != typeof( UncutCloth ) )
return false;
type = item.ItemType;
bool contains = false;
for ( int i = 0; !contains && i < m_TailorColorables.Length; ++i )
contains = ( m_TailorColorables[i] == type );
return contains;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( 0x248 );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
int index = -1;
#region Hats
AddCraft( typeof( SkullCap ), 1011375, 1025444, 0.0, 25.0, typeof( Cloth ), 1044286, 2, 1044287 );
AddCraft( typeof( Bandana ), 1011375, 1025440, 0.0, 25.0, typeof( Cloth ), 1044286, 2, 1044287 );
AddCraft( typeof( FloppyHat ), 1011375, 1025907, 6.2, 31.2, typeof( Cloth ), 1044286, 11, 1044287 );
AddCraft( typeof( Hood ), 1011375, "hood", 6.2, 31.2, typeof( Cloth ), 1044286, 11, 1044287 );
AddCraft( typeof( Cap ), 1011375, 1025909, 6.2, 31.2, typeof( Cloth ), 1044286, 11, 1044287 );
AddCraft( typeof( WideBrimHat ), 1011375, 1025908, 6.2, 31.2, typeof( Cloth ), 1044286, 12, 1044287 );
AddCraft( typeof( StrawHat ), 1011375, 1025911, 6.2, 31.2, typeof( Cloth ), 1044286, 10, 1044287 );
AddCraft( typeof( TallStrawHat ), 1011375, 1025910, 6.7, 31.7, typeof( Cloth ), 1044286, 13, 1044287 );
AddCraft( typeof( WizardsHat ), 1011375, 1025912, 7.2, 32.2, typeof( Cloth ), 1044286, 15, 1044287 );
AddCraft( typeof( Bonnet ), 1011375, 1025913, 6.2, 31.2, typeof( Cloth ), 1044286, 11, 1044287 );
AddCraft( typeof( FeatheredHat ), 1011375, 1025914, 6.2, 31.2, typeof( Cloth ), 1044286, 12, 1044287 );
AddCraft( typeof( TricorneHat ), 1011375, 1025915, 6.2, 31.2, typeof( Cloth ), 1044286, 12, 1044287 );
AddCraft( typeof( JesterHat ), 1011375, 1025916, 7.2, 32.2, typeof( Cloth ), 1044286, 15, 1044287 );
#endregion
#region Shirts
AddCraft( typeof( Doublet ), 1015269, 1028059, 0, 25.0, typeof( Cloth ), 1044286, 8, 1044287 );
AddCraft( typeof( Shirt ), 1015269, 1025399, 20.7, 45.7, typeof( Cloth ), 1044286, 8, 1044287 );
AddCraft( typeof( FancyShirt ), 1015269, 1027933, 24.8, 49.8, typeof( Cloth ), 1044286, 8, 1044287 );
AddCraft( typeof( Tunic ), 1015269, 1028097, 00.0, 25.0, typeof( Cloth ), 1044286, 12, 1044287 );
AddCraft( typeof( Surcoat ), 1015269, 1028189, 8.2, 33.2, typeof( Cloth ), 1044286, 14, 1044287 );
AddCraft( typeof( PlainDress ), 1015269, 1027937, 12.4, 37.4, typeof( Cloth ), 1044286, 10, 1044287 );
AddCraft( typeof( FancyDress ), 1015269, 1027935, 33.1, 58.1, typeof( Cloth ), 1044286, 12, 1044287 );
AddCraft( typeof( Cloak ), 1015269, 1025397, 41.4, 66.4, typeof( Cloth ), 1044286, 14, 1044287 );
AddCraft( typeof( Robe ), 1015269, 1027939, 53.9, 78.9, typeof( Cloth ), 1044286, 16, 1044287 );
AddCraft( typeof( JesterSuit ), 1015269, 1028095, 8.2, 33.2, typeof( Cloth ), 1044286, 24, 1044287 );
#endregion
#region Pants
AddCraft( typeof( ShortPants ), 1015279, 1025422, 24.8, 49.8, typeof( Cloth ), 1044286, 6, 1044287 );
AddCraft( typeof( LongPants ), 1015279, 1025433, 24.8, 49.8, typeof( Cloth ), 1044286, 8, 1044287 );
AddCraft( typeof( Kilt ), 1015279, 1025431, 20.7, 45.7, typeof( Cloth ), 1044286, 8, 1044287 );
AddCraft( typeof( Skirt ), 1015279, 1025398, 29.0, 54.0, typeof( Cloth ), 1044286, 10, 1044287 );
#endregion
#region Misc
AddCraft( typeof( BodySash ), 1015283, 1025441, 4.1, 29.1, typeof( Cloth ), 1044286, 4, 1044287 );
AddCraft( typeof( HalfApron ), 1015283, 1025435, 20.7, 45.7, typeof( Cloth ), 1044286, 6, 1044287 );
AddCraft( typeof( FullApron ), 1015283, 1025437, 29.0, 54.0, typeof( Cloth ), 1044286, 10, 1044287 );
AddCraft( typeof( OilCloth ), 1015283, 1041498, 74.6, 99.6, typeof( Cloth ), 1044286, 1, 1044287 );
AddCraft( typeof( Whip ), 1015283, "whip", 53.9, 78.9, typeof( Leather ), 1044462, 4, 1044463 );
#endregion
#region Footwear
AddCraft( typeof( Sandals ), 1015288, 1025901, 12.4, 37.4, typeof( Leather ), 1044462, 4, 1044463 );
AddCraft( typeof( Shoes ), 1015288, 1025904, 16.5, 41.5, typeof( Leather ), 1044462, 6, 1044463 );
AddCraft( typeof( Boots ), 1015288, 1025899, 33.1, 58.1, typeof( Leather ), 1044462, 8, 1044463 );
AddCraft( typeof( ThighBoots ), 1015288, 1025906, 41.4, 66.4, typeof( Leather ), 1044462, 10, 1044463 );
#endregion
#region Leather Armor
AddCraft( typeof( LeatherGorget ), 1015293, 1025063, 53.9, 78.9, typeof( Leather ), 1044462, 4, 1044463 );
AddCraft( typeof( LeatherCap ), 1015293, 1027609, 6.2, 31.2, typeof( Leather ), 1044462, 2, 1044463 );
AddCraft( typeof( LeatherGloves ), 1015293, 1025062, 51.8, 76.8, typeof( Leather ), 1044462, 3, 1044463 );
AddCraft( typeof( LeatherArms ), 1015293, 1025061, 53.9, 78.9, typeof( Leather ), 1044462, 4, 1044463 );
AddCraft( typeof( LeatherLegs ), 1015293, 1025067, 66.3, 91.3, typeof( Leather ), 1044462, 10, 1044463 );
AddCraft( typeof( LeatherChest ), 1015293, 1025068, 70.5, 95.5, typeof( Leather ), 1044462, 12, 1044463 );
#endregion
#region Studded Armor
AddCraft( typeof( StuddedGorget ), 1015300, 1025078, 78.8, 103.8, typeof( Leather ), 1044462, 6, 1044463 );
AddCraft( typeof( StuddedGloves ), 1015300, 1025077, 82.9, 107.9, typeof( Leather ), 1044462, 8, 1044463 );
AddCraft( typeof( StuddedArms ), 1015300, 1025076, 87.1, 112.1, typeof( Leather ), 1044462, 10, 1044463 );
AddCraft( typeof( StuddedLegs ), 1015300, 1025082, 91.2, 116.2, typeof( Leather ), 1044462, 12, 1044463 );
AddCraft( typeof( StuddedChest ), 1015300, 1025083, 94.0, 119.0, typeof( Leather ), 1044462, 14, 1044463 );
#endregion
#region Female Armor
AddCraft( typeof( LeatherShorts ), 1015306, 1027168, 62.2, 87.2, typeof( Leather ), 1044462, 8, 1044463 );
AddCraft( typeof( LeatherSkirt ), 1015306, 1027176, 58.0, 83.0, typeof( Leather ), 1044462, 6, 1044463 );
AddCraft( typeof( LeatherBustierArms ), 1015306, 1027178, 58.0, 83.0, typeof( Leather ), 1044462, 6, 1044463 );
AddCraft( typeof( StuddedBustierArms ), 1015306, 1027180, 82.9, 107.9, typeof( Leather ), 1044462, 8, 1044463 );
AddCraft( typeof( FemaleLeatherChest ), 1015306, 1027174, 62.2, 87.2, typeof( Leather ), 1044462, 8, 1044463 );
AddCraft( typeof( FemaleStuddedChest ), 1015306, 1027170, 87.1, 112.1, typeof( Leather ), 1044462, 10, 1044463 );
#endregion
#region Bone Armor
index = AddCraft( typeof( BoneHelm ), 1049149, 1025206, 85.0, 110.0, typeof( Leather ), 1044462, 4, 1044463 );
AddRes( index, typeof( Bone ), 1049064, 2, 1049063 );
index = AddCraft( typeof( BoneGloves ), 1049149, 1025205, 89.0, 114.0, typeof( Leather ), 1044462, 6, 1044463 );
AddRes( index, typeof( Bone ), 1049064, 2, 1049063 );
index = AddCraft( typeof( BoneArms ), 1049149, 1025203, 92.0, 117.0, typeof( Leather ), 1044462, 8, 1044463 );
AddRes( index, typeof( Bone ), 1049064, 4, 1049063 );
index = AddCraft( typeof( BoneLegs ), 1049149, 1025202, 95.0, 120.0, typeof( Leather ), 1044462, 10, 1044463 );
AddRes( index, typeof( Bone ), 1049064, 6, 1049063 );
index = AddCraft( typeof( BoneChest ), 1049149, 1025199, 96.0, 121.0, typeof( Leather ), 1044462, 12, 1044463 );
AddRes( index, typeof( Bone ), 1049064, 10, 1049063 );
index = AddCraft(typeof(OrcHelm), 1049149, 1027947, 90.0, 115.0, typeof(Leather), 1044462, 6, 1044463);
AddRes(index, typeof(Bone), 1049064, 4, 1049063);
#endregion
MarkOption = true;
Repair = true;
}
}
}

View file

@ -0,0 +1,454 @@
using System;
using Server;
using Server.Items;
using Server.Misc;
using Server.Targeting;
namespace Server.Engines.Craft
{
public class DefTinkering : CraftSystem
{
public override Trades MainSkill
{
get { return Trades.Tinkering; }
}
public override int GumpTitleNumber
{
get { return 1044007; } // <CENTER>TINKERING MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefTinkering();
return m_CraftSystem;
}
}
private DefTinkering() : base( 1, 1, 1.25 )// base( 1, 1, 3.0 )
{
}
public override double GetChanceAtMin( CraftItem item )
{
if ( item.NameNumber == 1044258 ) // potion keg
return 0.5; // 50%
return 0.0; // 0%
}
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
private static Type[] m_TinkerColorables = new Type[]
{
typeof( ForkLeft ), typeof( ForkRight ),
typeof( SpoonLeft ), typeof( SpoonRight ),
typeof( KnifeLeft ), typeof( KnifeRight ),
typeof( Plate ),
typeof( Goblet ), typeof( PewterMug ),
typeof( KeyRing ),
typeof( Candelabra ), typeof( Scales ),
typeof( Key ), typeof( Globe ),
typeof( Spyglass ), typeof( Lantern ),
typeof( HeatingStand )
};
public override bool RetainsColorFrom( CraftItem item, Type type )
{
if ( !type.IsSubclassOf( typeof( BaseIngot ) ) )
return false;
type = item.ItemType;
bool contains = false;
for ( int i = 0; !contains && i < m_TinkerColorables.Length; ++i )
contains = ( m_TinkerColorables[i] == type );
return contains;
}
public override void PlayCraftEffect( Mobile from )
{
from.PlaySound( Utility.RandomList( 0x241, 0x5D9 ) );
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public void AddJewelrySet( GemType gemType, Type itemType )
{
int offset = (int)gemType - 1;
int index = AddCraft( typeof( GoldRing ), 1044049, 1044176 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
index = AddCraft( typeof( SilverBeadNecklace ), 1044049, 1044185 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
index = AddCraft( typeof( GoldNecklace ), 1044049, 1044194 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
index = AddCraft( typeof( GoldEarrings ), 1044049, 1044203 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
index = AddCraft( typeof( GoldBeadNecklace ), 1044049, 1044212 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
index = AddCraft( typeof( GoldBracelet ), 1044049, 1044221 + offset, 40.0, 90.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddRes( index, itemType, 1044231 + offset, 1, 1044240 );
}
public override void InitCraftList()
{
int index = -1;
#region Wooden Items
AddCraft( typeof( JointingPlane ), 1044042, 1024144, 0.0, 50.0, typeof( WoodBoard ), 1044041, 4, 1044351 );
AddCraft( typeof( MouldingPlane ), 1044042, 1024140, 0.0, 50.0, typeof( WoodBoard ), 1044041, 4, 1044351 );
AddCraft( typeof( SmoothingPlane ), 1044042, 1024146, 0.0, 50.0, typeof( WoodBoard ), 1044041, 4, 1044351 );
AddCraft( typeof( ClockFrame ), 1044042, 1024173, 0.0, 50.0, typeof( WoodBoard ), 1044041, 6, 1044351 );
AddCraft( typeof( Axle ), 1044042, 1024187, -25.0, 25.0, typeof( WoodBoard ), 1044041, 2, 1044351 );
AddCraft( typeof( RollingPin ), 1044042, 1024163, 0.0, 50.0, typeof( WoodBoard ), 1044041, 5, 1044351 );
#endregion
#region Tools
AddCraft( typeof( Scissors ), 1044046, 1023998, 5.0, 55.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( MortarPestle ), 1044046, 1023739, 20.0, 70.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( Scorp ), 1044046, 1024327, 30.0, 80.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( TinkerTools ), 1044046, 1044164, 10.0, 60.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Hatchet ), 1044046, 1023907, 30.0, 80.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( DrawKnife ), 1044046, 1024324, 30.0, 80.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( SewingKit ), 1044046, 1023997, 10.0, 70.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Saw ), 1044046, 1024148, 30.0, 80.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( DovetailSaw ), 1044046, 1024136, 30.0, 80.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( Froe ), 1044046, 1024325, 30.0, 80.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Shovel ), 1044046, 1023898, 40.0, 90.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( Hammer ), 1044046, 1024138, 30.0, 80.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( Tongs ), 1044046, 1024028, 35.0, 85.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( SmithHammer ), 1044046, 1025091, 40.0, 90.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( SledgeHammer ), 1044046, 1024021, 40.0, 90.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( Inshave ), 1044046, 1024326, 30.0, 80.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Pickaxe ), 1044046, 1023718, 40.0, 90.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( Lockpick ), 1044046, 1025371, 45.0, 95.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( Skillet ), 1044046, 1044567, 30.0, 80.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( FlourSifter ), 1044046, 1024158, 50.0, 100.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( FletcherTools ), 1044046, 1044166, 35.0, 85.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( MapmakersPen ), 1044046, 1044167, 25.0, 75.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( ScribesPen ), 1044046, 1044168, 25.0, 75.0, typeof( IronIngot ), 1044036, 1, 1044037 );
#endregion
#region Parts
AddCraft( typeof( Gears ), 1044047, 1024179, 5.0, 55.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( ClockParts ), 1044047, 1024175, 25.0, 75.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( BarrelTap ), 1044047, 1024100, 35.0, 85.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Springs ), 1044047, 1024189, 5.0, 55.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( SextantParts ), 1044047, 1024185, 30.0, 80.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( BarrelHoops ), 1044047, 1024321, -15.0, 35.0, typeof( IronIngot ), 1044036, 5, 1044037 );
AddCraft( typeof( Hinge ), 1044047, 1024181, 5.0, 55.0, typeof( IronIngot ), 1044036, 2, 1044037 );
#endregion
#region Utensils
AddCraft( typeof( ButcherKnife ), 1044048, 1025110, 25.0, 75.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( SpoonLeft ), 1044048, 1044158, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( SpoonRight ), 1044048, 1044159, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( Plate ), 1044048, 1022519, 0.0, 50.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( ForkLeft ), 1044048, 1044160, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( ForkRight ), 1044048, 1044161, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( Cleaver ), 1044048, 1023778, 20.0, 70.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( KnifeLeft ), 1044048, 1044162, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( KnifeRight ), 1044048, 1044163, 0.0, 50.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddCraft( typeof( Goblet ), 1044048, 1022458, 10.0, 60.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( PewterMug ), 1044048, 1024097, 10.0, 60.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( SkinningKnife ), 1044048, 1023781, 25.0, 75.0, typeof( IronIngot ), 1044036, 2, 1044037 );
#endregion
#region Misc
index = AddCraft( typeof( CandleShort ), 1044050, 1022575, 25.0, 35.0, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
index = AddCraft( typeof( CandleMedium ), 1044050, 1022575, 35.0, 45.0, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
index = AddCraft( typeof( CandleLong ), 1044050, 1022575, 45.0, 55.0, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
index = AddCraft( typeof( IronBrazierShort ), 1044050, 1023633, 55.0, 105.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddRes( index, typeof( SulfurousAsh ), 1023980, 20, 1042081 );
index = AddCraft( typeof( IronBrazier ), 1044050, 1023633, 65.0, 115.0, typeof( IronIngot ), 1044036, 8, 1044037 );
AddRes( index, typeof( SulfurousAsh ), 1023980, 40, 1042081 );
index = AddCraft( typeof( IronBrazierStand ), 1044050, 1023633, 75.0, 125.0, typeof( IronIngot ), 1044036, 16, 1044037 );
AddRes( index, typeof( SulfurousAsh ), 1023980, 60, 1042081 );
index = AddCraft( typeof( IronCandle ), 1044050, 1022599, 55.0, 105.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
index = AddCraft( typeof( IronCandelabra ), 1044050, 1022599, 65.0, 115.0, typeof( IronIngot ), 1044036, 8, 1044037 );
AddRes( index, typeof( Beeswax ), 1025156, 6, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
index = AddCraft( typeof( IronCandelabraStand ), 1044050, 1022599, 75.0, 125.0, typeof( IronIngot ), 1044036, 16, 1044037 );
AddRes( index, typeof( Beeswax ), 1025156, 6, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 1, 1042081 );
AddCraft( typeof( Globe ), 1044050, 1024167, 55.0, 105.0, typeof( IronIngot ), 1044036, 4, 1044037 );
index = AddCraft( typeof( HeatingStand ), 1044050, 1026217, 60.0, 110.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddRes( index, typeof( Beeswax ), 1025156, 2, 1042081 );
AddRes( index, typeof( BaseString ), 1025149, 2, 1042081 );
AddCraft( typeof( Key ), 1044050, 1024112, 20.0, 70.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddCraft( typeof( KeyRing ), 1044050, 1024113, 10.0, 60.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Lantern ), 1044050, 1022597, 30.0, 80.0, typeof( IronIngot ), 1044036, 2, 1044037 );
AddCraft( typeof( Scales ), 1044050, 1026225, 60.0, 110.0, typeof( IronIngot ), 1044036, 4, 1044037 );
AddCraft( typeof( Spyglass ), 1044050, 1025365, 60.0, 110.0, typeof( IronIngot ), 1044036, 4, 1044037 );
#endregion
#region Jewelry
AddJewelrySet( GemType.StarSapphire, typeof( StarSapphire ) );
AddJewelrySet( GemType.Emerald, typeof( Emerald ) );
AddJewelrySet( GemType.Sapphire, typeof( Sapphire ) );
AddJewelrySet( GemType.Ruby, typeof( Ruby ) );
AddJewelrySet( GemType.Citrine, typeof( Citrine ) );
AddJewelrySet( GemType.Amethyst, typeof( Amethyst ) );
AddJewelrySet( GemType.Tourmaline, typeof( Tourmaline ) );
AddJewelrySet( GemType.Amber, typeof( Amber ) );
AddJewelrySet( GemType.Diamond, typeof( Diamond ) );
#endregion
#region Multi-Component Items
index = AddCraft( typeof( AxleGears ), 1044051, 1024177, 0.0, 0.0, typeof( Axle ), 1044169, 1, 1044253 );
AddRes( index, typeof( Gears ), 1044254, 1, 1044253 );
index = AddCraft( typeof( ClockParts ), 1044051, 1024175, 0.0, 0.0, typeof( AxleGears ), 1044170, 1, 1044253 );
AddRes( index, typeof( Springs ), 1044171, 1, 1044253 );
index = AddCraft( typeof( SextantParts ), 1044051, 1024185, 0.0, 0.0, typeof( AxleGears ), 1044170, 1, 1044253 );
AddRes( index, typeof( Hinge ), 1044172, 1, 1044253 );
index = AddCraft( typeof( ClockRight ), 1044051, 1044257, 0.0, 0.0, typeof( ClockFrame ), 1044174, 1, 1044253 );
AddRes( index, typeof( ClockParts ), 1044173, 1, 1044253 );
index = AddCraft( typeof( ClockLeft ), 1044051, 1044256, 0.0, 0.0, typeof( ClockFrame ), 1044174, 1, 1044253 );
AddRes( index, typeof( ClockParts ), 1044173, 1, 1044253 );
AddCraft( typeof( Sextant ), 1044051, 1024183, 0.0, 0.0, typeof( SextantParts ), 1044175, 1, 1044253 );
index = AddCraft( typeof( PotionKeg ), 1044051, 1044258, 75.0, 100.0, typeof( Keg ), 1044255, 1, 1044253 );
AddRes( index, typeof( Bottle ), 1044250, 10, 1044253 );
AddRes( index, typeof( BarrelLid ), 1044251, 1, 1044253 );
AddRes( index, typeof( BarrelTap ), 1044252, 1, 1044253 );
#endregion
#region Traps
// Dart Trap
index = AddCraft( typeof( DartTrapCraft ), 1044052, 1024396, 30.0, 80.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddRes( index, typeof( Bolt ), 1044570, 1, 1044253 );
// Poison Trap
index = AddCraft( typeof( PoisonTrapCraft ), 1044052, 1044593, 30.0, 80.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddRes( index, typeof( BasePoisonPotion ), 1044571, 1, 1044253 );
// Explosion Trap
index = AddCraft( typeof( ExplosionTrapCraft ), 1044052, 1044597, 55.0, 105.0, typeof( IronIngot ), 1044036, 1, 1044037 );
AddRes( index, typeof( BaseExplosionPotion ), 1044569, 1, 1044253 );
#endregion
#region Glass
index = AddCraft( typeof( Bottle ), 1072393, 1023854, 52.5, 102.5, typeof( CrystalPowder ), 1044625, 1, 1044627 );
SetUseAllRes( index, true );
AddCraft( typeof( SmallFlask ), 1072393, 1044610, 52.5, 102.5, typeof( CrystalPowder ), 1044625, 20, 1044627 );
AddCraft( typeof( MediumFlask ), 1072393, 1044611, 52.5, 102.5, typeof( CrystalPowder ), 1044625, 30, 1044627 );
AddCraft( typeof( CurvedFlask ), 1072393, 1044612, 55.0, 105.0, typeof( CrystalPowder ), 1044625, 20, 1044627 );
AddCraft( typeof( LongFlask ), 1072393, 1044613, 57.5, 107.5, typeof( CrystalPowder ), 1044625, 40, 1044627 );
AddCraft( typeof( LargeFlask ), 1072393, 1044623, 60.0, 110.0, typeof( CrystalPowder ), 1044625, 50, 1044627 );
AddCraft( typeof( AniSmallBlueFlask ), 1072393, 1044614, 60.0, 110.0, typeof( CrystalPowder ), 1044625, 50, 1044627 );
AddCraft( typeof( AniLargeVioletFlask ), 1072393, 1044615, 60.0, 110.0, typeof( CrystalPowder ), 1044625, 50, 1044627 );
AddCraft( typeof( AniRedRibbedFlask ), 1072393, 1044624, 60.0, 110.0, typeof( CrystalPowder ), 1044625, 70, 1044627 );
AddCraft( typeof( EmptyVialsWRack ), 1072393, 1044616, 65.0, 115.0, typeof( CrystalPowder ), 1044625, 80, 1044627 );
AddCraft( typeof( FullVialsWRack ), 1072393, 1044617, 65.0, 115.0, typeof( CrystalPowder ), 1044625, 90, 1044627 );
AddCraft( typeof( SpinningHourglass ), 1072393, 1044618, 75.0, 125.0, typeof( CrystalPowder ), 1044625, 100, 1044627 );
#endregion
MarkOption = true;
Repair = true;
}
}
public abstract class TrapCraft : CustomCraft
{
private LockableContainer m_Container;
public LockableContainer Container{ get{ return m_Container; } }
public abstract TrapType TrapType{ get; }
public TrapCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality ) : base( from, craftItem, craftSystem, typeRes, tool, quality )
{
}
private int Verify( LockableContainer container )
{
if ( container == null || container.KeyValue == 0 )
return 1005638; // You can only trap lockable chests.
if ( From.Map != container.Map || !From.InRange( container.GetWorldLocation(), 2 ) )
return 500446; // That is too far away.
if ( !container.Movable )
return 502944; // You cannot trap this item because it is locked down.
if ( !container.IsAccessibleTo( From ) )
return 502946; // That belongs to someone else.
if ( container.Locked )
return 502943; // You can only trap an unlocked object.
if ( container.TrapType != TrapType.None )
return 502945; // You can only place one trap on an object at a time.
return 0;
}
private bool Acquire( object target, out int message )
{
LockableContainer container = target as LockableContainer;
message = Verify( container );
if ( message > 0 )
{
return false;
}
else
{
m_Container = container;
return true;
}
}
public override void EndCraftAction()
{
From.SendLocalizedMessage( 502921 ); // What would you like to set a trap on?
From.Target = new ContainerTarget( this );
}
private class ContainerTarget : Target
{
private TrapCraft m_TrapCraft;
public ContainerTarget( TrapCraft trapCraft ) : base( -1, false, TargetFlags.None )
{
m_TrapCraft = trapCraft;
}
protected override void OnTarget( Mobile from, object targeted )
{
int message;
if ( m_TrapCraft.Acquire( targeted, out message ) )
m_TrapCraft.CraftItem.CompleteCraft( m_TrapCraft.Quality, false, m_TrapCraft.From, m_TrapCraft.CraftSystem, m_TrapCraft.TypeRes, m_TrapCraft.Tool, m_TrapCraft );
else
Failure( message );
}
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
{
if ( cancelType == TargetCancelType.Canceled )
Failure( 0 );
}
private void Failure( int message )
{
Mobile from = m_TrapCraft.From;
BaseTool tool = m_TrapCraft.Tool;
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, m_TrapCraft.CraftSystem, tool, message ) );
else if ( message > 0 )
from.SendLocalizedMessage( message );
}
}
public override Item CompleteCraft( out int message )
{
message = Verify( this.Container );
if ( message == 0 )
{
int trapLevel = (int)( SkillCheck.TradeSkill( From, Trades.Tinkering, false ) / 10 );
Container.TrapType = this.TrapType;
Container.TrapPower = trapLevel * 9;
Container.TrapLevel = trapLevel;
Container.TrapOnLockpick = true;
message = 1005639; // Trap is disabled until you lock the chest.
}
return null;
}
}
[CraftItemID( 0x1BFC )]
public class DartTrapCraft : TrapCraft
{
public override TrapType TrapType{ get{ return TrapType.DartTrap; } }
public DartTrapCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality ) : base( from, craftItem, craftSystem, typeRes, tool, quality )
{
}
}
[CraftItemID( 0x113E )]
public class PoisonTrapCraft : TrapCraft
{
public override TrapType TrapType{ get{ return TrapType.PoisonTrap; } }
public PoisonTrapCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality ) : base( from, craftItem, craftSystem, typeRes, tool, quality )
{
}
}
[CraftItemID( 0x370C )]
public class ExplosionTrapCraft : TrapCraft
{
public override TrapType TrapType{ get{ return TrapType.ExplosionTrap; } }
public ExplosionTrapCraft( Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality ) : base( from, craftItem, craftSystem, typeRes, tool, quality )
{
}
}
}

View file

@ -0,0 +1,54 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class DeclareFealtyGump : GuildMobileListGump
{
public DeclareFealtyGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011097, false, false ); // Declare your fealty
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 250, 35, 1011098, false, false ); // I have selected my new lord.
AddButton( 300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
state.Mobile.GuildFealty = m;
}
}
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GrantGuildTitleGump : GuildMobileListGump
{
public GrantGuildTitleGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011118, false, false ); // Grant a title to another member.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011127, false, false ); // I dub thee...
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Mobile.SendLocalizedMessage( 1013074 ); // New title (20 characters max):
m_Mobile.Prompt = new GuildTitlePrompt( m_Mobile, m, m_Guild );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,55 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildAbbrvPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildAbbrvPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 3 )
text = text.Substring( 0, 3 );
if ( text.Length > 0 )
{
if ( Guild.FindByAbbrev( text ) != null )
{
m_Mobile.SendMessage( "{0} conflicts with the abbreviation of an existing guild.", text );
}
else
{
m_Guild.Abbreviation = text;
m_Guild.GuildMessage( 1018025, true, text ); // Your guild abbreviation has changed:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,67 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildAcceptWarGump : GuildListGump
{
public GuildAcceptWarGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarInvitations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011147, false, false ); // Select the guild to accept the invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011100, false, false ); // Accept war invitations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarInvitations.Remove( g );
g.WarDeclarations.Remove( m_Guild );
m_Guild.AddEnemy( g );
m_Guild.GuildMessage( 1018020, true, "{0} ({1})", g.Name, g.Abbreviation );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarInvitations.Count > 0 )
m_Mobile.SendGump( new GuildAcceptWarGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,99 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildAdminCandidatesGump : GuildMobileListGump
{
public GuildAdminCandidatesGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Candidates )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1013075, false, false ); // Accept or Refuse candidates for membership
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1013076, false, false ); // Accept
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1013077, false, false ); // Refuse
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 0:
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
case 1: // Accept
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Guild.Candidates.Remove( m );
m_Guild.Accepted.Add( m );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Candidates.Count > 0 )
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
break;
}
case 2: // Refuse
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Guild.Candidates.Remove( m );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Candidates.Count > 0 )
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
break;
}
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildCandidatesGump : GuildMobileListGump
{
public GuildCandidatesGump( Mobile from, Guild guild ) : base( from, guild, false, guild.Candidates )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 500, 35, 1013030, false, false ); // <center> Candidates </center>
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,76 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildChangeTypeGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildChangeTypeGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtmlLocalized( 20, 15, 510, 30, 1013062, false, false ); // <center>Change Guild Type Menu</center>
AddHtmlLocalized( 50, 50, 450, 30, 1013066, false, false ); // Please select the type of guild you would like to change to
AddButton( 20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 100, 300, 30, 1013063, false, false ); // Standard guild
AddButton( 20, 150, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddItem( 50, 143, 7109 );
AddHtmlLocalized( 85, 150, 300, 300, 1013064, false, false ); // Order guild
AddButton( 20, 200, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddItem( 45, 200, 7107 );
AddHtmlLocalized( 85, 200, 300, 300, 1013065, false, false ); // Chaos guild
AddButton( 300, 360, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 360, 150, 30, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( m_Guild.TypeLastChange.AddDays( 7 ) > DateTime.Now )
{
m_Mobile.SendLocalizedMessage( 1005292 ); // Your guild type will be changed in one week.
}
else
{
GuildType newType;
switch ( info.ButtonID )
{
default: return; // Close
case 1: newType = GuildType.Regular; break;
case 2: newType = GuildType.Order; break;
case 3: newType = GuildType.Chaos; break;
}
if ( m_Guild.Type == newType )
return;
m_Guild.Type = newType;
m_Guild.GuildMessage( 1018022, true, newType.ToString() ); // Guild Message: Your guild type has changed:
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,73 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildCharterGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
private const string DefaultWebsite = "http://www.runuo.com/";
public GuildCharterGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddButton( 20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 300, 35, 1011120, false, false ); // Return to the main menu.
string charter;
if ( (charter = guild.Charter) == null || (charter = charter.Trim()).Length <= 0 )
AddHtmlLocalized( 20, 20, 400, 35, 1013032, false, false ); // No charter has been defined.
else
AddHtml( 20, 20, 510, 75, charter, true, true );
AddButton( 20, 200, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 200, 300, 20, 1011122, false, false ); // Visit the guild website :
string website;
if ( (website = guild.Website) == null || (website = website.Trim()).Length <= 0 )
website = DefaultWebsite;
AddHtml( 55, 220, 300, 20, website, false, false );
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 0: return; // Close
case 1: break; // Return to main menu
case 2:
{
string website;
if ( (website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0 )
website = DefaultWebsite;
m_Mobile.LaunchBrowser( website );
break;
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,48 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildCharterPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildCharterPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 50 )
text = text.Substring( 0, 50 );
if ( text.Length > 0 )
m_Guild.Charter = text;
m_Mobile.SendLocalizedMessage( 1013072 ); // Enter the new website for the guild (50 characters max):
m_Mobile.Prompt = new GuildWebsitePrompt( m_Mobile, m_Guild );
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildDeclarePeaceGump : GuildListGump
{
public GuildDeclarePeaceGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Enemies )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011137, false, false ); // Select the guild you wish to declare peace with.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011138, false, false ); // Send the olive branch.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.RemoveEnemy( g );
m_Guild.GuildMessage( 1018018, true, "{0} ({1})", g.Name, g.Abbreviation ); // Guild Message: You are now at peace with this guild:
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Enemies.Count > 0 )
m_Mobile.SendGump( new GuildDeclarePeaceGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,83 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildDeclareWarGump : GuildListGump
{
public GuildDeclareWarGump( Mobile from, Guild guild, List<Guild> list )
: base( from, guild, true, list )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011065, false, false ); // Select the guild you wish to declare war on.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011068, false, false ); // Send the challenge!
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = m_List[index];
if ( g != null )
{
if ( g == m_Guild )
{
m_Mobile.SendLocalizedMessage( 501184 ); // You cannot declare war against yourself!
}
else if ( (g.WarInvitations.Contains( m_Guild ) && m_Guild.WarDeclarations.Contains( g )) || m_Guild.IsWar( g ) )
{
m_Mobile.SendLocalizedMessage( 501183 ); // You are already at war with that guild.
}
else
{
if ( !m_Guild.WarDeclarations.Contains( g ) )
{
m_Guild.WarDeclarations.Add( g );
m_Guild.GuildMessage( 1018019, true, "{0} ({1})", g.Name, g.Abbreviation ); // Guild Message: Your guild has sent an invitation for war:
}
if ( !g.WarInvitations.Contains( m_Guild ) )
{
g.WarInvitations.Add( m_Guild );
g.GuildMessage( 1018021, true, "{0} ({1})", m_Guild.Name, m_Guild.Abbreviation ); // Guild Message: Your guild has received an invitation to war:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,59 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Prompts;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildDeclareWarPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildDeclareWarPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length >= 3 )
{
List<Guild> guilds = Utility.CastConvertList<BaseGuild, Guild>( Guild.Search( text ) );
GuildGump.EnsureClosed( m_Mobile );
if ( guilds.Count > 0 )
{
m_Mobile.SendGump( new GuildDeclareWarGump( m_Mobile, m_Guild, guilds ) );
}
else
{
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
m_Mobile.SendLocalizedMessage( 1018003 ); // No guilds found matching - try another name in the search
}
}
else
{
m_Mobile.SendMessage( "Search string must be at least three letters in length." );
}
}
}
}

View file

@ -0,0 +1,143 @@
using System;
using Server.Network;
using Server.Prompts;
using Server.Guilds;
using Server.Multis;
using Server.Regions;
namespace Server.Items
{
public class GuildDeed : Item
{
public override int LabelNumber{ get{ return 1041055; } } // a guild deed
[Constructable]
public GuildDeed() : base( 0x14F0 )
{
Weight = 1.0;
}
public GuildDeed( 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();
if ( Weight == 0.0 )
Weight = 1.0;
}
public override void OnDoubleClick( Mobile from )
{
if( Guild.NewGuildSystem )
return;
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else if ( from.Guild != null )
{
from.SendLocalizedMessage( 501137 ); // You must resign from your current guild before founding another!
}
else
{
BaseHouse house = BaseHouse.FindHouseAt( from );
if ( house == null )
{
from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
}
else if ( house.FindGuildstone() != null )
{
from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
}
else if ( !house.IsOwner( from ) )
{
from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
}
else
{
from.SendLocalizedMessage( 1013060 ); // Enter new guild name (40 characters max):
from.Prompt = new InternalPrompt( this );
}
}
}
private class InternalPrompt : Prompt
{
private GuildDeed m_Deed;
public InternalPrompt( GuildDeed deed )
{
m_Deed = deed;
}
public override void OnResponse( Mobile from, string text )
{
if ( m_Deed.Deleted )
return;
if ( !m_Deed.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else if ( from.Guild != null )
{
from.SendLocalizedMessage( 501137 ); // You must resign from your current guild before founding another!
}
else
{
BaseHouse house = BaseHouse.FindHouseAt( from );
if ( house == null )
{
from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
}
else if ( house.FindGuildstone() != null )
{
from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
}
else if ( !house.IsOwner( from ) )
{
from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
}
else
{
m_Deed.Delete();
if ( text.Length > 40 )
text = text.Substring( 0, 40 );
Guild guild = new Guild( from, text, "none" );
from.Guild = guild;
from.GuildTitle = "Guildmaster";
Guildstone stone = new Guildstone( guild );
stone.MoveToWorld( from.Location, from.Map );
guild.Guildstone = stone;
}
}
}
public override void OnCancel( Mobile from )
{
from.SendLocalizedMessage( 501145 ); // Placement of guildstone cancelled.
}
}
}
}

View file

@ -0,0 +1,62 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildDismissGump : GuildMobileListGump
{
public GuildDismissGump ( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011124, false, false ); // Whom do you wish to dismiss?
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011125, false, false ); // Kick them out!
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Guild.RemoveMember( m );
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Mobile == m_Guild.Leader )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
}
else if ( info.ButtonID == 2 && (m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Mobile == m_Guild.Leader) )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,225 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using Server.Prompts;
using Server.Targeting;
namespace Server.Gumps
{
public class GuildGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildGump( Mobile beholder, Guild guild ) : base( 20, 30 )
{
m_Mobile = beholder;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtml( 20, 15, 200, 35, guild.Name, false, false );
Mobile leader = guild.Leader;
if ( leader != null )
{
string leadTitle;
if ( (leadTitle = leader.GuildTitle) != null && (leadTitle = leadTitle.Trim()).Length > 0 )
leadTitle += ": ";
else
leadTitle = "";
string leadName;
if ( (leadName = leader.Name) == null || (leadName = leadName.Trim()).Length <= 0 )
leadName = "(empty)";
AddHtml( 220, 15, 250, 35, leadTitle + leadName, false, false );
}
AddButton( 20, 50, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 50, 100, 20, 1013022, false, false ); // Loyal to
Mobile fealty = beholder.GuildFealty;
if ( fealty == null || !guild.IsMember( fealty ) )
fealty = leader;
if ( fealty == null )
fealty = beholder;
string fealtyName;
if ( fealty == null || (fealtyName = fealty.Name) == null || (fealtyName = fealtyName.Trim()).Length <= 0 )
fealtyName = "(empty)";
if ( beholder == fealty )
AddHtmlLocalized( 55, 70, 470, 20, 1018002, false, false ); // yourself
else
AddHtml( 55, 70, 470, 20, fealtyName, false, false );
AddButton( 215, 50, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 250, 50, 170, 20, 1013023, false, false ); // Display guild abbreviation
AddHtmlLocalized( 250, 70, 50, 20, beholder.DisplayGuildTitle ? 1011262 : 1011263, false, false ); // on/off
AddButton( 20, 100, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 100, 470, 30, 1011086, false, false ); // View the current roster.
AddButton( 20, 130, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 130, 470, 30, 1011085, false, false ); // Recruit someone into the guild.
if ( guild.Candidates.Count > 0 )
{
AddButton( 20, 160, 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160, 470, 30, 1011093, false, false ); // View list of candidates who have been sponsored to the guild.
}
else
{
AddImage( 20, 160, 4020 );
AddHtmlLocalized( 55, 160, 470, 30, 1013031, false, false ); // There are currently no candidates for membership.
}
AddButton( 20, 220, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 220, 470, 30, 1011087, false, false ); // View the guild's charter.
AddButton( 20, 250, 4005, 4007, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 250, 470, 30, 1011092, false, false ); // Resign from the guild.
AddButton( 20, 280, 4005, 4007, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 280, 470, 30, 1011095, false, false ); // View list of guilds you are at war with.
if ( beholder.AccessLevel >= AccessLevel.GameMaster || beholder == leader )
{
AddButton( 20, 310, 4005, 4007, 9, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 310, 470, 30, 1011094, false, false ); // Access guildmaster functions.
}
else
{
AddImage( 20, 310, 4020 );
AddHtmlLocalized( 55, 310, 470, 30, 1018013, false, false ); // Reserved for guildmaster
}
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 470, 30, 1011441, false, false ); // EXIT
}
public static void EnsureClosed( Mobile m )
{
m.CloseGump( typeof( DeclareFealtyGump ) );
m.CloseGump( typeof( GrantGuildTitleGump ) );
m.CloseGump( typeof( GuildAdminCandidatesGump ) );
m.CloseGump( typeof( GuildCandidatesGump ) );
m.CloseGump( typeof( GuildChangeTypeGump ) );
m.CloseGump( typeof( GuildCharterGump ) );
m.CloseGump( typeof( GuildDismissGump ) );
m.CloseGump( typeof( GuildGump ) );
m.CloseGump( typeof( GuildmasterGump ) );
m.CloseGump( typeof( GuildRosterGump ) );
m.CloseGump( typeof( GuildWarGump ) );
}
public static bool BadLeader( Mobile m, Guild g )
{
if ( m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) )
return true;
Item stone = g.Guildstone;
return ( stone == null || stone.Deleted || !m.InRange( stone.GetWorldLocation(), 2 ) );
}
public static bool BadMember( Mobile m, Guild g )
{
if ( m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember( m )) )
return true;
Item stone = g.Guildstone;
return ( stone == null || stone.Deleted || !m.InRange( stone.GetWorldLocation(), 2 ) );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( BadMember( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Loyalty
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new DeclareFealtyGump( m_Mobile, m_Guild ) );
break;
}
case 2: // Toggle display abbreviation
{
m_Mobile.DisplayGuildTitle = !m_Mobile.DisplayGuildTitle;
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
break;
}
case 3: // View the current roster
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRosterGump( m_Mobile, m_Guild ) );
break;
}
case 4: // Recruit
{
m_Mobile.Target = new GuildRecruitTarget( m_Mobile, m_Guild );
break;
}
case 5: // Membership candidates
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildCandidatesGump( m_Mobile, m_Guild ) );
break;
}
case 6: // View charter
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildCharterGump( m_Mobile, m_Guild ) );
break;
}
case 7: // Resign
{
m_Guild.RemoveMember( m_Mobile );
break;
}
case 8: // View wars
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarGump( m_Mobile, m_Guild ) );
break;
}
case 9: // Guildmaster functions
{
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile )
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
break;
}
}
}
}
}

View file

@ -0,0 +1,67 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using System.Collections.Generic;
namespace Server.Gumps
{
public abstract class GuildListGump : Gump
{
protected Mobile m_Mobile;
protected Guild m_Guild;
protected List<Guild> m_List;
public GuildListGump( Mobile from, Guild guild, bool radio, List<Guild> list ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
Design();
m_List = new List<Guild>( list );
for ( int i = 0; i < m_List.Count; ++i )
{
if ( (i % 11) == 0 )
{
if ( i != 0 )
{
AddButton( 300, 370, 4005, 4007, 0, GumpButtonType.Page, (i / 11) + 1 );
AddHtmlLocalized( 335, 370, 300, 35, 1011066, false, false ); // Next page
}
AddPage( (i / 11) + 1 );
if ( i != 0 )
{
AddButton( 20, 370, 4014, 4016, 0, GumpButtonType.Page, (i / 11) );
AddHtmlLocalized( 55, 370, 300, 35, 1011067, false, false ); // Previous page
}
}
if ( radio )
AddRadio( 20, 35 + ((i % 11) * 30), 208, 209, false, i );
Guild g = m_List[i];
string name;
if ( (name = g.Name) != null && (name = name.Trim()).Length <= 0 )
name = "(empty)";
AddLabel( (radio ? 55 : 20), 35 + ((i % 11) * 30), 0, name );
}
}
protected virtual void Design()
{
}
}
}

View file

@ -0,0 +1,68 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using System.Collections.Generic;
namespace Server.Gumps
{
public abstract class GuildMobileListGump : Gump
{
protected Mobile m_Mobile;
protected Guild m_Guild;
protected List<Mobile> m_List;
public GuildMobileListGump( Mobile from, Guild guild, bool radio, List<Mobile> list )
: base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
Design();
m_List = new List<Mobile>( list );
for ( int i = 0; i < m_List.Count; ++i )
{
if ( (i % 11) == 0 )
{
if ( i != 0 )
{
AddButton( 300, 370, 4005, 4007, 0, GumpButtonType.Page, (i / 11) + 1 );
AddHtmlLocalized( 335, 370, 300, 35, 1011066, false, false ); // Next page
}
AddPage( (i / 11) + 1 );
if ( i != 0 )
{
AddButton( 20, 370, 4014, 4016, 0, GumpButtonType.Page, (i / 11) );
AddHtmlLocalized( 55, 370, 300, 35, 1011067, false, false ); // Previous page
}
}
if ( radio )
AddRadio( 20, 35 + ((i % 11) * 30), 208, 209, false, i );
Mobile m = m_List[i];
string name;
if ( (name = m.Name) != null && (name = name.Trim()).Length <= 0 )
name = "(empty)";
AddLabel( (radio ? 55 : 20), 35 + ((i % 11) * 30), 0, name );
}
}
protected virtual void Design()
{
}
}
}

View file

@ -0,0 +1,55 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildNamePrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildNamePrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 40 )
text = text.Substring( 0, 40 );
if ( text.Length > 0 )
{
if ( Guild.FindByName( text ) != null )
{
m_Mobile.SendMessage( "{0} conflicts with the name of an existing guild.", text );
}
else
{
m_Guild.Name = text;
m_Guild.GuildMessage( 1018024, true, text ); // The name of your guild has changed:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRejectWarGump : GuildListGump
{
public GuildRejectWarGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarInvitations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011148, false, false ); // Select the guild to reject their invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011101, false, false ); // Reject war invitations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarInvitations.Remove( g );
g.WarDeclarations.Remove( m_Guild );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarInvitations.Count > 0 )
m_Mobile.SendGump( new GuildRejectWarGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRescindDeclarationGump : GuildListGump
{
public GuildRescindDeclarationGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarDeclarations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011150, false, false ); // Select the guild to rescind our invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011102, false, false ); // Rescind your war declarations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarDeclarations.Remove( g );
g.WarInvitations.Remove( m_Guild );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarDeclarations.Count > 0 )
m_Mobile.SendGump( new GuildRescindDeclarationGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRosterGump : GuildMobileListGump
{
public GuildRosterGump( Mobile from, Guild guild ) : base( from, guild, false, guild.Members )
{
}
protected override void Design()
{
AddHtml( 20, 10, 500, 35, String.Format( "<center>{0}</center>", m_Guild.Name ), false, false );
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,105 @@
using System;
using Server.Network;
using Server.Prompts;
using Server.Guilds;
using Server.Multis;
using Server.Regions;
namespace Server.Items
{
public class GuildTeleporter : Item
{
private Item m_Stone;
public override int LabelNumber{ get{ return 1041054; } } // guildstone teleporter
[Constructable]
public GuildTeleporter() : this( null )
{
}
public GuildTeleporter( Item stone ) : base( 0x1869 )
{
Weight = 1.0;
LootType = LootType.Blessed;
m_Stone = stone;
}
public GuildTeleporter( Serial serial ) : base( serial )
{
}
public override bool DisplayLootType{ get{ return false; } }
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( m_Stone );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
LootType = LootType.Blessed;
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Stone = reader.ReadItem();
break;
}
}
if ( Weight == 0.0 )
Weight = 1.0;
}
public override void OnDoubleClick( Mobile from )
{
if( Guild.NewGuildSystem )
return;
Guildstone stone = m_Stone as Guildstone;
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else if ( stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this )
{
from.SendLocalizedMessage( 501197 ); // This teleporting object can not determine what guildstone to teleport
}
else
{
BaseHouse house = BaseHouse.FindHouseAt( from );
if ( house == null )
{
from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
}
else if ( !house.IsOwner( from ) )
{
from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
}
else if( house.FindGuildstone() != null )
{
from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
}
else
{
m_Stone.MoveToWorld( from.Location, from.Map );
Delete();
stone.Guild.Teleporter = null;
}
}
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildTitlePrompt : Prompt
{
private Mobile m_Leader, m_Target;
private Guild m_Guild;
public GuildTitlePrompt( Mobile leader, Mobile target, Guild g )
{
m_Leader = leader;
m_Target = target;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
GuildGump.EnsureClosed( m_Leader );
m_Leader.SendGump( new GuildmasterGump( m_Leader, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
text = text.Trim();
if ( text.Length > 20 )
text = text.Substring( 0, 20 );
if ( text.Length > 0 )
m_Target.GuildTitle = text;
GuildGump.EnsureClosed( m_Leader );
m_Leader.SendGump( new GuildmasterGump( m_Leader, m_Guild ) );
}
}
}

View file

@ -0,0 +1,121 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildWarAdminGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWarAdminGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
AddHtmlLocalized( 20, 10, 510, 35, 1011105, false, false ); // <center>WAR FUNCTIONS</center>
AddButton( 20, 40, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 40, 400, 30, 1011099, false, false ); // Declare war through guild name search.
int count = 0;
if ( guild.Enemies.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011103, false, false ); // Declare peace.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1013033, false, false ); // No current wars
}
if ( guild.WarInvitations.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011100, false, false ); // Accept war invitations.
AddButton( 20, 160 + (count * 30), 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011101, false, false ); // Reject war invitations.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1018012, false, false ); // No current invitations received for war.
}
if ( guild.WarDeclarations.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011102, false, false ); // Rescind your war declarations.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1013055, false, false ); // No current war declarations
}
AddButton( 20, 400, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 400, 35, 1011104, false, false ); // Return to the previous menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Declare war
{
m_Mobile.SendLocalizedMessage( 1018001 ); // Declare war through search - Enter Guild Name:
m_Mobile.Prompt = new GuildDeclareWarPrompt( m_Mobile, m_Guild );
break;
}
case 2: // Declare peace
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildDeclarePeaceGump( m_Mobile, m_Guild ) );
break;
}
case 3: // Accept war
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildAcceptWarGump( m_Mobile, m_Guild ) );
break;
}
case 4: // Reject war
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRejectWarGump( m_Mobile, m_Guild ) );
break;
}
case 5: // Rescind declarations
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRescindDeclarationGump( m_Mobile, m_Guild ) );
break;
}
case 6: // Return
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,116 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildWarGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWarGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
AddHtmlLocalized( 20, 10, 500, 35, 1011133, false, false ); // <center>WARFARE STATUS</center>
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
AddPage( 1 );
AddButton( 375, 375, 5224, 5224, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 410, 373, 100, 25, 1011066, false, false ); // Next page
AddHtmlLocalized( 20, 45, 400, 20, 1011134, false, false ); // We are at war with:
List<Guild> enemies = guild.Enemies;
if ( enemies.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1013033, false, false ); // No current wars
}
else
{
for ( int i = 0; i < enemies.Count; ++i )
{
Guild g = enemies[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
AddPage( 2 );
AddButton( 375, 375, 5224, 5224, 0, GumpButtonType.Page, 3 );
AddHtmlLocalized( 410, 373, 100, 25, 1011066, false, false ); // Next page
AddButton( 30, 375, 5223, 5223, 0, GumpButtonType.Page, 1 );
AddHtmlLocalized( 65, 373, 150, 25, 1011067, false, false ); // Previous page
AddHtmlLocalized( 20, 45, 400, 20, 1011136, false, false ); // Guilds that we have declared war on:
List<Guild> declared = guild.WarDeclarations;
if ( declared.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1018012, false, false ); // No current invitations received for war.
}
else
{
for ( int i = 0; i < declared.Count; ++i )
{
Guild g = (Guild)declared[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
AddPage( 3 );
AddButton( 30, 375, 5223, 5223, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 65, 373, 150, 25, 1011067, false, false ); // Previous page
AddHtmlLocalized( 20, 45, 400, 20, 1011135, false, false ); // Guilds that have declared war on us:
List<Guild> invites = guild.WarInvitations;
if ( invites.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1013055, false, false ); // No current war declarations
}
else
{
for ( int i = 0; i < invites.Count; ++i )
{
Guild g = invites[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,45 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildWebsitePrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWebsitePrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 50 )
text = text.Substring( 0, 50 );
if ( text.Length > 0 )
m_Guild.Website = text;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,184 @@
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildmasterGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildmasterGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtmlLocalized( 20, 15, 510, 35, 1011121, false, false ); // <center>GUILDMASTER FUNCTIONS</center>
AddButton( 20, 40, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 40, 470, 30, 1011107, false, false ); // Set the guild name.
AddButton( 20, 70, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 70, 470, 30, 1011109, false, false ); // Set the guild's abbreviation.
AddButton( 20, 100, 4005, 4007, 4, GumpButtonType.Reply, 0 );
switch ( m_Guild.Type )
{
case GuildType.Regular:
AddHtmlLocalized( 55, 100, 470, 30, 1013059, false, false ); // Change guild type: Currently Standard
break;
case GuildType.Order:
AddHtmlLocalized( 55, 100, 470, 30, 1013057, false, false ); // Change guild type: Currently Order
break;
case GuildType.Chaos:
AddHtmlLocalized( 55, 100, 470, 30, 1013058, false, false ); // Change guild type: Currently Chaos
break;
}
AddButton( 20, 130, 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 130, 470, 30, 1011112, false, false ); // Set the guild's charter.
AddButton( 20, 160, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160, 470, 30, 1011113, false, false ); // Dismiss a member.
AddButton( 20, 190, 4005, 4007, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 190, 470, 30, 1011114, false, false ); // Go to the WAR menu.
if ( m_Guild.Candidates.Count > 0 )
{
AddButton( 20, 220, 4005, 4007, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 220, 470, 30, 1013056, false, false ); // Administer the list of candidates
}
else
{
AddImage( 20, 220, 4020 );
AddHtmlLocalized( 55, 220, 470, 30, 1013031, false, false ); // There are currently no candidates for membership.
}
AddButton( 20, 250, 4005, 4007, 9, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 250, 470, 30, 1011117, false, false ); // Set the guildmaster's title.
AddButton( 20, 280, 4005, 4007, 10, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 280, 470, 30, 1011118, false, false ); // Grant a title to another member.
AddButton( 20, 310, 4005, 4007, 11, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 310, 470, 30, 1011119, false, false ); // Move this guildstone.
AddButton( 20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 245, 30, 1011120, false, false ); // Return to the main menu.
AddButton( 300, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 360, 100, 30, 1011441, false, false ); // EXIT
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Main menu
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
break;
}
case 2: // Set guild name
{
m_Mobile.SendLocalizedMessage( 1013060 ); // Enter new guild name (40 characters max):
m_Mobile.Prompt = new GuildNamePrompt( m_Mobile, m_Guild );
break;
}
case 3: // Set guild abbreviation
{
m_Mobile.SendLocalizedMessage( 1013061 ); // Enter new guild abbreviation (3 characters max):
m_Mobile.Prompt = new GuildAbbrvPrompt( m_Mobile, m_Guild );
break;
}
case 4: // Change guild type
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildChangeTypeGump( m_Mobile, m_Guild ) );
break;
}
case 5: // Set charter
{
m_Mobile.SendLocalizedMessage( 1013071 ); // Enter the new guild charter (50 characters max):
m_Mobile.Prompt = new GuildCharterPrompt( m_Mobile, m_Guild );
break;
}
case 6: // Dismiss member
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildDismissGump( m_Mobile, m_Guild ) );
break;
}
case 7: // War menu
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
break;
}
case 8: // Administer candidates
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
break;
}
case 9: // Set guildmaster's title
{
m_Mobile.SendLocalizedMessage( 1013073 ); // Enter new guildmaster title (20 characters max):
m_Mobile.Prompt = new GuildTitlePrompt( m_Mobile, m_Mobile, m_Guild );
break;
}
case 10: // Grant title
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GrantGuildTitleGump( m_Mobile, m_Guild ) );
break;
}
case 11: // Move guildstone
{
if ( m_Guild.Guildstone != null )
{
GuildTeleporter item = new GuildTeleporter( m_Guild.Guildstone );
if ( m_Guild.Teleporter != null )
m_Guild.Teleporter.Delete();
m_Mobile.SendLocalizedMessage( 501133 ); // Use the teleporting object placed in your backpack to move this guildstone.
m_Mobile.AddToBackpack( item );
m_Guild.Teleporter = item;
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,364 @@
using System;
using System.IO;
using Server.Gumps;
using Server.Guilds;
using Server.Network;
using Server.Multis;
namespace Server.Items
{
public class Guildstone : Item, IAddon, IChopable
{
private Guild m_Guild;
private string m_GuildName;
private string m_GuildAbbrev;
public Guild Guild
{
get
{
return m_Guild;
}
}
public override int LabelNumber { get { return 1041429; } } // a guildstone
public Guildstone( Guild g ) : this( g, g.Name, g.Abbreviation )
{
}
public Guildstone( Guild g, string guildName, string abbrev ) : base( Guild.NewGuildSystem ? 0xED6 : 0xED4 )
{
m_Guild = g;
m_GuildName = guildName;
m_GuildAbbrev = abbrev;
Movable = false;
}
public Guildstone( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
if( m_Guild != null && !m_Guild.Disbanded )
{
m_GuildName = m_Guild.Name;
m_GuildAbbrev = m_Guild.Abbreviation;
}
writer.Write( (int)3 ); // version
writer.Write( m_BeforeChangeover );
writer.Write( m_GuildName );
writer.Write( m_GuildAbbrev );
writer.Write( m_Guild );
}
private bool m_BeforeChangeover;
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch( version )
{
case 3:
{
m_BeforeChangeover = reader.ReadBool();
goto case 2;
}
case 2:
{
m_GuildName = reader.ReadString();
m_GuildAbbrev = reader.ReadString();
goto case 1;
}
case 1:
{
m_Guild = reader.ReadGuild() as Guild;
goto case 0;
}
case 0:
{
break;
}
}
if( Guild.NewGuildSystem && ItemID == 0xED4 )
ItemID = 0xED6;
if( m_Guild != null )
{
m_GuildName = m_Guild.Name;
m_GuildAbbrev = m_Guild.Abbreviation;
}
if( version <= 2 )
m_BeforeChangeover = true;
if( Guild.NewGuildSystem && m_BeforeChangeover )
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( AddToHouse ) );
if( !Guild.NewGuildSystem && m_Guild == null )
this.Delete();
}
private void AddToHouse()
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if( Guild.NewGuildSystem && m_BeforeChangeover && house != null && !house.Addons.Contains( this ) )
{
house.Addons.Add( this );
m_BeforeChangeover = false;
}
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if( m_Guild != null && !m_Guild.Disbanded )
{
string name;
string abbr;
if( (name = m_Guild.Name) == null || (name = name.Trim()).Length <= 0 )
name = "(unnamed)";
if( (abbr = m_Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0 )
abbr = "";
//list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~
list.Add( 1060802, String.Format( "{0} [{1}]", Utility.FixHtml( name ), Utility.FixHtml( abbr ) ) );
}
else
{
list.Add( 1060802, String.Format( "{0} [{1}]", Utility.FixHtml( m_GuildName ), Utility.FixHtml( m_GuildAbbrev ) ) );
}
}
public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );
string name;
if( m_Guild == null )
name = "(unfounded)";
else if( (name = m_Guild.Name) == null || (name = name.Trim()).Length <= 0 )
name = "(unnamed)";
this.LabelTo( from, name );
}
public override void OnAfterDelete()
{
if( !Guild.NewGuildSystem && m_Guild != null && !m_Guild.Disbanded )
m_Guild.Disband();
}
public override void OnDoubleClick( Mobile from )
{
if( Guild.NewGuildSystem )
return;
if( m_Guild == null || m_Guild.Disbanded )
{
Delete();
}
else if( !from.InRange( GetWorldLocation(), 2 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if( m_Guild.Accepted.Contains( from ) )
{
m_Guild.Accepted.Remove( from );
m_Guild.AddMember( from );
GuildGump.EnsureClosed( from );
from.SendGump( new GuildGump( from, m_Guild ) );
}
else if( from.AccessLevel < AccessLevel.GameMaster && !m_Guild.IsMember( from ) )
{
from.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, 0x3B2, 3, 501158, "", "" ) ); // You are not a member ...
}
else
{
GuildGump.EnsureClosed( from );
from.SendGump( new GuildGump( from, m_Guild ) );
}
}
#region IAddon Members
public Item Deed
{
get { return new GuildstoneDeed( m_Guild, m_GuildName, m_GuildAbbrev ); }
}
public bool CouldFit( IPoint3D p, Map map )
{
return map.CanFit( p.X, p.Y, p.Z, this.ItemData.Height );
}
#endregion
#region IChopable Members
public void OnChop( Mobile from )
{
if( !Guild.NewGuildSystem )
return;
BaseHouse house = BaseHouse.FindHouseAt( this );
if( ( house == null && m_BeforeChangeover ) || ( house != null && house.IsOwner( from ) && house.Addons.Contains( this ) ))
{
Effects.PlaySound( GetWorldLocation(), Map, 0x3B3 );
from.SendLocalizedMessage( 500461 ); // You destroy the item.
Delete();
if( house != null && house.Addons.Contains( this ) )
house.Addons.Remove( this );
Item deed = Deed;
if( deed != null )
{
from.AddToBackpack( deed );
}
}
}
#endregion
}
[Flipable( 0x14F0, 0x14EF )]
public class GuildstoneDeed : Item
{
public override int LabelNumber { get { return 1041233; } } // deed to a guildstone
private Guild m_Guild;
private string m_GuildName;
private string m_GuildAbbrev;
[Constructable]
public GuildstoneDeed( Guild g, string guildName, string abbrev ) : base( 0x14F0 )
{
m_Guild = g;
m_GuildName = guildName;
m_GuildAbbrev = abbrev;
Weight = 1.0;
}
public GuildstoneDeed( 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();
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if( m_Guild != null && !m_Guild.Disbanded )
{
string name;
string abbr;
if( (name = m_Guild.Name) == null || (name = name.Trim()).Length <= 0 )
name = "(unnamed)";
if( (abbr = m_Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0 )
abbr = "";
//list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~
list.Add( 1060802, String.Format( "{0} [{1}]", Utility.FixHtml( name ), Utility.FixHtml( abbr ) ) );
}
else
{
list.Add( 1060802, String.Format( "{0} [{1}]", Utility.FixHtml( m_GuildName ), Utility.FixHtml( m_GuildAbbrev ) ) );
}
}
public override void OnDoubleClick( Mobile from )
{
if( IsChildOf( from.Backpack ) )
{
BaseHouse house = BaseHouse.FindHouseAt( from );
if( house != null && house.IsOwner( from ) )
{
from.SendLocalizedMessage( 1062838 ); // Where would you like to place this decoration?
from.BeginTarget( -1, true, Targeting.TargetFlags.None, new TargetStateCallback( Placement_OnTarget ), null );
}
else
{
from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
}
}
else
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
}
public void Placement_OnTarget( Mobile from, object targeted, object state )
{
IPoint3D p = targeted as IPoint3D;
if( p == null || Deleted )
return;
Point3D loc = new Point3D( p );
BaseHouse house = BaseHouse.FindHouseAt( loc, from.Map, 16 );
if( IsChildOf( from.Backpack ) )
{
if( house != null && house.IsOwner( from ) )
{
Item addon = new Guildstone( m_Guild, m_GuildName, m_GuildAbbrev );
addon.MoveToWorld( loc, from.Map );
house.Addons.Add( addon );
Delete();
}
else
{
from.SendLocalizedMessage( 1042036 ); // That location is not in your house.
}
}
else
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
}
}
}

View file

@ -0,0 +1,75 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public delegate void SearchSelectionCallback( GuildDisplayType display );
public class GuildAdvancedSearchGump : BaseGuildGump
{
private GuildDisplayType m_Display;
private SearchSelectionCallback m_Callback;
public GuildAdvancedSearchGump( PlayerMobile pm, Guild g, GuildDisplayType display, SearchSelectionCallback callback ) : base( pm, g )
{
m_Callback = callback;
m_Display = display;
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0xF, false, false ); // Diplomacy
AddHtmlLocalized( 65, 80, 480, 26, 1063124, 0xF, true, false ); // <i>Advanced Search Options</i>
AddHtmlLocalized( 65, 110, 480, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/w/Relation/Waiting Relation
AddGroup( 1 );
AddRadio( 75, 140, 0xD2, 0xD3, false, 2 );
AddHtmlLocalized( 105, 140, 200, 26, 1063006, 0x0, false, false ); // Show Guilds with Relationship
AddRadio( 75, 170, 0xD2, 0xD3, false, 1 );
AddHtmlLocalized( 105, 170, 200, 26, 1063005, 0x0, false, false ); // Show Guilds Awaiting Action
AddRadio( 75, 200, 0xD2, 0xD3, false, 0 );
AddHtmlLocalized( 105, 200, 200, 26, 1063007, 0x0, false, false ); // Show All Guilds
AddBackground( 450, 370, 100, 26, 0x2486 );
AddButton( 455, 375, 0x845, 0x846, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 480, 373, 60, 26, 1006044, 0x0, false, false ); // OK
AddBackground( 340, 370, 100, 26, 0x2486 );
AddButton( 345, 375, 0x845, 0x846, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 370, 373, 60, 26, 1006045, 0x0, false, false ); // Cancel
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
GuildDisplayType display = m_Display;
if( info.ButtonID == 5 )
{
for( int i = 0; i < 3; i++ )
{
if( info.IsSwitched( i ) )
{
display = (GuildDisplayType)i;
m_Callback( display );
break;
}
}
}
}
}
}

View file

@ -0,0 +1,143 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Misc;
namespace Server.Guilds
{
public abstract class BaseGuildGump : Gump
{
private Guild m_Guild;
private PlayerMobile m_Player;
protected Guild guild{ get{ return m_Guild; } }
protected PlayerMobile player{ get{ return m_Player; } }
public BaseGuildGump( PlayerMobile pm, Guild g ) : this( pm, g, 10, 10 )
{
}
public BaseGuildGump( PlayerMobile pm, Guild g, int x, int y ) : base( x, y )
{
m_Guild = g;
m_Player = pm;
pm.CloseGump( typeof( BaseGuildGump ) );
}
//There's prolly a way to have all the vars set of inherited classes before something is called in the Ctor... but... I can't think of it right now, and I can't use Timer.DelayCall here :<
public virtual void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 600, 440, 0x24AE );
AddBackground( 66, 40, 150, 26, 0x2486 );
AddButton( 71, 45, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 96, 43, 110, 26, 1063014, 0x0, false, false ); // My Guild
AddBackground( 236, 40, 150, 26, 0x2486 );
AddButton( 241, 45, 0x845, 0x846, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 266, 43, 110, 26, 1062974, 0x0, false, false ); // Guild Roster
AddBackground( 401, 40, 150, 26, 0x2486 );
AddButton( 406, 45, 0x845, 0x846, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0x0, false, false ); // Diplomacy
AddPage( 1 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
switch( info.ButtonID )
{
case 1:
{
pm.SendGump( new GuildInfoGump( pm, guild ) );
break;
}
case 2:
{
pm.SendGump( new GuildRosterGump( pm, guild ) );
break;
}
case 3:
{
pm.SendGump( new GuildDiplomacyGump( pm, guild ) );
break;
}
}
}
public static bool IsLeader( Mobile m, Guild g )
{
return !( m.Deleted || g.Disbanded || !( m is PlayerMobile ) || (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) );
}
public static bool IsMember( Mobile m, Guild g )
{
return !( m.Deleted || g.Disbanded || !( m is PlayerMobile ) || (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember( m )) );
}
public static bool CheckProfanity( string s )
{
return CheckProfanity( s, 50 );
}
public static bool CheckProfanity( string s, int maxLength )
{
//return NameVerification.Validate( s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, ProfanityProtection.Disallowed, ProfanityProtection.StartDisallowed ); //What am I doing wrong, this still allows chars like the <3 symbol... 3 AM. someone change this to use this
//With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection
if( s.Length < 1 || s.Length > maxLength )
return false;
char[] exceptions = ProfanityProtection.Exceptions;
s = s.ToLower();
for ( int i = 0; i < s.Length; ++i )
{
char c = s[i];
if ( (c < 'a' || c > 'z') && (c < '0' || c > '9'))
{
bool except = false;
for( int j = 0; !except && j < exceptions.Length; j++ )
if( c == exceptions[j] )
except = true;
if( !except )
return false;
}
}
string[] disallowed = ProfanityProtection.Disallowed;
for( int i = 0; i < disallowed.Length; i++ )
{
if ( s.IndexOf( disallowed[i] ) != -1 )
return false;
}
return true;
}
public void AddHtmlText( int x, int y, int width, int height, TextDefinition text, bool back, bool scroll )
{
if ( text != null && text.Number > 0 )
AddHtmlLocalized( x, y, width, height, text.Number, back, scroll );
else if ( text != null && text.String != null )
AddHtml( x, y, width, height, text.String, back, scroll );
}
public static string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
}
}

View file

@ -0,0 +1,209 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using System.Collections.Generic;
namespace Server.Guilds
{
public abstract class BaseGuildListGump<T> : BaseGuildGump
{
List<T> m_List;
IComparer<T> m_Comparer;
InfoField<T>[] m_Fields;
bool m_Ascending;
string m_Filter;
int m_StartNumber;
private const int itemsPerPage = 8;
public BaseGuildListGump( PlayerMobile pm, Guild g, List<T> list, IComparer<T> currentComparer, bool ascending, string filter, int startNumber, InfoField<T>[] fields )
: base( pm, g )
{
m_Filter = filter.Trim();
m_Comparer = currentComparer;
m_Fields = fields;
m_Ascending = ascending;
m_StartNumber = startNumber;
m_List = list;
}
public virtual bool WillFilter{ get{ return (m_Filter.Length >= 0); } }
public override void PopulateGump()
{
base.PopulateGump();
List<T> list = m_List;
if( WillFilter )
{
m_List = new List<T>();
for( int i = 0; i < list.Count; i++ )
{
if( !IsFiltered( list[i], m_Filter ) )
m_List.Add( list[i] );
}
}
else
{
m_List = new List<T>( list );
}
m_List.Sort( m_Comparer );
m_StartNumber = Math.Max( Math.Min( m_StartNumber, m_List.Count - 1 ), 0 );
AddBackground( 130, 75, 385, 30, 0xBB8 );
AddTextEntry( 135, 80, 375, 30, 0x481, 1, m_Filter );
AddButton( 520, 75, 0x867, 0x868, 5, GumpButtonType.Reply, 0 ); //Filter Button
int width = 0;
for( int i = 0; i < m_Fields.Length; i++ )
{
InfoField<T> f = m_Fields[i];
AddImageTiled( 65 + width, 110, f.Width + 10, 26, 0xA40 );
AddImageTiled( 67 + width, 112, f.Width + 6, 22, 0xBBC );
AddHtmlText( 70 + width, 113, f.Width, 20, f.Name, false, false );
bool isComparer = ( m_Fields[i].Comparer.GetType() == m_Comparer.GetType() );
int ButtonID = ( isComparer ) ? ( m_Ascending ? 0x983 : 0x985 ) : 0x2716;
AddButton( 59 + width + f.Width, 117, ButtonID, ButtonID + (isComparer ? 1 : 0) , 100 + i, GumpButtonType.Reply, 0 );
width += (f.Width + 12);
}
if( m_StartNumber <= 0 )
AddButton( 65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page, 0 );
else
AddButton( 65, 80, 0x15E3, 0x15E7, 6, GumpButtonType.Reply, 0 ); // Back
if( m_StartNumber + itemsPerPage > m_List.Count )
AddButton( 95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 0 );
else
AddButton( 95, 80, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0 ); // Forward
int itemNumber = 0;
if( m_Ascending )
for( int i = m_StartNumber; i < m_StartNumber + itemsPerPage && i < m_List.Count; i++ )
DrawEntry( m_List[i], i, itemNumber++ );
else //descending, go from bottom of list to the top
for( int i = m_List.Count - 1 - m_StartNumber; i >= 0 && i >= (m_List.Count - itemsPerPage - m_StartNumber); i-- )
DrawEntry( m_List[i], i, itemNumber++ );
DrawEndingEntry( itemNumber );
}
public virtual void DrawEndingEntry( int itemNumber )
{
}
public virtual bool HasRelationship( T o )
{
return false;
}
public virtual void DrawEntry( T o, int index, int itemNumber )
{
int width = 0;
for( int j = 0; j < m_Fields.Length; j++ )
{
InfoField<T> f = m_Fields[j];
AddImageTiled( 65 + width, 138 + itemNumber * 28, f.Width + 10, 26, 0xA40 );
AddImageTiled( 67 + width, 140 + itemNumber * 28, f.Width + 6, 22, 0xBBC );
AddHtmlText( 70 + width, 141 + itemNumber * 28, f.Width, 20, GetValuesFor( o, m_Fields.Length )[j], false, false );
width += (f.Width + 12);
}
if( HasRelationship( o ) )
AddButton( 40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index, GumpButtonType.Reply, 0 ); //Info Button
else
AddButton( 40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index, GumpButtonType.Reply, 0 ); //Info Button
}
protected abstract TextDefinition[] GetValuesFor( T o, int aryLength );
protected abstract bool IsFiltered( T o, string filter );
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
int id = info.ButtonID;
switch( id )
{
case 5: //Filter
{
TextRelay t = info.GetTextEntry( 1 );
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, ( t == null ) ? "" : t.Text, 0 ) );
break;
}
case 6: //Back
{
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber - itemsPerPage ) );
break;
}
case 7: //Forward
{
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber + itemsPerPage ) );
break;
}
}
if( id >= 100 && id < (100 + m_Fields.Length) )
{
IComparer<T> comparer = m_Fields[id-100].Comparer;
if( m_Comparer.GetType() == comparer.GetType() )
m_Ascending = !m_Ascending;
pm.SendGump( GetResentGump( player, guild, comparer, m_Ascending, m_Filter, 0 ) );
}
else if( id >= 200 && id < ( 200 + m_List.Count ) )
{
pm.SendGump( GetObjectInfoGump( player, guild, m_List[id - 200] ) );
}
}
public abstract Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<T> comparer, bool ascending, string filter, int startNumber );
public abstract Gump GetObjectInfoGump( PlayerMobile pm, Guild g, T o );
public void ResendGump()
{
player.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber ) );
}
}
public struct InfoField<T>
{
private TextDefinition m_Name;
private int m_Width;
private IComparer<T> m_Comparer;
public TextDefinition Name{ get{ return m_Name; } }
public int Width{ get{ return m_Width; } }
public IComparer<T> Comparer { get { return m_Comparer; } }
public InfoField( TextDefinition name, int width, IComparer<T> comparer )
{
m_Name = name;
m_Width = width;
m_Comparer = comparer;
}
}
}

View file

@ -0,0 +1,101 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class CreateGuildGump : Gump
{
public CreateGuildGump( PlayerMobile pm ) : this( pm, "Guild Name", "" )
{
}
public CreateGuildGump( PlayerMobile pm, string guildName, string guildAbbrev ) : base( 10, 10 )
{
pm.CloseGump( typeof( CreateGuildGump ) );
pm.CloseGump( typeof( BaseGuildGump ) );
AddPage( 0 );
AddBackground( 0, 0, 500, 300, 0x2422 );
AddHtmlLocalized( 25, 20, 450, 25, 1062939, 0x0, true, false ); // <center>GUILD MENU</center>
AddHtmlLocalized( 25, 60, 450, 60, 1062940, 0x0, false, false ); // As you are not a member of any guild, you can create your own by providing a unique guild name and paying the standard guild registration fee.
AddHtmlLocalized( 25, 135, 120, 25, 1062941, 0x0, false, false ); // Registration Fee:
AddLabel( 155, 135, 0x481, Guild.RegistrationFee.ToString() );
AddHtmlLocalized( 25, 165, 120, 25, 1011140, 0x0, false, false ); // Enter Guild Name:
AddBackground( 155, 160, 320, 26, 0xBB8 );
AddTextEntry( 160, 163, 315, 21, 0x481, 5, guildName );
AddHtmlLocalized( 25, 191, 120, 26, 1063035, 0x0, false, false ); // Abbreviation:
AddBackground( 155, 186, 320, 26, 0xBB8 );
AddTextEntry( 160, 189, 315, 21, 0x481, 6, guildAbbrev );
AddButton( 415, 217, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
AddButton( 345, 217, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 );
if( pm.AcceptGuildInvites )
AddButton( 20, 260, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0 );
else
AddButton( 20, 260, 0xD3, 0xD2, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 260, 200, 30, 1062943, 0x0, false, false ); // <i>Ignore Guild Invites</i>
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || pm.Guild != null )
return; //Sanity
switch( info.ButtonID )
{
case 1:
{
TextRelay tName = info.GetTextEntry( 5 );
TextRelay tAbbrev = info.GetTextEntry( 6 );
string guildName = (tName == null) ? "" : tName.Text;
string guildAbbrev = (tAbbrev == null) ? "" : tAbbrev.Text;
guildName = Utility.FixHtml( guildName.Trim() );
guildAbbrev = Utility.FixHtml( guildAbbrev.Trim() );
if( guildName.Length <= 0 )
pm.SendLocalizedMessage( 1070884 ); // Guild name cannot be blank.
else if( guildAbbrev.Length <= 0 )
pm.SendLocalizedMessage( 1070885 ); // You must provide a guild abbreviation.
else if( guildName.Length > Guild.NameLimit )
pm.SendLocalizedMessage( 1063036, Guild.NameLimit.ToString() ); // A guild name cannot be more than ~1_val~ characters in length.
else if( guildAbbrev.Length > Guild.AbbrevLimit )
pm.SendLocalizedMessage( 1063037, Guild.AbbrevLimit.ToString() ); // An abbreviation cannot exceed ~1_val~ characters in length.
else if( Guild.FindByAbbrev( guildAbbrev ) != null || !BaseGuildGump.CheckProfanity( guildAbbrev ) )
pm.SendLocalizedMessage( 501153 ); // That abbreviation is not available.
else if( Guild.FindByName( guildName ) != null || !BaseGuildGump.CheckProfanity( guildName ) )
pm.SendLocalizedMessage( 1063000 ); // That guild name is not available.
else if( !Innkeeper.Withdraw( pm, Guild.RegistrationFee ) )
pm.SendLocalizedMessage( 1063001, Guild.RegistrationFee.ToString() ); // You do not possess the ~1_val~ gold piece fee required to create a guild.
else
{
pm.SendLocalizedMessage( 1060398, Guild.RegistrationFee.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your inn chest.
pm.SendLocalizedMessage( 1063238 ); // Your new guild has been founded.
pm.Guild = new Guild( pm, guildName, guildAbbrev );
}
break;
}
case 2:
{
pm.AcceptGuildInvites = !pm.AcceptGuildInvites;
if( pm.AcceptGuildInvites )
pm.SendLocalizedMessage( 1070699 ); // You are now accepting guild invitations.
else
pm.SendLocalizedMessage( 1070698 ); // You are now ignoring guild invitations.
break;
}
}
}
}
}

View file

@ -0,0 +1,291 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using System.Collections.Generic;
namespace Server.Guilds
{
public enum GuildDisplayType
{
All,
AwaitingAction,
Relations
}
public class GuildDiplomacyGump : BaseGuildListGump<Guild>
{
protected virtual bool AllowAdvancedSearch{ get{ return true; } }
#region Comparers
private class NameComparer : IComparer<Guild>
{
public static readonly IComparer<Guild> Instance = new NameComparer();
public NameComparer()
{
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
}
}
private class StatusComparer : IComparer<Guild>
{
private enum GuildCompareStatus
{
Peace,
Ally,
War
}
private Guild m_Guild;
public StatusComparer( Guild g )
{
m_Guild = g;
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
GuildCompareStatus aStatus = GuildCompareStatus.Peace;
GuildCompareStatus bStatus = GuildCompareStatus.Peace;
if( m_Guild.IsAlly( x ) )
aStatus = GuildCompareStatus.Ally;
else if( m_Guild.IsWar( x ) )
aStatus = GuildCompareStatus.War;
if( m_Guild.IsAlly( y ) )
bStatus = GuildCompareStatus.Ally;
else if( m_Guild.IsWar( y ) )
bStatus = GuildCompareStatus.War;
return ((int)aStatus).CompareTo( (int)bStatus );
}
}
private class AbbrevComparer : IComparer<Guild>
{
public static readonly IComparer<Guild> Instance = new AbbrevComparer();
public AbbrevComparer()
{
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Abbreviation, y.Abbreviation );
}
}
#endregion
GuildDisplayType m_Display;
TextDefinition m_LowerText;
public GuildDiplomacyGump( PlayerMobile pm, Guild g )
: this( pm, g, GuildDiplomacyGump.NameComparer.Instance, true, "", 0, GuildDisplayType.All, Utility.CastConvertList<BaseGuild, Guild>( new List<BaseGuild>( Guild.List.Values ) ), (1063136 + (int)GuildDisplayType.All) )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, GuildDisplayType display )
: this( pm, g, currentComparer, ascending, filter, startNumber, display, Utility.CastConvertList<BaseGuild, Guild>( new List<BaseGuild>( Guild.List.Values ) ), (1063136 + (int)display) )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, List<Guild> list, TextDefinition lowerText )
: this( pm, g, currentComparer, ascending, filter, startNumber, GuildDisplayType.All, list, lowerText )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, bool ascending, string filter, int startNumber, List<Guild> list, TextDefinition lowerText )
: this( pm, g, GuildDiplomacyGump.NameComparer.Instance, ascending, filter, startNumber, GuildDisplayType.All, list, lowerText )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, GuildDisplayType display, List<Guild> list, TextDefinition lowerText )
: base( pm, g, list, currentComparer, ascending, filter, startNumber,
new InfoField<Guild>[]
{
new InfoField<Guild>( 1062954, 280, GuildDiplomacyGump.NameComparer.Instance ), //Guild Name
new InfoField<Guild>( 1062957, 50, GuildDiplomacyGump.AbbrevComparer.Instance ), //Abbrev
new InfoField<Guild>( 1062958, 120, new GuildDiplomacyGump.StatusComparer( g ) ) //Guild Title
})
{
m_Display = display;
m_LowerText = lowerText;
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0xF, false, false ); // Diplomacy
}
protected override TextDefinition[] GetValuesFor( Guild g, int aryLength )
{
TextDefinition[] defs = new TextDefinition[aryLength];
defs[0] = ( g == guild ) ? Color( g.Name, 0x006600 ) : g.Name;
defs[1] = g.Abbreviation;
defs[2] = 3000085; //Peace
if( guild.IsAlly( g ) )
{
if( guild.Alliance.Leader == g )
defs[2] = 1063237; // Alliance Leader
else
defs[2] = 1062964; // Ally
}
else if( guild.IsWar( g ) )
{
defs[2] = 3000086; // War
}
return defs;
}
public override bool HasRelationship( Guild g )
{
if( g == guild )
return false;
if( guild.FindPendingWar( g ) != null )
return true;
AllianceInfo alliance = guild.Alliance;
if( alliance != null )
{
Guild leader = alliance.Leader;
if ( leader != null )
{
if ( guild == leader && alliance.IsPendingMember( g ) || g == leader && alliance.IsPendingMember( guild ) )
return true;
}
else if ( alliance.IsPendingMember( g ) )
return true;
}
return false;
}
public override void DrawEndingEntry( int itemNumber )
{
//AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/Awaiting Action/ w/Relation Ship
//AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false );
if ( m_LowerText != null && m_LowerText.Number > 0 )
AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF, false, false );
else if ( m_LowerText != null && m_LowerText.String != null )
AddHtml( 66, 153 + itemNumber * 28, 280, 26, Color( m_LowerText.String, 0x99 ), false, false );
if( AllowAdvancedSearch )
{
AddBackground( 350, 148 + itemNumber * 28, 200, 26, 0x2486 );
AddButton( 355, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 380, 151 + itemNumber * 28, 160, 26, 1063083, 0x0, false, false ); // Advanced Search
}
}
protected override bool IsFiltered( Guild g, string filter )
{
if( g == null )
return true;
switch( m_Display )
{
case GuildDisplayType.Relations:
{
//if( !( guild.IsWar( g ) || guild.IsAlly( g ) ) )
if( !( guild.FindActiveWar( g ) != null || guild.IsAlly( g ) ) ) //As per OSI, only the guild leader wars show up under the sorting by relation
return true;
return false;
}
case GuildDisplayType.AwaitingAction:
{
return !HasRelationship( g );
}
}
return !( Insensitive.Contains( g.Name, filter ) || Insensitive.Contains( g.Abbreviation, filter ) );
}
public override bool WillFilter
{
get
{
if( m_Display == GuildDisplayType.All )
return base.WillFilter;
return true;
}
}
public override Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<Guild> comparer, bool ascending, string filter, int startNumber )
{
return new GuildDiplomacyGump( pm, g, comparer, ascending, filter, startNumber, m_Display );
}
public override Gump GetObjectInfoGump( PlayerMobile pm, Guild g, Guild o )
{
if( guild == o )
return new GuildInfoGump( pm, g );
return new OtherGuildInfo( pm, g, (Guild)o ) ;
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
if( AllowAdvancedSearch && info.ButtonID == 8 )
pm.SendGump( new GuildAdvancedSearchGump( pm, guild, m_Display, new SearchSelectionCallback( AdvancedSearch_Callback ) ));
}
public void AdvancedSearch_Callback( GuildDisplayType display )
{
m_Display = display;
ResendGump();
}
}
}

View file

@ -0,0 +1,165 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Prompts;
namespace Server.Guilds
{
public class GuildInfoGump : BaseGuildGump
{
private bool m_IsResigning;
public GuildInfoGump( PlayerMobile pm, Guild g ) : this( pm, g, false )
{
}
public GuildInfoGump( PlayerMobile pm, Guild g, bool isResigning ) : base( pm, g )
{
m_IsResigning = isResigning;
PopulateGump();
}
public override void PopulateGump()
{
bool isLeader = IsLeader( player, guild );
base.PopulateGump();
AddHtmlLocalized( 96, 43, 110, 26, 1063014, 0xF, false, false ); // My Guild
AddImageTiled( 65, 80, 160, 26, 0xA40 );
AddImageTiled( 67, 82, 156, 22, 0xBBC );
AddHtmlLocalized( 70, 83, 150, 20, 1062954, 0x0, false, false ); // <i>Guild Name</i>
AddHtml( 233, 84, 320, 26, guild.Name, false, false );
AddImageTiled( 65, 114, 160, 26, 0xA40 );
AddImageTiled( 67, 116, 156, 22, 0xBBC );
AddHtmlLocalized( 70, 117, 150, 20, 1063025, 0x0, false, false ); // <i>Alliance</i>
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
{
AddHtml( 233, 118, 320, 26, guild.Alliance.Name, false, false );
AddButton( 40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0 ); //Alliance Roster
}
AddImageTiled( 65, 196, 480, 4, 0x238D );
string s = guild.Charter;
if( String.IsNullOrEmpty( s ) )
s = "The guild leader has not yet set the guild charter.";
AddHtml( 65, 216, 480, 80, s, true, true );
if( isLeader )
AddButton( 40, 251, 0x4B9, 0x4BA, 4, GumpButtonType.Reply, 0 ); //Charter Edit button
s = guild.Website;
if( string.IsNullOrEmpty( s ) )
s = "Guild website not yet set.";
AddHtml( 65, 306, 480, 30, s, true, false );
if( isLeader )
AddButton( 40, 313, 0x4B9, 0x4BA, 5, GumpButtonType.Reply, 0 ); //Website Edit button
AddCheck( 65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0 );
AddHtmlLocalized( 95, 370, 150, 26, 1063085, 0x0, false, false ); // Show Guild Title
AddBackground( 450, 370, 100, 26, 0x2486 );
AddButton( 455, 375, 0x845, 0x846, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 480, 373, 60, 26, 3006115, (m_IsResigning) ? 0x5000 : 0, false, false ); // Resign
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
pm.DisplayGuildTitle = info.IsSwitched( 0 );
switch( info.ButtonID )
{
//1-3 handled by base.OnResponse
case 4:
{
if( IsLeader( pm, guild ) )
{
pm.SendLocalizedMessage( 1013071 ); // Enter the new guild charter (50 characters max):
pm.BeginPrompt( new PromptCallback( SetCharter_Callback ), true ); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of ""
}
break;
}
case 5:
{
if( IsLeader( pm, guild ) )
{
pm.SendLocalizedMessage( 1013072 ); // Enter the new website for the guild (50 characters max):
pm.BeginPrompt( new PromptCallback( SetWebsite_Callback ), true ); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of ""
}
break;
}
case 6:
{
//Alliance Roster
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
pm.SendGump( new AllianceInfo.AllianceRosterGump( pm, guild, guild.Alliance ) );
break;
}
case 7:
{
//Resign
if( !m_IsResigning )
{
pm.SendLocalizedMessage( 1063332 ); // Are you sure you wish to resign from your guild?
pm.SendGump( new GuildInfoGump( pm, guild, true ) );
}
else
{
guild.RemoveMember( pm, 1063411 ); // You resign from your guild.
}
break;
}
}
}
public void SetCharter_Callback( Mobile from, string text )
{
if( !IsLeader( from, guild ) )
return;
string charter = Utility.FixHtml( text.Trim() );
if( charter.Length > 50 )
{
from.SendLocalizedMessage( 1070774, "50" ); // Your guild charter cannot exceed ~1_val~ characters.
}
else
{
guild.Charter = charter;
from.SendLocalizedMessage( 1070775 ); // You submit a new guild charter.
return;
}
}
public void SetWebsite_Callback( Mobile from, string text )
{
if( !IsLeader( from, guild ) )
return;
string site = Utility.FixHtml( text.Trim() );
if( site.Length > 50 )
from.SendLocalizedMessage( 1070777, "50" ); // Your guild website cannot exceed ~1_val~ characters.
else
{
guild.Website = site;
from.SendLocalizedMessage( 1070778 ); // You submit a new guild website.
return;
}
}
}
}

View file

@ -0,0 +1,63 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class GuildInvitationRequest : BaseGuildGump
{
PlayerMobile m_Inviter;
public GuildInvitationRequest( PlayerMobile pm, Guild g, PlayerMobile inviter ) : base( pm, g )
{
m_Inviter = inviter;
PopulateGump();
}
public override void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 350, 170, 0x2422 );
AddHtmlLocalized( 25, 20, 300, 45, 1062946, 0x0, true, false ); // <center>You have been invited to join a guild! (Warning: Accepting will make you attackable!)</center>
AddHtml( 25, 75, 300, 25, String.Format( "<center>{0}</center>", guild.Name ), true, false );
AddButton( 265, 130, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
AddButton( 195, 130, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 );
AddButton( 20, 130, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 130, 150, 30, 1062943, 0x0, false, false ); // <i>Ignore Guild Invites</i>
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if( guild.Disbanded || player.Guild != null )
return;
switch( info.ButtonID )
{
case 0:
{
m_Inviter.SendLocalizedMessage( 1063250, String.Format( "{0}\t{1}", player.Name, guild.Name ) ); // ~1_val~ has declined your invitation to join ~2_val~.
break;
}
case 1:
{
guild.AddMember( player );
player.SendLocalizedMessage( 1063056, guild.Name ); // You have joined ~1_val~.
m_Inviter.SendLocalizedMessage( 1063249, String.Format( "{0}\t{1}", player.Name, guild.Name ) ); // ~1_val~ has accepted your invitation to join ~2_val~.
break;
}
case 2:
{
player.AcceptGuildInvites = false;
player.SendLocalizedMessage( 1070698 ); // You are now ignoring guild invitations.
break;
}
}
}
}
}

View file

@ -0,0 +1,231 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Targeting;
using Server.Prompts;
namespace Server.Guilds
{
public class GuildMemberInfoGump : BaseGuildGump
{
PlayerMobile m_Member;
bool m_ToLeader, m_toKick;
public GuildMemberInfoGump( PlayerMobile pm, Guild g, PlayerMobile member, bool toKick, bool toPromoteToLeader ) : base( pm, g, 10, 40 )
{
m_ToLeader = toPromoteToLeader;
m_toKick = toKick;
m_Member = member;
PopulateGump();
}
public override void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 350, 255, 0x242C );
AddHtmlLocalized( 20, 15, 310, 26, 1063018, 0x0, false, false ); // <div align=center><i>Guild Member Information</i></div>
AddImageTiled( 20, 40, 310, 2, 0x2711 );
AddHtmlLocalized( 20, 50, 150, 26, 1062955, 0x0, true, false ); // <i>Name</i>
AddHtml( 180, 53, 150, 26, m_Member.Name, false, false );
AddHtmlLocalized( 20, 80, 150, 26, 1062956, 0x0, true, false ); // <i>Rank</i>
AddHtmlLocalized( 180, 83, 150, 26, m_Member.GuildRank.Name, 0x0, false, false );
AddHtmlLocalized( 20, 110, 150, 26, 1062953, 0x0, true, false ); // <i>Guild Title</i>
AddHtml( 180, 113, 150, 26, m_Member.GuildTitle, false, false );
AddImageTiled( 20, 142, 310, 2, 0x2711 );
AddBackground( 20, 150, 310, 26, 0x2486 );
AddButton( 25, 155, 0x845, 0x846, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 153, 270, 26, (m_Member == player.GuildFealty && guild.Leader != m_Member) ? 1063082 : 1062996, 0x0, false, false ); // Clear/Cast Vote For This Member
AddBackground( 20, 180, 150, 26, 0x2486 );
AddButton( 25, 185, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 183, 110, 26, 1062993, (m_ToLeader)? 0x990000 : 0, false, false ); // Promote
AddBackground( 180, 180, 150, 26, 0x2486 );
AddButton( 185, 185, 0x845, 0x846, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 210, 183, 110, 26, 1062995, 0x0, false, false ); // Set Guild Title
AddBackground( 20, 210, 150, 26, 0x2486 );
AddButton( 25, 215, 0x845, 0x846, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 213, 110, 26, 1062994, 0x0, false, false ); // Demote
AddBackground( 180, 210, 150, 26, 0x2486 );
AddButton( 185, 215, 0x845, 0x846, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 210, 213, 110, 26, 1062997, (m_toKick)? 0x5000 : 0, false, false ); // Kick
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) || !IsMember( m_Member, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
RankDefinition targetRank = m_Member.GuildRank;
switch( info.ButtonID )
{
case 1: //Promote
{
if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && ((playerRank.Rank -1 ) > targetRank.Rank || ( playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank )) )
{
targetRank = RankDefinition.Ranks[targetRank.Rank + 1];
if( targetRank == RankDefinition.Leader )
{
if( m_ToLeader )
{
m_Member.GuildRank = targetRank;
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
pm.SendLocalizedMessage( 1063156, pm.Name ); // The guild information for ~1_val~ has been updated.
guild.Leader = m_Member;
}
else
{
pm.SendLocalizedMessage( 1063144 ); // Are you sure you wish to make this member the new guild leader?
pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, false, true ) );
}
}
else
{
m_Member.GuildRank = targetRank;
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
}
}
else
pm.SendLocalizedMessage( 1063143 ); // You don't have permission to promote this member.
break;
}
case 2: //Demote
{
if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && playerRank.Rank > targetRank.Rank )
{
if( targetRank == RankDefinition.Lowest )
{
if( RankDefinition.Lowest.Name.Number == 1062963 )
pm.SendLocalizedMessage( 1063333 ); // You can't demote a ronin.
else
pm.SendMessage( "You can't demote a {0}.", RankDefinition.Lowest.Name );
}
else
{
m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1];
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
}
}
else
pm.SendLocalizedMessage( 1063146 ); // You don't have permission to demote this member.
break;
}
case 3: //Set Guild title
{
if( playerRank.GetFlag( RankFlags.CanSetGuildTitle ) && ( playerRank.Rank > targetRank.Rank || m_Member == player))
{
pm.SendLocalizedMessage( 1011128 ); // Enter the new title for this guild member or 'none' to remove a title:
pm.BeginPrompt( new PromptCallback( SetTitle_Callback ) );
}
else if( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
{
pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
}
else
{
pm.SendLocalizedMessage( 1063148 ); // You don't have permission to change this member's guild title.
}
break;
}
case 4: //Vote
{
if( m_Member == pm.GuildFealty && guild.Leader != m_Member )
pm.SendLocalizedMessage( 1063158 ); // You have cleared your vote for guild leader.
else if( guild.CanVote( m_Member ) )//( playerRank.GetFlag( RankFlags.CanVote ) )
{
if( m_Member == guild.Leader )
pm.SendLocalizedMessage( 1063424 ); // You can't vote for the current guild leader.
else if( !guild.CanBeVotedFor( m_Member ) )
pm.SendLocalizedMessage( 1063425 ); // You can't vote for an inactive guild member.
else
{
pm.GuildFealty = m_Member;
pm.SendLocalizedMessage( 1063159, m_Member.Name ); // You cast your vote for ~1_val~ for guild leader.
}
}
else
pm.SendLocalizedMessage( 1063149 ); // You don't have permission to vote.
break;
}
case 5: //Kick
{
if( ( playerRank.GetFlag( RankFlags.RemovePlayers ) && playerRank.Rank > targetRank.Rank ) || ( playerRank.GetFlag( RankFlags.RemoveLowestRank ) && targetRank == RankDefinition.Lowest ) )
{
if( m_toKick )
{
guild.RemoveMember( m_Member );
pm.SendLocalizedMessage( 1063157 ); // The member has been removed from your guild.
}
else
{
pm.SendLocalizedMessage( 1063152 ); // Are you sure you wish to kick this member from the guild?
pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, true, false ) );
}
}
else
pm.SendLocalizedMessage( 1063151 ); // You don't have permission to remove this member.
break;
}
}
}
public void SetTitle_Callback( Mobile from, string text )
{
PlayerMobile pm = from as PlayerMobile;
PlayerMobile targ = m_Member;
if( pm == null || targ == null )
return;
Guild g = targ.Guild as Guild;
if( g == null || !IsMember( pm, g ) || !(pm.GuildRank.GetFlag( RankFlags.CanSetGuildTitle ) && (pm.GuildRank.Rank > targ.GuildRank.Rank || pm == targ)) )
{
if( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
else
pm.SendLocalizedMessage( 1063148 ); // You don't have permission to change this member's guild title.
return;
}
string title = Utility.FixHtml( text.Trim() );
if( title.Length > 20 )
from.SendLocalizedMessage( 501178 ); // That title is too long.
else if( !BaseGuildGump.CheckProfanity( title ) )
from.SendLocalizedMessage( 501179 ); // That title is disallowed.
else
{
if( Insensitive.Equals( title, "none" ) )
targ.GuildTitle = null;
else
targ.GuildTitle = title;
pm.SendLocalizedMessage( 1063156, targ.Name ); // The guild information for ~1_val~ has been updated.
}
}
}
}

View file

@ -0,0 +1,239 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using Server.Targets;
using System.Collections.Generic;
namespace Server.Guilds
{
public class GuildRosterGump : BaseGuildListGump<PlayerMobile>
{
#region Comparers
private class NameComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new NameComparer();
public NameComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
}
}
private class LastOnComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new LastOnComparer();
public LastOnComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
NetState aState = x.NetState;
NetState bState = y.NetState;
if ( aState == null && bState == null )
return x.LastOnline.CompareTo( y.LastOnline );
else if ( aState == null )
return 1;
else if ( bState == null )
return -1;
else
return 0;
}
}
private class TitleComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new TitleComparer();
public TitleComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.GuildTitle, y.GuildTitle );
}
}
private class RankComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new RankComparer();
public RankComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return x.GuildRank.Rank.CompareTo( y.GuildRank.Rank );
}
}
#endregion
private static InfoField<PlayerMobile>[] m_Fields =
new InfoField<PlayerMobile>[]
{
new InfoField<PlayerMobile>( 1062955, 130, GuildRosterGump.NameComparer.Instance ), //Name
new InfoField<PlayerMobile>( 1062956, 80, GuildRosterGump.RankComparer.Instance ), //Rank
new InfoField<PlayerMobile>( 1062952, 80, GuildRosterGump.LastOnComparer.Instance), //Last On
new InfoField<PlayerMobile>( 1062953, 150, GuildRosterGump.TitleComparer.Instance ) //Guild Title
};
public GuildRosterGump( PlayerMobile pm, Guild g ) : this( pm, g, GuildRosterGump.LastOnComparer.Instance, true, "", 0 )
{
}
public GuildRosterGump( PlayerMobile pm, Guild g, IComparer<PlayerMobile> currentComparer, bool ascending, string filter, int startNumber )
: base( pm, g, Utility.SafeConvertList<Mobile, PlayerMobile>( g.Members ), currentComparer, ascending, filter, startNumber, m_Fields )
{
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 266, 43, 110, 26, 1062974, 0xF, false, false ); // Guild Roster
}
public override void DrawEndingEntry( int itemNumber )
{
AddBackground( 225, 148 + itemNumber * 28, 150, 26, 0x2486 );
AddButton( 230, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0, false, false ); // Invite Player
}
protected override TextDefinition[] GetValuesFor( PlayerMobile pm, int aryLength )
{
TextDefinition[] defs = new TextDefinition[aryLength];
string name = String.Format( "{0}{1}", pm.Name, ( player.GuildFealty == pm && player.GuildFealty != guild.Leader ) ? " *" : "" );
if( pm == player )
name = Color( name, 0x006600 );
else if( pm.NetState != null )
name = Color( name, 0x000066 );
defs[0] = name;
defs[1] = pm.GuildRank.Name;
defs[2] = (pm.NetState != null) ? new TextDefinition( 1063015 ): new TextDefinition( pm.LastOnline.ToString( "yyyy-MM-dd" ) );
defs[3] = (pm.GuildTitle == null) ? "" : pm.GuildTitle;
return defs;
}
protected override bool IsFiltered( PlayerMobile pm, string filter )
{
if( pm == null )
return true;
return !Insensitive.Contains( pm.Name, filter );
}
public override Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<PlayerMobile> comparer, bool ascending, string filter, int startNumber )
{
return new GuildRosterGump( pm, g, comparer, ascending, filter, startNumber );
}
public override Gump GetObjectInfoGump( PlayerMobile pm, Guild g, PlayerMobile o )
{
return new GuildMemberInfoGump( pm, g, o, false, false ) ;
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
if( info.ButtonID == 8 )
{
if( pm.GuildRank.GetFlag( RankFlags.CanInvitePlayer ) )
{
pm.SendLocalizedMessage( 1063048 ); // Whom do you wish to invite into your guild?
pm.BeginTarget( -1, false, Targeting.TargetFlags.None, new TargetStateCallback( InvitePlayer_Callback ), guild );
}
else
pm.SendLocalizedMessage( 503301 ); // You don't have permission to do that.
}
}
public void InvitePlayer_Callback( Mobile from, object targeted, object state )
{
PlayerMobile pm = from as PlayerMobile;
PlayerMobile targ = targeted as PlayerMobile;
Guild g = state as Guild;
if( pm == null || !IsMember( pm, guild ) || !pm.GuildRank.GetFlag( RankFlags.CanInvitePlayer ) )
{
pm.SendLocalizedMessage( 503301 ); // You don't have permission to do that.
}
else if( targ == null )
{
pm.SendLocalizedMessage( 1063334 ); // That isn't a valid player.
}
else if( !targ.AcceptGuildInvites )
{
pm.SendLocalizedMessage( 1063049, targ.Name ); // ~1_val~ is not accepting guild invitations.
}
else if( g.IsMember( targ ) )
{
pm.SendLocalizedMessage( 1063050, targ.Name ); // ~1_val~ is already a member of your guild!
}
else if( targ.Guild != null )
{
pm.SendLocalizedMessage( 1063051, targ.Name ); // ~1_val~ is already a member of a guild.
}
else if( targ.HasGump( typeof( BaseGuildGump ) ) || targ.HasGump( typeof( CreateGuildGump ) )) //TODO: Check message if CreateGuildGump Open
{
pm.SendLocalizedMessage( 1063052, targ.Name ); // ~1_val~ is currently considering another guild invitation.
}
else
{
pm.SendLocalizedMessage( 1063053, targ.Name ); // You invite ~1_val~ to join your guild.
targ.SendGump( new GuildInvitationRequest( targ, guild, pm ) );
}
}
}
}

View file

@ -0,0 +1,622 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Prompts;
namespace Server.Guilds
{
public class OtherGuildInfo : BaseGuildGump
{
private Guild m_Other;
public OtherGuildInfo( PlayerMobile pm, Guild g, Guild otherGuild ) : base( pm, g, 10, 40 )
{
m_Other = otherGuild;
g.CheckExpiredWars();
PopulateGump();
}
public void AddButtonAndBackground( int x, int y, int buttonID, int locNum )
{
AddBackground( x, y, 225, 26, 0x2486 );
AddButton( x+5, y+5, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0 );
AddHtmlLocalized( x+30, y+3, 185, 26, locNum, 0x0, false, false );
}
public override void PopulateGump()
{
Guild g = Guild.GetAllianceLeader( guild );
Guild other = Guild.GetAllianceLeader( m_Other );
WarDeclaration war = g.FindPendingWar( other );
WarDeclaration activeWar = g.FindActiveWar( other );
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
//NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses
bool PendingWar = (war != null);
bool ActiveWar = (activeWar != null);
AddPage( 0 );
AddBackground( 0, 0, 520, 335, 0x242C );
AddHtmlLocalized( 20, 15, 480, 26, 1062975, 0x0, false, false ); // <div align=center><i>Guild Relationship</i></div>
AddImageTiled( 20, 40, 480, 2, 0x2711 );
AddHtmlLocalized( 20, 50, 120, 26, 1062954, 0x0, true, false ); // <i>Guild Name</i>
AddHtml( 150, 53, 360, 26, m_Other.Name, false, false );
AddHtmlLocalized( 20, 80, 120, 26, 1063025, 0x0, true, false ); // <i>Alliance</i>
if( otherAlliance != null )
{
if( otherAlliance.IsMember( m_Other ))
{
AddHtml( 150, 83, 360, 26, otherAlliance.Name, false, false );
}
//else if( otherAlliance.Leader == guild && ( otherAlliance.IsPendingMember( m_Other ) || otherAlliance.IsPendingMember( guild ) ) )
/* else if( (otherAlliance.Leader == guild && otherAlliance.IsPendingMember( m_Other ) ) || ( otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) ) )
{
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0xF), false, false );
}
//AddHtml( 150, 83, 360, 26, ( alliance.PendingMembers.Contains( guild ) || alliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", alliance.Name ) : alliance.Name, false, false );
//AddHtml( 150, 83, 360, 26, ( otherAlliance == alliance && otherAlliance.PendingMembers.Contains( guild ) || otherAlliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", otherAlliance.Name ) : otherAlliance.Name, false, false );
*/
}
AddHtmlLocalized( 20, 110, 120, 26, 1063139, 0x0, true, false ); // <i>Abbreviation</i>
AddHtml( 150, 113, 120, 26, m_Other.Abbreviation, false, false );
string kills = "0/0";
string time = "00:00";
string otherKills = "0/0";
WarDeclaration otherWar;
if( ActiveWar )
{
kills = String.Format( "{0}/{1}", activeWar.Kills, activeWar.MaxKills );
TimeSpan timeRemaining = TimeSpan.Zero;
if( activeWar.WarLength != TimeSpan.Zero && (activeWar.WarBeginning + activeWar.WarLength) > DateTime.Now )
timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.Now;
//time = String.Format( "{0:D2}:{1:D2}", timeRemaining.Hours.ToString(), timeRemaining.Subtract( TimeSpan.FromHours( timeRemaining.Hours ) ).Minutes ); //Is there a formatter for htis? it's 2AM and I'm tired and can't find it
time = String.Format( "{0:D2}:{1:mm}", timeRemaining.Hours, DateTime.MinValue + timeRemaining );
otherWar = m_Other.FindActiveWar( guild );
if( otherWar != null )
otherKills = String.Format( "{0}/{1}", otherWar.Kills, otherWar.MaxKills );
}
else if( PendingWar )
{
kills = Color( String.Format( "{0}/{1}", war.Kills, war.MaxKills ), 0x990000 );
//time = Color( String.Format( "{0}:{1}", war.WarLength.Hours, ((TimeSpan)(war.WarLength - TimeSpan.FromHours( war.WarLength.Hours ))).Minutes ), 0xFF0000 );
time = Color( String.Format( "{0:D2}:{1:mm}", war.WarLength.Hours, DateTime.MinValue + war.WarLength ), 0x990000 );
otherWar = m_Other.FindPendingWar( guild );
if( otherWar != null )
otherKills = Color( String.Format( "{0}/{1}", otherWar.Kills, otherWar.MaxKills ), 0x990000 );
}
AddHtmlLocalized( 280, 110, 120, 26, 1062966, 0x0, true, false ); // <i>Your Kills</i>
AddHtml( 410, 113, 120, 26, kills , false, false );
AddHtmlLocalized( 20, 140, 120, 26, 1062968, 0x0, true, false ); // <i>Time Remaining</i>
AddHtml( 150, 143, 120, 26, time, false, false );
AddHtmlLocalized( 280, 140, 120, 26, 1062967, 0x0, true, false ); // <i>Their Kills</i>
AddHtml( 410, 143, 120, 26, otherKills, false, false );
AddImageTiled( 20, 172, 480, 2, 0x2711 );
int number = 1062973;// <div align=center>You are at peace with this guild.</div>
if( PendingWar )
{
if( war.WarRequester )
{
number = 1063027; // <div align=center>You have challenged this guild to war!</div>
}
else
{
number = 1062969; // <div align=center>This guild has challenged you to war!</div>
AddButtonAndBackground( 20, 260, 5, 1062981 ); // Accept Challenge
AddButtonAndBackground( 275, 260, 6, 1062983 ); //Modify Terms
}
AddButtonAndBackground( 20, 290, 7, 1062982 ); // Dismiss Challenge
}
else if( ActiveWar )
{
number = 1062965; // <div align=center>You are at war with this guild!</div>
AddButtonAndBackground( 20, 290, 8, 1062980 ); // Surrender
}
else if ( alliance != null && alliance == otherAlliance ) //alliance, Same Alliance
{
if( alliance.IsMember( guild ) && alliance.IsMember( m_Other ) ) //Both in Same alliance, full members
{
number = 1062970; // <div align=center>You are allied with this guild.</div>
if( alliance.Leader == guild )
{
AddButtonAndBackground( 20, 260, 12, 1062984 ); // Remove Guild from Alliance
AddButtonAndBackground( 275, 260, 13, 1063433 ); // Promote to Alliance Leader //Note: No 'confirmation' like the other leader guild promotion things
//Remove guild from alliance //Promote to Alliance Leader
}
//Show roster, Centered, up
AddButtonAndBackground( 148, 215, 10, 1063164 ); //Show Alliance Roster
//Leave Alliance
AddButtonAndBackground( 20, 290, 11, 1062985 ); // Leave Alliance
}
else if( alliance.Leader == guild && alliance.IsPendingMember( m_Other ) )
{
number = 1062971; // <div align=center>You have requested an alliance with this guild.</div>
//Show Alliance Roster, Centered, down.
AddButtonAndBackground( 148, 245, 10, 1063164 ); //Show Alliance Roster
//Withdraw Request
AddButtonAndBackground( 20, 290, 14, 1062986 ); // Withdraw Request
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0x99 ), false, false );
}
else if( alliance.Leader == m_Other && alliance.IsPendingMember( guild ) )
{
number = 1062972; // <div align=center>This guild has requested an alliance.</div>
//Show alliance Roster, top
AddButtonAndBackground( 148, 215, 10, 1063164 ); //Show Alliance Roster
//Deny Request
//Accept Request
AddButtonAndBackground( 20, 260, 15, 1062988 ); // Deny Request
AddButtonAndBackground( 20, 290, 16, 1062987 ); // Accept Request
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0x99 ), false, false );
}
}
else
{
AddButtonAndBackground( 20, 260, 2, 1062990 ); // Request Alliance
AddButtonAndBackground( 20, 290, 1, 1062989 ); // Declare War!
}
AddButtonAndBackground( 275, 290, 0, 3000091 ); //Cancel
AddHtmlLocalized( 20, 180, 480, 30, number, 0x0, true, false );
AddImageTiled( 20, 245, 480, 2, 0x2711 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
Guild guildLeader = Guild.GetAllianceLeader( guild );
Guild otherGuild = Guild.GetAllianceLeader( m_Other );
WarDeclaration war = guildLeader.FindPendingWar( otherGuild );
WarDeclaration activeWar = guildLeader.FindActiveWar( otherGuild );
WarDeclaration otherWar = otherGuild.FindPendingWar( guildLeader );
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = otherGuild.Alliance;
switch( info.ButtonID )
{
#region War
case 5: //Accept the war
{
if( war != null && !war.WarRequester && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
//Accept the war
guild.PendingWars.Remove( war );
war.WarBeginning = DateTime.Now;
guild.AcceptedWars.Add( war );
if( alliance != null && alliance.IsMember( guild ) )
{
alliance.AllianceMessage( 1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
alliance.InvalidateMemberProperties();
}
else
{
guild.GuildMessage( 1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
guild.InvalidateMemberProperties();
}
//Technically SHOULD say Your guild is now at war w/out any info, intentional diff.
otherGuild.PendingWars.Remove( otherWar );
otherWar.WarBeginning = DateTime.Now;
otherGuild.AcceptedWars.Add( otherWar );
if( otherAlliance != null && m_Other.Alliance.IsMember( m_Other ) )
{
otherAlliance.AllianceMessage( 1070769, ((alliance != null) ? alliance.Name : guild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
otherAlliance.InvalidateMemberProperties();
}
else
{
otherGuild.GuildMessage( 1070769, ((alliance != null) ? alliance.Name : guild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
otherGuild.InvalidateMemberProperties();
}
}
}
break;
}
case 6: //Modify war terms
{
if( war != null && !war.WarRequester && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
pm.SendGump( new WarDeclarationGump( pm, guild, otherGuild ) );
}
}
break;
}
case 7: //Dismiss war
{
if( war != null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
//Dismiss the war
guild.PendingWars.Remove( war );
otherGuild.PendingWars.Remove( otherWar );
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//Messages to opposing guild? (Testing on OSI says no)
}
}
break;
}
case 8: //Surrender
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
if( activeWar != null )
{
if( alliance != null && alliance.IsMember( guild ) )
{
alliance.AllianceMessage( 1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name) );// You have lost the war with ~1_val~.
alliance.InvalidateMemberProperties();
}
else
{
guild.GuildMessage( 1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name) );// You have lost the war with ~1_val~.
guild.InvalidateMemberProperties();
}
guild.AcceptedWars.Remove( activeWar );
if( otherAlliance != null && otherAlliance.IsMember( otherGuild ) )
{
otherAlliance.AllianceMessage( 1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) );// You have won the war against ~1_val~!
otherAlliance.InvalidateMemberProperties();
}
else
{
otherGuild.GuildMessage( 1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) );// You have won the war against ~1_val~!
otherGuild.InvalidateMemberProperties();
}
otherGuild.AcceptedWars.Remove( otherGuild.FindActiveWar( guild ) );
}
}
break;
}
case 1: //Declare War
{
if( war == null && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else if( otherAlliance != null && otherAlliance.Leader != m_Other )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", m_Other.Name, otherAlliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, otherAlliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
pm.SendGump( new WarDeclarationGump( pm, guild, m_Other ) );
}
}
break;
}
#endregion
case 2: //Request Alliance
{
#region New alliance
if( alliance == null )
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1070747 ); // You don't have permission to create an alliance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else
{
pm.SendLocalizedMessage( 1063439 ); // Enter a name for the new alliance:
pm.BeginPrompt( new PromptCallback( CreateAlliance_Callback ) );
}
}
#endregion
#region Existing Alliance
else
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( alliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1063416, guild.Name ); // ~1_val~ is currently considering another alliance proposal.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else
{
pm.SendLocalizedMessage( 1070750, m_Other.Name ); // An invitation to join your alliance has been sent to ~1_val~.
m_Other.GuildMessage( 1070780, guild.Name ); // ~1_val~ has proposed an alliance.
m_Other.Alliance = alliance; //Calls addPendingGuild
//alliance.AddPendingGuild( m_Other );
}
}
#endregion
break;
}
case 10: //Show Alliance Roster
{
if( alliance != null && alliance == otherAlliance )
pm.SendGump( new AllianceInfo.AllianceRosterGump( pm, guild, alliance ) );
break;
}
case 11: //Leave Alliance
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.IsMember( guild ) )
{
guild.Alliance = null; //Calls alliance.Removeguild
// alliance.RemoveGuild( guild );
m_Other.InvalidateWarNotoriety();
guild.InvalidateMemberNotoriety();
}
break;
}
case 12: //Remove Guild from alliance
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( alliance != null && alliance.IsMember( guild ) && alliance.IsMember( m_Other ) )
{
m_Other.Alliance = null;
m_Other.InvalidateMemberNotoriety();
guild.InvalidateWarNotoriety();
}
break;
}
case 13: //Promote to Alliance leader
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( alliance != null && alliance.IsMember( guild ) && alliance.IsMember( m_Other ) )
{
pm.SendLocalizedMessage( 1063434, String.Format( "{0}\t{1}", m_Other.Name, alliance.Name ) ); // ~1_val~ is now the leader of ~2_val~.
alliance.Leader = m_Other;
}
break;
}
case 14: //Withdraw Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader == guild && alliance.IsPendingMember( m_Other ) )
{
m_Other.Alliance = null;
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
}
break;
}
case 15: //Deny Alliance Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && otherAlliance != null && alliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal. //Per OSI commented out.
guild.Alliance = null;
}
break;
}
case 16: //Accept Alliance Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( otherAlliance != null && otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
otherAlliance.TurnToMember( m_Other ); //No need to verify it's in the guild or already a member, the function does this
otherAlliance.TurnToMember( guild );
}
break;
}
}
}
public void CreateAlliance_Callback( Mobile from, string text )
{
PlayerMobile pm = from as PlayerMobile;
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
if( !IsMember( from, guild ) || alliance != null )
return;
RankDefinition playerRank = pm.GuildRank;
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1070747 ); // You don't have permission to create an alliance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else
{
string name = Utility.FixHtml( text.Trim() );
if( !BaseGuildGump.CheckProfanity( name ) )
pm.SendLocalizedMessage( 1070886 ); // That alliance name is not allowed.
else if( name.Length > Guild.NameLimit )
pm.SendLocalizedMessage( 1070887, Guild.NameLimit.ToString() ); // An alliance name cannot exceed ~1_val~ characters in length.
else if( AllianceInfo.Alliances.ContainsKey( name.ToLower() ) )
pm.SendLocalizedMessage( 1063428 ); // That alliance name is not available.
else
{
pm.SendLocalizedMessage( 1070750, m_Other.Name ); // An invitation to join your alliance has been sent to ~1_val~.
m_Other.GuildMessage( 1070780, guild.Name ); // ~1_val~ has proposed an alliance.
new AllianceInfo( guild, name, m_Other );
}
}
}
}
}

View file

@ -0,0 +1,130 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class WarDeclarationGump : BaseGuildGump
{
private Guild m_Other;
public WarDeclarationGump( PlayerMobile pm, Guild g, Guild otherGuild ) : base( pm, g )
{
m_Other = otherGuild;
WarDeclaration war = g.FindPendingWar( otherGuild );
AddPage( 0 );
AddBackground( 0, 0, 500, 340, 0x24AE );
AddBackground( 65, 50, 370, 30, 0x2486 );
AddHtmlLocalized( 75, 55, 370, 26, 1062979, 0x3C00, false, false ); // <div align=center><i>Declaration of War</i></div>
AddImage( 410, 45, 0x232C );
AddHtmlLocalized( 65, 95, 200, 20, 1063009, 0x14AF, false, false ); // <i>Duration of War</i>
AddHtmlLocalized( 65, 120, 400, 20, 1063010, 0x0, false, false ); // Enter the number of hours the war will last.
AddBackground( 65, 150, 40, 30, 0x2486 );
AddTextEntry( 70, 154, 50, 30, 0x481, 10, (war != null) ? war.WarLength.Hours.ToString() : "0" );
AddHtmlLocalized( 65, 195, 200, 20, 1063011, 0x14AF, false, false ); // <i>Victory Condition</i>
AddHtmlLocalized( 65, 220, 400, 20, 1063012, 0x0, false, false ); // Enter the winning number of kills.
AddBackground( 65, 250, 40, 30, 0x2486 );
AddTextEntry( 70, 254, 50, 30, 0x481, 11, (war != null) ? war.MaxKills.ToString() : "0" );
AddBackground( 190, 270, 130, 26, 0x2486 );
AddButton( 195, 275, 0x845, 0x846, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 220, 273, 90, 26, 1006045, 0x0, false, false ); // Cancel
AddBackground( 330, 270, 130, 26, 0x2486 );
AddButton( 335, 275, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 360, 273, 90, 26, 1062989, 0x5000, false, false ); // Declare War!
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
switch( info.ButtonID )
{
case 1:
{
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else if( otherAlliance != null && otherAlliance.Leader != m_Other )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", m_Other.Name, otherAlliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, otherAlliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
WarDeclaration activeWar = guild.FindActiveWar( m_Other );
if( activeWar == null )
{
WarDeclaration war = guild.FindPendingWar( m_Other );
WarDeclaration otherWar = m_Other.FindPendingWar( guild );
//Note: OSI differs from what it says on website. unlimited war = 0 kills/ 0 hrs. Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.)
TextRelay tKills = info.GetTextEntry( 11 );
TextRelay tWarLength = info.GetTextEntry( 10 );
int maxKills = (tKills == null)? 0 : Math.Max( Math.Min( Utility.ToInt32( info.GetTextEntry( 11 ).Text ), 0xFFFF ), 0 );
TimeSpan warLength = TimeSpan.FromHours( (tWarLength == null) ? 0 : Math.Max( Math.Min( Utility.ToInt32( info.GetTextEntry( 10 ).Text ), 0xFFFF ), 0 ) );
if( war != null )
{
war.MaxKills = maxKills;
war.WarLength = warLength;
war.WarRequester = true;
}
else
{
guild.PendingWars.Add( new WarDeclaration( guild, m_Other, maxKills, warLength, true ) );
}
if( otherWar != null )
{
otherWar.MaxKills = maxKills;
otherWar.WarLength = warLength;
otherWar.WarRequester = false;
}
else
{
m_Other.PendingWars.Add( new WarDeclaration( m_Other, guild, maxKills, warLength, false ) );
}
if( war != null )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.
}
else
m_Other.GuildMessage( 1070781, ((guild.Alliance != null ) ? guild.Alliance.Name : guild.Name ) ); // ~1_val~ has proposed a war.
pm.SendLocalizedMessage( 1070751, ((m_Other.Alliance != null ) ? m_Other.Alliance.Name : m_Other.Name ) ); // War proposal has been sent to ~1_val~.
}
}
break;
}
default:
{
pm.SendGump( new OtherGuildInfo( pm, guild, m_Other ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,72 @@
using System;
using Server;
using Server.Guilds;
using Server.Targeting;
namespace Server.Gumps
{
public class GuildRecruitTarget : Target
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildRecruitTarget( Mobile m, Guild guild ) : base( 10, false, TargetFlags.None )
{
m_Mobile = m;
m_Guild = guild;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( targeted is Mobile )
{
Mobile m = (Mobile)targeted;
if ( !m.Player )
{
m_Mobile.SendLocalizedMessage( 501161 ); // You may only recruit players into the guild.
}
else if ( !m.Alive )
{
m_Mobile.SendLocalizedMessage( 501162 ); // Only the living may be recruited.
}
else if ( m_Guild.IsMember( m ) )
{
m_Mobile.SendLocalizedMessage( 501163 ); // They are already a guildmember!
}
else if ( m_Guild.Candidates.Contains( m ) )
{
m_Mobile.SendLocalizedMessage( 501164 ); // They are already a candidate.
}
else if ( m_Guild.Accepted.Contains( m ) )
{
m_Mobile.SendLocalizedMessage( 501165 ); // They have already been accepted for membership, and merely need to use the Guildstone to gain full membership.
}
else if ( m.Guild != null )
{
m_Mobile.SendLocalizedMessage( 501166 ); // You can only recruit candidates who are not already in a guild.
}
else if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile )
{
m_Guild.Accepted.Add( m );
}
else
{
m_Guild.Candidates.Add( m );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,100 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestBank
{
private int m_Current;
private int m_Maximum;
private DateTime m_NextRespawn;
private HarvestVein m_Vein, m_DefaultVein;
HarvestDefinition m_Definition;
public HarvestDefinition Definition
{
get { return m_Definition; }
}
public int Current
{
get
{
CheckRespawn();
return m_Current;
}
}
public HarvestVein Vein
{
get
{
CheckRespawn();
return m_Vein;
}
set
{
m_Vein = value;
}
}
public HarvestVein DefaultVein
{
get
{
CheckRespawn();
return m_DefaultVein;
}
}
public void CheckRespawn()
{
if ( m_Current == m_Maximum || m_NextRespawn > DateTime.Now )
return;
m_Current = m_Maximum;
if ( m_Definition.RandomizeVeins )
{
m_DefaultVein = m_Definition.GetVeinFrom( Utility.RandomDouble() );
}
m_Vein = m_DefaultVein;
}
public void Consume( int amount, Mobile from )
{
CheckRespawn();
if ( m_Current == m_Maximum )
{
double min = m_Definition.MinRespawn.TotalMinutes;
double max = m_Definition.MaxRespawn.TotalMinutes;
double rnd = Utility.RandomDouble();
m_Current = m_Maximum - amount;
double minutes = min + (rnd * (max - min));
m_NextRespawn = DateTime.Now + TimeSpan.FromMinutes( minutes );
}
else
{
m_Current -= amount;
}
if ( m_Current < 0 )
m_Current = 0;
}
public HarvestBank( HarvestDefinition def, HarvestVein defaultVein )
{
m_Maximum = Utility.RandomMinMax( def.MinTotal, def.MaxTotal );
m_Current = m_Maximum;
m_DefaultVein = defaultVein;
m_Vein = m_DefaultVein;
m_Definition = def;
}
}
}

View file

@ -0,0 +1,159 @@
using System;
using Server.Misc;
using System.Collections.Generic;
namespace Server.Engines.Harvest
{
public class HarvestDefinition
{
private int m_BankWidth, m_BankHeight;
private int m_MinTotal, m_MaxTotal;
private int[] m_Tiles;
private bool m_RangedTiles;
private TimeSpan m_MinRespawn, m_MaxRespawn;
private int m_MaxRange;
private int m_ConsumedPerHarvest;
private bool m_PlaceAtFeetIfFull;
private Trades m_Trade;
private int[] m_EffectActions;
private int[] m_EffectCounts;
private int[] m_EffectSounds;
private TimeSpan m_EffectSoundDelay;
private TimeSpan m_EffectDelay;
private object m_NoResourcesMessage, m_OutOfRangeMessage, m_TimedOutOfRangeMessage, m_DoubleHarvestMessage, m_FailMessage, m_PackFullMessage, m_ToolBrokeMessage;
private HarvestResource[] m_Resources;
private HarvestVein[] m_Veins;
private bool m_RaceBonus;
private bool m_RandomizeVeins;
public int BankWidth{ get{ return m_BankWidth; } set{ m_BankWidth = value; } }
public int BankHeight{ get{ return m_BankHeight; } set{ m_BankHeight = value; } }
public int MinTotal{ get{ return m_MinTotal; } set{ m_MinTotal = value; } }
public int MaxTotal{ get{ return m_MaxTotal; } set{ m_MaxTotal = value; } }
public int[] Tiles{ get{ return m_Tiles; } set{ m_Tiles = value; } }
public bool RangedTiles{ get{ return m_RangedTiles; } set{ m_RangedTiles = value; } }
public TimeSpan MinRespawn{ get{ return m_MinRespawn; } set{ m_MinRespawn = value; } }
public TimeSpan MaxRespawn{ get{ return m_MaxRespawn; } set{ m_MaxRespawn = value; } }
public int MaxRange{ get{ return m_MaxRange; } set{ m_MaxRange = value; } }
public int ConsumedPerHarvest{ get{ return m_ConsumedPerHarvest; } set{ m_ConsumedPerHarvest = value; } }
public bool PlaceAtFeetIfFull{ get{ return m_PlaceAtFeetIfFull; } set{ m_PlaceAtFeetIfFull = value; } }
public Trades Trade{ get{ return m_Trade; } set{ m_Trade = value; } }
public int[] EffectActions{ get{ return m_EffectActions; } set{ m_EffectActions = value; } }
public int[] EffectCounts{ get{ return m_EffectCounts; } set{ m_EffectCounts = value; } }
public int[] EffectSounds{ get{ return m_EffectSounds; } set{ m_EffectSounds = value; } }
public TimeSpan EffectSoundDelay{ get{ return m_EffectSoundDelay; } set{ m_EffectSoundDelay = value; } }
public TimeSpan EffectDelay{ get{ return m_EffectDelay; } set{ m_EffectDelay = value; } }
public object NoResourcesMessage{ get{ return m_NoResourcesMessage; } set{ m_NoResourcesMessage = value; } }
public object OutOfRangeMessage{ get{ return m_OutOfRangeMessage; } set{ m_OutOfRangeMessage = value; } }
public object TimedOutOfRangeMessage{ get{ return m_TimedOutOfRangeMessage; } set{ m_TimedOutOfRangeMessage = value; } }
public object DoubleHarvestMessage{ get{ return m_DoubleHarvestMessage; } set{ m_DoubleHarvestMessage = value; } }
public object FailMessage{ get{ return m_FailMessage; } set{ m_FailMessage = value; } }
public object PackFullMessage{ get{ return m_PackFullMessage; } set{ m_PackFullMessage = value; } }
public object ToolBrokeMessage{ get{ return m_ToolBrokeMessage; } set{ m_ToolBrokeMessage = value; } }
public HarvestResource[] Resources{ get{ return m_Resources; } set{ m_Resources = value; } }
public HarvestVein[] Veins{ get{ return m_Veins; } set{ m_Veins = value; } }
public bool RaceBonus { get { return m_RaceBonus; } set { m_RaceBonus = value; } }
public bool RandomizeVeins { get { return m_RandomizeVeins; } set { m_RandomizeVeins = value; } }
private Dictionary<Map, Dictionary<Point2D, HarvestBank>> m_BanksByMap;
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get{ return m_BanksByMap; } set{ m_BanksByMap = value; } }
public void SendMessageTo( Mobile from, object message )
{
if ( message is int )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
}
public HarvestBank GetBank( Map map, int x, int y )
{
if ( map == null || map == Map.Internal )
return null;
x /= m_BankWidth;
y /= m_BankHeight;
Dictionary<Point2D, HarvestBank> banks = null;
m_BanksByMap.TryGetValue( map, out banks );
if ( banks == null )
m_BanksByMap[map] = banks = new Dictionary<Point2D, HarvestBank>();
Point2D key = new Point2D( x, y );
HarvestBank bank = null;
banks.TryGetValue( key, out bank );
if ( bank == null )
banks[key] = bank = new HarvestBank( this, GetVeinAt( map, x, y ) );
return bank;
}
public HarvestVein GetVeinAt( Map map, int x, int y )
{
if ( m_Veins.Length == 1 )
return m_Veins[0];
double randomValue;
if ( m_RandomizeVeins )
{
randomValue = Utility.RandomDouble();
}
else
{
Random random = new Random( ( x * 17 ) + ( y * 11 ) + ( map.MapID * 3 ) );
randomValue = random.NextDouble();
}
return GetVeinFrom( randomValue );
}
public HarvestVein GetVeinFrom( double randomValue )
{
if ( m_Veins.Length == 1 )
return m_Veins[0];
randomValue *= 100;
for ( int i = 0; i < m_Veins.Length; ++i )
{
if ( randomValue <= m_Veins[i].VeinChance )
return m_Veins[i];
randomValue -= m_Veins[i].VeinChance;
}
return null;
}
public HarvestDefinition()
{
m_BanksByMap = new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
}
public bool Validate( int tileID )
{
if ( m_RangedTiles )
{
bool contains = false;
for ( int i = 0; !contains && i < m_Tiles.Length; i += 2 )
contains = ( tileID >= m_Tiles[i] && tileID <= m_Tiles[i + 1] );
return contains;
}
else
{
int dist = -1;
for ( int i = 0; dist < 0 && i < m_Tiles.Length; ++i )
dist = ( m_Tiles[i] - tileID );
return ( dist == 0 );
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestResource
{
private Type[] m_Types;
private double m_ReqSkill, m_MinSkill, m_MaxSkill;
private object m_SuccessMessage;
public Type[] Types{ get{ return m_Types; } set{ m_Types = value; } }
public double ReqSkill{ get{ return m_ReqSkill; } set{ m_ReqSkill = value; } }
public double MinSkill{ get{ return m_MinSkill; } set{ m_MinSkill = value; } }
public double MaxSkill{ get{ return m_MaxSkill; } set{ m_MaxSkill = value; } }
public object SuccessMessage{ get{ return m_SuccessMessage; } }
public void SendSuccessTo( Mobile m )
{
if ( m_SuccessMessage is int )
m.SendLocalizedMessage( (int)m_SuccessMessage );
else if ( m_SuccessMessage is string )
m.SendMessage( (string)m_SuccessMessage );
}
public HarvestResource( double reqSkill, double minSkill, double maxSkill, object message, params Type[] types )
{
m_ReqSkill = reqSkill;
m_MinSkill = minSkill;
m_MaxSkill = maxSkill;
m_Types = types;
m_SuccessMessage = message;
}
}
}

View file

@ -0,0 +1,33 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestSoundTimer : Timer
{
private Mobile m_From;
private Item m_Tool;
private HarvestSystem m_System;
private HarvestDefinition m_Definition;
private object m_ToHarvest, m_Locked;
private bool m_Last;
public HarvestSoundTimer( Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked, bool last ) : base( def.EffectSoundDelay )
{
m_From = from;
m_Tool = tool;
m_System = system;
m_Definition = def;
m_ToHarvest = toHarvest;
m_Locked = locked;
m_Last = last;
}
protected override void OnTick()
{
m_System.DoHarvestingSound( m_From, m_Tool, m_Definition, m_ToHarvest );
if ( m_Last )
m_System.FinishHarvesting( m_From, m_Tool, m_Definition, m_ToHarvest, m_Locked );
}
}
}

View file

@ -0,0 +1,498 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Misc;
using Server.Targeting;
using Server.Regions;
namespace Server.Engines.Harvest
{
public abstract class HarvestSystem
{
private List<HarvestDefinition> m_Definitions;
public List<HarvestDefinition> Definitions { get { return m_Definitions; } }
public HarvestSystem()
{
m_Definitions = new List<HarvestDefinition>();
}
public virtual bool CheckTool( Mobile from, Item tool )
{
bool wornOut = ( tool == null || tool.Deleted || (tool is IUsesRemaining && ((IUsesRemaining)tool).UsesRemaining <= 0) );
if ( wornOut )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool!
return !wornOut;
}
public virtual bool CheckHarvest( Mobile from, Item tool )
{
if ( from.Region is DungeonRegion )
{
from.SendLocalizedMessage( 1005213 ); // You can't do that.
return false;
}
return CheckTool( from, tool );
}
public virtual bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( from.Region is DungeonRegion )
{
from.SendLocalizedMessage( 1005213 ); // You can't do that.
return false;
}
return CheckTool( from, tool );
}
public virtual bool CheckRange( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
{
bool inRange = ( from.Map == map && from.InRange( loc, def.MaxRange ) );
if ( !inRange )
def.SendMessageTo( from, timed ? def.TimedOutOfRangeMessage : def.OutOfRangeMessage );
return inRange;
}
public virtual bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
{
HarvestBank bank = def.GetBank( map, loc.X, loc.Y );
bool available = ( bank != null && bank.Current >= def.ConsumedPerHarvest );
if ( !available )
def.SendMessageTo( from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage );
return available;
}
public virtual void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
}
public virtual object GetLock( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
/* Here we prevent multiple harvesting.
*
* Some options:
* - 'return tool;' : This will allow the player to harvest more than once concurrently, but only if they use multiple tools. This seems to be as OSI.
* - 'return GetType();' : This will disallow multiple harvesting of the same type. That is, we couldn't mine more than once concurrently, but we could be both mining and lumberjacking.
* - 'return typeof( HarvestSystem );' : This will completely restrict concurrent harvesting.
*/
return tool;
}
public virtual void OnConcurrentHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
}
public virtual void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
}
public virtual bool BeginHarvesting( Mobile from, Item tool )
{
if ( !CheckHarvest( from, tool ) )
return false;
from.Target = new HarvestTarget( tool, this );
return true;
}
public virtual void FinishHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked )
{
from.EndAction( locked );
if ( !CheckHarvest( from, tool ) )
return;
int tileID;
Map map;
Point3D loc;
if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
{
OnBadHarvestTarget( from, tool, toHarvest );
return;
}
else if ( !def.Validate( tileID ) )
{
OnBadHarvestTarget( from, tool, toHarvest );
return;
}
if ( !CheckRange( from, tool, def, map, loc, true ) )
return;
else if ( !CheckResources( from, tool, def, map, loc, true ) )
return;
else if ( !CheckHarvest( from, tool, def, toHarvest ) )
return;
if ( SpecialHarvest( from, tool, def, map, loc ) )
return;
HarvestBank bank = def.GetBank( map, loc.X, loc.Y );
if ( bank == null )
return;
HarvestVein vein = bank.Vein;
if ( vein != null )
vein = MutateVein( from, tool, def, bank, toHarvest, vein );
if ( vein == null )
return;
HarvestResource primary = vein.PrimaryResource;
HarvestResource fallback = vein.FallbackResource;
HarvestResource resource = MutateResource( from, tool, def, map, loc, vein, primary, fallback );
double skillBase = SkillCheck.TradeSkill( from, def.Trade, false );
double skillValue = skillBase;
Type type = null;
if ( skillBase >= resource.ReqSkill && SkillCheck.TestTrade( from, def.Trade, resource.MinSkill, resource.MaxSkill ) )
{
type = GetResourceType( from, tool, def, map, loc, resource );
if ( type != null )
type = MutateType( type, from, tool, def, map, loc, resource );
if ( type != null )
{
Item item = Construct( type, from );
if ( item == null )
{
type = null;
}
else
{
//The whole harvest system is kludgy and I'm sure this is just adding to it.
if ( item.Stackable )
{
item.Amount = def.ConsumedPerHarvest;
}
if ( item is WoodBoard )
{
item.ItemID = 0x1BE0;
item.Weight = 2.0;
}
bank.Consume( item.Amount, from );
if ( Give( from, item, def.PlaceAtFeetIfFull ) )
{
SendSuccessTo( from, item, resource );
}
else
{
SendPackFullTo( from, item, def, resource );
item.Delete();
}
if ( tool is BaseAxe && !(tool is Pickaxe) )
{
((BaseWeapon)tool).HitPoints--;
}
else if ( tool is IUsesRemaining )
{
IUsesRemaining toolWithUses = (IUsesRemaining)tool;
toolWithUses.ShowUsesRemaining = true;
if ( toolWithUses.UsesRemaining > 0 )
--toolWithUses.UsesRemaining;
if ( toolWithUses.UsesRemaining < 1 )
{
tool.Delete();
def.SendMessageTo( from, def.ToolBrokeMessage );
}
}
}
}
}
if ( type == null )
def.SendMessageTo( from, def.FailMessage );
OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
}
public virtual void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
{
}
public virtual bool SpecialHarvest( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
{
return false;
}
public virtual Item Construct( Type type, Mobile from )
{
try{ return Activator.CreateInstance( type ) as Item; }
catch{ return null; }
}
public virtual HarvestVein MutateVein( Mobile from, Item tool, HarvestDefinition def, HarvestBank bank, object toHarvest, HarvestVein vein )
{
return vein;
}
public virtual void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
{
resource.SendSuccessTo( from );
}
public virtual void SendPackFullTo( Mobile from, Item item, HarvestDefinition def, HarvestResource resource )
{
def.SendMessageTo( from, def.PackFullMessage );
}
public virtual bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( m.PlaceInBackpack( item ) )
return true;
if ( !placeAtFeet )
return false;
Map map = m.Map;
if ( map == null )
return false;
List<Item> atFeet = new List<Item>();
foreach ( Item obj in m.GetItemsInRange( 0 ) )
atFeet.Add( obj );
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = atFeet[i];
if ( check.StackWith( m, item, false ) )
return true;
}
item.MoveToWorld( m.Location, map );
return true;
}
public virtual Type MutateType( Type type, Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
return from.Region.GetResource( type );
}
public virtual Type GetResourceType( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
if ( resource.Types.Length > 0 )
return resource.Types[Utility.Random( resource.Types.Length )];
return null;
}
public virtual HarvestResource MutateResource( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestVein vein, HarvestResource primary, HarvestResource fallback )
{
bool racialBonus = (def.RaceBonus && from.Race == Race.Orc );
if( vein.ChanceToFallback > (Utility.RandomDouble() + (racialBonus ? .20 : 0)) )
return fallback;
double skillValue = SkillCheck.TradeSkill( from, def.Trade, false );
if ( fallback != null && (skillValue < primary.ReqSkill || skillValue < primary.MinSkill) )
return fallback;
return primary;
}
public virtual bool OnHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked, bool last )
{
if ( !CheckHarvest( from, tool ) )
{
from.EndAction( locked );
return false;
}
int tileID;
Map map;
Point3D loc;
if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
{
from.EndAction( locked );
OnBadHarvestTarget( from, tool, toHarvest );
return false;
}
else if ( !def.Validate( tileID ) )
{
from.EndAction( locked );
OnBadHarvestTarget( from, tool, toHarvest );
return false;
}
else if ( !CheckRange( from, tool, def, map, loc, true ) )
{
from.EndAction( locked );
return false;
}
else if ( !CheckResources( from, tool, def, map, loc, true ) )
{
from.EndAction( locked );
return false;
}
else if ( !CheckHarvest( from, tool, def, toHarvest ) )
{
from.EndAction( locked );
return false;
}
DoHarvestingEffect( from, tool, def, map, loc );
new HarvestSoundTimer( from, tool, this, def, toHarvest, locked, last ).Start();
return !last;
}
public virtual void DoHarvestingSound( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( def.EffectSounds.Length > 0 )
from.PlaySound( Utility.RandomList( def.EffectSounds ) );
}
public virtual void DoHarvestingEffect( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
{
from.Direction = from.GetDirectionTo( loc );
if ( !from.Mounted )
from.Animate( Utility.RandomList( def.EffectActions ), 5, 1, true, false, 0 );
}
public virtual HarvestDefinition GetDefinition( int tileID )
{
HarvestDefinition def = null;
for ( int i = 0; def == null && i < m_Definitions.Count; ++i )
{
HarvestDefinition check = m_Definitions[i];
if ( check.Validate( tileID ) )
def = check;
}
return def;
}
public virtual void StartHarvesting( Mobile from, Item tool, object toHarvest )
{
if ( !CheckHarvest( from, tool ) )
return;
int tileID;
Map map;
Point3D loc;
if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
{
OnBadHarvestTarget( from, tool, toHarvest );
return;
}
HarvestDefinition def = GetDefinition( tileID );
if ( def == null )
{
OnBadHarvestTarget( from, tool, toHarvest );
return;
}
if ( !CheckRange( from, tool, def, map, loc, false ) )
return;
else if ( !CheckResources( from, tool, def, map, loc, false ) )
return;
else if ( !CheckHarvest( from, tool, def, toHarvest ) )
return;
object toLock = GetLock( from, tool, def, toHarvest );
if ( !from.BeginAction( toLock ) )
{
OnConcurrentHarvest( from, tool, def, toHarvest );
return;
}
new HarvestTimer( from, tool, this, def, toHarvest, toLock ).Start();
OnHarvestStarted( from, tool, def, toHarvest );
}
public virtual bool GetHarvestDetails( Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc )
{
if ( toHarvest is Static && !((Static)toHarvest).Movable )
{
Static obj = (Static)toHarvest;
tileID = (obj.ItemID & 0x3FFF) | 0x4000;
map = obj.Map;
loc = obj.GetWorldLocation();
}
else if ( toHarvest is StaticTarget )
{
StaticTarget obj = (StaticTarget)toHarvest;
tileID = (obj.ItemID & 0x3FFF) | 0x4000;
map = from.Map;
loc = obj.Location;
}
else if ( toHarvest is LandTarget )
{
LandTarget obj = (LandTarget)toHarvest;
tileID = obj.TileID;
map = from.Map;
loc = obj.Location;
}
else
{
tileID = 0;
map = null;
loc = Point3D.Zero;
return false;
}
return ( map != null && map != Map.Internal );
}
}
}
namespace Server
{
public interface IChopable
{
void OnChop( Mobile from );
}
[AttributeUsage( AttributeTargets.Class )]
public class FurnitureAttribute : Attribute
{
public static bool Check( Item item )
{
return ( item != null && item.GetType().IsDefined( typeof( FurnitureAttribute ), false ) );
}
public FurnitureAttribute()
{
}
}
}

View file

@ -0,0 +1,80 @@
using System;
using Server;
using Server.Items;
using Server.Targeting;
using Server.Multis;
using Server.Mobiles;
namespace Server.Engines.Harvest
{
public class HarvestTarget : Target
{
private Item m_Tool;
private HarvestSystem m_System;
public HarvestTarget( Item tool, HarvestSystem system ) : base( -1, true, TargetFlags.None )
{
m_Tool = tool;
m_System = system;
DisallowMultis = true;
}
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p3D = targeted as IPoint3D;
if ( m_System is Fishing && ( from.Map != Map.Britannia || p3D.Z != -5 ) )
from.SendMessage( "You cannot fish here!" );
else if ( m_System is Lumberjacking && targeted is IChopable )
((IChopable)targeted).OnChop( from );
else if ( m_System is Lumberjacking && targeted is IAxe && m_Tool is BaseAxe )
{
IAxe obj = (IAxe)targeted;
Item item = (Item)targeted;
if ( !item.IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1062334 ); // This item must be in your backpack to be used.
else if ( obj.Axe( from, (BaseAxe)m_Tool ) )
from.PlaySound( 0x13E );
}
else if ( m_System is Lumberjacking && targeted is ICarvable )
((ICarvable)targeted).Carve( from, (Item)m_Tool );
else if ( m_System is Lumberjacking && FurnitureAttribute.Check( targeted as Item ) )
DestroyFurniture( from, (Item)targeted );
else if ( m_System is Mining && targeted is TreasureMap )
((TreasureMap)targeted).OnBeginDig( from );
else
m_System.StartHarvesting( from, m_Tool, targeted );
}
private void DestroyFurniture( Mobile from, Item item )
{
if ( !from.InRange( item.GetWorldLocation(), 3 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
return;
}
else if ( !item.IsChildOf( from.Backpack ) && !item.Movable )
{
from.SendLocalizedMessage( 500462 ); // You can't destroy that while it is here.
return;
}
from.SendLocalizedMessage( 500461 ); // You destroy the item.
Effects.PlaySound( item.GetWorldLocation(), item.Map, 0x3B3 );
if ( item is Container )
{
if ( item is TrapableContainer )
(item as TrapableContainer).ExecuteTrap( from );
((Container)item).Destroy();
}
else
{
item.Delete();
}
}
}
}

View file

@ -0,0 +1,31 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestTimer : Timer
{
private Mobile m_From;
private Item m_Tool;
private HarvestSystem m_System;
private HarvestDefinition m_Definition;
private object m_ToHarvest, m_Locked;
private int m_Index, m_Count;
public HarvestTimer( Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked ) : base( TimeSpan.Zero, def.EffectDelay )
{
m_From = from;
m_Tool = tool;
m_System = system;
m_Definition = def;
m_ToHarvest = toHarvest;
m_Locked = locked;
m_Count = Utility.RandomList( def.EffectCounts );
}
protected override void OnTick()
{
if ( !m_System.OnHarvesting( m_From, m_Tool, m_Definition, m_ToHarvest, m_Locked, ++m_Index == m_Count ) )
Stop();
}
}
}

View file

@ -0,0 +1,25 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestVein
{
private double m_VeinChance;
private double m_ChanceToFallback;
private HarvestResource m_PrimaryResource;
private HarvestResource m_FallbackResource;
public double VeinChance{ get{ return m_VeinChance; } set{ m_VeinChance = value; } }
public double ChanceToFallback{ get{ return m_ChanceToFallback; } set{ m_ChanceToFallback = value; } }
public HarvestResource PrimaryResource{ get{ return m_PrimaryResource; } set{ m_PrimaryResource = value; } }
public HarvestResource FallbackResource{ get{ return m_FallbackResource; } set{ m_FallbackResource = value; } }
public HarvestVein( double veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource )
{
m_VeinChance = veinChance;
m_ChanceToFallback = chanceToFallback;
m_PrimaryResource = primaryResource;
m_FallbackResource = fallbackResource;
}
}
}

View file

@ -0,0 +1,527 @@
using System;
using Server;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
namespace Server.Engines.Harvest
{
public class Fishing : HarvestSystem
{
private static Fishing m_System;
public static Fishing System
{
get
{
if ( m_System == null )
m_System = new Fishing();
return m_System;
}
}
private HarvestDefinition m_Definition;
public HarvestDefinition Definition
{
get{ return m_Definition; }
}
private Fishing()
{
HarvestResource[] res = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 1043297, typeof( Fish ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#region Fishing
HarvestDefinition fish = new HarvestDefinition();
// Resource banks are every 8x8 tiles
fish.BankWidth = 8;
fish.BankHeight = 8;
// Every bank holds from 5 to 15 fish
fish.MinTotal = 5;
fish.MaxTotal = 15;
// A resource bank will respawn its content every 10 to 20 minutes
fish.MinRespawn = TimeSpan.FromMinutes( 10.0 );
fish.MaxRespawn = TimeSpan.FromMinutes( 20.0 );
fish.Trade = Trades.Fishing;
// Set the list of harvestable tiles
fish.Tiles = m_WaterTiles;
fish.RangedTiles = true;
// Players must be within 4 tiles to harvest
fish.MaxRange = 4;
// One fish per harvest action
fish.ConsumedPerHarvest = 1;
// The fishing
fish.EffectActions = new int[]{ 12 };
fish.EffectSounds = new int[0];
fish.EffectCounts = new int[]{ 1 };
fish.EffectDelay = TimeSpan.Zero;
fish.EffectSoundDelay = TimeSpan.FromSeconds( 8.0 );
fish.NoResourcesMessage = 503172; // The fish don't seem to be biting here.
fish.FailMessage = 503171; // You fish a while, but fail to catch anything.
fish.TimedOutOfRangeMessage = 500976; // You need to be closer to the water to fish!
fish.OutOfRangeMessage = 500976; // You need to be closer to the water to fish!
fish.PackFullMessage = 503176; // You do not have room in your backpack for a fish.
fish.ToolBrokeMessage = 503174; // You broke your fishing pole.
fish.Resources = res;
fish.Veins = veins;
m_Definition = fish;
Definitions.Add( fish );
#endregion
}
public override void OnConcurrentHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
from.SendLocalizedMessage( 500972 ); // You are already fishing.
}
private class MutateEntry
{
public double m_ReqSkill, m_MinSkill, m_MaxSkill;
public bool m_DeepWater;
public Type[] m_Types;
public MutateEntry( double reqSkill, double minSkill, double maxSkill, bool deepWater, params Type[] types )
{
m_ReqSkill = reqSkill;
m_MinSkill = minSkill;
m_MaxSkill = maxSkill;
m_DeepWater = deepWater;
m_Types = types;
}
}
private static MutateEntry[] m_MutateTable = new MutateEntry[]
{
new MutateEntry( 80.0, 80.0, 4080.0, true, typeof( SpecialFishingNet ) ),
new MutateEntry( 80.0, 80.0, 4080.0, true, typeof( BigFish ) ),
new MutateEntry( 90.0, 80.0, 4080.0, true, typeof( TreasureMap ) ),
new MutateEntry( 100.0, 80.0, 4080.0, true, typeof( MessageInABottle ) ),
new MutateEntry( 0.0, 125.0, -2375.0, false, typeof( PrizedFish ), typeof( WondrousFish ), typeof( TrulyRareFish ), typeof( PeculiarFish ) ),
new MutateEntry( 0.0, 105.0, -420.0, false, typeof( Boots ), typeof( Shoes ), typeof( Sandals ), typeof( ThighBoots ) ),
new MutateEntry( 0.0, 200.0, -200.0, false, new Type[1]{ null } )
};
public override Type MutateType( Type type, Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
if ( !IsOnBoat( from ) )
return type;
bool deepWater = SpecialFishingNet.FullValidation( map, loc.X, loc.Y );
if ( !IsOnBoat( from ) )
deepWater = false;
double skillBase = SkillCheck.TradeSkill( from, Trades.Fishing, false );
double skillValue = skillBase;
for ( int i = 0; i < m_MutateTable.Length; ++i )
{
MutateEntry entry = m_MutateTable[i];
if ( !deepWater && entry.m_DeepWater )
continue;
if ( skillBase >= entry.m_ReqSkill )
{
double chance = (skillValue - entry.m_MinSkill) / (entry.m_MaxSkill - entry.m_MinSkill);
if ( chance > Utility.RandomDouble() )
return entry.m_Types[Utility.Random( entry.m_Types.Length )];
}
}
return type;
}
private static Map SafeMap( Map map )
{
if ( map == null || map == Map.Internal )
return Map.Britannia;
return map;
}
public override bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
{
Container pack = from.Backpack;
if ( pack != null )
{
List<SOS> messages = pack.FindItemsByType<SOS>();
for ( int i = 0; i < messages.Count; ++i )
{
SOS sos = messages[i];
if ( from.Map == Map.Britannia && from.InRange( sos.TargetLocation, 60 ) )
return true;
}
}
return base.CheckResources( from, tool, def, map, loc, timed );
}
public static bool IsOnBoat( Mobile m )
{
if ( m.Z != -2 )
return false;
bool KeepSearching = true;
bool IsOnShip = false;
foreach ( Item boatman in m.GetItemsInRange( 15 ) )
{
if ( KeepSearching )
{
if ( boatman is TillerMan )
{
IsOnShip = true;
if ( IsOnShip == true ){ KeepSearching = false; }
}
}
}
return IsOnShip;
}
public override Item Construct( Type type, Mobile from )
{
if ( type == typeof( TreasureMap ) )
{
int level = 1;
return new TreasureMap( level, Map.Britannia );
}
else if ( type == typeof( MessageInABottle ) )
{
return new MessageInABottle();
}
Container pack = from.Backpack;
if ( pack != null )
{
List<SOS> messages = pack.FindItemsByType<SOS>();
for ( int i = 0; i < messages.Count; ++i )
{
SOS sos = messages[i];
if ( from.Map == Map.Britannia && from.InRange( sos.TargetLocation, 60 ) )
{
Item preLoot = null;
switch ( Utility.Random( 8 ) )
{
case 0: // Body parts
{
int[] list = new int[]
{
0x1CDD, 0x1CE5, // arm
0x1CE0, 0x1CE8, // torso
0x1CE1, 0x1CE9, // head
0x1CE2, 0x1CEC // leg
};
preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
break;
}
case 1: // Bone parts
{
int[] list = new int[]
{
0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls
0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
0x1B15, 0x1B16 // pelvis bones
};
preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
break;
}
case 2: // Paintings and portraits
{
preLoot = new ShipwreckedItem( Utility.RandomPainting() );
break;
}
case 3: // Pillows
{
preLoot = new ShipwreckedItem( Utility.Random( 0x13A4, 11 ) );
break;
}
case 4: // Shells
{
preLoot = new ShipwreckedItem( Utility.Random( 0xFC4, 9 ) );
break;
}
case 5: //Hats
{
if ( Utility.RandomBool() )
preLoot = new SkullCap();
else
preLoot = new TricorneHat();
break;
}
case 6: // Misc
{
int[] list = new int[]
{
0x1EB5, // unfinished barrel
0xA2A, // stool
0xC1F, // broken clock
0x1047, 0x1048, // globe
0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves
};
if ( Utility.Random( list.Length + 1 ) == 0 )
preLoot = new Candelabra();
else
preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
break;
}
}
if ( preLoot != null )
{
if ( preLoot is IShipwreckedItem )
( (IShipwreckedItem)preLoot ).IsShipwreckedItem = true;
return preLoot;
}
LockableContainer chest;
if ( sos.IsAncient )
chest = new AncientChest();
else
chest = new SunkenChest();
TreasureMapChest.Fill( chest, Math.Max( 1, Math.Max( 4, sos.Level ) ) );
if ( sos.IsAncient )
chest.DropItem( new FabledFishingNet() );
else
chest.DropItem( new SpecialFishingNet() );
chest.Movable = true;
chest.Locked = false;
chest.TrapType = TrapType.None;
chest.TrapPower = 0;
chest.TrapLevel = 0;
sos.Delete();
return chest;
}
}
}
return base.Construct( type, from );
}
public override bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( item is TreasureMap || item is MessageInABottle || item is SpecialFishingNet )
{
BaseCreature serp;
if ( 0.25 > Utility.RandomDouble() )
serp = new DeepSeaSerpent();
else
serp = new SeaSerpent();
int x = m.X, y = m.Y;
Map map = m.Map;
for ( int i = 0; map != null && i < 20; ++i )
{
int tx = m.X - 10 + Utility.Random( 21 );
int ty = m.Y - 10 + Utility.Random( 21 );
LandTile t = map.Tiles.GetLandTile( tx, ty );
if ( t.Z == -5 && ( (t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137) ) && !Spells.SpellHelper.CheckMulti( new Point3D( tx, ty, -5 ), map ) )
{
x = tx;
y = ty;
break;
}
}
serp.MoveToWorld( new Point3D( x, y, -5 ), map );
serp.Home = serp.Location;
serp.RangeHome = 10;
serp.PackItem( item );
m.SendLocalizedMessage( 503170 ); // Uh oh! That doesn't look like a fish!
return true; // we don't want to give the item to the player, it's on the serpent
}
if ( item is BigFish || item is WoodenChest || item is MetalGoldenChest )
placeAtFeet = true;
return base.Give( m, item, placeAtFeet );
}
public override void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
{
if ( item is BigFish )
{
from.SendLocalizedMessage( 1042635 ); // Your fishing pole bends as you pull a big fish from the depths!
((BigFish)item).Fisher = from;
}
else if ( item is WoodenChest || item is MetalGoldenChest )
{
from.SendLocalizedMessage( 503175 ); // You pull up a heavy chest from the depths of the ocean!
}
else
{
int number;
string name;
if ( item is BaseMagicFish )
{
number = 1008124;
name = "a mess of small fish";
}
else if ( item is Fish )
{
number = 1008124;
name = "a fish";
}
else if ( item is BaseShoes )
{
number = 1008124;
name = item.ItemData.Name;
}
else if ( item is TreasureMap )
{
number = 1008125;
name = "a sodden piece of parchment";
}
else if ( item is MessageInABottle )
{
number = 1008125;
name = "a bottle, with a message in it";
}
else if ( item is SpecialFishingNet )
{
number = 1008125;
name = "a special fishing net"; // TODO: this is just a guess--what should it really be named?
}
else
{
number = 1043297;
if ( (item.ItemData.Flags & TileFlag.ArticleA) != 0 )
name = "a " + item.ItemData.Name;
else if ( (item.ItemData.Flags & TileFlag.ArticleAn) != 0 )
name = "an " + item.ItemData.Name;
else
name = item.ItemData.Name;
}
if ( number == 1043297 )
from.SendLocalizedMessage( number, name );
else
from.SendLocalizedMessage( number, true, name );
}
}
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
base.OnHarvestStarted( from, tool, def, toHarvest );
int tileID;
Map map;
Point3D loc;
if ( GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ),
delegate
{
Effects.SendLocationEffect( loc, map, 0x352D, 16, 4 );
Effects.PlaySound( loc, map, 0x364 );
} );
}
public override void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
{
base.OnHarvestFinished( from, tool, def, vein, bank, resource, harvested );
}
public override object GetLock( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
return this;
}
public override bool BeginHarvesting( Mobile from, Item tool )
{
if ( !base.BeginHarvesting( from, tool ) )
return false;
from.SendLocalizedMessage( 500974 ); // What water do you want to fish in?
return true;
}
public override bool CheckHarvest( Mobile from, Item tool )
{
if ( !base.CheckHarvest( from, tool ) )
return false;
if ( from.Mounted )
{
from.SendLocalizedMessage( 500971 ); // You can't fish while riding!
return false;
}
return true;
}
public override bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
return false;
if ( from.Mounted )
{
from.SendLocalizedMessage( 500971 ); // You can't fish while riding!
return false;
}
return true;
}
public static int[] m_WaterTiles = new int[]
{
0x00A8, 0x00A9, 0x00AA, 0x00AB,
0x0136, 0x0137,
0x5797, 0x5798, 0x5799, 0x579A, 0x579B, 0x579C,
0x746E, 0x746F, 0x7470, 0x7471, 0x7472, 0x7473, 0x7474, 0x7475, 0x7476, 0x7477, 0x7478, 0x7479, 0x747A, 0x747B, 0x747C, 0x747ED, 0x747E, 0x747F,
0x7480, 0x7481, 0x7482, 0x7483, 0x7484, 0x7485,
0x7494, 0x7495, 0x7496, 0x7497, 0x7498, 0x7499, 0x749A, 0x749B, 0x749C, 0x749D, 0x749E,
0x74A0, 0x74A1, 0x74A2, 0x74A3, 0x74A4, 0x74A5, 0x74A6, 0x74A7, 0x74A8, 0x74A9, 0x74AA, 0x74AB,
0x74B8, 0x74BA, 0x74BB, 0x74BD, 0x74BE, 0x74BF,
0x74C0, 0x74C2, 0x74C3, 0x74C4, 0x74C5, 0x74C7, 0x74C8, 0x74C9, 0x74CA
};
}
}

View file

@ -0,0 +1,161 @@
using System;
using Server;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Harvest
{
public class Lumberjacking : HarvestSystem
{
private static Lumberjacking m_System;
public static Lumberjacking System
{
get
{
if ( m_System == null )
m_System = new Lumberjacking();
return m_System;
}
}
private HarvestDefinition m_Definition;
public HarvestDefinition Definition
{
get{ return m_Definition; }
}
private Lumberjacking()
{
HarvestResource[] res = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 500498, typeof( WoodBoard ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#region Lumberjacking
HarvestDefinition lumber = new HarvestDefinition();
// Resource banks are every 4x3 tiles
lumber.BankWidth = 4;
lumber.BankHeight = 3;
// Every bank holds from 20 to 45 logs
lumber.MinTotal = 20;
lumber.MaxTotal = 45;
// A resource bank will respawn its content every 20 to 30 minutes
lumber.MinRespawn = TimeSpan.FromMinutes( 20.0 );
lumber.MaxRespawn = TimeSpan.FromMinutes( 30.0 );
lumber.Trade = Trades.Lumberjacking;
// Set the list of harvestable tiles
lumber.Tiles = m_TreeTiles;
// Players must be within 2 tiles to harvest
lumber.MaxRange = 2;
// Ten logs per harvest action
lumber.ConsumedPerHarvest = 10;
// The chopping effect
lumber.EffectActions = new int[]{ 13 };
lumber.EffectSounds = new int[]{ 0x13E };
lumber.EffectCounts = new int[]{ 1, 2, 2, 2, 3 };
lumber.EffectDelay = TimeSpan.FromSeconds( 1.6 );
lumber.EffectSoundDelay = TimeSpan.FromSeconds( 0.9 );
lumber.NoResourcesMessage = 500493; // There's not enough wood here to harvest.
lumber.FailMessage = 500495; // You hack at the tree for a while, but fail to produce any useable wood.
lumber.OutOfRangeMessage = 500446; // That is too far away.
lumber.PackFullMessage = 500497; // You can't place any wood into your backpack!
lumber.ToolBrokeMessage = 500499; // You broke your axe.
lumber.Resources = res;
lumber.Veins = veins;
lumber.RandomizeVeins = false;
m_Definition = lumber;
Definitions.Add( lumber );
#endregion
}
public override bool CheckHarvest( Mobile from, Item tool )
{
if ( !base.CheckHarvest( from, tool ) )
return false;
return true;
}
public override bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
return false;
if ( tool.Parent != from )
{
from.SendLocalizedMessage( 500487 ); // The axe must be equipped for any serious wood chopping.
return false;
}
return true;
}
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
if ( toHarvest is Mobile )
{
Mobile obj = (Mobile)toHarvest;
obj.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 500450 ); // You can only skin dead creatures.
}
else if ( toHarvest is Item )
{
Item obj = (Item)toHarvest;
obj.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 500464 ); // Use this on corpses to carve away meat and hide
}
else if ( toHarvest is Targeting.StaticTarget || toHarvest is Targeting.LandTarget )
from.SendLocalizedMessage( 500489 ); // You can't use an axe on that.
else
from.SendLocalizedMessage( 1005213 ); // You can't do that
}
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
base.OnHarvestStarted( from, tool, def, toHarvest );
}
public static void Initialize()
{
Array.Sort( m_TreeTiles );
}
#region Tile lists
private static int[] m_TreeTiles = new int[]
{
0x4CCA, 0x4CCB, 0x4CCC, 0x4CCD, 0x4CD0, 0x4CD3, 0x4CD6, 0x4CD8,
0x4CDA, 0x4CDD, 0x4CE0, 0x4CE3, 0x4CE6, 0x4CF8, 0x4CFB, 0x4CFE,
0x4D01, 0x4D41, 0x4D42, 0x4D43, 0x4D44, 0x4D57, 0x4D58, 0x4D59,
0x4D5A, 0x4D5B, 0x4D6E, 0x4D6F, 0x4D70, 0x4D71, 0x4D72, 0x4D84,
0x4D85, 0x4D86, 0x4D94, 0x4D98, 0x4D9C, 0x4DA0, 0x4DA4, 0x4DA8,
0x4CCE, 0x4CCF, 0x4CD1, 0x4CD2, 0x4CD4, 0x4CD5, 0x4CD7, 0x4CD9,
0x4CDB, 0x4CDC, 0x4CDE, 0x4CDF, 0x4CE1, 0x4CE2, 0x4CE4, 0x4CE5,
0x4CE7, 0x4CE8, 0x4CF9, 0x4CFA, 0x4CFC, 0x4CFD, 0x4CFF, 0x4D00,
0x4D02, 0x4D03, 0x4D45, 0x4D46, 0x4D47, 0x4D48, 0x4D49, 0x4D4A,
0x4D4B, 0x4D4C, 0x4D4D, 0x4D4E, 0x4D4F, 0x4D50, 0x4D51, 0x4D52,
0x4D53, 0x4D5C, 0x4D5D, 0x4D5E, 0x4D5F, 0x4D60, 0x4D61, 0x4D62,
0x4D63, 0x4D64, 0x4D65, 0x4D66, 0x4D67, 0x4D68, 0x4D69, 0x4D73,
0x4D74, 0x4D75, 0x4D76, 0x4D77, 0x4D78, 0x4D79, 0x4D7A, 0x4D7B,
0x4D7C, 0x4D7D, 0x4D7E, 0x4D7F, 0x4D87, 0x4D88, 0x4D89, 0x4D8A,
0x4D8B, 0x4D8C, 0x4D8D, 0x4D8E, 0x4D8F, 0x4D90, 0x4D95, 0x4D96,
0x4D97, 0x4D99, 0x4D9A, 0x4D9B, 0x4D9D, 0x4D9E, 0x4D9F, 0x4DA1,
0x4DA2, 0x4DA3, 0x4DA5, 0x4DA6, 0x4DA7, 0x4DA9, 0x4DAA, 0x4DAB,
0x52B5, 0x52B6, 0x52B7, 0x52B8, 0x52B9, 0x52BA, 0x52BB, 0x52BC,
0x52BD, 0x52BE, 0x52BF, 0x52C0, 0x52C1, 0x52C2, 0x52C3, 0x52C4,
0x52C5, 0x52C6, 0x52C7, 0x624A, 0x624C, 0x624D, 0x58D4, 0x58D5,
0x58D6, 0x58D7, 0x58D8, 0x58D9, 0x58DA, 0x58DB, 0x58DC
};
#endregion
}
}

View file

@ -0,0 +1,211 @@
using System;
using Server;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Engines.Harvest
{
public class Mining : HarvestSystem
{
private static Mining m_System;
public static Mining System
{
get
{
if ( m_System == null )
m_System = new Mining();
return m_System;
}
}
private HarvestDefinition m_OreAndStone;
public HarvestDefinition OreAndStone
{
get{ return m_OreAndStone; }
}
private Mining()
{
HarvestResource[] res = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 503044, typeof( IronOre ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#region Mining for ore and stone
HarvestDefinition oreAndStone = m_OreAndStone = new HarvestDefinition();
// Resource banks are every 8x8 tiles
oreAndStone.BankWidth = 8;
oreAndStone.BankHeight = 8;
// Every bank holds from 10 to 34 ore
oreAndStone.MinTotal = 10;
oreAndStone.MaxTotal = 34;
// A resource bank will respawn its content every 10 to 20 minutes
oreAndStone.MinRespawn = TimeSpan.FromMinutes( 10.0 );
oreAndStone.MaxRespawn = TimeSpan.FromMinutes( 20.0 );
oreAndStone.Trade = Trades.Mining;
// Set the list of harvestable tiles
oreAndStone.Tiles = m_MountainAndCaveTiles;
// Players must be within 2 tiles to harvest
oreAndStone.MaxRange = 2;
// One ore per harvest action
oreAndStone.ConsumedPerHarvest = 1;
// The digging effect
oreAndStone.EffectActions = new int[]{ 11 };
oreAndStone.EffectSounds = new int[]{ 0x125, 0x126 };
oreAndStone.EffectCounts = new int[]{ 1 };
oreAndStone.EffectDelay = TimeSpan.FromSeconds( 1.6 );
oreAndStone.EffectSoundDelay = TimeSpan.FromSeconds( 0.9 );
oreAndStone.NoResourcesMessage = 503040; // There is no metal here to mine.
oreAndStone.DoubleHarvestMessage = 503042; // Someone has gotten to the metal before you.
oreAndStone.TimedOutOfRangeMessage = 503041; // You have moved too far away to continue mining.
oreAndStone.OutOfRangeMessage = 500446; // That is too far away.
oreAndStone.FailMessage = 503043; // You loosen some rocks but fail to find any useable ore.
oreAndStone.PackFullMessage = 1010481; // Your backpack is full, so the ore you mined is lost.
oreAndStone.ToolBrokeMessage = 1044038; // You have worn out your tool!
oreAndStone.Resources = res;
oreAndStone.Veins = veins;
oreAndStone.RandomizeVeins = false;
Definitions.Add( oreAndStone );
#endregion
}
public override Type GetResourceType( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
return base.GetResourceType( from, tool, def, map, loc, resource );
}
public override bool CheckHarvest( Mobile from, Item tool )
{
if ( !base.CheckHarvest( from, tool ) )
return false;
if ( from.Mounted )
{
from.SendLocalizedMessage( 501864 ); // You can't mine while riding.
return false;
}
else if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
}
return true;
}
public override void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
{
base.SendSuccessTo( from, item, resource );
}
public override bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
return false;
if ( from.Mounted )
{
from.SendLocalizedMessage( 501864 ); // You can't mine while riding.
return false;
}
else if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
}
return true;
}
private static int[] m_Offsets = new int[]
{
-1, -1,
-1, 0,
-1, 1,
0, -1,
0, 1,
1, -1,
1, 0,
1, 1
};
public override bool BeginHarvesting( Mobile from, Item tool )
{
if ( !base.BeginHarvesting( from, tool ) )
return false;
from.SendLocalizedMessage( 503033 ); // Where do you wish to dig?
return true;
}
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
base.OnHarvestStarted( from, tool, def, toHarvest );
}
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
if ( toHarvest is LandTarget )
from.SendLocalizedMessage( 501862 ); // You can't mine there.
else
from.SendLocalizedMessage( 501863 ); // You can't mine that.
}
#region Tile lists
private static int[] m_MountainAndCaveTiles = new int[]
{
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 236, 237, 238, 239, 240, 241, 242, 243,
244, 245, 246, 247, 252, 253, 254, 255, 256, 257,
258, 259, 260, 261, 262, 263, 268, 269, 270, 271,
272, 273, 274, 275, 276, 277, 278, 279, 286, 287,
288, 289, 290, 291, 292, 293, 294, 296, 296, 297,
321, 322, 323, 324, 467, 468, 469, 470, 471, 472,
473, 474, 476, 477, 478, 479, 480, 481, 482, 483,
484, 485, 486, 487, 492, 493, 494, 495, 543, 544,
545, 546, 547, 548, 549, 550, 551, 552, 553, 554,
555, 556, 557, 558, 559, 560, 561, 562, 563, 564,
565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
575, 576, 577, 578, 579, 581, 582, 583, 584, 585,
586, 587, 588, 589, 590, 591, 592, 593, 594, 595,
596, 597, 598, 599, 600, 601, 610, 611, 612, 613,
1010, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749,
1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1771, 1772,
1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782,
1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1801, 1802,
1803, 1804, 1805, 1806, 1807, 1808, 1809, 1811, 1812, 1813,
1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823,
1824, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839,
1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849,
1850, 1851, 1852, 1853, 1854, 1861, 1862, 1863, 1864, 1865,
1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875,
1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1981,
1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2028, 2029, 2030, 2031, 2032, 2033, 2100,
2101, 2102, 2103, 2104, 2105,
0x453B, 0x453C, 0x453D, 0x453E, 0x453F, 0x4540, 0x4541,
0x4542, 0x4543, 0x4544, 0x4545, 0x4546, 0x4547, 0x4548,
0x4549, 0x454A, 0x454B, 0x454C, 0x454D, 0x454E, 0x454F
};
#endregion
}
}

View file

@ -0,0 +1,241 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Accounting;
using Server.Multis;
using Server.Mobiles;
using Server.Regions;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Misc;
using Server.Items;
using System.Globalization;
namespace Server.Engines.Help
{
public class HelpGump : Gump
{
public static void Initialize()
{
EventSink.HelpRequest += new HelpRequestEventHandler( EventSink_HelpRequest );
}
private static void EventSink_HelpRequest( HelpRequestEventArgs e )
{
foreach ( Gump g in e.Mobile.NetState.Gumps )
{
if ( g is HelpGump )
return;
}
e.Mobile.SendGump( new HelpGump( e.Mobile, 1 ) );
}
public static bool CheckCombat( Mobile m )
{
for ( int i = 0; i < m.Aggressed.Count; ++i )
{
AggressorInfo info = m.Aggressed[i];
if ( DateTime.Now - info.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) )
return true;
}
return false;
}
public HelpGump( Mobile from, int page ) : base( 25, 50 )
{
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
AddPage(0);
AddImage(0, 0, 2520);
AddImage(38, 0, 2521);
AddImage(208, 0, 2522);
AddImage(0, 38, 2523);
AddImage(0, 150, 2523);
AddImage(0, 262, 2523);
AddImage(0, 374, 2523);
AddImage(0, 486, 2523);
AddImage(209, 38, 2525);
AddImage(209, 150, 2525);
AddImage(209, 262, 2525);
AddImage(209, 374, 2525);
AddImage(209, 486, 2525);
AddImage(0, 598, 2526);
AddImage(38, 598, 2527);
AddImage(208, 598, 2528);
AddImage(37, 37, 2524);
AddImage(36, 146, 2524);
AddImage(36, 255, 2524);
AddImage(37, 362, 2524);
AddImage(35, 472, 2524);
AddImage(36, 486, 2524);
AddImage(40, 38, 2524);
AddImage(41, 147, 2524);
AddImage(41, 252, 2524);
AddImage(39, 349, 2524);
AddImage(39, 439, 2524);
AddImage(39, 488, 2524);
AddImage(246, 32, 2520);
AddImage(284, 32, 2521);
AddImage(1127, 32, 2522);
AddImage(246, 70, 2523);
AddImage(246, 182, 2523);
AddImage(246, 294, 2523);
AddImage(246, 406, 2523);
AddImage(246, 518, 2523);
AddImage(1128, 70, 2525);
AddImage(1128, 182, 2525);
AddImage(1128, 294, 2525);
AddImage(1128, 406, 2525);
AddImage(1128, 518, 2525);
AddImage(246, 630, 2526);
AddImage(284, 630, 2527);
AddImage(1127, 630, 2528);
AddImage(283, 69, 2524);
AddImage(282, 178, 2524);
AddImage(282, 287, 2524);
AddImage(283, 394, 2524);
AddImage(281, 504, 2524);
AddImage(282, 518, 2524);
AddImage(286, 70, 2524);
AddImage(287, 179, 2524);
AddImage(287, 284, 2524);
AddImage(285, 381, 2524);
AddImage(285, 471, 2524);
AddImage(285, 520, 2524);
AddImage(454, 32, 2534);
AddImage(454, 630, 2535);
AddImage(453, 69, 2524);
AddImage(452, 178, 2524);
AddImage(452, 287, 2524);
AddImage(453, 394, 2524);
AddImage(451, 504, 2524);
AddImage(452, 518, 2524);
AddImage(456, 70, 2524);
AddImage(457, 179, 2524);
AddImage(457, 284, 2524);
AddImage(455, 381, 2524);
AddImage(455, 471, 2524);
AddImage(455, 520, 2524);
AddImage(624, 32, 2521);
AddImage(624, 630, 2527);
AddImage(623, 69, 2524);
AddImage(622, 178, 2524);
AddImage(622, 287, 2524);
AddImage(623, 394, 2524);
AddImage(621, 504, 2524);
AddImage(622, 518, 2524);
AddImage(626, 70, 2524);
AddImage(627, 179, 2524);
AddImage(627, 284, 2524);
AddImage(625, 381, 2524);
AddImage(625, 471, 2524);
AddImage(625, 520, 2524);
AddImage(792, 32, 2534);
AddImage(792, 630, 2535);
AddImage(791, 69, 2524);
AddImage(790, 178, 2524);
AddImage(790, 287, 2524);
AddImage(791, 394, 2524);
AddImage(789, 504, 2524);
AddImage(790, 518, 2524);
AddImage(794, 70, 2524);
AddImage(795, 179, 2524);
AddImage(795, 284, 2524);
AddImage(793, 381, 2524);
AddImage(793, 471, 2524);
AddImage(793, 520, 2524);
AddImage(960, 32, 2521);
AddImage(960, 630, 2527);
AddImage(959, 69, 2524);
AddImage(958, 178, 2524);
AddImage(958, 287, 2524);
AddImage(959, 394, 2524);
AddImage(957, 504, 2524);
AddImage(958, 518, 2524);
AddImage(962, 70, 2524);
AddImage(963, 179, 2524);
AddImage(963, 284, 2524);
AddImage(961, 381, 2524);
AddImage(961, 471, 2524);
AddImage(961, 520, 2524);
AddHtml( 26, 14, 200, 20, @"<BODY><BASEFONT Color=#2a335d><BIG><CENTER>HELP</CENTER></BIG></BASEFONT></BODY>", (bool)false, (bool)false);
int v = 35;
int b = 60;
int i = 15;
int s = 0;
string c = "5c4c32";
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 1, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Basics</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 2, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Trades</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 3, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Guilds</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 4, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Homes</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 5, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Ships</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
AddButton(v, i, 2536, 2536, 6, GumpButtonType.Reply, 0);
AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Skills</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
AddHtml( 298, 46, 604, 20, @"<BODY><BASEFONT Color=#2a335d><BIG>" + ( HelpText( page, 1 ) ).ToUpper() + "</BIG></BASEFONT></BODY>", (bool)false, (bool)false);
AddHtml( 284, 79, 844, 547, @"<BODY><BASEFONT Color=#5c4c32><BIG>" + HelpText( page, 3 ) + "</BIG></BASEFONT></BODY>", (bool)false, (bool)(bool.Parse(HelpText( page, 2 ))));
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( info.ButtonID > 0 )
from.SendGump( new Server.Engines.Help.HelpGump( from, info.ButtonID ) );
}
public static string HelpText( int page, int part )
{
string val = "";
if ( page == 1 ){ val = HPBasics.HelpPageBasics( part ); }
else if ( page == 2 ){ val = HPTrades.HelpPageTrades( part ); }
else if ( page == 3 ){ val = HPGuilds.HelpPageGuilds( part ); }
else if ( page == 4 ){ val = HPHomes.HelpPageHomes( part ); }
else if ( page == 5 ){ val = HPShips.HelpPageShips( part ); }
else if ( page == 6 ){ val = HPSkills.HelpPageSkills( part ); }
return val;
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using Server;
namespace Server.Misc
{
public class HPBasics
{
public static string HelpPageBasics( int part )
{
string title = "Basics";
string scroll = "false";
string text = @"This is the main page!
";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,73 @@
using System;
using Server;
namespace Server.Misc
{
public class HPGuilds
{
public static string HelpPageGuilds( int part )
{
string title = "Guilds";
string scroll = "true";
string text = @"Player characters can start their own guilds, where they need only a guildstone and a house. Deeds for guildstones can be purchase from a provisioner.
There are also local guilds one can join. Some join them for increased learning, and thus quicker acquisition of skills. Other guild also may provide an advantage toward a trade skill. Search the towns and cities for a guildmaster of your desired guild. Single click on them and choose the JOIN option. They will tell you the price to join, where you can hand them the gold if you have it. If you are already a member of a guild, they will inform you that you need to resign from that guild first. Find your current guildmaster, and single click on them to choose the RESIGN option. Then you can join another guild. If you have over 4 murders reported against you, you will not be able to join any guilds and you will be suspended from any guild you are a member of. The exceptions to this are the Assassins Guild and Thieves Guild. Guildmasters will sell things to members as well.
Below are the various local guilds you can join:
ALCHEMISTS GUILD
Members of this guild have an advantage toward creating potions.
ASSASSINS GUILD
This dark guild usually attracts members that want an increased learning in fencing, hiding, poisoning, and stealth.
BARDS GUILD
Musicians join this guild to have an increased learning in music, discordance, peacemaking, and provocation.
BLACKSMITHS GUILD
Guild members have an advantage toward mining and blacksmithing.
CARPENTERS GUILD
Members have an advantage toward the woodworking trade.
HEALERS GUILD
Those that join this guild have a much increased learning in using bandages. Only guild members are able to resurrect another with bandages.
LIBRARIANS GUILD
Those that work on scribing magic scrolls, drawing maps, or deciphering treasure maps often join this guild to get an advantage in doing such tasks.
MAGES GUILD
Joining this guild gives the aspiring wizard an improved learning in magery, meditation, and concentration.
MARINERS GUILD
Fisherman often join this guild to have a much improved chance of acquiring things below the surface of the sea. Mariner guild members can also dock or launch their ship from any shore in the land.
RANGERS GUILD
Members of this guild get an advantage when crafting bows, arrows, or bolts. Rangers also have an increased learning in archery, tactics, and tracking.
TAILORS GUILD
Having an advantage in the tailoring trade come with membership in this guild.
THIEVES GUILD
Those seeking to pilfer things that don't belong to them, will seek out this guild. Members have an increased learning in hiding, lockpicking, stealing, and stealth.
TINKERS GUILD
Members of this guild get an advantage when creating things within this trade.
WARRIORS GUILD
Those seeking to be great warriors, eventually join this elite guild. Members have an increased learning in bludgeoning, fencing, parrying, swords, and tactics.
";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,86 @@
using System;
using Server;
namespace Server.Misc
{
public class HPHomes
{
public static string HelpPageHomes( int part )
{
string title = "Trades";
string scroll = "true";
string text = @"Trades are secondary skills you can use to produce or create items. All characters can use any of the trades available in the game as the base value of trade skills is 10. The proficiency in trades is dependent on the character's statistics (strength, intelligence, and dexterity). The higher the appropriate statistics, the better the trade skill. Most trades are influenced by a primary attribute, and slightly affected by a secondary attribute. These are listed with the trades below, where the primary is first, followed by the secondary. If you are a member of the associated guild, you will get a bonus of 20 to the trade(s). Like ordinary skills, trade skills cannot be higher than 100. Trade skills are not a part of a characters overall regular skill cap. The trade skills are listed below:
ALCHEMY
- Int / Dex
- Alchemists Guild
Get some empty bottles, a mortar & pestle, and some reagents to start creating potions. Reagents used are black pearl, bloodmoss, garlic, ginseng, mandrake root, nightshade, spiders silk, and sulfurous ash.
BLACKSMITHING
- Str / Dex
- Blacksmiths Guild
Using a tool like tongs or a hammer, with some ingots, and you can begin crafting armor and weapons. You can also repair such items that are made of metal, but you need to be near an anvil and forge to perform this trade.
CARPENTRY
- Dex / Str
- Carpentry Guild
Tools, like a saw, can be used with logs to create items like chairs, tables, or staves. You can also create stone chairs or stone tables if you have the right amount of ore.
CARTOGRAPHY
- Int / Dex
- Librarians Guild
With a mapmaking pen and some blank scrolls, you can start mapping the area around you. These maps can come in handy as sea charts as well, plotting courses to give to your ship's tillerman. A good cartographer can also decipher treasure maps, to discover where they are buried.
COOKING
- Int / Dex
Using an item like a frying pan, you can take various ingredients to create edible foods. Some ingredients can be purchases where others can be acquired from gardens. You can also harvest wheat and use a nearby mill to create some flour.
FISHING
- Str / Dex
- Mariners Guild
Grab a fishing pole, place it in your hand, and use it to cast a line onto the water. This trade is mostly a way to feed yourself with fresh fish, but some use the skill to help them learn the fates of discovered messages in bottles. Also using fishing nets is something fisherman do.
FLETCHING
- Dex / Str
- Rangers Guild
With some fletching tools, you can take some logs and create bows and arrows. For arrows you will need some feathers, but killing some birds will help with that. Use a bladed item (dagger, sword, etc.) on a dead bird to cut the feathers off. You can also repair bows.
INSCRIPTION
- Int / Dex
- Librarians Guild
Using a scribe pen and some blank scrolls, mages often use this to create scrolls from the spells they have learned. Creating a scroll requires a spellbook with the spell already in it, and also the reagents required to cast the spell.
LUMBERJACKING
- Str / Dex
- Carpentry Guild
Grab an axe, double click it, and then target a tree to chop some wood. Logs are pretty heavy so you may want to acquire a pack mule from the local stable master to help you haul it away. Logs can be used for carpentry or fletching.
MINING
- Str
- Blacksmiths Guild
With a shovel or pickaxe, you can go along a mountainside or into a cave and dig up some ore. Ore is pretty heavy so you may want to acquire a pack mule from the local stable master to help you haul it away. Using the ore on a forge will turn that into ingots you can use for blacksmithing.
TAILORING
- Dex / Int
- Tailors Guild
A sewing kit can be used to make some elegant clothing, leather armor, and even stitch bones together to make some horrific bone armor. You can repair such armor with this trade as well. Leather can be acquired from skinning many slain creatures by using a bladed item (dagger, sword, etc.) on the dead creature. Using scissors on the acquired hides will turn it into leather you can use. Bones can be found on slain skeletal creatures. To acquire cloth, you can buy it or you can pick the cotton and flax from gardens and use that on a spinning wheel. Then you can use the thread on a loom to make some cloth. You can do something similar by sheering sheep. Using scissors on the bolts of cloth will produce sheets of cloth you can craft with. Using scissors on cut cloth will turn that into bandages, which is used with the healing skill.
TINKERING
- Dex / Int
- Tinkers Guild
Tinkering is a handy craft as it allows you to make many tools that are used for other trades. With a set of tinker tools, and usually some ingots, you can create such items. You can even crush gems into a crystal powder and make glass items like bottles and vials. Just drop some gems onto a mortar and pestle and you will grind it into this fine powder.
";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,60 @@
using System;
using Server;
namespace Server.Misc
{
public class HPShips
{
public static string HelpPageShips( int part )
{
string days = ((int)(Server.Misc.Settings. BoatDelete())).ToString();
string title = "Ships";
string scroll = "true";
string text = @"If one wants to venture out onto the high seas, they will need to acquire a ship. Shipwrights sell such vessels, but sometimes a provisioner may have a small ship for sale as well. When you buy a ship, you will be given a deed that you would use near a dock to launch your new ship. When you choose a valid place for your ship, it will appear on the sea where a key will be provided in your backpack and another in your chest back at the inn. You can use this key by double clicking it and then selecting the side plank doors of the ship to either lock or unlock them.
To board your ship, you can double click the side door of the boat to extend the plank. You can then double click the plank to board your ship. To disembark, double click the door again to extend the plank and then walk onto it. You may have to step on and off a couple of times until you disembark onto land.
While on your ship, double click the tillerman to have a navigation window open. This will help you navigate your ship on the sea. If you want to rename your ship, then select the shipwright sign symbol on the lower right of this window. There is also a small X button near that if you want to close the navigation window. Much of the other buttons consists of arrows to steer your ship, drop or raise the anchor, and even extend or close the planks.
To dock your ship, you must first ensure that the hold is clear and the deck is clean. Then drop the anchor and disembark your ship. Once on shore, you can double click the tillerman to get a confirmation window about docking your ship. If this window does not appear, wait a few seconds and try again. Docking your ship will place a small ship model in your backpack that you can take with you and launch elsewhere.
Ships come in different sizes, and you should buy a ship that will hold the amount of goods you need it to. Below is a list of ships you can get:
Small Ship
Hold: 1,000 stones of weight
Small Dragon Ship
Hold: 1,400 stones of weight
Medium Ship
Hold: 1,800 stones of weight
Medium Dragon Ship
Hold: 2,200 stones of weight
Large Ship
Hold: 2,600 stones of weight
Large Dragon Ship
Hold: 3,200 stones of weight
Each ship has a hold at the front, that you can access like any other container by double clicking it. You cannot dock a ship while there are items in this hold or on the deck. You must be near a dock to launch or dock your ship. Being near a home you own will also allow you to do these actions. A member of the Mariners Guild can launch or dock their ship from any shore in the land.
Ships not only allow you to travel to far off lands, but they also provide different types of items to be fished up from the sea as opposed to just fishing from the shore. You could battle hideous sea creatures, or find a message in a bottle that contains a note to some sunken treasure.
An unattended ship will eventually have its hold rot and sink into the ocean. ";
text = text + "This will occur if nobody uses the ship within about " + days + " real world days.";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,107 @@
using System;
using Server;
namespace Server.Misc
{
public class HPSkills
{
public static string HelpPageSkills( int part )
{
string days = ((int)(Server.Misc.Settings. BoatDelete())).ToString();
string title = "Skills";
string scroll = "true";
string text = @"There are 25 available skills, and they rank from 0 to 100. Some of your attributes (strength, dexterity, or intelligence) can affect these values. A character has the opportunity to acquire a total of 700 skill points that can be gained. Once a character acquires 700 skill points, they can gain no more. A character can manage these gains and losses, however, and they would do that by using the SKILLS button on their character's PAPERDOLL. Each skill has arrows that can be set to gain, lower, or lock. So if you want to train a new skill, but are out of available points to gain, you can set a current skill to lower. If you want a skill to stop advancing, you can lock it at that value.
Some skills are used naturally during gameplay, while others have an action button associated with it. You can identify these on the SKILLS window if they have a blue gem icon on the left. You can click this gem to activate the skill, you or can click and drag the skill name from the SKILLS window, onto the view screen. A button will appear that will let you use the skill, and you can place that quick button wherever you want.
Below are the available skills, and a description of each:
ARCHERY
Determines the accuracy and effectiveness with bows and crossbows. You can do some rudimentary practicing on archery buttes.
BLUDGEONING
This skill is used for blunt weapons like staves, maces, mauls, whips, or clubs. You can do some rudimentary practicing on training dummies. Attacks can provide a bonus when averaging a warrior's skill with bludgeoning, swords, and fencing weapons.
CONCENTRATION
Wizards often practice this skill, that makes their spells more effective. It also helps them use less mana for casting spells.
DISCORDANCE
This is a bardic ability, where a musical instrument can be used to play a song that causes another to fight less effectively.
DODGING
This provides the ability to dodge physical attacks from others. It is influenced by dexterity and the amount of armor worn. The more armor (and heavier the armor) being worn will reduce the chance to dodge. It may also help one avoid dungeon floor and wall traps.
FENCING
This skill is used for piercing weapons like spears, pikes, rapiers, daggers, forks, or a kryss. You can do some rudimentary practicing on training dummies. Attacks can provide a bonus when averaging a warrior's skill with bludgeoning, swords, and fencing weapons.
HAND-TO-HAND
Using your bare hands for combat isn't the most effective of offensive skills, but it does provide ways for mages to be more defensive and effective. It has the benefits of faster spell casting and faster spell casting recovery. It also helps mages perhaps avoid having their spells interrupted. You can do some rudimentary practicing on training dummies.
HEALING
Bandages are used for this skill, and will allow for one to heal another or even cure poisons if talented enough. As a healer gets better with this skill, their ability to wrap a bandage is quicker. Those in the Healers Guild are said to be able to resurrect others with this method.
HIDING
This allows one to hide from others. Someone with revealing magic, or a good searching skill, may be able to find you. Hiding is also important for being able to walk around stealthily.
LOCKPICKING
Using lockpicks, a good thief can bypass almost any locked chest or dungeon door. Where most leave a dungeon with treasure, thieves often leave with much more since they can open what others cannot.
MAGERY
The art of magic can be powerful. Seek a mage to acquire a spellbook and some scrolls to get started. Do not forget to buy reagents, as spells require them to cast. The spellbook will inform you on everything you need to know about magery. Hovering your cursor over the spell page icon will briefly describe the spell for you.
MEDITATION
The ability to regain mana quickly is quite beneficial for a mage. This skill improves that recovery.
MUSICIANSHIP
This is the art of playing musical instruments. Without this skill, then a bard would not be able to use skills like discordance, peacemaking, and provocation.
PARRYING
Wielding a shield, a warrior can possibly avoid or reduce damages from physical attacks.
PEACEMAKING
Using this skill with an instrument will put even the angriest monster at ease, making them calm and unwilling to fight.
POISONING
Using poisons on bladed weapons, can only be accomplished with this skill. The better the skill, the deadlier of poisons one can use. Use the skill on a bottle of poison, and select the edged weapon you wish to poison. Whenever you strike an opponent with the weapon, they will also be poisoned if they are not immune to such things. If you ever want to wipe the poison off of the blade, then use an oil cloth to clean it.
PROVOCATION
Playing the proper musical tune will cause creatures to fight each other instead of you or your comrades.
REMOVE TRAPS
This skill can actively be used on containers and dungeon doors, and passively checked when passing near dungeon floor and wall traps. If successful, you would render the trap useless.
RESISTING SPELLS
The ability to avoid the effects of spells, or lessen the negative effects of spells, is determined by this skill.
SEARCHING
If you want to find a hidden creature, then you would use this skill to do that. This skill is also helpful in finding more treasure in dungeons, from both creatures and containers. Searching for more treasure is also enhanced if you have recently been magically night sighted. Holding a lit lantern, torch, or candle in your hands also enhances the search for hidden treasure.
STEALING
Stealing is seldom employed by thieves to take things from citizens, but more used for taking from monstrous creatures or murderous humanoids. You can double click a creature to open their pack, or double click a human to open their PAPERDOLL and then double click their backpack. Your stealing skill will be tested to see if you can peek into the pack. If you manage to open it, then you can try to take things from it. You must have both hands free to steal, and you cannot steal things from creatures if they are too heavy. Stealing is also used to take things from ornate dungeon chests, that require a sleight of hand to grab before they magically vanishing. Stealing from these chests do not have the weight restriction as creatures have, so you can attempt to steal anything within the chest. You can do some rudimentary practicing on pickpocket dips.
STEALTH
The better your hiding skill, the better you can use the stealth skill. Walking around without being noticed can be beneficial to anyone, but this skill is often used by rangers, thieves, and assassins. The amount and weight of equipped armor pieces will affect this ability, so the lighter your gear the easier it is to sneak around. Wearing heavier armor can help you get better with this skill.
SWORDSMANSHIP
This skill is used for sharp weapons like swords, axes, and polearms like halberds. You can do some rudimentary practicing on training dummies. Attacks can provide a bonus when averaging a warrior's skill with bludgeoning, swords, and fencing weapons.
TACTICS
This is a general warrior skill, that allows for more effective attacks with weapons. Archers also can benefit from this with their ranged weapons, as well as those that fight hand-to-hand.
TRACKING
Following the path of nearby creatures can come in handy when hunting for prey. The better you are at tracking, the further you can track them.
";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,86 @@
using System;
using Server;
namespace Server.Misc
{
public class HPTrades
{
public static string HelpPageTrades( int part )
{
string title = "Trades";
string scroll = "true";
string text = @"Trades are secondary skills you can use to produce or create items. All characters can use any of the trades available in the game as the base value of trade skills is 10. The proficiency in trades is dependent on the character's statistics (strength, intelligence, and dexterity). The higher the appropriate statistics, the better the trade skill. Most trades are influenced by a primary attribute, and slightly affected by a secondary attribute. These are listed with the trades below, where the primary is first, followed by the secondary. If you are a member of the associated guild, you will get a bonus of 20 to the trade(s). Like ordinary skills, trade skills cannot be higher than 100. Trade skills are not a part of a character's overall regular skill cap. The trade skills are listed below:
ALCHEMY
- Int / Dex
- Alchemists Guild
Get some empty bottles, a mortar & pestle, and some reagents to start creating potions. Reagents used are black pearl, bloodmoss, garlic, ginseng, mandrake root, nightshade, spiders silk, and sulfurous ash.
BLACKSMITHING
- Str / Dex
- Blacksmiths Guild
Using a tool like tongs or a hammer, with some ingots, and you can begin crafting armor and weapons. You can also repair such items that are made of metal, but you need to be near an anvil and forge to perform this trade.
CARPENTRY
- Dex / Str
- Carpentry Guild
Tools, like a saw, can be used with logs to create items like chairs, tables, or staves. You can also create stone chairs or stone tables if you have the right amount of ore.
CARTOGRAPHY
- Int / Dex
- Librarians Guild
With a mapmaking pen and some blank scrolls, you can start mapping the area around you. These maps can come in handy as sea charts as well, plotting courses to give to your ship's tillerman. A good cartographer can also decipher treasure maps, to discover where they are buried. If you discover the location of a buried treasure, get yourself a shovel and travel to that location. Use the shovel on the map and you should start digging it up. Be careful when removing treasure from the chest, as monsters will surely be guarding it from trespassers.
COOKING
- Int / Dex
Using an item like a frying pan, you can take various ingredients to create edible foods. Some ingredients can be purchases where others can be acquired from gardens. You can also harvest wheat and use a nearby mill to create some flour.
FISHING
- Str / Dex
- Mariners Guild
Grab a fishing pole, place it in your hand, and use it to cast a line onto the water. This trade is mostly a way to feed yourself with fresh fish, but some use the skill to help them learn the fates of discovered messages in bottles. Also using fishing nets is something fisherman do.
FLETCHING
- Dex / Str
- Rangers Guild
With some fletching tools, you can take some logs and create bows and arrows. For arrows you will need some feathers, but killing some birds will help with that. Use a bladed item (dagger, sword, etc.) on a dead bird to cut the feathers off. You can also repair bows.
INSCRIPTION
- Int / Dex
- Librarians Guild
Using a scribe pen and some blank scrolls, mages often use this to create scrolls from the spells they have learned. Creating a scroll requires a spellbook with the spell already in it, and also the reagents required to cast the spell.
LUMBERJACKING
- Str / Dex
- Carpentry Guild
Grab an axe, double click it, and then target a tree to chop some wood. Logs are pretty heavy so you may want to acquire a pack mule from the local stable master to help you haul it away. Logs can be used for carpentry or fletching. Logs can get a bit heavy, so using your axe on them will turn them into lighter weight boards.
MINING
- Str
- Blacksmiths Guild
With a shovel or pickaxe, you can go along a mountainside or into a cave and dig up some ore. Ore is pretty heavy so you may want to acquire a pack mule from the local stable master to help you haul it away. Using the ore on a forge will turn that into ingots you can use for blacksmithing.
TAILORING
- Dex / Int
- Tailors Guild
A sewing kit can be used to make some elegant clothing, leather armor, and even stitch bones together to make some horrific bone armor. You can repair such armor with this trade as well. Leather can be acquired from skinning many slain creatures by using a bladed item (dagger, sword, etc.) on the dead creature. Using scissors on the acquired hides will turn it into leather you can use. Bones can be found on slain skeletal creatures. To acquire cloth, you can buy it or you can pick the cotton and flax from gardens and use that on a spinning wheel. Then you can use the thread on a loom to make some cloth. You can do something similar by sheering sheep. Using scissors on the bolts of cloth will produce sheets of cloth you can craft with. Using scissors on cut cloth will turn that into bandages, which is used with the healing skill.
TINKERING
- Dex / Int
- Tinkers Guild
Tinkering is a handy craft as it allows you to make many tools that are used for other trades. With a set of tinker tools, and usually some ingots, you can create such items. You can even crush gems into a crystal powder and make glass items like bottles and vials. Just drop some gems onto a mortar and pestle and you will grind it into this fine powder.
";
if ( part == 1 )
return title;
else if ( part == 2 )
return scroll;
return text;
}
}
}

View file

@ -0,0 +1,30 @@
using System;
using Server.Network;
using Server.Prompts;
namespace Server.Engines.Help
{
public class PagePrompt : Prompt
{
private PageType m_Type;
public PagePrompt( PageType type )
{
m_Type = type;
}
public override void OnCancel( Mobile from )
{
from.SendLocalizedMessage( 501235, "", 0x35 ); // Help request aborted.
}
public override void OnResponse( Mobile from, string text )
{
from.SendLocalizedMessage( 501234, "", 0x35 ); /* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
PageQueue.Enqueue( new PageEntry( from, text, m_Type ) );
}
}
}

View file

@ -0,0 +1,61 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Engines.Help
{
public class PagePromptGump : Gump
{
private Mobile m_From;
private PageType m_Type;
public PagePromptGump( Mobile from, PageType type ) : base( 0, 0 )
{
m_From = from;
m_Type = type;
from.CloseGump( typeof( PagePromptGump ) );
AddBackground( 50, 50, 540, 350, 2600 );
AddPage( 0 );
AddHtmlLocalized( 264, 80, 200, 24, 1062524, false, false ); // Enter Description
AddHtmlLocalized( 120, 108, 420, 48, 1062638, false, false ); // Please enter a brief description (up to 200 characters) of your problem:
AddBackground( 100, 148, 440, 200, 3500 );
AddTextEntry( 120, 168, 400, 200, 1153, 0, "" );
AddButton( 175, 355, 2074, 2075, 1, GumpButtonType.Reply, 0 ); // Okay
AddButton( 405, 355, 2073, 2072, 0, GumpButtonType.Reply, 0 ); // Cancel
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 0 )
{
m_From.SendLocalizedMessage( 501235, "", 0x35 ); // Help request aborted.
}
else
{
TextRelay entry = info.GetTextEntry( 0 );
string text = ( entry == null ? "" : entry.Text.Trim() );
if ( text.Length == 0 )
{
m_From.SendMessage( 0x35, "You must enter a description." );
m_From.SendGump( new PagePromptGump( m_From, m_Type ) );
}
else
{
m_From.SendLocalizedMessage( 501234, "", 0x35 ); /* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
PageQueue.Enqueue( new PageEntry( m_From, text, m_Type ) );
}
}
}
}
}

View file

@ -0,0 +1,395 @@
using System;
using System.Collections;
using System.Net.Mail;
using System.IO;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Misc;
using Server.Accounting;
using Server.Engines.Reports;
using Server.Commands;
using System.Collections.Generic;
namespace Server.Engines.Help
{
public enum PageType
{
Bug,
Stuck,
Account,
Question,
Suggestion,
Other,
VerbalHarassment,
PhysicalHarassment
}
public class PageEntry
{
// What page types should have a speech log as attachment?
public static readonly PageType[] SpeechLogAttachment = new PageType[]
{
PageType.VerbalHarassment
};
private Mobile m_Sender;
private Mobile m_Handler;
private DateTime m_Sent;
private string m_Message;
private PageType m_Type;
private Point3D m_PageLocation;
private Map m_PageMap;
private List<SpeechLogEntry> m_SpeechLog;
private PageInfo m_PageInfo;
public PageInfo PageInfo
{
get{ return m_PageInfo; }
}
public Mobile Sender
{
get
{
return m_Sender;
}
}
public Mobile Handler
{
get
{
return m_Handler;
}
set
{
PageQueue.OnHandlerChanged( m_Handler, value, this );
m_Handler = value;
}
}
public DateTime Sent
{
get
{
return m_Sent;
}
}
public string Message
{
get
{
return m_Message;
}
}
public PageType Type
{
get
{
return m_Type;
}
}
public Point3D PageLocation
{
get
{
return m_PageLocation;
}
}
public Map PageMap
{
get
{
return m_PageMap;
}
}
public List<SpeechLogEntry> SpeechLog
{
get
{
return m_SpeechLog;
}
}
private Timer m_Timer;
public void Stop()
{
if ( m_Timer != null )
m_Timer.Stop();
m_Timer = null;
}
public void AddResponse( Mobile mob, string text )
{
if ( m_PageInfo != null )
{
lock ( m_PageInfo )
m_PageInfo.Responses.Add( PageInfo.GetAccount( mob ), text );
if ( PageInfo.ResFromResp( text ) != PageResolution.None )
m_PageInfo.UpdateResolver();
}
}
public PageEntry( Mobile sender, string message, PageType type )
{
m_Sender = sender;
m_Sent = DateTime.Now;
m_Message = Utility.FixHtml( message );
m_Type = type;
m_PageLocation = sender.Location;
m_PageMap = sender.Map;
PlayerMobile pm = sender as PlayerMobile;
if ( pm != null && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
m_SpeechLog = new List<SpeechLogEntry>( pm.SpeechLog );
m_Timer = new InternalTimer( this );
m_Timer.Start();
StaffHistory history = Reports.Reports.StaffHistory;
if ( history != null )
{
m_PageInfo = new PageInfo( this );
history.AddPage( m_PageInfo );
}
}
private class InternalTimer : Timer
{
private static TimeSpan StatusDelay = TimeSpan.FromMinutes( 2.0 );
private PageEntry m_Entry;
public InternalTimer( PageEntry entry ) : base( TimeSpan.FromSeconds( 1.0 ), StatusDelay )
{
m_Entry = entry;
}
protected override void OnTick()
{
int index = PageQueue.IndexOf( m_Entry );
if ( m_Entry.Sender.NetState != null && index != -1 )
{
m_Entry.Sender.SendLocalizedMessage( 1008077, true, (index + 1).ToString() ); // Thank you for paging. Queue status :
m_Entry.Sender.SendLocalizedMessage( 1008084 ); // You can reference our website at www.uo.com or contact us at support@uo.com. To cancel your page, please select the help button again and select cancel.
if ( m_Entry.Handler != null && m_Entry.Handler.NetState == null ) {
m_Entry.Handler = null;
}
}
else
{
if ( index != -1 )
m_Entry.AddResponse( m_Entry.Sender, "[Logout]" );
PageQueue.Remove( m_Entry );
}
}
}
}
public class PageQueue
{
private static ArrayList m_List = new ArrayList();
private static Hashtable m_KeyedByHandler = new Hashtable();
private static Hashtable m_KeyedBySender = new Hashtable();
public static void Initialize()
{
CommandSystem.Register( "Pages", AccessLevel.Counselor, new CommandEventHandler( Pages_OnCommand ) );
}
public static bool CheckAllowedToPage( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
return true;
if ( pm.DesignContext != null )
{
from.SendLocalizedMessage( 500182 ); // You cannot request help while customizing a house or transferring a character.
return false;
}
else if ( pm.PagingSquelched )
{
from.SendMessage( "You cannot request help, sorry." );
return false;
}
return true;
}
public static string GetPageTypeName( PageType type )
{
if ( type == PageType.VerbalHarassment )
return "Verbal Harassment";
else if ( type == PageType.PhysicalHarassment )
return "Physical Harassment";
else
return type.ToString();
}
public static void OnHandlerChanged( Mobile old, Mobile value, PageEntry entry )
{
if ( old != null )
m_KeyedByHandler.Remove( old );
if ( value != null )
m_KeyedByHandler[value] = entry;
}
[Usage( "Pages" )]
[Description( "Opens the page queue menu." )]
private static void Pages_OnCommand( CommandEventArgs e )
{
PageEntry entry = (PageEntry)m_KeyedByHandler[e.Mobile];
if ( entry != null )
{
e.Mobile.SendGump( new PageEntryGump( e.Mobile, entry ) );
}
else if ( m_List.Count > 0 )
{
e.Mobile.SendGump( new PageQueueGump() );
}
else
{
e.Mobile.SendMessage( "The page queue is empty." );
}
}
public static bool IsHandling( Mobile check )
{
return m_KeyedByHandler.ContainsKey( check );
}
public static bool Contains( Mobile sender )
{
return m_KeyedBySender.ContainsKey( sender );
}
public static int IndexOf( PageEntry e )
{
return m_List.IndexOf( e );
}
public static void Cancel( Mobile sender )
{
Remove( (PageEntry) m_KeyedBySender[sender] );
}
public static void Remove( PageEntry e )
{
if ( e == null )
return;
e.Stop();
m_List.Remove( e );
m_KeyedBySender.Remove( e.Sender );
if ( e.Handler != null )
m_KeyedByHandler.Remove( e.Handler );
}
public static PageEntry GetEntry( Mobile sender )
{
return (PageEntry)m_KeyedBySender[sender];
}
public static void Remove( Mobile sender )
{
Remove( GetEntry( sender ) );
}
public static ArrayList List
{
get
{
return m_List;
}
}
public static void Enqueue( PageEntry entry )
{
m_List.Add( entry );
m_KeyedBySender[entry.Sender] = entry;
bool isStaffOnline = false;
foreach ( NetState ns in NetState.Instances )
{
Mobile m = ns.Mobile;
if ( m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling( m ) )
m.SendMessage( "A new page has been placed in the queue." );
if ( m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && m.LastMoveTime >= (DateTime.Now - TimeSpan.FromMinutes( 10.0 )) )
isStaffOnline = true;
}
if ( !isStaffOnline )
entry.Sender.SendMessage( "We are sorry, but no staff members are currently available to assist you. Your page will remain in the queue until one becomes available, or until you cancel it manually." );
if ( Email.SpeechLogPageAddresses != null && entry.SpeechLog != null )
SendEmail( entry );
}
private static void SendEmail( PageEntry entry )
{
Mobile sender = entry.Sender;
DateTime time = DateTime.Now;
MailMessage mail = new MailMessage( "RunUO", Email.SpeechLogPageAddresses );
mail.Subject = "RunUO Speech Log Page Forwarding";
using ( StringWriter writer = new StringWriter() )
{
writer.WriteLine( "RunUO Speech Log Page - {0}", PageQueue.GetPageTypeName( entry.Type ) );
writer.WriteLine();
writer.WriteLine( "From: '{0}', Account: '{1}'", sender.RawName, sender.Account is Account ? sender.Account.Username : "???" );
writer.WriteLine( "Location: {0} [{1}]", sender.Location, sender.Map );
writer.WriteLine( "Sent on: {0}/{1:00}/{2:00} {3}:{4:00}:{5:00}", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second );
writer.WriteLine();
writer.WriteLine( "Message:" );
writer.WriteLine( "'{0}'", entry.Message );
writer.WriteLine();
writer.WriteLine( "Speech Log" );
writer.WriteLine( "==========" );
foreach ( SpeechLogEntry logEntry in entry.SpeechLog )
{
Mobile from = logEntry.From;
string fromName = from.RawName;
string fromAccount = from.Account is Account ? from.Account.Username : "???";
DateTime created = logEntry.Created;
string speech = logEntry.Speech;
writer.WriteLine( "{0}:{1:00}:{2:00} - {3} ({4}): '{5}'", created.Hour, created.Minute, created.Second, fromName, fromAccount, speech );
}
mail.Body = writer.ToString();
}
Email.AsyncSend( mail );
}
}
}

View file

@ -0,0 +1,834 @@
using System;
using System.IO;
using System.Collections;
using Server;
using Server.Network;
using Server.Gumps;
namespace Server.Engines.Help
{
public class MessageSentGump : Gump
{
private string m_Name, m_Text;
private Mobile m_Mobile;
public MessageSentGump( Mobile mobile, string name, string text ) : base( 30, 30 )
{
m_Name = name;
m_Text = text;
m_Mobile = mobile;
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, 92, 75, 0xA3C );
AddImageTiled( 5, 7, 82, 61, 0xA40 );
AddAlphaRegion( 5, 7, 82, 61 );
AddImageTiled( 9, 11, 21, 53, 0xBBC );
AddButton( 10, 12, 0x7D2, 0x7D2, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 34, 28, 65, 24, 3001002, 0xFFFFFF, false, false ); // Message
}
public override void OnResponse( NetState state, RelayInfo info )
{
m_Mobile.SendGump( new PageResponseGump( m_Mobile, m_Name, m_Text ) );
//m_Mobile.SendMessage( 0x482, "{0} tells you:", m_Name );
//m_Mobile.SendMessage( 0x482, m_Text );
}
}
public class PageQueueGump : Gump
{
private PageEntry[] m_List;
public PageQueueGump() : base( 30, 30 )
{
Add( new GumpPage( 0 ) );
//Add( new GumpBackground( 0, 0, 410, 448, 9200 ) );
Add( new GumpImageTiled( 0, 0, 410, 448, 0xA40 ) );
Add( new GumpAlphaRegion( 1, 1, 408, 446 ) );
Add( new GumpLabel( 180, 12, 2100, "Page Queue" ) );
ArrayList list = PageQueue.List;
for ( int i = 0; i < list.Count; )
{
PageEntry e = (PageEntry)list[i];
if ( e.Sender.Deleted || e.Sender.NetState == null )
{
e.AddResponse( e.Sender, "[Logout]" );
PageQueue.Remove( e );
}
else
{
++i;
}
}
m_List = (PageEntry[])list.ToArray( typeof( PageEntry ) );
if ( m_List.Length > 0 )
{
Add( new GumpPage( 1 ) );
for ( int i = 0; i < m_List.Length; ++i )
{
PageEntry e = m_List[i];
if ( i >= 5 && (i % 5) == 0 )
{
Add( new GumpButton( 368, 12, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1 ) );
Add( new GumpLabel( 298, 12, 2100, "Next Page" ) );
Add( new GumpPage( (i / 5) + 1 ) );
Add( new GumpButton( 12, 12, 0xFAE, 0xFB0, 0, GumpButtonType.Page, (i / 5) ) );
Add( new GumpLabel( 48, 12, 2100, "Previous Page" ) );
}
string typeString = PageQueue.GetPageTypeName( e.Type );
string html = String.Format( "[{0}] {1} <basefont color=#{2:X6}>[<u>{3}</u>]</basefont>", typeString, e.Message, e.Handler == null ? 0xFF0000 : 0xFF, e.Handler == null ? "Unhandled" : "Handling" );
Add( new GumpHtml( 12, 44 + ((i % 5) * 80), 350, 70, html, true, true ) );
Add( new GumpButton( 370, 44 + ((i % 5) * 80) + 24, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0 ) );
}
}
else
{
Add( new GumpLabel( 12, 44, 2100, "The page queue is empty." ) );
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID >= 1 && info.ButtonID <= m_List.Length )
{
if ( PageQueue.List.IndexOf( m_List[info.ButtonID - 1] ) >= 0 )
{
PageEntryGump g = new PageEntryGump( state.Mobile, m_List[info.ButtonID - 1] );
g.SendTo( state );
}
else
{
state.Mobile.SendGump( new PageQueueGump() );
state.Mobile.SendMessage( "That page has been removed." );
}
}
}
}
public class PredefinedResponse
{
private string m_Title;
private string m_Message;
public string Title{ get{ return m_Title; } set{ m_Title = value; } }
public string Message{ get{ return m_Message; } set{ m_Message = value; } }
public PredefinedResponse( string title, string message )
{
m_Title = title;
m_Message = message;
}
private static ArrayList m_List;
public static ArrayList List
{
get
{
if ( m_List == null )
m_List = Load();
return m_List;
}
}
public static PredefinedResponse Add( string title, string message )
{
if ( m_List == null )
m_List = Load();
PredefinedResponse resp = new PredefinedResponse( title, message );
m_List.Add( resp );
Save();
return resp;
}
public static void Save()
{
if ( m_List == null )
m_List = Load();
try
{
string path = Path.Combine( Core.BaseDirectory, "Data/Config/pageresponse.cfg" );
using ( StreamWriter op = new StreamWriter( path ) )
{
for ( int i = 0; i < m_List.Count; ++i )
{
PredefinedResponse resp = (PredefinedResponse)m_List[i];
op.WriteLine( "{0}\t{1}", resp.Title, resp.Message );
}
}
}
catch ( Exception e )
{
Console.WriteLine( e );
}
}
public static ArrayList Load()
{
ArrayList list = new ArrayList();
string path = Path.Combine( Core.BaseDirectory, "Data/Config/pageresponse.cfg" );
if ( File.Exists( path ) )
{
try
{
using ( StreamReader ip = new StreamReader( path ) )
{
string line;
while ( (line = ip.ReadLine()) != null )
{
try
{
line = line.Trim();
if ( line.Length == 0 || line.StartsWith( "#" ) )
continue;
string[] split = line.Split( '\t' );
if ( split.Length == 2 )
list.Add( new PredefinedResponse( split[0], split[1] ) );
}
catch
{
}
}
}
}
catch ( Exception e )
{
Console.WriteLine( e );
}
}
return list;
}
}
public class PredefGump : Gump
{
private const int LabelColor32 = 0xFFFFFF;
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public void AddTextInput( int x, int y, int w, int h, int id, string def )
{
AddImageTiled( x, y, w, h, 0xA40 );
AddImageTiled( x + 1, y + 1, w - 2, h - 2, 0xBBC );
AddTextEntry( x + 3, y + 1, w - 4, h - 2, 0x480, id, def );
}
private Mobile m_From;
private PredefinedResponse m_Response;
public PredefGump( Mobile from, PredefinedResponse response ) : base( 30, 30 )
{
m_From = from;
m_Response = response;
from.CloseGump( typeof( PredefGump ) );
bool canEdit = ( from.AccessLevel >= AccessLevel.GameMaster );
AddPage( 0 );
if ( response == null )
{
AddImageTiled( 0, 0, 410, 448, 0xA40 );
AddAlphaRegion( 1, 1, 408, 446 );
AddHtml( 10, 10, 390, 20, Color( Center( "Predefined Responses" ), LabelColor32 ), false, false );
ArrayList list = PredefinedResponse.List;
AddPage( 1 );
int i;
for ( i = 0; i < list.Count; ++i )
{
if ( i >= 5 && (i % 5) == 0 )
{
AddButton( 368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1 );
AddLabel( 298, 10, 2100, "Next Page" );
AddPage( (i / 5) + 1 );
AddButton( 12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5 );
AddLabel( 48, 10, 2100, "Previous Page" );
}
PredefinedResponse resp = (PredefinedResponse)list[i];
string html = String.Format( "<u>{0}</u><br>{1}", resp.Title, resp.Message );
AddHtml( 12, 44 + ((i % 5) * 80), 350, 70, html, true, true );
if ( canEdit )
{
AddButton( 370, 44 + ((i % 5) * 80) + 24, 0xFA5, 0xFA7, 2 + (i * 3), GumpButtonType.Reply, 0 );
if ( i > 0 )
AddButton( 377, 44 + ((i % 5) * 80) + 2, 0x15E0, 0x15E4, 3 + (i * 3), GumpButtonType.Reply, 0 );
else
AddImage( 377, 44 + ((i % 5) * 80) + 2, 0x25E4 );
if ( i < (list.Count - 1) )
AddButton( 377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + (i * 3), GumpButtonType.Reply, 0 );
else
AddImage( 377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x25E8 );
}
}
if ( canEdit )
{
if ( i >= 5 && (i % 5) == 0 )
{
AddButton( 368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1 );
AddLabel( 298, 10, 2100, "Next Page" );
AddPage( (i / 5) + 1 );
AddButton( 12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5 );
AddLabel( 48, 10, 2100, "Previous Page" );
}
AddButton( 12, 44 + ((i % 5) * 80), 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0 );
AddHtml( 45, 44 + ((i % 5) * 80), 200, 20, Color( "New Response", LabelColor32 ), false, false );
}
}
else if ( canEdit )
{
AddImageTiled( 0, 0, 410, 250, 0xA40 );
AddAlphaRegion( 1, 1, 408, 248 );
AddHtml( 10, 10, 390, 20, Color( Center( "Predefined Response Editor" ), LabelColor32 ), false, false );
AddButton( 10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0 );
AddHtml( 45, 40, 200, 20, Color( "Remove", LabelColor32 ), false, false );
AddButton( 10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddHtml( 45, 70, 200, 20, Color( "Title:", LabelColor32 ), false, false );
AddTextInput( 10, 90, 300, 20, 0, response.Title );
AddButton( 10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddHtml( 45, 120, 200, 20, Color( "Message:", LabelColor32 ), false, false );
AddTextInput( 10, 140, 390, 100, 1, response.Message );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_From.AccessLevel < AccessLevel.Administrator )
return;
if ( m_Response == null )
{
int index = info.ButtonID - 1;
if ( index == 0 )
{
PredefinedResponse resp = new PredefinedResponse( "", "" );
ArrayList list = PredefinedResponse.List;
list.Add( resp );
m_From.SendGump( new PredefGump( m_From, resp ) );
}
else
{
--index;
int type = index % 3;
index /= 3;
ArrayList list = PredefinedResponse.List;
if ( index >= 0 && index < list.Count )
{
PredefinedResponse resp = (PredefinedResponse)list[index];
switch ( type )
{
case 0: // edit
{
m_From.SendGump( new PredefGump( m_From, resp ) );
break;
}
case 1: // move up
{
if ( index > 0 )
{
list.RemoveAt( index );
list.Insert( index - 1, resp );
PredefinedResponse.Save();
m_From.SendGump( new PredefGump( m_From, null ) );
}
break;
}
case 2: // move down
{
if ( index < (list.Count - 1) )
{
list.RemoveAt( index );
list.Insert( index + 1, resp );
PredefinedResponse.Save();
m_From.SendGump( new PredefGump( m_From, null ) );
}
break;
}
}
}
}
}
else
{
ArrayList list = PredefinedResponse.List;
switch ( info.ButtonID )
{
case 1:
{
list.Remove( m_Response );
PredefinedResponse.Save();
m_From.SendGump( new PredefGump( m_From, null ) );
break;
}
case 2:
{
TextRelay te = info.GetTextEntry( 0 );
if ( te != null )
m_Response.Title = te.Text;
PredefinedResponse.Save();
m_From.SendGump( new PredefGump( m_From, m_Response ) );
break;
}
case 3:
{
TextRelay te = info.GetTextEntry( 1 );
if ( te != null )
m_Response.Message = te.Text;
PredefinedResponse.Save();
m_From.SendGump( new PredefGump( m_From, m_Response ) );
break;
}
}
}
}
}
public class PageEntryGump : Gump
{
private PageEntry m_Entry;
private Mobile m_Mobile;
private static int[] m_AccessLevelHues = new int[]
{
2100,
2122,
2117,
2129,
2415,
2415,
2415
};
public PageEntryGump( Mobile m, PageEntry entry ) : base( 30, 30 )
{
try
{
m_Mobile = m;
m_Entry = entry;
int buttons = 0;
int bottom = 356;
AddPage( 0 );
AddImageTiled( 0, 0, 410, 456, 0xA40 );
AddAlphaRegion( 1, 1, 408, 454 );
AddPage( 1 );
AddLabel( 18, 18, 2100, "Sent:" );
AddLabelCropped( 128, 18, 264, 20, 2100, entry.Sent.ToString() );
AddLabel( 18, 38, 2100, "Sender:" );
AddLabelCropped( 128, 38, 264, 20, 2100, String.Format( "{0} {1} [{2}]", entry.Sender.RawName, entry.Sender.Location, entry.Sender.Map ) );
AddButton( 18, bottom - (buttons * 22), 0xFAB, 0xFAD, 8, GumpButtonType.Reply, 0 );
AddImageTiled( 52, bottom - (buttons * 22) + 1, 340, 80, 0xA40/*0xBBC*//*0x2458*/ );
AddImageTiled( 53, bottom - (buttons * 22) + 2, 338, 78, 0xBBC/*0x2426*/ );
AddTextEntry( 55, bottom - (buttons++ * 22) + 2, 336, 78, 0x480, 0, "" );
AddButton( 18, bottom - (buttons * 22), 0xFA5, 0xFA7, 0, GumpButtonType.Page, 2 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Predefined Response" );
if ( entry.Sender != m )
{
AddButton( 18, bottom - (buttons * 22), 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Go to Sender" );
}
AddLabel( 18, 58, 2100, "Handler:" );
if ( entry.Handler == null )
{
AddLabelCropped( 128, 58, 264, 20, 2100, "Unhandled" );
AddButton( 18, bottom - (buttons * 22), 0xFB1, 0xFB3, 5, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Delete Page" );
AddButton( 18, bottom - (buttons * 22), 0xFB7, 0xFB9, 4, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Handle Page" );
}
else
{
AddLabelCropped( 128, 58, 264, 20, m_AccessLevelHues[(int)entry.Handler.AccessLevel], entry.Handler.Name );
if ( entry.Handler != m )
{
AddButton( 18, bottom - (buttons * 22), 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Go to Handler" );
}
else
{
AddButton( 18, bottom - (buttons * 22), 0xFA2, 0xFA4, 6, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Abandon Page" );
AddButton( 18, bottom - (buttons * 22), 0xFB7, 0xFB9, 7, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Page Handled" );
}
}
AddLabel( 18, 78, 2100, "Page Location:" );
AddLabelCropped( 128, 78, 264, 20, 2100, String.Format( "{0} [{1}]", entry.PageLocation, entry.PageMap ) );
AddButton( 18, bottom - (buttons * 22), 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "Go to Page Location" );
if ( entry.SpeechLog != null )
{
AddButton( 18, bottom - (buttons * 22), 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0 );
AddLabel( 52, bottom - (buttons++ * 22), 2100, "View Speech Log" );
}
AddLabel( 18, 98, 2100, "Page Type:" );
AddLabelCropped( 128, 98, 264, 20, 2100, PageQueue.GetPageTypeName( entry.Type ) );
AddLabel( 18, 118, 2100, "Message:" );
AddHtml( 128, 118, 250, 100, entry.Message, true, true );
AddPage( 2 );
ArrayList preresp = PredefinedResponse.List;
AddButton( 18, 18, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1 );
AddButton( 410 - 18 - 32, 18, 0xFAB, 0xFAC, 9, GumpButtonType.Reply, 0 );
if ( preresp.Count == 0 )
{
AddLabel( 52, 18, 2100, "There are no predefined responses." );
}
else
{
AddLabel( 52, 18, 2100, "Back" );
for ( int i = 0; i < preresp.Count; ++i )
{
AddButton( 18, 40 + (i * 22), 0xFA5, 0xFA7, 100 + i, GumpButtonType.Reply, 0 );
AddLabel( 52, 40 + (i * 22), 2100, ((PredefinedResponse)preresp[i]).Title );
}
}
}
catch ( Exception e )
{
Console.WriteLine(e);
}
}
public void Resend( NetState state )
{
PageEntryGump g = new PageEntryGump( m_Mobile, m_Entry );
g.SendTo( state );
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID != 0 && PageQueue.List.IndexOf( m_Entry ) < 0 )
{
state.Mobile.SendGump( new PageQueueGump() );
state.Mobile.SendMessage( "That page has been removed." );
return;
}
switch ( info.ButtonID )
{
case 0: // close
{
if ( m_Entry.Handler != state.Mobile )
{
PageQueueGump g = new PageQueueGump();
g.SendTo( state );
}
break;
}
case 1: // go to sender
{
Mobile m = state.Mobile;
if ( m_Entry.Sender.Deleted )
{
m.SendMessage( "That character no longer exists." );
}
else if ( m_Entry.Sender.Map == null || m_Entry.Sender.Map == Map.Internal )
{
m.SendMessage( "That character is not in the world." );
}
else
{
m_Entry.AddResponse( state.Mobile, "[Go Sender]" );
m.MoveToWorld( m_Entry.Sender.Location, m_Entry.Sender.Map );
m.SendMessage( "You have been teleported to that pages sender." );
Resend( state );
}
break;
}
case 2: // go to handler
{
Mobile m = state.Mobile;
Mobile h = m_Entry.Handler;
if ( h != null )
{
if ( h.Deleted )
{
m.SendMessage( "That character no longer exists." );
}
else if ( h.Map == null || h.Map == Map.Internal )
{
m.SendMessage( "That character is not in the world." );
}
else
{
m_Entry.AddResponse( state.Mobile, "[Go Handler]" );
m.MoveToWorld( h.Location, h.Map );
m.SendMessage( "You have been teleported to that pages handler." );
Resend( state );
}
}
else
{
m.SendMessage( "Nobody is handling that page." );
Resend( state );
}
break;
}
case 3: // go to page location
{
Mobile m = state.Mobile;
if ( m_Entry.PageMap == null || m_Entry.PageMap == Map.Internal )
{
m.SendMessage( "That location is not in the world." );
}
else
{
m_Entry.AddResponse( state.Mobile, "[Go PageLoc]" );
m.MoveToWorld( m_Entry.PageLocation, m_Entry.PageMap );
state.Mobile.SendMessage( "You have been teleported to the original page location." );
Resend( state );
}
break;
}
case 4: // handle page
{
if ( m_Entry.Handler == null )
{
m_Entry.AddResponse( state.Mobile, "[Handling]" );
m_Entry.Handler = state.Mobile;
state.Mobile.SendMessage( "You are now handling the page." );
}
else
{
state.Mobile.SendMessage( "Someone is already handling that page." );
}
Resend( state );
break;
}
case 5: // delete page
{
if ( m_Entry.Handler == null )
{
m_Entry.AddResponse( state.Mobile, "[Deleting]" );
PageQueue.Remove( m_Entry );
state.Mobile.SendMessage( "You delete the page." );
PageQueueGump g = new PageQueueGump();
g.SendTo( state );
}
else
{
state.Mobile.SendMessage( "Someone is handling that page, it can not be deleted." );
Resend( state );
}
break;
}
case 6: // abandon page
{
if ( m_Entry.Handler == state.Mobile )
{
m_Entry.AddResponse( state.Mobile, "[Abandoning]" );
state.Mobile.SendMessage( "You abandon the page." );
m_Entry.Handler = null;
}
else
{
state.Mobile.SendMessage( "You are not handling that page." );
}
Resend( state );
break;
}
case 7: // page handled
{
if ( m_Entry.Handler == state.Mobile )
{
m_Entry.AddResponse( state.Mobile, "[Handled]" );
PageQueue.Remove( m_Entry );
m_Entry.Handler = null;
state.Mobile.SendMessage( "You mark the page as handled, and remove it from the queue." );
PageQueueGump g = new PageQueueGump();
g.SendTo( state );
}
else
{
state.Mobile.SendMessage( "You are not handling that page." );
Resend( state );
}
break;
}
case 8: // Send message
{
TextRelay text = info.GetTextEntry( 0 );
if ( text != null )
{
m_Entry.AddResponse( state.Mobile, "[Response] " + text.Text );
m_Entry.Sender.SendGump( new MessageSentGump( m_Entry.Sender, state.Mobile.Name, text.Text ) );
//m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
//m_Entry.Sender.SendMessage( 0x482, text.Text );
}
Resend( state );
break;
}
case 9: // predef overview
{
Resend( state );
state.Mobile.SendGump( new PredefGump( state.Mobile, null ) );
break;
}
case 10: // View Speech Log
{
Resend( state );
if ( m_Entry.SpeechLog != null )
{
Gump gump = new SpeechLogGump( m_Entry.Sender, m_Entry.SpeechLog );
state.Mobile.SendGump( gump );
}
break;
}
default:
{
int index = info.ButtonID - 100;
ArrayList preresp = PredefinedResponse.List;
if ( index >= 0 && index < preresp.Count )
{
m_Entry.AddResponse( state.Mobile, "[PreDef] " + ((PredefinedResponse)preresp[index]).Title );
m_Entry.Sender.SendGump( new MessageSentGump( m_Entry.Sender, state.Mobile.Name, ((PredefinedResponse)preresp[index]).Message ) );
}
Resend( state );
break;
}
}
}
}
}

View file

@ -0,0 +1,39 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Engines.Help
{
public class PageResponseGump : Gump
{
private Mobile m_From;
private string m_Name, m_Text;
public PageResponseGump( Mobile from, string name, string text ) : base( 0, 0 )
{
m_From = from;
m_Name = name;
m_Text = text;
AddBackground( 50, 25, 540, 430, 2600 );
AddPage( 0 );
AddHtmlLocalized( 150, 40, 360, 40, 1062610, false, false ); // <CENTER><U>Ultima Online Help Response</U></CENTER>
AddHtml( 80, 90, 480, 290, String.Format( "{0} tells {1}: {2}", name, from.Name, text ), true, true );
AddHtmlLocalized( 80, 390, 480, 40, 1062611, false, false ); // Clicking the OKAY button will remove the reponse you have received.
AddButton( 400, 417, 2074, 2075, 1, GumpButtonType.Reply, 0 ); // OKAY
AddButton( 475, 417, 2073, 2072, 0, GumpButtonType.Reply, 0 ); // CANCEL
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID != 1 )
m_From.SendGump( new MessageSentGump( m_From, m_Name, m_Text ) );
}
}
}

Some files were not shown because too many files have changed in this diff Show more