ModernUO/Projects/Scripts/Gumps/PolymorphGump.cs
Kamron Batman 179cb50557 Updates Packets & Randomizer (#43)
* 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
2019-11-11 12:40:16 +01:00

242 lines
7.8 KiB
C#

using Server.Network;
using Server.Spells;
using Server.Spells.Seventh;
namespace Server.Gumps
{
public class PolymorphEntry
{
public static readonly PolymorphEntry Chicken = new PolymorphEntry(8401, 0xD0, 1015236, 15, 10);
public static readonly PolymorphEntry Dog = new PolymorphEntry(8405, 0xD9, 1015237, 17, 10);
public static readonly PolymorphEntry Wolf = new PolymorphEntry(8426, 0xE1, 1015238, 18, 10);
public static readonly PolymorphEntry Panther = new PolymorphEntry(8473, 0xD6, 1015239, 20, 14);
public static readonly PolymorphEntry Gorilla = new PolymorphEntry(8437, 0x1D, 1015240, 23, 10);
public static readonly PolymorphEntry BlackBear = new PolymorphEntry(8399, 0xD3, 1015241, 22, 10);
public static readonly PolymorphEntry GrizzlyBear = new PolymorphEntry(8411, 0xD4, 1015242, 22, 12);
public static readonly PolymorphEntry PolarBear = new PolymorphEntry(8417, 0xD5, 1015243, 26, 10);
public static readonly PolymorphEntry HumanMale = new PolymorphEntry(8397, 0x190, 1015244, 29, 8);
public static readonly PolymorphEntry HumanFemale = new PolymorphEntry(8398, 0x191, 1015254, 29, 10);
public static readonly PolymorphEntry Slime = new PolymorphEntry(8424, 0x33, 1015246, 5, 10);
public static readonly PolymorphEntry Orc = new PolymorphEntry(8416, 0x11, 1015247, 29, 10);
public static readonly PolymorphEntry LizardMan = new PolymorphEntry(8414, 0x21, 1015248, 26, 10);
public static readonly PolymorphEntry Gargoyle = new PolymorphEntry(8409, 0x04, 1015249, 22, 10);
public static readonly PolymorphEntry Ogre = new PolymorphEntry(8415, 0x01, 1015250, 24, 9);
public static readonly PolymorphEntry Troll = new PolymorphEntry(8425, 0x36, 1015251, 25, 9);
public static readonly PolymorphEntry Ettin = new PolymorphEntry(8408, 0x02, 1015252, 25, 8);
public static readonly PolymorphEntry Daemon = new PolymorphEntry(8403, 0x09, 1015253, 25, 8);
private PolymorphEntry(int Art, int Body, int LocNum, int X, int Y)
{
ArtID = Art;
BodyID = Body;
LocNumber = LocNum;
this.X = X;
this.Y = Y;
}
public int ArtID{ get; }
public int BodyID{ get; }
public int LocNumber{ get; }
public int X{ get; }
public int Y{ get; }
}
public class PolymorphGump : Gump
{
private static PolymorphCategory[] Categories =
{
new PolymorphCategory(1015235, // Animals
PolymorphEntry.Chicken,
PolymorphEntry.Dog,
PolymorphEntry.Wolf,
PolymorphEntry.Panther,
PolymorphEntry.Gorilla,
PolymorphEntry.BlackBear,
PolymorphEntry.GrizzlyBear,
PolymorphEntry.PolarBear,
PolymorphEntry.HumanMale),
new PolymorphCategory(1015245, // Monsters
PolymorphEntry.Slime,
PolymorphEntry.Orc,
PolymorphEntry.LizardMan,
PolymorphEntry.Gargoyle,
PolymorphEntry.Ogre,
PolymorphEntry.Troll,
PolymorphEntry.Ettin,
PolymorphEntry.Daemon,
PolymorphEntry.HumanFemale)
};
private Mobile m_Caster;
private Item m_Scroll;
public PolymorphGump(Mobile caster, Item scroll) : base(50, 50)
{
m_Caster = caster;
m_Scroll = scroll;
int x, y;
AddPage(0);
AddBackground(0, 0, 585, 393, 5054);
AddBackground(195, 36, 387, 275, 3000);
AddHtmlLocalized(0, 0, 510, 18, 1015234); // <center>Polymorph Selection Menu</center>
AddHtmlLocalized(60, 355, 150, 18, 1011036); // OKAY
AddButton(25, 355, 4005, 4007, 1, GumpButtonType.Reply, 1);
AddHtmlLocalized(320, 355, 150, 18, 1011012); // CANCEL
AddButton(285, 355, 4005, 4007, 0, GumpButtonType.Reply, 2);
y = 35;
for (int i = 0; i < Categories.Length; i++)
{
PolymorphCategory cat = Categories[i];
AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true);
AddButton(155, y, 4005, 4007, 0, GumpButtonType.Page, i + 1);
y += 25;
}
for (int i = 0; i < Categories.Length; i++)
{
PolymorphCategory cat = Categories[i];
AddPage(i + 1);
for (int c = 0; c < cat.Entries.Length; c++)
{
PolymorphEntry entry = cat.Entries[c];
x = 198 + c % 3 * 129;
y = 38 + c / 3 * 67;
AddHtmlLocalized(x, y, 100, 18, entry.LocNumber);
AddItem(x + 20, y + 25, entry.ArtID);
AddRadio(x, y + 20, 210, 211, false, (c << 8) + i);
}
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && info.Switches.Length > 0)
{
int cnum = info.Switches[0];
int cat = cnum % 256;
int ent = cnum >> 8;
if (cat >= 0 && cat < Categories.Length)
if (ent >= 0 && ent < Categories[cat].Entries.Length)
{
Spell spell = new PolymorphSpell(m_Caster, m_Scroll, Categories[cat].Entries[ent].BodyID);
spell.Cast();
}
}
}
private class PolymorphCategory
{
public PolymorphCategory(int num, params PolymorphEntry[] entries)
{
LocNumber = num;
Entries = entries;
}
public PolymorphEntry[] Entries{ get; }
public int LocNumber{ get; }
}
}
public class NewPolymorphGump : Gump
{
private static readonly PolymorphEntry[] m_Entries =
{
PolymorphEntry.Chicken,
PolymorphEntry.Dog,
PolymorphEntry.Wolf,
PolymorphEntry.Panther,
PolymorphEntry.Gorilla,
PolymorphEntry.BlackBear,
PolymorphEntry.GrizzlyBear,
PolymorphEntry.PolarBear,
PolymorphEntry.HumanMale,
PolymorphEntry.HumanFemale,
PolymorphEntry.Slime,
PolymorphEntry.Orc,
PolymorphEntry.LizardMan,
PolymorphEntry.Gargoyle,
PolymorphEntry.Ogre,
PolymorphEntry.Troll,
PolymorphEntry.Ettin,
PolymorphEntry.Daemon
};
private Mobile m_Caster;
private Item m_Scroll;
public NewPolymorphGump(Mobile caster, Item scroll) : base(0, 0)
{
m_Caster = caster;
m_Scroll = scroll;
AddPage(0);
AddBackground(0, 0, 520, 404, 0x13BE);
AddImageTiled(10, 10, 500, 20, 0xA40);
AddImageTiled(10, 40, 500, 324, 0xA40);
AddImageTiled(10, 374, 500, 20, 0xA40);
AddAlphaRegion(10, 10, 500, 384);
AddHtmlLocalized(14, 12, 500, 20, 1015234, 0x7FFF); // <center>Polymorph Selection Menu</center>
AddButton(10, 374, 0xFB1, 0xFB2, 0);
AddHtmlLocalized(45, 376, 450, 20, 1060051, 0x7FFF); // CANCEL
for (int i = 0; i < m_Entries.Length; i++)
{
PolymorphEntry entry = m_Entries[i];
int page = i / 10 + 1;
int pos = i % 10;
if (pos == 0)
{
if (page > 1)
{
AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page);
AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next
}
AddPage(page);
if (page > 1)
{
AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back
}
}
int x = pos % 2 == 0 ? 14 : 264;
int y = pos / 2 * 64 + 44;
AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entry.ArtID, 0x0, entry.X, entry.Y);
AddHtmlLocalized(x + 84, y, 250, 60, entry.LocNumber, 0x7FFF);
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
int idx = info.ButtonID - 1;
if (idx < 0 || idx >= m_Entries.Length)
return;
Spell spell = new PolymorphSpell(m_Caster, m_Scroll, m_Entries[idx].BodyID);
spell.Cast();
}
}
}