ML quest system; first SVN release.
Secondary changes: - Region fixes, mainly for New Haven. - Recipe system changes. - Enabled ML craftables. - Dyeing/cutting restrictions for quest items. - Moved IsInvulnerable from BaseVendor to BaseCreature. - Moved RandomBrightHue to Utility. - Items no longer decay when attached to a spawner. - Quest item hue is now faked through packets, instead of overriding Hue. - Re-enabled item drag effects for SA clients. - Fixed AssignRandomFacialHair bug in Utility. - Added random hue comments to Utility.
This commit is contained in:
parent
5c7af18dfb
commit
35fbffdb51
167 changed files with 23218 additions and 234 deletions
214
Scripts/Engines/MLQuests/Objectives/BaseObjective.cs
Normal file
214
Scripts/Engines/MLQuests/Objectives/BaseObjective.cs
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.MLQuests.Objectives
|
||||
{
|
||||
public abstract class BaseObjective
|
||||
{
|
||||
public virtual bool IsTimed { get { return false; } }
|
||||
public virtual TimeSpan Duration { get { return TimeSpan.Zero; } }
|
||||
|
||||
public BaseObjective()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool CanOffer( BaseCreature quester, PlayerMobile pm )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void WriteToGump( Gump g, ref int y );
|
||||
|
||||
public virtual BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseObjectiveInstance
|
||||
{
|
||||
private MLQuestInstance m_Instance;
|
||||
private DateTime m_EndTime;
|
||||
private bool m_Expired;
|
||||
|
||||
public MLQuestInstance Instance
|
||||
{
|
||||
get { return m_Instance; }
|
||||
}
|
||||
|
||||
public bool IsTimed
|
||||
{
|
||||
get { return ( m_EndTime != DateTime.MinValue ); }
|
||||
}
|
||||
|
||||
public DateTime EndTime
|
||||
{
|
||||
get { return m_EndTime; }
|
||||
set { m_EndTime = value; }
|
||||
}
|
||||
|
||||
public bool Expired
|
||||
{
|
||||
get { return m_Expired; }
|
||||
set { m_Expired = value; }
|
||||
}
|
||||
|
||||
public BaseObjectiveInstance( MLQuestInstance instance, BaseObjective obj )
|
||||
{
|
||||
m_Instance = instance;
|
||||
|
||||
if ( obj.IsTimed )
|
||||
m_EndTime = DateTime.Now + obj.Duration;
|
||||
}
|
||||
|
||||
public virtual void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
if ( IsTimed )
|
||||
WriteTimeRemaining( g, ref y, ( m_EndTime > DateTime.Now ) ? ( m_EndTime - DateTime.Now ) : TimeSpan.Zero );
|
||||
}
|
||||
|
||||
public static void WriteTimeRemaining( Gump g, ref int y, TimeSpan timeRemaining )
|
||||
{
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1062379, 0x15F90, false, false ); // Est. time remaining:
|
||||
g.AddLabel( 223, y, 0x481, timeRemaining.TotalSeconds.ToString( "F0" ) );
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public virtual bool AllowsQuestItem( Item item, Type type )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsCompleted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void CheckComplete()
|
||||
{
|
||||
if ( IsCompleted() )
|
||||
{
|
||||
m_Instance.Player.PlaySound( 0x5B6 ); // public sound
|
||||
m_Instance.CheckComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnQuestAccepted()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnQuestCancelled()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnQuestCompleted()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool OnBeforeClaimReward()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void OnClaimReward()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnAfterClaimReward()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnRewardClaimed()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnQuesterDeleted()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnPlayerDeath()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnExpire()
|
||||
{
|
||||
}
|
||||
|
||||
public enum DataType : byte
|
||||
{
|
||||
None,
|
||||
EscortObjective,
|
||||
KillObjective,
|
||||
DeliverObjective
|
||||
}
|
||||
|
||||
public virtual DataType ExtraDataType { get { return DataType.None; } }
|
||||
|
||||
public virtual void Serialize( GenericWriter writer )
|
||||
{
|
||||
// Version info is written in MLQuestPersistence.Serialize
|
||||
|
||||
if ( IsTimed )
|
||||
{
|
||||
writer.Write( true );
|
||||
writer.WriteDeltaTime( m_EndTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write( false );
|
||||
}
|
||||
|
||||
// For type checks on deserialization
|
||||
// (This way quest objectives can be changed without breaking serialization)
|
||||
writer.Write( (byte)ExtraDataType );
|
||||
}
|
||||
|
||||
public static void Deserialize( GenericReader reader, int version, BaseObjectiveInstance objInstance )
|
||||
{
|
||||
if ( reader.ReadBool() )
|
||||
{
|
||||
DateTime endTime = reader.ReadDeltaTime();
|
||||
|
||||
if ( objInstance != null )
|
||||
objInstance.EndTime = endTime;
|
||||
}
|
||||
|
||||
DataType extraDataType = (DataType)reader.ReadByte();
|
||||
|
||||
switch ( extraDataType )
|
||||
{
|
||||
case DataType.EscortObjective:
|
||||
{
|
||||
bool completed = reader.ReadBool();
|
||||
|
||||
if ( objInstance is EscortObjectiveInstance )
|
||||
( (EscortObjectiveInstance)objInstance ).HasCompleted = completed;
|
||||
|
||||
break;
|
||||
}
|
||||
case DataType.KillObjective:
|
||||
{
|
||||
int slain = reader.ReadInt();
|
||||
|
||||
if ( objInstance is KillObjectiveInstance )
|
||||
( (KillObjectiveInstance)objInstance ).Slain = slain;
|
||||
|
||||
break;
|
||||
}
|
||||
case DataType.DeliverObjective:
|
||||
{
|
||||
bool completed = reader.ReadBool();
|
||||
|
||||
if ( objInstance is DeliverObjectiveInstance )
|
||||
( (DeliverObjectiveInstance)objInstance ).HasCompleted = completed;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
258
Scripts/Engines/MLQuests/Objectives/CollectObjective.cs
Normal file
258
Scripts/Engines/MLQuests/Objectives/CollectObjective.cs
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
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 { return m_DesiredAmount; }
|
||||
set { m_DesiredAmount = value; }
|
||||
}
|
||||
|
||||
public Type AcceptedType
|
||||
{
|
||||
get { return m_AcceptedType; }
|
||||
set { m_AcceptedType = value; }
|
||||
}
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { m_Name = value; }
|
||||
}
|
||||
|
||||
public virtual bool ShowDetailed
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public CollectObjective()
|
||||
: this( 0, null, null )
|
||||
{
|
||||
}
|
||||
|
||||
public CollectObjective( int amount, Type type, TextDefinition name )
|
||||
{
|
||||
m_DesiredAmount = amount;
|
||||
m_AcceptedType = type;
|
||||
m_Name = name;
|
||||
}
|
||||
|
||||
public bool CheckType( Type type )
|
||||
{
|
||||
return ( m_AcceptedType != null && m_AcceptedType.IsAssignableFrom( type ) );
|
||||
}
|
||||
|
||||
public virtual bool CheckItem( Item item )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int LabelToItemID( int label )
|
||||
{
|
||||
int result;
|
||||
|
||||
if ( label < 1078872 )
|
||||
result = ( label - 1020000 );
|
||||
else
|
||||
result = ( label - 1078872 );
|
||||
|
||||
if ( MLQuestSystem.Debug && result > 0x4000 )
|
||||
Console.WriteLine( "Warning: cliloc {0} is likely giving the wrong item ID", label );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
if ( ShowDetailed )
|
||||
{
|
||||
string amount = m_DesiredAmount.ToString();
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 350, 16, 1072205, 0x15F90, false, false ); // Obtain
|
||||
g.AddLabel( 143, y, 0x481, amount );
|
||||
|
||||
if ( m_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 ) );
|
||||
}
|
||||
else if ( m_Name.String != null )
|
||||
{
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, m_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 );
|
||||
}
|
||||
|
||||
y += 32;
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
return new CollectObjectiveInstance( this, instance );
|
||||
}
|
||||
}
|
||||
|
||||
#region Timed
|
||||
|
||||
public class TimedCollectObjective : CollectObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed { get { return true; } }
|
||||
public override TimeSpan Duration { get { return m_Duration; } }
|
||||
|
||||
public TimedCollectObjective( TimeSpan duration, int amount, Type type, TextDefinition name )
|
||||
: base( amount, type, name )
|
||||
{
|
||||
m_Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class CollectObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private CollectObjective m_Objective;
|
||||
|
||||
public CollectObjective Objective
|
||||
{
|
||||
get { return m_Objective; }
|
||||
set { m_Objective = value; }
|
||||
}
|
||||
|
||||
public CollectObjectiveInstance( CollectObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
}
|
||||
|
||||
private int GetCurrentTotal()
|
||||
{
|
||||
Container pack = Instance.Player.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return 0;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.AcceptedType, false ); // Note: subclasses are included
|
||||
int total = 0;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( item.QuestItem && m_Objective.CheckItem( item ) )
|
||||
total += item.Amount;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public override bool AllowsQuestItem( Item item, Type type )
|
||||
{
|
||||
return ( m_Objective.CheckType( type ) && m_Objective.CheckItem( item ) );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return ( GetCurrentTotal() >= m_Objective.DesiredAmount );
|
||||
}
|
||||
|
||||
public override void OnQuestCancelled()
|
||||
{
|
||||
PlayerMobile pm = Instance.Player;
|
||||
Container pack = pm.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return;
|
||||
|
||||
Type checkType = m_Objective.AcceptedType;
|
||||
Item[] items = pack.FindItemsByType( checkType, false );
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( item.QuestItem && !MLQuestSystem.CanMarkQuestItem( pm, item, checkType ) ) // does another quest still need this item? (OSI just unmarks everything)
|
||||
item.QuestItem = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Should only be called after IsComplete() is checked to be true
|
||||
public override void OnClaimReward()
|
||||
{
|
||||
Container pack = Instance.Player.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return;
|
||||
|
||||
// TODO: OSI also counts the item in the cursor?
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.AcceptedType, false );
|
||||
int left = m_Objective.DesiredAmount;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( item.QuestItem && m_Objective.CheckItem( item ) )
|
||||
{
|
||||
if ( left == 0 )
|
||||
return;
|
||||
|
||||
if ( item.Amount > left )
|
||||
{
|
||||
item.Consume( left );
|
||||
left = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Delete();
|
||||
left -= item.Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterClaimReward()
|
||||
{
|
||||
OnQuestCancelled(); // same thing, clear other quest items
|
||||
}
|
||||
|
||||
public override void OnExpire()
|
||||
{
|
||||
OnQuestCancelled();
|
||||
|
||||
// No message
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
y -= 16;
|
||||
|
||||
if ( m_Objective.ShowDetailed )
|
||||
{
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 3000087, 0x15F90, false, false ); // Total
|
||||
g.AddLabel( 223, y, 0x481, GetCurrentTotal().ToString() );
|
||||
y += 16;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1074782, 0x15F90, false, false ); // Return to
|
||||
g.AddLabel( 223, y, 0x481, Instance.GetReturnTo() );
|
||||
y += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
270
Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs
Normal file
270
Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
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 TextDefinition m_DestinationName;
|
||||
|
||||
public Type Delivery
|
||||
{
|
||||
get { return m_Delivery; }
|
||||
set { m_Delivery = value; }
|
||||
}
|
||||
|
||||
public int Amount
|
||||
{
|
||||
get { return m_Amount; }
|
||||
set { m_Amount = value; }
|
||||
}
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { m_Name = value; }
|
||||
}
|
||||
|
||||
public Type Destination
|
||||
{
|
||||
get { return m_Destination; }
|
||||
set { m_Destination = value; }
|
||||
}
|
||||
|
||||
public TextDefinition DestinationName
|
||||
{
|
||||
get { return m_DestinationName; }
|
||||
set { m_DestinationName = value; }
|
||||
}
|
||||
|
||||
public DeliverObjective( Type delivery, int amount, TextDefinition name, Type destination, TextDefinition destinationName )
|
||||
{
|
||||
m_Delivery = delivery;
|
||||
m_Amount = amount;
|
||||
m_Name = name;
|
||||
m_Destination = destination;
|
||||
m_DestinationName = destinationName;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
string amount = m_Amount.ToString();
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1072207, 0x15F90, false, false ); // Deliver
|
||||
g.AddLabel( 143, y, 0x481, amount );
|
||||
|
||||
if ( m_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 ) );
|
||||
}
|
||||
else if ( m_Name.String != null )
|
||||
{
|
||||
g.AddLabel( 143 + amount.Length * 15, y, 0x481, m_Name.String );
|
||||
}
|
||||
|
||||
y += 32;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1072379, 0x15F90, false, false ); // Deliver to
|
||||
|
||||
if ( m_DestinationName.Number > 0 )
|
||||
g.AddHtmlLocalized( 223, y, 190, 18, m_DestinationName.Number, false, false );
|
||||
else
|
||||
g.AddLabel( 223, y, 0x481, m_DestinationName.String );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
return new DeliverObjectiveInstance( this, instance );
|
||||
}
|
||||
}
|
||||
|
||||
#region Timed
|
||||
|
||||
public class TimedDeliverObjective : DeliverObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed { get { return true; } }
|
||||
public override TimeSpan Duration { get { return m_Duration; } }
|
||||
|
||||
public TimedDeliverObjective( TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination, TextDefinition destinationName )
|
||||
: base( delivery, amount, name, destination, destinationName )
|
||||
{
|
||||
m_Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class DeliverObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private DeliverObjective m_Objective;
|
||||
private bool m_HasCompleted;
|
||||
|
||||
public DeliverObjective Objective
|
||||
{
|
||||
get { return m_Objective; }
|
||||
set { m_Objective = value; }
|
||||
}
|
||||
|
||||
public bool HasCompleted
|
||||
{
|
||||
get { return m_HasCompleted; }
|
||||
set { m_HasCompleted = value; }
|
||||
}
|
||||
|
||||
public DeliverObjectiveInstance( DeliverObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
}
|
||||
|
||||
public virtual bool IsDestination( BaseCreature quester, Type type )
|
||||
{
|
||||
Type destType = m_Objective.Destination;
|
||||
|
||||
return ( destType != null && destType.IsAssignableFrom( type ) );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return m_HasCompleted;
|
||||
}
|
||||
|
||||
public override void OnQuestAccepted()
|
||||
{
|
||||
Container pack = Instance.Player.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return; // where are we supposed to put them?
|
||||
|
||||
Type type = m_Objective.Delivery;
|
||||
int amount = m_Objective.Amount;
|
||||
|
||||
List<Item> delivery = new List<Item>();
|
||||
|
||||
for ( int i = 0; i < amount; ++i )
|
||||
{
|
||||
Item item = Activator.CreateInstance( type ) as Item;
|
||||
|
||||
if ( item == null )
|
||||
continue;
|
||||
|
||||
delivery.Add( item );
|
||||
|
||||
if ( item.Stackable && amount > 1 )
|
||||
{
|
||||
item.Amount = amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( Item item in delivery )
|
||||
pack.DropItem( item ); // Confirmed: on OSI items are added even if your pack is full
|
||||
}
|
||||
|
||||
// This is VERY similar to CollectObjective.GetCurrentTotal
|
||||
private int GetCurrentTotal()
|
||||
{
|
||||
Container pack = Instance.Player.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return 0;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.Delivery, false ); // Note: subclasses are included
|
||||
int total = 0;
|
||||
|
||||
foreach ( Item item in items )
|
||||
total += item.Amount;
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public override bool OnBeforeClaimReward()
|
||||
{
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
int total = GetCurrentTotal();
|
||||
int desired = m_Objective.Amount;
|
||||
|
||||
if ( total < desired )
|
||||
{
|
||||
pm.SendLocalizedMessage( 1074861 ); // You do not have everything you need!
|
||||
pm.SendLocalizedMessage( 1074885, String.Format( "{0}\t{1}", total, desired ) ); // You have ~1_val~ item(s) but require ~2_val~
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: This is VERY similar to CollectObjective.OnClaimReward
|
||||
public override void OnClaimReward()
|
||||
{
|
||||
Container pack = Instance.Player.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return;
|
||||
|
||||
Item[] items = pack.FindItemsByType( m_Objective.Delivery, false );
|
||||
int left = m_Objective.Amount;
|
||||
|
||||
foreach ( Item item in items )
|
||||
{
|
||||
if ( left == 0 )
|
||||
break;
|
||||
|
||||
if ( item.Amount > left )
|
||||
{
|
||||
item.Consume( left );
|
||||
left = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Delete();
|
||||
left -= item.Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnQuestCancelled()
|
||||
{
|
||||
OnClaimReward(); // same effect
|
||||
}
|
||||
|
||||
public override void OnExpire()
|
||||
{
|
||||
OnQuestCancelled();
|
||||
|
||||
Instance.Player.SendLocalizedMessage( 1074813 ); // You have failed to complete your delivery.
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
// No extra instance stuff printed for this objective
|
||||
}
|
||||
|
||||
public override DataType ExtraDataType { get { return DataType.DeliverObjective; } }
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_HasCompleted );
|
||||
}
|
||||
}
|
||||
}
|
||||
289
Scripts/Engines/MLQuests/Objectives/EscortObjective.cs
Normal file
289
Scripts/Engines/MLQuests/Objectives/EscortObjective.cs
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
using Server.Misc;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.MLQuests.Objectives
|
||||
{
|
||||
public class EscortObjective : BaseObjective
|
||||
{
|
||||
private QuestArea m_Destination;
|
||||
|
||||
public QuestArea Destination
|
||||
{
|
||||
get { return m_Destination; }
|
||||
set { m_Destination = value; }
|
||||
}
|
||||
|
||||
public EscortObjective()
|
||||
: this( null )
|
||||
{
|
||||
}
|
||||
|
||||
public EscortObjective( QuestArea destination )
|
||||
{
|
||||
m_Destination = destination;
|
||||
}
|
||||
|
||||
public override bool CanOffer( BaseCreature quester, PlayerMobile pm )
|
||||
{
|
||||
BaseEscortable escortable = quester as BaseEscortable;
|
||||
|
||||
if ( quester.Controlled || ( escortable != null && escortable.IsBeingDeleted ) )
|
||||
return false;
|
||||
|
||||
MLQuestContext context = MLQuestSystem.GetContext( pm );
|
||||
|
||||
if ( context != null )
|
||||
{
|
||||
foreach ( MLQuestInstance instance in context.QuestInstances )
|
||||
{
|
||||
if ( instance.Quest.IsEscort )
|
||||
{
|
||||
MLQuestSystem.Tell( quester, pm, 500896 ); // I see you already have an escort.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DateTime nextEscort = pm.LastEscortTime + BaseEscortable.EscortDelay;
|
||||
|
||||
// Note: On OSI Bravehorn doesn't check the time limit, but it does SET the last escort time... bug!
|
||||
if ( nextEscort > DateTime.Now )
|
||||
{
|
||||
int minutes = (int)Math.Ceiling( ( nextEscort - DateTime.Now ).TotalMinutes );
|
||||
|
||||
if ( minutes == 1 )
|
||||
MLQuestSystem.Tell( quester, pm, "You must rest 1 minute before we set out on this journey." );
|
||||
else
|
||||
MLQuestSystem.Tell( quester, pm, 1071195, minutes.ToString() ); // You must rest ~1_minsleft~ minutes before we set out on this journey.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
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 );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
if ( instance == null || m_Destination == null )
|
||||
return null;
|
||||
|
||||
return new EscortObjectiveInstance( this, instance );
|
||||
}
|
||||
}
|
||||
|
||||
public class EscortObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private EscortObjective m_Objective;
|
||||
private bool m_HasCompleted;
|
||||
private Timer m_Timer;
|
||||
private DateTime m_LastSeenEscorter;
|
||||
|
||||
public bool HasCompleted
|
||||
{
|
||||
get { return m_HasCompleted; }
|
||||
set { m_HasCompleted = value; }
|
||||
}
|
||||
|
||||
public EscortObjectiveInstance( EscortObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
m_HasCompleted = false;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 5 ), new TimerCallback( CheckDestination ) );
|
||||
m_LastSeenEscorter = DateTime.Now;
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
// Once complete, it stays complete
|
||||
return m_HasCompleted;
|
||||
}
|
||||
|
||||
private void CheckDestination()
|
||||
{
|
||||
if ( m_HasCompleted ) // Completed by deserialization
|
||||
{
|
||||
StopTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
MLQuestInstance instance = Instance;
|
||||
BaseCreature escort = instance.Quester;
|
||||
PlayerMobile pm = instance.Player;
|
||||
|
||||
if ( instance.Removed ) // Player cancelled or player died
|
||||
{
|
||||
Abandon();
|
||||
}
|
||||
else if ( m_Objective.Destination.Contains( escort ) ) // We've arrived!
|
||||
{
|
||||
m_HasCompleted = true;
|
||||
CheckComplete();
|
||||
InternalOnQuestCompleted();
|
||||
StopTimer();
|
||||
}
|
||||
else if ( pm.Map != escort.Map || !pm.InRange( escort, 30 ) ) // Player abandoned us (range not verified)
|
||||
{
|
||||
if ( m_LastSeenEscorter + BaseEscortable.AbandonDelay <= DateTime.Now )
|
||||
Abandon();
|
||||
}
|
||||
else // Player is still with us
|
||||
{
|
||||
m_LastSeenEscorter = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopTimer()
|
||||
{
|
||||
if ( m_Timer != null )
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BeginFollow( BaseCreature quester, PlayerMobile pm )
|
||||
{
|
||||
quester.ControlSlots = 0;
|
||||
quester.SetControlMaster( pm );
|
||||
|
||||
quester.ActiveSpeed = 0.1;
|
||||
quester.PassiveSpeed = 0.2;
|
||||
|
||||
quester.ControlOrder = OrderType.Follow;
|
||||
quester.ControlTarget = pm;
|
||||
|
||||
quester.CantWalk = false;
|
||||
quester.CurrentSpeed = 0.1;
|
||||
}
|
||||
|
||||
public static void EndFollow( BaseCreature quester )
|
||||
{
|
||||
quester.ActiveSpeed = 0.2;
|
||||
quester.PassiveSpeed = 1.0;
|
||||
|
||||
quester.ControlOrder = OrderType.None;
|
||||
quester.ControlTarget = null;
|
||||
|
||||
quester.CurrentSpeed = 1.0;
|
||||
|
||||
quester.SetControlMaster( null );
|
||||
|
||||
if ( quester is BaseEscortable )
|
||||
( (BaseEscortable)quester ).BeginDelete();
|
||||
}
|
||||
|
||||
public override void OnQuestAccepted()
|
||||
{
|
||||
MLQuestInstance instance = Instance;
|
||||
PlayerMobile pm = instance.Player;
|
||||
|
||||
pm.LastEscortTime = DateTime.Now;
|
||||
|
||||
BeginFollow( instance.Quester, pm );
|
||||
}
|
||||
|
||||
public void Abandon()
|
||||
{
|
||||
StopTimer();
|
||||
|
||||
MLQuestInstance instance = Instance;
|
||||
BaseCreature quester = instance.Quester;
|
||||
PlayerMobile pm = instance.Player;
|
||||
|
||||
if ( !quester.Deleted )
|
||||
{
|
||||
if ( !pm.Alive )
|
||||
quester.Say( 500901 ); // Ack! My escort has come to haunt me!
|
||||
else
|
||||
quester.Say( 500902 ); // My escort seems to have abandoned me!
|
||||
|
||||
EndFollow( quester );
|
||||
}
|
||||
|
||||
// Note: this sound is sent twice on OSI (once here and once in Cancel())
|
||||
//m_Player.SendSound( 0x5B3 ); // private sound
|
||||
pm.SendLocalizedMessage( 1071194 ); // You have failed your escort quest...
|
||||
|
||||
if ( !instance.Removed )
|
||||
instance.Cancel();
|
||||
}
|
||||
|
||||
private void InternalOnQuestCompleted() // To make sure it's never executed twice (when combined with a CollectObjective for example)
|
||||
{
|
||||
MLQuestInstance instance = Instance;
|
||||
PlayerMobile pm = instance.Player;
|
||||
BaseCreature quester = instance.Quester;
|
||||
|
||||
quester.Say( 1042809, pm.Name ); // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay.
|
||||
|
||||
// Verified: auto double click goes here
|
||||
MLQuestSystem.OnDoubleClick( quester, pm ); // Auto claim reward
|
||||
|
||||
if ( pm.Young || quester.Region.IsPartOf( "Haven Island" ) )
|
||||
Titles.AwardFame( pm, 10, true );
|
||||
else
|
||||
VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( quester is BaseEscortable && ( (BaseEscortable)quester ).IsPrisoner ) ? 400 : 200 );
|
||||
|
||||
EndFollow( quester );
|
||||
}
|
||||
|
||||
public override void OnQuesterDeleted()
|
||||
{
|
||||
if ( IsCompleted() || Instance.Removed )
|
||||
return;
|
||||
|
||||
Abandon();
|
||||
}
|
||||
|
||||
public override void OnPlayerDeath()
|
||||
{
|
||||
// Note: OSI also cancels it when the quest is already complete
|
||||
if ( /*IsCompleted() ||*/ Instance.Removed )
|
||||
return;
|
||||
|
||||
Instance.Cancel();
|
||||
}
|
||||
|
||||
public override void OnExpire()
|
||||
{
|
||||
Abandon();
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
// No extra instance stuff printed for this objective
|
||||
}
|
||||
|
||||
public override DataType ExtraDataType { get { return DataType.EscortObjective; } }
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_HasCompleted );
|
||||
}
|
||||
}
|
||||
}
|
||||
190
Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs
Normal file
190
Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.MLQuests.Objectives
|
||||
{
|
||||
public enum GainSkillObjectiveFlags : byte
|
||||
{
|
||||
None = 0x00,
|
||||
UseReal = 0x01,
|
||||
Accelerate = 0x02
|
||||
}
|
||||
|
||||
public class GainSkillObjective : BaseObjective
|
||||
{
|
||||
private SkillName m_Skill;
|
||||
private int m_ThresholdFixed;
|
||||
private GainSkillObjectiveFlags m_Flags;
|
||||
|
||||
public SkillName Skill
|
||||
{
|
||||
get { return m_Skill; }
|
||||
set { m_Skill = value; }
|
||||
}
|
||||
|
||||
public int ThresholdFixed
|
||||
{
|
||||
get { return m_ThresholdFixed; }
|
||||
set { m_ThresholdFixed = value; }
|
||||
}
|
||||
|
||||
public bool UseReal
|
||||
{
|
||||
get { return GetFlag( GainSkillObjectiveFlags.UseReal ); }
|
||||
set { SetFlag( GainSkillObjectiveFlags.UseReal, value ); }
|
||||
}
|
||||
|
||||
public bool Accelerate
|
||||
{
|
||||
get { return GetFlag( GainSkillObjectiveFlags.Accelerate ); }
|
||||
set { SetFlag( GainSkillObjectiveFlags.Accelerate, value ); }
|
||||
}
|
||||
|
||||
public GainSkillObjective()
|
||||
: this( SkillName.Alchemy, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public GainSkillObjective( SkillName skill, int thresholdFixed )
|
||||
: this( skill, thresholdFixed, false, false )
|
||||
{
|
||||
}
|
||||
|
||||
public GainSkillObjective( SkillName skill, int thresholdFixed, bool useReal, bool accelerate )
|
||||
{
|
||||
m_Skill = skill;
|
||||
m_ThresholdFixed = thresholdFixed;
|
||||
m_Flags = GainSkillObjectiveFlags.None;
|
||||
|
||||
if ( useReal )
|
||||
m_Flags |= GainSkillObjectiveFlags.UseReal;
|
||||
|
||||
if ( accelerate )
|
||||
m_Flags |= GainSkillObjectiveFlags.Accelerate;
|
||||
}
|
||||
|
||||
public override bool CanOffer( BaseCreature quester, PlayerMobile pm )
|
||||
{
|
||||
Skill skill = pm.Skills[m_Skill];
|
||||
|
||||
if ( ( UseReal ? skill.Fixed : skill.BaseFixedPoint ) >= m_ThresholdFixed )
|
||||
{
|
||||
// On OSI both 1077772 and 1080107 are sent.
|
||||
MLQuestSystem.Tell( quester, pm, 1077772 ); // I cannot teach you, for you know all I can teach!
|
||||
//MLQuestSystem.Tell( quester, pm, 1080107 ); // I'm sorry, I have nothing for you at this time.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
int skillLabel = AosSkillBonuses.GetLabel( m_Skill );
|
||||
string args;
|
||||
|
||||
if ( m_ThresholdFixed % 10 == 0 )
|
||||
args = String.Format( "#{0}\t{1}", skillLabel, m_ThresholdFixed / 10 ); // as seen on OSI
|
||||
else
|
||||
args = String.Format( "#{0}\t{1:0.0}", skillLabel, (double)m_ThresholdFixed / 10 ); // for non-integer skill levels
|
||||
|
||||
g.AddHtmlLocalized( 98, y, 312, 16, 1077485, args, 0x15F90, false, false ); // Increase ~1_SKILL~ to ~2_VALUE~
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
return new GainSkillObjectiveInstance( this, instance );
|
||||
}
|
||||
|
||||
private bool GetFlag( GainSkillObjectiveFlags flag )
|
||||
{
|
||||
return ( ( m_Flags & flag ) != 0 );
|
||||
}
|
||||
|
||||
private void SetFlag( GainSkillObjectiveFlags flag, bool value )
|
||||
{
|
||||
if ( value )
|
||||
m_Flags |= flag;
|
||||
else
|
||||
m_Flags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
// On OSI, once this is complete, it will *stay* complete, even if you lower your skill again
|
||||
public class GainSkillObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private GainSkillObjective m_Objective;
|
||||
|
||||
public GainSkillObjective Objective
|
||||
{
|
||||
get { return m_Objective; }
|
||||
set { m_Objective = value; }
|
||||
}
|
||||
|
||||
public GainSkillObjectiveInstance( GainSkillObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
}
|
||||
|
||||
public bool Handles( SkillName skill )
|
||||
{
|
||||
return ( m_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;
|
||||
|
||||
return ( valueFixed >= m_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 )
|
||||
return;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
pm.AcceleratedSkill = m_Objective.Skill;
|
||||
pm.AcceleratedStart = DateTime.Now + TimeSpan.FromMinutes( 15 ); // TODO: Is there a max duration?
|
||||
}
|
||||
|
||||
public override void OnQuestCancelled()
|
||||
{
|
||||
if ( !m_Objective.Accelerate )
|
||||
return;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
pm.AcceleratedStart = DateTime.Now;
|
||||
pm.PlaySound( 0x100 );
|
||||
}
|
||||
|
||||
public override void OnQuestCompleted()
|
||||
{
|
||||
OnQuestCancelled();
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_Objective.WriteToGump( g, ref y );
|
||||
|
||||
base.WriteToGump( g, ref y );
|
||||
|
||||
if ( IsCompleted() )
|
||||
{
|
||||
g.AddHtmlLocalized( 113, y, 312, 20, 1055121, 0xFFFFFF, false, false ); // Complete
|
||||
y += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
194
Scripts/Engines/MLQuests/Objectives/KillObjective.cs
Normal file
194
Scripts/Engines/MLQuests/Objectives/KillObjective.cs
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
|
||||
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 { return m_DesiredAmount; }
|
||||
set { m_DesiredAmount = value; }
|
||||
}
|
||||
|
||||
public Type[] AcceptedTypes
|
||||
{
|
||||
get { return m_AcceptedTypes; }
|
||||
set { m_AcceptedTypes = value; }
|
||||
}
|
||||
|
||||
public TextDefinition Name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { m_Name = value; }
|
||||
}
|
||||
|
||||
public QuestArea Area
|
||||
{
|
||||
get { return m_Area; }
|
||||
set { m_Area = value; }
|
||||
}
|
||||
|
||||
public KillObjective()
|
||||
: this( 0, null, null, null )
|
||||
{
|
||||
}
|
||||
|
||||
public KillObjective( int amount, Type[] types, TextDefinition name )
|
||||
: this( amount, types, name, null )
|
||||
{
|
||||
}
|
||||
|
||||
public KillObjective( int amount, Type[] types, TextDefinition name, QuestArea area )
|
||||
{
|
||||
m_DesiredAmount = amount;
|
||||
m_AcceptedTypes = types;
|
||||
m_Name = name;
|
||||
m_Area = area;
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
string amount = m_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 );
|
||||
|
||||
y += 16;
|
||||
|
||||
#region Location
|
||||
if ( m_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 );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override BaseObjectiveInstance CreateInstance( MLQuestInstance instance )
|
||||
{
|
||||
return new KillObjectiveInstance( this, instance );
|
||||
}
|
||||
}
|
||||
|
||||
#region Timed
|
||||
|
||||
public class TimedKillObjective : KillObjective
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public override bool IsTimed { get { return true; } }
|
||||
public override TimeSpan Duration { get { return m_Duration; } }
|
||||
|
||||
public TimedKillObjective( TimeSpan duration, int amount, Type[] types, TextDefinition name )
|
||||
: this( duration, amount, types, name, null )
|
||||
{
|
||||
}
|
||||
|
||||
public TimedKillObjective( TimeSpan duration, int amount, Type[] types, TextDefinition name, QuestArea area )
|
||||
: base( amount, types, name, area )
|
||||
{
|
||||
m_Duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class KillObjectiveInstance : BaseObjectiveInstance
|
||||
{
|
||||
private KillObjective m_Objective;
|
||||
private int m_Slain;
|
||||
|
||||
public KillObjective Objective
|
||||
{
|
||||
get { return m_Objective; }
|
||||
set { m_Objective = value; }
|
||||
}
|
||||
|
||||
public int Slain
|
||||
{
|
||||
get { return m_Slain; }
|
||||
set { m_Slain = value; }
|
||||
}
|
||||
|
||||
public KillObjectiveInstance( KillObjective objective, MLQuestInstance instance )
|
||||
: base( instance, objective )
|
||||
{
|
||||
m_Objective = objective;
|
||||
m_Slain = 0;
|
||||
}
|
||||
|
||||
public bool AddKill( Mobile mob, Type type )
|
||||
{
|
||||
int desired = m_Objective.DesiredAmount;
|
||||
|
||||
foreach ( Type acceptedType in m_Objective.AcceptedTypes )
|
||||
{
|
||||
if ( acceptedType.IsAssignableFrom( type ) )
|
||||
{
|
||||
if ( m_Objective.Area != null && !m_Objective.Area.Contains( mob ) )
|
||||
return false;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
if ( ++m_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.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return ( m_Slain >= m_Objective.DesiredAmount );
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
{
|
||||
m_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() );
|
||||
y += 16;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1074782, 0x15F90, false, false ); // Return to
|
||||
g.AddLabel( 223, y, 0x481, Instance.GetReturnTo() );
|
||||
y += 16;
|
||||
}
|
||||
|
||||
public override DataType ExtraDataType { get { return DataType.KillObjective; } }
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( m_Slain );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue