Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,93 @@
using Server.Mobiles;
using Server.Multis;
using Server.Network;
namespace Server.Items
{
public class BarkeepContract : Item
{
[Constructible]
public BarkeepContract() : base(0x14F0)
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public BarkeepContract(Serial serial) : base(serial)
{
}
public override string DefaultName => "a barkeep contract";
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();
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendLocalizedMessage(503248); // Your godly powers allow you to place this vendor whereever you wish.
Mobile v = new PlayerBarkeeper(from, BaseHouse.FindHouseAt(from));
v.Direction = from.Direction & Direction.Mask;
v.MoveToWorld(from.Location, from.Map);
Delete();
}
else
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house == null || !house.IsOwner(from))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, false,
"You are not the full owner of this house.");
}
else if (!house.CanPlaceNewBarkeep())
{
from.SendLocalizedMessage(
1062490); // That action would exceed the maximum number of barkeeps for this house.
}
else
{
BaseHouse.IsThereVendor(from.Location, from.Map, out bool vendor, out bool contract);
if (vendor)
{
from.SendLocalizedMessage(1062677); // You cannot place a vendor or barkeep at this location.
}
else if (contract)
{
from.SendLocalizedMessage(
1062678); // You cannot place a vendor or barkeep on top of a rental contract!
}
else
{
Mobile v = new PlayerBarkeeper(from, house);
v.Direction = from.Direction & Direction.Mask;
v.MoveToWorld(from.Location, from.Map);
Delete();
}
}
}
}
}
}

View file

@ -0,0 +1,100 @@
using Server.Targeting;
namespace Server.Items
{
public class ClothingBlessTarget : Target // Create our targeting class (which we derive from the base target class)
{
private ClothingBlessDeed m_Deed;
public ClothingBlessTarget(ClothingBlessDeed deed) : base(1, false, TargetFlags.None)
{
m_Deed = deed;
}
protected override void OnTarget(Mobile from, object target) // Override the protected OnTarget() for our feature
{
if (m_Deed.Deleted || m_Deed.RootParent != from)
return;
if (target is BaseClothing item)
{
if ((item as IArcaneEquip)?.IsArcane == true)
{
from.SendLocalizedMessage(1005019); // This bless deed is for Clothes only.
return;
}
if (item.LootType == LootType.Blessed || item.BlessedFor == from || Mobile.InsuranceEnabled && item.Insured
) // Check if its already newbied (blessed)
{
from.SendLocalizedMessage(1045113); // That item is already blessed
}
else if (item.LootType != LootType.Regular)
{
from.SendLocalizedMessage(1045114); // You can not bless that item
}
else if (!item.CanBeBlessed || item.RootParent != from)
{
from.SendLocalizedMessage(500509); // You cannot bless that object
}
else
{
item.LootType = LootType.Blessed;
from.SendLocalizedMessage(1010026); // You bless the item....
m_Deed.Delete(); // Delete the bless deed
}
}
else
{
from.SendLocalizedMessage(500509); // You cannot bless that object
}
}
}
public class ClothingBlessDeed : Item // Create the item class which is derived from the base item class
{
[Constructible]
public ClothingBlessDeed() : base(0x14F0)
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public ClothingBlessDeed(Serial serial) : base(serial)
{
}
public override string DefaultName => "a clothing bless deed";
public override bool DisplayLootType => false;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
LootType = LootType.Blessed;
int version = reader.ReadInt();
}
public override void OnDoubleClick(Mobile from) // Override double click of the deed to call our target
{
if (!IsChildOf(from.Backpack)) // Make sure its in their pack
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else
{
from.SendLocalizedMessage(1005018); // What would you like to bless? (Clothes Only)
from.Target = new ClothingBlessTarget(this); // Call our target
}
}
}
}

View file

@ -0,0 +1,243 @@
using Server.Targeting;
namespace Server.Items
{
public interface ICommodity /* added IsDeedable prop so expansion-based deedables can determine true/false */
{
int DescriptionNumber{ get; }
bool IsDeedable{ get; }
}
public class CommodityDeed : Item
{
public CommodityDeed(Item commodity = null) : base(0x14F0)
{
Weight = 1.0;
Hue = 0x47;
Commodity = commodity;
LootType = LootType.Blessed;
}
public CommodityDeed(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Item Commodity{ get; private set; }
public override int LabelNumber => Commodity == null ? 1047016 : 1047017;
public bool SetCommodity(Item item)
{
InvalidateProperties();
if (Commodity == null && (item as ICommodity)?.IsDeedable == true)
{
Commodity = item;
Commodity.Internalize();
InvalidateProperties();
return true;
}
return false;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write(Commodity);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
Commodity = reader.ReadItem();
switch (version)
{
case 0:
{
if (Commodity != null) Hue = 0x592;
break;
}
}
}
public override void OnDelete()
{
Commodity?.Delete();
base.OnDelete();
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Commodity != null)
{
string args;
if (Commodity.Name == null)
args =
$"#{(Commodity is ICommodity commodity ? commodity.DescriptionNumber : Commodity.LabelNumber)}\t{Commodity.Amount}";
else
args = $"{Commodity.Name}\t{Commodity.Amount}";
list.Add(1060658, args); // ~1_val~: ~2_val~
}
else
{
list.Add(1060748); // unfilled
}
}
public override void OnSingleClick(Mobile from)
{
base.OnSingleClick(from);
if (Commodity != null)
{
string args;
if (Commodity.Name == null)
args =
$"#{(Commodity is ICommodity commodity ? commodity.DescriptionNumber : Commodity.LabelNumber)}\t{Commodity.Amount}";
else
args = $"{Commodity.Name}\t{Commodity.Amount}";
LabelTo(from, 1060658, args); // ~1_val~: ~2_val~
}
}
public override void OnDoubleClick(Mobile from)
{
int number;
BankBox box = from.FindBankNoCreate();
CommodityDeedBox cox = CommodityDeedBox.Find(this);
// Veteran Rewards mods
if (Commodity != null)
{
if (box != null && IsChildOf(box))
{
number = 1047031; // The commodity has been redeemed.
box.DropItem(Commodity);
Commodity = null;
Delete();
}
else if (cox != null)
{
if (cox.IsSecure)
{
number = 1047031; // The commodity has been redeemed.
cox.DropItem(Commodity);
Commodity = null;
Delete();
}
else
{
number = 1080525; // The commodity deed box must be secured before you can use it.
}
}
else
{
if (Core.ML)
number = 1080526; // That must be in your bank box or commodity deed box to use it.
else
number = 1047024; // To claim the resources ....
}
}
else if (cox?.IsSecure == false)
{
number = 1080525; // The commodity deed box must be secured before you can use it.
}
else if ((box == null || !IsChildOf(box)) && cox == null)
{
if (Core.ML)
number = 1080526; // That must be in your bank box or commodity deed box to use it.
else
number = 1047026; // That must be in your bank box to use it.
}
else
{
number = 1047029; // Target the commodity to fill this deed with.
from.Target = new InternalTarget(this);
}
from.SendLocalizedMessage(number);
}
private class InternalTarget : Target
{
private CommodityDeed m_Deed;
public InternalTarget(CommodityDeed deed) : base(3, false, TargetFlags.None)
{
m_Deed = deed;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (m_Deed.Deleted)
return;
int number;
if (m_Deed.Commodity != null)
{
number = 1047028; // The commodity deed has already been filled.
}
else if (targeted is Item item)
{
BankBox box = from.FindBankNoCreate();
CommodityDeedBox cox = CommodityDeedBox.Find(m_Deed);
// Veteran Rewards mods
if (box != null && m_Deed.IsChildOf(box) && item.IsChildOf(box) ||
cox?.IsSecure != true && item.IsChildOf(cox))
{
if (m_Deed.SetCommodity(item))
{
m_Deed.Hue = 0x592;
number = 1047030; // The commodity deed has been filled.
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
}
else if (Core.ML)
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
from.SendLocalizedMessage(number);
}
}
}
}

View file

@ -0,0 +1,175 @@
using System;
using Server.Engines.Craft;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Items
{
[TypeAlias("Server.Items.DragonBarding")]
public class DragonBardingDeed : Item, ICraftable
{
private Mobile m_Crafter;
private bool m_Exceptional;
private CraftResource m_Resource;
public DragonBardingDeed() : base(0x14F0)
{
Weight = 1.0;
}
public DragonBardingDeed(Serial serial) : base(serial)
{
}
public override int LabelNumber => m_Exceptional ? 1053181 : 1053012; // dragon barding deed
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Crafter
{
get => m_Crafter;
set
{
m_Crafter = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Exceptional
{
get => m_Exceptional;
set
{
m_Exceptional = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => m_Resource;
set
{
m_Resource = value;
Hue = CraftResources.GetHue(value);
InvalidateProperties();
}
}
#region ICraftable Members
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue)
{
Exceptional = quality >= 2;
if (makersMark)
Crafter = from;
Type resourceType = typeRes;
if (resourceType == null)
resourceType = craftItem.Resources.GetAt(0).ItemType;
Resource = CraftResources.GetFromType(resourceType);
CraftContext context = craftSystem.GetContext(from);
if (context?.DoNotColor == true)
Hue = 0;
return quality;
}
#endregion
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (m_Exceptional && m_Crafter != null)
list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~
}
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack))
{
from.BeginTarget(6, false, TargetFlags.None, OnTarget);
from.SendLocalizedMessage(1053024); // Select the swamp dragon you wish to place the barding on.
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
public virtual void OnTarget(Mobile from, object obj)
{
if (Deleted)
return;
if (!(obj is SwampDragon pet) || pet.HasBarding)
{
from.SendLocalizedMessage(1053025); // That is not an unarmored swamp dragon.
}
else if (!pet.Controlled || pet.ControlMaster != from)
{
from.SendLocalizedMessage(1053026); // You can only put barding on a tamed swamp dragon that you own.
}
else if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1060640); // The item must be in your backpack to use it.
}
else
{
pet.BardingExceptional = Exceptional;
pet.BardingCrafter = Crafter;
pet.BardingHP = pet.BardingMaxHP;
pet.BardingResource = Resource;
pet.HasBarding = true;
pet.Hue = Hue;
Delete();
from.SendLocalizedMessage(
1053027); // You place the barding on your swamp dragon. Use a bladed item on your dragon to remove the armor.
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write(m_Exceptional);
writer.Write(m_Crafter);
writer.Write((int)m_Resource);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
case 0:
{
m_Exceptional = reader.ReadBool();
m_Crafter = reader.ReadMobile();
if (version < 1)
reader.ReadInt();
m_Resource = (CraftResource)reader.ReadInt();
break;
}
}
}
}
}

View file

@ -0,0 +1,150 @@
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Items
{
public class HairRestylingDeed : Item
{
[Constructible]
public HairRestylingDeed() : base(0x14F0)
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public HairRestylingDeed(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1041061; // a coupon for a free hair restyling
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();
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
from.SendLocalizedMessage(1042001); // That must be in your pack...
else
from.SendGump(new InternalGump(from, this));
}
private class InternalGump : Gump
{
private int[][] ElvenArray =
{
new[] { 0 },
new[] { 1011064, 1011064, 0, 0, 0, 0 }, // bald
new[] { 1074386, 1074386, 0x2fc0, 0x2fc0, 0xedf5, 0xc6e5 }, // long feather
new[] { 1074387, 1074387, 0x2fc1, 0x2fc1, 0xedf6, 0xc6e6 }, // short
new[] { 1074388, 1074388, 0x2fc2, 0x2fc2, 0xedf7, 0xc6e7 }, // mullet
new[] { 1074391, 1074391, 0x2fce, 0x2fce, 0xeddc, 0xc6cc }, // knob
new[] { 1074392, 1074392, 0x2fcf, 0x2fcf, 0xeddd, 0xc6cd }, // braided
new[] { 1074394, 1074394, 0x2fd1, 0x2fd1, 0xeddf, 0xc6cf }, // spiked
new[] { 1074389, 1074385, 0x2fcc, 0x2fbf, 0xedda, 0xc6e4 }, // flower, mid-long
new[] { 1074393, 1074390, 0x2fd0, 0x2fcd, 0xedde, 0xc6cb } // buns, long
};
/*
racial arrays are: cliloc_F, cliloc_M, ItemID_F, ItemID_M, gump_img_F, gump_img_M
*/
private int[][] HumanArray = /* why on earth cant these utilies be consistent with hex/dec */
{
new[] { 0 },
new[] { 1011064, 1011064, 0, 0, 0, 0 }, // bald
new[] { 1011052, 1011052, 0x203B, 0x203B, 0xed1c, 0xC60C }, // Short
new[] { 1011053, 1011053, 0x203C, 0x203C, 0xed1d, 0xc60d }, // Long
new[] { 1011054, 1011054, 0x203D, 0x203D, 0xed1e, 0xc60e }, // Ponytail
new[] { 1011055, 1011055, 0x2044, 0x2044, 0xed27, 0xC60F }, // Mohawk
new[] { 1011047, 1011047, 0x2045, 0x2045, 0xED26, 0xED26 }, // Pageboy
new[] { 1074393, 1011048, 0x2046, 0x2048, 0xed28, 0xEDE5 }, // Buns, Receding
new[] { 1011049, 1011049, 0x2049, 0x2049, 0xede6, 0xede6 }, // 2-tails
new[] { 1011050, 1011050, 0x204A, 0x204A, 0xED29, 0xED29 }, // Topknot
new[] { 1011396, 1011396, 0x2047, 0x2047, 0xed25, 0xc618 } // Curly
};
/*
gump data: bgX, bgY, htmlX, htmlY, imgX, imgY, butX, butY
*/
private int[][] LayoutArray =
{
new[] { 0 }, /* padding: its more efficient than code to ++ the index/buttonid */
new[] { 425, 280, 342, 295, 000, 000, 310, 292 },
new[] { 235, 060, 150, 075, 168, 020, 118, 073 },
new[] { 235, 115, 150, 130, 168, 070, 118, 128 },
new[] { 235, 170, 150, 185, 168, 130, 118, 183 },
new[] { 235, 225, 150, 240, 168, 185, 118, 238 },
new[] { 425, 060, 342, 075, 358, 018, 310, 073 },
new[] { 425, 115, 342, 130, 358, 075, 310, 128 },
new[] { 425, 170, 342, 185, 358, 125, 310, 183 },
new[] { 425, 225, 342, 240, 358, 185, 310, 238 },
new[] { 235, 280, 150, 295, 168, 245, 118, 292 } // slot 10, Curly - N/A for elfs.
};
private HairRestylingDeed m_Deed;
private Mobile m_From;
public InternalGump(Mobile from, HairRestylingDeed deed) : base(50, 50)
{
m_From = from;
m_Deed = deed;
from.CloseGump<InternalGump>();
AddBackground(100, 10, 400, 385, 0xA28);
AddHtmlLocalized(100, 25, 400, 35, 1013008);
AddButton(175, 340, 0xFA5, 0xFA7, 0x0); // CANCEL
AddHtmlLocalized(210, 342, 90, 35, 1011012); // <CENTER>HAIRSTYLE SELECTION MENU</center>
int[][] RacialData = from.Race == Race.Human ? HumanArray : ElvenArray;
for (int i = 1; i < RacialData.Length; i++)
{
AddHtmlLocalized(LayoutArray[i][2], LayoutArray[i][3], i == 1 ? 125 : 80, i == 1 ? 70 : 35,
m_From.Female ? RacialData[i][0] : RacialData[i][1]);
if (LayoutArray[i][4] != 0)
{
AddBackground(LayoutArray[i][0], LayoutArray[i][1], 50, 50, 0xA3C);
AddImage(LayoutArray[i][4], LayoutArray[i][5], m_From.Female ? RacialData[i][4] : RacialData[i][5]);
}
AddButton(LayoutArray[i][6], LayoutArray[i][7], 0xFA5, 0xFA7, i);
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_From?.Alive != true)
return;
if (m_Deed.Deleted)
return;
if (info.ButtonID < 1 || info.ButtonID > 10)
return;
int[][] RacialData = m_From.Race == Race.Human ? HumanArray : ElvenArray;
if (m_From is PlayerMobile pm)
{
pm.SetHairMods(-1, -1); // clear any hairmods (disguise kit, incognito)
pm.HairItemID = pm.Female ? RacialData[info.ButtonID][2] : RacialData[info.ButtonID][3];
m_Deed.Delete();
}
}
}
}
}

View file

@ -0,0 +1,160 @@
using System;
using Server.Gumps;
using Server.Multis;
using Server.Network;
using Server.Targeting;
namespace Server.Items
{
public class HolidayTreeDeed : Item
{
[Constructible]
public HolidayTreeDeed() : base(0x14F0)
{
Hue = 0x488;
Weight = 1.0;
LootType = LootType.Blessed;
}
public HolidayTreeDeed(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1041116; // a deed for a holiday tree
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();
LootType = LootType.Blessed;
}
public bool ValidatePlacement(Mobile from, Point3D loc)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
return true;
if (!from.InRange(GetWorldLocation(), 1))
{
from.SendLocalizedMessage(500446); // That is too far away.
return false;
}
if (DateTime.UtcNow.Month != 12)
{
from.SendLocalizedMessage(
1005700); // You will have to wait till next December to put your tree back up for display.
return false;
}
Map map = from.Map;
if (map == null)
return false;
BaseHouse house = BaseHouse.FindHouseAt(loc, map, 20);
if (house == null || !house.IsFriend(from))
{
from.SendLocalizedMessage(1005701); // The holiday tree can only be placed in your house.
return false;
}
if (!map.CanFit(loc, 20))
{
from.SendLocalizedMessage(500269); // You cannot build that there.
return false;
}
return true;
}
public void BeginPlace(Mobile from, HolidayTreeType type)
{
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, type);
}
public void Placement_OnTarget(Mobile from, object targeted, HolidayTreeType type)
{
if (!(targeted is IPoint3D p))
return;
Point3D loc = new Point3D(p);
if (p is StaticTarget target)
loc.Z -= TileData.ItemTable[target.ItemID]
.CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here.
* A side affect is that you can only place on floors (due to the CanFit call).
* That functionality may be desired. And so, it's included in this script.
*/
if (ValidatePlacement(from, loc))
EndPlace(from, type, loc);
}
public void EndPlace(Mobile from, HolidayTreeType type, Point3D loc)
{
Delete();
HolidayTree tree = new HolidayTree(from, type, loc);
BaseHouse.FindHouseAt(tree)?.Addons.Add(tree);
}
public override void OnDoubleClick(Mobile from)
{
from.CloseGump<HolidayTreeChoiceGump>();
from.SendGump(new HolidayTreeChoiceGump(from, this));
}
}
public class HolidayTreeChoiceGump : Gump
{
private HolidayTreeDeed m_Deed;
private Mobile m_From;
public HolidayTreeChoiceGump(Mobile from, HolidayTreeDeed deed) : base(200, 200)
{
m_From = from;
m_Deed = deed;
AddPage(0);
AddBackground(0, 0, 220, 120, 5054);
AddBackground(10, 10, 200, 100, 3000);
AddButton(20, 35, 4005, 4007, 1);
AddHtmlLocalized(55, 35, 145, 25, 1018322); // Classic
AddButton(20, 65, 4005, 4007, 2);
AddHtmlLocalized(55, 65, 145, 25, 1018321); // Modern
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed.Deleted)
return;
switch (info.ButtonID)
{
case 1:
{
m_Deed.BeginPlace(m_From, HolidayTreeType.Classic);
break;
}
case 2:
{
m_Deed.BeginPlace(m_From, HolidayTreeType.Modern);
break;
}
}
}
}
}

View file

@ -0,0 +1,124 @@
using Server.Gumps;
using Server.Misc;
using Server.Network;
namespace Server.Items
{
public class NameChangeDeed : Item
{
[Constructible]
public NameChangeDeed() : base(0x14F0)
{
LootType = LootType.Blessed;
}
public NameChangeDeed(Serial serial) : base(serial)
{
}
public override string DefaultName => "a name change 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();
}
public override void OnDoubleClick(Mobile from)
{
if (RootParent == from)
{
from.CloseGump<NameChangeDeedGump>();
from.SendGump(new NameChangeDeedGump(this));
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
}
public class NameChangeDeedGump : Gump
{
private Item m_Sender;
public NameChangeDeedGump(Item sender) : base(50, 50)
{
m_Sender = sender;
Closable = true;
Draggable = true;
Resizable = false;
AddPage(0);
AddBlackAlpha(10, 120, 250, 85);
AddHtml(10, 125, 250, 20, Color(Center("Name Change Deed"), 0xFFFFFF));
AddLabel(73, 15, 1152, "");
AddLabel(20, 150, 0x480, "New Name:");
AddTextField(100, 150, 150, 20, 0);
AddButtonLabeled(75, 180, 1, "Submit");
}
public void AddBlackAlpha(int x, int y, int width, int height)
{
AddImageTiled(x, y, width, height, 2624);
AddAlphaRegion(x, y, width, height);
}
public void AddTextField(int x, int y, int width, int height, int index)
{
AddBackground(x - 2, y - 2, width + 4, height + 4, 0x2486);
AddTextEntry(x + 2, y + 2, width - 4, height - 4, 0, index, "");
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
public void AddButtonLabeled(int x, int y, int buttonID, string text)
{
AddButton(x, y - 1, 4005, 4007, buttonID);
AddHtml(x + 35, y, 240, 20, Color(text, 0xFFFFFF));
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Sender?.Deleted != false || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile)
return;
Mobile m = sender.Mobile;
TextRelay nameEntry = info.GetTextEntry(0);
string newName = nameEntry?.Text.Trim();
if (!NameVerification.Validate(newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
{
m.SendMessage("That name is unacceptable.");
return;
}
m.RawName = newName;
m.SendMessage("Your name has been changed!");
m.SendMessage($"You are now known as {newName}");
m_Sender.Delete();
}
}
}

View file

@ -0,0 +1,208 @@
using Server.Gumps;
using Server.Network;
using Server.Targeting;
namespace Server.Items
{
public class NewPlayerTicket : Item
{
[Constructible]
public NewPlayerTicket() : base(0x14EF)
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public NewPlayerTicket(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner{ get; set; }
public override int LabelNumber => 1062094; // a young player ticket
public override bool DisplayLootType => false;
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1041492); // This is half a prize ticket! Double-click this ticket and target any other ticket marked NEW PLAYER and get a prize! This ticket will only work for YOU, so don't give it away!
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Owner);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Owner = reader.ReadMobile();
break;
}
}
if (Name == "a young player ticket")
Name = null;
}
public override void OnDoubleClick(Mobile from)
{
if (from != Owner)
{
from.SendLocalizedMessage(501926); // This isn't your ticket! Shame on you! You have to use YOUR ticket.
}
else if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else
{
from.SendLocalizedMessage(501927); // Target any other ticket marked NEW PLAYER to win a prize.
from.Target = new InternalTarget(this);
}
}
private class InternalTarget : Target
{
private NewPlayerTicket m_Ticket;
public InternalTarget(NewPlayerTicket ticket) : base(2, false, TargetFlags.None)
{
m_Ticket = ticket;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted == m_Ticket)
{
from.SendLocalizedMessage(501928); // You can't target the same ticket!
}
else if (targeted is NewPlayerTicket theirTicket)
{
Mobile them = theirTicket.Owner;
if (them?.Deleted != false)
{
from.SendLocalizedMessage(501930); // That is not a valid ticket.
}
else
{
from.SendGump(new InternalGump(from, m_Ticket));
them.SendGump(new InternalGump(them, theirTicket));
}
}
else if ((targeted as Item)?.ItemID == 0x14F0)
{
from.SendLocalizedMessage(501931); // You need to find another ticket marked NEW PLAYER.
}
else
{
from.SendLocalizedMessage(501929); // You will need to select a ticket.
}
}
}
private class InternalGump : Gump
{
private Mobile m_From;
private NewPlayerTicket m_Ticket;
public InternalGump(Mobile from, NewPlayerTicket ticket) : base(50, 50)
{
m_From = from;
m_Ticket = ticket;
AddBackground(0, 0, 400, 385, 0xA28);
AddHtmlLocalized(30, 45, 340, 70, 1013011, true,
true); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket!
AddButton(46, 128, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(80, 130, 320, 35, 1013012); // A sextant
AddButton(46, 163, 0xFA5, 0xFA7, 2);
AddHtmlLocalized(80, 165, 320, 35, 1013013); // A coupon for a single hair restyling
AddButton(46, 198, 0xFA5, 0xFA7, 3);
AddHtmlLocalized(80, 200, 320, 35, 1013014); // A spellbook with all 1st - 4th spells.
AddButton(46, 233, 0xFA5, 0xFA7, 4);
AddHtmlLocalized(80, 235, 320, 35, 1013015); // A wand of fireworks
AddButton(46, 268, 0xFA5, 0xFA7, 5);
AddHtmlLocalized(80, 270, 320, 35, 1013016); // A spyglass
AddButton(46, 303, 0xFA5, 0xFA7, 6);
AddHtmlLocalized(80, 305, 320, 35, 1013017); // Dyes and a dye tub
AddButton(120, 340, 0xFA5, 0xFA7, 0);
AddHtmlLocalized(154, 342, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Ticket.Deleted)
return;
int number = 0;
Item item = null;
Item item2 = null;
switch (info.ButtonID)
{
case 1:
item = new Sextant();
number = 1010494;
break; // A sextant has been placed in your backpack.
case 2:
item = new HairRestylingDeed();
number = 501933;
break; // A coupon for a free hair restyling has been placed in your backpack.
case 3:
item = new Spellbook(0xFFFFFFFF);
number = 1010495;
break; // A spellbook with all 1st to 4th circle spells has been placed in your backpack.
case 4:
item = new FireworksWand();
number = 501935;
break; // A wand of fireworks has been placed in your backpack.
case 5:
item = new Spyglass();
number = 501936;
break; // A spyglass has been placed in your backpack.
case 6:
item = new DyeTub();
item2 = new Dyes();
number = 501937;
break; // The dyes and dye tub have been placed in your backpack.
}
if (item != null)
{
m_Ticket.Delete();
m_From.SendLocalizedMessage(number);
m_From.AddToBackpack(item);
if (item2 != null)
m_From.AddToBackpack(item2);
}
}
}
}
}

View file

@ -0,0 +1,349 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;
using Server.Targeting;
namespace Server.Items
{
public class VendorRentalContract : Item
{
private VendorRentalDuration m_Duration;
private Mobile m_Offeree;
private Timer m_OfferExpireTimer;
[Constructible]
public VendorRentalContract() : base(0x14F0)
{
Weight = 1.0;
Hue = 0x672;
m_Duration = VendorRentalDuration.Instances[0];
Price = 1500;
}
public VendorRentalContract(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1062332; // a vendor rental contract
public VendorRentalDuration Duration
{
get => m_Duration;
set
{
if (value != null)
m_Duration = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int Price{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool LandlordRenew{ get; set; }
public Mobile Offeree
{
get => m_Offeree;
set
{
if (m_OfferExpireTimer != null)
{
m_OfferExpireTimer.Stop();
m_OfferExpireTimer = null;
}
m_Offeree = value;
if (value != null)
{
m_OfferExpireTimer = new OfferExpireTimer(this);
m_OfferExpireTimer.Start();
}
InvalidateProperties();
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Offeree != null)
list.Add(1062368, Offeree.Name); // Being Offered To ~1_NAME~
}
public bool IsLandlord(Mobile m)
{
if (IsLockedDown)
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.DecayType != DecayType.Condemned)
return house.IsOwner(m);
}
return false;
}
public bool IsUsableBy(Mobile from, bool byLandlord, bool byBackpack, bool noOfferee, bool sendMessage)
{
if (Deleted || !from.CheckAlive(sendMessage))
return false;
if (noOfferee && Offeree != null)
{
if (sendMessage)
from.SendLocalizedMessage(1062343); // That item is currently in use.
return false;
}
if (byBackpack && IsChildOf(from.Backpack))
return true;
if (byLandlord && IsLandlord(from))
{
if (from.Map != Map || !from.InRange(this, 5))
{
if (sendMessage)
from.SendLocalizedMessage(501853); // Target is too far away.
return false;
}
return true;
}
return false;
}
public override void OnDelete()
{
if (IsLockedDown)
{
BaseHouse house = BaseHouse.FindHouseAt(this);
house?.VendorRentalContracts.Remove(this);
}
}
public override void OnDoubleClick(Mobile from)
{
if (Offeree != null)
{
from.SendLocalizedMessage(1062343); // That item is currently in use.
}
else if (!IsLockedDown)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
return;
}
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house == null || !house.IsOwner(from))
{
from.SendLocalizedMessage(
1062333); // You must be standing inside of a house that you own to make use of this contract.
}
else if (!house.IsAosRules)
{
from.SendMessage("Rental contracts can only be placed in AOS-enabled houses.");
}
else if (!house.Public)
{
from.SendLocalizedMessage(1062335); // Rental contracts can only be placed in public houses.
}
else if (!house.CanPlaceNewVendor())
{
from.SendLocalizedMessage(1062352); // You do not have enough storage available to place this contract.
}
else
{
from.SendLocalizedMessage(1062337); // Target the exact location you wish to rent out.
from.Target = new RentTarget(this);
}
}
else if (IsLandlord(from))
{
if (from.InRange(this, 5))
{
from.CloseGump<VendorRentalContractGump>();
from.SendGump(new VendorRentalContractGump(this, from));
}
else
{
from.SendLocalizedMessage(501853); // Target is too far away.
}
}
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (IsUsableBy(from, true, true, true, false)) list.Add(new ContractOptionEntry(this));
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt(0); // version
writer.WriteEncodedInt(m_Duration.ID);
writer.Write(Price);
writer.Write(LandlordRenew);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
int durationID = reader.ReadEncodedInt();
if (durationID < VendorRentalDuration.Instances.Length)
m_Duration = VendorRentalDuration.Instances[durationID];
else
m_Duration = VendorRentalDuration.Instances[0];
Price = reader.ReadInt();
LandlordRenew = reader.ReadBool();
}
private class ContractOptionEntry : ContextMenuEntry
{
private VendorRentalContract m_Contract;
public ContractOptionEntry(VendorRentalContract contract) : base(6209)
{
m_Contract = contract;
}
public override void OnClick()
{
Mobile from = Owner.From;
if (m_Contract.IsUsableBy(from, true, true, true, true))
{
from.CloseGump<VendorRentalContractGump>();
from.SendGump(new VendorRentalContractGump(m_Contract, from));
}
}
}
private class RentTarget : Target
{
private VendorRentalContract m_Contract;
public RentTarget(VendorRentalContract contract) : base(-1, false, TargetFlags.None)
{
m_Contract = contract;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (!m_Contract.IsUsableBy(from, false, true, true, true))
return;
if (!(targeted is IPoint3D location))
return;
Point3D pLocation = new Point3D(location);
Map map = from.Map;
BaseHouse house = BaseHouse.FindHouseAt(pLocation, map, 0);
if (house == null || !house.IsOwner(from))
{
from.SendLocalizedMessage(1062338); // The location being rented out must be inside of your house.
}
else if (BaseHouse.FindHouseAt(from) != house)
{
from.SendLocalizedMessage(
1062339); // You must be located inside of the house in which you are trying to place the contract.
}
else if (!house.IsAosRules)
{
from.SendMessage("Rental contracts can only be placed in AOS-enabled houses.");
}
else if (!house.Public)
{
from.SendLocalizedMessage(1062335); // Rental contracts can only be placed in public houses.
}
else if (house.DecayType == DecayType.Condemned)
{
from.SendLocalizedMessage(1062468); // You cannot place a contract in a condemned house.
}
else if (!house.CanPlaceNewVendor())
{
from.SendLocalizedMessage(1062352); // You do not have enought storage available to place this contract.
}
else if (!map.CanFit(pLocation, 16, false, false))
{
from.SendLocalizedMessage(1062486); // A vendor cannot exist at that location. Please try again.
}
else
{
BaseHouse.IsThereVendor(pLocation, map, out bool vendor, out bool contract);
if (vendor)
{
from.SendLocalizedMessage(
1062342); // You may not place a rental contract at this location while other beings occupy it.
}
else if (contract)
{
from.SendLocalizedMessage(
1062341); // That location is cluttered. Please clear out any objects there and try again.
}
else
{
m_Contract.MoveToWorld(pLocation, map);
if (!house.LockDown(from, m_Contract)) from.AddToBackpack(m_Contract);
}
}
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
from.SendLocalizedMessage(1062336); // You decide not to place the contract at this time.
}
}
private class OfferExpireTimer : Timer
{
private VendorRentalContract m_Contract;
public OfferExpireTimer(VendorRentalContract contract) : base(TimeSpan.FromSeconds(30.0))
{
m_Contract = contract;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
Mobile offeree = m_Contract.Offeree;
if (offeree != null)
{
offeree.CloseGump<VendorRentalOfferGump>();
m_Contract.Offeree = null;
}
}
}
}
}