fix: Adds safety to corpses and cleans up quests (#1685)

### Summary
- Adds some more checks in case a corpse's owner is somehow null. Would like to eventually allow null owner corpses, but more work is needed.
- Cleans up variable unboxing and reassignment in quests. Also flattens quest logic. Still more work needs to be done.
- Codegens more quest items/mobiles.
This commit is contained in:
Kamron Batman 2024-02-18 19:33:08 -08:00 • committed by GitHub
parent 0d5aa1d022
commit e994505ad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
90 changed files with 2623 additions and 3168 deletions

View file

@ -608,7 +608,7 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
{
if (from is PlayerMobile { Quest: SolenMatriarchQuest qs })
{
QuestObjective obj = qs.FindObjective<GatherWaterObjective>();
var obj = qs.FindObjective<GatherWaterObjective>();
if (obj?.Completed == false)
{

View file

@ -183,7 +183,7 @@ public partial class BankCheck : Item
if (qs is DarkTidesQuest)
{
QuestObjective obj = qs.FindObjective<CashBankCheckObjective>();
var obj = qs.FindObjective<CashBankCheckObjective>();
if (obj?.Completed == false)
{

View file

@ -47,16 +47,19 @@ public static class CorpsePackets
}
}
if (beheld.Hair?.ItemID > 0)
if (beheld.Owner != null)
{
writer.Write((byte)(Layer.Hair + 1));
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
}
if (beheld.Hair?.ItemID > 0)
{
writer.Write((byte)(Layer.Hair + 1));
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
}
if (beheld.FacialHair?.ItemID > 0)
{
writer.Write((byte)(Layer.FacialHair + 1));
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
if (beheld.FacialHair?.ItemID > 0)
{
writer.Write((byte)(Layer.FacialHair + 1));
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
}
}
writer.Write((byte)Layer.Invalid);
@ -115,38 +118,41 @@ public static class CorpsePackets
}
}
if (hairItemID > 0)
if (beheld.Owner != null)
{
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
writer.Write((ushort)hairItemID);
writer.Write((byte)0); // signed, itemID offset
writer.Write((ushort)1);
writer.Write(0); // X/Y
if (ns.ContainerGridLines)
if (hairItemID > 0)
{
writer.Write((byte)0); // Grid Location?
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
writer.Write((ushort)hairItemID);
writer.Write((byte)0); // signed, itemID offset
writer.Write((ushort)1);
writer.Write(0); // X/Y
if (ns.ContainerGridLines)
{
writer.Write((byte)0); // Grid Location?
}
writer.Write(beheld.Serial);
writer.Write((ushort)beheld.Hair!.Hue);
++written;
}
writer.Write(beheld.Serial);
writer.Write((ushort)beheld.Hair!.Hue);
++written;
}
if (facialHairItemID > 0)
{
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
writer.Write((ushort)facialHairItemID);
writer.Write((byte)0); // signed, itemID offset
writer.Write((ushort)1);
writer.Write(0); // X/Y
if (ns.ContainerGridLines)
if (facialHairItemID > 0)
{
writer.Write((byte)0); // Grid Location?
}
writer.Write(beheld.Serial);
writer.Write((ushort)beheld.FacialHair!.Hue);
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
writer.Write((ushort)facialHairItemID);
writer.Write((byte)0); // signed, itemID offset
writer.Write((ushort)1);
writer.Write(0); // X/Y
if (ns.ContainerGridLines)
{
writer.Write((byte)0); // Grid Location?
}
writer.Write(beheld.Serial);
writer.Write((ushort)beheld.FacialHair!.Hue);
++written;
++written;
}
}
writer.Seek(1, SeekOrigin.Begin);