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:
parent
0d5aa1d022
commit
e994505ad0
90 changed files with 2623 additions and 3168 deletions
|
|
@ -1,72 +1,59 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests.Hag
|
||||
namespace Server.Engines.Quests.Hag;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class MagicFlute : Item
|
||||
{
|
||||
public class MagicFlute : Item
|
||||
[Constructible]
|
||||
public MagicFlute() : base(0x1421) => Hue = 0x8AB;
|
||||
|
||||
public override int LabelNumber => 1055051; // magic flute
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
[Constructible]
|
||||
public MagicFlute() : base(0x1421) => Hue = 0x8AB;
|
||||
|
||||
public MagicFlute(Serial serial) : base(serial)
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042292); // You must have the object in your backpack to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1055051; // magic flute
|
||||
from.PlaySound(0x3D);
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
if (from is not PlayerMobile player)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042292); // You must have the object in your backpack to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
from.PlaySound(0x3D);
|
||||
|
||||
if (from is PlayerMobile player)
|
||||
{
|
||||
var qs = player.Quest;
|
||||
|
||||
if (qs is WitchApprenticeQuest)
|
||||
{
|
||||
var obj = qs.FindObjective<FindZeefzorpulObjective>();
|
||||
if (obj?.Completed == false)
|
||||
{
|
||||
if (player.Map != Map.Trammel && player.Map != Map.Felucca || !player.InRange(obj.ImpLocation, 8))
|
||||
{
|
||||
player.SendLocalizedMessage(
|
||||
1055053
|
||||
); // Nothing happens. Zeefzorpul must not be hiding in this area.
|
||||
}
|
||||
else if (player.InRange(obj.ImpLocation, 4))
|
||||
{
|
||||
Delete();
|
||||
|
||||
obj.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendLocalizedMessage(
|
||||
1055052
|
||||
); // The flute sparkles. Zeefzorpul must be in a good hiding place nearby.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
var qs = player.Quest;
|
||||
|
||||
writer.Write(0); // version
|
||||
if (qs is not WitchApprenticeQuest)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
var obj = qs.FindObjective<FindZeefzorpulObjective>();
|
||||
if (obj?.Completed != false)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Map != Map.Trammel && player.Map != Map.Felucca || !player.InRange(obj.ImpLocation, 8))
|
||||
{
|
||||
// Nothing happens. Zeefzorpul must not be hiding in this area.
|
||||
player.SendLocalizedMessage(1055053);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.InRange(obj.ImpLocation, 4))
|
||||
{
|
||||
Delete();
|
||||
obj.Complete();
|
||||
return;
|
||||
}
|
||||
|
||||
// The flute sparkles. Zeefzorpul must be in a good hiding place nearby.
|
||||
player.SendLocalizedMessage(1055052);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue