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,28 +1,12 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class Cauldron : Item
|
||||
{
|
||||
public class Cauldron : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Cauldron() : base(0x9ED) => Weight = 1.0;
|
||||
[Constructible]
|
||||
public Cauldron() : base(0x9ED) => Weight = 1.0;
|
||||
|
||||
public Cauldron(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override string DefaultName => "a cauldron";
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override string DefaultName => "a cauldron";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,105 +1,75 @@
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.Quests.Hag
|
||||
namespace Server.Engines.Quests.Hag;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HagApprenticeCorpse : Corpse
|
||||
{
|
||||
public class HagApprenticeCorpse : Corpse
|
||||
[Constructible]
|
||||
public HagApprenticeCorpse() : base(GetOwner(), []) => Direction = Direction.South;
|
||||
|
||||
private static Mobile GetOwner()
|
||||
{
|
||||
[Constructible]
|
||||
public HagApprenticeCorpse() : base(GetOwner(), GetEquipment())
|
||||
var apprentice = new Mobile
|
||||
{
|
||||
Direction = Direction.South;
|
||||
Hue = Race.Human.RandomSkinHue(),
|
||||
Female = false,
|
||||
Body = 0x190
|
||||
};
|
||||
|
||||
foreach (var item in EquipItems)
|
||||
apprentice.Delete();
|
||||
|
||||
return apprentice;
|
||||
}
|
||||
|
||||
public override void AddNameProperty(IPropertyList list)
|
||||
{
|
||||
list.Add("a charred corpse");
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
var hue = Notoriety.GetHue(NotorietyHandlers.CorpseNotoriety(from, this));
|
||||
|
||||
from.NetState.SendMessage(Serial, ItemID, MessageType.Label, hue, 3, true, null, "", "a charred corpse");
|
||||
}
|
||||
|
||||
public override void Open(Mobile from, bool checkSelfLoot)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (from is PlayerMobile player)
|
||||
{
|
||||
var qs = player.Quest;
|
||||
|
||||
if (qs is WitchApprenticeQuest)
|
||||
{
|
||||
DropItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public HagApprenticeCorpse(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: What is this? Why are we creating a mobile and deleting it?
|
||||
private static Mobile GetOwner()
|
||||
{
|
||||
var apprentice = new Mobile();
|
||||
|
||||
apprentice.Hue = Race.Human.RandomSkinHue();
|
||||
apprentice.Female = false;
|
||||
apprentice.Body = 0x190;
|
||||
|
||||
apprentice.Delete();
|
||||
|
||||
return apprentice;
|
||||
}
|
||||
|
||||
private static List<Item> GetEquipment() => new();
|
||||
|
||||
public override void AddNameProperty(IPropertyList list)
|
||||
{
|
||||
list.Add("a charred corpse");
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
var hue = Notoriety.GetHue(NotorietyHandlers.CorpseNotoriety(from, this));
|
||||
|
||||
from.NetState.SendMessage(Serial, ItemID, MessageType.Label, hue, 3, true, null, "", "a charred corpse");
|
||||
}
|
||||
|
||||
public override void Open(Mobile from, bool checkSelfLoot)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (from is PlayerMobile player)
|
||||
{
|
||||
var qs = player.Quest;
|
||||
|
||||
if (qs is WitchApprenticeQuest)
|
||||
var obj = qs.FindObjective<FindApprenticeObjective>();
|
||||
if (obj?.Completed == false)
|
||||
{
|
||||
var obj = qs.FindObjective<FindApprenticeObjective>();
|
||||
if (obj?.Completed == false)
|
||||
if (obj.Corpse == this)
|
||||
{
|
||||
if (obj.Corpse == this)
|
||||
{
|
||||
obj.Complete();
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendLocalizedMessageTo(
|
||||
from,
|
||||
1055047
|
||||
); // You examine the corpse, but it doesn't fit the description of the particular apprentice the Hag tasked you with finding.
|
||||
}
|
||||
|
||||
return;
|
||||
obj.Complete();
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
// You examine the corpse, but it doesn't fit the description of the particular apprentice the Hag tasked you with finding.
|
||||
SendLocalizedMessageTo(from, 1055047);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SendLocalizedMessageTo(from, 1055048); // You examine the corpse, but find nothing of interest.
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
SendLocalizedMessageTo(from, 1055048); // You examine the corpse, but find nothing of interest.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,20 @@
|
|||
namespace Server.Items
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HagCauldron : BaseAddon
|
||||
{
|
||||
public class HagCauldron : BaseAddon
|
||||
[Constructible]
|
||||
public HagCauldron()
|
||||
{
|
||||
[Constructible]
|
||||
public HagCauldron()
|
||||
{
|
||||
AddonComponent pot;
|
||||
pot = new AddonComponent(2420);
|
||||
AddComponent(pot, 0, 0, 0); // pot w/ support
|
||||
AddonComponent pot;
|
||||
pot = new AddonComponent(2420);
|
||||
AddComponent(pot, 0, 0, 0); // pot w/ support
|
||||
|
||||
AddonComponent fire;
|
||||
fire = new AddonComponent(4012); // fire pit
|
||||
fire.Light = LightType.Circle150;
|
||||
AddComponent(fire, 0, 0, 0);
|
||||
}
|
||||
|
||||
public HagCauldron(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
AddonComponent fire;
|
||||
fire = new AddonComponent(4012); // fire pit
|
||||
fire.Light = LightType.Circle150;
|
||||
AddComponent(fire, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,52 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HagStew : BaseAddon
|
||||
{
|
||||
public class HagStew : BaseAddon
|
||||
[Constructible]
|
||||
public HagStew()
|
||||
{
|
||||
[Constructible]
|
||||
public HagStew()
|
||||
// stew
|
||||
AddComponent(new AddonComponent(2416)
|
||||
{
|
||||
AddonComponent stew;
|
||||
stew = new AddonComponent(2416);
|
||||
stew.Name = "stew";
|
||||
stew.Visible = true;
|
||||
AddComponent(stew, 0, 0, -7); // stew
|
||||
}
|
||||
Name = "stew",
|
||||
Visible = true
|
||||
}, 0, 0, -7);
|
||||
}
|
||||
|
||||
public HagStew(Serial serial) : base(serial)
|
||||
public override void OnComponentUsed(AddonComponent stew, Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.SendMessage("You are too far away.");
|
||||
}
|
||||
|
||||
public override void OnComponentUsed(AddonComponent stew, Mobile from)
|
||||
else
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
stew.Visible = false;
|
||||
|
||||
var hagstew = new BreadLoaf(); // this decides your fillrate
|
||||
hagstew.Eat(from);
|
||||
|
||||
Timer timer = new ShowStew(stew);
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public class ShowStew : Timer
|
||||
{
|
||||
private readonly AddonComponent _stew;
|
||||
|
||||
public ShowStew(AddonComponent ac) : base(TimeSpan.FromSeconds(30)) => _stew = ac;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (_stew.Visible == false)
|
||||
{
|
||||
from.SendMessage("You are too far away.");
|
||||
}
|
||||
else
|
||||
{
|
||||
stew.Visible = false;
|
||||
|
||||
var hagstew = new BreadLoaf(); // this decides your fillrate
|
||||
hagstew.Eat(from);
|
||||
|
||||
Timer m_timer = new ShowStew(stew);
|
||||
m_timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public class ShowStew : Timer
|
||||
{
|
||||
private readonly AddonComponent stew;
|
||||
|
||||
public ShowStew(AddonComponent ac) : base(TimeSpan.FromSeconds(30))
|
||||
{
|
||||
stew = ac;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (stew.Visible == false)
|
||||
{
|
||||
Stop();
|
||||
stew.Visible = true;
|
||||
}
|
||||
Stop();
|
||||
_stew.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,51 @@
|
|||
namespace Server.Engines.Quests.Hag
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Engines.Quests.Hag;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HangoverCure : Item
|
||||
{
|
||||
public class HangoverCure : Item
|
||||
[EncodedInt]
|
||||
[SerializableField(0)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private int _uses;
|
||||
|
||||
[Constructible]
|
||||
public HangoverCure() : base(0xE2B)
|
||||
{
|
||||
[Constructible]
|
||||
public HangoverCure() : base(0xE2B)
|
||||
{
|
||||
Weight = 1.0;
|
||||
Hue = 0x2D;
|
||||
Weight = 1.0;
|
||||
Hue = 0x2D;
|
||||
|
||||
Uses = 20;
|
||||
_uses = 20;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1055060; // Grizelda's Extra Strength Hangover Cure
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042038); // You must have the object in your backpack to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
public HangoverCure(Serial serial) : base(serial)
|
||||
if (Uses > 0)
|
||||
{
|
||||
from.PlaySound(0x2D6);
|
||||
from.SendLocalizedMessage(501206); // An awful taste fills your mouth.
|
||||
|
||||
if (from.BAC > 0)
|
||||
{
|
||||
from.BAC = 0;
|
||||
from.SendLocalizedMessage(501204); // You are now sober!
|
||||
}
|
||||
|
||||
Uses--;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1055060; // Grizelda's Extra Strength Hangover Cure
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Uses { get; set; }
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
else
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042038); // You must have the object in your backpack to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
if (Uses > 0)
|
||||
{
|
||||
from.PlaySound(0x2D6);
|
||||
from.SendLocalizedMessage(501206); // An awful taste fills your mouth.
|
||||
|
||||
if (from.BAC > 0)
|
||||
{
|
||||
from.BAC = 0;
|
||||
from.SendLocalizedMessage(501204); // You are now sober!
|
||||
}
|
||||
|
||||
Uses--;
|
||||
}
|
||||
else
|
||||
{
|
||||
Delete();
|
||||
from.SendLocalizedMessage(501201); // There wasn't enough left to have any effect.
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.WriteEncodedInt(Uses);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Uses = reader.ReadEncodedInt();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Uses = 20;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Delete();
|
||||
from.SendLocalizedMessage(501201); // There wasn't enough left to have any effect.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,12 @@
|
|||
namespace Server.Engines.Quests.Hag
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Engines.Quests.Hag;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class MoonfireBrew : Item
|
||||
{
|
||||
public class MoonfireBrew : Item
|
||||
{
|
||||
[Constructible]
|
||||
public MoonfireBrew() : base(0xF04) => Weight = 1.0;
|
||||
[Constructible]
|
||||
public MoonfireBrew() : base(0xF04) => Weight = 1.0;
|
||||
|
||||
public MoonfireBrew(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1055065; // a bottle of magical moonfire brew
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override int LabelNumber => 1055065; // a bottle of magical moonfire brew
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue