Adds assemblies config, fixes crash bugs. (#134)
This commit is contained in:
parent
0140eb73b4
commit
8ec166bcd0
3223 changed files with 191 additions and 191 deletions
78
Projects/UOContent/Items/Traps/BaseTrap.cs
Normal file
78
Projects/UOContent/Items/Traps/BaseTrap.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class BaseTrap : Item
|
||||
{
|
||||
private DateTime m_NextPassiveTrigger, m_NextActiveTrigger;
|
||||
|
||||
public BaseTrap(int itemID) : base(itemID) => Movable = false;
|
||||
|
||||
public BaseTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int GetEffectHue()
|
||||
{
|
||||
int hue = Hue & 0x3FFF;
|
||||
|
||||
if (hue < 2)
|
||||
return 0;
|
||||
|
||||
return hue - 1;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
base.OnMovement(m, oldLocation);
|
||||
|
||||
if (m.Location == oldLocation)
|
||||
return;
|
||||
|
||||
if (CheckRange(m.Location, oldLocation, 0) && DateTime.UtcNow >= m_NextActiveTrigger)
|
||||
{
|
||||
m_NextActiveTrigger = m_NextPassiveTrigger = DateTime.UtcNow + ResetDelay;
|
||||
|
||||
OnTrigger(m);
|
||||
}
|
||||
else if (PassivelyTriggered && CheckRange(m.Location, oldLocation, PassiveTriggerRange) &&
|
||||
DateTime.UtcNow >= m_NextPassiveTrigger)
|
||||
{
|
||||
m_NextPassiveTrigger = DateTime.UtcNow + 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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Projects/UOContent/Items/Traps/FireColumnTrap.cs
Normal file
114
Projects/UOContent/Items/Traps/FireColumnTrap.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class FireColumnTrap : BaseTrap
|
||||
{
|
||||
private int m_MaxDamage;
|
||||
|
||||
private int m_MinDamage;
|
||||
|
||||
private bool m_WarningFlame;
|
||||
|
||||
[Constructible]
|
||||
public FireColumnTrap() : base(0x1B71)
|
||||
{
|
||||
m_MinDamage = 10;
|
||||
m_MaxDamage = 40;
|
||||
|
||||
m_WarningFlame = true;
|
||||
}
|
||||
|
||||
public FireColumnTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
get => m_MinDamage;
|
||||
set => m_MinDamage = value;
|
||||
}
|
||||
|
||||
[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)
|
||||
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);
|
||||
|
||||
int 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
162
Projects/UOContent/Items/Traps/FlameSpurtTrap.cs
Normal file
162
Projects/UOContent/Items/Traps/FlameSpurtTrap.cs
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class FlameSpurtTrap : BaseTrap
|
||||
{
|
||||
private Item m_Spurt;
|
||||
private Timer m_Timer;
|
||||
|
||||
[Constructible]
|
||||
public FlameSpurtTrap() : base(0x1B71) => Visible = false;
|
||||
|
||||
public FlameSpurtTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StartTimer()
|
||||
{
|
||||
m_Timer ??= Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Refresh);
|
||||
}
|
||||
|
||||
public virtual void StopTimer()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
}
|
||||
|
||||
public virtual void CheckTimer()
|
||||
{
|
||||
Map 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()
|
||||
{
|
||||
base.OnSectorDeactivate();
|
||||
|
||||
StopTimer();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
base.OnDelete();
|
||||
|
||||
m_Spurt?.Delete();
|
||||
}
|
||||
|
||||
public virtual void Refresh()
|
||||
{
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
bool foundPlayer = GetMobilesInRange(3)
|
||||
.Where(mob => mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player)
|
||||
.Any(mob => Z + 8 >= mob.Z && mob.Z + 16 > Z);
|
||||
|
||||
if (!foundPlayer)
|
||||
{
|
||||
m_Spurt?.Delete();
|
||||
m_Spurt = null;
|
||||
}
|
||||
else if (m_Spurt?.Deleted != false)
|
||||
{
|
||||
m_Spurt = new Static(0x3709);
|
||||
m_Spurt.MoveToWorld(Location, Map);
|
||||
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x309);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
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 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))
|
||||
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);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_Spurt);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Item item = reader.ReadItem();
|
||||
|
||||
item?.Delete();
|
||||
|
||||
CheckTimer();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Projects/UOContent/Items/Traps/GasTrap.cs
Normal file
105
Projects/UOContent/Items/Traps/GasTrap.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum GasTrapType
|
||||
{
|
||||
NorthWall,
|
||||
WestWall,
|
||||
Floor
|
||||
}
|
||||
|
||||
public class GasTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public GasTrap() : this(Poison.Lesser)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GasTrap(Poison poison) : this(GasTrapType.Floor, poison)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GasTrap(GasTrapType type, Poison poison = null) : base(GetBaseID(type)) => Poison = 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(), 0);
|
||||
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
|
||||
|
||||
Poison.Serialize(Poison, writer);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Poison = Poison.Deserialize(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Projects/UOContent/Items/Traps/GiantSpikeTrap.cs
Normal file
47
Projects/UOContent/Items/Traps/GiantSpikeTrap.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GiantSpikeTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public GiantSpikeTrap() : base(1)
|
||||
{
|
||||
}
|
||||
|
||||
public GiantSpikeTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
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(), 0);
|
||||
|
||||
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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Projects/UOContent/Items/Traps/MushroomTrap.cs
Normal file
61
Projects/UOContent/Items/Traps/MushroomTrap.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using Server.Regions;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class MushroomTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public MushroomTrap() : base(0x1125)
|
||||
{
|
||||
}
|
||||
|
||||
public MushroomTrap(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 override void OnTrigger(Mobile from)
|
||||
{
|
||||
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.DelayCall(TimeSpan.FromSeconds(2.0), OnMushroomReset);
|
||||
}
|
||||
|
||||
public virtual void OnMushroomReset()
|
||||
{
|
||||
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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (ItemID == 0x1126)
|
||||
OnMushroomReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Projects/UOContent/Items/Traps/SawTrap.cs
Normal file
87
Projects/UOContent/Items/Traps/SawTrap.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum SawTrapType
|
||||
{
|
||||
WestWall,
|
||||
NorthWall,
|
||||
WestFloor,
|
||||
NorthFloor
|
||||
}
|
||||
|
||||
public class SawTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public SawTrap(SawTrapType type = SawTrapType.NorthFloor) : base(GetBaseID(type))
|
||||
{
|
||||
}
|
||||
|
||||
public SawTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SawTrapType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnTrigger(Mobile from)
|
||||
{
|
||||
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
|
||||
return;
|
||||
|
||||
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 6, 3, GetEffectHue(), 0);
|
||||
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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
144
Projects/UOContent/Items/Traps/SpikeTrap.cs
Normal file
144
Projects/UOContent/Items/Traps/SpikeTrap.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum SpikeTrapType
|
||||
{
|
||||
WestWall,
|
||||
NorthWall,
|
||||
WestFloor,
|
||||
NorthFloor
|
||||
}
|
||||
|
||||
public class SpikeTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public SpikeTrap(SpikeTrapType type = SpikeTrapType.WestFloor) : base(GetBaseID(type))
|
||||
{
|
||||
}
|
||||
|
||||
public SpikeTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SpikeTrapType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
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
|
||||
{
|
||||
bool 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
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 18, 3, GetEffectHue(), 0);
|
||||
Effects.PlaySound(Location, Map, 0x22C);
|
||||
|
||||
foreach (Mobile mob in GetMobilesInRange(0))
|
||||
if (mob.Alive && !mob.IsDeadBondedPet)
|
||||
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnSpikeExtended);
|
||||
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500852); // You stepped onto a spike trap!
|
||||
}
|
||||
|
||||
public virtual void OnSpikeExtended()
|
||||
{
|
||||
Extended = true;
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), OnSpikeRetracted);
|
||||
}
|
||||
|
||||
public virtual void OnSpikeRetracted()
|
||||
{
|
||||
Extended = false;
|
||||
Effects.SendLocationEffect(Location, Map, GetExtendedID(Type) - 1, 6, 3, GetEffectHue(), 0);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Extended = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
160
Projects/UOContent/Items/Traps/StoneFaceTrap.cs
Normal file
160
Projects/UOContent/Items/Traps/StoneFaceTrap.cs
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
using System;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum StoneFaceTrapType
|
||||
{
|
||||
NorthWestWall,
|
||||
NorthWall,
|
||||
WestWall
|
||||
}
|
||||
|
||||
public class StoneFaceTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public StoneFaceTrap() : base(0x10FC) => Light = LightType.Circle225;
|
||||
|
||||
public StoneFaceTrap(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public StoneFaceTrapType Type
|
||||
{
|
||||
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
|
||||
{
|
||||
bool 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.DelayCall(TimeSpan.FromSeconds(2.0), FinishBreath);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), TriggerDamage);
|
||||
}
|
||||
|
||||
public virtual void FinishBreath()
|
||||
{
|
||||
Breathing = false;
|
||||
}
|
||||
|
||||
public virtual void TriggerDamage()
|
||||
{
|
||||
foreach (Mobile 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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Breathing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class StoneFaceTrapNoDamage : StoneFaceTrap
|
||||
{
|
||||
[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);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue