## Summary Migrates the Quest system gumps from legacy `Gump` to `DynamicGump` / `StaticGump<T>`. **Renames** `Engines/ML Quests/Gumps/BaseQuestGump` to **`BaseMLQuestGump`** to disambiguate from the Core quest abstract (`Engines/Quests/Core/QuestSystem.cs`). Both abstracts now extend `DynamicGump`. **Abstract bases**: - `Server.Engines.Quests.BaseQuestGump` (Core) - now `abstract DynamicGump`. Holds constants and a static `AddHtmlObject(ref DynamicGumpBuilder, ...)` helper. Concrete subclasses each provide their own `BuildLayout`. - `Server.Engines.MLQuests.Gumps.BaseMLQuestGump` (ML, renamed) - now `abstract DynamicGump` with a `protected abstract BuildContent(ref DynamicGumpBuilder)` hook. The base's `BuildLayout` draws shared chrome (background art, frame, label header) and then invokes `BuildContent`; subclasses use `BuildPage`, `SetTitle`, `RegisterButton`, `SetPageCount`, and content helpers (`AddDescription`, `AddObjectives`, `AddObjectivesProgress`, `AddRewardsPage`, `AddRewards`, `AddConversation`). **Concrete Core gumps** migrated to `DynamicGump`: - `QuestCancelGump`, `QuestOfferGump` (Core), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump`, `SheetMusicOfferGump` (Impresario), `PaintedImageGump` (renamed from `PaintedImage.InternalGump`). **Concrete ML gumps** migrated to `DynamicGump` (extending `BaseMLQuestGump` or directly): - `InfoNPCGump`, `QuestConversationGump`, `QuestLogDetailedGump`, `QuestLogGump`, `QuestOfferGump` (ML), `QuestReportBackGump`, `QuestRewardGump`, `QuestCancelConfirmGump`, `RaceChangeConfirmGump`. **`StaticGump<T>` migrations**: - `ScrollOfAbraxusGump` (Dark Tides). Its layout is a single hard-coded cliloc (1060116) with no per-instance dynamic content - safe to cache. **Cliloc rule**: Every other quest dialog bakes per-instance cliloc IDs into its layout (quest titles, NPC names, race-specific prompts, era-conditional progress messages, escort destinations). Per the cliloc rule, baking different cliloc numbers into a cached layout would defeat `StaticGump<T>` caching - so all of these are `DynamicGump`. **Signature changes** to support the migration: - `QuestObjective.RenderMessage`/`RenderProgress` now take `ref DynamicGumpBuilder builder` (15 overrides updated across Collector, Solen Matriarch, Ambitious Solen Queen, Study of the Solen Hive, Terrible Hatchlings, The Summoning, Uzeraan Turmoil, Witch Apprentice, Emino's Undertaking). - ML `BaseObjective.WriteToGump` / `BaseObjectiveInstance.WriteToGump` / `BaseReward.WriteToGump` now take `ref DynamicGumpBuilder` (KillObjective, GainSkillObjective, EscortObjective, CollectObjective, DeliverObjective, BaseReward). **Empty-gump and `Singleton` rules**: All concrete gumps now have private constructors with static `DisplayTo` entry points that null-check the player NetState before allocation. All gumps that shouldn't stack are `Singleton => true`. **External callers updated**: `MLQuest.SendOffer`/`OnRefuse`, `MLQuestEntry.SendProgressGump`/`SendRewardGump`/`SendReportBackGump`, `MLQuestSystem.QuestGumpRequest` and `ViewQuestsCommand`, `BoonCollector` (Darius/Nedrick), `SirHelper.OnDoubleClick` (no longer caches a single shared `InfoNPCGump` instance - `DisplayTo` constructs one per click and the gump's `Singleton => true` handles deduplication), `RaceChangeDeed.OnDoubleClick`, `PaintedImage.OnDoubleClick`, `ScrollOfAbraxus.OnDoubleClick`, `Impresario.OnTalk`, and `PlayerMobile`'s `BaseQuestGump` alias is now `BaseMLQuestGump`. **Concrete subclasses found beyond the listed entry points**: `SheetMusicOfferGump` (in Impresario.cs), `PaintedImageGump` (was `PaintedImage.InternalGump`), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump` (the Core base has these embedded across `QuestSystem.cs`/`QuestObjective.cs`/`QuestConversation.cs`/`QuestItemInfo.cs`). **Code-standards cleanup**: Renamed legacy `m_X` private fields to `_x` in rewritten files; braces on all control flow.
128 lines
2.9 KiB
C#
128 lines
2.9 KiB
C#
using System;
|
|
using ModernUO.Serialization;
|
|
using Server.Engines.MLQuests.Gumps;
|
|
using Server.Items;
|
|
using Server.Mobiles;
|
|
using Server.Network;
|
|
|
|
namespace Server.Engines.MLQuests.Mobiles;
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class SirHelper : Mage
|
|
{
|
|
private static readonly TimeSpan m_ShoutDelay = TimeSpan.FromSeconds(20);
|
|
|
|
private static readonly TimeSpan
|
|
m_ShoutCooldown = TimeSpan.FromDays(1); // TODO: Verify, could be a lot longer... or until a restart even
|
|
|
|
private DateTime m_NextShout;
|
|
|
|
[Constructible]
|
|
public SirHelper()
|
|
{
|
|
Title = "the Profession Guide"; // TODO: Don't display in paperdoll
|
|
|
|
Hue = 0x83EA;
|
|
|
|
Direction = Direction.South;
|
|
Frozen = true;
|
|
}
|
|
|
|
public override string DefaultName => "Sir Helper";
|
|
public override bool IsActiveVendor => false;
|
|
|
|
public override void InitSBInfo()
|
|
{
|
|
}
|
|
|
|
public override bool GetGender() => false;
|
|
|
|
public override void CheckMorph()
|
|
{
|
|
}
|
|
|
|
public override void InitOutfit()
|
|
{
|
|
HairItemID = 0x203C;
|
|
FacialHairItemID = 0x204D;
|
|
HairHue = FacialHairHue = 0x8A7;
|
|
|
|
AddItem(new Sandals());
|
|
|
|
AddItem(new Cloak
|
|
{
|
|
ItemID = 0x26AD,
|
|
Hue = 0x455
|
|
});
|
|
|
|
AddItem(new Robe
|
|
{
|
|
ItemID = 0x26AE,
|
|
Hue = 0x4AB
|
|
});
|
|
|
|
AddItem(new Backpack
|
|
{
|
|
Movable = false
|
|
});
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (from.BeginAction(this))
|
|
{
|
|
Timer.StartTimer(m_ShoutCooldown, () => EndLock(from));
|
|
}
|
|
|
|
MLQuestSystem.TurnToFace(this, from);
|
|
InfoNPCGump.DisplayTo(from, 1078029, 1078028);
|
|
|
|
// Paperdoll doesn't open
|
|
// base.OnDoubleClick( from );
|
|
}
|
|
|
|
public override void OnThink()
|
|
{
|
|
base.OnThink();
|
|
|
|
if (m_NextShout > Core.Now)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")].InitializePacket();
|
|
|
|
foreach (var state in GetClientsInRange(12))
|
|
{
|
|
var m = state.Mobile;
|
|
|
|
if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
|
|
{
|
|
// Double Click On Me For Help!
|
|
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
|
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
|
|
);
|
|
|
|
if (length != buffer.Length)
|
|
{
|
|
buffer = buffer[..length];
|
|
}
|
|
|
|
state.Send(buffer);
|
|
}
|
|
}
|
|
|
|
m_NextShout = Core.Now + m_ShoutDelay;
|
|
}
|
|
|
|
private void EndLock(Mobile m)
|
|
{
|
|
m.EndAction(this);
|
|
}
|
|
|
|
[AfterDeserialization]
|
|
private void AfterDeserialization()
|
|
{
|
|
Frozen = true;
|
|
}
|
|
}
|