fix: Fixes travel restriction messages (#1263)
- [X] `BaseRegion.CheckTravel` now properly cascades through parent regions - [X] `SpellHelper.CheckTravel` now returns a failure message instead of sending one internally. - [X] Consolidates travel restriction messages so they aren't duplicated.
This commit is contained in:
parent
2057fe74a2
commit
1d8e8ec0a8
13 changed files with 121 additions and 69 deletions
|
|
@ -166,5 +166,14 @@ public class BaseRegion : Region
|
|||
|
||||
public override string ToString() => Name ?? RuneName ?? GetType().Name;
|
||||
|
||||
public virtual bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType) => true;
|
||||
public virtual bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType, out TextDefinition message)
|
||||
{
|
||||
if (Parent is BaseRegion parent)
|
||||
{
|
||||
return parent.CheckTravel(m, newLocation, travelType, out message);
|
||||
}
|
||||
|
||||
message = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,11 @@ public class GreenAcresRegion : BaseRegion
|
|||
public override bool AllowHousing(Mobile from, Point3D p) =>
|
||||
from.AccessLevel != AccessLevel.Player && base.AllowHousing(from, p);
|
||||
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType) =>
|
||||
m.AccessLevel != AccessLevel.Player;
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType, out TextDefinition message)
|
||||
{
|
||||
message = null; // Use default message
|
||||
return m.AccessLevel != AccessLevel.Player;
|
||||
}
|
||||
|
||||
public override bool OnBeginSpellCast(Mobile m, ISpell s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,15 +43,17 @@ public class JailRegion : BaseRegion
|
|||
global = LightCycle.JailLevel;
|
||||
}
|
||||
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType)
|
||||
private static TextDefinition _jailBreakPlan = 1114345; // You'll need a better jailbreak plan than that!
|
||||
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType, out TextDefinition message)
|
||||
{
|
||||
if (m?.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
m.SendLocalizedMessage(1114345); // You'll need a better jailbreak plan than that!
|
||||
message = _jailBreakPlan;
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckTravel(m, newLocation, travelType);
|
||||
return base.CheckTravel(m, newLocation, travelType, out message);
|
||||
}
|
||||
|
||||
public override bool OnBeginSpellCast(Mobile from, ISpell s)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using Server.Spells.Sixth;
|
||||
|
||||
namespace Server.Regions;
|
||||
|
||||
public class MondainRegion : NoTravelSpellsAllowedRegion
|
||||
|
|
@ -13,15 +11,4 @@ public class MondainRegion : NoTravelSpellsAllowedRegion
|
|||
: base(name, map, parent, priority, area)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnBeginSpellCast(Mobile m, ISpell s)
|
||||
{
|
||||
if (m.Player && s is MarkSpell)
|
||||
{
|
||||
m.SendLocalizedMessage(501802); // Thy spell doth not appear to work...
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnBeginSpellCast(m, s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ public class NoTravelSpellsAllowedRegion : DungeonRegion
|
|||
{
|
||||
}
|
||||
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType) =>
|
||||
m.AccessLevel == AccessLevel.Player;
|
||||
public override bool CheckTravel(Mobile m, Point3D newLocation, TravelCheckType travelType, out TextDefinition message)
|
||||
{
|
||||
message = null; // Use default message
|
||||
return m.AccessLevel > AccessLevel.Player ||
|
||||
travelType is not TravelCheckType.TeleportFrom or TravelCheckType.TeleportTo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue