Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
140
Projects/Scripts/Items/Guilds/GuildDeed.cs
Normal file
140
Projects/Scripts/Items/Guilds/GuildDeed.cs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GuildDeed : Item
|
||||
{
|
||||
[Constructible]
|
||||
public GuildDeed() : base(0x14F0)
|
||||
{
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public GuildDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1041055; // a guild deed
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (Weight == 0.0)
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (from.Guild != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501137); // You must resign from your current guild before founding another!
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
from.SendLocalizedMessage(501138); // You can only place a guildstone in a house.
|
||||
}
|
||||
else if (house.FindGuildstone() != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house.
|
||||
}
|
||||
else if (!house.IsOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501141); // You can only place a guildstone in a house you own!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max):
|
||||
from.Prompt = new InternalPrompt(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalPrompt : Prompt
|
||||
{
|
||||
private GuildDeed m_Deed;
|
||||
|
||||
public InternalPrompt(GuildDeed deed)
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
if (m_Deed.Deleted)
|
||||
return;
|
||||
|
||||
if (!m_Deed.IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (from.Guild != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501137); // You must resign from your current guild before founding another!
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
from.SendLocalizedMessage(501138); // You can only place a guildstone in a house.
|
||||
}
|
||||
else if (house.FindGuildstone() != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house.
|
||||
}
|
||||
else if (!house.IsOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501141); // You can only place a guildstone in a house you own!
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Deed.Delete();
|
||||
|
||||
if (text.Length > 40)
|
||||
text = text.Substring(0, 40);
|
||||
|
||||
Guild guild = new Guild(from, text, "none");
|
||||
|
||||
from.Guild = guild;
|
||||
from.GuildTitle = "Guildmaster";
|
||||
|
||||
Guildstone stone = new Guildstone(guild);
|
||||
|
||||
stone.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
guild.Guildstone = stone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
from.SendLocalizedMessage(501145); // Placement of guildstone cancelled.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
96
Projects/Scripts/Items/Guilds/GuildTeleporter.cs
Normal file
96
Projects/Scripts/Items/Guilds/GuildTeleporter.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GuildTeleporter : Item
|
||||
{
|
||||
private Item m_Stone;
|
||||
|
||||
public GuildTeleporter(Item stone = null) : base(0x1869)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
m_Stone = stone;
|
||||
}
|
||||
|
||||
public GuildTeleporter(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1041054; // guildstone teleporter
|
||||
|
||||
public override bool DisplayLootType => false;
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_Stone);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Stone = reader.ReadItem();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Weight == 0.0)
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
Guildstone stone = m_Stone as Guildstone;
|
||||
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (stone?.Deleted != false || stone.Guild?.Teleporter != this)
|
||||
{
|
||||
from.SendLocalizedMessage(501197); // This teleporting object can not determine what guildstone to teleport
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
from.SendLocalizedMessage(501138); // You can only place a guildstone in a house.
|
||||
}
|
||||
else if (!house.IsOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501141); // You can only place a guildstone in a house you own!
|
||||
}
|
||||
else if (house.FindGuildstone() != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stone.MoveToWorld(from.Location, from.Map);
|
||||
Delete();
|
||||
stone.Guild.Teleporter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
440
Projects/Scripts/Items/Guilds/Guildstone.cs
Normal file
440
Projects/Scripts/Items/Guilds/Guildstone.cs
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
using System;
|
||||
using Server.Factions;
|
||||
using Server.Guilds;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Guildstone : Item, IAddon, IChopable
|
||||
{
|
||||
private bool m_BeforeChangeover;
|
||||
private string m_GuildAbbrev;
|
||||
private string m_GuildName;
|
||||
|
||||
public Guildstone(Guild g) : this(g, g.Name, g.Abbreviation)
|
||||
{
|
||||
}
|
||||
|
||||
public Guildstone(Guild g, string guildName, string abbrev) : base(Guild.NewGuildSystem ? 0xED6 : 0xED4)
|
||||
{
|
||||
Guild = g;
|
||||
m_GuildName = guildName;
|
||||
m_GuildAbbrev = abbrev;
|
||||
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public Guildstone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string GuildName
|
||||
{
|
||||
get => m_GuildName;
|
||||
set
|
||||
{
|
||||
m_GuildName = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string GuildAbbrev
|
||||
{
|
||||
get => m_GuildAbbrev;
|
||||
set
|
||||
{
|
||||
m_GuildAbbrev = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Guild Guild{ get; private set; }
|
||||
|
||||
public override int LabelNumber => 1041429; // a guildstone
|
||||
|
||||
#region IChopable Members
|
||||
|
||||
public void OnChop(Mobile from)
|
||||
{
|
||||
if (!Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
bool contains = false;
|
||||
|
||||
if (house == null && m_BeforeChangeover || house?.IsOwner(from) == true && (contains = house.Addons.Contains(this)))
|
||||
{
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
|
||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||
|
||||
Delete();
|
||||
|
||||
if (contains)
|
||||
house.Addons.Remove(this);
|
||||
|
||||
Item deed = Deed;
|
||||
|
||||
if (deed != null)
|
||||
from.AddToBackpack(deed);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if (Guild?.Disbanded == false)
|
||||
{
|
||||
m_GuildName = Guild.Name;
|
||||
m_GuildAbbrev = Guild.Abbreviation;
|
||||
}
|
||||
|
||||
writer.Write(3); // version
|
||||
|
||||
writer.Write(m_BeforeChangeover);
|
||||
|
||||
writer.Write(m_GuildName);
|
||||
writer.Write(m_GuildAbbrev);
|
||||
|
||||
writer.Write(Guild);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
m_BeforeChangeover = reader.ReadBool();
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_GuildName = reader.ReadString();
|
||||
m_GuildAbbrev = reader.ReadString();
|
||||
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
Guild = reader.ReadGuild() as Guild;
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Guild.NewGuildSystem && ItemID == 0xED4)
|
||||
ItemID = 0xED6;
|
||||
|
||||
if (version <= 2)
|
||||
m_BeforeChangeover = true;
|
||||
|
||||
if (Guild.NewGuildSystem && m_BeforeChangeover)
|
||||
Timer.DelayCall(TimeSpan.Zero, AddToHouse);
|
||||
|
||||
if (!Guild.NewGuildSystem && Guild == null)
|
||||
Delete();
|
||||
}
|
||||
|
||||
private void AddToHouse()
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
if (Guild.NewGuildSystem && m_BeforeChangeover && house?.Addons.Contains(this) == false)
|
||||
{
|
||||
house.Addons.Add(this);
|
||||
m_BeforeChangeover = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (Guild?.Disbanded == false)
|
||||
{
|
||||
string name;
|
||||
string abbr;
|
||||
|
||||
if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0)
|
||||
name = "(unnamed)";
|
||||
|
||||
if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0)
|
||||
abbr = "";
|
||||
|
||||
//list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~
|
||||
list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]");
|
||||
}
|
||||
else if (m_GuildName != null && m_GuildAbbrev != null)
|
||||
{
|
||||
list.Add(1060802, $"{Utility.FixHtml(m_GuildName)} [{Utility.FixHtml(m_GuildAbbrev)}]");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
if (Guild?.Disbanded == false)
|
||||
{
|
||||
string name;
|
||||
|
||||
if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0)
|
||||
name = "(unnamed)";
|
||||
|
||||
LabelTo(from, name);
|
||||
}
|
||||
else if (m_GuildName != null)
|
||||
{
|
||||
LabelTo(from, m_GuildName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (!Guild.NewGuildSystem && Guild?.Disbanded == false)
|
||||
Guild.Disband();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
if (Guild?.Disbanded != false)
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
else if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
else if (Guild.Accepted.Contains(from))
|
||||
{
|
||||
#region Factions
|
||||
|
||||
PlayerState guildState = PlayerState.Find(Guild.Leader);
|
||||
PlayerState targetState = PlayerState.Find(from);
|
||||
|
||||
Faction guildFaction = guildState?.Faction;
|
||||
Faction targetFaction = targetState?.Faction;
|
||||
|
||||
if (guildFaction != targetFaction || targetState?.IsLeaving == true)
|
||||
return;
|
||||
|
||||
if (guildState != null && targetState != null)
|
||||
targetState.Leaving = guildState.Leaving;
|
||||
|
||||
#endregion
|
||||
|
||||
Guild.Accepted.Remove(from);
|
||||
Guild.AddMember(from);
|
||||
|
||||
GuildGump.EnsureClosed(from);
|
||||
from.SendGump(new GuildGump(from, Guild));
|
||||
}
|
||||
else if (from.AccessLevel < AccessLevel.GameMaster && !Guild.IsMember(from))
|
||||
{
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, 501158, "",
|
||||
"")); // You are not a member ...
|
||||
}
|
||||
else
|
||||
{
|
||||
GuildGump.EnsureClosed(from);
|
||||
from.SendGump(new GuildGump(from, Guild));
|
||||
}
|
||||
}
|
||||
|
||||
#region IAddon Members
|
||||
|
||||
public Item Deed => new GuildstoneDeed(Guild, m_GuildName, m_GuildAbbrev);
|
||||
|
||||
public bool CouldFit(IPoint3D p, Map map)
|
||||
{
|
||||
return map.CanFit(p.X, p.Y, p.Z, ItemData.Height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Flippable(0x14F0, 0x14EF)]
|
||||
public class GuildstoneDeed : Item
|
||||
{
|
||||
private string m_GuildAbbrev;
|
||||
|
||||
private string m_GuildName;
|
||||
|
||||
public GuildstoneDeed(Guild g = null, string guildName = null, string abbrev = null) :
|
||||
base(0x14F0)
|
||||
{
|
||||
Guild = g;
|
||||
m_GuildName = guildName;
|
||||
m_GuildAbbrev = abbrev;
|
||||
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public GuildstoneDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1041233; // deed to a guildstone
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string GuildName
|
||||
{
|
||||
get => m_GuildName;
|
||||
set
|
||||
{
|
||||
m_GuildName = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string GuildAbbrev
|
||||
{
|
||||
get => m_GuildAbbrev;
|
||||
set
|
||||
{
|
||||
m_GuildAbbrev = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Guild Guild{ get; private set; }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if (Guild?.Disbanded == false)
|
||||
{
|
||||
m_GuildName = Guild.Name;
|
||||
m_GuildAbbrev = Guild.Abbreviation;
|
||||
}
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(m_GuildName);
|
||||
writer.Write(m_GuildAbbrev);
|
||||
|
||||
writer.Write(Guild);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_GuildName = reader.ReadString();
|
||||
m_GuildAbbrev = reader.ReadString();
|
||||
|
||||
Guild = reader.ReadGuild() as Guild;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (Guild?.Disbanded == false)
|
||||
{
|
||||
string name;
|
||||
string abbr;
|
||||
|
||||
if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0)
|
||||
name = "(unnamed)";
|
||||
|
||||
if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0)
|
||||
abbr = "";
|
||||
|
||||
//list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~
|
||||
list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]");
|
||||
}
|
||||
else if (m_GuildName != null && m_GuildAbbrev != null)
|
||||
{
|
||||
list.Add(1060802, $"{Utility.FixHtml(m_GuildName)} [{Utility.FixHtml(m_GuildAbbrev)}]");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if (house?.IsOwner(from) == true)
|
||||
{
|
||||
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
|
||||
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502092); // You must be in your house to do this.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public void Placement_OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (!(targeted is IPoint3D p) || Deleted)
|
||||
return;
|
||||
|
||||
Point3D loc = new Point3D(p);
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
|
||||
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
if (house?.IsOwner(from) == true)
|
||||
{
|
||||
Item addon = new Guildstone(Guild, m_GuildName, m_GuildAbbrev);
|
||||
|
||||
addon.MoveToWorld(loc, from.Map);
|
||||
|
||||
house.Addons.Add(addon);
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042036); // That location is not in your house.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue