Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
233
Scripts/Services/City Loyalty System/Items/Addons.cs
Normal file
233
Scripts/Services/City Loyalty System/Items/Addons.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
using Server;
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class InterchangeableAddonDeed : BaseAddonDeed
|
||||
{
|
||||
// This will need to be further implemented in any derived class
|
||||
public override BaseAddon Addon { get { return null; } }
|
||||
|
||||
public abstract int EastID { get; }
|
||||
public abstract int SouthID { get; }
|
||||
|
||||
public InterchangeableAddonDeed()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if ( IsChildOf( from.Backpack ) )
|
||||
from.Target = new InternalTarget( this );
|
||||
else
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
public InterchangeableAddonDeed Deed { get; set; }
|
||||
|
||||
public InternalTarget(InterchangeableAddonDeed deed) : base( -1, true, TargetFlags.None )
|
||||
{
|
||||
Deed = deed;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
IPoint3D p = targeted as IPoint3D;
|
||||
Map map = from.Map;
|
||||
|
||||
if(p == null || map == null || Deed.Deleted)
|
||||
return;
|
||||
|
||||
AddonFitResult result = AddonFitResult.Valid;
|
||||
|
||||
if(Deed.IsChildOf(from.Backpack))
|
||||
{
|
||||
BaseHouse house = null;
|
||||
|
||||
if ( !map.CanFit( p.X, p.Y, p.Z, 16, false, true, false ) )
|
||||
result = AddonFitResult.Blocked;
|
||||
else if ( !BaseAddon.CheckHouse( from, new Point3D(p), map, 16, ref house ) )
|
||||
result = AddonFitResult.NotInHouse;
|
||||
else
|
||||
{
|
||||
bool east = BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map);
|
||||
bool south = BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map);
|
||||
|
||||
if(!south && !east)
|
||||
result = AddonFitResult.NoWall;
|
||||
else if (south && east)
|
||||
from.SendGump(new AddonInterchangeableGump(from, Deed, p, map));
|
||||
else
|
||||
{
|
||||
BaseAddon addon = Deed.DeployAddon(east, p, map);
|
||||
house.Addons[addon] = from;
|
||||
}
|
||||
}
|
||||
|
||||
switch (result)
|
||||
{
|
||||
default: break;
|
||||
case AddonFitResult.Blocked: from.SendLocalizedMessage(500269); break; // You cannot build that there.
|
||||
case AddonFitResult.NotInHouse: from.SendLocalizedMessage(500274); break; // You can only place this in a house that you own!
|
||||
case AddonFitResult.NoWall: from.SendLocalizedMessage(500268); break; // This object needs to be mounted on something.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual BaseAddon DeployAddon(bool east, IPoint3D p, Map map)
|
||||
{
|
||||
BaseAddon addon = Addon;
|
||||
|
||||
if(addon != null)
|
||||
{
|
||||
if(addon is InterchangeableAddon)
|
||||
((InterchangeableAddon)addon).EastFacing = east;
|
||||
|
||||
Server.Spells.SpellHelper.GetSurfaceTop( ref p );
|
||||
|
||||
addon.MoveToWorld(new Point3D(p), map);
|
||||
|
||||
Delete();
|
||||
}
|
||||
|
||||
return addon;
|
||||
}
|
||||
|
||||
public InterchangeableAddonDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class InterchangeableAddon : BaseAddon
|
||||
{
|
||||
private bool _EastFacing;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool EastFacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EastFacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(Components.Count == 1)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
Components[0].ItemID = EastID;
|
||||
}
|
||||
else
|
||||
{
|
||||
Components[0].ItemID = SouthID;
|
||||
}
|
||||
}
|
||||
|
||||
_EastFacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int EastID { get; }
|
||||
public abstract int SouthID { get; }
|
||||
|
||||
// This will need to be further implemented in any derived class
|
||||
public override BaseAddonDeed Deed { get { return null; } }
|
||||
|
||||
public InterchangeableAddon(bool eastface = true, int loc = 0)
|
||||
{
|
||||
if(loc != 0)
|
||||
AddComponent(new LocalizedAddonComponent(eastface ? EastID : SouthID, loc), 0, 0, 0);
|
||||
else
|
||||
AddComponent(new AddonComponent(eastface ? EastID : SouthID), 0, 0, 0);
|
||||
}
|
||||
|
||||
public InterchangeableAddon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class AddonInterchangeableGump : Gump
|
||||
{
|
||||
public InterchangeableAddonDeed Deed { get; private set; }
|
||||
public IPoint3D Point { get; private set; }
|
||||
public Map Map { get; private set; }
|
||||
|
||||
public AddonInterchangeableGump(Mobile user, InterchangeableAddonDeed deed, IPoint3D p, Map map) : base(50, 50)
|
||||
{
|
||||
Deed = deed;
|
||||
Point = p;
|
||||
Map = map;
|
||||
|
||||
AddGumpLayout();
|
||||
}
|
||||
|
||||
public void AddGumpLayout()
|
||||
{
|
||||
AddBackground(0, 0, 300, 200, 2600);
|
||||
|
||||
AddHtmlLocalized(0, 15, 300, 16, 1152360, false, false); // <CENTER>Choose a banner:</CENTER>
|
||||
|
||||
Rectangle2D b = ItemBounds.Table[Deed.EastID];
|
||||
AddItem(70 - b.Width / 2 - b.X, 75 - b.Height / 2 - b.Y, Deed.EastID);
|
||||
|
||||
b = ItemBounds.Table[Deed.SouthID];
|
||||
AddItem(180 - b.Width / 2 - b.X, 75 - b.Height / 2 - b.Y, Deed.SouthID);
|
||||
|
||||
AddButton(75, 50, 2103, 2104, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(205, 50, 2103, 2104, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
if (!state.Mobile.InRange(Point, 3))
|
||||
{
|
||||
state.Mobile.SendLocalizedMessage(500251); // That location is too far away.
|
||||
}
|
||||
else if (info.ButtonID == 1)
|
||||
{
|
||||
Deed.DeployAddon(true, Point, Map);
|
||||
}
|
||||
else if (info.ButtonID == 2)
|
||||
{
|
||||
Deed.DeployAddon(false, Point, Map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
122
Scripts/Services/City Loyalty System/Items/Banners.cs
Normal file
122
Scripts/Services/City Loyalty System/Items/Banners.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.CityLoyalty
|
||||
{
|
||||
public class CityBanner : InterchangeableAddon
|
||||
{
|
||||
public override BaseAddonDeed Deed { get { return new CityBannerDeed(City); } }
|
||||
|
||||
public override bool ForceShowProperties { get { return true; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public City City { get; private set; }
|
||||
|
||||
public override int EastID { get { return SouthID + 9; } }
|
||||
public override int SouthID { get { return BannerInfo[City][0]; } }
|
||||
|
||||
[Constructable]
|
||||
public CityBanner(City city)
|
||||
: base(true, BannerInfo[city][1])
|
||||
{
|
||||
City = city;
|
||||
}
|
||||
|
||||
public static Dictionary<City, int[]> BannerInfo { get; set; }
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
BannerInfo = new Dictionary<City, int[]>();
|
||||
//ID Cliloc
|
||||
BannerInfo[City.Moonglow] = new int[] { 0x4B63, 1098171 };
|
||||
BannerInfo[City.Britain] = new int[] { 0x4B64, 1098172 };
|
||||
BannerInfo[City.Jhelom] = new int[] { 0x4B65, 1098173 };
|
||||
BannerInfo[City.Yew] = new int[] { 0x4B66, 1098174 };
|
||||
BannerInfo[City.Minoc] = new int[] { 0x4B67, 1098175 };
|
||||
BannerInfo[City.Trinsic] = new int[] { 0x4B62, 1098170 };
|
||||
BannerInfo[City.SkaraBrae] = new int[] { 0x4B6A, 1098178 };
|
||||
BannerInfo[City.NewMagincia] = new int[] { 0x4B69, 1098177 };
|
||||
BannerInfo[City.Vesper] = new int[] { 0x4B68, 1098176 };
|
||||
}
|
||||
|
||||
public CityBanner(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)City);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
City = (City)reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class CityBannerDeed : InterchangeableAddonDeed
|
||||
{
|
||||
public override BaseAddon Addon { get { return new CityBanner(City); } }
|
||||
|
||||
public override int LabelNumber { get { return CityBanner.BannerInfo[City][1]; } }
|
||||
|
||||
public override int EastID { get { return SouthID + 9; } }
|
||||
public override int SouthID { get { return CityBanner.BannerInfo[City][0]; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public City City { get; private set; }
|
||||
|
||||
[Constructable]
|
||||
public CityBannerDeed(City city)
|
||||
{
|
||||
City = city;
|
||||
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
CityLoyaltySystem sys = CityLoyaltySystem.GetCityInstance(this.City);
|
||||
|
||||
if (CityLoyaltySystem.HasCitizenship(from, this.City) && sys.GetLoyaltyRating(from) >= LoyaltyRating.Commended)
|
||||
{
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage(1152361, String.Format("#{0}", CityLoyaltySystem.GetCityLocalization(this.City))); // You are not sufficiently loyal to ~1_CITY~ to use this.
|
||||
}
|
||||
}
|
||||
|
||||
public CityBannerDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)City);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
City = (City)reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
95
Scripts/Services/City Loyalty System/Items/BoxOfRopes.cs
Normal file
95
Scripts/Services/City Loyalty System/Items/BoxOfRopes.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.CityLoyalty;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class BoxOfRopes : Container
|
||||
{
|
||||
public City City { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public CityLoyaltySystem CitySystem { get { return CityLoyaltySystem.GetCityInstance(City); } set { } }
|
||||
|
||||
public override int LabelNumber { get { return 1152262; } } // a box of ropes
|
||||
|
||||
public BoxOfRopes(City city) : base(3650)
|
||||
{
|
||||
Hue = 1944;
|
||||
Movable = false;
|
||||
|
||||
City = city;
|
||||
|
||||
if (CitySystem != null && CitySystem.Captain != null)
|
||||
CitySystem.Captain.Box = this;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (CityLoyaltySystem.Enabled && CityLoyaltySystem.IsSetup() && from.InRange(this.Location, 3))
|
||||
{
|
||||
if (_Cooldown == null || !_Cooldown.ContainsKey(from) || _Cooldown[from] < DateTime.UtcNow)
|
||||
{
|
||||
var rope = new GuardsmansRope();
|
||||
from.AddToBackpack(rope);
|
||||
|
||||
from.SendLocalizedMessage(1152263); // You take a rope from the chest. Use it to arrest rioters and subdued raiders.
|
||||
|
||||
if (_Cooldown == null)
|
||||
_Cooldown = new Dictionary<Mobile, DateTime>();
|
||||
|
||||
_Cooldown[from] = DateTime.UtcNow + TimeSpan.FromSeconds(60);
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage(1152264); // You must wait a moment before taking another rope.
|
||||
}
|
||||
else
|
||||
from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045, from.NetState); // I can't reach that.
|
||||
}
|
||||
|
||||
public static Dictionary<Mobile, DateTime> _Cooldown { get; set; }
|
||||
|
||||
public static void Defrag()
|
||||
{
|
||||
if (_Cooldown == null)
|
||||
return;
|
||||
|
||||
List<Mobile> list = new List<Mobile>(_Cooldown.Keys);
|
||||
|
||||
foreach (Mobile m in list.Where(mob => _Cooldown[mob] < DateTime.UtcNow))
|
||||
_Cooldown.Remove(m);
|
||||
|
||||
list.Clear();
|
||||
list.TrimExcess();
|
||||
}
|
||||
|
||||
public BoxOfRopes(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)City);
|
||||
|
||||
Defrag();
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
City = (City)reader.ReadInt();
|
||||
|
||||
if (CitySystem != null && CitySystem.Captain != null)
|
||||
CitySystem.Captain.Box = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
184
Scripts/Services/City Loyalty System/Items/CityMessageBoard.cs
Normal file
184
Scripts/Services/City Loyalty System/Items/CityMessageBoard.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.CityLoyalty;
|
||||
using System.Linq;
|
||||
using Server.Prompts;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class CityMessageBoard : BasePlayerBB
|
||||
{
|
||||
public City City { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public CityLoyaltySystem CitySystem { get { return CityLoyaltySystem.GetCityInstance(City); } set { } }
|
||||
|
||||
public override int LabelNumber { get { return 1027774; } } // bulletin board
|
||||
public override bool Public { get { return true; } }
|
||||
public override bool ForceShowProperties { get { return true; } }
|
||||
|
||||
[Constructable]
|
||||
public CityMessageBoard(City city, int id) : base(id)
|
||||
{
|
||||
Movable = false;
|
||||
City = city;
|
||||
}
|
||||
|
||||
public override bool CanPostGreeting(Server.Multis.BaseHouse house, Mobile m)
|
||||
{
|
||||
var sys = CitySystem;
|
||||
|
||||
return sys != null && (m.AccessLevel >= AccessLevel.GameMaster || sys.Governor == m);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!CityLoyaltySystem.Enabled || CitySystem == null)
|
||||
return;
|
||||
|
||||
if (CitySystem.IsCitizen(from, true))
|
||||
{
|
||||
if (from.InRange(this.Location, 3))
|
||||
{
|
||||
from.SendGump(new PlayerBBGump(from, null, this, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045, from.NetState);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1154275); // Only Citizens of this City may use this.
|
||||
}
|
||||
}
|
||||
|
||||
/*public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (!CityLoyaltySystem.Enabled || CitySystem == null || !CitySystem.IsGovernor(from))
|
||||
return;
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154912, m => // Set New Announcement
|
||||
{
|
||||
if (m.Prompt != null)
|
||||
m.SendLocalizedMessage(1079166); // You already have a text entry request pending.
|
||||
else if (CitySystem.Herald != null)
|
||||
{
|
||||
m.SendMessage("Enter message board headline:");
|
||||
m.BeginPrompt(
|
||||
(mob, text) =>
|
||||
{
|
||||
if (Server.Guilds.BaseGuildGump.CheckProfanity(text, 150))
|
||||
{
|
||||
CitySystem.Herald.Announcement = text;
|
||||
}
|
||||
else
|
||||
mob.SendLocalizedMessage(1112587); // Invalid entry.
|
||||
},
|
||||
(mob, text) =>
|
||||
{
|
||||
mob.SendMessage("Herald message unchanged.");
|
||||
});
|
||||
}
|
||||
}, enabled: CitySystem.Herald != null));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154913, m => // Set Headline
|
||||
{
|
||||
if (m.Prompt != null)
|
||||
m.SendLocalizedMessage(1079166); // You already have a text entry request pending.
|
||||
else
|
||||
{
|
||||
m.SendMessage("Enter message board headline:");
|
||||
m.BeginPrompt(
|
||||
(mob, text) =>
|
||||
{
|
||||
if (Server.Guilds.BaseGuildGump.CheckProfanity(text, 150))
|
||||
{
|
||||
if (String.IsNullOrEmpty(text))
|
||||
{
|
||||
CitySystem.Headline = null;
|
||||
CitySystem.Body = null;
|
||||
CitySystem.PostedOn = DateTime.Now;
|
||||
mob.SendMessage("{0} message board headline removed!", CitySystem.Definition.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
CitySystem.Headline = text;
|
||||
CitySystem.PostedOn = DateTime.Now;
|
||||
mob.SendMessage("{0} message board headline changed!", CitySystem.Definition.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
mob.SendLocalizedMessage(1112587); // Invalid entry.
|
||||
},
|
||||
(mob, text) =>
|
||||
{
|
||||
mob.SendMessage("Message headline unchanged.");
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154914, m => // Set Body
|
||||
{
|
||||
if (m.Prompt != null)
|
||||
m.SendLocalizedMessage(1079166); // You already have a text entry request pending.
|
||||
else
|
||||
{
|
||||
m.SendMessage("Enter message board body:");
|
||||
m.BeginPrompt(
|
||||
(mob, text) =>
|
||||
{
|
||||
if (Server.Guilds.BaseGuildGump.CheckProfanity(text, 150))
|
||||
{
|
||||
if (String.IsNullOrEmpty(text))
|
||||
{
|
||||
CitySystem.Body = null;
|
||||
CitySystem.PostedOn = DateTime.Now;
|
||||
mob.SendMessage("{0} message board body removed!", CitySystem.Definition.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
CitySystem.Body = text;
|
||||
CitySystem.PostedOn = DateTime.Now;
|
||||
mob.SendMessage("{0} message board body removed!", CitySystem.Definition.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
mob.SendLocalizedMessage(1112587); // Invalid entry.
|
||||
},
|
||||
(mob, text) =>
|
||||
{
|
||||
mob.SendMessage("Message body unchanged.");
|
||||
});
|
||||
}
|
||||
}));
|
||||
}*/
|
||||
|
||||
public CityMessageBoard(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)City);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
City = (City)reader.ReadInt();
|
||||
CitySystem.Board = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
260
Scripts/Services/City Loyalty System/Items/CityStone.cs
Normal file
260
Scripts/Services/City Loyalty System/Items/CityStone.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Server.ContextMenus;
|
||||
using Server.Targeting;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.CityLoyalty
|
||||
{
|
||||
public class CityStone : Item
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public CityLoyaltySystem City { get; set; }
|
||||
|
||||
public List<BallotBox> Boxes { get; set; }
|
||||
|
||||
public CityStone(CityLoyaltySystem city) : base(0xED4)
|
||||
{
|
||||
City = city;
|
||||
Movable = false;
|
||||
|
||||
City.Stone = this;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (CityLoyaltySystem.Enabled && CityLoyaltySystem.IsSetup() && from is PlayerMobile && from.InRange(from.Location, 3))
|
||||
{
|
||||
if (from is PlayerMobile && City != null && City.IsCitizen(from))
|
||||
BaseGump.SendGump(new CityStoneGump(from as PlayerMobile, City));
|
||||
else
|
||||
from.SendLocalizedMessage(1153888); // Only Citizens of this City may use the Election Stone.
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddNameProperty(ObjectPropertyList list)
|
||||
{
|
||||
if(City != null)
|
||||
list.Add(1153887, String.Format("#{0}", CityLoyaltySystem.GetCityLocalization(City.City)));
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (!CityLoyaltySystem.Enabled || City == null)
|
||||
return;
|
||||
|
||||
if (City.GovernorElect != null)
|
||||
list.Add(1154066, City.GovernorElect.Name); // Governor-Elect: ~1_NAME~
|
||||
else
|
||||
list.Add(1154067, City.PendingGovernor ? "#1154102" : City.Governor != null ? City.Governor.Name : "#1154072"); // Governor: ~1_NAME~
|
||||
|
||||
if (City.Election != null)
|
||||
{
|
||||
DateTime dt;
|
||||
|
||||
if (City.Election.CanNominate(out dt))
|
||||
list.Add(1155756, dt.ToShortDateString()); // Nomination period ends after: ~1_DATE~
|
||||
|
||||
if (City.Election.CanVote(out dt))
|
||||
list.Add(1155757, dt.ToShortDateString()); // Voting Period Ends After: ~1_DATE~
|
||||
}
|
||||
|
||||
list.Add(1154023, City.Treasury > 0 ? City.Treasury.ToString("N0", CultureInfo.GetCultureInfo("en-US")) : City.Treasury.ToString()); // City Treasury Balance: ~1_AMT~
|
||||
list.Add(1154059, String.Format("#{0}", City.ActiveTradeDeal == TradeDeal.None ? 1011051 : (int)City.ActiveTradeDeal - 12)); // Current Trade Deal: ~1_GUILD~
|
||||
list.Add(1154907, City.CompletedTrades.ToString(CultureInfo.GetCultureInfo("en-US"))); // Trade Orders Delivered: ~1_val~
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (!CityLoyaltySystem.Enabled || City == null)
|
||||
return;
|
||||
|
||||
if (!City.IsCitizen(from))
|
||||
{
|
||||
if (City.Herald != null)
|
||||
City.Herald.SayTo(from, 1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
|
||||
else
|
||||
from.SendLocalizedMessage(1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154018, m => // Grant Citizen Title
|
||||
{
|
||||
if(City.IsGovernor(m))
|
||||
{
|
||||
m.SendLocalizedMessage(1154027); // Which Citizen do you wish to bestow a title?
|
||||
m.BeginTarget(10, false, TargetFlags.None, (mob, targeted) =>
|
||||
{
|
||||
PlayerMobile pm = targeted as PlayerMobile;
|
||||
|
||||
if (pm != null)
|
||||
{
|
||||
if (City.IsCitizen(pm))
|
||||
{
|
||||
BaseGump.SendGump(new PlayerTitleGump(mob as PlayerMobile, pm, City));
|
||||
}
|
||||
else
|
||||
mob.SendLocalizedMessage(1154029); // You may only bestow a title on citizens of this city!
|
||||
}
|
||||
else
|
||||
mob.SendLocalizedMessage(1154028); // You can only bestow a title on a player!
|
||||
});
|
||||
}
|
||||
}, enabled: City.IsGovernor(from)));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154031, m => // Open Trade Deal
|
||||
{
|
||||
if (City.IsGovernor(m))
|
||||
{
|
||||
BaseGump.SendGump(new ChooseTradeDealGump(m as PlayerMobile, City));
|
||||
}
|
||||
}, enabled: City.IsGovernor(from)));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154277, m => // Open Inventory WTF is this?
|
||||
{
|
||||
if (m is PlayerMobile && City.IsGovernor(m))
|
||||
{
|
||||
BaseGump.SendGump(new OpenInventoryGump((PlayerMobile)m, City));
|
||||
}
|
||||
}, enabled: City.IsGovernor(from)));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154278, m => // Place Ballot Box
|
||||
{
|
||||
if (City.IsGovernor(m))
|
||||
{
|
||||
if (Boxes != null && Boxes.Count >= CityLoyaltySystem.MaxBallotBoxes)
|
||||
{
|
||||
m.SendMessage("You have reached the maximum amount of ballot boxes in your city.");
|
||||
return;
|
||||
}
|
||||
|
||||
m.SendMessage("Where would you like to place a ballot box?");
|
||||
m.BeginTarget(3, true, TargetFlags.None, (mob, targeted) =>
|
||||
{
|
||||
if (targeted is IPoint3D)
|
||||
{
|
||||
IPoint3D p = targeted as IPoint3D;
|
||||
Server.Spells.SpellHelper.GetSurfaceTop(ref p);
|
||||
BallotBox box = new BallotBox();
|
||||
|
||||
if (CheckLocation(m, box, p))
|
||||
{
|
||||
box.Owner = m;
|
||||
box.Movable = false;
|
||||
|
||||
if (Boxes == null)
|
||||
Boxes = new List<BallotBox>();
|
||||
|
||||
Boxes.Add(box);
|
||||
box.MoveToWorld(new Point3D(p), this.Map);
|
||||
|
||||
m.SendMessage("{0} of {1} ballot boxes placed.", Boxes.Count.ToString(), CityLoyaltySystem.MaxBallotBoxes.ToString());
|
||||
}
|
||||
else
|
||||
box.Delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, enabled: City.IsGovernor(from)));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154060, m => // Utilize Trade Deal
|
||||
{
|
||||
City.TryUtilizeTradeDeal(from);
|
||||
}, enabled: City.ActiveTradeDeal != TradeDeal.None));
|
||||
|
||||
CityLoyaltyEntry entry = City.GetPlayerEntry<CityLoyaltyEntry>(from);
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154019, m => // Remove City Title
|
||||
{
|
||||
if (entry != null && entry.CustomTitle != null)
|
||||
{
|
||||
entry.CustomTitle = null;
|
||||
|
||||
if(m is PlayerMobile)
|
||||
((PlayerMobile)m).RemoveRewardTitle(1154017, true);
|
||||
|
||||
m.SendMessage("City Title removed.");
|
||||
}
|
||||
}, enabled: entry != null && entry.CustomTitle != null));
|
||||
|
||||
list.Add(new SimpleContextMenuEntry(from, 1154068, m => // Accept Office
|
||||
{
|
||||
if (m is PlayerMobile && m == City.GovernorElect && City.Governor == null)
|
||||
{
|
||||
BaseGump.SendGump(new AcceptOfficeGump(m as PlayerMobile, City));
|
||||
}
|
||||
}, enabled: City.GovernorElect == from && City.Governor == null && City.GetLoyaltyRating(from) >= LoyaltyRating.Unknown));
|
||||
}
|
||||
|
||||
public bool CheckLocation(Mobile m, BallotBox box, IPoint3D p)
|
||||
{
|
||||
Region r = Region.Find(new Point3D(p), this.Map);
|
||||
|
||||
if (!r.IsPartOf(City.Definition.Region))
|
||||
{
|
||||
m.SendMessage("You can only place a ballot box within the {0} city limits!", City.Definition.Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!box.DropToWorld(new Point3D(p), this.Map))
|
||||
{
|
||||
m.SendMessage("You cannot place a ballot box there!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public CityStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)City.City);
|
||||
|
||||
writer.Write(Boxes == null ? 0 : Boxes.Count);
|
||||
if (Boxes != null)
|
||||
{
|
||||
Boxes.ForEach(b => writer.Write(b));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
City = CityLoyaltySystem.GetCityInstance((City)reader.ReadInt());
|
||||
|
||||
if(City != null)
|
||||
City.Stone = this;
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
BallotBox box = reader.ReadItem() as BallotBox;
|
||||
|
||||
if (box != null)
|
||||
{
|
||||
if (Boxes == null)
|
||||
Boxes = new List<BallotBox>();
|
||||
|
||||
Boxes.Add(box);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Scripts/Services/City Loyalty System/Items/GuardsmansRope.cs
Normal file
70
Scripts/Services/City Loyalty System/Items/GuardsmansRope.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Engines.CityLoyalty;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GuardsmansRope : BaseDecayingItem
|
||||
{
|
||||
public override int LabelNumber { get { return 1152261; } } // guardsman's rope
|
||||
public override int Lifespan { get { return 3600; } }
|
||||
|
||||
public GuardsmansRope() : base(0x14F8)
|
||||
{
|
||||
Hue = 1944;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1152244); // What would you like to arrest?
|
||||
from.BeginTarget(10, false, TargetFlags.None, (m, targeted) =>
|
||||
{
|
||||
if (targeted is Raider)
|
||||
{
|
||||
Raider raider = targeted as Raider;
|
||||
|
||||
if (raider.InRange(m.Location, 1))
|
||||
{
|
||||
if (raider.TryArrest(from))
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
m.SendLocalizedMessage(1152242); // You cannot reach that.
|
||||
}
|
||||
else
|
||||
m.SendLocalizedMessage(1152243); // You cannot arrest that.
|
||||
});
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage(1116249); // That must be in your backpack for you to use it.
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public GuardsmansRope(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user