ModernUO/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs
Kamron Batman e994505ad0
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.
2024-02-18 19:33:08 -08:00

59 lines
1.7 KiB
C#

using ModernUO.Serialization;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Quests.Necro;
[SerializationGenerator(0, false)]
public partial class KronusScrollBox : MetalBox
{
[Constructible]
public KronusScrollBox()
{
ItemID = 0xE80;
Movable = false;
for (var i = 0; i < 40; i++)
{
Item scroll = Loot.RandomScroll(0, 15, SpellbookType.Necromancer);
scroll.Movable = false;
DropItem(scroll);
}
}
public override void OnDoubleClick(Mobile from)
{
if (from is PlayerMobile pm && pm.InRange(GetWorldLocation(), 2))
{
var qs = pm.Quest;
if (qs is DarkTidesQuest)
{
var obj = qs.FindObjective<FindCallingScrollObjective>();
if (obj?.Completed == false || DarkTidesQuest.HasLostCallingScroll(from))
{
Item scroll = new KronusScroll();
if (pm.PlaceInBackpack(scroll))
{
// You rummage through the scrolls until you find the Scroll of Calling. You quickly put it in your pack.
pm.SendLocalizedMessage(1060120, "", 0x41);
if (obj?.Completed == false)
{
obj.Complete();
}
}
else
{
pm.SendLocalizedMessage(1060148, "", 0x41); // You were unable to take the scroll.
scroll.Delete();
}
}
}
}
base.OnDoubleClick(from);
}
}