fix: Codegens more quest entities (#1538)
This commit is contained in:
parent
0086d674e7
commit
0018901a79
114 changed files with 4087 additions and 4867 deletions
|
|
@ -1,115 +1,98 @@
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests
|
||||
namespace Server.Engines.Quests;
|
||||
|
||||
public class TalkEntry : ContextMenuEntry
|
||||
{
|
||||
public class TalkEntry : ContextMenuEntry
|
||||
private readonly BaseQuester _quester;
|
||||
|
||||
public TalkEntry(BaseQuester quester) : base(quester.TalkNumber) => _quester = quester;
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
private readonly BaseQuester m_Quester;
|
||||
var from = Owner.From;
|
||||
|
||||
public TalkEntry(BaseQuester quester) : base(quester.TalkNumber) => m_Quester = quester;
|
||||
|
||||
public override void OnClick()
|
||||
if (from.CheckAlive() && from is PlayerMobile mobile && _quester.CanTalkTo(mobile))
|
||||
{
|
||||
var from = Owner.From;
|
||||
|
||||
if (from.CheckAlive() && from is PlayerMobile mobile && m_Quester.CanTalkTo(mobile))
|
||||
{
|
||||
m_Quester.OnTalk(mobile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseQuester : BaseVendor
|
||||
{
|
||||
protected List<SBInfo> m_SBInfos = new();
|
||||
|
||||
public BaseQuester(string title = null) : base(title)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseQuester(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<SBInfo> SBInfos => m_SBInfos;
|
||||
|
||||
public override bool IsActiveVendor => false;
|
||||
public override bool IsInvulnerable => true;
|
||||
public override bool DisallowAllMoves => true;
|
||||
public override bool ClickTitle => false;
|
||||
public override bool CanTeach => false;
|
||||
|
||||
public virtual int TalkNumber // Talk
|
||||
=> 6146;
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void OnTalk(PlayerMobile player, bool contextMenu);
|
||||
|
||||
public virtual bool CanTalkTo(PlayerMobile to) => true;
|
||||
|
||||
public virtual int GetAutoTalkRange(PlayerMobile m) => -1;
|
||||
|
||||
public override bool CanBeDamaged() => false;
|
||||
|
||||
protected Item SetHue(Item item, int hue)
|
||||
{
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.AddCustomContextEntries(from, list);
|
||||
|
||||
if (from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo(mobile))
|
||||
{
|
||||
list.Add(new TalkEntry(this));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m.Alive && m is PlayerMobile pm)
|
||||
{
|
||||
var range = GetAutoTalkRange(pm);
|
||||
|
||||
if (pm.Alive && range >= 0 && InRange(m, range) && !InRange(oldLocation, range) && CanTalkTo(pm))
|
||||
{
|
||||
OnTalk(pm, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FocusTo(Mobile to)
|
||||
{
|
||||
QuestSystem.FocusTo(this, to);
|
||||
}
|
||||
|
||||
public static Container GetNewContainer()
|
||||
{
|
||||
var bag = new Bag();
|
||||
bag.Hue = QuestSystem.RandomBrightHue();
|
||||
return bag;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
_quester.OnTalk(mobile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public abstract partial class BaseQuester : BaseVendor
|
||||
{
|
||||
protected List<SBInfo> _sbInfos = new();
|
||||
|
||||
public BaseQuester(string title = null) : base(title)
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<SBInfo> SBInfos => _sbInfos;
|
||||
|
||||
public override bool IsActiveVendor => false;
|
||||
public override bool IsInvulnerable => true;
|
||||
public override bool DisallowAllMoves => true;
|
||||
public override bool ClickTitle => false;
|
||||
public override bool CanTeach => false;
|
||||
|
||||
public virtual int TalkNumber => 6146; // Talk
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void OnTalk(PlayerMobile player, bool contextMenu);
|
||||
|
||||
public virtual bool CanTalkTo(PlayerMobile to) => true;
|
||||
|
||||
public virtual int GetAutoTalkRange(PlayerMobile m) => -1;
|
||||
|
||||
public override bool CanBeDamaged() => false;
|
||||
|
||||
protected Item SetHue(Item item, int hue)
|
||||
{
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.AddCustomContextEntries(from, list);
|
||||
|
||||
if (from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo(mobile))
|
||||
{
|
||||
list.Add(new TalkEntry(this));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m.Alive && m is PlayerMobile pm)
|
||||
{
|
||||
var range = GetAutoTalkRange(pm);
|
||||
|
||||
if (pm.Alive && range >= 0 && InRange(m, range) && !InRange(oldLocation, range) && CanTalkTo(pm))
|
||||
{
|
||||
OnTalk(pm, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FocusTo(Mobile to)
|
||||
{
|
||||
QuestSystem.FocusTo(this, to);
|
||||
}
|
||||
|
||||
public static Container GetNewContainer()
|
||||
{
|
||||
return new Bag
|
||||
{
|
||||
Hue = QuestSystem.RandomBrightHue()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,43 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests
|
||||
namespace Server.Engines.Quests;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public abstract partial class DynamicTeleporter : Item
|
||||
{
|
||||
public abstract class DynamicTeleporter : Item
|
||||
public DynamicTeleporter(int itemID = 0x1822, int hue = 0x482) : base(itemID)
|
||||
{
|
||||
public DynamicTeleporter(int itemID = 0x1822, int hue = 0x482) : base(itemID)
|
||||
Movable = false;
|
||||
Hue = hue;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1049382; // a magical teleporter
|
||||
|
||||
public virtual int NotWorkingMessage => 500309; // Nothing Happens.
|
||||
|
||||
public abstract bool GetDestination(PlayerMobile player, ref Point3D loc, ref Map map);
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile pm)
|
||||
{
|
||||
Movable = false;
|
||||
Hue = hue;
|
||||
}
|
||||
var loc = Point3D.Zero;
|
||||
Map map = null;
|
||||
|
||||
public DynamicTeleporter(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1049382; // a magical teleporter
|
||||
|
||||
public virtual int NotWorkingMessage // Nothing Happens.
|
||||
=> 500309;
|
||||
|
||||
public abstract bool GetDestination(PlayerMobile player, ref Point3D loc, ref Map map);
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile pm)
|
||||
if (GetDestination(pm, ref loc, ref map))
|
||||
{
|
||||
var loc = Point3D.Zero;
|
||||
Map map = null;
|
||||
BaseCreature.TeleportPets(pm, loc, map);
|
||||
|
||||
if (GetDestination(pm, ref loc, ref map))
|
||||
{
|
||||
BaseCreature.TeleportPets(pm, loc, map);
|
||||
pm.PlaySound(0x1FE);
|
||||
pm.MoveToWorld(loc, map);
|
||||
|
||||
pm.PlaySound(0x1FE);
|
||||
pm.MoveToWorld(loc, map);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pm.SendLocalizedMessage(NotWorkingMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnMoveOver(m);
|
||||
pm.SendLocalizedMessage(NotWorkingMessage);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
return base.OnMoveOver(m);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,187 +1,173 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class EnchantedSextant : Item
|
||||
{
|
||||
public class EnchantedSextant : Item
|
||||
private const double LongDistance = 300.0;
|
||||
|
||||
private const double ShortDistance = 5.0;
|
||||
|
||||
// TODO: Use region types/names or types
|
||||
// TODO: Add Tokuno/TerMur?
|
||||
|
||||
// TODO: Trammel/Haven
|
||||
private static readonly Point2D[] _trammelBanks =
|
||||
{
|
||||
private const double m_LongDistance = 300.0;
|
||||
new(652, 820),
|
||||
new(1813, 2825),
|
||||
new(3734, 2149),
|
||||
new(2503, 552),
|
||||
new(3764, 1317),
|
||||
new(587, 2146),
|
||||
new(1655, 1606),
|
||||
new(1425, 1690),
|
||||
new(4471, 1156),
|
||||
new(1317, 3773),
|
||||
new(2881, 684),
|
||||
new(2731, 2192),
|
||||
new(3620, 2617),
|
||||
new(2880, 3472),
|
||||
new(1897, 2684),
|
||||
new(5346, 74),
|
||||
new(5275, 3977),
|
||||
new(5669, 3131)
|
||||
};
|
||||
|
||||
private const double m_ShortDistance = 5.0;
|
||||
private static readonly Point2D[] _feluccaBanks =
|
||||
{
|
||||
new(652, 820),
|
||||
new(1813, 2825),
|
||||
new(3734, 2149),
|
||||
new(2503, 552),
|
||||
new(3764, 1317),
|
||||
new(3695, 2511),
|
||||
new(587, 2146),
|
||||
new(1655, 1606),
|
||||
new(1425, 1690),
|
||||
new(4471, 1156),
|
||||
new(1317, 3773),
|
||||
new(2881, 684),
|
||||
new(2731, 2192),
|
||||
new(2880, 3472),
|
||||
new(1897, 2684),
|
||||
new(5346, 74),
|
||||
new(5275, 3977),
|
||||
new(5669, 3131)
|
||||
};
|
||||
|
||||
// TODO: Trammel/Haven
|
||||
private static readonly Point2D[] m_TrammelBanks =
|
||||
{
|
||||
new(652, 820),
|
||||
new(1813, 2825),
|
||||
new(3734, 2149),
|
||||
new(2503, 552),
|
||||
new(3764, 1317),
|
||||
new(587, 2146),
|
||||
new(1655, 1606),
|
||||
new(1425, 1690),
|
||||
new(4471, 1156),
|
||||
new(1317, 3773),
|
||||
new(2881, 684),
|
||||
new(2731, 2192),
|
||||
new(3620, 2617),
|
||||
new(2880, 3472),
|
||||
new(1897, 2684),
|
||||
new(5346, 74),
|
||||
new(5275, 3977),
|
||||
new(5669, 3131)
|
||||
};
|
||||
|
||||
private static readonly Point2D[] m_FeluccaBanks =
|
||||
{
|
||||
new(652, 820),
|
||||
new(1813, 2825),
|
||||
new(3734, 2149),
|
||||
new(2503, 552),
|
||||
new(3764, 1317),
|
||||
new(3695, 2511),
|
||||
new(587, 2146),
|
||||
new(1655, 1606),
|
||||
new(1425, 1690),
|
||||
new(4471, 1156),
|
||||
new(1317, 3773),
|
||||
new(2881, 684),
|
||||
new(2731, 2192),
|
||||
new(2880, 3472),
|
||||
new(1897, 2684),
|
||||
new(5346, 74),
|
||||
new(5275, 3977),
|
||||
new(5669, 3131)
|
||||
};
|
||||
|
||||
private static readonly Point2D[] m_IlshenarBanks =
|
||||
{
|
||||
new(854, 680),
|
||||
new(855, 603),
|
||||
new(1226, 554),
|
||||
new(1610, 556)
|
||||
};
|
||||
|
||||
private static readonly Point2D[] m_MalasBanks =
|
||||
{
|
||||
new(996, 519),
|
||||
new(2048, 1345)
|
||||
};
|
||||
|
||||
[Constructible]
|
||||
public EnchantedSextant() : base(0x1058) => Weight = 2.0;
|
||||
|
||||
public EnchantedSextant(Serial serial) : base(serial)
|
||||
private static readonly Point2D[] _ilshenarBanks =
|
||||
{
|
||||
new(854, 680),
|
||||
new(855, 603),
|
||||
new(1226, 554),
|
||||
new(1610, 556)
|
||||
};
|
||||
|
||||
private static readonly Point2D[] _malasBanks =
|
||||
{
|
||||
new(996, 519),
|
||||
new(2048, 1345)
|
||||
};
|
||||
|
||||
[Constructible]
|
||||
public EnchantedSextant() : base(0x1058) => Weight = 2.0;
|
||||
|
||||
public override int LabelNumber => 1046226; // an enchanted sextant
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1046226; // an enchanted sextant
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
Point2D[] banks;
|
||||
PMList moongates;
|
||||
if (from.Map == Map.Trammel)
|
||||
{
|
||||
banks = _trammelBanks;
|
||||
moongates = PMList.Trammel;
|
||||
}
|
||||
else if (from.Map == Map.Felucca)
|
||||
{
|
||||
banks = _feluccaBanks;
|
||||
moongates = PMList.Felucca;
|
||||
}
|
||||
else if (from.Map == Map.Ilshenar)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
Point2D[] banks;
|
||||
PMList moongates;
|
||||
if (from.Map == Map.Trammel)
|
||||
{
|
||||
banks = m_TrammelBanks;
|
||||
moongates = PMList.Trammel;
|
||||
}
|
||||
else if (from.Map == Map.Felucca)
|
||||
{
|
||||
banks = m_FeluccaBanks;
|
||||
moongates = PMList.Felucca;
|
||||
}
|
||||
else if (from.Map == Map.Ilshenar)
|
||||
{
|
||||
#if false
|
||||
banks = m_IlshenarBanks;
|
||||
moongates = PMList.Ilshenar;
|
||||
#else
|
||||
// The magic of the sextant fails...
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, 1061684);
|
||||
// The magic of the sextant fails...
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, 1061684);
|
||||
|
||||
return;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
else if (from.Map == Map.Malas)
|
||||
{
|
||||
banks = m_MalasBanks;
|
||||
moongates = PMList.Malas;
|
||||
}
|
||||
else
|
||||
{
|
||||
banks = null;
|
||||
moongates = null;
|
||||
}
|
||||
}
|
||||
else if (from.Map == Map.Malas)
|
||||
{
|
||||
banks = _malasBanks;
|
||||
moongates = PMList.Malas;
|
||||
}
|
||||
else
|
||||
{
|
||||
banks = null;
|
||||
moongates = null;
|
||||
}
|
||||
|
||||
var closestMoongate = Point3D.Zero;
|
||||
var moongateDistance = double.MaxValue;
|
||||
if (moongates != null)
|
||||
var closestMoongate = Point3D.Zero;
|
||||
var moongateDistance = double.MaxValue;
|
||||
if (moongates != null)
|
||||
{
|
||||
foreach (var entry in moongates.Entries)
|
||||
{
|
||||
foreach (var entry in moongates.Entries)
|
||||
var dist = from.GetDistanceToSqrt(entry.Location);
|
||||
if (moongateDistance > dist)
|
||||
{
|
||||
var dist = from.GetDistanceToSqrt(entry.Location);
|
||||
if (moongateDistance > dist)
|
||||
{
|
||||
closestMoongate = entry.Location;
|
||||
moongateDistance = dist;
|
||||
}
|
||||
closestMoongate = entry.Location;
|
||||
moongateDistance = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var closestBank = Point2D.Zero;
|
||||
var bankDistance = double.MaxValue;
|
||||
if (banks != null)
|
||||
var closestBank = Point2D.Zero;
|
||||
var bankDistance = double.MaxValue;
|
||||
if (banks != null)
|
||||
{
|
||||
foreach (var p in banks)
|
||||
{
|
||||
foreach (var p in banks)
|
||||
var dist = from.GetDistanceToSqrt(p);
|
||||
if (bankDistance > dist)
|
||||
{
|
||||
var dist = from.GetDistanceToSqrt(p);
|
||||
if (bankDistance > dist)
|
||||
{
|
||||
closestBank = p;
|
||||
bankDistance = dist;
|
||||
}
|
||||
closestBank = p;
|
||||
bankDistance = dist;
|
||||
}
|
||||
}
|
||||
|
||||
int moonMsg = moongateDistance switch
|
||||
{
|
||||
double.MaxValue => 1048021, // The sextant fails to find a Moongate nearby.
|
||||
> m_LongDistance => 1046449 + (int)from.GetDirectionTo(closestMoongate), // A moongate is * from here
|
||||
> m_ShortDistance => 1048010 + (int)from.GetDirectionTo(closestMoongate), // There is a Moongate * of here.
|
||||
_ => 1048018 // You are next to a Moongate at the moment.
|
||||
};
|
||||
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg);
|
||||
|
||||
int bankMsg = bankDistance switch
|
||||
{
|
||||
double.MaxValue => 1048020, // The sextant fails to find a Bank nearby.
|
||||
> m_LongDistance => 1046462 + (int)from.GetDirectionTo(closestBank), // A town is * from here
|
||||
> m_ShortDistance => 1048002 + (int)from.GetDirectionTo(closestBank), // There is a city Bank * of here.
|
||||
_ => 1048019 // You are next to a Bank at the moment.
|
||||
};
|
||||
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
int moonMsg = moongateDistance switch
|
||||
{
|
||||
base.Serialize(writer);
|
||||
double.MaxValue => 1048021, // The sextant fails to find a Moongate nearby.
|
||||
> LongDistance => 1046449 + (int)from.GetDirectionTo(closestMoongate), // A moongate is * from here
|
||||
> ShortDistance => 1048010 + (int)from.GetDirectionTo(closestMoongate), // There is a Moongate * of here.
|
||||
_ => 1048018 // You are next to a Moongate at the moment.
|
||||
};
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg);
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
int bankMsg = bankDistance switch
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
double.MaxValue => 1048020, // The sextant fails to find a Bank nearby.
|
||||
> LongDistance => 1046462 + (int)from.GetDirectionTo(closestBank), // A town is * from here
|
||||
> ShortDistance => 1048002 + (int)from.GetDirectionTo(closestBank), // There is a city Bank * of here.
|
||||
_ => 1048019 // You are next to a Bank at the moment.
|
||||
};
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
from.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,192 +1,140 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Items;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Engines.Quests
|
||||
namespace Server.Engines.Quests;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HornOfRetreat : Item
|
||||
{
|
||||
public class HornOfRetreat : Item
|
||||
[SerializableField(0)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private Point3D _destLoc;
|
||||
|
||||
[SerializableField(1)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private Map _destMap;
|
||||
|
||||
[InvalidateProperties]
|
||||
[SerializableField(2)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private int _charges;
|
||||
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public HornOfRetreat() : base(0xFC4)
|
||||
{
|
||||
private int m_Charges;
|
||||
Hue = 0x482;
|
||||
Weight = 1.0;
|
||||
_charges = 10;
|
||||
}
|
||||
|
||||
private TimerExecutionToken _timerToken;
|
||||
public override int LabelNumber => 1049117; // Horn of Retreat
|
||||
|
||||
[Constructible]
|
||||
public HornOfRetreat() : base(0xFC4)
|
||||
public virtual bool ValidateUse(Mobile from) => true;
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060741, _charges); // charges: ~1_val~
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
Hue = 0x482;
|
||||
Weight = 1.0;
|
||||
Charges = 10;
|
||||
SendLocalizedMessageTo(from, 1042001); // That must be in your pack for you to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
public HornOfRetreat(Serial serial) : base(serial)
|
||||
if (!ValidateUse(from))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 500309); // Nothing Happens.
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D DestLoc { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map DestMap { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Charges
|
||||
else if (Core.ML && from.Map != Map.Trammel && from.Map != Map.Malas)
|
||||
{
|
||||
get => m_Charges;
|
||||
set
|
||||
{
|
||||
m_Charges = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
from.SendLocalizedMessage(1076154); // You can only use this in Trammel and Malas.
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1049117; // Horn of Retreat
|
||||
|
||||
public virtual bool ValidateUse(Mobile from) => true;
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
else if (_timerToken.Running)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060741, m_Charges); // charges: ~1_val~
|
||||
SendLocalizedMessageTo(from, 1042144); // This is currently in use.
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
else if (Charges > 0)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
if (!ValidateUse(from))
|
||||
{
|
||||
SendLocalizedMessageTo(from, 500309); // Nothing Happens.
|
||||
}
|
||||
else if (Core.ML && from.Map != Map.Trammel && from.Map != Map.Malas)
|
||||
{
|
||||
from.SendLocalizedMessage(1076154); // You can only use this in Trammel and Malas.
|
||||
}
|
||||
else if (_timerToken.Running)
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042144); // This is currently in use.
|
||||
}
|
||||
else if (Charges > 0)
|
||||
{
|
||||
from.Animate(34, 7, 1, true, false, 0);
|
||||
from.PlaySound(0xFF);
|
||||
from.SendLocalizedMessage(1049115); // You play the horn and a sense of peace overcomes you...
|
||||
from.Animate(34, 7, 1, true, false, 0);
|
||||
from.PlaySound(0xFF);
|
||||
from.SendLocalizedMessage(1049115); // You play the horn and a sense of peace overcomes you...
|
||||
|
||||
--Charges;
|
||||
--Charges;
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => PlayTimer_Callback(from), out _timerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042544); // This item is out of charges.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => PlayTimer_Callback(from), out _timerToken);
|
||||
}
|
||||
|
||||
public virtual void PlayTimer_Callback(Mobile from)
|
||||
else
|
||||
{
|
||||
_timerToken.Cancel();
|
||||
|
||||
var gate = new HornOfRetreatMoongate(DestLoc, DestMap, from, Hue);
|
||||
|
||||
gate.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
from.PlaySound(0x20E);
|
||||
|
||||
gate.SendLocalizedMessageTo(from, 1049102, from.Name); // Quickly ~1_NAME~! Onward through the gate!
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(DestLoc);
|
||||
writer.Write(DestMap);
|
||||
writer.Write(m_Charges);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
DestLoc = reader.ReadPoint3D();
|
||||
DestMap = reader.ReadMap();
|
||||
m_Charges = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
SendLocalizedMessageTo(from, 1042544); // This item is out of charges.
|
||||
}
|
||||
}
|
||||
|
||||
public class HornOfRetreatMoongate : Moongate
|
||||
public virtual void PlayTimer_Callback(Mobile from)
|
||||
{
|
||||
private readonly Mobile m_Caster;
|
||||
_timerToken.Cancel();
|
||||
|
||||
public HornOfRetreatMoongate(Point3D destLoc, Map destMap, Mobile caster, int hue)
|
||||
var gate = new HornOfRetreatMoongate(DestLoc, DestMap, from, Hue);
|
||||
|
||||
gate.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
from.PlaySound(0x20E);
|
||||
|
||||
gate.SendLocalizedMessageTo(from, 1049102, from.Name); // Quickly ~1_NAME~! Onward through the gate!
|
||||
}
|
||||
}
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HornOfRetreatMoongate : Moongate
|
||||
{
|
||||
private readonly Mobile _caster;
|
||||
|
||||
public HornOfRetreatMoongate(Point3D destLoc, Map destMap, Mobile caster, int hue)
|
||||
{
|
||||
_caster = caster;
|
||||
|
||||
Target = destLoc;
|
||||
TargetMap = destMap;
|
||||
|
||||
Hue = hue;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
Dispellable = false;
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Delete);
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1049114; // Sanctuary Gate
|
||||
|
||||
public override void BeginConfirmation(Mobile from)
|
||||
{
|
||||
EndConfirmation(from);
|
||||
}
|
||||
|
||||
public override void UseGate(Mobile m)
|
||||
{
|
||||
if (m.Region.IsPartOf<JailRegion>())
|
||||
{
|
||||
m_Caster = caster;
|
||||
|
||||
Target = destLoc;
|
||||
TargetMap = destMap;
|
||||
|
||||
Hue = hue;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
Dispellable = false;
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Delete);
|
||||
m.SendLocalizedMessage(1114345); // You'll need a better jailbreak plan than that!
|
||||
}
|
||||
|
||||
public HornOfRetreatMoongate(Serial serial) : base(serial)
|
||||
else if (m == _caster)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1049114; // Sanctuary Gate
|
||||
|
||||
public override void BeginConfirmation(Mobile from)
|
||||
{
|
||||
EndConfirmation(from);
|
||||
}
|
||||
|
||||
public override void UseGate(Mobile m)
|
||||
{
|
||||
if (m.Region.IsPartOf<JailRegion>())
|
||||
{
|
||||
m.SendLocalizedMessage(1114345); // You'll need a better jailbreak plan than that!
|
||||
}
|
||||
else if (m == m_Caster)
|
||||
{
|
||||
base.UseGate(m);
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
base.UseGate(m);
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
[AfterDeserialization(false)]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,118 +1,98 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests
|
||||
namespace Server.Engines.Quests;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public abstract partial class QuestItem : Item
|
||||
{
|
||||
public abstract class QuestItem : Item
|
||||
public QuestItem(int itemID) : base(itemID)
|
||||
{
|
||||
public QuestItem(int itemID) : base(itemID)
|
||||
}
|
||||
|
||||
public virtual bool Accepted => Deleted;
|
||||
|
||||
public abstract bool CanDrop(PlayerMobile pm);
|
||||
|
||||
public override bool DropToWorld(Mobile from, Point3D p)
|
||||
{
|
||||
var ret = base.DropToWorld(from, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
{
|
||||
}
|
||||
|
||||
public QuestItem(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool Accepted => Deleted;
|
||||
|
||||
public abstract bool CanDrop(PlayerMobile pm);
|
||||
|
||||
public override bool DropToWorld(Mobile from, Point3D p)
|
||||
{
|
||||
var ret = base.DropToWorld(from, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(
|
||||
1049343
|
||||
); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override bool DropToMobile(Mobile from, Mobile target, Point3D p)
|
||||
{
|
||||
var ret = base.DropToMobile(from, target, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
if (from is not PlayerMobile playerMobile || CanDrop(playerMobile))
|
||||
{
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(
|
||||
1049344
|
||||
); // You decide against trading the item. You still need it for your quest.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
// You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
|
||||
playerMobile.SendLocalizedMessage(1049343);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DropToItem(Mobile from, Item target, Point3D p)
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override bool DropToMobile(Mobile from, Mobile target, Point3D p)
|
||||
{
|
||||
var ret = base.DropToMobile(from, target, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
{
|
||||
var ret = base.DropToItem(from, target, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(
|
||||
1049343
|
||||
); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override DeathMoveResult OnParentDeath(Mobile parent)
|
||||
{
|
||||
if (parent is PlayerMobile mobile && !CanDrop(mobile))
|
||||
if (from is not PlayerMobile playerMobile || CanDrop(playerMobile))
|
||||
{
|
||||
return DeathMoveResult.MoveToBackpack;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnParentDeath(parent);
|
||||
// You decide against trading the item. You still need it for your quest.
|
||||
playerMobile.SendLocalizedMessage(1049344);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override bool DropToItem(Mobile from, Item target, Point3D p)
|
||||
{
|
||||
var ret = base.DropToItem(from, target, p);
|
||||
|
||||
if (ret && !Accepted && Parent != from.Backpack)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
writer.Write(0); // version
|
||||
if (from is not PlayerMobile playerMobile || CanDrop(playerMobile))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
|
||||
playerMobile.SendLocalizedMessage(1049343);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override DeathMoveResult OnParentDeath(Mobile parent)
|
||||
{
|
||||
if (parent is PlayerMobile mobile && !CanDrop(mobile))
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
return DeathMoveResult.MoveToBackpack;
|
||||
}
|
||||
|
||||
return base.OnParentDeath(parent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue