fix: Codegens traps (#1472)

This commit is contained in:
Kamron Batman 2023-08-25 20:44:37 -07:00 committed by GitHub
parent c341d6ad3e
commit 06309d9d59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1082 additions and 1254 deletions

View file

@ -1,83 +1,66 @@
using System;
using ModernUO.Serialization;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public abstract partial class BaseTrap : Item
{
public abstract class BaseTrap : Item
private DateTime m_NextPassiveTrigger, m_NextActiveTrigger;
public BaseTrap(int itemID) : base(itemID) => Movable = false;
public virtual bool PassivelyTriggered => false;
public virtual TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public virtual int PassiveTriggerRange => -1;
public virtual TimeSpan ResetDelay => TimeSpan.Zero;
public override bool HandlesOnMovement => true; // Tell the core that we implement OnMovement
public virtual void OnTrigger(Mobile from)
{
private DateTime m_NextPassiveTrigger, m_NextActiveTrigger;
}
public BaseTrap(int itemID) : base(itemID) => Movable = false;
public virtual int GetEffectHue()
{
var hue = Hue & 0x3FFF;
public BaseTrap(Serial serial) : base(serial)
if (hue < 2)
{
return 0;
}
public virtual bool PassivelyTriggered => false;
public virtual TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public virtual int PassiveTriggerRange => -1;
public virtual TimeSpan ResetDelay => TimeSpan.Zero;
return hue - 1;
}
public override bool HandlesOnMovement => true; // Tell the core that we implement OnMovement
public bool CheckRange(Point3D loc, Point3D oldLoc, int range) =>
CheckRange(loc, range) && !CheckRange(oldLoc, range);
public virtual void OnTrigger(Mobile from)
public bool CheckRange(Point3D loc, int range) =>
Z + 8 >= loc.Z && loc.Z + 16 > Z
&& Utility.InRange(GetWorldLocation(), loc, range);
public override void OnMovement(Mobile m, Point3D oldLocation)
{
base.OnMovement(m, oldLocation);
if (m.Location == oldLocation)
{
return;
}
public virtual int GetEffectHue()
if (CheckRange(m.Location, oldLocation, 0) && Core.Now >= m_NextActiveTrigger)
{
var hue = Hue & 0x3FFF;
m_NextActiveTrigger = m_NextPassiveTrigger = Core.Now + ResetDelay;
if (hue < 2)
{
return 0;
}
return hue - 1;
OnTrigger(m);
}
public bool CheckRange(Point3D loc, Point3D oldLoc, int range) =>
CheckRange(loc, range) && !CheckRange(oldLoc, range);
public bool CheckRange(Point3D loc, int range) =>
Z + 8 >= loc.Z && loc.Z + 16 > Z
&& Utility.InRange(GetWorldLocation(), loc, range);
public override void OnMovement(Mobile m, Point3D oldLocation)
else if (PassivelyTriggered && CheckRange(m.Location, oldLocation, PassiveTriggerRange) &&
Core.Now >= m_NextPassiveTrigger)
{
base.OnMovement(m, oldLocation);
m_NextPassiveTrigger = Core.Now + PassiveTriggerDelay;
if (m.Location == oldLocation)
{
return;
}
if (CheckRange(m.Location, oldLocation, 0) && Core.Now >= m_NextActiveTrigger)
{
m_NextActiveTrigger = m_NextPassiveTrigger = Core.Now + ResetDelay;
OnTrigger(m);
}
else if (PassivelyTriggered && CheckRange(m.Location, oldLocation, PassiveTriggerRange) &&
Core.Now >= m_NextPassiveTrigger)
{
m_NextPassiveTrigger = Core.Now + PassiveTriggerDelay;
OnTrigger(m);
}
}
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();
OnTrigger(m);
}
}
}

View file

@ -1,134 +1,80 @@
using System;
using ModernUO.Serialization;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class FireColumnTrap : BaseTrap
{
public class FireColumnTrap : BaseTrap
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private bool _warningFlame;
[SerializableField(1)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private int _minDamage;
[SerializableField(2)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private int _maxDamage;
[Constructible]
public FireColumnTrap() : base(0x1B71)
{
private int m_MaxDamage;
_minDamage = 10;
_maxDamage = 40;
private int m_MinDamage;
_warningFlame = true;
}
private bool m_WarningFlame;
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.FromSeconds(2.0);
public override int PassiveTriggerRange => 3;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.5);
[Constructible]
public FireColumnTrap() : base(0x1B71)
public override void OnTrigger(Mobile from)
{
if (from.AccessLevel > AccessLevel.Player)
{
m_MinDamage = 10;
m_MaxDamage = 40;
m_WarningFlame = true;
return;
}
public FireColumnTrap(Serial serial) : base(serial)
if (WarningFlame)
{
DoEffect();
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.FromSeconds(2.0);
public override int PassiveTriggerRange => 3;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.5);
[CommandProperty(AccessLevel.GameMaster)]
public virtual int MinDamage
if (from.Alive && CheckRange(from.Location, 0))
{
get => m_MinDamage;
set => m_MinDamage = value;
}
SpellHelper.Damage(
TimeSpan.FromSeconds(0.5),
from,
from,
Utility.RandomMinMax(MinDamage, MaxDamage),
0,
100,
0,
0,
0
);
[CommandProperty(AccessLevel.GameMaster)]
public virtual int MaxDamage
{
get => m_MaxDamage;
set => m_MaxDamage = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public virtual bool WarningFlame
{
get => m_WarningFlame;
set => m_WarningFlame = value;
}
public override void OnTrigger(Mobile from)
{
if (from.AccessLevel > AccessLevel.Player)
{
return;
}
if (WarningFlame)
if (!WarningFlame)
{
DoEffect();
}
if (from.Alive && CheckRange(from.Location, 0))
{
SpellHelper.Damage(
TimeSpan.FromSeconds(0.5),
from,
from,
Utility.RandomMinMax(MinDamage, MaxDamage),
0,
100,
0,
0,
0
);
if (!WarningFlame)
{
DoEffect();
}
}
}
private void DoEffect()
{
Effects.SendLocationParticles(
EffectItem.Create(Location, Map, EffectItem.DefaultDuration),
0x3709,
10,
30,
5052
);
Effects.PlaySound(Location, Map, 0x225);
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write(m_WarningFlame);
writer.Write(m_MinDamage);
writer.Write(m_MaxDamage);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 1:
{
m_WarningFlame = reader.ReadBool();
m_MinDamage = reader.ReadInt();
m_MaxDamage = reader.ReadInt();
break;
}
}
if (version == 0)
{
m_WarningFlame = true;
m_MinDamage = 10;
m_MaxDamage = 40;
}
}
}
private void DoEffect()
{
Effects.SendLocationParticles(
EffectItem.Create(Location, Map, EffectItem.DefaultDuration),
0x3709,
10,
30,
5052
);
Effects.PlaySound(Location, Map, 0x225);
}
}

View file

@ -1,178 +1,152 @@
using System;
using ModernUO.Serialization;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class FlameSpurtTrap : BaseTrap
{
public class FlameSpurtTrap : BaseTrap
private Item _spurt;
private TimerExecutionToken _timerToken;
[Constructible]
public FlameSpurtTrap() : base(0x1B71) => Visible = false;
public virtual void StartTimer()
{
private Item m_Spurt;
private TimerExecutionToken _timerToken;
[Constructible]
public FlameSpurtTrap() : base(0x1B71) => Visible = false;
public FlameSpurtTrap(Serial serial) : base(serial)
if (!_timerToken.Running)
{
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Refresh, out _timerToken);
}
}
public virtual void StartTimer()
public virtual void StopTimer()
{
_timerToken.Cancel();
}
public virtual void CheckTimer()
{
var map = Map;
if (map?.GetSector(GetWorldLocation()).Active == true)
{
if (!_timerToken.Running)
{
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Refresh, out _timerToken);
}
}
public virtual void StopTimer()
{
_timerToken.Cancel();
}
public virtual void CheckTimer()
{
var map = Map;
if (map?.GetSector(GetWorldLocation()).Active == true)
{
StartTimer();
}
else
{
StopTimer();
}
}
public override void OnLocationChange(Point3D oldLocation)
{
base.OnLocationChange(oldLocation);
CheckTimer();
}
public override void OnMapChange()
{
base.OnMapChange();
CheckTimer();
}
public override void OnSectorActivate()
{
base.OnSectorActivate();
StartTimer();
}
public override void OnSectorDeactivate()
else
{
base.OnSectorDeactivate();
StopTimer();
}
}
public override void OnDelete()
public override void OnLocationChange(Point3D oldLocation)
{
base.OnLocationChange(oldLocation);
CheckTimer();
}
public override void OnMapChange()
{
base.OnMapChange();
CheckTimer();
}
public override void OnSectorActivate()
{
base.OnSectorActivate();
StartTimer();
}
public override void OnSectorDeactivate()
{
base.OnSectorDeactivate();
StopTimer();
}
public override void OnDelete()
{
base.OnDelete();
_spurt?.Delete();
}
public virtual void Refresh()
{
if (Deleted)
{
base.OnDelete();
m_Spurt?.Delete();
return;
}
public virtual void Refresh()
foreach (var mob in GetMobilesInRange(3))
{
if (Deleted)
if (mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player && Z + 8 >= mob.Z && mob.Z + 16 > Z)
{
if (_spurt?.Deleted != false)
{
_spurt = new Static(0x3709);
_spurt.MoveToWorld(Location, Map);
Effects.PlaySound(GetWorldLocation(), Map, 0x309);
}
return;
}
foreach (var mob in GetMobilesInRange(3))
{
if (mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player && Z + 8 >= mob.Z && mob.Z + 16 > Z)
{
if (m_Spurt?.Deleted != false)
{
m_Spurt = new Static(0x3709);
m_Spurt.MoveToWorld(Location, Map);
Effects.PlaySound(GetWorldLocation(), Map, 0x309);
}
return;
}
}
m_Spurt?.Delete();
m_Spurt = null;
}
public override bool OnMoveOver(Mobile m)
_spurt?.Delete();
_spurt = null;
}
public override bool OnMoveOver(Mobile m)
{
if (m.AccessLevel > AccessLevel.Player)
{
if (m.AccessLevel > AccessLevel.Player)
{
return true;
}
if (!(m.Player && m.Alive))
{
return false;
}
CheckTimer();
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30));
m.PlaySound(m.Female ? 0x327 : 0x437);
return true;
}
if (!(m.Player && m.Alive))
{
return false;
}
public override void OnMovement(Mobile m, Point3D oldLocation)
CheckTimer();
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30));
m.PlaySound(m.Female ? 0x327 : 0x437);
return false;
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
base.OnMovement(m, oldLocation);
if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player
|| !CheckRange(m.Location, oldLocation, 1))
{
base.OnMovement(m, oldLocation);
if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player
|| !CheckRange(m.Location, oldLocation, 1))
{
return;
}
CheckTimer();
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10));
m.PlaySound(m.Female ? 0x327 : 0x437);
if (m.Body.IsHuman)
{
m.Animate(20, 1, 1, true, false, 0);
}
return;
}
public override void Serialize(IGenericWriter writer)
CheckTimer();
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10));
m.PlaySound(m.Female ? 0x327 : 0x437);
if (m.Body.IsHuman)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(m_Spurt);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
var item = reader.ReadEntity<Item>();
item?.Delete();
CheckTimer();
break;
}
}
m.Animate(20, 1, 1, true, false, 0);
}
}
[AfterDeserialization(false)]
private void AfterDeserialization()
{
_spurt?.Delete();
CheckTimer();
}
}

View file

@ -1,106 +1,76 @@
using System;
using ModernUO.Serialization;
namespace Server.Items
namespace Server.Items;
public enum GasTrapType
{
public enum GasTrapType
NorthWall,
WestWall,
Floor
}
[SerializationGenerator(0, false)]
public partial class GasTrap : BaseTrap
{
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private Poison _poison;
[Constructible]
public GasTrap() : this(Poison.Lesser)
{
NorthWall,
WestWall,
Floor
}
public class GasTrap : BaseTrap
[Constructible]
public GasTrap(Poison poison) : this(GasTrapType.Floor, poison)
{
[Constructible]
public GasTrap() : this(Poison.Lesser)
}
[Constructible]
public GasTrap(GasTrapType type, Poison poison = null) : base(GetBaseID(type)) => Poison = poison;
[CommandProperty(AccessLevel.GameMaster)]
public GasTrapType Type
{
get => ItemID switch
{
0x113C => GasTrapType.NorthWall,
0x1147 => GasTrapType.WestWall,
0x11A8 => GasTrapType.Floor,
_ => GasTrapType.WestWall
};
set => ItemID = GetBaseID(value);
}
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public static int GetBaseID(GasTrapType type)
{
return type switch
{
GasTrapType.NorthWall => 0x113C,
GasTrapType.WestWall => 0x1147,
GasTrapType.Floor => 0x11A8,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (Poison == null || !from.Player || !from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
[Constructible]
public GasTrap(Poison poison) : this(GasTrapType.Floor, poison)
{
}
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) - 2, 16, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x231);
[Constructible]
public GasTrap(GasTrapType type, Poison poison = null) : base(GetBaseID(type)) => Poison = poison;
from.ApplyPoison(from, Poison);
public GasTrap(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Poison Poison { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public GasTrapType Type
{
get
{
return ItemID switch
{
0x113C => GasTrapType.NorthWall,
0x1147 => GasTrapType.WestWall,
0x11A8 => GasTrapType.Floor,
_ => GasTrapType.WestWall
};
}
set => ItemID = GetBaseID(value);
}
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public static int GetBaseID(GasTrapType type)
{
return type switch
{
GasTrapType.NorthWall => 0x113C,
GasTrapType.WestWall => 0x1147,
GasTrapType.Floor => 0x11A8,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (Poison == null || !from.Player || !from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) - 2, 16, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x231);
from.ApplyPoison(from, Poison);
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500855); // You are enveloped by a noxious gas cloud!
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Poison);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
Poison = reader.ReadPoison();
break;
}
}
}
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500855); // You are enveloped by a noxious gas cloud!
}
}

View file

@ -1,51 +1,34 @@
using System;
using ModernUO.Serialization;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class GiantSpikeTrap : BaseTrap
{
public class GiantSpikeTrap : BaseTrap
[Constructible]
public GiantSpikeTrap() : base(1)
{
[Constructible]
public GiantSpikeTrap() : base(1)
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 3;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public override void OnTrigger(Mobile from)
{
if (from.AccessLevel > AccessLevel.Player)
{
return;
}
public GiantSpikeTrap(Serial serial) : base(serial)
Effects.SendLocationEffect(Location, Map, 0x1D99, 48, 2, GetEffectHue());
if (from.Alive && CheckRange(from.Location, 0))
{
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 3;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public override void OnTrigger(Mobile from)
{
if (from.AccessLevel > AccessLevel.Player)
{
return;
}
Effects.SendLocationEffect(Location, Map, 0x1D99, 48, 2, GetEffectHue());
if (from.Alive && CheckRange(from.Location, 0))
{
SpellHelper.Damage(TimeSpan.FromTicks(1), from, from, Utility.Dice(10, 7, 0));
}
}
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();
SpellHelper.Damage(TimeSpan.FromTicks(1), from, from, Utility.Dice(10, 7, 0));
}
}
}

View file

@ -1,69 +1,56 @@
using System;
using ModernUO.Serialization;
using Server.Regions;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class MushroomTrap : BaseTrap
{
public class MushroomTrap : BaseTrap
[Constructible]
public MushroomTrap() : base(0x1125)
{
[Constructible]
public MushroomTrap() : base(0x1125)
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 2;
public override TimeSpan ResetDelay => TimeSpan.Zero;
public override void OnTrigger(Mobile from)
{
if (!from.Alive || ItemID != 0x1125 || from.AccessLevel > AccessLevel.Player)
{
return;
}
public MushroomTrap(Serial serial) : base(serial)
ItemID = 0x1126;
Effects.PlaySound(Location, Map, 0x306);
SpellHelper.Damage(TimeSpan.FromSeconds(0.5), from, from, Utility.Dice(2, 4, 0));
Timer.StartTimer(TimeSpan.FromSeconds(2.0), OnMushroomReset);
}
public virtual void OnMushroomReset()
{
if (Region.Find(Location, Map).IsPartOf<DungeonRegion>())
{
ItemID = 0x1125; // reset
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 2;
public override TimeSpan ResetDelay => TimeSpan.Zero;
public override void OnTrigger(Mobile from)
else
{
if (!from.Alive || ItemID != 0x1125 || from.AccessLevel > AccessLevel.Player)
{
return;
}
ItemID = 0x1126;
Effects.PlaySound(Location, Map, 0x306);
SpellHelper.Damage(TimeSpan.FromSeconds(0.5), from, from, Utility.Dice(2, 4, 0));
Timer.StartTimer(TimeSpan.FromSeconds(2.0), OnMushroomReset);
Delete();
}
}
public virtual void OnMushroomReset()
[AfterDeserialization(false)]
private void AfterDeserialization()
{
if (ItemID == 0x1126)
{
if (Region.Find(Location, Map).IsPartOf<DungeonRegion>())
{
ItemID = 0x1125; // reset
}
else
{
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();
if (ItemID == 0x1126)
{
OnMushroomReset();
}
OnMushroomReset();
}
}
}

View file

@ -1,88 +1,87 @@
using System;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
public enum SawTrapType
{
public enum SawTrapType
WestWall,
NorthWall,
WestFloor,
NorthFloor
}
public class SawTrap : BaseTrap
{
[Constructible]
public SawTrap(SawTrapType type = SawTrapType.NorthFloor) : base(GetBaseID(type))
{
WestWall,
NorthWall,
WestFloor,
NorthFloor
}
public class SawTrap : BaseTrap
public SawTrap(Serial serial) : base(serial)
{
[Constructible]
public SawTrap(SawTrapType type = SawTrapType.NorthFloor) : base(GetBaseID(type))
{
}
}
public SawTrap(Serial serial) : base(serial)
[CommandProperty(AccessLevel.GameMaster)]
public SawTrapType Type
{
get
{
}
[CommandProperty(AccessLevel.GameMaster)]
public SawTrapType Type
{
get
return ItemID switch
{
return ItemID switch
{
0x1103 => SawTrapType.NorthWall,
0x1116 => SawTrapType.WestWall,
0x11AC => SawTrapType.NorthFloor,
0x11B1 => SawTrapType.WestFloor,
_ => SawTrapType.NorthWall
};
}
set => ItemID = GetBaseID(value);
}
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public static int GetBaseID(SawTrapType type)
{
return type switch
{
SawTrapType.NorthWall => 0x1103,
SawTrapType.WestWall => 0x1116,
SawTrapType.NorthFloor => 0x11AC,
SawTrapType.WestFloor => 0x11B1,
_ => 0
0x1103 => SawTrapType.NorthWall,
0x1116 => SawTrapType.WestWall,
0x11AC => SawTrapType.NorthFloor,
0x11B1 => SawTrapType.WestFloor,
_ => SawTrapType.NorthWall
};
}
public override void OnTrigger(Mobile from)
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 6, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x21C);
SpellHelper.Damage(TimeSpan.FromTicks(1), from, from, Utility.RandomMinMax(5, 15));
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500853); // You stepped onto a blade trap!
}
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();
}
set => ItemID = GetBaseID(value);
}
}
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(0.0);
public static int GetBaseID(SawTrapType type)
{
return type switch
{
SawTrapType.NorthWall => 0x1103,
SawTrapType.WestWall => 0x1116,
SawTrapType.NorthFloor => 0x11AC,
SawTrapType.WestFloor => 0x11B1,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 6, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x21C);
SpellHelper.Damage(TimeSpan.FromTicks(1), from, from, Utility.RandomMinMax(5, 15));
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500853); // You stepped onto a blade trap!
}
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();
}
}

View file

@ -1,153 +1,125 @@
using System;
using ModernUO.Serialization;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
public enum SpikeTrapType
{
public enum SpikeTrapType
WestWall,
NorthWall,
WestFloor,
NorthFloor
}
[SerializationGenerator(0, false)]
public partial class SpikeTrap : BaseTrap
{
[Constructible]
public SpikeTrap(SpikeTrapType type = SpikeTrapType.WestFloor) : base(GetBaseID(type))
{
WestWall,
NorthWall,
WestFloor,
NorthFloor
}
public class SpikeTrap : BaseTrap
[CommandProperty(AccessLevel.GameMaster)]
public SpikeTrapType Type
{
[Constructible]
public SpikeTrap(SpikeTrapType type = SpikeTrapType.WestFloor) : base(GetBaseID(type))
get
{
}
public SpikeTrap(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public SpikeTrapType Type
{
get
return ItemID switch
{
return ItemID switch
{
4360 => SpikeTrapType.WestWall,
4361 => SpikeTrapType.WestWall,
4366 => SpikeTrapType.WestWall,
4379 => SpikeTrapType.NorthWall,
4380 => SpikeTrapType.NorthWall,
4385 => SpikeTrapType.NorthWall,
4506 => SpikeTrapType.WestFloor,
4507 => SpikeTrapType.WestFloor,
4511 => SpikeTrapType.WestFloor,
4512 => SpikeTrapType.NorthFloor,
4513 => SpikeTrapType.NorthFloor,
4517 => SpikeTrapType.NorthFloor,
_ => SpikeTrapType.WestWall
};
}
set
{
var extended = Extended;
ItemID = extended ? GetExtendedID(value) : GetBaseID(value);
}
}
public bool Extended
{
get => ItemID == GetExtendedID(Type);
set
{
if (value)
{
ItemID = GetExtendedID(Type);
}
else
{
ItemID = GetBaseID(Type);
}
}
}
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(6.0);
public static int GetBaseID(SpikeTrapType type)
{
return type switch
{
SpikeTrapType.WestWall => 4360,
SpikeTrapType.NorthWall => 4379,
SpikeTrapType.WestFloor => 4506,
SpikeTrapType.NorthFloor => 4512,
_ => 0
4360 => SpikeTrapType.WestWall,
4361 => SpikeTrapType.WestWall,
4366 => SpikeTrapType.WestWall,
4379 => SpikeTrapType.NorthWall,
4380 => SpikeTrapType.NorthWall,
4385 => SpikeTrapType.NorthWall,
4506 => SpikeTrapType.WestFloor,
4507 => SpikeTrapType.WestFloor,
4511 => SpikeTrapType.WestFloor,
4512 => SpikeTrapType.NorthFloor,
4513 => SpikeTrapType.NorthFloor,
4517 => SpikeTrapType.NorthFloor,
_ => SpikeTrapType.WestWall
};
}
set => ItemID = Extended ? GetExtendedID(value) : GetBaseID(value);
}
public static int GetExtendedID(SpikeTrapType type) => GetBaseID(type) + GetExtendedOffset(type);
public bool Extended
{
get => ItemID == GetExtendedID(Type);
set => ItemID = value ? GetExtendedID(Type) : GetBaseID(Type);
}
public static int GetExtendedOffset(SpikeTrapType type)
public override bool PassivelyTriggered => false;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 0;
public override TimeSpan ResetDelay => TimeSpan.FromSeconds(6.0);
public static int GetBaseID(SpikeTrapType type)
{
return type switch
{
return type switch
{
SpikeTrapType.WestWall => 6,
SpikeTrapType.NorthWall => 6,
SpikeTrapType.WestFloor => 5,
SpikeTrapType.NorthFloor => 5,
_ => 0
};
SpikeTrapType.WestWall => 4360,
SpikeTrapType.NorthWall => 4379,
SpikeTrapType.WestFloor => 4506,
SpikeTrapType.NorthFloor => 4512,
_ => 0
};
}
public static int GetExtendedID(SpikeTrapType type) => GetBaseID(type) + GetExtendedOffset(type);
public static int GetExtendedOffset(SpikeTrapType type)
{
return type switch
{
SpikeTrapType.WestWall => 6,
SpikeTrapType.NorthWall => 6,
SpikeTrapType.WestFloor => 5,
SpikeTrapType.NorthFloor => 5,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
public override void OnTrigger(Mobile from)
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 18, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x22C);
foreach (var mob in GetMobilesInRange(0))
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
if (mob.Alive && !mob.IsDeadBondedPet)
{
return;
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6);
}
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 18, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x22C);
foreach (var mob in GetMobilesInRange(0))
{
if (mob.Alive && !mob.IsDeadBondedPet)
{
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6);
}
}
Timer.StartTimer(TimeSpan.FromSeconds(1.0), OnSpikeExtended);
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500852); // You stepped onto a spike trap!
}
public virtual void OnSpikeExtended()
{
Extended = true;
Timer.StartTimer(TimeSpan.FromSeconds(5.0), OnSpikeRetracted);
}
Timer.StartTimer(TimeSpan.FromSeconds(1.0), OnSpikeExtended);
public virtual void OnSpikeRetracted()
{
Extended = false;
Effects.SendLocationEffect(Location, Map, GetExtendedID(Type) - 1, 6, 3, GetEffectHue());
}
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500852); // You stepped onto a spike trap!
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
public virtual void OnSpikeExtended()
{
Extended = true;
Timer.StartTimer(TimeSpan.FromSeconds(5.0), OnSpikeRetracted);
}
writer.Write(0); // version
}
public virtual void OnSpikeRetracted()
{
Extended = false;
Effects.SendLocationEffect(Location, Map, GetExtendedID(Type) - 1, 6, 3, GetEffectHue());
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
Extended = false;
}
[AfterDeserialization]
private void AfterDeserialization()
{
Extended = false;
}
}

View file

@ -1,170 +1,125 @@
using System;
using ModernUO.Serialization;
using Server.Spells;
namespace Server.Items
namespace Server.Items;
public enum StoneFaceTrapType
{
public enum StoneFaceTrapType
NorthWestWall,
NorthWall,
WestWall
}
[SerializationGenerator(0, false)]
public partial class StoneFaceTrap : BaseTrap
{
[Constructible]
public StoneFaceTrap() : base(0x10FC) => Light = LightType.Circle225;
[CommandProperty(AccessLevel.GameMaster)]
public StoneFaceTrapType Type
{
NorthWestWall,
NorthWall,
WestWall
get
{
return ItemID switch
{
0x10F5 => StoneFaceTrapType.NorthWestWall,
0x10F6 => StoneFaceTrapType.NorthWestWall,
0x10F7 => StoneFaceTrapType.NorthWestWall,
0x10FC => StoneFaceTrapType.NorthWall,
0x10FD => StoneFaceTrapType.NorthWall,
0x10FE => StoneFaceTrapType.NorthWall,
0x110F => StoneFaceTrapType.WestWall,
0x1110 => StoneFaceTrapType.WestWall,
0x1111 => StoneFaceTrapType.WestWall,
_ => StoneFaceTrapType.NorthWestWall
};
}
set => ItemID = Breathing ? GetFireID(value) : GetBaseID(value);
}
public class StoneFaceTrap : BaseTrap
public bool Breathing
{
[Constructible]
public StoneFaceTrap() : base(0x10FC) => Light = LightType.Circle225;
get => ItemID == GetFireID(Type);
set => ItemID = value ? GetFireID(Type) : GetBaseID(Type);
}
public StoneFaceTrap(Serial serial) : base(serial)
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 2;
public override TimeSpan ResetDelay => TimeSpan.Zero;
public static int GetBaseID(StoneFaceTrapType type)
{
return type switch
{
StoneFaceTrapType.NorthWestWall => 0x10F5,
StoneFaceTrapType.NorthWall => 0x10FC,
StoneFaceTrapType.WestWall => 0x110F,
_ => 0
};
}
public static int GetFireID(StoneFaceTrapType type)
{
return type switch
{
StoneFaceTrapType.NorthWestWall => 0x10F7,
StoneFaceTrapType.NorthWall => 0x10FE,
StoneFaceTrapType.WestWall => 0x1111,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
[CommandProperty(AccessLevel.GameMaster)]
public StoneFaceTrapType Type
Effects.PlaySound(Location, Map, 0x359);
Breathing = true;
Timer.StartTimer(TimeSpan.FromSeconds(2.0), FinishBreath);
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TriggerDamage);
}
public virtual void FinishBreath()
{
Breathing = false;
}
public virtual void TriggerDamage()
{
foreach (var mob in GetMobilesInRange(1))
{
get
if (mob.Alive && !mob.IsDeadBondedPet && mob.AccessLevel == AccessLevel.Player)
{
return ItemID switch
{
0x10F5 => StoneFaceTrapType.NorthWestWall,
0x10F6 => StoneFaceTrapType.NorthWestWall,
0x10F7 => StoneFaceTrapType.NorthWestWall,
0x10FC => StoneFaceTrapType.NorthWall,
0x10FD => StoneFaceTrapType.NorthWall,
0x10FE => StoneFaceTrapType.NorthWall,
0x110F => StoneFaceTrapType.WestWall,
0x1110 => StoneFaceTrapType.WestWall,
0x1111 => StoneFaceTrapType.WestWall,
_ => StoneFaceTrapType.NorthWestWall
};
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.Dice(3, 15, 0));
}
set
{
var breathing = Breathing;
ItemID = breathing ? GetFireID(value) : GetBaseID(value);
}
}
public bool Breathing
{
get => ItemID == GetFireID(Type);
set
{
if (value)
{
ItemID = GetFireID(Type);
}
else
{
ItemID = GetBaseID(Type);
}
}
}
public override bool PassivelyTriggered => true;
public override TimeSpan PassiveTriggerDelay => TimeSpan.Zero;
public override int PassiveTriggerRange => 2;
public override TimeSpan ResetDelay => TimeSpan.Zero;
public static int GetBaseID(StoneFaceTrapType type)
{
return type switch
{
StoneFaceTrapType.NorthWestWall => 0x10F5,
StoneFaceTrapType.NorthWall => 0x10FC,
StoneFaceTrapType.WestWall => 0x110F,
_ => 0
};
}
public static int GetFireID(StoneFaceTrapType type)
{
return type switch
{
StoneFaceTrapType.NorthWestWall => 0x10F7,
StoneFaceTrapType.NorthWall => 0x10FE,
StoneFaceTrapType.WestWall => 0x1111,
_ => 0
};
}
public override void OnTrigger(Mobile from)
{
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
Effects.PlaySound(Location, Map, 0x359);
Breathing = true;
Timer.StartTimer(TimeSpan.FromSeconds(2.0), FinishBreath);
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TriggerDamage);
}
public virtual void FinishBreath()
{
Breathing = false;
}
public virtual void TriggerDamage()
{
foreach (var mob in GetMobilesInRange(1))
{
if (mob.Alive && !mob.IsDeadBondedPet && mob.AccessLevel == AccessLevel.Player)
{
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.Dice(3, 15, 0));
}
}
}
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();
Breathing = false;
}
}
public class StoneFaceTrapNoDamage : StoneFaceTrap
[AfterDeserialization]
private void AfterDeserialization()
{
[Constructible]
public StoneFaceTrapNoDamage()
{
}
public StoneFaceTrapNoDamage(Serial serial) : base(serial)
{
}
public override void TriggerDamage()
{
// nothing..
}
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();
}
Breathing = false;
}
}
[SerializationGenerator(0, false)]
public partial class StoneFaceTrapNoDamage : StoneFaceTrap
{
[Constructible]
public StoneFaceTrapNoDamage()
{
}
public override void TriggerDamage()
{
// nothing..
}
}

View file

@ -5,257 +5,256 @@ using Server.Network;
using Server.Spells;
using Server.Targeting;
namespace Server.Items
namespace Server.Items;
public enum WandEffect
{
public enum WandEffect
Clumsiness,
Identification,
Healing,
Feeblemindedness,
Weakness,
MagicArrow,
Harming,
Fireball,
GreaterHealing,
Lightning,
ManaDraining
}
[SerializationGenerator(1, false)]
public abstract partial class BaseWand : BaseBashing
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private WandEffect _wandEffect;
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(1)]
private int _charges;
public BaseWand(WandEffect effect, int minCharges, int maxCharges) : base(0xDF2 + Utility.Random(4))
{
Clumsiness,
Identification,
Healing,
Feeblemindedness,
Weakness,
MagicArrow,
Harming,
Fireball,
GreaterHealing,
Lightning,
ManaDraining
Weight = 1.0;
_wandEffect = effect;
_charges = Utility.RandomMinMax(minCharges, maxCharges);
Attributes.SpellChanneling = 1;
Attributes.CastSpeed = -1;
WeaponAttributes.MageWeapon = Utility.RandomMinMax(1, 10);
}
[SerializationGenerator(1, false)]
public abstract partial class BaseWand : BaseBashing
public override WeaponAbility PrimaryAbility => WeaponAbility.Dismount;
public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm;
public override int AosStrengthReq => 5;
public override int AosMinDamage => 9;
public override int AosMaxDamage => 11;
public override int AosSpeed => 40;
public override float MlSpeed => 2.75f;
public override int OldStrengthReq => 0;
public override int OldMinDamage => 2;
public override int OldMaxDamage => 6;
public override int OldSpeed => 35;
public override int InitMinHits => 31;
public override int InitMaxHits => 110;
public virtual TimeSpan GetUseDelay => TimeSpan.FromSeconds(4.0);
public void ConsumeCharge(Mobile from)
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private WandEffect _wandEffect;
--Charges;
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(1)]
private int _charges;
public BaseWand(WandEffect effect, int minCharges, int maxCharges) : base(0xDF2 + Utility.Random(4))
if (_charges == 0)
{
Weight = 1.0;
_wandEffect = effect;
_charges = Utility.RandomMinMax(minCharges, maxCharges);
Attributes.SpellChanneling = 1;
Attributes.CastSpeed = -1;
WeaponAttributes.MageWeapon = Utility.RandomMinMax(1, 10);
from.SendLocalizedMessage(1019073); // This item is out of charges.
}
public override WeaponAbility PrimaryAbility => WeaponAbility.Dismount;
public override WeaponAbility SecondaryAbility => WeaponAbility.Disarm;
ApplyDelayTo(from);
}
public override int AosStrengthReq => 5;
public override int AosMinDamage => 9;
public override int AosMaxDamage => 11;
public override int AosSpeed => 40;
public override float MlSpeed => 2.75f;
public virtual void ApplyDelayTo(Mobile from)
{
from.BeginAction<BaseWand>();
Timer.StartTimer(GetUseDelay,
() =>
{
from.EndAction<BaseWand>();
ReleaseWandLock_Callback(from);
}
);
}
public override int OldStrengthReq => 0;
public override int OldMinDamage => 2;
public override int OldMaxDamage => 6;
public override int OldSpeed => 35;
public virtual void ReleaseWandLock_Callback(Mobile state)
{
}
public override int InitMinHits => 31;
public override int InitMaxHits => 110;
public virtual TimeSpan GetUseDelay => TimeSpan.FromSeconds(4.0);
public void ConsumeCharge(Mobile from)
public override void OnDoubleClick(Mobile from)
{
if (!from.CanBeginAction<BaseWand>())
{
--Charges;
from.SendLocalizedMessage(1070860); // You must wait a moment for the wand to recharge.
return;
}
if (_charges == 0)
if (Parent == from)
{
if (_charges > 0)
{
OnWandUse(from);
}
else
{
from.SendLocalizedMessage(1019073); // This item is out of charges.
}
ApplyDelayTo(from);
}
public virtual void ApplyDelayTo(Mobile from)
else
{
from.BeginAction<BaseWand>();
Timer.StartTimer(GetUseDelay,
() =>
{
from.EndAction<BaseWand>();
ReleaseWandLock_Callback(from);
}
);
from.SendLocalizedMessage(502641); // You must equip this item to use it.
}
public virtual void ReleaseWandLock_Callback(Mobile state)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!from.CanBeginAction<BaseWand>())
{
from.SendLocalizedMessage(1070860); // You must wait a moment for the wand to recharge.
return;
}
if (Parent == from)
{
if (_charges > 0)
{
OnWandUse(from);
}
else
{
from.SendLocalizedMessage(1019073); // This item is out of charges.
}
}
else
{
from.SendLocalizedMessage(502641); // You must equip this item to use it.
}
}
private void Deserialize(IGenericReader reader, int version)
{
_wandEffect = (WandEffect)reader.ReadInt();
_charges = reader.ReadInt();
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
switch (_wandEffect)
{
case WandEffect.Clumsiness:
list.Add(1017326, $"{_charges}");
break; // clumsiness charges: ~1_val~
case WandEffect.Identification:
list.Add(1017350, $"{_charges}");
break; // identification charges: ~1_val~
case WandEffect.Healing:
list.Add(1017329, $"{_charges}");
break; // healing charges: ~1_val~
case WandEffect.Feeblemindedness:
list.Add(1017327, $"{_charges}");
break; // feeblemind charges: ~1_val~
case WandEffect.Weakness:
list.Add(1017328, $"{_charges}");
break; // weakness charges: ~1_val~
case WandEffect.MagicArrow:
list.Add(1060492, $"{_charges}");
break; // magic arrow charges: ~1_val~
case WandEffect.Harming:
list.Add(1017334, $"{_charges}");
break; // harm charges: ~1_val~
case WandEffect.Fireball:
list.Add(1060487, $"{_charges}");
break; // fireball charges: ~1_val~
case WandEffect.GreaterHealing:
list.Add(1017330, $"{_charges}");
break; // greater healing charges: ~1_val~
case WandEffect.Lightning:
list.Add(1060491, $"{_charges}");
break; // lightning charges: ~1_val~
case WandEffect.ManaDraining:
list.Add(1017339, $"{_charges}");
break; // mana drain charges: ~1_val~
}
}
public override void OnSingleClick(Mobile from)
{
var attrs = new List<EquipInfoAttribute>();
if (DisplayLootType)
{
if (LootType == LootType.Blessed)
{
attrs.Add(new EquipInfoAttribute(1038021)); // blessed
}
else if (LootType == LootType.Cursed)
{
attrs.Add(new EquipInfoAttribute(1049643)); // cursed
}
}
if (!Identified)
{
attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified
}
else
{
var num = _wandEffect switch
{
WandEffect.Clumsiness => 3002011,
WandEffect.Identification => 1044063,
WandEffect.Healing => 3002014,
WandEffect.Feeblemindedness => 3002013,
WandEffect.Weakness => 3002018,
WandEffect.MagicArrow => 3002015,
WandEffect.Harming => 3002022,
WandEffect.Fireball => 3002028,
WandEffect.GreaterHealing => 3002039,
WandEffect.Lightning => 3002040,
WandEffect.ManaDraining => 3002041,
_ => 0
};
if (num > 0)
{
attrs.Add(new EquipInfoAttribute(num, _charges));
}
}
int number;
if (Name == null)
{
number = 1017085;
}
else
{
LabelTo(from, Name);
number = 1041000;
}
if (attrs.Count == 0 && Crafter == null && Name != null)
{
return;
}
from.NetState.SendDisplayEquipmentInfo(Serial, number, Crafter?.RawName, false, attrs);
}
public void Cast(Spell spell)
{
var m = Movable;
Movable = false;
spell.Cast();
Movable = m;
}
public virtual void OnWandUse(Mobile from)
{
from.Target = new WandTarget(this);
}
public virtual void DoWandTarget(Mobile from, object o)
{
if (Deleted || _charges <= 0 || Parent != from || o is StaticTarget or LandTarget)
{
return;
}
if (OnWandTarget(from, o))
{
ConsumeCharge(from);
}
}
public virtual bool OnWandTarget(Mobile from, object o) => true;
}
private void Deserialize(IGenericReader reader, int version)
{
_wandEffect = (WandEffect)reader.ReadInt();
_charges = reader.ReadInt();
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
switch (_wandEffect)
{
case WandEffect.Clumsiness:
list.Add(1017326, $"{_charges}");
break; // clumsiness charges: ~1_val~
case WandEffect.Identification:
list.Add(1017350, $"{_charges}");
break; // identification charges: ~1_val~
case WandEffect.Healing:
list.Add(1017329, $"{_charges}");
break; // healing charges: ~1_val~
case WandEffect.Feeblemindedness:
list.Add(1017327, $"{_charges}");
break; // feeblemind charges: ~1_val~
case WandEffect.Weakness:
list.Add(1017328, $"{_charges}");
break; // weakness charges: ~1_val~
case WandEffect.MagicArrow:
list.Add(1060492, $"{_charges}");
break; // magic arrow charges: ~1_val~
case WandEffect.Harming:
list.Add(1017334, $"{_charges}");
break; // harm charges: ~1_val~
case WandEffect.Fireball:
list.Add(1060487, $"{_charges}");
break; // fireball charges: ~1_val~
case WandEffect.GreaterHealing:
list.Add(1017330, $"{_charges}");
break; // greater healing charges: ~1_val~
case WandEffect.Lightning:
list.Add(1060491, $"{_charges}");
break; // lightning charges: ~1_val~
case WandEffect.ManaDraining:
list.Add(1017339, $"{_charges}");
break; // mana drain charges: ~1_val~
}
}
public override void OnSingleClick(Mobile from)
{
var attrs = new List<EquipInfoAttribute>();
if (DisplayLootType)
{
if (LootType == LootType.Blessed)
{
attrs.Add(new EquipInfoAttribute(1038021)); // blessed
}
else if (LootType == LootType.Cursed)
{
attrs.Add(new EquipInfoAttribute(1049643)); // cursed
}
}
if (!Identified)
{
attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified
}
else
{
var num = _wandEffect switch
{
WandEffect.Clumsiness => 3002011,
WandEffect.Identification => 1044063,
WandEffect.Healing => 3002014,
WandEffect.Feeblemindedness => 3002013,
WandEffect.Weakness => 3002018,
WandEffect.MagicArrow => 3002015,
WandEffect.Harming => 3002022,
WandEffect.Fireball => 3002028,
WandEffect.GreaterHealing => 3002039,
WandEffect.Lightning => 3002040,
WandEffect.ManaDraining => 3002041,
_ => 0
};
if (num > 0)
{
attrs.Add(new EquipInfoAttribute(num, _charges));
}
}
int number;
if (Name == null)
{
number = 1017085;
}
else
{
LabelTo(from, Name);
number = 1041000;
}
if (attrs.Count == 0 && Crafter == null && Name != null)
{
return;
}
from.NetState.SendDisplayEquipmentInfo(Serial, number, Crafter?.RawName, false, attrs);
}
public void Cast(Spell spell)
{
var m = Movable;
Movable = false;
spell.Cast();
Movable = m;
}
public virtual void OnWandUse(Mobile from)
{
from.Target = new WandTarget(this);
}
public virtual void DoWandTarget(Mobile from, object o)
{
if (Deleted || _charges <= 0 || Parent != from || o is StaticTarget or LandTarget)
{
return;
}
if (OnWandTarget(from, o))
{
ConsumeCharge(from);
}
}
public virtual bool OnWandTarget(Mobile from, object o) => true;
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.First;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class ClumsyWand : BaseWand
{
[Constructible]
public ClumsyWand() : base(WandEffect.Clumsiness, 5, 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new ClumsySpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class ClumsyWand : BaseWand
{
[Constructible]
public ClumsyWand() : base(WandEffect.Clumsiness, 5, 30)
{
}
public override void OnWandUse(Mobile from)
{
Cast(new ClumsySpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.First;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class FeebleWand : BaseWand
{
[Constructible]
public FeebleWand() : base(WandEffect.Feeblemindedness, 5, 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new FeeblemindSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class FeebleWand : BaseWand
{
[Constructible]
public FeebleWand() : base(WandEffect.Feeblemindedness, 5, 30)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new FeeblemindSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.Third;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class FireballWand : BaseWand
{
[Constructible]
public FireballWand() : base(WandEffect.Fireball, 5, Core.ML ? 109 : 15)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new FireballSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class FireballWand : BaseWand
{
[Constructible]
public FireballWand() : base(WandEffect.Fireball, 5, Core.ML ? 109 : 15)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new FireballSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.Fourth;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class GreaterHealWand : BaseWand
{
[Constructible]
public GreaterHealWand() : base(WandEffect.GreaterHealing, 1, Core.ML ? 109 : 5)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new GreaterHealSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class GreaterHealWand : BaseWand
{
[Constructible]
public GreaterHealWand() : base(WandEffect.GreaterHealing, 1, Core.ML ? 109 : 5)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new GreaterHealSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.Second;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class HarmWand : BaseWand
{
[Constructible]
public HarmWand() : base(WandEffect.Harming, 5, Core.ML ? 109 : 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new HarmSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class HarmWand : BaseWand
{
[Constructible]
public HarmWand() : base(WandEffect.Harming, 5, Core.ML ? 109 : 30)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new HarmSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.First;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class HealWand : BaseWand
{
[Constructible]
public HealWand() : base(WandEffect.Healing, 10, Core.ML ? 109 : 25)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new HealSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class HealWand : BaseWand
{
[Constructible]
public HealWand() : base(WandEffect.Healing, 10, Core.ML ? 109 : 25)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new HealSpell(from, this));
}
}

View file

@ -1,40 +1,39 @@
using System;
using ModernUO.Serialization;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class IDWand : BaseWand
{
[SerializationGenerator(0, false)]
public partial class IDWand : BaseWand
[Constructible]
public IDWand() : base(WandEffect.Identification, 25, 175)
{
[Constructible]
public IDWand() : base(WandEffect.Identification, 25, 175)
{
}
}
public override TimeSpan GetUseDelay => TimeSpan.Zero;
public override TimeSpan GetUseDelay => TimeSpan.Zero;
public override bool OnWandTarget(Mobile from, object o)
public override bool OnWandTarget(Mobile from, object o)
{
if (o is Item item)
{
if (o is Item item)
if (item is BaseWeapon weapon)
{
if (item is BaseWeapon weapon)
{
weapon.Identified = true;
}
else if (item is BaseArmor armor)
{
armor.Identified = true;
}
if (!Core.AOS)
{
item.OnSingleClick(from);
}
return true;
weapon.Identified = true;
}
else if (item is BaseArmor armor)
{
armor.Identified = true;
}
return false;
if (!Core.AOS)
{
item.OnSingleClick(from);
}
return true;
}
return false;
}
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.Fourth;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class LightningWand : BaseWand
{
[Constructible]
public LightningWand() : base(WandEffect.Lightning, 5, Core.ML ? 109 : 20)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new LightningSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class LightningWand : BaseWand
{
[Constructible]
public LightningWand() : base(WandEffect.Lightning, 5, Core.ML ? 109 : 20)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new LightningSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.First;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class MagicArrowWand : BaseWand
{
[Constructible]
public MagicArrowWand() : base(WandEffect.MagicArrow, 5, Core.ML ? 109 : 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new MagicArrowSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class MagicArrowWand : BaseWand
{
[Constructible]
public MagicArrowWand() : base(WandEffect.MagicArrow, 5, Core.ML ? 109 : 30)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new MagicArrowSpell(from, this));
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.Fourth;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class ManaDrainWand : BaseWand
{
[Constructible]
public ManaDrainWand() : base(WandEffect.ManaDraining, 5, 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new ManaDrainSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class ManaDrainWand : BaseWand
{
[Constructible]
public ManaDrainWand() : base(WandEffect.ManaDraining, 5, 30)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new ManaDrainSpell(from, this));
}
}

View file

@ -1,16 +1,15 @@
using Server.Items;
namespace Server.Targeting
namespace Server.Targeting;
public class WandTarget : Target
{
public class WandTarget : Target
private readonly BaseWand m_Item;
public WandTarget(BaseWand item) : base(6, false, TargetFlags.None) => m_Item = item;
protected override void OnTarget(Mobile from, object targeted)
{
private readonly BaseWand m_Item;
public WandTarget(BaseWand item) : base(6, false, TargetFlags.None) => m_Item = item;
protected override void OnTarget(Mobile from, object targeted)
{
m_Item.DoWandTarget(from, targeted);
}
m_Item.DoWandTarget(from, targeted);
}
}
}

View file

@ -1,19 +1,18 @@
using ModernUO.Serialization;
using Server.Spells.First;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class WeaknessWand : BaseWand
{
[Constructible]
public WeaknessWand() : base(WandEffect.Weakness, 5, 30)
{
}
namespace Server.Items;
public override void OnWandUse(Mobile from)
{
Cast(new WeakenSpell(from, this));
}
[SerializationGenerator(0, false)]
public partial class WeaknessWand : BaseWand
{
[Constructible]
public WeaknessWand() : base(WandEffect.Weakness, 5, 30)
{
}
}
public override void OnWandUse(Mobile from)
{
Cast(new WeakenSpell(from, this));
}
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.BaseTrap"
}

View file

@ -0,0 +1,30 @@
{
"version": 0,
"type": "Server.Items.FireColumnTrap",
"properties": [
{
"name": "WarningFlame",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "MinDamage",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "MaxDamage",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.FlameSpurtTrap"
}

View file

@ -0,0 +1,14 @@
{
"version": 0,
"type": "Server.Items.GasTrap",
"properties": [
{
"name": "Poison",
"type": "Server.Poison",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Poison"
]
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.GiantSpikeTrap"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.MushroomTrap"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SpikeTrap"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.StoneFaceTrap"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.StoneFaceTrapNoDamage"
}