Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
73
Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs
Normal file
73
Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public delegate void SearchSelectionCallback(GuildDisplayType display);
|
||||
|
||||
public class GuildAdvancedSearchGump : BaseGuildGump
|
||||
{
|
||||
private readonly GuildDisplayType m_Display;
|
||||
private readonly SearchSelectionCallback m_Callback;
|
||||
public GuildAdvancedSearchGump(PlayerMobile pm, Guild g, GuildDisplayType display, SearchSelectionCallback callback)
|
||||
: base(pm, g)
|
||||
{
|
||||
this.m_Callback = callback;
|
||||
this.m_Display = display;
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
base.PopulateGump();
|
||||
|
||||
this.AddHtmlLocalized(431, 43, 110, 26, 1062978, 0xF, false, false); // Diplomacy
|
||||
|
||||
this.AddHtmlLocalized(65, 80, 480, 26, 1063124, 0xF, true, false); // <i>Advanced Search Options</i>
|
||||
|
||||
this.AddHtmlLocalized(65, 110, 480, 26, 1063136 + (int)this.m_Display, 0xF, false, false); // Showing All Guilds/w/Relation/Waiting Relation
|
||||
|
||||
this.AddGroup(1);
|
||||
this.AddRadio(75, 140, 0xD2, 0xD3, false, 2);
|
||||
this.AddHtmlLocalized(105, 140, 200, 26, 1063006, 0x0, false, false); // Show Guilds with Relationship
|
||||
this.AddRadio(75, 170, 0xD2, 0xD3, false, 1);
|
||||
this.AddHtmlLocalized(105, 170, 200, 26, 1063005, 0x0, false, false); // Show Guilds Awaiting Action
|
||||
this.AddRadio(75, 200, 0xD2, 0xD3, false, 0);
|
||||
this.AddHtmlLocalized(105, 200, 200, 26, 1063007, 0x0, false, false); // Show All Guilds
|
||||
|
||||
this.AddBackground(450, 370, 100, 26, 0x2486);
|
||||
this.AddButton(455, 375, 0x845, 0x846, 5, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(480, 373, 60, 26, 1006044, 0x0, false, false); // OK
|
||||
this.AddBackground(340, 370, 100, 26, 0x2486);
|
||||
this.AddButton(345, 375, 0x845, 0x846, 0, GumpButtonType.Reply, 0);
|
||||
this.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, this.guild))
|
||||
return;
|
||||
|
||||
GuildDisplayType display = this.m_Display;
|
||||
|
||||
if (info.ButtonID == 5)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (info.IsSwitched(i))
|
||||
{
|
||||
display = (GuildDisplayType)i;
|
||||
this.m_Callback(display);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
153
Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs
Normal file
153
Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public abstract class BaseGuildGump : Gump
|
||||
{
|
||||
private readonly Guild m_Guild;
|
||||
private readonly PlayerMobile 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)
|
||||
{
|
||||
this.m_Guild = g;
|
||||
this.m_Player = pm;
|
||||
|
||||
pm.CloseGump(typeof(BaseGuildGump));
|
||||
}
|
||||
|
||||
protected Guild guild
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Guild;
|
||||
}
|
||||
}
|
||||
protected PlayerMobile player
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Player;
|
||||
}
|
||||
}
|
||||
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 static string Color(string text, int color)
|
||||
{
|
||||
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text);
|
||||
}
|
||||
|
||||
//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()
|
||||
{
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 600, 440, 0x24AE);
|
||||
this.AddBackground(66, 40, 150, 26, 0x2486);
|
||||
this.AddButton(71, 45, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(96, 43, 110, 26, 1063014, 0x0, false, false); // My Guild
|
||||
this.AddBackground(236, 40, 150, 26, 0x2486);
|
||||
this.AddButton(241, 45, 0x845, 0x846, 2, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(266, 43, 110, 26, 1062974, 0x0, false, false); // Guild Roster
|
||||
this.AddBackground(401, 40, 150, 26, 0x2486);
|
||||
this.AddButton(406, 45, 0x845, 0x846, 3, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(431, 43, 110, 26, 1062978, 0x0, false, false); // Diplomacy
|
||||
this.AddPage(1);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
PlayerMobile pm = sender.Mobile as PlayerMobile;
|
||||
|
||||
if (!IsMember(pm, this.guild))
|
||||
return;
|
||||
|
||||
switch( info.ButtonID )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
pm.SendGump(new GuildInfoGump(pm, this.guild));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
pm.SendGump(new GuildRosterGump(pm, this.guild));
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
pm.SendGump(new GuildDiplomacyGump(pm, this.guild));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)
|
||||
{
|
||||
if (text != null && text.Number > 0)
|
||||
this.AddHtmlLocalized(x, y, width, height, text.Number, back, scroll);
|
||||
else if (text != null && text.String != null)
|
||||
this.AddHtml(x, y, width, height, text.String, back, scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
226
Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs
Normal file
226
Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public struct InfoField<T>
|
||||
{
|
||||
private readonly TextDefinition m_Name;
|
||||
private readonly int m_Width;
|
||||
private readonly IComparer<T> m_Comparer;
|
||||
public InfoField(TextDefinition name, int width, IComparer<T> comparer)
|
||||
{
|
||||
this.m_Name = name;
|
||||
this.m_Width = width;
|
||||
this.m_Comparer = comparer;
|
||||
}
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Name;
|
||||
}
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Width;
|
||||
}
|
||||
}
|
||||
public IComparer<T> Comparer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Comparer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseGuildListGump<T> : BaseGuildGump
|
||||
{
|
||||
private const int itemsPerPage = 8;
|
||||
readonly IComparer<T> m_Comparer;
|
||||
readonly InfoField<T>[] m_Fields;
|
||||
readonly string m_Filter;
|
||||
List<T> m_List;
|
||||
bool m_Ascending;
|
||||
int m_StartNumber;
|
||||
public BaseGuildListGump(PlayerMobile pm, Guild g, List<T> list, IComparer<T> currentComparer, bool ascending, string filter, int startNumber, InfoField<T>[] fields)
|
||||
: base(pm, g)
|
||||
{
|
||||
this.m_Filter = filter.Trim();
|
||||
|
||||
this.m_Comparer = currentComparer;
|
||||
this.m_Fields = fields;
|
||||
this.m_Ascending = ascending;
|
||||
this.m_StartNumber = startNumber;
|
||||
this.m_List = list;
|
||||
}
|
||||
|
||||
public virtual bool WillFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_Filter.Length >= 0);
|
||||
}
|
||||
}
|
||||
public override void PopulateGump()
|
||||
{
|
||||
base.PopulateGump();
|
||||
|
||||
List<T> list = this.m_List;
|
||||
if (this.WillFilter)
|
||||
{
|
||||
this.m_List = new List<T>();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (!this.IsFiltered(list[i], this.m_Filter))
|
||||
this.m_List.Add(list[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_List = new List<T>(list);
|
||||
}
|
||||
|
||||
this.m_List.Sort(this.m_Comparer);
|
||||
this.m_StartNumber = Math.Max(Math.Min(this.m_StartNumber, this.m_List.Count - 1), 0);
|
||||
|
||||
this.AddBackground(130, 75, 385, 30, 0xBB8);
|
||||
this.AddTextEntry(135, 80, 375, 30, 0x481, 1, this.m_Filter);
|
||||
this.AddButton(520, 75, 0x867, 0x868, 5, GumpButtonType.Reply, 0); //Filter Button
|
||||
|
||||
int width = 0;
|
||||
for (int i = 0; i < this.m_Fields.Length; i++)
|
||||
{
|
||||
InfoField<T> f = this.m_Fields[i];
|
||||
|
||||
this.AddImageTiled(65 + width, 110, f.Width + 10, 26, 0xA40);
|
||||
this.AddImageTiled(67 + width, 112, f.Width + 6, 22, 0xBBC);
|
||||
this.AddHtmlText(70 + width, 113, f.Width, 20, f.Name, false, false);
|
||||
|
||||
bool isComparer = (this.m_Fields[i].Comparer.GetType() == this.m_Comparer.GetType());
|
||||
|
||||
int ButtonID = (isComparer) ? (this.m_Ascending ? 0x983 : 0x985) : 0x2716;
|
||||
|
||||
this.AddButton(59 + width + f.Width, 117, ButtonID, ButtonID + (isComparer ? 1 : 0), 100 + i, GumpButtonType.Reply, 0);
|
||||
|
||||
width += (f.Width + 12);
|
||||
}
|
||||
|
||||
if (this.m_StartNumber <= 0)
|
||||
this.AddButton(65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page, 0);
|
||||
else
|
||||
this.AddButton(65, 80, 0x15E3, 0x15E7, 6, GumpButtonType.Reply, 0); // Back
|
||||
|
||||
if (this.m_StartNumber + itemsPerPage > this.m_List.Count)
|
||||
this.AddButton(95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 0);
|
||||
else
|
||||
this.AddButton(95, 80, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0); // Forward
|
||||
|
||||
int itemNumber = 0;
|
||||
|
||||
if (this.m_Ascending)
|
||||
for (int i = this.m_StartNumber; i < this.m_StartNumber + itemsPerPage && i < this.m_List.Count; i++)
|
||||
this.DrawEntry(this.m_List[i], i, itemNumber++);
|
||||
else //descending, go from bottom of list to the top
|
||||
for (int i = this.m_List.Count - 1 - this.m_StartNumber; i >= 0 && i >= (this.m_List.Count - itemsPerPage - this.m_StartNumber); i--)
|
||||
this.DrawEntry(this.m_List[i], i, itemNumber++);
|
||||
|
||||
this.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 < this.m_Fields.Length; j++)
|
||||
{
|
||||
InfoField<T> f = this.m_Fields[j];
|
||||
|
||||
this.AddImageTiled(65 + width, 138 + itemNumber * 28, f.Width + 10, 26, 0xA40);
|
||||
this.AddImageTiled(67 + width, 140 + itemNumber * 28, f.Width + 6, 22, 0xBBC);
|
||||
this.AddHtmlText(70 + width, 141 + itemNumber * 28, f.Width, 20, this.GetValuesFor(o, this.m_Fields.Length)[j], false, false);
|
||||
|
||||
width += (f.Width + 12);
|
||||
}
|
||||
|
||||
if (this.HasRelationship(o))
|
||||
this.AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index, GumpButtonType.Reply, 0); //Info Button
|
||||
else
|
||||
this.AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index, GumpButtonType.Reply, 0); //Info Button
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
base.OnResponse(sender, info);
|
||||
|
||||
PlayerMobile pm = sender.Mobile as PlayerMobile;
|
||||
|
||||
if (pm == null || !IsMember(pm, this.guild))
|
||||
return;
|
||||
|
||||
int id = info.ButtonID;
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case 5: //Filter
|
||||
{
|
||||
TextRelay t = info.GetTextEntry(1);
|
||||
pm.SendGump(this.GetResentGump(this.player, this.guild, this.m_Comparer, this.m_Ascending, (t == null) ? "" : t.Text, 0));
|
||||
break;
|
||||
}
|
||||
case 6: //Back
|
||||
{
|
||||
pm.SendGump(this.GetResentGump(this.player, this.guild, this.m_Comparer, this.m_Ascending, this.m_Filter, this.m_StartNumber - itemsPerPage));
|
||||
break;
|
||||
}
|
||||
case 7: //Forward
|
||||
{
|
||||
pm.SendGump(this.GetResentGump(this.player, this.guild, this.m_Comparer, this.m_Ascending, this.m_Filter, this.m_StartNumber + itemsPerPage));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id >= 100 && id < (100 + this.m_Fields.Length))
|
||||
{
|
||||
IComparer<T> comparer = this.m_Fields[id - 100].Comparer;
|
||||
|
||||
if (this.m_Comparer.GetType() == comparer.GetType())
|
||||
this.m_Ascending = !this.m_Ascending;
|
||||
|
||||
pm.SendGump(this.GetResentGump(this.player, this.guild, comparer, this.m_Ascending, this.m_Filter, 0));
|
||||
}
|
||||
else if (id >= 200 && id < (200 + this.m_List.Count))
|
||||
{
|
||||
pm.SendGump(this.GetObjectInfoGump(this.player, this.guild, this.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()
|
||||
{
|
||||
this.player.SendGump(this.GetResentGump(this.player, this.guild, this.m_Comparer, this.m_Ascending, this.m_Filter, this.m_StartNumber));
|
||||
}
|
||||
|
||||
protected abstract TextDefinition[] GetValuesFor(T o, int aryLength);
|
||||
|
||||
protected abstract bool IsFiltered(T o, string filter);
|
||||
}
|
||||
}
|
||||
102
Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs
Normal file
102
Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
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));
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 500, 300, 0x2422);
|
||||
this.AddHtmlLocalized(25, 20, 450, 25, 1062939, 0x0, true, false); // <center>GUILD MENU</center>
|
||||
this.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.
|
||||
this.AddHtmlLocalized(25, 135, 120, 25, 1062941, 0x0, false, false); // Registration Fee:
|
||||
this.AddLabel(155, 135, 0x481, Guild.RegistrationFee.ToString());
|
||||
this.AddHtmlLocalized(25, 165, 120, 25, 1011140, 0x0, false, false); // Enter Guild Name:
|
||||
this.AddBackground(155, 160, 320, 26, 0xBB8);
|
||||
this.AddTextEntry(160, 163, 315, 21, 0x481, 5, guildName);
|
||||
this.AddHtmlLocalized(25, 191, 120, 26, 1063035, 0x0, false, false); // Abbreviation:
|
||||
this.AddBackground(155, 186, 320, 26, 0xBB8);
|
||||
this.AddTextEntry(160, 189, 315, 21, 0x481, 6, guildAbbrev);
|
||||
this.AddButton(415, 217, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0);
|
||||
this.AddButton(345, 217, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0);
|
||||
|
||||
if (pm.AcceptGuildInvites)
|
||||
this.AddButton(20, 260, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0);
|
||||
else
|
||||
this.AddButton(20, 260, 0xD3, 0xD2, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
this.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 (!Banker.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 bank box.
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
288
Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs
Normal file
288
Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs
Normal file
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
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 readonly Guild m_Guild;
|
||||
public StatusComparer(Guild g)
|
||||
{
|
||||
this.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 (this.m_Guild.IsAlly(x))
|
||||
aStatus = GuildCompareStatus.Ally;
|
||||
else if (this.m_Guild.IsWar(x))
|
||||
aStatus = GuildCompareStatus.War;
|
||||
|
||||
if (this.m_Guild.IsAlly(y))
|
||||
bStatus = GuildCompareStatus.Ally;
|
||||
else if (this.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;
|
||||
readonly 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
|
||||
})
|
||||
{
|
||||
this.m_Display = display;
|
||||
this.m_LowerText = lowerText;
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
base.PopulateGump();
|
||||
|
||||
this.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 == this.guild) ? Color(g.Name, 0x006600) : g.Name;
|
||||
defs[1] = g.Abbreviation;
|
||||
|
||||
defs[2] = 3000085; //Peace
|
||||
|
||||
if (this.guild.IsAlly(g))
|
||||
{
|
||||
if (this.guild.Alliance.Leader == g)
|
||||
defs[2] = 1063237; // Alliance Leader
|
||||
else
|
||||
defs[2] = 1062964; // Ally
|
||||
}
|
||||
else if (this.guild.IsWar(g))
|
||||
{
|
||||
defs[2] = 3000086; // War
|
||||
}
|
||||
|
||||
return defs;
|
||||
}
|
||||
|
||||
public override bool HasRelationship(Guild g)
|
||||
{
|
||||
if (g == this.guild)
|
||||
return false;
|
||||
|
||||
if (this.guild.FindPendingWar(g) != null)
|
||||
return true;
|
||||
|
||||
AllianceInfo alliance = this.guild.Alliance;
|
||||
|
||||
if (alliance != null)
|
||||
{
|
||||
Guild leader = alliance.Leader;
|
||||
|
||||
if (leader != null)
|
||||
{
|
||||
if (this.guild == leader && alliance.IsPendingMember(g) || g == leader && alliance.IsPendingMember(this.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 (this.m_LowerText != null && this.m_LowerText.Number > 0)
|
||||
this.AddHtmlLocalized(66, 153 + itemNumber * 28, 280, 26, this.m_LowerText.Number, 0xF, false, false);
|
||||
else if (this.m_LowerText != null && this.m_LowerText.String != null)
|
||||
this.AddHtml(66, 153 + itemNumber * 28, 280, 26, Color(this.m_LowerText.String, 0x99), false, false);
|
||||
|
||||
if (this.AllowAdvancedSearch)
|
||||
{
|
||||
this.AddBackground(350, 148 + itemNumber * 28, 200, 26, 0x2486);
|
||||
this.AddButton(355, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0);
|
||||
this.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( this.m_Display )
|
||||
{
|
||||
case GuildDisplayType.Relations:
|
||||
{
|
||||
//if( !( guild.IsWar( g ) || guild.IsAlly( g ) ) )
|
||||
if (!(this.guild.FindActiveWar(g) != null || this.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 !this.HasRelationship(g);
|
||||
}
|
||||
}
|
||||
|
||||
return !(Insensitive.Contains(g.Name, filter) || Insensitive.Contains(g.Abbreviation, filter));
|
||||
}
|
||||
|
||||
public override bool WillFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.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, this.m_Display);
|
||||
}
|
||||
|
||||
public override Gump GetObjectInfoGump(PlayerMobile pm, Guild g, Guild o)
|
||||
{
|
||||
if (this.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, this.guild))
|
||||
return;
|
||||
|
||||
if (this.AllowAdvancedSearch && info.ButtonID == 8)
|
||||
pm.SendGump(new GuildAdvancedSearchGump(pm, this.guild, this.m_Display, new SearchSelectionCallback(AdvancedSearch_Callback)));
|
||||
}
|
||||
|
||||
public void AdvancedSearch_Callback(GuildDisplayType display)
|
||||
{
|
||||
this.m_Display = display;
|
||||
this.ResendGump();
|
||||
}
|
||||
}
|
||||
}
|
||||
225
Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs
Normal file
225
Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
using System;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public class GuildInfoGump : BaseGuildGump
|
||||
{
|
||||
private readonly bool m_IsResigning;
|
||||
private readonly bool m_IsResigningVvV;
|
||||
|
||||
public GuildInfoGump(PlayerMobile pm, Guild g)
|
||||
: this(pm, g, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
public GuildInfoGump(PlayerMobile pm, Guild g, bool isResigning, bool isResigningVvV)
|
||||
: base(pm, g)
|
||||
{
|
||||
this.m_IsResigning = isResigning;
|
||||
this.m_IsResigningVvV = isResigningVvV;
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
bool isLeader = IsLeader(this.player, this.guild);
|
||||
base.PopulateGump();
|
||||
|
||||
this.AddHtmlLocalized(96, 43, 110, 26, 1063014, 0xF, false, false); // My Guild
|
||||
|
||||
this.AddImageTiled(65, 80, 160, 26, 0xA40);
|
||||
this.AddImageTiled(67, 82, 156, 22, 0xBBC);
|
||||
this.AddHtmlLocalized(70, 83, 150, 20, 1062954, 0x0, false, false); // <i>Guild Name</i>
|
||||
this.AddHtml(233, 84, 320, 26, this.guild.Name, false, false);
|
||||
|
||||
this.AddImageTiled(65, 114, 160, 26, 0xA40);
|
||||
this.AddImageTiled(67, 116, 156, 22, 0xBBC);
|
||||
this.AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0, false, false); // <i>Alliance</i>
|
||||
|
||||
if (this.guild.Alliance != null && this.guild.Alliance.IsMember(this.guild))
|
||||
{
|
||||
this.AddHtml(233, 118, 320, 26, this.guild.Alliance.Name, false, false);
|
||||
this.AddButton(40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0); //Alliance Roster
|
||||
}
|
||||
|
||||
this.AddImageTiled(65, 148, 160, 26, 0xA40);
|
||||
this.AddImageTiled(67, 150, 156, 22, 0xBBC);
|
||||
this.AddHtmlLocalized(70, 151, 150, 20, 1063084, 0x0, false, false); // <i>Guild Faction</i>
|
||||
|
||||
Faction f = Faction.Find(this.guild.Leader);
|
||||
if (f != null)
|
||||
this.AddHtml(233, 152, 320, 26, f.ToString(), false, false);
|
||||
|
||||
this.AddImageTiled(65, 196, 480, 4, 0x238D);
|
||||
|
||||
string s = this.guild.Charter;
|
||||
if (String.IsNullOrEmpty(s))
|
||||
s = "The guild leader has not yet set the guild charter.";
|
||||
|
||||
this.AddHtml(65, 216, 480, 80, s, true, true);
|
||||
if (isLeader)
|
||||
this.AddButton(40, 251, 0x4B9, 0x4BA, 4, GumpButtonType.Reply, 0); //Charter Edit button
|
||||
|
||||
s = this.guild.Website;
|
||||
|
||||
if (string.IsNullOrEmpty(s))
|
||||
s = "Guild website not yet set.";
|
||||
|
||||
this.AddHtml(65, 306, 480, 30, s, true, false);
|
||||
|
||||
if (isLeader)
|
||||
this.AddButton(40, 313, 0x4B9, 0x4BA, 5, GumpButtonType.Reply, 0); //Website Edit button
|
||||
|
||||
AddBackground(65, 370, 170, 26, 0x2486);
|
||||
|
||||
if (Server.Engines.VvV.ViceVsVirtueSystem.Enabled)
|
||||
{
|
||||
if (Server.Engines.VvV.ViceVsVirtueSystem.IsVvV(player))
|
||||
{
|
||||
AddButton(67, 375, 0x4B9, 0x4BA, 9, GumpButtonType.Reply, 0); // Resign Vice vs Virtue
|
||||
AddHtmlLocalized(92, 373, 170, 26, 1155557, m_IsResigningVvV ? 0x5000 : 0, false, false);
|
||||
|
||||
AddBackground(255, 370, 170, 26, 0x2486);
|
||||
AddButton(257, 375, 0x4B9, 0x4BA, 10, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(282, 373, 150, 26, 1114982, false, false); // Leaderboards
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(67, 375, 0x4B9, 0x4BA, 8, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(92, 373, 170, 26, 1155556, false, false); // Join Vice vs Virtue
|
||||
}
|
||||
}
|
||||
|
||||
AddBackground(445, 370, 100, 26, 0x2486);
|
||||
AddButton(447, 375, 0x845, 0x846, 7, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(472, 373, 60, 26, 3006115, (this.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, this.guild))
|
||||
return;
|
||||
|
||||
pm.DisplayGuildTitle = info.IsSwitched(0);
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
//1-3 handled by base.OnResponse
|
||||
case 4:
|
||||
{
|
||||
if (IsLeader(pm, this.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, this.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 (this.guild.Alliance != null && this.guild.Alliance.IsMember(this.guild))
|
||||
pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, this.guild, this.guild.Alliance));
|
||||
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
//Resign
|
||||
if (!this.m_IsResigning)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063332); // Are you sure you wish to resign from your guild?
|
||||
pm.SendGump(new GuildInfoGump(pm, this.guild, true, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guild.RemoveMember(pm, 1063411); // You resign from your guild.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
if (pm.Young)
|
||||
{
|
||||
pm.SendLocalizedMessage(1155562); // Young players may not join Vice vs Virtue. Renounce your young player status by saying, "I renounce my young player status" and try again.
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendGump(new Server.Engines.VvV.ConfirmSignupGump(pm));
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (Server.Engines.Points.PointsSystem.ViceVsVirtue.IsResigning(pm, guild))
|
||||
{
|
||||
pm.SendLocalizedMessage(1155560); // You are currently in the process of quitting Vice vs Virtue.
|
||||
}
|
||||
else if (m_IsResigningVvV)
|
||||
{
|
||||
pm.SendLocalizedMessage(1155559); // You have begun the Vice vs Virtue resignation process. You will be removed from VvV in 3 days.
|
||||
Server.Engines.Points.PointsSystem.ViceVsVirtue.OnResign(pm);
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1155558); // Are you sure you wish to resign from Vice vs Virtue? You will not be allowed to rejoin for 3 days.
|
||||
pm.SendGump(new GuildInfoGump(pm, guild, false, true));
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
pm.SendGump(new Server.Engines.VvV.ViceVsVirtueLeaderboardGump(pm));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCharter_Callback(Mobile from, string text)
|
||||
{
|
||||
if (!IsLeader(from, this.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
|
||||
{
|
||||
this.guild.Charter = charter;
|
||||
from.SendLocalizedMessage(1070775); // You submit a new guild charter.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWebsite_Callback(Mobile from, string text)
|
||||
{
|
||||
if (!IsLeader(from, this.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
|
||||
{
|
||||
this.guild.Website = site;
|
||||
from.SendLocalizedMessage(1070778); // You submit a new guild website.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public class GuildInvitationRequest : BaseGuildGump
|
||||
{
|
||||
readonly PlayerMobile m_Inviter;
|
||||
public GuildInvitationRequest(PlayerMobile pm, Guild g, PlayerMobile inviter)
|
||||
: base(pm, g)
|
||||
{
|
||||
this.m_Inviter = inviter;
|
||||
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 350, 170, 0x2422);
|
||||
this.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>
|
||||
this.AddHtml(25, 75, 300, 25, String.Format("<center>{0}</center>", this.guild.Name), true, false);
|
||||
this.AddButton(265, 130, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0);
|
||||
this.AddButton(195, 130, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0);
|
||||
this.AddButton(20, 130, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(45, 130, 150, 30, 1062943, 0x0, false, false); // <i>Ignore Guild Invites</i>
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (this.guild.Disbanded || this.player.Guild != null)
|
||||
return;
|
||||
|
||||
switch( info.ButtonID )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Inviter.SendLocalizedMessage(1063250, String.Format("{0}\t{1}", this.player.Name, this.guild.Name)); // ~1_val~ has declined your invitation to join ~2_val~.
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
this.guild.AddMember(this.player);
|
||||
this.player.SendLocalizedMessage(1063056, this.guild.Name); // You have joined ~1_val~.
|
||||
this.m_Inviter.SendLocalizedMessage(1063249, String.Format("{0}\t{1}", this.player.Name, this.guild.Name)); // ~1_val~ has accepted your invitation to join ~2_val~.
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
this.player.AcceptGuildInvites = false;
|
||||
this.player.SendLocalizedMessage(1070698); // You are now ignoring guild invitations.
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
227
Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs
Normal file
227
Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs
Normal file
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public class GuildMemberInfoGump : BaseGuildGump
|
||||
{
|
||||
readonly PlayerMobile m_Member;
|
||||
readonly bool m_ToLeader;
|
||||
readonly bool m_toKick;
|
||||
public GuildMemberInfoGump(PlayerMobile pm, Guild g, PlayerMobile member, bool toKick, bool toPromoteToLeader)
|
||||
: base(pm, g, 10, 40)
|
||||
{
|
||||
this.m_ToLeader = toPromoteToLeader;
|
||||
this.m_toKick = toKick;
|
||||
this.m_Member = member;
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 350, 255, 0x242C);
|
||||
this.AddHtmlLocalized(20, 15, 310, 26, 1063018, 0x0, false, false); // <div align=center><i>Guild Member Information</i></div>
|
||||
this.AddImageTiled(20, 40, 310, 2, 0x2711);
|
||||
|
||||
this.AddHtmlLocalized(20, 50, 150, 26, 1062955, 0x0, true, false); // <i>Name</i>
|
||||
this.AddHtml(180, 53, 150, 26, this.m_Member.Name, false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 150, 26, 1062956, 0x0, true, false); // <i>Rank</i>
|
||||
this.AddHtmlLocalized(180, 83, 150, 26, this.m_Member.GuildRank.Name, 0x0, false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 110, 150, 26, 1062953, 0x0, true, false); // <i>Guild Title</i>
|
||||
this.AddHtml(180, 113, 150, 26, this.m_Member.GuildTitle, false, false);
|
||||
this.AddImageTiled(20, 142, 310, 2, 0x2711);
|
||||
|
||||
this.AddBackground(20, 150, 310, 26, 0x2486);
|
||||
this.AddButton(25, 155, 0x845, 0x846, 4, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(50, 153, 270, 26, (this.m_Member == this.player.GuildFealty && this.guild.Leader != this.m_Member) ? 1063082 : 1062996, 0x0, false, false); // Clear/Cast Vote For This Member
|
||||
|
||||
this.AddBackground(20, 180, 150, 26, 0x2486);
|
||||
this.AddButton(25, 185, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(50, 183, 110, 26, 1062993, (this.m_ToLeader) ? 0x990000 : 0, false, false); // Promote
|
||||
|
||||
this.AddBackground(180, 180, 150, 26, 0x2486);
|
||||
this.AddButton(185, 185, 0x845, 0x846, 3, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(210, 183, 110, 26, 1062995, 0x0, false, false); // Set Guild Title
|
||||
|
||||
this.AddBackground(20, 210, 150, 26, 0x2486);
|
||||
this.AddButton(25, 215, 0x845, 0x846, 2, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(50, 213, 110, 26, 1062994, 0x0, false, false); // Demote
|
||||
|
||||
this.AddBackground(180, 210, 150, 26, 0x2486);
|
||||
this.AddButton(185, 215, 0x845, 0x846, 5, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(210, 213, 110, 26, 1062997, (this.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, this.guild) || !IsMember(this.m_Member, this.guild))
|
||||
return;
|
||||
|
||||
RankDefinition playerRank = pm.GuildRank;
|
||||
RankDefinition targetRank = this.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 (this.m_ToLeader)
|
||||
{
|
||||
this.m_Member.GuildRank = targetRank;
|
||||
pm.SendLocalizedMessage(1063156, this.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.
|
||||
this.guild.Leader = this.m_Member;
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1063144); // Are you sure you wish to make this member the new guild leader?
|
||||
pm.SendGump(new GuildMemberInfoGump(this.player, this.guild, this.m_Member, false, true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Member.GuildRank = targetRank;
|
||||
pm.SendLocalizedMessage(1063156, this.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
|
||||
{
|
||||
this.m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1];
|
||||
pm.SendLocalizedMessage(1063156, this.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 || this.m_Member == this.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 (this.m_Member.GuildTitle == null || this.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 (this.m_Member == pm.GuildFealty && this.guild.Leader != this.m_Member)
|
||||
pm.SendLocalizedMessage(1063158); // You have cleared your vote for guild leader.
|
||||
else if (this.guild.CanVote(this.m_Member))//( playerRank.GetFlag( RankFlags.CanVote ) )
|
||||
{
|
||||
if (this.m_Member == this.guild.Leader)
|
||||
pm.SendLocalizedMessage(1063424); // You can't vote for the current guild leader.
|
||||
else if (!this.guild.CanBeVotedFor(this.m_Member))
|
||||
pm.SendLocalizedMessage(1063425); // You can't vote for an inactive guild member.
|
||||
else
|
||||
{
|
||||
pm.GuildFealty = this.m_Member;
|
||||
pm.SendLocalizedMessage(1063159, this.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 (this.m_toKick)
|
||||
{
|
||||
this.guild.RemoveMember(this.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(this.player, this.guild, this.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 = this.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 (this.m_Member.GuildTitle == null || this.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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
267
Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs
Normal file
267
Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
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 readonly 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}{2}",
|
||||
pm.Name,
|
||||
Engines.VvV.ViceVsVirtueSystem.IsVvV(pm) ? "VvV" : "",
|
||||
(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;
|
||||
|
||||
PlayerState guildState = PlayerState.Find(g.Leader);
|
||||
PlayerState targetState = PlayerState.Find(targ);
|
||||
|
||||
Faction guildFaction = (guildState == null ? null : guildState.Faction);
|
||||
Faction targetFaction = (targetState == null ? null : targetState.Faction);
|
||||
|
||||
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.
|
||||
}
|
||||
#region Factions
|
||||
else if (targ.Young && guildFaction != null)
|
||||
{
|
||||
pm.SendLocalizedMessage(1070766); // You cannot invite a young player to your faction-aligned guild.
|
||||
}
|
||||
else if (guildFaction != targetFaction)
|
||||
{
|
||||
if (guildFaction == null)
|
||||
pm.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild.
|
||||
else if (targetFaction == null)
|
||||
pm.SendLocalizedMessage(1013026); // That player must be in a faction before joining this guild.
|
||||
else
|
||||
pm.SendLocalizedMessage(1013028); // That person has a different faction affiliation.
|
||||
}
|
||||
else if (targetState != null && targetState.IsLeaving)
|
||||
{
|
||||
// OSI does this quite strangely, so we'll just do it this way
|
||||
pm.SendMessage("That person is quitting their faction and so you may not recruit them.");
|
||||
}
|
||||
#endregion
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1063053, targ.Name); // You invite ~1_val~ to join your guild.
|
||||
targ.SendGump(new GuildInvitationRequest(targ, guild, pm));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
629
Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs
Normal file
629
Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs
Normal file
@@ -0,0 +1,629 @@
|
||||
using System;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public class OtherGuildInfo : BaseGuildGump
|
||||
{
|
||||
private readonly Guild m_Other;
|
||||
public OtherGuildInfo(PlayerMobile pm, Guild g, Guild otherGuild)
|
||||
: base(pm, g, 10, 40)
|
||||
{
|
||||
this.m_Other = otherGuild;
|
||||
|
||||
g.CheckExpiredWars();
|
||||
|
||||
this.PopulateGump();
|
||||
}
|
||||
|
||||
public void AddButtonAndBackground(int x, int y, int buttonID, int locNum)
|
||||
{
|
||||
this.AddBackground(x, y, 225, 26, 0x2486);
|
||||
this.AddButton(x + 5, y + 5, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(x + 30, y + 3, 185, 26, locNum, 0x0, false, false);
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
{
|
||||
Guild g = Guild.GetAllianceLeader(this.guild);
|
||||
Guild other = Guild.GetAllianceLeader(this.m_Other);
|
||||
|
||||
WarDeclaration war = g.FindPendingWar(other);
|
||||
WarDeclaration activeWar = g.FindActiveWar(other);
|
||||
|
||||
AllianceInfo alliance = this.guild.Alliance;
|
||||
AllianceInfo otherAlliance = this.m_Other.Alliance;
|
||||
//NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses
|
||||
|
||||
bool PendingWar = (war != null);
|
||||
bool ActiveWar = (activeWar != null);
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 520, 335, 0x242C);
|
||||
this.AddHtmlLocalized(20, 15, 480, 26, 1062975, 0x0, false, false); // <div align=center><i>Guild Relationship</i></div>
|
||||
this.AddImageTiled(20, 40, 480, 2, 0x2711);
|
||||
this.AddHtmlLocalized(20, 50, 120, 26, 1062954, 0x0, true, false); // <i>Guild Name</i>
|
||||
this.AddHtml(150, 53, 360, 26, this.m_Other.Name, false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true, false); // <i>Alliance</i>
|
||||
|
||||
if (otherAlliance != null)
|
||||
{
|
||||
if (otherAlliance.IsMember(this.m_Other))
|
||||
{
|
||||
this.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 );
|
||||
*/
|
||||
}
|
||||
|
||||
this.AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true, false); // <i>Abbreviation</i>
|
||||
this.AddHtml(150, 113, 120, 26, this.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.UtcNow)
|
||||
timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.UtcNow;
|
||||
|
||||
//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 = this.m_Other.FindActiveWar(this.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 = this.m_Other.FindPendingWar(this.guild);
|
||||
if (otherWar != null)
|
||||
otherKills = Color(String.Format("{0}/{1}", otherWar.Kills, otherWar.MaxKills), 0x990000);
|
||||
}
|
||||
|
||||
this.AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true, false); // <i>Your Kills</i>
|
||||
this.AddHtml(410, 113, 120, 26, kills, false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 140, 120, 26, 1062968, 0x0, true, false); // <i>Time Remaining</i>
|
||||
this.AddHtml(150, 143, 120, 26, time, false, false);
|
||||
|
||||
this.AddHtmlLocalized(280, 140, 120, 26, 1062967, 0x0, true, false); // <i>Their Kills</i>
|
||||
this.AddHtml(410, 143, 120, 26, otherKills, false, false);
|
||||
|
||||
this.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>
|
||||
|
||||
this.AddButtonAndBackground(20, 260, 5, 1062981); // Accept Challenge
|
||||
this.AddButtonAndBackground(275, 260, 6, 1062983); //Modify Terms
|
||||
}
|
||||
|
||||
this.AddButtonAndBackground(20, 290, 7, 1062982); // Dismiss Challenge
|
||||
}
|
||||
else if (ActiveWar)
|
||||
{
|
||||
number = 1062965; // <div align=center>You are at war with this guild!</div>
|
||||
this.AddButtonAndBackground(20, 290, 8, 1062980); // Surrender
|
||||
}
|
||||
else if (alliance != null && alliance == otherAlliance) //alliance, Same Alliance
|
||||
{
|
||||
if (alliance.IsMember(this.guild) && alliance.IsMember(this.m_Other)) //Both in Same alliance, full members
|
||||
{
|
||||
number = 1062970; // <div align=center>You are allied with this guild.</div>
|
||||
|
||||
if (alliance.Leader == this.guild)
|
||||
{
|
||||
this.AddButtonAndBackground(20, 260, 12, 1062984); // Remove Guild from Alliance
|
||||
this.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
|
||||
this.AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster
|
||||
//Leave Alliance
|
||||
this.AddButtonAndBackground(20, 290, 11, 1062985); // Leave Alliance
|
||||
}
|
||||
else if (alliance.Leader == this.guild && alliance.IsPendingMember(this.m_Other))
|
||||
{
|
||||
number = 1062971; // <div align=center>You have requested an alliance with this guild.</div>
|
||||
|
||||
//Show Alliance Roster, Centered, down.
|
||||
this.AddButtonAndBackground(148, 245, 10, 1063164); //Show Alliance Roster
|
||||
//Withdraw Request
|
||||
this.AddButtonAndBackground(20, 290, 14, 1062986); // Withdraw Request
|
||||
|
||||
this.AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false);
|
||||
}
|
||||
else if (alliance.Leader == this.m_Other && alliance.IsPendingMember(this.guild))
|
||||
{
|
||||
number = 1062972; // <div align=center>This guild has requested an alliance.</div>
|
||||
|
||||
//Show alliance Roster, top
|
||||
this.AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster
|
||||
//Deny Request
|
||||
//Accept Request
|
||||
this.AddButtonAndBackground(20, 260, 15, 1062988); // Deny Request
|
||||
this.AddButtonAndBackground(20, 290, 16, 1062987); // Accept Request
|
||||
|
||||
this.AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AddButtonAndBackground(20, 260, 2, 1062990); // Request Alliance
|
||||
this.AddButtonAndBackground(20, 290, 1, 1062989); // Declare War!
|
||||
}
|
||||
|
||||
this.AddButtonAndBackground(275, 290, 0, 3000091); //Cancel
|
||||
|
||||
this.AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true, false);
|
||||
this.AddImageTiled(20, 245, 480, 2, 0x2711);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
PlayerMobile pm = sender.Mobile as PlayerMobile;
|
||||
|
||||
if (!IsMember(pm, this.guild))
|
||||
return;
|
||||
|
||||
RankDefinition playerRank = pm.GuildRank;
|
||||
|
||||
Guild guildLeader = Guild.GetAllianceLeader(this.guild);
|
||||
Guild otherGuild = Guild.GetAllianceLeader(this.m_Other);
|
||||
|
||||
WarDeclaration war = guildLeader.FindPendingWar(otherGuild);
|
||||
WarDeclaration activeWar = guildLeader.FindActiveWar(otherGuild);
|
||||
WarDeclaration otherWar = otherGuild.FindPendingWar(guildLeader);
|
||||
|
||||
AllianceInfo alliance = this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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
|
||||
this.guild.PendingWars.Remove(war);
|
||||
war.WarBeginning = DateTime.UtcNow;
|
||||
this.guild.AcceptedWars.Add(war);
|
||||
|
||||
if (alliance != null && alliance.IsMember(this.guild))
|
||||
{
|
||||
alliance.AllianceMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
||||
alliance.InvalidateMemberProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guild.GuildMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
||||
this.guild.InvalidateMemberProperties();
|
||||
}
|
||||
//Technically SHOULD say Your guild is now at war w/out any info, intentional diff.
|
||||
|
||||
otherGuild.PendingWars.Remove(otherWar);
|
||||
otherWar.WarBeginning = DateTime.UtcNow;
|
||||
otherGuild.AcceptedWars.Add(otherWar);
|
||||
|
||||
if (otherAlliance != null && this.m_Other.Alliance.IsMember(this.m_Other))
|
||||
{
|
||||
otherAlliance.AllianceMessage(1070769, ((alliance != null) ? alliance.Name : this.guild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
|
||||
otherAlliance.InvalidateMemberProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
otherGuild.GuildMessage(1070769, ((alliance != null) ? alliance.Name : this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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, this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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
|
||||
this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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(this.guild))
|
||||
{
|
||||
alliance.AllianceMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));// You have lost the war with ~1_val~.
|
||||
alliance.InvalidateMemberProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guild.GuildMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));// You have lost the war with ~1_val~.
|
||||
this.guild.InvalidateMemberProperties();
|
||||
}
|
||||
|
||||
this.guild.AcceptedWars.Remove(activeWar);
|
||||
|
||||
if (otherAlliance != null && otherAlliance.IsMember(otherGuild))
|
||||
{
|
||||
otherAlliance.AllianceMessage(1070739, ((this.guild.Alliance != null) ? this.guild.Alliance.Name : this.guild.Name));// You have won the war against ~1_val~!
|
||||
otherAlliance.InvalidateMemberProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
otherGuild.GuildMessage(1070739, ((this.guild.Alliance != null) ? this.guild.Alliance.Name : this.guild.Name));// You have won the war against ~1_val~!
|
||||
otherGuild.InvalidateMemberProperties();
|
||||
}
|
||||
|
||||
otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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 != this.m_Other)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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, this.guild, this.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 (Faction.Find(this.guild.Leader) != Faction.Find(this.m_Other.Leader))
|
||||
{
|
||||
pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
|
||||
}
|
||||
else if (otherAlliance != null)
|
||||
{
|
||||
if (otherAlliance.IsPendingMember(this.m_Other))
|
||||
pm.SendLocalizedMessage(1063416, this.m_Other.Name); // ~1_val~ is currently considering another alliance proposal.
|
||||
else
|
||||
pm.SendLocalizedMessage(1063426, this.m_Other.Name); // ~1_val~ already belongs to an alliance.
|
||||
}
|
||||
else if (this.m_Other.AcceptedWars.Count > 0 || this.m_Other.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.m_Other.Name); // ~1_val~ is currently involved in a guild war.
|
||||
}
|
||||
else if (this.guild.AcceptedWars.Count > 0 || this.guild.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
}
|
||||
else if (otherAlliance != null)
|
||||
{
|
||||
if (otherAlliance.IsPendingMember(this.m_Other))
|
||||
pm.SendLocalizedMessage(1063416, this.m_Other.Name); // ~1_val~ is currently considering another alliance proposal.
|
||||
else
|
||||
pm.SendLocalizedMessage(1063426, this.m_Other.Name); // ~1_val~ already belongs to an alliance.
|
||||
}
|
||||
else if (alliance.IsPendingMember(this.guild))
|
||||
{
|
||||
pm.SendLocalizedMessage(1063416, this.guild.Name); // ~1_val~ is currently considering another alliance proposal.
|
||||
}
|
||||
else if (this.m_Other.AcceptedWars.Count > 0 || this.m_Other.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.m_Other.Name); // ~1_val~ is currently involved in a guild war.
|
||||
}
|
||||
else if (this.guild.AcceptedWars.Count > 0 || this.guild.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.guild.Name); // ~1_val~ is currently involved in a guild war.
|
||||
}
|
||||
else if (Faction.Find(this.guild.Leader) != Faction.Find(this.m_Other.Leader))
|
||||
{
|
||||
pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
|
||||
}
|
||||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1070750, this.m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.
|
||||
|
||||
this.m_Other.GuildMessage(1070780, this.guild.Name); // ~1_val~ has proposed an alliance.
|
||||
|
||||
this.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, this.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(this.guild))
|
||||
{
|
||||
this.guild.Alliance = null; //Calls alliance.Removeguild
|
||||
// alliance.RemoveGuild( guild );
|
||||
|
||||
this.m_Other.InvalidateWarNotoriety();
|
||||
|
||||
this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
}
|
||||
else if (alliance != null && alliance.IsMember(this.guild) && alliance.IsMember(this.m_Other))
|
||||
{
|
||||
this.m_Other.Alliance = null;
|
||||
|
||||
this.m_Other.InvalidateMemberNotoriety();
|
||||
|
||||
this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
}
|
||||
else if (alliance != null && alliance.IsMember(this.guild) && alliance.IsMember(this.m_Other))
|
||||
{
|
||||
pm.SendLocalizedMessage(1063434, String.Format("{0}\t{1}", this.m_Other.Name, alliance.Name)); // ~1_val~ is now the leader of ~2_val~.
|
||||
|
||||
alliance.Leader = this.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 == this.guild && alliance.IsPendingMember(this.m_Other))
|
||||
{
|
||||
this.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 == this.m_Other && otherAlliance.IsPendingMember(this.guild))
|
||||
{
|
||||
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
||||
//m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal. //Per OSI commented out.
|
||||
|
||||
this.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 == this.m_Other && otherAlliance.IsPendingMember(this.guild))
|
||||
{
|
||||
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
||||
|
||||
otherAlliance.TurnToMember(this.m_Other); //No need to verify it's in the guild or already a member, the function does this
|
||||
|
||||
otherAlliance.TurnToMember(this.guild);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateAlliance_Callback(Mobile from, string text)
|
||||
{
|
||||
PlayerMobile pm = from as PlayerMobile;
|
||||
|
||||
AllianceInfo alliance = this.guild.Alliance;
|
||||
AllianceInfo otherAlliance = this.m_Other.Alliance;
|
||||
|
||||
if (!IsMember(from, this.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 (Faction.Find(this.guild.Leader) != Faction.Find(this.m_Other.Leader))
|
||||
{
|
||||
//Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
|
||||
pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
|
||||
}
|
||||
else if (otherAlliance != null)
|
||||
{
|
||||
if (otherAlliance.IsPendingMember(this.m_Other))
|
||||
pm.SendLocalizedMessage(1063416, this.m_Other.Name); // ~1_val~ is currently considering another alliance proposal.
|
||||
else
|
||||
pm.SendLocalizedMessage(1063426, this.m_Other.Name); // ~1_val~ already belongs to an alliance.
|
||||
}
|
||||
else if (this.m_Other.AcceptedWars.Count > 0 || this.m_Other.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.m_Other.Name); // ~1_val~ is currently involved in a guild war.
|
||||
}
|
||||
else if (this.guild.AcceptedWars.Count > 0 || this.guild.PendingWars.Count > 0)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063427, this.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, this.m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.
|
||||
|
||||
this.m_Other.GuildMessage(1070780, this.guild.Name); // ~1_val~ has proposed an alliance.
|
||||
|
||||
new AllianceInfo(this.guild, name, this.m_Other);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
128
Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs
Normal file
128
Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Guilds
|
||||
{
|
||||
public class WarDeclarationGump : BaseGuildGump
|
||||
{
|
||||
private readonly Guild m_Other;
|
||||
public WarDeclarationGump(PlayerMobile pm, Guild g, Guild otherGuild)
|
||||
: base(pm, g)
|
||||
{
|
||||
this.m_Other = otherGuild;
|
||||
WarDeclaration war = g.FindPendingWar(otherGuild);
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 500, 340, 0x24AE);
|
||||
this.AddBackground(65, 50, 370, 30, 0x2486);
|
||||
this.AddHtmlLocalized(75, 55, 370, 26, 1062979, 0x3C00, false, false); // <div align=center><i>Declaration of War</i></div>
|
||||
this.AddImage(410, 45, 0x232C);
|
||||
this.AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF, false, false); // <i>Duration of War</i>
|
||||
this.AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0, false, false); // Enter the number of hours the war will last.
|
||||
this.AddBackground(65, 150, 40, 30, 0x2486);
|
||||
this.AddTextEntry(70, 154, 50, 30, 0x481, 10, (war != null) ? war.WarLength.Hours.ToString() : "0");
|
||||
this.AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF, false, false); // <i>Victory Condition</i>
|
||||
this.AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0, false, false); // Enter the winning number of kills.
|
||||
this.AddBackground(65, 250, 40, 30, 0x2486);
|
||||
this.AddTextEntry(70, 254, 50, 30, 0x481, 11, (war != null) ? war.MaxKills.ToString() : "0");
|
||||
this.AddBackground(190, 270, 130, 26, 0x2486);
|
||||
this.AddButton(195, 275, 0x845, 0x846, 0, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0, false, false); // Cancel
|
||||
this.AddBackground(330, 270, 130, 26, 0x2486);
|
||||
this.AddButton(335, 275, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
|
||||
this.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, this.guild))
|
||||
return;
|
||||
|
||||
RankDefinition playerRank = pm.GuildRank;
|
||||
|
||||
switch( info.ButtonID )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
AllianceInfo alliance = this.guild.Alliance;
|
||||
AllianceInfo otherAlliance = this.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 != this.guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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 != this.m_Other)
|
||||
{
|
||||
pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", this.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 = this.guild.FindActiveWar(this.m_Other);
|
||||
|
||||
if (activeWar == null)
|
||||
{
|
||||
WarDeclaration war = this.guild.FindPendingWar(this.m_Other);
|
||||
WarDeclaration otherWar = this.m_Other.FindPendingWar(this.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
|
||||
{
|
||||
this.guild.PendingWars.Add(new WarDeclaration(this.guild, this.m_Other, maxKills, warLength, true));
|
||||
}
|
||||
|
||||
if (otherWar != null)
|
||||
{
|
||||
otherWar.MaxKills = maxKills;
|
||||
otherWar.WarLength = warLength;
|
||||
otherWar.WarRequester = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Other.PendingWars.Add(new WarDeclaration(this.m_Other, this.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
|
||||
this.m_Other.GuildMessage(1070781, ((this.guild.Alliance != null) ? this.guild.Alliance.Name : this.guild.Name)); // ~1_val~ has proposed a war.
|
||||
|
||||
pm.SendLocalizedMessage(1070751, ((this.m_Other.Alliance != null) ? this.m_Other.Alliance.Name : this.m_Other.Name)); // War proposal has been sent to ~1_val~.
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
pm.SendGump(new OtherGuildInfo(pm, this.guild, this.m_Other));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user