## 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.
166 lines
4.7 KiB
C#
166 lines
4.7 KiB
C#
using System;
|
|
using Server.Gumps;
|
|
using Server.Mobiles;
|
|
|
|
namespace Server.Engines.MLQuests.Objectives
|
|
{
|
|
[Flags]
|
|
public enum GainSkillObjectiveFlags : byte
|
|
{
|
|
None = 0x00,
|
|
UseReal = 0x01,
|
|
Accelerate = 0x02
|
|
}
|
|
|
|
public class GainSkillObjective : BaseObjective
|
|
{
|
|
private GainSkillObjectiveFlags m_Flags;
|
|
|
|
public GainSkillObjective(
|
|
SkillName skill = SkillName.Alchemy, int thresholdFixed = 0, bool useReal = false, bool accelerate = false
|
|
)
|
|
{
|
|
Skill = skill;
|
|
ThresholdFixed = thresholdFixed;
|
|
m_Flags = GainSkillObjectiveFlags.None;
|
|
|
|
if (useReal)
|
|
{
|
|
m_Flags |= GainSkillObjectiveFlags.UseReal;
|
|
}
|
|
|
|
if (accelerate)
|
|
{
|
|
m_Flags |= GainSkillObjectiveFlags.Accelerate;
|
|
}
|
|
}
|
|
|
|
public SkillName Skill { get; set; }
|
|
|
|
public int ThresholdFixed { get; set; }
|
|
|
|
public bool UseReal
|
|
{
|
|
get => GetFlag(GainSkillObjectiveFlags.UseReal);
|
|
set => SetFlag(GainSkillObjectiveFlags.UseReal, value);
|
|
}
|
|
|
|
public bool Accelerate
|
|
{
|
|
get => GetFlag(GainSkillObjectiveFlags.Accelerate);
|
|
set => SetFlag(GainSkillObjectiveFlags.Accelerate, value);
|
|
}
|
|
|
|
public override bool CanOffer(IQuestGiver quester, PlayerMobile pm, bool message)
|
|
{
|
|
var skill = pm.Skills[Skill];
|
|
|
|
if ((UseReal ? skill.Fixed : skill.BaseFixedPoint) >= ThresholdFixed)
|
|
{
|
|
if (message)
|
|
{
|
|
MLQuestSystem.Tell(quester, pm, 1077772); // I cannot teach you, for you know all I can teach!
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
|
|
{
|
|
var skillLabel = AosSkillBonuses.GetLabel(Skill);
|
|
var args = $"#{skillLabel}\t{ThresholdFixed / 10.0:0.#}";
|
|
|
|
builder.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x5F90); // Increase ~1_SKILL~ to ~2_VALUE~
|
|
y += 16;
|
|
}
|
|
|
|
public override BaseObjectiveInstance CreateInstance(MLQuestInstance instance) =>
|
|
new GainSkillObjectiveInstance(this, instance);
|
|
|
|
private bool GetFlag(GainSkillObjectiveFlags flag) => (m_Flags & flag) != 0;
|
|
|
|
private void SetFlag(GainSkillObjectiveFlags flag, bool value)
|
|
{
|
|
if (value)
|
|
{
|
|
m_Flags |= flag;
|
|
}
|
|
else
|
|
{
|
|
m_Flags &= ~flag;
|
|
}
|
|
}
|
|
}
|
|
|
|
// On OSI, once this is complete, it will *stay* complete, even if you lower your skill again
|
|
public class GainSkillObjectiveInstance : BaseObjectiveInstance
|
|
{
|
|
public GainSkillObjectiveInstance(GainSkillObjective objective, MLQuestInstance instance)
|
|
: base(instance, objective) =>
|
|
Objective = objective;
|
|
|
|
public GainSkillObjective Objective { get; set; }
|
|
|
|
public bool Handles(SkillName skill) => Objective.Skill == skill;
|
|
|
|
public override bool IsCompleted()
|
|
{
|
|
var pm = Instance.Player;
|
|
|
|
var valueFixed = Objective.UseReal
|
|
? pm.Skills[Objective.Skill].Fixed
|
|
: pm.Skills[Objective.Skill].BaseFixedPoint;
|
|
|
|
return valueFixed >= Objective.ThresholdFixed;
|
|
}
|
|
|
|
// TODO: This may interfere with scrolls, or even quests among each other
|
|
// How does OSI deal with this?
|
|
public override void OnQuestAccepted()
|
|
{
|
|
if (!Objective.Accelerate)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var pm = Instance.Player;
|
|
|
|
pm.AcceleratedSkill = Objective.Skill;
|
|
pm.AcceleratedStart = Core.Now + TimeSpan.FromMinutes(15); // TODO: Is there a max duration?
|
|
}
|
|
|
|
public override void OnQuestCancelled()
|
|
{
|
|
if (!Objective.Accelerate)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var pm = Instance.Player;
|
|
|
|
pm.AcceleratedStart = Core.Now;
|
|
pm.PlaySound(0x100);
|
|
}
|
|
|
|
public override void OnQuestCompleted()
|
|
{
|
|
OnQuestCancelled();
|
|
}
|
|
|
|
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
|
|
{
|
|
Objective.WriteToGump(ref builder, ref y);
|
|
|
|
base.WriteToGump(ref builder, ref y);
|
|
|
|
if (IsCompleted())
|
|
{
|
|
builder.AddHtmlLocalized(113, y, 312, 20, 1055121, 0x7FFF); // Complete
|
|
y += 16;
|
|
}
|
|
}
|
|
}
|
|
}
|