* 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
174 lines
4.8 KiB
C#
174 lines
4.8 KiB
C#
using System.Collections.Generic;
|
|
using Server.Gumps;
|
|
using Server.Network;
|
|
|
|
namespace Server
|
|
{
|
|
public delegate void OnVirtueUsed(Mobile from);
|
|
|
|
public class VirtueGump : Gump
|
|
{
|
|
private static Dictionary<int, OnVirtueUsed> m_Callbacks = new Dictionary<int, OnVirtueUsed>();
|
|
|
|
private static int[] m_Table = {
|
|
0x0481, 0x0963, 0x0965,
|
|
0x060A, 0x060F, 0x002A,
|
|
0x08A4, 0x08A7, 0x0034,
|
|
0x0965, 0x08FD, 0x0480,
|
|
0x00EA, 0x0845, 0x0020,
|
|
0x0011, 0x0269, 0x013D,
|
|
0x08A1, 0x08A3, 0x0042,
|
|
0x0543, 0x0547, 0x0061
|
|
};
|
|
|
|
private Mobile m_Beholder, m_Beheld;
|
|
|
|
public VirtueGump(Mobile beholder, Mobile beheld) : base(0, 0)
|
|
{
|
|
m_Beholder = beholder;
|
|
m_Beheld = beheld;
|
|
|
|
Serial = beheld.Serial;
|
|
|
|
AddPage(0);
|
|
|
|
AddImage(30, 40, 104);
|
|
|
|
AddPage(1);
|
|
|
|
Add(new GumpImage(61, 71, 108, GetHueFor(0), "VirtueGumpItem")); // Humility
|
|
Add(new GumpImage(123, 46, 112, GetHueFor(4), "VirtueGumpItem")); // Valor
|
|
Add(new GumpImage(187, 70, 107, GetHueFor(5), "VirtueGumpItem")); // Honor
|
|
Add(new GumpImage(35, 135, 110, GetHueFor(1), "VirtueGumpItem")); // Sacrifice
|
|
Add(new GumpImage(211, 133, 105, GetHueFor(2), "VirtueGumpItem")); // Compassion
|
|
Add(new GumpImage(61, 195, 111, GetHueFor(3), "VirtueGumpItem")); // Spiritulaity
|
|
Add(new GumpImage(186, 195, 109, GetHueFor(6), "VirtueGumpItem")); // Justice
|
|
Add(new GumpImage(121, 221, 106, GetHueFor(7), "VirtueGumpItem")); // Honesty
|
|
|
|
if (m_Beholder == m_Beheld)
|
|
{
|
|
AddButton(57, 269, 2027, 2027, 1);
|
|
AddButton(186, 269, 2071, 2071, 2);
|
|
}
|
|
}
|
|
|
|
public static void Initialize()
|
|
{
|
|
EventSink.VirtueGumpRequest += EventSink_VirtueGumpRequest;
|
|
EventSink.VirtueItemRequest += EventSink_VirtueItemRequest;
|
|
EventSink.VirtueMacroRequest += EventSink_VirtueMacroRequest;
|
|
}
|
|
|
|
public static void Register(int gumpID, OnVirtueUsed callback)
|
|
{
|
|
m_Callbacks[gumpID] = callback;
|
|
}
|
|
|
|
private static void EventSink_VirtueItemRequest(VirtueItemRequestEventArgs e)
|
|
{
|
|
if (e.Beholder != e.Beheld)
|
|
return;
|
|
|
|
e.Beholder.CloseGump<VirtueGump>();
|
|
|
|
if (e.Beholder.Kills >= 5)
|
|
{
|
|
e.Beholder.SendLocalizedMessage(1049609); // Murderers cannot invoke this virtue.
|
|
return;
|
|
}
|
|
|
|
if (m_Callbacks.TryGetValue(e.GumpID, out OnVirtueUsed callback))
|
|
callback(e.Beholder);
|
|
else
|
|
e.Beholder.SendLocalizedMessage(1052066); // That virtue is not active yet.
|
|
}
|
|
|
|
|
|
private static void EventSink_VirtueMacroRequest(VirtueMacroRequestEventArgs e)
|
|
{
|
|
var virtueID = e.VirtueID switch
|
|
{
|
|
0 => // Honor
|
|
107,
|
|
1 => // Sacrifice
|
|
110,
|
|
2 => // Valor;
|
|
112,
|
|
_ => 0
|
|
};
|
|
|
|
EventSink_VirtueItemRequest(new VirtueItemRequestEventArgs(e.Mobile, e.Mobile, virtueID));
|
|
}
|
|
|
|
private static void EventSink_VirtueGumpRequest(VirtueGumpRequestEventArgs e)
|
|
{
|
|
Mobile beholder = e.Beholder;
|
|
Mobile beheld = e.Beheld;
|
|
|
|
if (beholder == beheld && beholder.Kills >= 5)
|
|
{
|
|
beholder.SendLocalizedMessage(1049609); // Murderers cannot invoke this virtue.
|
|
}
|
|
else if (beholder.Map == beheld.Map && beholder.InRange(beheld, 12))
|
|
{
|
|
beholder.CloseGump<VirtueGump>();
|
|
beholder.SendGump(new VirtueGump(beholder, beheld));
|
|
}
|
|
}
|
|
|
|
private int GetHueFor(int index)
|
|
{
|
|
if (m_Beheld.Virtues.GetValue(index) == 0)
|
|
return 2402;
|
|
|
|
int value = m_Beheld.Virtues.GetValue(index);
|
|
|
|
if (value < 4000)
|
|
return 2402;
|
|
|
|
if (value >= 30000)
|
|
value = 20000; //Sanity
|
|
|
|
|
|
int vl;
|
|
|
|
if (value < 10000)
|
|
vl = 0;
|
|
else if (value >= 20000 && index == 5)
|
|
vl = 2;
|
|
else if (value >= 21000 && index != 1)
|
|
vl = 2;
|
|
else if (value >= 22000 && index == 1)
|
|
vl = 2;
|
|
else
|
|
vl = 1;
|
|
|
|
|
|
return m_Table[index * 3 + vl];
|
|
}
|
|
|
|
public override void OnResponse(NetState sender, RelayInfo info)
|
|
{
|
|
if (info.ButtonID == 1 && m_Beholder == m_Beheld)
|
|
m_Beholder.SendGump(new VirtueStatusGump(m_Beholder));
|
|
}
|
|
|
|
private class InternalEntry : GumpImage
|
|
{
|
|
private static byte[] m_Class = StringToBuffer(" class=VirtueGumpItem");
|
|
|
|
public InternalEntry(int x, int y, int gumpID, int hue) : base(x, y, gumpID, hue)
|
|
{
|
|
}
|
|
|
|
public override string Compile(NetState ns) => $"{{ gumppic {X} {Y} {GumpID} hue={Hue} class=VirtueGumpItem }}";
|
|
|
|
public override void AppendTo(NetState ns, IGumpWriter disp)
|
|
{
|
|
base.AppendTo(ns, disp);
|
|
|
|
disp.AppendLayout(m_Class);
|
|
}
|
|
}
|
|
}
|
|
}
|