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
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue