* 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
542 lines
11 KiB
C#
542 lines
11 KiB
C#
using System;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Items
|
|
{
|
|
public class UtilityItem
|
|
{
|
|
public static int RandomChoice(int itemID1, int itemID2)
|
|
{
|
|
var iRet = Utility.Random(2) switch
|
|
{
|
|
0 => itemID1,
|
|
1 => itemID2,
|
|
_ => itemID1
|
|
};
|
|
|
|
return iRet;
|
|
}
|
|
}
|
|
|
|
// ********** Dough **********
|
|
public class Dough : Item
|
|
{
|
|
[Constructible]
|
|
public Dough() : base(0x103d)
|
|
{
|
|
Stackable = Core.ML;
|
|
Weight = 1.0;
|
|
}
|
|
|
|
public Dough(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
|
|
writer.Write(0); // version
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
|
|
int version = reader.ReadInt();
|
|
}
|
|
|
|
#if false
|
|
public override void OnDoubleClick( Mobile from )
|
|
{
|
|
if ( !Movable )
|
|
return;
|
|
|
|
from.Target = new InternalTarget( this );
|
|
}
|
|
#endif
|
|
|
|
private class InternalTarget : Target
|
|
{
|
|
private Dough m_Item;
|
|
|
|
public InternalTarget(Dough item) : base(1, false, TargetFlags.None) => m_Item = item;
|
|
|
|
protected override void OnTarget(Mobile from, object targeted)
|
|
{
|
|
if (m_Item.Deleted) return;
|
|
|
|
if (!(targeted is Item targetItem) || targetItem.Deleted)
|
|
return;
|
|
|
|
m_Item.Consume();
|
|
|
|
if (targeted is Eggs)
|
|
{
|
|
from.AddToBackpack(new UnbakedQuiche());
|
|
from.AddToBackpack(new Eggshells());
|
|
}
|
|
else if (targeted is CheeseWheel)
|
|
{
|
|
from.AddToBackpack(new CheesePizza());
|
|
}
|
|
else if (targeted is Sausage)
|
|
{
|
|
from.AddToBackpack(new SausagePizza());
|
|
}
|
|
else if (targeted is Apple)
|
|
{
|
|
from.AddToBackpack(new UnbakedApplePie());
|
|
}
|
|
else if (targeted is Peach)
|
|
{
|
|
from.AddToBackpack(new UnbakedPeachCobbler());
|
|
}
|
|
else
|
|
return;
|
|
|
|
targetItem.Consume();
|
|
}
|
|
}
|
|
}
|
|
|
|
// ********** SweetDough **********
|
|
public class SweetDough : Item
|
|
{
|
|
public override int LabelNumber => 1041340; // sweet dough
|
|
|
|
[Constructible]
|
|
public SweetDough() : base(0x103d)
|
|
{
|
|
Stackable = Core.ML;
|
|
Weight = 1.0;
|
|
Hue = 150;
|
|
}
|
|
|
|
public SweetDough(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
|
|
writer.Write(0); // version
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
|
|
int version = reader.ReadInt();
|
|
|
|
if (Hue == 51)
|
|
Hue = 150;
|
|
}
|
|
|
|
#if false
|
|
public override void OnDoubleClick( Mobile from )
|
|
{
|
|
if ( !Movable )
|
|
return;
|
|
|
|
from.Target = new InternalTarget( this );
|
|
}
|
|
#endif
|
|
|
|
private class InternalTarget : Target
|
|
{
|
|
private SweetDough m_Item;
|
|
|
|
public InternalTarget(SweetDough item) : base(1, false, TargetFlags.None) => m_Item = item;
|
|
|
|
protected override void OnTarget(Mobile from, object targeted)
|
|
{
|
|
if (m_Item.Deleted) return;
|
|
|
|
m_Item.Consume();
|
|
|
|
if (targeted is BowlFlour flour)
|
|
{
|
|
flour.Delete();
|
|
|
|
from.AddToBackpack(new CakeMix());
|
|
}
|
|
else if (targeted is Campfire campfire)
|
|
{
|
|
from.PlaySound(0x225);
|
|
InternalTimer t = new InternalTimer(from, campfire);
|
|
t.Start();
|
|
}
|
|
}
|
|
|
|
private class InternalTimer : Timer
|
|
{
|
|
private Campfire m_Campfire;
|
|
private Mobile m_From;
|
|
|
|
public InternalTimer(Mobile from, Campfire campfire) : base(TimeSpan.FromSeconds(5.0))
|
|
{
|
|
m_From = from;
|
|
m_Campfire = campfire;
|
|
}
|
|
|
|
protected override void OnTick()
|
|
{
|
|
if (m_From.GetDistanceToSqrt(m_Campfire) > 3)
|
|
{
|
|
m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined.
|
|
return;
|
|
}
|
|
|
|
if (m_From.CheckSkill(SkillName.Cooking, 0, 10))
|
|
{
|
|
if (m_From.AddToBackpack(new Muffins()))
|
|
m_From.PlaySound(0x57);
|
|
}
|
|
else
|
|
{
|
|
m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined.
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// ********** JarHoney **********
|
|
public class JarHoney : Item
|
|
{
|
|
[Constructible]
|
|
public JarHoney() : base(0x9ec)
|
|
{
|
|
Weight = 1.0;
|
|
Stackable = true;
|
|
}
|
|
|
|
public JarHoney(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
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();
|
|
Stackable = true;
|
|
}
|
|
|
|
/*public override void OnDoubleClick( Mobile from )
|
|
{
|
|
if ( !Movable )
|
|
return;
|
|
|
|
from.Target = new InternalTarget( this );
|
|
}*/
|
|
|
|
private class InternalTarget : Target
|
|
{
|
|
private JarHoney m_Item;
|
|
|
|
public InternalTarget(JarHoney item) : base(1, false, TargetFlags.None) => m_Item = item;
|
|
|
|
protected override void OnTarget(Mobile from, object targeted)
|
|
{
|
|
if (m_Item.Deleted) return;
|
|
|
|
m_Item.Consume();
|
|
|
|
if (targeted is Dough dough)
|
|
{
|
|
dough.Consume();
|
|
|
|
from.AddToBackpack(new SweetDough());
|
|
}
|
|
|
|
if (targeted is BowlFlour flour)
|
|
{
|
|
flour.Delete();
|
|
|
|
from.AddToBackpack(new CookieMix());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// ********** BowlFlour **********
|
|
public class BowlFlour : Item
|
|
{
|
|
[Constructible]
|
|
public BowlFlour() : base(0xa1e) => Weight = 1.0;
|
|
|
|
public BowlFlour(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
// ********** WoodenBowl **********
|
|
public class WoodenBowl : Item
|
|
{
|
|
[Constructible]
|
|
public WoodenBowl() : base(0x15f8) => Weight = 1.0;
|
|
|
|
public WoodenBowl(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
// ********** PitcherWater **********
|
|
/*public class PitcherWater : Item
|
|
{
|
|
[Constructible]
|
|
public PitcherWater() : base(Utility.Random( 0x1f9d, 2 ))
|
|
{
|
|
Weight = 1.0;
|
|
}
|
|
|
|
public PitcherWater( Serial serial ) : base( serial )
|
|
{
|
|
}
|
|
|
|
public override void Serialize( GenericWriter writer )
|
|
{
|
|
base.Serialize( writer );
|
|
|
|
writer.Write( (int) 0 ); // version
|
|
}
|
|
|
|
public override void Deserialize( GenericReader reader )
|
|
{
|
|
base.Deserialize( reader );
|
|
|
|
int version = reader.ReadInt();
|
|
}
|
|
|
|
public override void OnDoubleClick( Mobile from )
|
|
{
|
|
if ( !Movable )
|
|
return;
|
|
|
|
from.Target = new InternalTarget( this );
|
|
}
|
|
|
|
private class InternalTarget : Target
|
|
{
|
|
private PitcherWater m_Item;
|
|
|
|
public InternalTarget( PitcherWater item ) : base( 1, false, TargetFlags.None )
|
|
{
|
|
m_Item = item;
|
|
}
|
|
|
|
protected override void OnTarget( Mobile from, object targeted )
|
|
{
|
|
if ( m_Item.Deleted ) return;
|
|
|
|
if ( targeted is BowlFlour )
|
|
{
|
|
m_Item.Delete();
|
|
((BowlFlour)targeted).Delete();
|
|
|
|
from.AddToBackpack( new Dough() );
|
|
from.AddToBackpack( new WoodenBowl() );
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
|
|
// ********** SackFlour **********
|
|
[TypeAlias("Server.Items.SackFlourOpen")]
|
|
public class SackFlour : Item, IHasQuantity
|
|
{
|
|
private int m_Quantity;
|
|
|
|
[Constructible]
|
|
public SackFlour() : base(0x1039)
|
|
{
|
|
Weight = 5.0;
|
|
m_Quantity = 20;
|
|
}
|
|
|
|
public SackFlour(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int Quantity
|
|
{
|
|
get => m_Quantity;
|
|
set
|
|
{
|
|
m_Quantity = Math.Min(20, Math.Max(0, value));
|
|
|
|
if (m_Quantity == 0)
|
|
Delete();
|
|
else if (m_Quantity < 20 && (ItemID == 0x1039 || ItemID == 0x1045))
|
|
++ItemID;
|
|
}
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
|
|
writer.Write(2); // version
|
|
|
|
writer.Write(m_Quantity);
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
|
|
int version = reader.ReadInt();
|
|
|
|
switch (version)
|
|
{
|
|
case 2:
|
|
case 1:
|
|
{
|
|
m_Quantity = reader.ReadInt();
|
|
break;
|
|
}
|
|
case 0:
|
|
{
|
|
m_Quantity = 20;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (version < 2 && Weight == 1.0)
|
|
Weight = 5.0;
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (!Movable)
|
|
return;
|
|
|
|
if (ItemID == 0x1039 || ItemID == 0x1045)
|
|
++ItemID;
|
|
|
|
#if false
|
|
this.Delete();
|
|
|
|
from.AddToBackpack( new SackFlourOpen() );
|
|
#endif
|
|
}
|
|
}
|
|
|
|
// ********** Eggshells **********
|
|
public class Eggshells : Item
|
|
{
|
|
[Constructible]
|
|
public Eggshells() : base(0x9b4) => Weight = 0.5;
|
|
|
|
public Eggshells(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
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 class WheatSheaf : Item
|
|
{
|
|
[Constructible]
|
|
public WheatSheaf(int amount = 1) : base(7869)
|
|
{
|
|
Weight = 1.0;
|
|
Stackable = true;
|
|
Amount = amount;
|
|
}
|
|
|
|
public WheatSheaf(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (!Movable)
|
|
return;
|
|
|
|
from.BeginTarget(4, false, TargetFlags.None, OnTarget);
|
|
}
|
|
|
|
public virtual void OnTarget(Mobile from, object obj)
|
|
{
|
|
if (obj is AddonComponent addon)
|
|
obj = addon.Addon;
|
|
|
|
if (obj is IFlourMill mill)
|
|
{
|
|
int needs = mill.MaxFlour - mill.CurFlour;
|
|
|
|
if (needs > Amount)
|
|
needs = Amount;
|
|
|
|
mill.CurFlour += needs;
|
|
Consume(needs);
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|