This reverts commit 179cb50557.
This commit is contained in:
parent
179cb50557
commit
c2ecc76457
588 changed files with 16260 additions and 10926 deletions
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Buffers;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -89,7 +87,7 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
CloseCurrent(ns);
|
||||
|
||||
m_Pending[ns] = new RaceChangeState(owner, ns, targetRace);
|
||||
SendRaceChanger(ns, from.Female, targetRace);
|
||||
ns.Send(new RaceChanger(from.Female, targetRace));
|
||||
}
|
||||
|
||||
private static void CloseCurrent(NetState ns)
|
||||
|
|
@ -100,7 +98,7 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
m_Pending.Remove(ns);
|
||||
}
|
||||
|
||||
SendCloseRaceChanger(ns);
|
||||
ns.Send(CloseRaceChanger.Instance);
|
||||
}
|
||||
|
||||
private static void Timeout(NetState ns)
|
||||
|
|
@ -108,21 +106,30 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
if (IsPending(ns))
|
||||
{
|
||||
m_Pending.Remove(ns);
|
||||
SendCloseRaceChanger(ns);
|
||||
ns.Send(CloseRaceChanger.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsWearingEquipment(Mobile from)
|
||||
{
|
||||
return from.Items.Select(item => item.Layer switch
|
||||
foreach (Item item in from.Items)
|
||||
switch (item.Layer)
|
||||
{
|
||||
Layer.Hair => false,
|
||||
Layer.FacialHair => false,
|
||||
Layer.Backpack => false,
|
||||
Layer.Mount => false,
|
||||
Layer.Bank => false,
|
||||
_ => true
|
||||
}).FirstOrDefault();
|
||||
case Layer.Hair:
|
||||
case Layer.FacialHair:
|
||||
case Layer.Backpack:
|
||||
case Layer.Mount:
|
||||
case Layer.Bank:
|
||||
{
|
||||
continue; // ignore
|
||||
}
|
||||
default:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CanChange(PlayerMobile from, Race targetRace)
|
||||
|
|
@ -231,34 +238,38 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
m_Timeout = Timer.DelayCall(m_TimeoutDelay, Timeout, ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendRaceChanger(NetState ns, bool female, Race targetRace)
|
||||
public sealed class RaceChanger : Packet
|
||||
{
|
||||
public RaceChanger(bool female, Race targetRace)
|
||||
: base(0xBF)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
EnsureCapacity(7);
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[7]);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)0x07); // Dynamic Length
|
||||
|
||||
writer.Write((short)0x2A);
|
||||
writer.Write(female);
|
||||
writer.Write((byte)(targetRace.RaceID + 1));
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
private static void SendCloseRaceChanger(NetState ns)
|
||||
{
|
||||
ns?.Send(stackalloc byte[]
|
||||
{
|
||||
0xBF, // Packet ID
|
||||
0x07, // Dynamic Length
|
||||
0x00,
|
||||
0xFF
|
||||
});
|
||||
m_Stream.Write((short)0x2A);
|
||||
m_Stream.Write((byte)(female ? 1 : 0));
|
||||
m_Stream.Write((byte)(targetRace.RaceID + 1));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CloseRaceChanger : Packet
|
||||
{
|
||||
public static readonly Packet Instance = SetStatic(new CloseRaceChanger());
|
||||
|
||||
private CloseRaceChanger()
|
||||
: base(0xBF)
|
||||
{
|
||||
EnsureCapacity(7);
|
||||
|
||||
m_Stream.Write((short)0x2A);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
#region For testing
|
||||
|
||||
public class RaceChangeDeed : Item, IRaceChanger
|
||||
{
|
||||
[Constructible]
|
||||
|
|
@ -319,4 +330,6 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,14 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public virtual int Version => 0;
|
||||
|
||||
public bool HasObjective<T>() where T : BaseObjective => Objectives.OfType<T>().Any();
|
||||
public bool HasObjective<T>() where T : BaseObjective
|
||||
{
|
||||
foreach (BaseObjective obj in Objectives)
|
||||
if (obj is T)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void Generate()
|
||||
{
|
||||
|
|
@ -144,7 +151,11 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
}
|
||||
|
||||
return Objectives.All(obj => obj.CanOffer(quester, pm, message));
|
||||
foreach (BaseObjective obj in Objectives)
|
||||
if (!obj.CanOffer(quester, pm, message))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void SendOffer(IQuestGiver quester, PlayerMobile pm)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.MLQuests
|
||||
|
|
@ -114,7 +113,14 @@ namespace Server.Engines.MLQuests
|
|||
return quest != null && HasDoneQuest(quest);
|
||||
}
|
||||
|
||||
public bool HasDoneQuest(MLQuest quest) => m_DoneQuests.Any(info => info.m_Quest == quest);
|
||||
public bool HasDoneQuest(MLQuest quest)
|
||||
{
|
||||
foreach (MLDoneQuestInfo info in m_DoneQuests)
|
||||
if (info.m_Quest == quest)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasDoneQuest(MLQuest quest, out DateTime nextAvailable)
|
||||
{
|
||||
|
|
@ -174,10 +180,20 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
MLQuest quest = MLQuestSystem.FindQuest(questType);
|
||||
|
||||
return quest == null ? null : FindInstance(quest);
|
||||
if (quest == null)
|
||||
return null;
|
||||
|
||||
return FindInstance(quest);
|
||||
}
|
||||
|
||||
public MLQuestInstance FindInstance(MLQuest quest) => QuestInstances.FirstOrDefault(instance => instance.Quest == quest);
|
||||
public MLQuestInstance FindInstance(MLQuest quest)
|
||||
{
|
||||
foreach (MLQuestInstance instance in QuestInstances)
|
||||
if (instance.Quest == quest)
|
||||
return instance;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsDoingQuest(Type questType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Engines.MLQuests.Gumps;
|
||||
using Server.Engines.MLQuests.Objectives;
|
||||
using Server.Engines.MLQuests.Rewards;
|
||||
|
|
@ -37,7 +36,16 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
Objectives = new BaseObjectiveInstance[quest.Objectives.Count];
|
||||
|
||||
bool timed = quest.Objectives.Aggregate(false, (current, t) => current | t.CreateInstance(this).IsTimed);
|
||||
BaseObjectiveInstance obj;
|
||||
bool timed = false;
|
||||
|
||||
for (int i = 0; i < quest.Objectives.Count; ++i)
|
||||
{
|
||||
Objectives[i] = obj = quest.Objectives[i].CreateInstance(this);
|
||||
|
||||
if (obj.IsTimed)
|
||||
timed = true;
|
||||
}
|
||||
|
||||
Register();
|
||||
|
||||
|
|
@ -105,8 +113,14 @@ namespace Server.Engines.MLQuests
|
|||
Removed = true;
|
||||
}
|
||||
|
||||
public bool AllowsQuestItem(Item item, Type type) =>
|
||||
Objectives.Any(objective => !objective.Expired && objective.AllowsQuestItem(item, type));
|
||||
public bool AllowsQuestItem(Item item, Type type)
|
||||
{
|
||||
foreach (BaseObjectiveInstance objective in Objectives)
|
||||
if (!objective.Expired && objective.AllowsQuestItem(item, type))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsCompleted()
|
||||
{
|
||||
|
|
@ -238,11 +252,13 @@ namespace Server.Engines.MLQuests
|
|||
if (Quest.ObjectiveType == ObjectiveType.All)
|
||||
{
|
||||
// TODO: 1115877 - You no longer have the required items to complete this quest.
|
||||
if (Objectives.Any(objective => !objective.IsCompleted()))
|
||||
return;
|
||||
foreach (BaseObjectiveInstance objective in Objectives)
|
||||
if (!objective.IsCompleted())
|
||||
return;
|
||||
|
||||
if (Objectives.Any(objective => !objective.OnBeforeClaimReward()))
|
||||
return;
|
||||
foreach (BaseObjectiveInstance objective in Objectives)
|
||||
if (!objective.OnBeforeClaimReward())
|
||||
return;
|
||||
|
||||
foreach (BaseObjectiveInstance objective in Objectives)
|
||||
objective.OnClaimReward();
|
||||
|
|
@ -298,7 +314,14 @@ namespace Server.Engines.MLQuests
|
|||
{
|
||||
// On OSI a more naive method of checking is used.
|
||||
// For containers, only the actual container item counts.
|
||||
bool canFit = rewards.All(rewardItem => Player.AddToBackpack(rewardItem));
|
||||
bool canFit = true;
|
||||
|
||||
foreach (Item rewardItem in rewards)
|
||||
if (!Player.AddToBackpack(rewardItem))
|
||||
{
|
||||
canFit = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!canFit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
public static void EnsureExistence()
|
||||
{
|
||||
m_Instance ??= new MLQuestPersistence();
|
||||
if (m_Instance == null)
|
||||
m_Instance = new MLQuestPersistence();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -54,4 +55,4 @@ namespace Server.Engines.MLQuests
|
|||
MLQuest.Deserialize(reader, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Engines.MLQuests.Gumps;
|
||||
|
|
@ -214,7 +213,7 @@ namespace Server.Engines.MLQuests
|
|||
return;
|
||||
}
|
||||
|
||||
bool enable = e.Length != 1 || e.GetBoolean(0);
|
||||
bool enable = e.Length == 1 ? e.GetBoolean(0) : true;
|
||||
|
||||
foreach (MLQuest quest in Quests.Values)
|
||||
quest.SaveEnabled = enable;
|
||||
|
|
@ -330,8 +329,17 @@ namespace Server.Engines.MLQuests
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CanMarkQuestItem(PlayerMobile pm, Item item, Type type) =>
|
||||
GetContext(pm)?.QuestInstances.Any(quest => !quest.ClaimReward && quest.AllowsQuestItem(item, type)) == true;
|
||||
public static bool CanMarkQuestItem(PlayerMobile pm, Item item, Type type)
|
||||
{
|
||||
MLQuestContext context = GetContext(pm);
|
||||
|
||||
if (context != null)
|
||||
foreach (MLQuestInstance quest in context.QuestInstances)
|
||||
if (!quest.ClaimReward && quest.AllowsQuestItem(item, type))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void OnMarkQuestItem(PlayerMobile pm, Item item, Type type)
|
||||
{
|
||||
|
|
@ -555,7 +563,8 @@ namespace Server.Engines.MLQuests
|
|||
* Save first quest that reaches the CanOffer call.
|
||||
* If no quests are valid at all, return this quest for displaying the CanOffer error message.
|
||||
*/
|
||||
fallback ??= quest;
|
||||
if (fallback == null)
|
||||
fallback = quest;
|
||||
|
||||
if (quest.CanOffer(quester, pm, context, false))
|
||||
m_EligiblePool.Add(quest);
|
||||
|
|
@ -634,7 +643,7 @@ namespace Server.Engines.MLQuests
|
|||
if (questType == null)
|
||||
return null; // no longer a type
|
||||
|
||||
return questType == null ? null : FindQuest(questType);
|
||||
return FindQuest(questType);
|
||||
}
|
||||
|
||||
public static MLQuest FindQuest(Type questType)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Engines.MLQuests.Definitions;
|
||||
using Server.Engines.MLQuests.Gumps;
|
||||
using Server.Items;
|
||||
|
|
@ -136,7 +135,20 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
{
|
||||
MLQuestContext context = MLQuestSystem.GetContext(pm);
|
||||
|
||||
return context == null ? 0 : Needed.Select(MLQuestSystem.FindQuest).Count(quest => quest == null || context.HasDoneQuest(quest));
|
||||
if (context == null)
|
||||
return 0;
|
||||
|
||||
int result = 0;
|
||||
|
||||
foreach (Type type in Needed)
|
||||
{
|
||||
MLQuest quest = MLQuestSystem.FindQuest(type);
|
||||
|
||||
if (quest == null || context.HasDoneQuest(quest))
|
||||
++result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual void OnComplete(PlayerMobile pm)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
|
||||
public override bool GetGender() => false;
|
||||
|
||||
public override bool CheckMorph() => true;
|
||||
public override void CheckMorph()
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
|
|
@ -51,9 +53,22 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
HairHue = FacialHairHue = 0x8A7;
|
||||
|
||||
AddItem(new Sandals());
|
||||
AddItem(new Cloak{ ItemID = 0x26AD, Hue = 0x455});
|
||||
AddItem(new Robe {ItemID = 0x26AE, Hue = 0x4AB});
|
||||
AddItem(new Backpack {Movable = false});
|
||||
|
||||
Item item;
|
||||
|
||||
item = new Cloak();
|
||||
item.ItemID = 0x26AD;
|
||||
item.Hue = 0x455;
|
||||
AddItem(item);
|
||||
|
||||
item = new Robe();
|
||||
item.ItemID = 0x26AE;
|
||||
item.Hue = 0x4AB;
|
||||
AddItem(item);
|
||||
|
||||
item = new Backpack();
|
||||
item.Movable = false;
|
||||
AddItem(item);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
|
|
@ -77,23 +92,32 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
|
||||
if (m_NextShout <= DateTime.UtcNow)
|
||||
{
|
||||
IPooledEnumerable eable = GetClientsInRange(12);
|
||||
foreach (NetState state in eable)
|
||||
Packet shoutPacket = null;
|
||||
|
||||
foreach (NetState state in GetClientsInRange(12))
|
||||
{
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
|
||||
Packets.SendMessageLocalized(state, Serial, Body, MessageType.Regular, 946, 3,
|
||||
1078099, Name); // Double Click On Me For Help!
|
||||
{
|
||||
if (shoutPacket == null)
|
||||
shoutPacket = Packet.Acquire(new MessageLocalized(Serial, Body, MessageType.Regular, 946, 3,
|
||||
1078099, Name, "")); // Double Click On Me For Help!
|
||||
|
||||
state.Send(shoutPacket);
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
Packet.Release(shoutPacket);
|
||||
|
||||
m_NextShout = DateTime.UtcNow + m_ShoutDelay;
|
||||
}
|
||||
}
|
||||
|
||||
private void EndLock(Mobile m) => m.EndAction(this);
|
||||
private void EndLock(Mobile m)
|
||||
{
|
||||
m.EndAction(this);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
|
|
@ -111,4 +135,4 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
Frozen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -21,13 +20,14 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
MLQuestContext context = MLQuestSystem.GetContext(pm);
|
||||
|
||||
if (context != null)
|
||||
if (context.QuestInstances.Any(instance => instance.Quest.IsEscort))
|
||||
{
|
||||
if (message)
|
||||
MLQuestSystem.Tell(quester, pm, 500896); // I see you already have an escort.
|
||||
foreach (MLQuestInstance instance in context.QuestInstances)
|
||||
if (instance.Quest.IsEscort)
|
||||
{
|
||||
if (message)
|
||||
MLQuestSystem.Tell(quester, pm, 500896); // I see you already have an escort.
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DateTime nextEscort = pm.LastEscortTime + BaseEscortable.EscortDelay;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
|
||||
|
|
@ -92,21 +91,22 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
{
|
||||
int desired = Objective.DesiredAmount;
|
||||
|
||||
if (Objective.AcceptedTypes.Any(acceptedType => acceptedType.IsAssignableFrom(type)))
|
||||
{
|
||||
if (Objective.Area?.Contains(mob) == false)
|
||||
return false;
|
||||
foreach (Type acceptedType in Objective.AcceptedTypes)
|
||||
if (acceptedType.IsAssignableFrom(type))
|
||||
{
|
||||
if (Objective.Area?.Contains(mob) == false)
|
||||
return false;
|
||||
|
||||
PlayerMobile pm = Instance.Player;
|
||||
PlayerMobile pm = Instance.Player;
|
||||
|
||||
if (++Slain >= desired)
|
||||
pm.SendLocalizedMessage(1075050); // You have killed all the required quest creatures of this type.
|
||||
else
|
||||
pm.SendLocalizedMessage(1075051,
|
||||
(desired - Slain).ToString()); // You have killed a quest creature. ~1_val~ more left.
|
||||
if (++Slain >= desired)
|
||||
pm.SendLocalizedMessage(1075050); // You have killed all the required quest creatures of this type.
|
||||
else
|
||||
pm.SendLocalizedMessage(1075051,
|
||||
(desired - Slain).ToString()); // You have killed a quest creature. ~1_val~ more left.
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Engines.MLQuests
|
||||
{
|
||||
|
|
@ -35,7 +34,14 @@ namespace Server.Engines.MLQuests
|
|||
// Debug method
|
||||
public void Validate()
|
||||
{
|
||||
bool found = Region.Regions.Any(r => r.Name == RegionName && (ForceMap == null || r.Map == ForceMap));
|
||||
bool found = false;
|
||||
|
||||
foreach (Region r in Region.Regions)
|
||||
if (r.Name == RegionName && (ForceMap == null || r.Map == ForceMap))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
Console.WriteLine("Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue