* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand. * WIP - Rewriting packets. * Cleanup and updates README * Converts more packets * Fixes header * Converts Effects packets. * Forgot the send command * Adds the start of containers packets. * Adds message packets with caching * Extends the send methods * Starts to add Acquire methods * Converted the packets * Cleanup * Cleanup * Adds more packets * Adds more packets * Fixes clearing arrays from pool. Adds Mobile Incoming * Converts more packets. * Moves more packets * Moves more packets * Test compression * Merges * Migrating to an idiomatic syntax that also supports compression, and proxying. * Optimize the stack alloc. Changes attributes * Converted container packets * Visual Studio doesn't auto save files. I am still getting used to subpar IDEs. * Adds static packet caching. Will profile later. Converts more packets * Fixes packets and changes how compression is configured * WIP - Adds basics for Gumps. Not finished though. * Fix file * Fixes formatting * Changed SpanWriter to be more idiomatic. * Fixes Span vs RawSpan and missing stackallocs * Converts over some more gumps * WIP - Deletes 32bit support. * Drops RDRand32 support. * Fixes gump compilation * Converting gump components * Removes old huffman compression function * Revert signature for backwards compatibility * WIP - Converting more gump components * Creates ArraySet for the strings. Updates AppendTo to reference that. * Converts the maining gump components * Cleans up gump components * Cleans up directives * Cleans up ArraySet and moves it. Adds null-coalescing-assignment * Cleanup, Target Packets, and C# 8 changes. * Removed OPL Packet * World packets * Fixing packet uses * Cleans up code. Fixes packet uses in various places. * More cleanup for packets * Code cleanup * Converts more packet uses and cleans up more code * More code cleanup * Finishes fixing the packets in Item * Updates secure trade packets * Updates core and gets it to compile. * Moved packets to scripts. Fixed account handler use of packets * Code cleanup * Updates chat packets * Code cleanuo * Adds party packets, but need to implement them. * Party packets WIP * Finishes party packets * Rearrange movement namespaces and classes * Finishes plant packets * Code Formatting * Fixes moving effects * Code cleanup, eliminates equipinfo * Adds more packets. Fixes bugs with various packets. * Finishes mahjon packets * Fixes mahjong packet * Code cleanup * Finishes mahjong packets * Adds Map packets * Add multifacet maps and charts * Cleans up some packets with UTF8 * Optimizes packets * Cleans up more packets. Moves the MessageHelper * Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets. * Updates protocol extensions packet receiver * Fixes a few bugs. Fixes a few more packets. * Code cleanup and fixing more packets * Fixes packet effects * Cleaned up more code * Buff Icon cleanup * Removed unused constructors * Code Cleanup. Adds BoatHS Packets * Moves house files. Updates house foundation packets. * Deployment cleanup * Fixes: * Code cleanup * More code cleanup * More code cleanup * Cleaned up BaseHouse * Enforces styling * Converts foreach to linq where possible. * Dont need that * Goals/Readme updates * Removes 32bit support at the highest level. Turns on HRT by default. * Code cleanup. Fixes extended features packet. * Fixes various bugs * Code cleanup * Code cleanup * Code cleanup. Fixes gump X/Y assignment. * Code cleanup using |= operator * More code cleanup * Cleanup * Fixes spacing issues. Thanks Visual Studio. You suck. * Compiler error * Fixes NPE from RunUO 2.7 * Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README * Fixes more packets. Stupid trailing nulls. * Fixes various bugs. * Fixes for gumps * Fixes more gump stuff. Going to split it out later since it is getting insane * Recoded the gump writing * WIP * *Added output path of scripts project to dev branch *Activated debugging in code
261 lines
7.3 KiB
C#
261 lines
7.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Server.ContextMenus;
|
|
using Server.Engines.Quests;
|
|
using Server.Network;
|
|
using Server.Regions;
|
|
using Server.Spells;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Items
|
|
{
|
|
public enum BagOfSendingHue
|
|
{
|
|
Yellow,
|
|
Blue,
|
|
Red
|
|
}
|
|
|
|
public class BagOfSending : Item, TranslocationItem
|
|
{
|
|
private BagOfSendingHue m_BagOfSendingHue;
|
|
|
|
private int m_Charges;
|
|
private int m_Recharges;
|
|
|
|
[Constructible]
|
|
public BagOfSending() : this(RandomHue())
|
|
{
|
|
}
|
|
|
|
[Constructible]
|
|
public BagOfSending(BagOfSendingHue hue) : base(0xE76)
|
|
{
|
|
Weight = 2.0;
|
|
|
|
BagOfSendingHue = hue;
|
|
|
|
m_Charges = Utility.RandomMinMax(3, 9);
|
|
}
|
|
|
|
public BagOfSending(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
public override int LabelNumber => 1054104; // a bag of sending
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public BagOfSendingHue BagOfSendingHue
|
|
{
|
|
get => m_BagOfSendingHue;
|
|
set
|
|
{
|
|
m_BagOfSendingHue = value;
|
|
|
|
Hue = value switch
|
|
{
|
|
BagOfSendingHue.Yellow => 0x8A5,
|
|
BagOfSendingHue.Blue => 0x8AD,
|
|
BagOfSendingHue.Red => 0x89B,
|
|
_ => Hue
|
|
};
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int Charges
|
|
{
|
|
get => m_Charges;
|
|
set
|
|
{
|
|
if (value > MaxCharges)
|
|
m_Charges = MaxCharges;
|
|
else if (value < 0)
|
|
m_Charges = 0;
|
|
else
|
|
m_Charges = value;
|
|
|
|
InvalidateProperties();
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int Recharges
|
|
{
|
|
get => m_Recharges;
|
|
set
|
|
{
|
|
if (value > MaxRecharges)
|
|
m_Recharges = MaxRecharges;
|
|
else if (value < 0)
|
|
m_Recharges = 0;
|
|
else
|
|
m_Recharges = value;
|
|
|
|
InvalidateProperties();
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int MaxCharges => 30;
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int MaxRecharges => 255;
|
|
|
|
public string TranslocationItemName => "bag of sending";
|
|
|
|
public static BagOfSendingHue RandomHue()
|
|
{
|
|
return Utility.Random(3) switch
|
|
{
|
|
0 => BagOfSendingHue.Yellow,
|
|
1 => BagOfSendingHue.Blue,
|
|
_ => BagOfSendingHue.Red
|
|
};
|
|
}
|
|
|
|
public override void GetProperties(ObjectPropertyList list)
|
|
{
|
|
base.GetProperties(list);
|
|
|
|
list.Add(1060741, m_Charges.ToString()); // charges: ~1_val~
|
|
}
|
|
|
|
public override void OnSingleClick(Mobile from)
|
|
{
|
|
base.OnSingleClick(from);
|
|
|
|
LabelTo(from, 1060741, m_Charges.ToString()); // charges: ~1_val~
|
|
}
|
|
|
|
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
|
{
|
|
base.GetContextMenuEntries(from, list);
|
|
|
|
if (from.Alive)
|
|
list.Add(new UseBagEntry(this, Charges > 0 && IsChildOf(from.Backpack)));
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (from.Region.IsPartOf<Jail>())
|
|
from.SendMessage("You may not do that in jail.");
|
|
else if (!IsChildOf(from.Backpack))
|
|
MessageHelper.SendLocalizedMessageTo(this, from, 1062334,
|
|
0x59); // The bag of sending must be in your backpack.
|
|
else if (Charges == 0)
|
|
MessageHelper.SendLocalizedMessageTo(this, from, 1042544, 0x59); // This item is out of charges.
|
|
else
|
|
from.Target = new SendTarget(this);
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
|
|
writer.WriteEncodedInt(1); // version
|
|
|
|
writer.WriteEncodedInt(m_Recharges);
|
|
|
|
writer.WriteEncodedInt(m_Charges);
|
|
writer.WriteEncodedInt((int)m_BagOfSendingHue);
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
|
|
int version = reader.ReadEncodedInt();
|
|
|
|
switch (version)
|
|
{
|
|
case 1:
|
|
{
|
|
m_Recharges = reader.ReadEncodedInt();
|
|
goto case 0;
|
|
}
|
|
case 0:
|
|
{
|
|
m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges);
|
|
m_BagOfSendingHue = (BagOfSendingHue)reader.ReadEncodedInt();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private class UseBagEntry : ContextMenuEntry
|
|
{
|
|
private BagOfSending m_Bag;
|
|
|
|
public UseBagEntry(BagOfSending bag, bool enabled) : base(6189)
|
|
{
|
|
m_Bag = bag;
|
|
|
|
if (!enabled)
|
|
Flags |= CMEFlags.Disabled;
|
|
}
|
|
|
|
public override void OnClick()
|
|
{
|
|
if (m_Bag.Deleted)
|
|
return;
|
|
|
|
Mobile from = Owner.From;
|
|
|
|
if (from.CheckAlive())
|
|
m_Bag.OnDoubleClick(from);
|
|
}
|
|
}
|
|
|
|
private class SendTarget : Target
|
|
{
|
|
private BagOfSending m_Bag;
|
|
|
|
public SendTarget(BagOfSending bag) : base(-1, false, TargetFlags.None) => m_Bag = bag;
|
|
|
|
protected override void OnTarget(Mobile from, object targeted)
|
|
{
|
|
if (m_Bag.Deleted)
|
|
return;
|
|
|
|
if (from.Region.IsPartOf<Jail>())
|
|
from.SendMessage("You may not do that in jail.");
|
|
else if (!m_Bag.IsChildOf(from.Backpack))
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054107,
|
|
0x59); // This item must be in your backpack.
|
|
else if (m_Bag.Charges == 0)
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1042544, 0x59); // This item is out of charges.
|
|
else if (targeted is Item item)
|
|
{
|
|
int reqCharges = (int)Math.Max(1, Math.Ceiling(item.TotalWeight / 10.0));
|
|
|
|
if (!item.IsChildOf(from.Backpack))
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054152,
|
|
0x59); // You may only send items from your backpack to your bank box.
|
|
else if (item is BagOfSending || item is Container)
|
|
Packets.SendAsciiMessage(from.NetState, m_Bag.Serial, m_Bag.ItemID, MessageType.Regular, 0x3B2, 3, "",
|
|
"You cannot send a container through the bag of sending." );
|
|
else if (item.LootType == LootType.Cursed)
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054108,
|
|
0x59); // The bag of sending rejects the cursed item.
|
|
else if (!item.VerifyMove(from) || item is QuestItem || item.Nontransferable)
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054109,
|
|
0x59); // The bag of sending rejects that item.
|
|
else if (SpellHelper.IsDoomGauntlet(from.Map, from.Location))
|
|
from.SendLocalizedMessage(1062089); // You cannot use that here.
|
|
else if (!from.BankBox.TryDropItem(from, item, false))
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054110, 0x59); // Your bank box is full.
|
|
else if (Core.ML && reqCharges > m_Bag.Charges)
|
|
from.SendLocalizedMessage(1079932); //You don't have enough charges to send that much weight
|
|
else
|
|
{
|
|
m_Bag.Charges -= Core.ML ? reqCharges : 1;
|
|
|
|
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054150,
|
|
0x59); // The item was placed in your bank box.
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|