Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
86
Projects/Scripts/Items/Traps/BaseTrap.cs
Normal file
86
Projects/Scripts/Items/Traps/BaseTrap.cs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
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)
|
||||
{
|
||||
return CheckRange(loc, range) && !CheckRange(oldLoc, range);
|
||||
}
|
||||
|
||||
public bool CheckRange(Point3D loc, int range)
|
||||
{
|
||||
return 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Projects/Scripts/Items/Traps/FireColumnTrap.cs
Normal file
114
Projects/Scripts/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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(m_WarningFlame);
|
||||
writer.Write(m_MinDamage);
|
||||
writer.Write(m_MaxDamage);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
166
Projects/Scripts/Items/Traps/FlameSpurtTrap.cs
Normal file
166
Projects/Scripts/Items/Traps/FlameSpurtTrap.cs
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
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()
|
||||
{
|
||||
if (m_Timer == null)
|
||||
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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_Spurt);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Item item = reader.ReadItem();
|
||||
|
||||
item?.Delete();
|
||||
|
||||
CheckTimer();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
Projects/Scripts/Items/Traps/GasTrap.cs
Normal file
110
Projects/Scripts/Items/Traps/GasTrap.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
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
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 0x113C: return GasTrapType.NorthWall;
|
||||
case 0x1147: return GasTrapType.WestWall;
|
||||
case 0x11A8: return GasTrapType.Floor;
|
||||
}
|
||||
|
||||
return 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)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GasTrapType.NorthWall: return 0x113C;
|
||||
case GasTrapType.WestWall: return 0x1147;
|
||||
case GasTrapType.Floor: return 0x11A8;
|
||||
}
|
||||
|
||||
return 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Poison.Serialize(Poison, writer);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Poison = Poison.Deserialize(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Projects/Scripts/Items/Traps/GiantSpikeTrap.cs
Normal file
47
Projects/Scripts/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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Projects/Scripts/Items/Traps/MushroomTrap.cs
Normal file
61
Projects/Scripts/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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (ItemID == 0x1126)
|
||||
OnMushroomReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
89
Projects/Scripts/Items/Traps/SawTrap.cs
Normal file
89
Projects/Scripts/Items/Traps/SawTrap.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
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
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 0x1103: return SawTrapType.NorthWall;
|
||||
case 0x1116: return SawTrapType.WestWall;
|
||||
case 0x11AC: return SawTrapType.NorthFloor;
|
||||
case 0x11B1: return SawTrapType.WestFloor;
|
||||
}
|
||||
|
||||
return 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)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SawTrapType.NorthWall: return 0x1103;
|
||||
case SawTrapType.WestWall: return 0x1116;
|
||||
case SawTrapType.NorthFloor: return 0x11AC;
|
||||
case SawTrapType.WestFloor: return 0x11B1;
|
||||
}
|
||||
|
||||
return 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
151
Projects/Scripts/Items/Traps/SpikeTrap.cs
Normal file
151
Projects/Scripts/Items/Traps/SpikeTrap.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
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
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 4360:
|
||||
case 4361:
|
||||
case 4366: return SpikeTrapType.WestWall;
|
||||
case 4379:
|
||||
case 4380:
|
||||
case 4385: return SpikeTrapType.NorthWall;
|
||||
case 4506:
|
||||
case 4507:
|
||||
case 4511: return SpikeTrapType.WestFloor;
|
||||
case 4512:
|
||||
case 4513:
|
||||
case 4517: return SpikeTrapType.NorthFloor;
|
||||
}
|
||||
|
||||
return 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)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SpikeTrapType.WestWall: return 4360;
|
||||
case SpikeTrapType.NorthWall: return 4379;
|
||||
case SpikeTrapType.WestFloor: return 4506;
|
||||
case SpikeTrapType.NorthFloor: return 4512;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int GetExtendedID(SpikeTrapType type)
|
||||
{
|
||||
return GetBaseID(type) + GetExtendedOffset(type);
|
||||
}
|
||||
|
||||
public static int GetExtendedOffset(SpikeTrapType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SpikeTrapType.WestWall: return 6;
|
||||
case SpikeTrapType.NorthWall: return 6;
|
||||
|
||||
case SpikeTrapType.WestFloor: return 5;
|
||||
case SpikeTrapType.NorthFloor: return 5;
|
||||
}
|
||||
|
||||
return 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Extended = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
166
Projects/Scripts/Items/Traps/StoneFaceTrap.cs
Normal file
166
Projects/Scripts/Items/Traps/StoneFaceTrap.cs
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
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
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 0x10F5:
|
||||
case 0x10F6:
|
||||
case 0x10F7: return StoneFaceTrapType.NorthWestWall;
|
||||
case 0x10FC:
|
||||
case 0x10FD:
|
||||
case 0x10FE: return StoneFaceTrapType.NorthWall;
|
||||
case 0x110F:
|
||||
case 0x1110:
|
||||
case 0x1111: return StoneFaceTrapType.WestWall;
|
||||
}
|
||||
|
||||
return 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)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case StoneFaceTrapType.NorthWestWall: return 0x10F5;
|
||||
case StoneFaceTrapType.NorthWall: return 0x10FC;
|
||||
case StoneFaceTrapType.WestWall: return 0x110F;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int GetFireID(StoneFaceTrapType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case StoneFaceTrapType.NorthWestWall: return 0x10F7;
|
||||
case StoneFaceTrapType.NorthWall: return 0x10FE;
|
||||
case StoneFaceTrapType.WestWall: return 0x1111;
|
||||
}
|
||||
|
||||
return 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader 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(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue