Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -30,19 +30,17 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
{
|
||||
private struct ButtonInfo
|
||||
{
|
||||
private ButtonPosition m_Position;
|
||||
private ButtonGraphic m_Graphic;
|
||||
private int m_ButtonID;
|
||||
public ButtonPosition Position { get; }
|
||||
|
||||
public ButtonPosition Position => m_Position;
|
||||
public ButtonGraphic Graphic => m_Graphic;
|
||||
public int ButtonID => m_ButtonID;
|
||||
public ButtonGraphic Graphic { get; }
|
||||
|
||||
public int ButtonID { get; }
|
||||
|
||||
public ButtonInfo( ButtonPosition position, ButtonGraphic graphic, int buttonID )
|
||||
{
|
||||
m_Position = position;
|
||||
m_Graphic = graphic;
|
||||
m_ButtonID = buttonID;
|
||||
Position = position;
|
||||
Graphic = graphic;
|
||||
ButtonID = buttonID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ namespace Server.Engines.MLQuests.Items
|
|||
public class MLQuestTeleporter : Teleporter
|
||||
{
|
||||
private Type m_QuestType;
|
||||
private TextDefinition m_Message;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Type QuestType
|
||||
|
|
@ -17,11 +16,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TextDefinition Message
|
||||
{
|
||||
get => m_Message;
|
||||
set => m_Message = value;
|
||||
}
|
||||
public TextDefinition Message { get; set; }
|
||||
|
||||
[Constructible]
|
||||
public MLQuestTeleporter()
|
||||
|
|
@ -40,7 +35,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
: base(pointDest, mapDest)
|
||||
{
|
||||
m_QuestType = questType;
|
||||
m_Message = message;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public override bool CanTeleport(Mobile m)
|
||||
|
|
@ -58,7 +53,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
if (context?.IsDoingQuest(m_QuestType) == true || context?.HasDoneQuest(m_QuestType) == true)
|
||||
return true;
|
||||
|
||||
TextDefinition.SendMessageTo(m, m_Message);
|
||||
TextDefinition.SendMessageTo(m, Message);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
|
@ -83,7 +78,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((m_QuestType != null) ? m_QuestType.FullName : null);
|
||||
TextDefinition.Serialize(writer, m_Message);
|
||||
TextDefinition.Serialize(writer, Message);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
|
|
@ -97,7 +92,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
if (typeName != null)
|
||||
m_QuestType = ScriptCompiler.FindTypeByFullName(typeName, false);
|
||||
|
||||
m_Message = TextDefinition.Deserialize(reader);
|
||||
Message = TextDefinition.Deserialize(reader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +104,6 @@ namespace Server.Engines.MLQuests.Items
|
|||
public class TicketTeleporter : Teleporter
|
||||
{
|
||||
private Type m_TicketType;
|
||||
private TextDefinition m_Message;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Type TicketType
|
||||
|
|
@ -119,11 +113,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TextDefinition Message
|
||||
{
|
||||
get => m_Message;
|
||||
set => m_Message = value;
|
||||
}
|
||||
public TextDefinition Message { get; set; }
|
||||
|
||||
[Constructible]
|
||||
public TicketTeleporter()
|
||||
|
|
@ -142,7 +132,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
: base(pointDest, mapDest)
|
||||
{
|
||||
m_TicketType = ticketType;
|
||||
m_Message = message;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public override bool CanTeleport(Mobile m)
|
||||
|
|
@ -172,7 +162,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
|
||||
if (ticket == null)
|
||||
{
|
||||
TextDefinition.SendMessageTo(m, m_Message);
|
||||
TextDefinition.SendMessageTo(m, Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +192,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((m_TicketType != null) ? m_TicketType.FullName : null);
|
||||
TextDefinition.Serialize(writer, m_Message);
|
||||
TextDefinition.Serialize(writer, Message);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
|
|
@ -216,7 +206,7 @@ namespace Server.Engines.MLQuests.Items
|
|||
if (typeName != null)
|
||||
m_TicketType = ScriptCompiler.FindTypeByFullName(typeName, false);
|
||||
|
||||
m_Message = TextDefinition.Deserialize(reader);
|
||||
Message = TextDefinition.Deserialize(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,84 +15,29 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public class MLQuest
|
||||
{
|
||||
private bool m_Deserialized;
|
||||
private bool m_SaveEnabled;
|
||||
public bool Deserialized { get; set; }
|
||||
|
||||
public bool Deserialized
|
||||
{
|
||||
get => m_Deserialized;
|
||||
set => m_Deserialized = value;
|
||||
}
|
||||
|
||||
public bool SaveEnabled
|
||||
{
|
||||
get => m_SaveEnabled;
|
||||
set => m_SaveEnabled = value;
|
||||
}
|
||||
|
||||
private bool m_Activated;
|
||||
private List<BaseObjective> m_Objectives;
|
||||
private ObjectiveType m_ObjectiveType;
|
||||
private List<BaseReward> m_Rewards;
|
||||
|
||||
private List<MLQuestInstance> m_Instances;
|
||||
|
||||
private TextDefinition m_Title;
|
||||
private TextDefinition m_Description;
|
||||
private TextDefinition m_RefuseMessage;
|
||||
private TextDefinition m_InProgressMessage;
|
||||
private TextDefinition m_CompletionMessage;
|
||||
private TextDefinition m_CompletionNotice;
|
||||
public bool SaveEnabled { get; set; }
|
||||
|
||||
// TODO: Flags? (Deserialized, SaveEnabled, Activated)
|
||||
private bool m_OneTimeOnly;
|
||||
private bool m_HasRestartDelay;
|
||||
|
||||
public bool Activated
|
||||
{
|
||||
get => m_Activated;
|
||||
set => m_Activated = value;
|
||||
}
|
||||
public bool Activated { get; set; }
|
||||
|
||||
public List<BaseObjective> Objectives
|
||||
{
|
||||
get => m_Objectives;
|
||||
set => m_Objectives = value;
|
||||
}
|
||||
public List<BaseObjective> Objectives { get; set; }
|
||||
|
||||
public ObjectiveType ObjectiveType
|
||||
{
|
||||
get => m_ObjectiveType;
|
||||
set => m_ObjectiveType = value;
|
||||
}
|
||||
public ObjectiveType ObjectiveType { get; set; }
|
||||
|
||||
public List<BaseReward> Rewards
|
||||
{
|
||||
get => m_Rewards;
|
||||
set => m_Rewards = value;
|
||||
}
|
||||
public List<BaseReward> Rewards { get; set; }
|
||||
|
||||
public List<MLQuestInstance> Instances
|
||||
{
|
||||
get => m_Instances;
|
||||
set => m_Instances = value;
|
||||
}
|
||||
public List<MLQuestInstance> Instances { get; set; }
|
||||
|
||||
public bool OneTimeOnly
|
||||
{
|
||||
get => m_OneTimeOnly;
|
||||
set => m_OneTimeOnly = value;
|
||||
}
|
||||
public bool OneTimeOnly { get; set; }
|
||||
|
||||
public bool HasRestartDelay
|
||||
{
|
||||
get => m_HasRestartDelay;
|
||||
set => m_HasRestartDelay = value;
|
||||
}
|
||||
public bool HasRestartDelay { get; set; }
|
||||
|
||||
public bool HasObjective<T>() where T : BaseObjective
|
||||
{
|
||||
foreach ( BaseObjective obj in m_Objectives )
|
||||
foreach ( BaseObjective obj in Objectives )
|
||||
{
|
||||
if ( obj is T )
|
||||
return true;
|
||||
|
|
@ -107,29 +52,22 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public bool RequiresCollection => HasObjective<CollectObjective>() || HasObjective<DeliverObjective>();
|
||||
|
||||
public virtual bool RecordCompletion => ( m_OneTimeOnly || m_HasRestartDelay );
|
||||
public virtual bool RecordCompletion => ( OneTimeOnly || HasRestartDelay );
|
||||
|
||||
public virtual bool IsChainTriggered => false;
|
||||
public virtual Type NextQuest => null;
|
||||
|
||||
public TextDefinition Title { get => m_Title;
|
||||
set => m_Title = value;
|
||||
}
|
||||
public TextDefinition Description { get => m_Description;
|
||||
set => m_Description = value;
|
||||
}
|
||||
public TextDefinition RefusalMessage { get => m_RefuseMessage;
|
||||
set => m_RefuseMessage = value;
|
||||
}
|
||||
public TextDefinition InProgressMessage { get => m_InProgressMessage;
|
||||
set => m_InProgressMessage = value;
|
||||
}
|
||||
public TextDefinition CompletionMessage { get => m_CompletionMessage;
|
||||
set => m_CompletionMessage = value;
|
||||
}
|
||||
public TextDefinition CompletionNotice { get => m_CompletionNotice;
|
||||
set => m_CompletionNotice = value;
|
||||
}
|
||||
public TextDefinition Title { get; set; }
|
||||
|
||||
public TextDefinition Description { get; set; }
|
||||
|
||||
public TextDefinition RefusalMessage { get; set; }
|
||||
|
||||
public TextDefinition InProgressMessage { get; set; }
|
||||
|
||||
public TextDefinition CompletionMessage { get; set; }
|
||||
|
||||
public TextDefinition CompletionNotice { get; set; }
|
||||
|
||||
public static readonly TextDefinition CompletionNoticeDefault = new TextDefinition( 1072273 ); // You've completed a quest! Don't forget to collect your reward.
|
||||
public static readonly TextDefinition CompletionNoticeShort = new TextDefinition( 1046258 ); // Your quest is complete.
|
||||
|
|
@ -138,15 +76,15 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public MLQuest()
|
||||
{
|
||||
m_Activated = false;
|
||||
m_Objectives = new List<BaseObjective>();
|
||||
m_ObjectiveType = ObjectiveType.All;
|
||||
m_Rewards = new List<BaseReward>();
|
||||
m_CompletionNotice = CompletionNoticeDefault;
|
||||
Activated = false;
|
||||
Objectives = new List<BaseObjective>();
|
||||
ObjectiveType = ObjectiveType.All;
|
||||
Rewards = new List<BaseReward>();
|
||||
CompletionNotice = CompletionNoticeDefault;
|
||||
|
||||
m_Instances = new List<MLQuestInstance>();
|
||||
Instances = new List<MLQuestInstance>();
|
||||
|
||||
m_SaveEnabled = true;
|
||||
SaveEnabled = true;
|
||||
}
|
||||
|
||||
public virtual void Generate()
|
||||
|
|
@ -208,7 +146,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public virtual bool CanOffer( IQuestGiver quester, PlayerMobile pm, MLQuestContext context, bool message )
|
||||
{
|
||||
if ( !m_Activated || quester.Deleted )
|
||||
if ( !Activated || quester.Deleted )
|
||||
return false;
|
||||
|
||||
if ( context != null )
|
||||
|
|
@ -253,7 +191,7 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
}
|
||||
|
||||
foreach ( BaseObjective obj in m_Objectives )
|
||||
foreach ( BaseObjective obj in Objectives )
|
||||
{
|
||||
if ( !obj.CanOffer( quester, pm, message ) )
|
||||
return false;
|
||||
|
|
@ -333,7 +271,7 @@ namespace Server.Engines.MLQuests
|
|||
return; // not saved or no longer exists
|
||||
|
||||
quest.Refresh( oldVersion );
|
||||
quest.m_Deserialized = true;
|
||||
quest.Deserialized = true;
|
||||
}
|
||||
|
||||
public virtual int Version => 0;
|
||||
|
|
|
|||
|
|
@ -46,20 +46,17 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
}
|
||||
|
||||
private PlayerMobile m_Owner;
|
||||
private List<MLQuestInstance> m_QuestInstances;
|
||||
private List<MLDoneQuestInfo> m_DoneQuests;
|
||||
private List<MLQuest> m_ChainOffers;
|
||||
private MLQuestFlag m_Flags;
|
||||
|
||||
public PlayerMobile Owner => m_Owner;
|
||||
public PlayerMobile Owner { get; }
|
||||
|
||||
public List<MLQuestInstance> QuestInstances => m_QuestInstances;
|
||||
public List<MLQuestInstance> QuestInstances { get; }
|
||||
|
||||
public List<MLQuest> ChainOffers => m_ChainOffers;
|
||||
public List<MLQuest> ChainOffers { get; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool IsFull => m_QuestInstances.Count >= MLQuestSystem.MaxConcurrentQuests;
|
||||
public bool IsFull => QuestInstances.Count >= MLQuestSystem.MaxConcurrentQuests;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Spellweaving
|
||||
|
|
@ -91,10 +88,10 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public MLQuestContext( PlayerMobile owner )
|
||||
{
|
||||
m_Owner = owner;
|
||||
m_QuestInstances = new List<MLQuestInstance>();
|
||||
Owner = owner;
|
||||
QuestInstances = new List<MLQuestInstance>();
|
||||
m_DoneQuests = new List<MLDoneQuestInfo>();
|
||||
m_ChainOffers = new List<MLQuest>();
|
||||
ChainOffers = new List<MLQuest>();
|
||||
m_Flags = MLQuestFlag.None;
|
||||
}
|
||||
|
||||
|
|
@ -164,14 +161,14 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public void HandleDeath()
|
||||
{
|
||||
for ( int i = m_QuestInstances.Count - 1; i >= 0; --i )
|
||||
m_QuestInstances[i].OnPlayerDeath();
|
||||
for ( int i = QuestInstances.Count - 1; i >= 0; --i )
|
||||
QuestInstances[i].OnPlayerDeath();
|
||||
}
|
||||
|
||||
public void HandleDeletion()
|
||||
{
|
||||
for ( int i = m_QuestInstances.Count - 1; i >= 0; --i )
|
||||
m_QuestInstances[i].Remove();
|
||||
for ( int i = QuestInstances.Count - 1; i >= 0; --i )
|
||||
QuestInstances[i].Remove();
|
||||
}
|
||||
|
||||
public MLQuestInstance FindInstance( Type questType )
|
||||
|
|
@ -186,7 +183,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public MLQuestInstance FindInstance( MLQuest quest )
|
||||
{
|
||||
foreach ( MLQuestInstance instance in m_QuestInstances )
|
||||
foreach ( MLQuestInstance instance in QuestInstances )
|
||||
{
|
||||
if ( instance.Quest == quest )
|
||||
return instance;
|
||||
|
|
@ -211,10 +208,10 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
// Version info is written in MLQuestPersistence.Serialize
|
||||
|
||||
writer.WriteMobile<PlayerMobile>( m_Owner );
|
||||
writer.Write( m_QuestInstances.Count );
|
||||
writer.WriteMobile<PlayerMobile>( Owner );
|
||||
writer.Write( QuestInstances.Count );
|
||||
|
||||
foreach ( MLQuestInstance instance in m_QuestInstances )
|
||||
foreach ( MLQuestInstance instance in QuestInstances )
|
||||
instance.Serialize( writer );
|
||||
|
||||
writer.Write( m_DoneQuests.Count );
|
||||
|
|
@ -222,9 +219,9 @@ namespace Server.Engines.MLQuests
|
|||
foreach ( MLDoneQuestInfo info in m_DoneQuests )
|
||||
info.Serialize( writer );
|
||||
|
||||
writer.Write( m_ChainOffers.Count );
|
||||
writer.Write( ChainOffers.Count );
|
||||
|
||||
foreach ( MLQuest quest in m_ChainOffers )
|
||||
foreach ( MLQuest quest in ChainOffers )
|
||||
MLQuestSystem.WriteQuestRef( writer, quest );
|
||||
|
||||
writer.WriteEncodedInt( (int)m_Flags );
|
||||
|
|
@ -232,19 +229,19 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public MLQuestContext( GenericReader reader, int version )
|
||||
{
|
||||
m_Owner = reader.ReadMobile<PlayerMobile>();
|
||||
m_QuestInstances = new List<MLQuestInstance>();
|
||||
Owner = reader.ReadMobile<PlayerMobile>();
|
||||
QuestInstances = new List<MLQuestInstance>();
|
||||
m_DoneQuests = new List<MLDoneQuestInfo>();
|
||||
m_ChainOffers = new List<MLQuest>();
|
||||
ChainOffers = new List<MLQuest>();
|
||||
|
||||
int instances = reader.ReadInt();
|
||||
|
||||
for ( int i = 0; i < instances; ++i )
|
||||
{
|
||||
MLQuestInstance instance = MLQuestInstance.Deserialize( reader, version, m_Owner );
|
||||
MLQuestInstance instance = MLQuestInstance.Deserialize( reader, version, Owner );
|
||||
|
||||
if ( instance != null )
|
||||
m_QuestInstances.Add( instance );
|
||||
QuestInstances.Add( instance );
|
||||
}
|
||||
|
||||
int doneQuests = reader.ReadInt();
|
||||
|
|
@ -264,7 +261,7 @@ namespace Server.Engines.MLQuests
|
|||
MLQuest quest = MLQuestSystem.ReadQuestRef( reader );
|
||||
|
||||
if ( quest != null && quest.IsChainTriggered )
|
||||
m_ChainOffers.Add( quest );
|
||||
ChainOffers.Add( quest );
|
||||
}
|
||||
|
||||
m_Flags = (MLQuestFlag)reader.ReadEncodedInt();
|
||||
|
|
|
|||
|
|
@ -18,38 +18,31 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public class MLQuestInstance
|
||||
{
|
||||
private MLQuest m_Quest;
|
||||
|
||||
private IQuestGiver m_Quester;
|
||||
private Type m_QuesterType;
|
||||
private PlayerMobile m_Player;
|
||||
|
||||
private DateTime m_Accepted;
|
||||
private MLQuestInstanceFlags m_Flags;
|
||||
|
||||
private BaseObjectiveInstance[] m_ObjectiveInstances;
|
||||
|
||||
private Timer m_Timer;
|
||||
|
||||
public MLQuestInstance( MLQuest quest, IQuestGiver quester, PlayerMobile player )
|
||||
{
|
||||
m_Quest = quest;
|
||||
Quest = quest;
|
||||
|
||||
m_Quester = quester;
|
||||
m_QuesterType = quester?.GetType();
|
||||
m_Player = player;
|
||||
QuesterType = quester?.GetType();
|
||||
Player = player;
|
||||
|
||||
m_Accepted = DateTime.UtcNow;
|
||||
Accepted = DateTime.UtcNow;
|
||||
m_Flags = MLQuestInstanceFlags.None;
|
||||
|
||||
m_ObjectiveInstances = new BaseObjectiveInstance[quest.Objectives.Count];
|
||||
Objectives = new BaseObjectiveInstance[quest.Objectives.Count];
|
||||
|
||||
BaseObjectiveInstance obj;
|
||||
bool timed = false;
|
||||
|
||||
for ( int i = 0; i < quest.Objectives.Count; ++i )
|
||||
{
|
||||
m_ObjectiveInstances[i] = obj = quest.Objectives[i].CreateInstance( this );
|
||||
Objectives[i] = obj = quest.Objectives[i].CreateInstance( this );
|
||||
|
||||
if ( obj.IsTimed )
|
||||
timed = true;
|
||||
|
|
@ -63,27 +56,23 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
private void Register()
|
||||
{
|
||||
m_Quest?.Instances?.Add( this );
|
||||
Quest?.Instances?.Add( this );
|
||||
|
||||
if ( m_Player != null )
|
||||
if ( Player != null )
|
||||
PlayerContext.QuestInstances.Add( this );
|
||||
}
|
||||
|
||||
private void Unregister()
|
||||
{
|
||||
m_Quest?.Instances?.Remove( this );
|
||||
Quest?.Instances?.Remove( this );
|
||||
|
||||
if ( m_Player != null )
|
||||
if ( Player != null )
|
||||
PlayerContext.QuestInstances.Remove( this );
|
||||
|
||||
Removed = true;
|
||||
}
|
||||
|
||||
public MLQuest Quest
|
||||
{
|
||||
get => m_Quest;
|
||||
set => m_Quest = value;
|
||||
}
|
||||
public MLQuest Quest { get; set; }
|
||||
|
||||
public IQuestGiver Quester
|
||||
{
|
||||
|
|
@ -91,25 +80,17 @@ namespace Server.Engines.MLQuests
|
|||
set
|
||||
{
|
||||
m_Quester = value;
|
||||
m_QuesterType = value?.GetType();
|
||||
QuesterType = value?.GetType();
|
||||
}
|
||||
}
|
||||
|
||||
public Type QuesterType => m_QuesterType;
|
||||
public Type QuesterType { get; private set; }
|
||||
|
||||
public PlayerMobile Player
|
||||
{
|
||||
get => m_Player;
|
||||
set => m_Player = value;
|
||||
}
|
||||
public PlayerMobile Player { get; set; }
|
||||
|
||||
public MLQuestContext PlayerContext => MLQuestSystem.GetOrCreateContext( m_Player );
|
||||
public MLQuestContext PlayerContext => MLQuestSystem.GetOrCreateContext( Player );
|
||||
|
||||
public DateTime Accepted
|
||||
{
|
||||
get => m_Accepted;
|
||||
set => m_Accepted = value;
|
||||
}
|
||||
public DateTime Accepted { get; set; }
|
||||
|
||||
public bool ClaimReward
|
||||
{
|
||||
|
|
@ -129,15 +110,11 @@ namespace Server.Engines.MLQuests
|
|||
set => SetFlag( MLQuestInstanceFlags.Failed, value );
|
||||
}
|
||||
|
||||
public BaseObjectiveInstance[] Objectives
|
||||
{
|
||||
get => m_ObjectiveInstances;
|
||||
set => m_ObjectiveInstances = value;
|
||||
}
|
||||
public BaseObjectiveInstance[] Objectives { get; set; }
|
||||
|
||||
public bool AllowsQuestItem( Item item, Type type )
|
||||
{
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
{
|
||||
if ( !objective.Expired && objective.AllowsQuestItem( item, type ) )
|
||||
return true;
|
||||
|
|
@ -148,9 +125,9 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public bool IsCompleted()
|
||||
{
|
||||
bool requiresAll = ( m_Quest.ObjectiveType == ObjectiveType.All );
|
||||
bool requiresAll = ( Quest.ObjectiveType == ObjectiveType.All );
|
||||
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
{
|
||||
bool complete = obj.IsCompleted();
|
||||
|
||||
|
|
@ -167,12 +144,12 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
if ( IsCompleted() )
|
||||
{
|
||||
m_Player.PlaySound( 0x5B5 ); // public sound
|
||||
Player.PlaySound( 0x5B5 ); // public sound
|
||||
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
obj.OnQuestCompleted();
|
||||
|
||||
TextDefinition.SendMessageTo( m_Player, m_Quest.CompletionNotice, 0x23 );
|
||||
TextDefinition.SendMessageTo( Player, Quest.CompletionNotice, 0x23 );
|
||||
|
||||
/*
|
||||
* Advance to the ClaimReward=true stage if this quest has no
|
||||
|
|
@ -182,7 +159,7 @@ namespace Server.Engines.MLQuests
|
|||
* For quests that require collections, this is done later when
|
||||
* the player double clicks the quester.
|
||||
*/
|
||||
if ( !Removed && SkipReportBack && !m_Quest.RequiresCollection ) // An OnQuestCompleted can potentially have removed this instance already
|
||||
if ( !Removed && SkipReportBack && !Quest.RequiresCollection ) // An OnQuestCompleted can potentially have removed this instance already
|
||||
ContinueReportBack( false );
|
||||
}
|
||||
}
|
||||
|
|
@ -203,13 +180,13 @@ namespace Server.Engines.MLQuests
|
|||
bool hasAnyFails = false;
|
||||
bool hasAnyLeft = false;
|
||||
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
{
|
||||
if ( !obj.Expired )
|
||||
{
|
||||
if ( obj.IsTimed && obj.EndTime <= DateTime.UtcNow )
|
||||
{
|
||||
m_Player.SendLocalizedMessage( 1072258 ); // You failed to complete an objective in time!
|
||||
Player.SendLocalizedMessage( 1072258 ); // You failed to complete an objective in time!
|
||||
|
||||
obj.Expired = true;
|
||||
obj.OnExpire();
|
||||
|
|
@ -223,7 +200,7 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
}
|
||||
|
||||
if ( ( m_Quest.ObjectiveType == ObjectiveType.All && hasAnyFails ) || !hasAnyLeft )
|
||||
if ( ( Quest.ObjectiveType == ObjectiveType.All && hasAnyFails ) || !hasAnyLeft )
|
||||
Fail();
|
||||
|
||||
if ( !hasAnyLeft )
|
||||
|
|
@ -232,18 +209,18 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public void SendProgressGump()
|
||||
{
|
||||
m_Player.SendGump( new QuestConversationGump( m_Quest, m_Player, m_Quest.InProgressMessage ) );
|
||||
Player.SendGump( new QuestConversationGump( Quest, Player, Quest.InProgressMessage ) );
|
||||
}
|
||||
|
||||
public void SendRewardOffer()
|
||||
{
|
||||
m_Quest.GetRewards( this );
|
||||
Quest.GetRewards( this );
|
||||
}
|
||||
|
||||
// TODO: Split next quest stuff from SendRewardGump stuff?
|
||||
public void SendRewardGump()
|
||||
{
|
||||
Type nextQuestType = m_Quest.NextQuest;
|
||||
Type nextQuestType = Quest.NextQuest;
|
||||
|
||||
if ( nextQuestType != null )
|
||||
{
|
||||
|
|
@ -253,45 +230,45 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
MLQuest nextQuest = MLQuestSystem.FindQuest( nextQuestType );
|
||||
|
||||
nextQuest?.SendOffer( m_Quester, m_Player );
|
||||
nextQuest?.SendOffer( m_Quester, Player );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Player.SendGump( new QuestRewardGump( this ) );
|
||||
Player.SendGump( new QuestRewardGump( this ) );
|
||||
}
|
||||
}
|
||||
|
||||
public bool SkipReportBack => TextDefinition.IsNullOrEmpty( m_Quest.CompletionMessage );
|
||||
public bool SkipReportBack => TextDefinition.IsNullOrEmpty( Quest.CompletionMessage );
|
||||
|
||||
public void SendReportBackGump()
|
||||
{
|
||||
if ( SkipReportBack )
|
||||
ContinueReportBack( true ); // skip ahead
|
||||
else
|
||||
m_Player.SendGump( new QuestReportBackGump( this ) );
|
||||
Player.SendGump( new QuestReportBackGump( this ) );
|
||||
}
|
||||
|
||||
public void ContinueReportBack( bool sendRewardGump )
|
||||
{
|
||||
// There is a backpack check here on OSI for the rewards as well (even though it's not needed...)
|
||||
|
||||
if ( m_Quest.ObjectiveType == ObjectiveType.All )
|
||||
if ( Quest.ObjectiveType == ObjectiveType.All )
|
||||
{
|
||||
// TODO: 1115877 - You no longer have the required items to complete this quest.
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
{
|
||||
if ( !objective.IsCompleted() )
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
{
|
||||
if ( !objective.OnBeforeClaimReward() )
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
objective.OnClaimReward();
|
||||
}
|
||||
else
|
||||
|
|
@ -302,7 +279,7 @@ namespace Server.Engines.MLQuests
|
|||
*/
|
||||
bool complete = false;
|
||||
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
{
|
||||
if ( objective.IsCompleted() )
|
||||
{
|
||||
|
|
@ -322,11 +299,11 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
ClaimReward = true;
|
||||
|
||||
if ( m_Quest.HasRestartDelay )
|
||||
PlayerContext.SetDoneQuest( m_Quest, DateTime.UtcNow + m_Quest.GetRestartDelay() );
|
||||
if ( Quest.HasRestartDelay )
|
||||
PlayerContext.SetDoneQuest( Quest, DateTime.UtcNow + Quest.GetRestartDelay() );
|
||||
|
||||
// This is correct for ObjectiveType.Any as well
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
objective.OnAfterClaimReward();
|
||||
|
||||
if ( sendRewardGump )
|
||||
|
|
@ -335,13 +312,13 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public void ClaimRewards()
|
||||
{
|
||||
if ( m_Quest == null || m_Player == null || m_Player.Deleted || !ClaimReward || Removed )
|
||||
if ( Quest == null || Player == null || Player.Deleted || !ClaimReward || Removed )
|
||||
return;
|
||||
|
||||
List<Item> rewards = new List<Item>();
|
||||
|
||||
foreach ( BaseReward reward in m_Quest.Rewards )
|
||||
reward.AddRewardItems( m_Player, rewards );
|
||||
foreach ( BaseReward reward in Quest.Rewards )
|
||||
reward.AddRewardItems( Player, rewards );
|
||||
|
||||
if ( rewards.Count != 0 )
|
||||
{
|
||||
|
|
@ -351,7 +328,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
foreach ( Item rewardItem in rewards )
|
||||
{
|
||||
if ( !m_Player.AddToBackpack( rewardItem ) )
|
||||
if ( !Player.AddToBackpack( rewardItem ) )
|
||||
{
|
||||
canFit = false;
|
||||
break;
|
||||
|
|
@ -363,7 +340,7 @@ namespace Server.Engines.MLQuests
|
|||
foreach ( Item rewardItem in rewards )
|
||||
rewardItem.Delete();
|
||||
|
||||
m_Player.SendLocalizedMessage( 1078524 ); // Your backpack is full. You cannot complete the quest and receive your reward.
|
||||
Player.SendLocalizedMessage( 1078524 ); // Your backpack is full. You cannot complete the quest and receive your reward.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -372,26 +349,26 @@ namespace Server.Engines.MLQuests
|
|||
string rewardName = rewardItem.Name ?? string.Concat( "#", rewardItem.LabelNumber );
|
||||
|
||||
if ( rewardItem.Stackable )
|
||||
m_Player.SendLocalizedMessage( 1115917, string.Concat( rewardItem.Amount, "\t", rewardName ) ); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
|
||||
Player.SendLocalizedMessage( 1115917, string.Concat( rewardItem.Amount, "\t", rewardName ) ); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
|
||||
else
|
||||
m_Player.SendLocalizedMessage( 1074360, rewardName ); // You receive a reward: ~1_REWARD~
|
||||
Player.SendLocalizedMessage( 1074360, rewardName ); // You receive a reward: ~1_REWARD~
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( BaseObjectiveInstance objective in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objective in Objectives )
|
||||
objective.OnRewardClaimed();
|
||||
|
||||
m_Quest.OnRewardClaimed( this );
|
||||
Quest.OnRewardClaimed( this );
|
||||
|
||||
MLQuestContext context = PlayerContext;
|
||||
|
||||
if ( m_Quest.RecordCompletion && !m_Quest.HasRestartDelay ) // Quests with restart delays are logged earlier as per OSI
|
||||
context.SetDoneQuest( m_Quest );
|
||||
if ( Quest.RecordCompletion && !Quest.HasRestartDelay ) // Quests with restart delays are logged earlier as per OSI
|
||||
context.SetDoneQuest( Quest );
|
||||
|
||||
if ( m_Quest.IsChainTriggered )
|
||||
context.ChainOffers.Remove( m_Quest );
|
||||
if ( Quest.IsChainTriggered )
|
||||
context.ChainOffers.Remove( Quest );
|
||||
|
||||
Type nextQuestType = m_Quest.NextQuest;
|
||||
Type nextQuestType = Quest.NextQuest;
|
||||
|
||||
if ( nextQuestType != null )
|
||||
{
|
||||
|
|
@ -413,15 +390,15 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
Remove();
|
||||
|
||||
m_Player.SendSound( 0x5B3 ); // private sound
|
||||
Player.SendSound( 0x5B3 ); // private sound
|
||||
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
obj.OnQuestCancelled();
|
||||
|
||||
m_Quest.OnCancel( this );
|
||||
Quest.OnCancel( this );
|
||||
|
||||
if ( removeChain )
|
||||
PlayerContext.ChainOffers.Remove( m_Quest );
|
||||
PlayerContext.ChainOffers.Remove( Quest );
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
|
|
@ -441,18 +418,18 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public void OnQuesterDeleted()
|
||||
{
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
obj.OnQuesterDeleted();
|
||||
|
||||
m_Quest.OnQuesterDeleted( this );
|
||||
Quest.OnQuesterDeleted( this );
|
||||
}
|
||||
|
||||
public void OnPlayerDeath()
|
||||
{
|
||||
foreach ( BaseObjectiveInstance obj in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance obj in Objectives )
|
||||
obj.OnPlayerDeath();
|
||||
|
||||
m_Quest.OnPlayerDeath( this );
|
||||
Quest.OnPlayerDeath( this );
|
||||
}
|
||||
|
||||
private bool GetFlag( MLQuestInstanceFlags flag )
|
||||
|
|
@ -472,7 +449,7 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
// Version info is written in MLQuestPersistence.Serialize
|
||||
|
||||
MLQuestSystem.WriteQuestRef( writer, m_Quest );
|
||||
MLQuestSystem.WriteQuestRef( writer, Quest );
|
||||
|
||||
if ( m_Quester == null || m_Quester.Deleted )
|
||||
writer.Write( Serial.MinusOne );
|
||||
|
|
@ -480,9 +457,9 @@ namespace Server.Engines.MLQuests
|
|||
writer.Write( m_Quester.Serial );
|
||||
|
||||
writer.Write( ClaimReward );
|
||||
writer.Write( m_ObjectiveInstances.Length );
|
||||
writer.Write( Objectives.Length );
|
||||
|
||||
foreach ( BaseObjectiveInstance objInstance in m_ObjectiveInstances )
|
||||
foreach ( BaseObjectiveInstance objInstance in Objectives )
|
||||
objInstance.Serialize( writer );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,23 +23,19 @@ namespace Server.Engines.MLQuests
|
|||
public static readonly bool AutoGenerateNew = true;
|
||||
public static readonly bool Debug = false;
|
||||
|
||||
private static Dictionary<Type, MLQuest> m_Quests;
|
||||
private static Dictionary<Type, List<MLQuest>> m_QuestGivers;
|
||||
private static Dictionary<PlayerMobile, MLQuestContext> m_Contexts;
|
||||
|
||||
public static readonly List<MLQuest> EmptyList = new List<MLQuest>();
|
||||
|
||||
public static Dictionary<Type, MLQuest> Quests => m_Quests;
|
||||
public static Dictionary<Type, MLQuest> Quests { get; }
|
||||
|
||||
public static Dictionary<Type, List<MLQuest>> QuestGivers => m_QuestGivers;
|
||||
public static Dictionary<Type, List<MLQuest>> QuestGivers { get; }
|
||||
|
||||
public static Dictionary<PlayerMobile, MLQuestContext> Contexts => m_Contexts;
|
||||
public static Dictionary<PlayerMobile, MLQuestContext> Contexts { get; }
|
||||
|
||||
static MLQuestSystem()
|
||||
{
|
||||
m_Quests = new Dictionary<Type, MLQuest>();
|
||||
m_QuestGivers = new Dictionary<Type, List<MLQuest>>();
|
||||
m_Contexts = new Dictionary<PlayerMobile, MLQuestContext>();
|
||||
Quests = new Dictionary<Type, MLQuest>();
|
||||
QuestGivers = new Dictionary<Type, List<MLQuest>>();
|
||||
Contexts = new Dictionary<PlayerMobile, MLQuestContext>();
|
||||
|
||||
string cfgPath = Path.Combine( Core.BaseDirectory, Path.Combine( "Data", "MLQuests.cfg" ) );
|
||||
|
||||
|
|
@ -103,13 +99,13 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
private static void Register( Type type, MLQuest quest )
|
||||
{
|
||||
m_Quests[type] = quest;
|
||||
Quests[type] = quest;
|
||||
}
|
||||
|
||||
private static void RegisterQuestGiver( MLQuest quest, Type questerType )
|
||||
{
|
||||
if (!m_QuestGivers.TryGetValue( questerType, out List<MLQuest> questList ))
|
||||
m_QuestGivers[questerType] = questList = new List<MLQuest>();
|
||||
if (!QuestGivers.TryGetValue( questerType, out List<MLQuest> questList ))
|
||||
QuestGivers[questerType] = questList = new List<MLQuest>();
|
||||
|
||||
questList.Add( quest );
|
||||
}
|
||||
|
|
@ -129,7 +125,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
if ( AutoGenerateNew )
|
||||
{
|
||||
foreach ( MLQuest quest in m_Quests.Values )
|
||||
foreach ( MLQuest quest in Quests.Values )
|
||||
{
|
||||
if ( quest != null && !quest.Deserialized )
|
||||
quest.Generate();
|
||||
|
|
@ -157,14 +153,14 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
if ( e.Length == 0 )
|
||||
{
|
||||
m.SendMessage( "Quest table length: {0}", m_Quests.Count );
|
||||
m.SendMessage( "Quest table length: {0}", Quests.Count );
|
||||
return;
|
||||
}
|
||||
|
||||
Type index = ScriptCompiler.FindTypeByName( e.GetString( 0 ) );
|
||||
MLQuest quest;
|
||||
|
||||
if ( index == null || !m_Quests.TryGetValue( index, out quest ) )
|
||||
if ( index == null || !Quests.TryGetValue( index, out quest ) )
|
||||
{
|
||||
m.SendMessage( "Invalid quest type name." );
|
||||
return;
|
||||
|
|
@ -238,7 +234,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
Type index = ScriptCompiler.FindTypeByName( e.GetString( 0 ) );
|
||||
|
||||
if ( index == null || !m_Quests.TryGetValue( index, out MLQuest quest ) )
|
||||
if ( index == null || !Quests.TryGetValue( index, out MLQuest quest ) )
|
||||
{
|
||||
m.SendMessage( "Invalid quest type name." );
|
||||
return;
|
||||
|
|
@ -267,7 +263,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
bool enable = ( e.Length == 1 ) ? e.GetBoolean( 0 ) : true;
|
||||
|
||||
foreach ( MLQuest quest in m_Quests.Values )
|
||||
foreach ( MLQuest quest in Quests.Values )
|
||||
quest.SaveEnabled = enable;
|
||||
|
||||
m.SendMessage( "Serialization for all quests is now {0}.", enable ? "enabled" : "disabled" );
|
||||
|
|
@ -561,15 +557,15 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public static MLQuestContext GetContext( PlayerMobile pm )
|
||||
{
|
||||
m_Contexts.TryGetValue( pm, out MLQuestContext context );
|
||||
Contexts.TryGetValue( pm, out MLQuestContext context );
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
public static MLQuestContext GetOrCreateContext( PlayerMobile pm )
|
||||
{
|
||||
if (!m_Contexts.TryGetValue( pm, out MLQuestContext context ))
|
||||
m_Contexts[pm] = context = new MLQuestContext( pm );
|
||||
if (!Contexts.TryGetValue( pm, out MLQuestContext context ))
|
||||
Contexts[pm] = context = new MLQuestContext( pm );
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
@ -588,7 +584,7 @@ namespace Server.Engines.MLQuests
|
|||
if ( context != null )
|
||||
{
|
||||
context.HandleDeletion();
|
||||
m_Contexts.Remove( pm );
|
||||
Contexts.Remove( pm );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -725,14 +721,14 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public static MLQuest FindQuest( Type questType )
|
||||
{
|
||||
m_Quests.TryGetValue( questType, out MLQuest result );
|
||||
Quests.TryGetValue( questType, out MLQuest result );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<MLQuest> FindQuestList( Type questerType )
|
||||
{
|
||||
return m_QuestGivers.TryGetValue(questerType, out List<MLQuest> result) ? result : EmptyList;
|
||||
return QuestGivers.TryGetValue(questerType, out List<MLQuest> result) ? result : EmptyList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,38 +28,26 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public abstract class BaseObjectiveInstance
|
||||
{
|
||||
private MLQuestInstance m_Instance;
|
||||
private DateTime m_EndTime;
|
||||
private bool m_Expired;
|
||||
public MLQuestInstance Instance { get; }
|
||||
|
||||
public MLQuestInstance Instance => m_Instance;
|
||||
public bool IsTimed => ( EndTime != DateTime.MinValue );
|
||||
|
||||
public bool IsTimed => ( m_EndTime != DateTime.MinValue );
|
||||
public DateTime EndTime { get; set; }
|
||||
|
||||
public DateTime EndTime
|
||||
{
|
||||
get => m_EndTime;
|
||||
set => m_EndTime = value;
|
||||
}
|
||||
|
||||
public bool Expired
|
||||
{
|
||||
get => m_Expired;
|
||||
set => m_Expired = value;
|
||||
}
|
||||
public bool Expired { get; set; }
|
||||
|
||||
public BaseObjectiveInstance( MLQuestInstance instance, BaseObjective obj )
|
||||
{
|
||||
m_Instance = instance;
|
||||
Instance = instance;
|
||||
|
||||
if ( obj.IsTimed )
|
||||
m_EndTime = DateTime.UtcNow + obj.Duration;
|
||||
EndTime = DateTime.UtcNow + obj.Duration;
|
||||
}
|
||||
|
||||
public virtual void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
if ( IsTimed )
|
||||
WriteTimeRemaining( g, ref y, ( m_EndTime > DateTime.UtcNow ) ? ( m_EndTime - DateTime.UtcNow ) : TimeSpan.Zero );
|
||||
WriteTimeRemaining( g, ref y, ( EndTime > DateTime.UtcNow ) ? ( EndTime - DateTime.UtcNow ) : TimeSpan.Zero );
|
||||
}
|
||||
|
||||
public static void WriteTimeRemaining( Gump g, ref int y, TimeSpan timeRemaining )
|
||||
|
|
@ -83,8 +71,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
if ( IsCompleted() )
|
||||
{
|
||||
m_Instance.Player.PlaySound( 0x5B6 ); // public sound
|
||||
m_Instance.CheckComplete();
|
||||
Instance.Player.PlaySound( 0x5B6 ); // public sound
|
||||
Instance.CheckComplete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +134,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
if ( IsTimed )
|
||||
{
|
||||
writer.Write( true );
|
||||
writer.WriteDeltaTime( m_EndTime );
|
||||
writer.WriteDeltaTime( EndTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,27 +7,11 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
public class CollectObjective : BaseObjective
|
||||
{
|
||||
private int m_DesiredAmount;
|
||||
private Type m_AcceptedType;
|
||||
private TextDefinition m_Name;
|
||||
public int DesiredAmount { get; set; }
|
||||
|
||||
public int DesiredAmount
|
||||
{
|
||||
get => m_DesiredAmount;
|
||||
set => m_DesiredAmount = value;
|
||||
}
|
||||
public Type AcceptedType { get; set; }
|
||||
|
||||
public Type AcceptedType
|
||||
{
|
||||
get => m_AcceptedType;
|
||||
set => m_AcceptedType = value;
|
||||
}
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
public TextDefinition Name { get; set; }
|
||||
|
||||
public virtual bool ShowDetailed => true;
|
||||
|
||||
|
|
@ -38,9 +22,9 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public CollectObjective( int amount, Type type, TextDefinition name )
|
||||
{
|
||||
m_DesiredAmount = amount;
|
||||
m_AcceptedType = type;
|
||||
m_Name = name;
|
||||
DesiredAmount = amount;
|
||||
AcceptedType = type;
|
||||
Name = name;
|
||||
|
||||
if ( MLQuestSystem.Debug && ShowDetailed && name.Number > 0 )
|
||||
{
|
||||
|
|
@ -53,7 +37,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public bool CheckType( Type type )
|
||||
{
|
||||
return ( m_AcceptedType != null && m_AcceptedType.IsAssignableFrom( type ) );
|
||||
return ( AcceptedType != null && AcceptedType.IsAssignableFrom( type ) );
|
||||
}
|
||||
|
||||
public virtual bool CheckItem( Item item )
|
||||
|
|
@ -72,27 +56,27 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
if ( ShowDetailed )
|
||||
{
|
||||
string amount = m_DesiredAmount.ToString();
|
||||
string amount = DesiredAmount.ToString();
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 350, 16, 1072205, 0x15F90, false, false ); // Obtain
|
||||
g.AddLabel( 143, y, 0x481, amount );
|
||||
|
||||
if ( m_Name.Number > 0 )
|
||||
if ( Name.Number > 0 )
|
||||
{
|
||||
g.AddHtmlLocalized( 143 + amount.Length * 15, y, 190, 18, m_Name.Number, 0x77BF, false, false );
|
||||
g.AddItem( 350, y, LabelToItemID( m_Name.Number ) );
|
||||
g.AddHtmlLocalized( 143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false );
|
||||
g.AddItem( 350, y, LabelToItemID( Name.Number ) );
|
||||
}
|
||||
else if ( m_Name.String != null )
|
||||
else if ( Name.String != null )
|
||||
{
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, m_Name.String );
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, Name.String );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 98, y, 312, 32, m_Name.Number, 0x15F90, false, false );
|
||||
else if ( m_Name.String != null )
|
||||
g.AddLabel( 98, y, 0x481, m_Name.String );
|
||||
if ( Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 98, y, 312, 32, Name.Number, 0x15F90, false, false );
|
||||
else if ( Name.String != null )
|
||||
g.AddLabel( 98, y, 0x481, Name.String );
|
||||
}
|
||||
|
||||
y += 32;
|
||||
|
|
@ -108,15 +92,13 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class TimedCollectObjective : CollectObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed => true;
|
||||
public override TimeSpan Duration => m_Duration;
|
||||
public override TimeSpan Duration { get; }
|
||||
|
||||
public TimedCollectObjective( TimeSpan duration, int amount, Type type, TextDefinition name )
|
||||
: base( amount, type, name )
|
||||
{
|
||||
m_Duration = duration;
|
||||
Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,18 +106,12 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class CollectObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private CollectObjective m_Objective;
|
||||
|
||||
public CollectObjective Objective
|
||||
{
|
||||
get => m_Objective;
|
||||
set => m_Objective = value;
|
||||
}
|
||||
public CollectObjective Objective { get; set; }
|
||||
|
||||
public CollectObjectiveInstance( CollectObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
Objective = objective;
|
||||
}
|
||||
|
||||
private int GetCurrentTotal()
|
||||
|
|
@ -145,12 +121,12 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
if ( pack == null )
|
||||
return 0;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.AcceptedType, false ); // Note: subclasses are included
|
||||
Item[] items = pack.FindItemsByType( Objective.AcceptedType, false ); // Note: subclasses are included
|
||||
int total = 0;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( item.QuestItem && m_Objective.CheckItem( item ) )
|
||||
if ( item.QuestItem && Objective.CheckItem( item ) )
|
||||
total += item.Amount;
|
||||
}
|
||||
|
||||
|
|
@ -159,12 +135,12 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override bool AllowsQuestItem( Item item, Type type )
|
||||
{
|
||||
return ( m_Objective.CheckType( type ) && m_Objective.CheckItem( item ) );
|
||||
return ( Objective.CheckType( type ) && Objective.CheckItem( item ) );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return ( GetCurrentTotal() >= m_Objective.DesiredAmount );
|
||||
return ( GetCurrentTotal() >= Objective.DesiredAmount );
|
||||
}
|
||||
|
||||
public override void OnQuestCancelled()
|
||||
|
|
@ -175,7 +151,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
if ( pack == null )
|
||||
return;
|
||||
|
||||
Type checkType = m_Objective.AcceptedType;
|
||||
Type checkType = Objective.AcceptedType;
|
||||
Item[] items = pack.FindItemsByType( checkType, false );
|
||||
|
||||
foreach ( Item item in items )
|
||||
|
|
@ -195,12 +171,12 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
// TODO: OSI also counts the item in the cursor?
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.AcceptedType, false );
|
||||
int left = m_Objective.DesiredAmount;
|
||||
Item[] items = pack.FindItemsByType( Objective.AcceptedType, false );
|
||||
int left = Objective.DesiredAmount;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( item.QuestItem && m_Objective.CheckItem( item ) )
|
||||
if ( item.QuestItem && Objective.CheckItem( item ) )
|
||||
{
|
||||
if ( left == 0 )
|
||||
return;
|
||||
|
|
@ -233,10 +209,10 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
Objective.WriteToGump( g, ref y );
|
||||
y -= 16;
|
||||
|
||||
if ( m_Objective.ShowDetailed )
|
||||
if ( Objective.ShowDetailed )
|
||||
{
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
|
|
|
|||
|
|
@ -8,41 +8,15 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
public class DeliverObjective : BaseObjective
|
||||
{
|
||||
private Type m_Delivery;
|
||||
private int m_Amount;
|
||||
private TextDefinition m_Name;
|
||||
private Type m_Destination;
|
||||
private bool m_SpawnsDelivery;
|
||||
public Type Delivery { get; set; }
|
||||
|
||||
public Type Delivery
|
||||
{
|
||||
get => m_Delivery;
|
||||
set => m_Delivery = value;
|
||||
}
|
||||
public int Amount { get; set; }
|
||||
|
||||
public int Amount
|
||||
{
|
||||
get => m_Amount;
|
||||
set => m_Amount = value;
|
||||
}
|
||||
public TextDefinition Name { get; set; }
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
public Type Destination { get; set; }
|
||||
|
||||
public Type Destination
|
||||
{
|
||||
get => m_Destination;
|
||||
set => m_Destination = value;
|
||||
}
|
||||
|
||||
public bool SpawnsDelivery
|
||||
{
|
||||
get => m_SpawnsDelivery;
|
||||
set => m_SpawnsDelivery = value;
|
||||
}
|
||||
public bool SpawnsDelivery { get; set; }
|
||||
|
||||
public DeliverObjective( Type delivery, int amount, TextDefinition name, Type destination )
|
||||
: this( delivery, amount, name, destination, true )
|
||||
|
|
@ -51,11 +25,11 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public DeliverObjective( Type delivery, int amount, TextDefinition name, Type destination, bool spawnsDelivery )
|
||||
{
|
||||
m_Delivery = delivery;
|
||||
m_Amount = amount;
|
||||
m_Name = name;
|
||||
m_Destination = destination;
|
||||
m_SpawnsDelivery = spawnsDelivery;
|
||||
Delivery = delivery;
|
||||
Amount = amount;
|
||||
Name = name;
|
||||
Destination = destination;
|
||||
SpawnsDelivery = spawnsDelivery;
|
||||
|
||||
if ( MLQuestSystem.Debug && name.Number > 0 )
|
||||
{
|
||||
|
|
@ -68,21 +42,21 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public virtual void SpawnDelivery( Container pack )
|
||||
{
|
||||
if ( !m_SpawnsDelivery || pack == null )
|
||||
if ( !SpawnsDelivery || pack == null )
|
||||
return;
|
||||
|
||||
List<Item> delivery = new List<Item>();
|
||||
|
||||
for ( int i = 0; i < m_Amount; ++i )
|
||||
for ( int i = 0; i < Amount; ++i )
|
||||
{
|
||||
if ( !(Activator.CreateInstance( m_Delivery ) is Item item) )
|
||||
if ( !(Activator.CreateInstance( Delivery ) is Item item) )
|
||||
continue;
|
||||
|
||||
delivery.Add( item );
|
||||
|
||||
if ( item.Stackable && m_Amount > 1 )
|
||||
if ( item.Stackable && Amount > 1 )
|
||||
{
|
||||
item.Amount = m_Amount;
|
||||
item.Amount = Amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -93,25 +67,25 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
string amount = m_Amount.ToString();
|
||||
string amount = Amount.ToString();
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1072207, 0x15F90, false, false ); // Deliver
|
||||
g.AddLabel( 143, y, 0x481, amount );
|
||||
|
||||
if ( m_Name.Number > 0 )
|
||||
if ( Name.Number > 0 )
|
||||
{
|
||||
g.AddHtmlLocalized( 143 + amount.Length * 15, y, 190, 18, m_Name.Number, 0x77BF, false, false );
|
||||
g.AddItem( 350, y, CollectObjective.LabelToItemID( m_Name.Number ) );
|
||||
g.AddHtmlLocalized( 143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false );
|
||||
g.AddItem( 350, y, CollectObjective.LabelToItemID( Name.Number ) );
|
||||
}
|
||||
else if ( m_Name.String != null )
|
||||
else if ( Name.String != null )
|
||||
{
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, m_Name.String );
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, Name.String );
|
||||
}
|
||||
|
||||
y += 32;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1072379, 0x15F90, false, false ); // Deliver to
|
||||
g.AddLabel( 223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor( m_Destination ) );
|
||||
g.AddLabel( 223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor( Destination ) );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
|
@ -126,10 +100,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class TimedDeliverObjective : DeliverObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed => true;
|
||||
public override TimeSpan Duration => m_Duration;
|
||||
public override TimeSpan Duration { get; }
|
||||
|
||||
public TimedDeliverObjective( TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination )
|
||||
: this( duration, delivery, amount, name, destination, true )
|
||||
|
|
@ -139,7 +111,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
public TimedDeliverObjective( TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination, bool spawnsDelivery )
|
||||
: base( delivery, amount, name, destination, spawnsDelivery )
|
||||
{
|
||||
m_Duration = duration;
|
||||
Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,42 +119,31 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class DeliverObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private DeliverObjective m_Objective;
|
||||
private bool m_HasCompleted;
|
||||
public DeliverObjective Objective { get; set; }
|
||||
|
||||
public DeliverObjective Objective
|
||||
{
|
||||
get => m_Objective;
|
||||
set => m_Objective = value;
|
||||
}
|
||||
|
||||
public bool HasCompleted
|
||||
{
|
||||
get => m_HasCompleted;
|
||||
set => m_HasCompleted = value;
|
||||
}
|
||||
public bool HasCompleted { get; set; }
|
||||
|
||||
public DeliverObjectiveInstance( DeliverObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
Objective = objective;
|
||||
}
|
||||
|
||||
public virtual bool IsDestination( IQuestGiver quester, Type type )
|
||||
{
|
||||
Type destType = m_Objective.Destination;
|
||||
Type destType = Objective.Destination;
|
||||
|
||||
return ( destType != null && destType.IsAssignableFrom( type ) );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return m_HasCompleted;
|
||||
return HasCompleted;
|
||||
}
|
||||
|
||||
public override void OnQuestAccepted()
|
||||
{
|
||||
m_Objective.SpawnDelivery( Instance.Player.Backpack );
|
||||
Objective.SpawnDelivery( Instance.Player.Backpack );
|
||||
}
|
||||
|
||||
// This is VERY similar to CollectObjective.GetCurrentTotal
|
||||
|
|
@ -193,7 +154,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
if ( pack == null )
|
||||
return 0;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.Delivery, false ); // Note: subclasses are included
|
||||
Item[] items = pack.FindItemsByType( Objective.Delivery, false ); // Note: subclasses are included
|
||||
int total = 0;
|
||||
|
||||
foreach ( Item item in items )
|
||||
|
|
@ -207,7 +168,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
int total = GetCurrentTotal();
|
||||
int desired = m_Objective.Amount;
|
||||
int desired = Objective.Amount;
|
||||
|
||||
if ( total < desired )
|
||||
{
|
||||
|
|
@ -227,8 +188,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
if ( pack == null )
|
||||
return;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.Delivery, false );
|
||||
int left = m_Objective.Amount;
|
||||
Item[] items = pack.FindItemsByType( Objective.Delivery, false );
|
||||
int left = Objective.Amount;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
|
|
@ -262,7 +223,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
|
|
@ -275,7 +236,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_HasCompleted );
|
||||
writer.Write( HasCompleted );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
public class EscortObjective : BaseObjective
|
||||
{
|
||||
private QuestArea m_Destination;
|
||||
|
||||
public QuestArea Destination
|
||||
{
|
||||
get => m_Destination;
|
||||
set => m_Destination = value;
|
||||
}
|
||||
public QuestArea Destination { get; set; }
|
||||
|
||||
public EscortObjective()
|
||||
: this( null )
|
||||
|
|
@ -22,7 +16,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public EscortObjective( QuestArea destination )
|
||||
{
|
||||
m_Destination = destination;
|
||||
Destination = destination;
|
||||
}
|
||||
|
||||
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
|
||||
|
|
@ -70,17 +64,17 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1072206, 0x15F90, false, false ); // Escort to
|
||||
|
||||
if ( m_Destination.Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 173, y, 312, 20, m_Destination.Name.Number, 0xFFFFFF, false, false );
|
||||
else if ( m_Destination.Name.String != null )
|
||||
g.AddLabel( 173, y, 0x481, m_Destination.Name.String );
|
||||
if ( Destination.Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 173, y, 312, 20, Destination.Name.Number, 0xFFFFFF, false, false );
|
||||
else if ( Destination.Name.String != null )
|
||||
g.AddLabel( 173, y, 0x481, Destination.Name.String );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
if ( instance == null || m_Destination == null )
|
||||
if ( instance == null || Destination == null )
|
||||
return null;
|
||||
|
||||
return new EscortObjectiveInstance( this, instance );
|
||||
|
|
@ -90,22 +84,17 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
public class EscortObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private EscortObjective m_Objective;
|
||||
private bool m_HasCompleted;
|
||||
private Timer m_Timer;
|
||||
private DateTime m_LastSeenEscorter;
|
||||
private BaseCreature m_Escort;
|
||||
|
||||
public bool HasCompleted
|
||||
{
|
||||
get => m_HasCompleted;
|
||||
set => m_HasCompleted = value;
|
||||
}
|
||||
public bool HasCompleted { get; set; }
|
||||
|
||||
public EscortObjectiveInstance( EscortObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
m_HasCompleted = false;
|
||||
HasCompleted = false;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 5 ), CheckDestination );
|
||||
m_LastSeenEscorter = DateTime.UtcNow;
|
||||
m_Escort = instance.Quester as BaseCreature;
|
||||
|
|
@ -116,12 +105,12 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return m_HasCompleted;
|
||||
return HasCompleted;
|
||||
}
|
||||
|
||||
private void CheckDestination()
|
||||
{
|
||||
if ( m_Escort == null || m_HasCompleted ) // Completed by deserialization
|
||||
if ( m_Escort == null || HasCompleted ) // Completed by deserialization
|
||||
{
|
||||
StopTimer();
|
||||
return;
|
||||
|
|
@ -146,7 +135,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
EndFollow( m_Escort );
|
||||
StopTimer();
|
||||
|
||||
m_HasCompleted = true;
|
||||
HasCompleted = true;
|
||||
CheckComplete();
|
||||
|
||||
// Auto claim reward
|
||||
|
|
@ -275,7 +264,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_HasCompleted );
|
||||
writer.Write( HasCompleted );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,21 +13,11 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class GainSkillObjective : BaseObjective
|
||||
{
|
||||
private SkillName m_Skill;
|
||||
private int m_ThresholdFixed;
|
||||
private GainSkillObjectiveFlags m_Flags;
|
||||
|
||||
public SkillName Skill
|
||||
{
|
||||
get => m_Skill;
|
||||
set => m_Skill = value;
|
||||
}
|
||||
public SkillName Skill { get; set; }
|
||||
|
||||
public int ThresholdFixed
|
||||
{
|
||||
get => m_ThresholdFixed;
|
||||
set => m_ThresholdFixed = value;
|
||||
}
|
||||
public int ThresholdFixed { get; set; }
|
||||
|
||||
public bool UseReal
|
||||
{
|
||||
|
|
@ -53,8 +43,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public GainSkillObjective( SkillName skill, int thresholdFixed, bool useReal, bool accelerate )
|
||||
{
|
||||
m_Skill = skill;
|
||||
m_ThresholdFixed = thresholdFixed;
|
||||
Skill = skill;
|
||||
ThresholdFixed = thresholdFixed;
|
||||
m_Flags = GainSkillObjectiveFlags.None;
|
||||
|
||||
if ( useReal )
|
||||
|
|
@ -66,9 +56,9 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
|
||||
{
|
||||
Skill skill = pm.Skills[m_Skill];
|
||||
Skill skill = pm.Skills[Skill];
|
||||
|
||||
if ( ( UseReal ? skill.Fixed : skill.BaseFixedPoint ) >= m_ThresholdFixed )
|
||||
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!
|
||||
|
|
@ -81,13 +71,13 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
int skillLabel = AosSkillBonuses.GetLabel( m_Skill );
|
||||
int skillLabel = AosSkillBonuses.GetLabel( Skill );
|
||||
string args;
|
||||
|
||||
if ( m_ThresholdFixed % 10 == 0 )
|
||||
args = $"#{skillLabel}\t{m_ThresholdFixed / 10}"; // as seen on OSI
|
||||
if ( ThresholdFixed % 10 == 0 )
|
||||
args = $"#{skillLabel}\t{ThresholdFixed / 10}"; // as seen on OSI
|
||||
else
|
||||
args = $"#{skillLabel}\t{(double) m_ThresholdFixed / 10:0.0}"; // for non-integer skill levels
|
||||
args = $"#{skillLabel}\t{(double) ThresholdFixed / 10:0.0}"; // for non-integer skill levels
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1077485, args, 0x15F90, false, false ); // Increase ~1_SKILL~ to ~2_VALUE~
|
||||
y += 16;
|
||||
|
|
@ -115,50 +105,44 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
// On OSI, once this is complete, it will *stay* complete, even if you lower your skill again
|
||||
public class GainSkillObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private GainSkillObjective m_Objective;
|
||||
|
||||
public GainSkillObjective Objective
|
||||
{
|
||||
get => m_Objective;
|
||||
set => m_Objective = value;
|
||||
}
|
||||
public GainSkillObjective Objective { get; set; }
|
||||
|
||||
public GainSkillObjectiveInstance( GainSkillObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
Objective = objective;
|
||||
}
|
||||
|
||||
public bool Handles( SkillName skill )
|
||||
{
|
||||
return ( m_Objective.Skill == skill );
|
||||
return ( Objective.Skill == skill );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
int valueFixed = m_Objective.UseReal ? pm.Skills[m_Objective.Skill].Fixed : pm.Skills[m_Objective.Skill].BaseFixedPoint;
|
||||
int valueFixed = Objective.UseReal ? pm.Skills[Objective.Skill].Fixed : pm.Skills[Objective.Skill].BaseFixedPoint;
|
||||
|
||||
return ( valueFixed >= m_Objective.ThresholdFixed );
|
||||
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 ( !m_Objective.Accelerate )
|
||||
if ( !Objective.Accelerate )
|
||||
return;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
pm.AcceleratedSkill = m_Objective.Skill;
|
||||
pm.AcceleratedSkill = Objective.Skill;
|
||||
pm.AcceleratedStart = DateTime.UtcNow + TimeSpan.FromMinutes( 15 ); // TODO: Is there a max duration?
|
||||
}
|
||||
|
||||
public override void OnQuestCancelled()
|
||||
{
|
||||
if ( !m_Objective.Accelerate )
|
||||
if ( !Objective.Accelerate )
|
||||
return;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
|
@ -174,7 +158,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
|
|
|
|||
|
|
@ -6,34 +6,13 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
public class KillObjective : BaseObjective
|
||||
{
|
||||
private int m_DesiredAmount;
|
||||
private Type[] m_AcceptedTypes; // Example of Type[] requirement on OSI: killing X bone magis or skeletal mages (probably the same type on OSI though?)
|
||||
private TextDefinition m_Name;
|
||||
private QuestArea m_Area;
|
||||
public int DesiredAmount { get; set; }
|
||||
|
||||
public int DesiredAmount
|
||||
{
|
||||
get => m_DesiredAmount;
|
||||
set => m_DesiredAmount = value;
|
||||
}
|
||||
public Type[] AcceptedTypes { get; set; }
|
||||
|
||||
public Type[] AcceptedTypes
|
||||
{
|
||||
get => m_AcceptedTypes;
|
||||
set => m_AcceptedTypes = value;
|
||||
}
|
||||
public TextDefinition Name { get; set; }
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
|
||||
public QuestArea Area
|
||||
{
|
||||
get => m_Area;
|
||||
set => m_Area = value;
|
||||
}
|
||||
public QuestArea Area { get; set; }
|
||||
|
||||
public KillObjective()
|
||||
: this( 0, null, null, null )
|
||||
|
|
@ -47,35 +26,35 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public KillObjective( int amount, Type[] types, TextDefinition name, QuestArea area )
|
||||
{
|
||||
m_DesiredAmount = amount;
|
||||
m_AcceptedTypes = types;
|
||||
m_Name = name;
|
||||
m_Area = area;
|
||||
DesiredAmount = amount;
|
||||
AcceptedTypes = types;
|
||||
Name = name;
|
||||
Area = area;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
string amount = m_DesiredAmount.ToString();
|
||||
string amount = DesiredAmount.ToString();
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1072204, 0x15F90, false, false ); // Slay
|
||||
g.AddLabel( 133, y, 0x481, amount );
|
||||
|
||||
if ( m_Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 133 + amount.Length * 15, y, 190, 18, m_Name.Number, 0x77BF, false, false );
|
||||
else if ( m_Name.String != null )
|
||||
g.AddLabel( 133 + amount.Length * 15, y, 0x481, m_Name.String );
|
||||
if ( Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 133 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false );
|
||||
else if ( Name.String != null )
|
||||
g.AddLabel( 133 + amount.Length * 15, y, 0x481, Name.String );
|
||||
|
||||
y += 16;
|
||||
|
||||
#region Location
|
||||
if ( m_Area != null )
|
||||
if ( Area != null )
|
||||
{
|
||||
g.AddHtmlLocalized( 103, y, 312, 20, 1018327, 0x15F90, false, false ); // Location
|
||||
|
||||
if ( m_Area.Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 223, y, 312, 20, m_Area.Name.Number, 0xFFFFFF, false, false );
|
||||
else if ( m_Area.Name.String != null )
|
||||
g.AddLabel( 223, y, 0x481, m_Area.Name.String );
|
||||
if ( Area.Name.Number > 0 )
|
||||
g.AddHtmlLocalized( 223, y, 312, 20, Area.Name.Number, 0xFFFFFF, false, false );
|
||||
else if ( Area.Name.String != null )
|
||||
g.AddLabel( 223, y, 0x481, Area.Name.String );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
|
@ -92,10 +71,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class TimedKillObjective : KillObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed => true;
|
||||
public override TimeSpan Duration => m_Duration;
|
||||
public override TimeSpan Duration { get; }
|
||||
|
||||
public TimedKillObjective( TimeSpan duration, int amount, Type[] types, TextDefinition name )
|
||||
: this( duration, amount, types, name, null )
|
||||
|
|
@ -105,7 +82,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
public TimedKillObjective( TimeSpan duration, int amount, Type[] types, TextDefinition name, QuestArea area )
|
||||
: base( amount, types, name, area )
|
||||
{
|
||||
m_Duration = duration;
|
||||
Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,45 +90,34 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public class KillObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private KillObjective m_Objective;
|
||||
private int m_Slain;
|
||||
public KillObjective Objective { get; set; }
|
||||
|
||||
public KillObjective Objective
|
||||
{
|
||||
get => m_Objective;
|
||||
set => m_Objective = value;
|
||||
}
|
||||
|
||||
public int Slain
|
||||
{
|
||||
get => m_Slain;
|
||||
set => m_Slain = value;
|
||||
}
|
||||
public int Slain { get; set; }
|
||||
|
||||
public KillObjectiveInstance( KillObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
m_Slain = 0;
|
||||
Objective = objective;
|
||||
Slain = 0;
|
||||
}
|
||||
|
||||
public bool AddKill( Mobile mob, Type type )
|
||||
{
|
||||
int desired = m_Objective.DesiredAmount;
|
||||
int desired = Objective.DesiredAmount;
|
||||
|
||||
foreach ( Type acceptedType in m_Objective.AcceptedTypes )
|
||||
foreach ( Type acceptedType in Objective.AcceptedTypes )
|
||||
{
|
||||
if ( acceptedType.IsAssignableFrom( type ) )
|
||||
{
|
||||
if ( m_Objective.Area != null && !m_Objective.Area.Contains( mob ) )
|
||||
if ( Objective.Area != null && !Objective.Area.Contains( mob ) )
|
||||
return false;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
if ( ++m_Slain >= desired )
|
||||
if ( ++Slain >= desired )
|
||||
pm.SendLocalizedMessage( 1075050 ); // You have killed all the required quest creatures of this type.
|
||||
else
|
||||
pm.SendLocalizedMessage( 1075051, ( desired - m_Slain ).ToString() ); // You have killed a quest creature. ~1_val~ more left.
|
||||
pm.SendLocalizedMessage( 1075051, ( desired - Slain ).ToString() ); // You have killed a quest creature. ~1_val~ more left.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -162,17 +128,17 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return ( m_Slain >= m_Objective.DesiredAmount );
|
||||
return ( Slain >= Objective.DesiredAmount );
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 3000087, 0x15F90, false, false ); // Total
|
||||
g.AddLabel( 223, y, 0x481, m_Slain.ToString() );
|
||||
g.AddLabel( 223, y, 0x481, Slain.ToString() );
|
||||
y += 16;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1074782, 0x15F90, false, false ); // Return to
|
||||
|
|
@ -186,7 +152,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_Slain );
|
||||
writer.Write( Slain );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,27 +4,11 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
public class QuestArea
|
||||
{
|
||||
private TextDefinition m_Name; // So we can add custom names, different from the Region name
|
||||
private string m_RegionName;
|
||||
private Map m_ForceMap;
|
||||
public TextDefinition Name { get; set; }
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
public string RegionName { get; set; }
|
||||
|
||||
public string RegionName
|
||||
{
|
||||
get => m_RegionName;
|
||||
set => m_RegionName = value;
|
||||
}
|
||||
|
||||
public Map ForceMap
|
||||
{
|
||||
get => m_ForceMap;
|
||||
set => m_ForceMap = value;
|
||||
}
|
||||
public Map ForceMap { get; set; }
|
||||
|
||||
public QuestArea( TextDefinition name, string region )
|
||||
: this( name, region, null )
|
||||
|
|
@ -33,9 +17,9 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public QuestArea( TextDefinition name, string region, Map forceMap )
|
||||
{
|
||||
m_Name = name;
|
||||
m_RegionName = region;
|
||||
m_ForceMap = forceMap;
|
||||
Name = name;
|
||||
RegionName = region;
|
||||
ForceMap = forceMap;
|
||||
|
||||
if ( MLQuestSystem.Debug )
|
||||
ValidationQueue<QuestArea>.Add( this );
|
||||
|
|
@ -48,10 +32,10 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public bool Contains( Region reg )
|
||||
{
|
||||
if ( reg == null || ( m_ForceMap != null && reg.Map != m_ForceMap ) )
|
||||
if ( reg == null || ( ForceMap != null && reg.Map != ForceMap ) )
|
||||
return false;
|
||||
|
||||
return reg.IsPartOf( m_RegionName );
|
||||
return reg.IsPartOf( RegionName );
|
||||
}
|
||||
|
||||
// Debug method
|
||||
|
|
@ -61,7 +45,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
foreach ( Region r in Region.Regions )
|
||||
{
|
||||
if ( r.Name == m_RegionName && ( m_ForceMap == null || r.Map == m_ForceMap ) )
|
||||
if ( r.Name == RegionName && ( ForceMap == null || r.Map == ForceMap ) )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
|
@ -69,7 +53,7 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
|
||||
if ( !found )
|
||||
Console.WriteLine( "Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", m_RegionName, ( m_ForceMap == null ) ? "-null-" : m_ForceMap.ToString() );
|
||||
Console.WriteLine( "Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName, ( ForceMap == null ) ? "-null-" : ForceMap.ToString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@ namespace Server.Engines.MLQuests
|
|||
[AttributeUsage( AttributeTargets.Class )]
|
||||
public class QuesterNameAttribute : Attribute
|
||||
{
|
||||
private string m_QuesterName;
|
||||
|
||||
public string QuesterName => m_QuesterName;
|
||||
public string QuesterName { get; }
|
||||
|
||||
public QuesterNameAttribute( string questerName )
|
||||
{
|
||||
m_QuesterName = questerName;
|
||||
QuesterName = questerName;
|
||||
}
|
||||
|
||||
private static readonly Type m_Type = typeof( QuesterNameAttribute );
|
||||
|
|
|
|||
|
|
@ -6,24 +6,18 @@ namespace Server.Engines.MLQuests.Rewards
|
|||
{
|
||||
public abstract class BaseReward
|
||||
{
|
||||
private TextDefinition m_Name;
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
public TextDefinition Name { get; set; }
|
||||
|
||||
public BaseReward( TextDefinition name )
|
||||
{
|
||||
m_Name = name;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
protected virtual int LabelHeight => 16;
|
||||
|
||||
public void WriteToGump( Gump g, int x, ref int y )
|
||||
{
|
||||
TextDefinition.AddHtmlText( g, x, y, 280, LabelHeight, m_Name, false, false, 0x15F90, 0xBDE784 );
|
||||
TextDefinition.AddHtmlText( g, x, y, 280, LabelHeight, Name, false, false, 0x15F90, 0xBDE784 );
|
||||
}
|
||||
|
||||
public abstract void AddRewardItems( PlayerMobile pm, List<Item> rewards );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue