Adds BufferReader and BufferWriter. Updates UOP handling. (#101)

This commit is contained in:
Kamron Batman 2020-04-12 21:33:24 -07:00 committed by GitHub
parent 2c0d97cd36
commit 038c3be258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 2458 additions and 2185 deletions

View file

@ -215,61 +215,58 @@ namespace Server.Items
}
}
private static void EventSink_OpenDoorMacroUsed(OpenDoorMacroEventArgs args)
private static void EventSink_OpenDoorMacroUsed(Mobile m)
{
Mobile m = args.Mobile;
if (m.Map == null) return;
if (m.Map != null)
int x = m.X, y = m.Y;
switch (m.Direction & Direction.Mask)
{
int x = m.X, y = m.Y;
switch (m.Direction & Direction.Mask)
{
case Direction.North:
--y;
break;
case Direction.Right:
++x;
--y;
break;
case Direction.East:
++x;
break;
case Direction.Down:
++x;
++y;
break;
case Direction.South:
++y;
break;
case Direction.Left:
--x;
++y;
break;
case Direction.West:
--x;
break;
case Direction.Up:
--x;
--y;
break;
}
Sector sector = m.Map.GetSector(x, y);
foreach (Item item in sector.Items)
if (item.Location.X == x && item.Location.Y == y && item.Z + item.ItemData.Height > m.Z &&
m.Z + 16 > item.Z && item is BaseDoor && m.CanSee(item) && m.InLOS(item))
{
if (m.CheckAlive())
{
m.SendLocalizedMessage(500024); // Opening door...
item.OnDoubleClick(m);
}
break;
}
case Direction.North:
--y;
break;
case Direction.Right:
++x;
--y;
break;
case Direction.East:
++x;
break;
case Direction.Down:
++x;
++y;
break;
case Direction.South:
++y;
break;
case Direction.Left:
--x;
++y;
break;
case Direction.West:
--x;
break;
case Direction.Up:
--x;
--y;
break;
}
Sector sector = m.Map.GetSector(x, y);
foreach (Item item in sector.Items)
if (item.Location.X == x && item.Location.Y == y && item.Z + item.ItemData.Height > m.Z &&
m.Z + 16 > item.Z && item is BaseDoor && m.CanSee(item) && m.InLOS(item))
{
if (m.CheckAlive())
{
m.SendLocalizedMessage(500024); // Opening door...
item.OnDoubleClick(m);
}
break;
}
}
public static Point3D GetOffset(DoorFacing facing) => m_Offsets[(int)facing];

View file

@ -1048,9 +1048,9 @@ namespace Server.Items
EventSink.Login += EventSink_Login;
}
private static void EventSink_Login(LoginEventArgs e)
private static void EventSink_Login(Mobile m)
{
CheckHeaveTimer(e.Mobile);
CheckHeaveTimer(m);
}
public static void CheckHeaveTimer(Mobile from)

View file

@ -193,16 +193,7 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public virtual bool InstancedCorpse
{
get
{
if (!Core.SE)
return false;
return DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
}
}
public virtual bool InstancedCorpse => Core.SE && DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
public override bool IsDecoContainer => false;

View file

@ -630,10 +630,8 @@ namespace Server.Items
EventSink.Logout += EventSink_Logout;
}
public static void EventSink_Logout(LogoutEventArgs e)
public static void EventSink_Logout(Mobile from)
{
Mobile from = e.Mobile;
if (from == null || !m_Table.TryGetValue(from, out TeleportingInfo info))
return;

View file

@ -245,6 +245,7 @@ namespace Server.Items
{
EventSink.OpenSpellbookRequest += EventSink_OpenSpellbookRequest;
EventSink.CastSpellRequest += EventSink_CastSpellRequest;
EventSink.TargetedSpell += EventSink_TargetedSpell;
CommandSystem.Register("AllSpells", AccessLevel.GameMaster, AllSpells_OnCommand);
}
@ -278,14 +279,12 @@ namespace Server.Items
}
}
private static void EventSink_OpenSpellbookRequest(OpenSpellbookRequestEventArgs e)
private static void EventSink_OpenSpellbookRequest(Mobile from, int typeID)
{
Mobile from = e.Mobile;
if (!DesignContext.Check(from))
return; // They are customizing
var type = e.Type switch
var type = typeID switch
{
1 => SpellbookType.Regular,
2 => SpellbookType.Necromancer,
@ -302,15 +301,32 @@ namespace Server.Items
book?.DisplayTo(from);
}
private static void EventSink_CastSpellRequest(CastSpellRequestEventArgs e)
private static void EventSink_TargetedSpell(Mobile from, IEntity target, int spellId)
{
Mobile from = e.Mobile;
if (!DesignContext.Check(from)) return; // They are customizing
Spellbook book = Find(from, spellId);
if (book?.HasSpell(spellId) != true)
{
from.SendLocalizedMessage(500015); // You do not have that spell!
return;
}
SpecialMove move = SpellRegistry.GetSpecialMove(spellId);
if (move != null)
SpecialMove.SetCurrentMove(from, move);
else
SpellRegistry.NewSpell(spellId, @from, null)?.Cast();
}
private static void EventSink_CastSpellRequest(Mobile from, int spellID, Item item)
{
if (!DesignContext.Check(from))
return; // They are customizing
Spellbook book = e.Spellbook as Spellbook;
int spellID = e.SpellID;
Spellbook book = item as Spellbook;
if (book?.HasSpell(spellID) != true)
book = Find(from, spellID);
@ -688,7 +704,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
if ((prop = Attributes.NightSight) != 0)
if ((Attributes.NightSight) != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)
@ -700,7 +716,7 @@ namespace Server.Items
if ((prop = Attributes.RegenHits) != 0)
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~
if ((prop = Attributes.SpellChanneling) != 0)
if ((Attributes.SpellChanneling) != 0)
list.Add(1060482); // spell channeling
if ((prop = Attributes.SpellDamage) != 0)

View file

@ -70,30 +70,27 @@ namespace Server.Items
}
}
private static void EventSink_BandageTargetRequest(BandageTargetRequestEventArgs e)
private static void EventSink_BandageTargetRequest(Mobile from, Item item, Mobile target)
{
if (!(e.Bandage is Bandage b) || b.Deleted)
if (!(item is Bandage b) || b.Deleted)
return;
Mobile from = e.Mobile;
if (from.InRange(b.GetWorldLocation(), Range))
{
if (from.Target != null)
{
Target.Cancel(from);
from.Target = null;
}
from.RevealingAction();
from.SendLocalizedMessage(500948); // Who will you use the bandages on?
new InternalTarget(b).Invoke(from, e.Target);
}
else
if (!from.InRange(b.GetWorldLocation(), Range))
{
from.SendLocalizedMessage(500295); // You are too far away to do that.
return;
}
if (from.Target != null)
{
Target.Cancel(from);
from.Target = null;
}
from.RevealingAction();
from.SendLocalizedMessage(500948); // Who will you use the bandages on?
new InternalTarget(b).Invoke(from, target);
}
private class InternalTarget : Target
@ -203,7 +200,7 @@ namespace Server.Items
{
StopHeal();
int healerNumber = -1, patientNumber = -1;
int healerNumber, patientNumber;
bool playSound = true;
bool checkSkills = false;

View file

@ -389,14 +389,12 @@ namespace Server.Items
EventSink.SetAbility += EventSink_SetAbility;
}
private static void EventSink_SetAbility(SetAbilityEventArgs e)
private static void EventSink_SetAbility(Mobile m, int index)
{
int index = e.Index;
if (index == 0)
ClearCurrentAbility(e.Mobile);
ClearCurrentAbility(m);
else if (index >= 1 && index < Abilities.Length)
SetCurrentAbility(e.Mobile, Abilities[index]);
SetCurrentAbility(m, Abilities[index]);
}
private static void AddContext(Mobile m, WeaponAbilityContext context)

View file

@ -216,13 +216,11 @@ namespace Server.Items
return (item == null || item is Spellbook) && m.FindItemOnLayer(Layer.TwoHanded) == null;
}
private static void EventSink_DisarmRequest(DisarmRequestEventArgs e)
private static void EventSink_DisarmRequest(Mobile m)
{
if (Core.AOS)
return;
Mobile m = e.Mobile;
#region Dueling
if (!DuelContext.AllowSpecialAbility(m, "Disarm", true))
@ -251,13 +249,11 @@ namespace Server.Items
}
}
private static void EventSink_StunRequest(StunRequestEventArgs e)
private static void EventSink_StunRequest(Mobile m)
{
if (Core.AOS)
return;
Mobile m = e.Mobile;
#region Dueling
if (!DuelContext.AllowSpecialAbility(m, "Stun", true))