Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,140 +1,140 @@
|
|||
using Server.Prompts;
|
||||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GuildDeed : Item
|
||||
{
|
||||
public override int LabelNumber => 1041055; // a guild deed
|
||||
public class GuildDeed : Item
|
||||
{
|
||||
[Constructible]
|
||||
public GuildDeed() : base(0x14F0)
|
||||
{
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GuildDeed() : base( 0x14F0 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
}
|
||||
public GuildDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public GuildDeed( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override int LabelNumber => 1041055; // a guild deed
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( Weight == 0.0 )
|
||||
Weight = 1.0;
|
||||
}
|
||||
if (Weight == 0.0)
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( Guild.NewGuildSystem )
|
||||
return;
|
||||
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 (!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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
private class InternalPrompt : Prompt
|
||||
{
|
||||
private GuildDeed m_Deed;
|
||||
|
||||
public InternalPrompt( GuildDeed deed )
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
public InternalPrompt(GuildDeed deed)
|
||||
{
|
||||
m_Deed = deed;
|
||||
}
|
||||
|
||||
public override void OnResponse( Mobile from, string text )
|
||||
{
|
||||
if ( m_Deed.Deleted )
|
||||
return;
|
||||
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 (!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 (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 );
|
||||
if (text.Length > 40)
|
||||
text = text.Substring(0, 40);
|
||||
|
||||
Guild guild = new Guild( from, text, "none" );
|
||||
Guild guild = new Guild(from, text, "none");
|
||||
|
||||
from.Guild = guild;
|
||||
from.GuildTitle = "Guildmaster";
|
||||
from.Guild = guild;
|
||||
from.GuildTitle = "Guildmaster";
|
||||
|
||||
Guildstone stone = new Guildstone( guild );
|
||||
Guildstone stone = new Guildstone(guild);
|
||||
|
||||
stone.MoveToWorld( from.Location, from.Map );
|
||||
stone.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
guild.Guildstone = stone;
|
||||
}
|
||||
}
|
||||
}
|
||||
guild.Guildstone = stone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCancel( Mobile from )
|
||||
{
|
||||
from.SendLocalizedMessage( 501145 ); // Placement of guildstone cancelled.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
from.SendLocalizedMessage(501145); // Placement of guildstone cancelled.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,99 +3,99 @@ using Server.Multis;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GuildTeleporter : Item
|
||||
{
|
||||
private Item m_Stone;
|
||||
public class GuildTeleporter : Item
|
||||
{
|
||||
private Item m_Stone;
|
||||
|
||||
public override int LabelNumber => 1041054; // guildstone teleporter
|
||||
[Constructible]
|
||||
public GuildTeleporter() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GuildTeleporter() : this( null )
|
||||
{
|
||||
}
|
||||
public GuildTeleporter(Item stone) : base(0x1869)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
public GuildTeleporter( Item stone ) : base( 0x1869 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
m_Stone = stone;
|
||||
}
|
||||
|
||||
m_Stone = stone;
|
||||
}
|
||||
public GuildTeleporter(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public GuildTeleporter( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override int LabelNumber => 1041054; // guildstone teleporter
|
||||
|
||||
public override bool DisplayLootType => false;
|
||||
public override bool DisplayLootType => false;
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write( m_Stone );
|
||||
}
|
||||
writer.Write(m_Stone);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
LootType = LootType.Blessed;
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
LootType = LootType.Blessed;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Stone = reader.ReadItem();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Stone = reader.ReadItem();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Weight == 0.0 )
|
||||
Weight = 1.0;
|
||||
}
|
||||
if (Weight == 0.0)
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( Guild.NewGuildSystem )
|
||||
return;
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
Guildstone stone = m_Stone as Guildstone;
|
||||
Guildstone stone = m_Stone as Guildstone;
|
||||
|
||||
if ( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if ( stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this )
|
||||
{
|
||||
from.SendLocalizedMessage( 501197 ); // This teleporting object can not determine what guildstone to teleport
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( from );
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this)
|
||||
{
|
||||
from.SendLocalizedMessage(501197); // This teleporting object can not determine what guildstone to teleport
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if ( house == null )
|
||||
{
|
||||
from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
|
||||
}
|
||||
else if ( !house.IsOwner( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
|
||||
}
|
||||
else if ( house.FindGuildstone() != null )
|
||||
{
|
||||
from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stone.MoveToWorld( from.Location, from.Map );
|
||||
Delete();
|
||||
stone.Guild.Teleporter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,427 +1,446 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Guilds;
|
||||
using Server.Network;
|
||||
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 string m_GuildName;
|
||||
private string m_GuildAbbrev;
|
||||
|
||||
[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
|
||||
|
||||
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 )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
if ( Guild != null && !Guild.Disbanded )
|
||||
{
|
||||
m_GuildName = Guild.Name;
|
||||
m_GuildAbbrev = Guild.Abbreviation;
|
||||
}
|
||||
|
||||
writer.Write( (int)3 ); // version
|
||||
|
||||
writer.Write( m_BeforeChangeover );
|
||||
|
||||
writer.Write( m_GuildName );
|
||||
writer.Write( m_GuildAbbrev );
|
||||
|
||||
writer.Write( Guild );
|
||||
}
|
||||
|
||||
private bool m_BeforeChangeover;
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch( version )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
m_BeforeChangeover = reader.ReadBool();
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_GuildName = reader.ReadString();
|
||||
m_GuildAbbrev = reader.ReadString();
|
||||
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
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 != null && !house.Addons.Contains( this ) )
|
||||
{
|
||||
house.Addons.Add( this );
|
||||
m_BeforeChangeover = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( Guild != null && !Guild.Disbanded )
|
||||
{
|
||||
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 != null && !Guild.Disbanded )
|
||||
{
|
||||
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 != null && !Guild.Disbanded )
|
||||
Guild.Disband();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( Guild.NewGuildSystem )
|
||||
return;
|
||||
|
||||
if ( Guild == null || Guild.Disbanded )
|
||||
{
|
||||
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 != null && targetState.IsLeaving) )
|
||||
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
|
||||
|
||||
#region IChopable Members
|
||||
|
||||
public void OnChop( Mobile from )
|
||||
{
|
||||
if ( !Guild.NewGuildSystem )
|
||||
return;
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( this );
|
||||
|
||||
if ( ( house == null && m_BeforeChangeover ) || ( house != null && house.IsOwner( from ) && house.Addons.Contains( this ) ))
|
||||
{
|
||||
Effects.PlaySound( GetWorldLocation(), Map, 0x3B3 );
|
||||
from.SendLocalizedMessage( 500461 ); // You destroy the item.
|
||||
|
||||
Delete();
|
||||
|
||||
if ( house != null && house.Addons.Contains( this ) )
|
||||
house.Addons.Remove( this );
|
||||
|
||||
Item deed = Deed;
|
||||
|
||||
if ( deed != null )
|
||||
{
|
||||
from.AddToBackpack( deed );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Flippable( 0x14F0, 0x14EF )]
|
||||
public class GuildstoneDeed : Item
|
||||
{
|
||||
public override int LabelNumber => 1041233; // deed to a guildstone
|
||||
|
||||
private string m_GuildName;
|
||||
private string m_GuildAbbrev;
|
||||
|
||||
[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; }
|
||||
|
||||
[Constructible]
|
||||
public GuildstoneDeed() : this( null, null )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GuildstoneDeed( string guildName, string abbrev ) : this( null, guildName, abbrev )
|
||||
{
|
||||
}
|
||||
|
||||
public GuildstoneDeed( Guild g, string guildName, string abbrev ) : base( 0x14F0 )
|
||||
{
|
||||
Guild = g;
|
||||
m_GuildName = guildName;
|
||||
m_GuildAbbrev = abbrev;
|
||||
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public GuildstoneDeed( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
if ( Guild != null && !Guild.Disbanded )
|
||||
{
|
||||
m_GuildName = Guild.Name;
|
||||
m_GuildAbbrev = Guild.Abbreviation;
|
||||
}
|
||||
|
||||
writer.Write( (int)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 != null && !Guild.Disbanded )
|
||||
{
|
||||
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 != null && house.IsOwner( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062838 ); // Where would you like to place this decoration?
|
||||
from.BeginTarget( -1, true, Targeting.TargetFlags.None, Placement_OnTarget, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public void Placement_OnTarget( Mobile from, object targeted, object state )
|
||||
{
|
||||
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 != null && house.IsOwner( from ) )
|
||||
{
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
if (house == null && m_BeforeChangeover || house != null && house.IsOwner(from) && house.Addons.Contains(this))
|
||||
{
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
|
||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||
|
||||
Delete();
|
||||
|
||||
if (house != null && house.Addons.Contains(this))
|
||||
house.Addons.Remove(this);
|
||||
|
||||
Item deed = Deed;
|
||||
|
||||
if (deed != null) from.AddToBackpack(deed);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if (Guild != null && !Guild.Disbanded)
|
||||
{
|
||||
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 != null && !house.Addons.Contains(this))
|
||||
{
|
||||
house.Addons.Add(this);
|
||||
m_BeforeChangeover = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (Guild != null && !Guild.Disbanded)
|
||||
{
|
||||
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 != null && !Guild.Disbanded)
|
||||
{
|
||||
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 != null && !Guild.Disbanded)
|
||||
Guild.Disband();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Guild.NewGuildSystem)
|
||||
return;
|
||||
|
||||
if (Guild == null || Guild.Disbanded)
|
||||
{
|
||||
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 != null && targetState.IsLeaving)
|
||||
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;
|
||||
|
||||
[Constructible]
|
||||
public GuildstoneDeed() : this(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GuildstoneDeed(string guildName, string abbrev) : this(null, guildName, abbrev)
|
||||
{
|
||||
}
|
||||
|
||||
public GuildstoneDeed(Guild g, string guildName, string abbrev) : 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 != null && !Guild.Disbanded)
|
||||
{
|
||||
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 != null && !Guild.Disbanded)
|
||||
{
|
||||
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 != null && house.IsOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
|
||||
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502092); // You must be in your house to do this.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public void Placement_OnTarget(Mobile from, object targeted, object state)
|
||||
{
|
||||
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 != null && house.IsOwner(from))
|
||||
{
|
||||
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