- Modified the quest system to allow non-BaseCreature quest givers, now requires IQuestGiver.
- Added base quest giver items, both timed and untimed. - Added BatteredBucket and Lost and Found quest. - Moved quester 'friendly names' to a class attribute. If left unspecified, the type name is used. - Misc quest corrections. - The bag of sending will now reject nontransferable items. - Fixed quest items generating error messages when StackWith was attempted on them. (StackWith is not supposed to produce feedback.) - Quest items can now be dropped onto the player's backpack.
This commit is contained in:
parent
0fcd5821a5
commit
71a9e054de
36 changed files with 627 additions and 258 deletions
|
|
@ -16,7 +16,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
}
|
||||
|
||||
public virtual bool CanOffer( BaseCreature quester, PlayerMobile pm, bool message )
|
||||
public virtual bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
m_DesiredAmount = amount;
|
||||
m_AcceptedType = type;
|
||||
m_Name = name;
|
||||
|
||||
if ( MLQuestSystem.Debug && ShowDetailed && name.Number > 0 )
|
||||
{
|
||||
int itemid = LabelToItemID( name.Number );
|
||||
|
||||
if ( itemid <= 0 || itemid > 0x4000 )
|
||||
Console.WriteLine( "Warning: cliloc {0} is likely giving the wrong item ID", name.Number );
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckType( Type type )
|
||||
|
|
@ -60,17 +68,10 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
public static int LabelToItemID( int label )
|
||||
{
|
||||
int result;
|
||||
|
||||
if ( label < 1078872 )
|
||||
result = ( label - 1020000 );
|
||||
return ( label - 1020000 );
|
||||
else
|
||||
result = ( label - 1078872 );
|
||||
|
||||
if ( MLQuestSystem.Debug && ( result <= 0 || result > 0x4000 ) )
|
||||
Console.WriteLine( "Warning: cliloc {0} is likely giving the wrong item ID", label );
|
||||
|
||||
return result;
|
||||
return ( label - 1078872 );
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
|
|
@ -250,7 +251,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
y += 16;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1074782, 0x15F90, false, false ); // Return to
|
||||
g.AddLabel( 223, y, 0x481, Instance.GetReturnTo() );
|
||||
g.AddLabel( 223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor( Instance.QuesterType ) );
|
||||
y += 16;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
private int m_Amount;
|
||||
private TextDefinition m_Name;
|
||||
private Type m_Destination;
|
||||
private TextDefinition m_DestinationName;
|
||||
private bool m_SpawnsDelivery;
|
||||
|
||||
public Type Delivery
|
||||
{
|
||||
|
|
@ -39,19 +39,59 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
set { m_Destination = value; }
|
||||
}
|
||||
|
||||
public TextDefinition DestinationName
|
||||
public bool SpawnsDelivery
|
||||
{
|
||||
get { return m_DestinationName; }
|
||||
set { m_DestinationName = value; }
|
||||
get { return m_SpawnsDelivery; }
|
||||
set { m_SpawnsDelivery = value; }
|
||||
}
|
||||
|
||||
public DeliverObjective( Type delivery, int amount, TextDefinition name, Type destination, TextDefinition destinationName )
|
||||
public DeliverObjective( Type delivery, int amount, TextDefinition name, Type destination )
|
||||
: this( delivery, amount, name, destination, true )
|
||||
{
|
||||
}
|
||||
|
||||
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_DestinationName = destinationName;
|
||||
m_SpawnsDelivery = spawnsDelivery;
|
||||
|
||||
if ( MLQuestSystem.Debug && name.Number > 0 )
|
||||
{
|
||||
int itemid = CollectObjective.LabelToItemID( name.Number );
|
||||
|
||||
if ( itemid <= 0 || itemid > 0x4000 )
|
||||
Console.WriteLine( "Warning: cliloc {0} is likely giving the wrong item ID", name.Number );
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SpawnDelivery( Container pack )
|
||||
{
|
||||
if ( !m_SpawnsDelivery || pack == null )
|
||||
return;
|
||||
|
||||
List<Item> delivery = new List<Item>();
|
||||
|
||||
for ( int i = 0; i < m_Amount; ++i )
|
||||
{
|
||||
Item item = Activator.CreateInstance( m_Delivery ) as Item;
|
||||
|
||||
if ( item == null )
|
||||
continue;
|
||||
|
||||
delivery.Add( item );
|
||||
|
||||
if ( item.Stackable && m_Amount > 1 )
|
||||
{
|
||||
item.Amount = m_Amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( Item item in delivery )
|
||||
pack.DropItem( item ); // Confirmed: on OSI items are added even if your pack is full
|
||||
}
|
||||
|
||||
public override void WriteToGump( Gump g, ref int y )
|
||||
|
|
@ -74,11 +114,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
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 );
|
||||
g.AddLabel( 223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor( m_Destination ) );
|
||||
|
||||
y += 16;
|
||||
}
|
||||
|
|
@ -98,8 +134,13 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
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 )
|
||||
public TimedDeliverObjective( TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination )
|
||||
: this( duration, delivery, amount, name, destination, true )
|
||||
{
|
||||
}
|
||||
|
||||
public TimedDeliverObjective( TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination, bool spawnsDelivery )
|
||||
: base( delivery, amount, name, destination, spawnsDelivery )
|
||||
{
|
||||
m_Duration = duration;
|
||||
}
|
||||
|
|
@ -130,7 +171,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
m_Objective = objective;
|
||||
}
|
||||
|
||||
public virtual bool IsDestination( BaseCreature quester, Type type )
|
||||
public virtual bool IsDestination( IQuestGiver quester, Type type )
|
||||
{
|
||||
Type destType = m_Objective.Destination;
|
||||
|
||||
|
|
@ -144,34 +185,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
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
|
||||
m_Objective.SpawnDelivery( Instance.Player.Backpack );
|
||||
}
|
||||
|
||||
// This is VERY similar to CollectObjective.GetCurrentTotal
|
||||
|
|
|
|||
|
|
@ -29,11 +29,9 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
m_Destination = destination;
|
||||
}
|
||||
|
||||
public override bool CanOffer( BaseCreature quester, PlayerMobile pm, bool message )
|
||||
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
|
||||
{
|
||||
BaseEscortable escortable = quester as BaseEscortable;
|
||||
|
||||
if ( quester.Controlled || ( escortable != null && escortable.IsBeingDeleted ) )
|
||||
if ( ( quester is BaseCreature && ( (BaseCreature)quester ).Controlled ) || ( quester is BaseEscortable && ( (BaseEscortable)quester ).IsBeingDeleted ) )
|
||||
return false;
|
||||
|
||||
MLQuestContext context = MLQuestSystem.GetContext( pm );
|
||||
|
|
@ -54,7 +52,6 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
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 )
|
||||
{
|
||||
if ( message )
|
||||
|
|
@ -100,6 +97,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
private bool m_HasCompleted;
|
||||
private Timer m_Timer;
|
||||
private DateTime m_LastSeenEscorter;
|
||||
private BaseCreature m_Escort;
|
||||
|
||||
public bool HasCompleted
|
||||
{
|
||||
|
|
@ -114,43 +112,56 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
m_HasCompleted = false;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 5 ), new TimerCallback( CheckDestination ) );
|
||||
m_LastSeenEscorter = DateTime.Now;
|
||||
m_Escort = instance.Quester as BaseCreature;
|
||||
|
||||
if ( MLQuestSystem.Debug && m_Escort == null && instance.Quester != null )
|
||||
Console.WriteLine( "Warning: EscortObjective is not supported for type '{0}'", instance.Quester.GetType().Name );
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
// Once complete, it stays complete
|
||||
return m_HasCompleted;
|
||||
}
|
||||
|
||||
private void CheckDestination()
|
||||
{
|
||||
if ( m_HasCompleted ) // Completed by deserialization
|
||||
if ( m_Escort == null || 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
|
||||
if ( instance.Removed )
|
||||
{
|
||||
Abandon();
|
||||
}
|
||||
else if ( m_Objective.Destination.Contains( escort ) ) // We've arrived!
|
||||
else if ( m_Objective.Destination.Contains( m_Escort ) )
|
||||
{
|
||||
m_Escort.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.
|
||||
|
||||
if ( pm.Young || m_Escort.Region.IsPartOf( "Haven Island" ) )
|
||||
Titles.AwardFame( pm, 10, true );
|
||||
else
|
||||
VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( m_Escort is BaseEscortable && ( (BaseEscortable)m_Escort ).IsPrisoner ) ? 400 : 200 );
|
||||
|
||||
EndFollow( m_Escort );
|
||||
StopTimer();
|
||||
|
||||
m_HasCompleted = true;
|
||||
CheckComplete();
|
||||
InternalOnQuestCompleted();
|
||||
StopTimer();
|
||||
|
||||
// Auto claim reward
|
||||
MLQuestSystem.OnDoubleClick( m_Escort, pm );
|
||||
}
|
||||
else if ( pm.Map != escort.Map || !pm.InRange( escort, 30 ) ) // Player abandoned us (range not verified)
|
||||
else if ( pm.Map != m_Escort.Map || !pm.InRange( m_Escort, 30 ) ) // TODO: verify range
|
||||
{
|
||||
if ( m_LastSeenEscorter + BaseEscortable.AbandonDelay <= DateTime.Now )
|
||||
Abandon();
|
||||
}
|
||||
else // Player is still with us
|
||||
else
|
||||
{
|
||||
m_LastSeenEscorter = DateTime.Now;
|
||||
}
|
||||
|
|
@ -203,7 +214,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
pm.LastEscortTime = DateTime.Now;
|
||||
|
||||
BeginFollow( instance.Quester, pm );
|
||||
if ( m_Escort != null )
|
||||
BeginFollow( m_Escort, pm );
|
||||
}
|
||||
|
||||
public void Abandon()
|
||||
|
|
@ -211,17 +223,16 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
StopTimer();
|
||||
|
||||
MLQuestInstance instance = Instance;
|
||||
BaseCreature quester = instance.Quester;
|
||||
PlayerMobile pm = instance.Player;
|
||||
|
||||
if ( !quester.Deleted )
|
||||
if ( m_Escort != null && !m_Escort.Deleted )
|
||||
{
|
||||
if ( !pm.Alive )
|
||||
quester.Say( 500901 ); // Ack! My escort has come to haunt me!
|
||||
m_Escort.Say( 500901 ); // Ack! My escort has come to haunt me!
|
||||
else
|
||||
quester.Say( 500902 ); // My escort seems to have abandoned me!
|
||||
m_Escort.Say( 500902 ); // My escort seems to have abandoned me!
|
||||
|
||||
EndFollow( quester );
|
||||
EndFollow( m_Escort );
|
||||
}
|
||||
|
||||
// Note: this sound is sent twice on OSI (once here and once in Cancel())
|
||||
|
|
@ -232,25 +243,6 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
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 )
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
m_Flags |= GainSkillObjectiveFlags.Accelerate;
|
||||
}
|
||||
|
||||
public override bool CanOffer( BaseCreature quester, PlayerMobile pm, bool message )
|
||||
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
|
||||
{
|
||||
Skill skill = pm.Skills[m_Skill];
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
y += 16;
|
||||
|
||||
g.AddHtmlLocalized( 103, y, 120, 16, 1074782, 0x15F90, false, false ); // Return to
|
||||
g.AddLabel( 223, y, 0x481, Instance.GetReturnTo() );
|
||||
g.AddLabel( 223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor( Instance.QuesterType ) );
|
||||
y += 16;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue