From cab25a9b8fba21bdd6f77f6c8c956d99752fd343 Mon Sep 17 00:00:00 2001 From: "eos@runuo.com" Date: Fri, 7 Jun 2013 01:07:07 +0000 Subject: [PATCH] Decoupled the Order/Chaos system from the NewGuildSystem setting. --- Scripts/Engines/Factions/Core/Faction.cs | 2 +- Scripts/Gumps/Guilds/GuildChangeTypeGump.cs | 50 +++++++++++-------- Scripts/Gumps/Guilds/GuildmasterGump.cs | 29 +++++++---- .../Guilds/New Guild System/GuildInfoGump.cs | 23 +++++++-- Scripts/Misc/Guild.cs | 13 ++--- 5 files changed, 74 insertions(+), 43 deletions(-) diff --git a/Scripts/Engines/Factions/Core/Faction.cs b/Scripts/Engines/Factions/Core/Faction.cs index c4d01cbdf..02dabc076 100644 --- a/Scripts/Engines/Factions/Core/Faction.cs +++ b/Scripts/Engines/Factions/Core/Faction.cs @@ -489,7 +489,7 @@ namespace Server.Factions if ( guild.Leader != pm ) pm.SendLocalizedMessage( 1005057 ); // You cannot join a faction because you are in a guild and not the guildmaster - else if ( !Guild.NewGuildSystem && guild.Type != GuildType.Regular ) + else if ( guild.Type != GuildType.Regular ) pm.SendLocalizedMessage( 1042161 ); // You cannot join a faction because your guild is an Order or Chaos type. else if ( !Guild.NewGuildSystem && guild.Enemies != null && guild.Enemies.Count > 0 ) //CAN join w/wars in new system pm.SendLocalizedMessage( 1005056 ); // You cannot join a faction with active Wars diff --git a/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs b/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs index f6f619139..50acc580d 100644 --- a/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using Server; using Server.Guilds; +using Server.Mobiles; using Server.Network; using Server.Factions; @@ -44,36 +45,45 @@ namespace Server.Gumps public override void OnResponse( NetState state, RelayInfo info ) { - if ( GuildGump.BadLeader( m_Mobile, m_Guild ) ) + if ( ( Guild.NewGuildSystem && !BaseGuildGump.IsLeader( m_Mobile, m_Guild ) ) || ( !Guild.NewGuildSystem && GuildGump.BadLeader( m_Mobile, m_Guild ) ) ) return; - PlayerState pl = PlayerState.Find( m_Mobile ); + GuildType newType; - if ( pl != null ) + switch ( info.ButtonID ) { - m_Mobile.SendLocalizedMessage( 1010405 ); // You cannot change guild types while in a Faction! + default: newType = m_Guild.Type; break; + case 1: newType = GuildType.Regular; break; + case 2: newType = GuildType.Order; break; + case 3: newType = GuildType.Chaos; break; } - else 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 ) + if ( m_Guild.Type != newType ) + { + PlayerState pl = PlayerState.Find( m_Mobile ); + + if ( pl != null ) { - default: return; // Close - case 1: newType = GuildType.Regular; break; - case 2: newType = GuildType.Order; break; - case 3: newType = GuildType.Chaos; break; + m_Mobile.SendLocalizedMessage( 1010405 ); // You cannot change guild types while in a Faction! } + else if ( m_Guild.TypeLastChange.AddDays( 7 ) > DateTime.Now ) + { + m_Mobile.SendLocalizedMessage( 1011142 ); // You have already changed your guild type recently. + // TODO: Clilocs 1011142-1011145 suggest a timer for pending changes + } + else + { + m_Guild.Type = newType; + m_Guild.GuildMessage( 1018022, true, newType.ToString() ); // Guild Message: Your guild type has changed: + } + } - if ( m_Guild.Type == newType ) - return; + if ( Guild.NewGuildSystem ) + { + if ( m_Mobile is PlayerMobile ) + m_Mobile.SendGump( new GuildInfoGump( (PlayerMobile)m_Mobile, m_Guild ) ); - m_Guild.Type = newType; - m_Guild.GuildMessage( 1018022, true, newType.ToString() ); // Guild Message: Your guild type has changed: + return; } GuildGump.EnsureClosed( m_Mobile ); diff --git a/Scripts/Gumps/Guilds/GuildmasterGump.cs b/Scripts/Gumps/Guilds/GuildmasterGump.cs index 3616c60b0..177a56fa8 100644 --- a/Scripts/Gumps/Guilds/GuildmasterGump.cs +++ b/Scripts/Gumps/Guilds/GuildmasterGump.cs @@ -31,18 +31,22 @@ namespace Server.Gumps 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 ) + if ( Guild.OrderChaos ) { - 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, 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 ); @@ -111,6 +115,9 @@ namespace Server.Gumps } case 4: // Change guild type { + if ( !Guild.OrderChaos ) + return; + GuildGump.EnsureClosed( m_Mobile ); m_Mobile.SendGump( new GuildChangeTypeGump( m_Mobile, m_Guild ) ); diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs index c439fa568..f3f4af0b6 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -43,12 +43,19 @@ namespace Server.Guilds AddButton( 40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0 ); //Alliance Roster } + if( Guild.OrderChaos && isLeader ) + AddButton( 40, 154, 0x4B9, 0x4BA, 100, GumpButtonType.Reply, 0 ); // Guild Faction + AddImageTiled( 65, 148, 160, 26, 0xA40 ); AddImageTiled( 67, 150, 156, 22, 0xBBC ); AddHtmlLocalized( 70, 151, 150, 20, 1063084, 0x0, false, false ); // Guild Faction - - Faction f = Faction.Find( guild.Leader ); - if( f != null ) + + GuildType gt; + Faction f; + + if( ( gt = guild.Type ) != GuildType.Regular ) + AddHtml( 233, 152, 320, 26, gt.ToString(), false, false ); + else if( ( f = Faction.Find( guild.Leader ) ) != null ) AddHtml( 233, 152, 320, 26, f.ToString(), false, false ); AddImageTiled( 65, 196, 480, 4, 0x238D ); @@ -133,6 +140,16 @@ namespace Server.Guilds } break; } + case 100: // Custom code to support Order/Chaos in the new guild system + { + // Guild Faction + if( Guild.OrderChaos && IsLeader( pm, guild ) ) + { + pm.CloseGump( typeof( GuildChangeTypeGump ) ); + pm.SendGump( new GuildChangeTypeGump( pm, guild ) ); + } + break; + } } } diff --git a/Scripts/Misc/Guild.cs b/Scripts/Misc/Guild.cs index 8595dd3aa..cba1a6e5b 100644 --- a/Scripts/Misc/Guild.cs +++ b/Scripts/Misc/Guild.cs @@ -694,6 +694,7 @@ namespace Server.Guilds #endregion public static bool NewGuildSystem{ get{ return Core.SE; } } + public static bool OrderChaos{ get{ return !Core.SE; } } public static readonly int RegistrationFee = 25000; public static readonly int AbbrevLimit = 4; @@ -1166,13 +1167,10 @@ namespace Server.Guilds public bool IsEnemy( Guild g ) { - if( NewGuildSystem ) - return IsWar( g ); - - if( m_Type != GuildType.Regular && g.m_Type != GuildType.Regular && m_Type != g.m_Type ) + if( Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type ) return true; - return m_Enemies.Contains( g ); + return IsWar( g ); } public bool IsWar( Guild g ) @@ -1184,14 +1182,13 @@ namespace Server.Guilds { Guild guild = GetAllianceLeader( this ); Guild otherGuild = GetAllianceLeader( g ); - + if ( guild.FindActiveWar( otherGuild ) != null ) return true; return false; } - return m_Enemies.Contains( g ); } #endregion @@ -1765,7 +1762,7 @@ namespace Server.Guilds { get { - return m_Type; + return OrderChaos ? m_Type : GuildType.Regular; } set {