Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
792
Scripts/Services/Doom/GaryRoom.cs
Normal file
792
Scripts/Services/Doom/GaryRoom.cs
Normal file
@@ -0,0 +1,792 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Items;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
[PropertyObject]
|
||||
public class GaryRegion : BaseRegion
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Core.SA)
|
||||
{
|
||||
new GaryRegion();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GaryTheDungeonMaster Gary { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Sapphired20 Dice { get; set; }
|
||||
|
||||
public DisplayStatue[] Statues { get; set; }
|
||||
|
||||
public Timer Timer { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseDoor DoorOne { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseDoor DoorTwo { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime NextRoll { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseCreature Spawn { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ForceRoll { get; set; }
|
||||
|
||||
private static Point3D _GaryLoc = new Point3D(389, 8, 0);
|
||||
private static Point3D _DiceLoc = new Point3D(390, 8, 5);
|
||||
private static Point3D _RulesLoc = new Point3D(390, 9, 6);
|
||||
private static Point3D _SpawnLoc = new Point3D(396, 8, 4);
|
||||
private static Point3D _DoorOneLoc = new Point3D(395, 15, -1);
|
||||
private static Point3D _DoorTwoLoc = new Point3D(396, 15, -1);
|
||||
private static Point3D[] _StatueLocs = new Point3D[]
|
||||
{
|
||||
new Point3D(393, 4, 5),
|
||||
new Point3D(395, 4 ,5),
|
||||
new Point3D(397, 4, 5)
|
||||
};
|
||||
private static Rectangle2D[] _Bounds =
|
||||
{
|
||||
new Rectangle2D(388, 3, 16, 12)
|
||||
};
|
||||
|
||||
private Type[] _MonsterList =
|
||||
{
|
||||
typeof(BoneDemon), typeof(SkeletalKnight), typeof(SkeletalMage), typeof(DarkGuardian), typeof(Devourer),
|
||||
typeof(FleshGolem), typeof(Gibberling), typeof(AncientLich), typeof(Lich), typeof(LichLord),
|
||||
typeof(Mummy), typeof(PatchworkSkeleton), typeof(Ravager), typeof(RestlessSoul), typeof(Dragon),
|
||||
typeof(SkeletalDragon), typeof(VampireBat), typeof(WailingBanshee), typeof(WandererOfTheVoid)
|
||||
};
|
||||
|
||||
public TimeSpan RollDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromMinutes(Utility.RandomMinMax(12, 15));
|
||||
}
|
||||
}
|
||||
|
||||
public GaryRegion()
|
||||
: base("Gary Region", Map.Malas, Region.Find(_GaryLoc, Map.Malas), _Bounds)
|
||||
{
|
||||
Register();
|
||||
CheckStuff();
|
||||
}
|
||||
|
||||
public override void OnRegister()
|
||||
{
|
||||
NextRoll = DateTime.UtcNow;
|
||||
Timer = Timer.DelayCall(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), OnTick);
|
||||
|
||||
ForceRoll = -1;
|
||||
}
|
||||
|
||||
public override void OnUnregister()
|
||||
{
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTick()
|
||||
{
|
||||
if (NextRoll < DateTime.UtcNow /*&& (Spawn == null || !Spawn.Alive)*/ && this.GetEnumeratedMobiles().OfType<PlayerMobile>().Where(p => p.Alive).Count() > 0)
|
||||
{
|
||||
DoRoll();
|
||||
NextRoll = DateTime.UtcNow + RollDelay;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoRoll()
|
||||
{
|
||||
var g = GetGary();
|
||||
var d = GetDice();
|
||||
int roll = ForceRoll >= 0 && ForceRoll < 20 ? ForceRoll : Utility.Random(20);
|
||||
|
||||
g.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1080099); // *Gary rolls the sapphire d20*
|
||||
|
||||
var door1 = GetDoor1();
|
||||
var door2 = GetDoor2();
|
||||
|
||||
door1.Locked = true;
|
||||
door2.Locked = true;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(2), () =>
|
||||
{
|
||||
door1.Locked = false;
|
||||
door2.Locked = false;
|
||||
});
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
if (d != null)
|
||||
{
|
||||
d.Roll(roll);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var m in this.GetEnumeratedMobiles().OfType<PlayerMobile>())
|
||||
{
|
||||
m.SendMessage("- {0} -", (roll + 1).ToString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), () =>
|
||||
{
|
||||
if (roll == 19)
|
||||
{
|
||||
DoStaffSpawn();
|
||||
}
|
||||
else
|
||||
{
|
||||
Spawn = Activator.CreateInstance(_MonsterList[roll]) as BaseCreature;
|
||||
Server.Engines.XmlSpawner2.XmlAttach.AttachTo(Spawn, new Server.Engines.XmlSpawner2.XmlData("Notoriety", "red"));
|
||||
|
||||
if (Spawn is Dragon)
|
||||
{
|
||||
Spawn.Body = 155;
|
||||
Spawn.CorpseNameOverride = "a rotting corpse";
|
||||
}
|
||||
|
||||
Spawn.MoveToWorld(_SpawnLoc, Map.Malas);
|
||||
Spawn.Home = _SpawnLoc;
|
||||
Spawn.RangeHome = 7;
|
||||
}
|
||||
|
||||
ChangeStatues();
|
||||
});
|
||||
|
||||
ForceRoll = -1;
|
||||
}
|
||||
|
||||
public void ChangeStatues()
|
||||
{
|
||||
foreach (var statue in GetStatues())
|
||||
{
|
||||
statue.AssignRandom();
|
||||
}
|
||||
}
|
||||
|
||||
public void DoStaffSpawn()
|
||||
{
|
||||
GameMaster gm1 = new GameMaster();
|
||||
GameMaster gm2 = new GameMaster();
|
||||
|
||||
Point3D p = _SpawnLoc;
|
||||
|
||||
gm1.MoveToWorld(new Point3D(p.X + 1, p.Y - 1, p.Z), Map.Malas);
|
||||
gm2.MoveToWorld(new Point3D(p.X + 1, p.Y + 1, p.Z), Map.Malas);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
gm1.Say(1080100); // What the heck?
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
gm2.Say(1080101); // Did we just get summoned?
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), () =>
|
||||
{
|
||||
gm1.Say(1080102); // Wow. We did!
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
gm2.Say(1080103); // What're the odds of that!?
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), () =>
|
||||
{
|
||||
gm1.Say(1080104); // ...about 1 in 20?
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
gm2.Say(1080105); // *looks at the d20*
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), () =>
|
||||
{
|
||||
gm1.Say(1080106);// Ah, right.
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(2), () =>
|
||||
{
|
||||
DeleteStaff(gm1, gm2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void DeleteStaff(BaseCreature one, BaseCreature two)
|
||||
{
|
||||
GMHidingStone.SendStoneEffects((StoneEffect)Utility.Random(19), 0, one);
|
||||
GMHidingStone.SendStoneEffects((StoneEffect)Utility.Random(19), 0, two);
|
||||
|
||||
one.Delete();
|
||||
two.Delete();
|
||||
}
|
||||
|
||||
public override void OnDeath(Mobile m)
|
||||
{
|
||||
if (m == Spawn)
|
||||
{
|
||||
var door1 = GetDoor1();
|
||||
var door2 = GetDoor2();
|
||||
|
||||
door1.Locked = false;
|
||||
door2.Locked = false;
|
||||
|
||||
Spawn = null;
|
||||
}
|
||||
|
||||
base.OnDeath(m);
|
||||
}
|
||||
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
var g = GetGary();
|
||||
|
||||
g.SayTo(m, 1080098); // Ah... visitors!
|
||||
}
|
||||
|
||||
public override bool CheckTravel(Mobile traveller, Point3D p, Server.Spells.TravelCheckType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Server.Spells.TravelCheckType.Mark:
|
||||
case Server.Spells.TravelCheckType.RecallTo:
|
||||
case Server.Spells.TravelCheckType.RecallFrom:
|
||||
case Server.Spells.TravelCheckType.GateTo:
|
||||
case Server.Spells.TravelCheckType.GateFrom:
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckTravel(traveller, p, type);
|
||||
}
|
||||
|
||||
private GaryTheDungeonMaster GetGary()
|
||||
{
|
||||
if (Gary == null || Gary.Deleted)
|
||||
{
|
||||
GaryTheDungeonMaster gary = null;
|
||||
IPooledEnumerable eable = Map.GetMobilesInBounds(_Bounds[0]);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
if (m is GaryTheDungeonMaster)
|
||||
{
|
||||
gary = (GaryTheDungeonMaster)m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
if (gary != null)
|
||||
{
|
||||
Gary = gary;
|
||||
Gary.MoveToWorld(_GaryLoc, Map.Malas);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gary = new GaryTheDungeonMaster();
|
||||
Gary.MoveToWorld(_GaryLoc, Map.Malas);
|
||||
}
|
||||
}
|
||||
|
||||
return Gary;
|
||||
}
|
||||
|
||||
private Sapphired20 GetDice()
|
||||
{
|
||||
if (Dice == null || Dice.Deleted)
|
||||
{
|
||||
Sapphired20 dice = this.GetEnumeratedItems().OfType<Sapphired20>().FirstOrDefault(i => !i.Deleted);
|
||||
|
||||
if (dice != null)
|
||||
{
|
||||
Dice = dice;
|
||||
Dice.MoveToWorld(_DiceLoc, Map.Malas);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dice = new Sapphired20();
|
||||
Dice.Movable = false;
|
||||
Dice.MoveToWorld(_DiceLoc, Map.Malas);
|
||||
}
|
||||
}
|
||||
|
||||
return Dice;
|
||||
}
|
||||
|
||||
private DisplayStatue[] GetStatues()
|
||||
{
|
||||
if(Statues == null || Statues.Length != 3)
|
||||
{
|
||||
Statues = new DisplayStatue[3];
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
if(Statues[i] == null || Statues[i].Deleted)
|
||||
{
|
||||
DisplayStatue s = this.GetEnumeratedItems().OfType<DisplayStatue>().FirstOrDefault(st => Array.IndexOf(Statues, st) == -1);
|
||||
|
||||
if(s == null)
|
||||
{
|
||||
Statues[i] = new DisplayStatue();
|
||||
Statues[i].Movable = false;
|
||||
Statues[i].MoveToWorld(_StatueLocs[i], Map.Malas);
|
||||
}
|
||||
else
|
||||
{
|
||||
Statues[i] = s;
|
||||
Statues[i].MoveToWorld(_StatueLocs[i], Map.Malas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Statues;
|
||||
}
|
||||
|
||||
private BaseDoor GetDoor1()
|
||||
{
|
||||
if (DoorOne == null || DoorOne.Deleted)
|
||||
{
|
||||
//BaseDoor door = this.GetEnumeratedItems().OfType<DarkWoodDoor>().FirstOrDefault(d => d.Location == _DoorOneLoc);
|
||||
Point3D p = _DoorOneLoc;
|
||||
BaseDoor door = GetDoor(p);
|
||||
|
||||
if (door == null)
|
||||
{
|
||||
door = GetDoor(new Point3D(p.X - 1, p.Y + 1, p.Z));
|
||||
}
|
||||
|
||||
if (door == null)
|
||||
{
|
||||
DoorOne = new DarkWoodDoor(DoorFacing.WestCW);
|
||||
DoorOne.MoveToWorld(_DoorOneLoc, Map.Malas);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoorOne = door;
|
||||
}
|
||||
|
||||
DoorOne.Locked = false;
|
||||
}
|
||||
|
||||
return DoorOne;
|
||||
}
|
||||
|
||||
private BaseDoor GetDoor2()
|
||||
{
|
||||
if (DoorTwo == null || DoorTwo.Deleted)
|
||||
{
|
||||
//BaseDoor door = this.GetEnumeratedItems().OfType<DarkWoodDoor>().FirstOrDefault(d => d.Location == _DoorOneLoc);
|
||||
Point3D p = _DoorTwoLoc;
|
||||
BaseDoor door = GetDoor(p);
|
||||
|
||||
if (door == null)
|
||||
{
|
||||
door = GetDoor(new Point3D(p.X + 1, p.Y + 1, p.Z));
|
||||
}
|
||||
|
||||
if (door == null)
|
||||
{
|
||||
DoorTwo = new DarkWoodDoor(DoorFacing.EastCCW);
|
||||
DoorTwo.MoveToWorld(_DoorTwoLoc, Map.Malas);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoorTwo = door;
|
||||
}
|
||||
|
||||
DoorTwo.Locked = false;
|
||||
}
|
||||
|
||||
return DoorTwo;
|
||||
}
|
||||
|
||||
private void CheckStuff()
|
||||
{
|
||||
GetGary();
|
||||
GetStatues();
|
||||
GetDice();
|
||||
GetDoor1();
|
||||
GetDoor2();
|
||||
|
||||
if (!FindObject(typeof(UOBoard), _RulesLoc))
|
||||
{
|
||||
var rules = new UOBoard();
|
||||
rules.Movable = false;
|
||||
rules.MoveToWorld(_RulesLoc, Map.Malas);
|
||||
}
|
||||
|
||||
Point3D p = new Point3D(390, 7, 2);
|
||||
|
||||
if (!FindObject(typeof(Static), p))
|
||||
{
|
||||
var books = new Static(0x1E22);
|
||||
books.MoveToWorld(p, Map.Malas);
|
||||
}
|
||||
|
||||
if (!FindObject(typeof(ScribesPen), p))
|
||||
{
|
||||
var pen = new ScribesPen();
|
||||
pen.ItemID = 4032;
|
||||
pen.Movable = false;
|
||||
pen.MoveToWorld(p, Map.Malas);
|
||||
}
|
||||
}
|
||||
|
||||
private bool FindObject(Type t, Point3D p)
|
||||
{
|
||||
IPooledEnumerable eable = Map.GetObjectsInRange(p, 0);
|
||||
|
||||
foreach (object o in eable)
|
||||
{
|
||||
if (o.GetType() == t)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
return false;
|
||||
}
|
||||
|
||||
private BaseDoor GetDoor(Point3D p)
|
||||
{
|
||||
IPooledEnumerable eable = Map.GetItemsInRange(p, 0);
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if(item is BaseDoor)
|
||||
{
|
||||
eable.Free();
|
||||
return (BaseDoor)item;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class Sapphired20 : Item
|
||||
{
|
||||
public override int LabelNumber { get { return 1080096; } } // Star Sapphire d20
|
||||
|
||||
[Constructable]
|
||||
public Sapphired20()
|
||||
: base(0x3192)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (this.GetRegion().IsPartOf<GaryRegion>())
|
||||
{
|
||||
m.SendLocalizedMessage(1080097); // You're blasted back in a blaze of light! This d20 is not yours to roll...
|
||||
|
||||
m.Damage(Utility.RandomMinMax(20, 30));
|
||||
}
|
||||
else
|
||||
{
|
||||
Roll(Utility.Random(20));
|
||||
}
|
||||
}
|
||||
|
||||
public void Roll(int roll)
|
||||
{
|
||||
PublicOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, false, String.Format("- {0} -", (roll + 1).ToString()));
|
||||
}
|
||||
|
||||
public Sapphired20(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class DisplayStatue : Item
|
||||
{
|
||||
private MonsterStatuetteInfo _Info;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public MonsterStatuetteInfo Info
|
||||
{
|
||||
get { return _Info; }
|
||||
set
|
||||
{
|
||||
_Info = value;
|
||||
|
||||
if (ItemID != _Info.ItemID)
|
||||
{
|
||||
ItemID = _Info.ItemID;
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Info == null)
|
||||
return base.LabelNumber;
|
||||
|
||||
return _Info.LabelNumber;
|
||||
}
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public DisplayStatue()
|
||||
{
|
||||
AssignRandom();
|
||||
|
||||
Hue = 2958;
|
||||
}
|
||||
|
||||
public void AssignRandom()
|
||||
{
|
||||
MonsterStatuetteInfo info;
|
||||
|
||||
do
|
||||
{
|
||||
info = MonsterStatuetteInfo.Table[Utility.Random(MonsterStatuetteInfo.Table.Length)];
|
||||
}
|
||||
while (ItemID == info.ItemID);
|
||||
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public DisplayStatue(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
AssignRandom();
|
||||
}
|
||||
}
|
||||
|
||||
public class UOBoard : Item
|
||||
{
|
||||
private int _Index;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Index
|
||||
{
|
||||
get { return _Index; }
|
||||
set
|
||||
{
|
||||
_Index = value;
|
||||
|
||||
if (_Index < 0)
|
||||
_Index = 0;
|
||||
|
||||
if (_Index > 9)
|
||||
_Index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override int LabelNumber { get { return 1080085; } } // The Rulebook
|
||||
|
||||
[Constructable]
|
||||
public UOBoard() : base(0xFAA)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if(from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
int cliloc;
|
||||
|
||||
if(_Index == 0)
|
||||
{
|
||||
cliloc = 1080095;
|
||||
}
|
||||
else
|
||||
{
|
||||
cliloc = 1080086 + _Index;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(cliloc);
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> entries)
|
||||
{
|
||||
base.GetContextMenuEntries(from, entries);
|
||||
|
||||
entries.Add(new SimpleContextMenuEntry(from, 3006162, m =>
|
||||
{
|
||||
Index = 0;
|
||||
}, 2));
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1062703); // Spectator Vision
|
||||
}
|
||||
|
||||
public UOBoard(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class GaryTheDungeonMaster : BaseCreature
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GaryRegion RegionProps
|
||||
{
|
||||
get { return this.Region as GaryRegion; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public GaryTheDungeonMaster()
|
||||
: base(AIType.AI_Vendor, FightMode.None, 10, 1, .2, .4)
|
||||
{
|
||||
Blessed = true;
|
||||
Body = 0x190;
|
||||
Name = "Gary";
|
||||
Title = "the Dungeon Master";
|
||||
|
||||
SetStr(150);
|
||||
SetInt(150);
|
||||
SetDex(150);
|
||||
|
||||
SetWearable(new ShortPants(), 1024);
|
||||
SetWearable(new FancyShirt(), 680);
|
||||
SetWearable(new JinBaori());
|
||||
SetWearable(new Shoes());
|
||||
|
||||
HairItemID = 8253;
|
||||
FacialHairItemID = 8267;
|
||||
Hue = Race.RandomSkinHue();
|
||||
|
||||
CantWalk = true;
|
||||
SpeechHue = 0x3B2;
|
||||
}
|
||||
|
||||
public GaryTheDungeonMaster(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(1);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (version == 0)
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public class GameMaster : BaseCreature
|
||||
{
|
||||
public GameMaster()
|
||||
: base(AIType.AI_Vendor, FightMode.None, 10, 1, .2, .4)
|
||||
{
|
||||
Blessed = true;
|
||||
Body = 0x190;
|
||||
Name = "Game Master";
|
||||
|
||||
SetStr(150);
|
||||
SetInt(150);
|
||||
SetDex(150);
|
||||
|
||||
SetWearable(new Robe(0x204F), 0x85);
|
||||
|
||||
HairItemID = 8253;
|
||||
FacialHairItemID = 8267;
|
||||
Hue = Race.RandomSkinHue();
|
||||
|
||||
CantWalk = true;
|
||||
SpeechHue = 0x3B2;
|
||||
}
|
||||
|
||||
public GameMaster(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10), Delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
964
Scripts/Services/Doom/GauntletSpawner.cs
Normal file
964
Scripts/Services/Doom/GauntletSpawner.cs
Normal file
@@ -0,0 +1,964 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Server.Commands;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
public enum GauntletSpawnerState
|
||||
{
|
||||
InSequence,
|
||||
InProgress,
|
||||
Completed
|
||||
}
|
||||
|
||||
public class GauntletSpawner : Item
|
||||
{
|
||||
public const int PlayersPerSpawn = 5;
|
||||
public const int InSequenceItemHue = 0x000;
|
||||
public const int InProgressItemHue = 0x676;
|
||||
public const int CompletedItemHue = 0x455;
|
||||
|
||||
private GauntletSpawnerState m_State;
|
||||
|
||||
private string m_TypeName;
|
||||
|
||||
private BaseDoor m_Door;
|
||||
private BaseAddon m_Addon;
|
||||
|
||||
private GauntletSpawner m_Sequence;
|
||||
|
||||
private List<Mobile> m_Creatures;
|
||||
private List<BaseTrap> m_Traps;
|
||||
|
||||
private Rectangle2D m_RegionBounds;
|
||||
|
||||
private Region m_Region;
|
||||
private Timer m_Timer;
|
||||
|
||||
[Constructable]
|
||||
public GauntletSpawner()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public GauntletSpawner(string typeName)
|
||||
: base(0x36FE)
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_TypeName = typeName;
|
||||
m_Creatures = new List<Mobile>();
|
||||
m_Traps = new List<BaseTrap>();
|
||||
}
|
||||
|
||||
public GauntletSpawner(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string TypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_TypeName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TypeName = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseDoor Door
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Door;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Door = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseAddon Addon
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Addon;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Addon = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GauntletSpawner Sequence
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Sequence;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Sequence = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool HasCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Creatures.Count == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < m_Creatures.Count; ++i)
|
||||
{
|
||||
Mobile mob = m_Creatures[i];
|
||||
|
||||
if (!mob.Deleted)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Rectangle2D RegionBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_RegionBounds;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_RegionBounds = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GauntletSpawnerState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_State;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_State == value)
|
||||
return;
|
||||
|
||||
m_State = value;
|
||||
|
||||
int hue = 0;
|
||||
bool lockDoors = (m_State == GauntletSpawnerState.InProgress);
|
||||
|
||||
switch ( m_State )
|
||||
{
|
||||
case GauntletSpawnerState.InSequence:
|
||||
hue = InSequenceItemHue;
|
||||
break;
|
||||
case GauntletSpawnerState.InProgress:
|
||||
hue = InProgressItemHue;
|
||||
break;
|
||||
case GauntletSpawnerState.Completed:
|
||||
hue = CompletedItemHue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_Door != null)
|
||||
{
|
||||
m_Door.Hue = hue;
|
||||
m_Door.Locked = lockDoors;
|
||||
|
||||
if (lockDoors)
|
||||
{
|
||||
m_Door.KeyValue = Key.RandomValue();
|
||||
m_Door.Open = false;
|
||||
}
|
||||
|
||||
if (m_Door.Link != null)
|
||||
{
|
||||
m_Door.Link.Hue = hue;
|
||||
m_Door.Link.Locked = lockDoors;
|
||||
|
||||
if (lockDoors)
|
||||
{
|
||||
m_Door.Link.KeyValue = Key.RandomValue();
|
||||
m_Door.Open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Addon != null)
|
||||
m_Addon.Hue = hue;
|
||||
|
||||
if (m_State == GauntletSpawnerState.InProgress)
|
||||
{
|
||||
CreateRegion();
|
||||
FullSpawn();
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), new TimerCallback(Slice));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearCreatures();
|
||||
ClearTraps();
|
||||
DestroyRegion();
|
||||
|
||||
if (m_Timer != null)
|
||||
m_Timer.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Mobile> Creatures
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Creatures;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Creatures = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseTrap> Traps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Traps;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Traps = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Region Region
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Region;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Region = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "doom spawner";
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("GenGauntlet", AccessLevel.Administrator, new CommandEventHandler(GenGauntlet_OnCommand));
|
||||
CommandSystem.Register("DeleteGauntlet", AccessLevel.Administrator, new CommandEventHandler(DeleteGauntlet_OnCommand));
|
||||
}
|
||||
|
||||
private static bool FindObject<T>(Map map, Point3D p, int range, out T value) where T : IEntity
|
||||
{
|
||||
return FindObject(map, p, range, null, out value);
|
||||
}
|
||||
|
||||
private static bool FindObject<T>(Map map, Point3D p, int range, Func<T, bool> predicate, out T value)
|
||||
where T : IEntity
|
||||
{
|
||||
value = default(T);
|
||||
|
||||
var any = false;
|
||||
|
||||
var e = map.GetObjectsInRange(p, range);
|
||||
|
||||
foreach (var o in (predicate != null ? e.OfType<T>().Where(predicate) : e.OfType<T>()).Where(o => o != null))
|
||||
{
|
||||
value = o;
|
||||
any = true;
|
||||
break;
|
||||
}
|
||||
|
||||
e.Free();
|
||||
|
||||
return any;
|
||||
}
|
||||
|
||||
private static void DeleteDoor(BaseDoor d)
|
||||
{
|
||||
if (d == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.Link != null)
|
||||
{
|
||||
DeleteDoor(d.Link);
|
||||
}
|
||||
|
||||
d.Delete();
|
||||
}
|
||||
|
||||
public static void CreateTeleporter(int xFrom, int yFrom, int xTo, int yTo)
|
||||
{
|
||||
var p = new Point3D(xFrom, yFrom, -1);
|
||||
|
||||
Static telePad;
|
||||
|
||||
if (FindObject(Map.Malas, p, 0, out telePad))
|
||||
{
|
||||
telePad.Delete();
|
||||
}
|
||||
|
||||
telePad = new Static(0x1822);
|
||||
telePad.MoveToWorld(p, Map.Malas);
|
||||
telePad.Hue = 0x482;
|
||||
|
||||
WeakEntityCollection.Add("doom", telePad);
|
||||
|
||||
Teleporter teleItem;
|
||||
|
||||
if (FindObject(Map.Malas, p, 0, out teleItem))
|
||||
{
|
||||
teleItem.Delete();
|
||||
}
|
||||
|
||||
teleItem = new Teleporter(new Point3D(xTo, yTo, -1), Map.Malas, false);
|
||||
teleItem.MoveToWorld(p, Map.Malas);
|
||||
teleItem.SourceEffect = true;
|
||||
teleItem.DestEffect = true;
|
||||
teleItem.SoundID = 0x1FE;
|
||||
|
||||
WeakEntityCollection.Add("doom", teleItem);
|
||||
}
|
||||
|
||||
public static BaseDoor CreateDoorSet(int xDoor, int yDoor, bool doorEastToWest, int hue)
|
||||
{
|
||||
var ph = new Point3D(xDoor, yDoor, -1);
|
||||
var pl = new Point3D(xDoor + (doorEastToWest ? 0 : 1), yDoor + (doorEastToWest ? 1 : 0), -1);
|
||||
|
||||
BaseDoor hiDoor, loDoor;
|
||||
|
||||
if (FindObject(Map.Malas, ph, 0, out hiDoor))
|
||||
{
|
||||
DeleteDoor(hiDoor);
|
||||
}
|
||||
|
||||
if (FindObject(Map.Malas, pl, 0, out loDoor))
|
||||
{
|
||||
DeleteDoor(loDoor);
|
||||
}
|
||||
|
||||
hiDoor = new MetalDoor(doorEastToWest ? DoorFacing.NorthCCW : DoorFacing.WestCW);
|
||||
loDoor = new MetalDoor(doorEastToWest ? DoorFacing.SouthCW : DoorFacing.EastCCW);
|
||||
|
||||
hiDoor.MoveToWorld(ph, Map.Malas);
|
||||
loDoor.MoveToWorld(pl, Map.Malas);
|
||||
|
||||
hiDoor.Link = loDoor;
|
||||
loDoor.Link = hiDoor;
|
||||
|
||||
hiDoor.Hue = hue;
|
||||
loDoor.Hue = hue;
|
||||
|
||||
WeakEntityCollection.Add("doom", hiDoor);
|
||||
WeakEntityCollection.Add("doom", loDoor);
|
||||
|
||||
return hiDoor;
|
||||
}
|
||||
|
||||
public static GauntletSpawner CreateSpawner(
|
||||
string typeName,
|
||||
int xSpawner,
|
||||
int ySpawner,
|
||||
int xDoor,
|
||||
int yDoor,
|
||||
int xPentagram,
|
||||
int yPentagram,
|
||||
bool doorEastToWest,
|
||||
int xStart,
|
||||
int yStart,
|
||||
int xWidth,
|
||||
int yHeight)
|
||||
{
|
||||
var sp = new Point3D(xSpawner, ySpawner, -1);
|
||||
|
||||
GauntletSpawner spawner;
|
||||
|
||||
if (FindObject(Map.Malas, sp, 0, out spawner))
|
||||
{
|
||||
spawner.Delete();
|
||||
}
|
||||
|
||||
spawner = new GauntletSpawner(typeName);
|
||||
spawner.MoveToWorld(sp, Map.Malas);
|
||||
|
||||
if (spawner.Door != null)
|
||||
{
|
||||
DeleteDoor(spawner.Door);
|
||||
}
|
||||
|
||||
if (xDoor > 0 && yDoor > 0)
|
||||
{
|
||||
spawner.Door = CreateDoorSet(xDoor, yDoor, doorEastToWest, 0);
|
||||
}
|
||||
|
||||
spawner.RegionBounds = new Rectangle2D(xStart, yStart, xWidth, yHeight);
|
||||
|
||||
if (spawner.Addon != null)
|
||||
{
|
||||
spawner.Addon.Delete();
|
||||
spawner.Addon = null;
|
||||
}
|
||||
|
||||
if (xPentagram > 0 && yPentagram > 0)
|
||||
{
|
||||
var pp = new Point3D(xPentagram, yPentagram, -1);
|
||||
|
||||
PentagramAddon pentagram;
|
||||
|
||||
if (FindObject(Map.Malas, pp, 0, out pentagram))
|
||||
{
|
||||
pentagram.Delete();
|
||||
}
|
||||
|
||||
pentagram = new PentagramAddon();
|
||||
pentagram.MoveToWorld(pp, Map.Malas);
|
||||
|
||||
WeakEntityCollection.Add("doom", pentagram);
|
||||
|
||||
spawner.Addon = pentagram;
|
||||
}
|
||||
|
||||
WeakEntityCollection.Add("doom", spawner);
|
||||
|
||||
return spawner;
|
||||
}
|
||||
|
||||
public static void CreatePricedHealer(int price, int x, int y)
|
||||
{
|
||||
var p = new Point3D(x, y, -1);
|
||||
|
||||
PricedHealer healer;
|
||||
|
||||
if (FindObject(Map.Malas, p, 10, out healer))
|
||||
{
|
||||
healer.Delete();
|
||||
}
|
||||
|
||||
healer = new PricedHealer(price);
|
||||
healer.MoveToWorld(p, Map.Malas);
|
||||
healer.Home = p;
|
||||
healer.RangeHome = 5;
|
||||
|
||||
WeakEntityCollection.Add("doom", healer);
|
||||
}
|
||||
|
||||
public static void CreateMorphItem(int x, int y, int inactiveItemID, int activeItemID, int range, int hue)
|
||||
{
|
||||
var p = new Point3D(x, y, -1);
|
||||
|
||||
MorphItem item;
|
||||
|
||||
if (FindObject(Map.Malas, p, 0, out item))
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
|
||||
item = new MorphItem(inactiveItemID, activeItemID, range);
|
||||
item.MoveToWorld(p, Map.Malas);
|
||||
item.Hue = hue;
|
||||
|
||||
WeakEntityCollection.Add("doom", item);
|
||||
}
|
||||
|
||||
public static void CreateVarietyDealer(int x, int y)
|
||||
{
|
||||
var p = new Point3D(x, y, -1);
|
||||
|
||||
VarietyDealer dealer;
|
||||
|
||||
if (FindObject(Map.Malas, p, 10, out dealer))
|
||||
{
|
||||
dealer.Delete();
|
||||
}
|
||||
|
||||
dealer = new VarietyDealer
|
||||
{
|
||||
Name = "Nix",
|
||||
Title = "the Variety Dealer",
|
||||
Body = 400,
|
||||
Female = false,
|
||||
Hue = 0x8835
|
||||
};
|
||||
|
||||
WeakEntityCollection.Add("doom", dealer);
|
||||
|
||||
/* Begin outfit */
|
||||
|
||||
var ic = dealer.Items.Count;
|
||||
|
||||
while (--ic >= 0)
|
||||
{
|
||||
if (ic >= dealer.Items.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var item = dealer.Items[ic];
|
||||
|
||||
if (item.Layer != Layer.ShopBuy && item.Layer != Layer.ShopResale && item.Layer != Layer.ShopSell)
|
||||
item.Delete();
|
||||
}
|
||||
|
||||
dealer.HairItemID = 0x2049; // Pig Tails
|
||||
dealer.HairHue = 0x482;
|
||||
|
||||
dealer.FacialHairItemID = 0x203E;
|
||||
dealer.FacialHairHue = 0x482;
|
||||
|
||||
dealer.AddItem(new FloppyHat(1));
|
||||
dealer.AddItem(new Robe(1));
|
||||
|
||||
dealer.AddItem(new LanternOfSouls());
|
||||
|
||||
dealer.AddItem(new Sandals(0x482));
|
||||
/* End outfit */
|
||||
|
||||
dealer.MoveToWorld(p, Map.Malas);
|
||||
|
||||
dealer.Home = p;
|
||||
dealer.RangeHome = 2;
|
||||
}
|
||||
|
||||
public static void DeleteGauntlet_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
WeakEntityCollection.Delete("doom");
|
||||
}
|
||||
|
||||
public static void GenGauntlet_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
WeakEntityCollection.Delete("doom");
|
||||
|
||||
/* Begin healer room */
|
||||
CreatePricedHealer(5000, 387, 400);
|
||||
CreateTeleporter(390, 407, 394, 405);
|
||||
|
||||
BaseDoor healerDoor = CreateDoorSet(393, 404, true, 0x44E);
|
||||
|
||||
healerDoor.Locked = true;
|
||||
healerDoor.KeyValue = Key.RandomValue();
|
||||
|
||||
if (healerDoor.Link != null)
|
||||
{
|
||||
healerDoor.Link.Locked = true;
|
||||
healerDoor.Link.KeyValue = Key.RandomValue();
|
||||
}
|
||||
/* End healer room */
|
||||
|
||||
/* Begin supply room */
|
||||
CreateMorphItem(433, 371, 0x29F, 0x116, 3, 0x44E);
|
||||
CreateMorphItem(433, 372, 0x29F, 0x115, 3, 0x44E);
|
||||
|
||||
CreateVarietyDealer(492, 369);
|
||||
|
||||
foreach (var s in Map.Malas.GetItemsInBounds(new Rectangle2D(434, 371, 44, 1)))
|
||||
{
|
||||
s.Delete();
|
||||
}
|
||||
|
||||
for (int x = 434; x <= 478; ++x)
|
||||
{
|
||||
for (int y = 371; y <= 372; ++y)
|
||||
{
|
||||
var item = new Static(0x524)
|
||||
{
|
||||
Hue = 1
|
||||
};
|
||||
|
||||
item.MoveToWorld(new Point3D(x, y, -1), Map.Malas);
|
||||
|
||||
WeakEntityCollection.Add("doom", item);
|
||||
}
|
||||
}
|
||||
/* End supply room */
|
||||
|
||||
/* Begin gauntlet cycle */
|
||||
CreateTeleporter(471, 428, 474, 428);
|
||||
CreateTeleporter(462, 494, 462, 498);
|
||||
CreateTeleporter(403, 502, 399, 506);
|
||||
CreateTeleporter(357, 476, 356, 480);
|
||||
CreateTeleporter(361, 433, 357, 434);
|
||||
|
||||
GauntletSpawner sp1 = CreateSpawner("DarknightCreeper", 491, 456, 473, 432, 417, 426, true, 473, 412, 39, 60);
|
||||
GauntletSpawner sp2 = CreateSpawner("FleshRenderer", 482, 520, 468, 496, 426, 422, false, 448, 496, 56, 48);
|
||||
GauntletSpawner sp3 = CreateSpawner("Impaler", 406, 538, 408, 504, 432, 430, false, 376, 504, 64, 48);
|
||||
GauntletSpawner sp4 = CreateSpawner("ShadowKnight", 335, 512, 360, 478, 424, 439, false, 300, 478, 72, 64);
|
||||
GauntletSpawner sp5 = CreateSpawner("AbysmalHorror", 326, 433, 360, 429, 416, 435, true, 300, 408, 60, 56);
|
||||
GauntletSpawner sp6 = CreateSpawner("DemonKnight", 423, 430, 0, 0, 423, 430, true, 392, 392, 72, 96);
|
||||
|
||||
sp1.Sequence = sp2;
|
||||
sp2.Sequence = sp3;
|
||||
sp3.Sequence = sp4;
|
||||
sp4.Sequence = sp5;
|
||||
sp5.Sequence = sp6;
|
||||
sp6.Sequence = sp1;
|
||||
|
||||
sp1.State = GauntletSpawnerState.InProgress;
|
||||
/* End gauntlet cycle */
|
||||
|
||||
/* Begin exit gate */
|
||||
var p = new Point3D(433, 326, 4);
|
||||
|
||||
ConfirmationMoongate gate;
|
||||
|
||||
if (FindObject(Map.Malas, p, 0, out gate))
|
||||
{
|
||||
gate.Delete();
|
||||
}
|
||||
|
||||
gate = new ConfirmationMoongate
|
||||
{
|
||||
Dispellable = false,
|
||||
Target = new Point3D(2350, 1270, -85),
|
||||
TargetMap = Map.Malas,
|
||||
GumpWidth = 420,
|
||||
GumpHeight = 280,
|
||||
MessageColor = 0x7F00,
|
||||
MessageNumber = 1062109, // You are about to exit Dungeon Doom. Do you wish to continue?
|
||||
TitleColor = 0x7800,
|
||||
TitleNumber = 1062108, // Please verify...
|
||||
Hue = 0x44E
|
||||
};
|
||||
|
||||
gate.MoveToWorld(p, Map.Malas);
|
||||
|
||||
WeakEntityCollection.Add("doom", gate);
|
||||
/* End exit gate */
|
||||
}
|
||||
|
||||
public virtual void CreateRegion()
|
||||
{
|
||||
if (m_Region != null)
|
||||
return;
|
||||
|
||||
Map map = Map;
|
||||
|
||||
if (map == null || map == Map.Internal)
|
||||
return;
|
||||
|
||||
m_Region = new GauntletRegion(this, map);
|
||||
}
|
||||
|
||||
public virtual void DestroyRegion()
|
||||
{
|
||||
if (m_Region != null)
|
||||
m_Region.Unregister();
|
||||
|
||||
m_Region = null;
|
||||
}
|
||||
|
||||
public virtual int ComputeTrapCount()
|
||||
{
|
||||
int area = m_RegionBounds.Width * m_RegionBounds.Height;
|
||||
|
||||
return area / 100;
|
||||
}
|
||||
|
||||
public virtual void ClearTraps()
|
||||
{
|
||||
for (int i = 0; i < m_Traps.Count; ++i)
|
||||
m_Traps[i].Delete();
|
||||
|
||||
m_Traps.Clear();
|
||||
}
|
||||
|
||||
public virtual void SpawnTrap()
|
||||
{
|
||||
Map map = Map;
|
||||
|
||||
if (map == null)
|
||||
return;
|
||||
|
||||
BaseTrap trap = null;
|
||||
|
||||
int random = Utility.Random(100);
|
||||
|
||||
if (22 > random)
|
||||
trap = new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor);
|
||||
else if (44 > random)
|
||||
trap = new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor);
|
||||
else if (66 > random)
|
||||
trap = new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall);
|
||||
else if (88 > random)
|
||||
trap = new FireColumnTrap();
|
||||
else
|
||||
trap = new MushroomTrap();
|
||||
|
||||
if (trap == null)
|
||||
return;
|
||||
|
||||
if (trap is FireColumnTrap || trap is MushroomTrap)
|
||||
trap.Hue = 0x451;
|
||||
|
||||
// try 10 times to find a valid location
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
int x = Utility.Random(m_RegionBounds.X, m_RegionBounds.Width);
|
||||
int y = Utility.Random(m_RegionBounds.Y, m_RegionBounds.Height);
|
||||
int z = Z;
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
z = map.GetAverageZ(x, y);
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
continue;
|
||||
|
||||
trap.MoveToWorld(new Point3D(x, y, z), map);
|
||||
m_Traps.Add(trap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trap.Delete();
|
||||
}
|
||||
|
||||
public virtual int ComputeSpawnCount()
|
||||
{
|
||||
int playerCount = 0;
|
||||
|
||||
Map map = Map;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
Point3D loc = GetWorldLocation();
|
||||
|
||||
Region reg = Region.Find(loc, map).GetRegion("Doom Gauntlet");
|
||||
|
||||
if (reg != null)
|
||||
playerCount = reg.GetEnumeratedMobiles().Where(m => m is PlayerMobile && m.AccessLevel == AccessLevel.Player).Count();
|
||||
}
|
||||
|
||||
if (playerCount == 0 && m_Region != null)
|
||||
playerCount = m_Region.GetEnumeratedMobiles().Where(m => m.AccessLevel == AccessLevel.Player).Count();
|
||||
|
||||
int count = (playerCount + PlayersPerSpawn - 1) / PlayersPerSpawn;
|
||||
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual void ClearCreatures()
|
||||
{
|
||||
for (int i = 0; i < m_Creatures.Count; ++i)
|
||||
m_Creatures[i].Delete();
|
||||
|
||||
m_Creatures.Clear();
|
||||
}
|
||||
|
||||
public virtual void FullSpawn()
|
||||
{
|
||||
ClearCreatures();
|
||||
|
||||
int count = ComputeSpawnCount();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
Spawn();
|
||||
|
||||
ClearTraps();
|
||||
|
||||
count = ComputeTrapCount();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
SpawnTrap();
|
||||
}
|
||||
|
||||
public virtual void Spawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_TypeName == null)
|
||||
return;
|
||||
|
||||
Type type = ScriptCompiler.FindTypeByName(m_TypeName, true);
|
||||
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
object obj = Activator.CreateInstance(type);
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
if (obj is Item)
|
||||
{
|
||||
((Item)obj).Delete();
|
||||
}
|
||||
else if (obj is Mobile)
|
||||
{
|
||||
Mobile mob = (Mobile)obj;
|
||||
|
||||
mob.MoveToWorld(GetWorldLocation(), Map);
|
||||
|
||||
m_Creatures.Add(mob);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RecurseReset()
|
||||
{
|
||||
if (m_State != GauntletSpawnerState.InSequence)
|
||||
{
|
||||
State = GauntletSpawnerState.InSequence;
|
||||
|
||||
if (m_Sequence != null && !m_Sequence.Deleted)
|
||||
m_Sequence.RecurseReset();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Slice()
|
||||
{
|
||||
if (m_State != GauntletSpawnerState.InProgress)
|
||||
return;
|
||||
|
||||
int count = ComputeSpawnCount();
|
||||
|
||||
for (int i = m_Creatures.Count; i < count; ++i)
|
||||
Spawn();
|
||||
|
||||
if (HasCompleted)
|
||||
{
|
||||
State = GauntletSpawnerState.Completed;
|
||||
|
||||
if (m_Sequence != null && !m_Sequence.Deleted)
|
||||
{
|
||||
if (m_Sequence.State == GauntletSpawnerState.Completed)
|
||||
RecurseReset();
|
||||
|
||||
m_Sequence.State = GauntletSpawnerState.InProgress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
ClearCreatures();
|
||||
ClearTraps();
|
||||
DestroyRegion();
|
||||
|
||||
if (m_Timer != null)
|
||||
m_Timer.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)1); // version
|
||||
|
||||
writer.Write(m_RegionBounds);
|
||||
|
||||
writer.WriteItemList<BaseTrap>(m_Traps, false);
|
||||
|
||||
writer.Write(m_Creatures, false);
|
||||
|
||||
writer.Write(m_TypeName);
|
||||
writer.WriteItem<BaseDoor>(m_Door);
|
||||
writer.WriteItem<BaseAddon>(m_Addon);
|
||||
writer.WriteItem<GauntletSpawner>(m_Sequence);
|
||||
|
||||
writer.Write((int)m_State);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_RegionBounds = reader.ReadRect2D();
|
||||
m_Traps = reader.ReadStrongItemList<BaseTrap>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if (version < 1)
|
||||
{
|
||||
m_Traps = new List<BaseTrap>();
|
||||
m_RegionBounds = new Rectangle2D(X - 40, Y - 40, 80, 80);
|
||||
}
|
||||
|
||||
m_Creatures = reader.ReadStrongMobileList();
|
||||
|
||||
m_TypeName = reader.ReadString();
|
||||
m_Door = reader.ReadItem<BaseDoor>();
|
||||
m_Addon = reader.ReadItem<BaseAddon>();
|
||||
m_Sequence = reader.ReadItem<GauntletSpawner>();
|
||||
|
||||
State = (GauntletSpawnerState)reader.ReadInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GauntletRegion : BaseRegion
|
||||
{
|
||||
private readonly GauntletSpawner m_Spawner;
|
||||
public GauntletRegion(GauntletSpawner spawner, Map map)
|
||||
: base(null, map, Region.Find(spawner.Location, spawner.Map), spawner.RegionBounds)
|
||||
{
|
||||
m_Spawner = spawner;
|
||||
|
||||
GoLocation = spawner.Location;
|
||||
|
||||
Register();
|
||||
}
|
||||
|
||||
public override void AlterLightLevel(Mobile m, ref int global, ref int personal)
|
||||
{
|
||||
global = 12;
|
||||
}
|
||||
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
295
Scripts/Services/Doom/GuardianRoom.cs
Normal file
295
Scripts/Services/Doom/GuardianRoom.cs
Normal file
@@ -0,0 +1,295 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
public class DoomGuardianRegion : DungeonRegion
|
||||
{
|
||||
public static DoomGuardianRegion Instance { get; set; }
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Instance != null)
|
||||
Instance.CheckDoors();
|
||||
}
|
||||
|
||||
private Timer m_Timer;
|
||||
|
||||
public bool Active { get; set; }
|
||||
public List<DarkGuardian> Guardians { get; set; }
|
||||
public BaseDoor DoorOne { get; set; }
|
||||
public BaseDoor DoorTwo { get; set; }
|
||||
public DateTime NextActivate { get; set; }
|
||||
|
||||
public bool CanActivate { get { return NextActivate < DateTime.UtcNow; } }
|
||||
|
||||
private static Rectangle2D[] RegionBounds = new Rectangle2D[] { new Rectangle2D(355, 5, 20, 20) };
|
||||
private static Rectangle2D PentagramBounds = new Rectangle2D(364, 14, 2, 2);
|
||||
private static Point3D DoorOneLoc = new Point3D(355, 14, -1);
|
||||
private static Point3D DoorTwoLoc = new Point3D(355, 15, -1);
|
||||
private static Point3D KickLoc = new Point3D(344, 172, -1);
|
||||
private static Point3D PentagramLoc = new Point3D(365, 15, -1);
|
||||
|
||||
public DoomGuardianRegion(XmlElement xml, Map map, Region parent)
|
||||
: base(xml, map, parent)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnLocationChanged( Mobile m, Point3D oldLocation )
|
||||
{
|
||||
base.OnLocationChanged( m, oldLocation );
|
||||
|
||||
if(!Active && CanActivate && m is PlayerMobile && m.AccessLevel == AccessLevel.Player && m.Alive)
|
||||
{
|
||||
for(int x = m.X - 3; x <= m.X + 3; x++)
|
||||
{
|
||||
for(int y = m.Y - 3; y <= m.Y + 3; y++)
|
||||
{
|
||||
if(!Active && PentagramBounds.Contains(new Point2D(x, y)))
|
||||
{
|
||||
Activate(m);
|
||||
Active = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckReset()
|
||||
{
|
||||
if (GetPlayerCount() == 0 || Guardians == null || Guardians.Count == 0 || !Guardians.Any(x => !x.Deleted))
|
||||
{
|
||||
Reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnDeath( Mobile m )
|
||||
{
|
||||
if(Guardians != null && m is DarkGuardian && Guardians.Contains((DarkGuardian)m))
|
||||
{
|
||||
Guardians.Remove((DarkGuardian)m);
|
||||
}
|
||||
|
||||
if(m is PlayerMobile && Active)
|
||||
{
|
||||
Timer.DelayCall<PlayerMobile>(TimeSpan.FromSeconds(3), MoveDeadPlayer, (PlayerMobile)m);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveDeadPlayer(PlayerMobile pm)
|
||||
{
|
||||
if (pm.Region == this)
|
||||
{
|
||||
BaseCreature.TeleportPets(pm, KickLoc, Map.Malas);
|
||||
pm.MoveToWorld(KickLoc, Map.Malas);
|
||||
|
||||
if (pm.Corpse != null)
|
||||
pm.Corpse.MoveToWorld(KickLoc, Map.Malas);
|
||||
}
|
||||
|
||||
if (!GetEnumeratedMobiles().Any(mob => mob is PlayerMobile && mob.Alive))
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate(Mobile m)
|
||||
{
|
||||
if (Active)
|
||||
return;
|
||||
|
||||
CheckDoors();
|
||||
|
||||
DoorOne.Open = false;
|
||||
DoorTwo.Open = false;
|
||||
DoorOne.Locked = true;
|
||||
DoorTwo.Locked = true;
|
||||
|
||||
Effects.PlaySound(DoorOne.Location, DoorOne.Map, 0x241);
|
||||
Effects.PlaySound(DoorTwo.Location, DoorTwo.Map, 0x241);
|
||||
|
||||
if (Guardians == null)
|
||||
Guardians = new List<DarkGuardian>();
|
||||
|
||||
int count = 0;
|
||||
foreach (var mob in this.GetEnumeratedMobiles().Where(mob => mob is PlayerMobile || (mob is BaseCreature && ((BaseCreature)mob).GetMaster() != null && !mob.IsDeadBondedPet)))
|
||||
{
|
||||
if (mob.NetState != null)
|
||||
mob.SendLocalizedMessage(1050000, "", 365); // The locks on the door click loudly and you begin to hear a faint hissing near the walls.
|
||||
|
||||
if(mob.Alive)
|
||||
count++;
|
||||
}
|
||||
|
||||
count = Math.Max(1, count * 2);
|
||||
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
DarkGuardian guardian = new DarkGuardian();
|
||||
|
||||
int x = Utility.RandomMinMax(PentagramBounds.X, PentagramBounds.X + PentagramBounds.Width);
|
||||
int y = Utility.RandomMinMax(PentagramBounds.Y, PentagramBounds.Y + PentagramBounds.Height);
|
||||
int z = Map.Malas.GetAverageZ(x, y);
|
||||
|
||||
guardian.MoveToWorld(new Point3D(x, y, z), Map.Malas);
|
||||
Guardians.Add(guardian);
|
||||
|
||||
guardian.Combatant = m;
|
||||
}
|
||||
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
|
||||
m_Timer = new InternalTimer(this);
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (!Active)
|
||||
return;
|
||||
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
|
||||
DoorOne.Locked = false;
|
||||
DoorTwo.Locked = false;
|
||||
|
||||
Active = false;
|
||||
NextActivate = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(15, 60));
|
||||
}
|
||||
|
||||
public void CheckDoors()
|
||||
{
|
||||
if(DoorOne == null || DoorOne.Deleted)
|
||||
{
|
||||
if(!CheckDoor(DoorOneLoc, 1))
|
||||
{
|
||||
DoorOne = new MetalDoor2(DoorFacing.NorthCW);
|
||||
DoorOne.MoveToWorld(DoorOneLoc, Map.Malas);
|
||||
DoorOne.KeyValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(DoorTwo == null || DoorTwo.Deleted)
|
||||
{
|
||||
if(!CheckDoor(DoorTwoLoc, 2))
|
||||
{
|
||||
DoorTwo = new MetalDoor2(DoorFacing.SouthCCW);
|
||||
DoorTwo.MoveToWorld(DoorTwoLoc, Map.Malas);
|
||||
DoorTwo.KeyValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(DoorOne != null && DoorOne.Link != DoorTwo)
|
||||
DoorOne.Link = DoorTwo;
|
||||
|
||||
if(DoorTwo != null && DoorTwo.Link != DoorOne)
|
||||
DoorTwo.Link = DoorOne;
|
||||
|
||||
CheckPentagram();
|
||||
}
|
||||
|
||||
public bool CheckDoor(Point3D p, int door)
|
||||
{
|
||||
IPooledEnumerable eable = Map.Malas.GetItemsInRange(p, 0);
|
||||
|
||||
foreach(Item item in eable)
|
||||
{
|
||||
if(item is BaseDoor)
|
||||
{
|
||||
eable.Free();
|
||||
|
||||
if (door == 1)
|
||||
DoorOne = item as BaseDoor;
|
||||
else
|
||||
DoorTwo = item as BaseDoor;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckPentagram()
|
||||
{
|
||||
IPooledEnumerable eable = Map.Malas.GetItemsInRange(PentagramLoc, 0);
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (item is PentagramAddon)
|
||||
{
|
||||
eable.Free();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
var addon = new PentagramAddon();
|
||||
addon.MoveToWorld(PentagramLoc, Map.Malas);
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
public DoomGuardianRegion Region { get; private set; }
|
||||
public DateTime NextGas { get; private set; }
|
||||
|
||||
public InternalTimer(DoomGuardianRegion reg)
|
||||
: base(TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500))
|
||||
{
|
||||
Region = reg;
|
||||
NextGas = DateTime.UtcNow + TimeSpan.FromSeconds(3);
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Region.CheckReset())
|
||||
{
|
||||
Region.Reset();
|
||||
}
|
||||
else if (NextGas < DateTime.UtcNow)
|
||||
{
|
||||
for (int i = 0; i < Utility.RandomMinMax(5, 12); i++)
|
||||
{
|
||||
Point3D p = Region.RandomSpawnLocation(0, true, false, Point3D.Zero, 0);
|
||||
Effects.SendLocationEffect(p, Map.Malas, Utility.RandomList(0x113C, 0x1147, 0x11A8) - 2, 16, 3, 0, 0);
|
||||
}
|
||||
|
||||
foreach (var m in Region.GetEnumeratedMobiles().Where(m => m is PlayerMobile && m.Alive && m.AccessLevel == AccessLevel.Player && m.Poison == null))
|
||||
{
|
||||
m.ApplyPoison(m, Poison.Deadly);
|
||||
m.SendSound(0x231);
|
||||
}
|
||||
|
||||
NextGas = DateTime.UtcNow + TimeSpan.FromSeconds(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
761
Scripts/Services/Doom/LeverPuzzleController.cs
Normal file
761
Scripts/Services/Doom/LeverPuzzleController.cs
Normal file
@@ -0,0 +1,761 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
|
||||
/*
|
||||
this is From me to you, Under no terms, Conditions... K? to apply you
|
||||
just simply Unpatch/delete, Stick these in, Same location.. Restart
|
||||
*/
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
public class LeverPuzzleController : Item
|
||||
{
|
||||
public static string[] Msgs =
|
||||
{
|
||||
"You are pinned down by the weight of the boulder!!!", // 0
|
||||
"A speeding rock hits you in the head!", // 1
|
||||
"OUCH!" // 2
|
||||
};
|
||||
/* font&hue for above msgs. index matches */
|
||||
public static int[][] MsgParams =
|
||||
{
|
||||
new int[] { 0x66d, 3 },
|
||||
new int[] { 0x66d, 3 },
|
||||
new int[] { 0x34, 3 }
|
||||
};
|
||||
/* World data for items */
|
||||
public static int[][] TA =
|
||||
{
|
||||
new int[] { 316, 64, 5 },
|
||||
/* 3D Coords for levers */ new int[] { 323, 58, 5 },
|
||||
new int[] { 332, 63, 5 },
|
||||
new int[] { 323, 71, 5 },
|
||||
new int[] { 324, 64 },
|
||||
/* 2D Coords for standing regions */ new int[] { 316, 65 },
|
||||
new int[] { 324, 58 },
|
||||
new int[] { 332, 64 },
|
||||
new int[] { 323, 72 },
|
||||
new int[] { 468, 92, -1 }, new int[] { 0x181D, 0x482 },
|
||||
/* 3D coord, itemid+hue for L.R. teles */ new int[] { 469, 92, -1 }, new int[] { 0x1821, 0x3fd },
|
||||
new int[] { 470, 92, -1 }, new int[] { 0x1825, 0x66d },
|
||||
new int[] { 319, 70, 18 }, new int[] { 0x12d8 },
|
||||
/* 3D coord, itemid for statues */ new int[] { 329, 60, 18 }, new int[] { 0x12d9 },
|
||||
new int[] { 469, 96, 6 }
|
||||
/* 3D Coords for Fake Box */ };
|
||||
/* CLILOC data for statue "correct souls" messages */
|
||||
public static int[] Statue_Msg = { 1050009, 1050007, 1050008, 1050008 };
|
||||
/* Exit & Enter locations for the lamp room */
|
||||
public static Point3D lr_Exit = new Point3D(353, 172, -1);
|
||||
public static Point3D lr_Enter = new Point3D(467, 96, -1);
|
||||
/* "Center" location in puzzle */
|
||||
public static Point3D lp_Center = new Point3D(324, 64, -1);
|
||||
/* Lamp Room Area */
|
||||
public static Rectangle2D lr_Rect = new Rectangle2D(465, 92, 10, 10);
|
||||
/* Lamp Room area Poison message data */
|
||||
public static int[][] PA =
|
||||
{
|
||||
new int[] { 0, 0, 0xA6 },
|
||||
new int[] { 1050001, 0x485, 0xAA },
|
||||
new int[] { 1050003, 0x485, 0xAC },
|
||||
new int[] { 1050056, 0x485, 0xA8 },
|
||||
new int[] { 1050057, 0x485, 0xA4 },
|
||||
new int[] { 1062091, 0x23F3, 0xAC }
|
||||
};
|
||||
public static Poison[] PA2 =
|
||||
{
|
||||
Poison.Lesser,
|
||||
Poison.Regular,
|
||||
Poison.Greater,
|
||||
Poison.Deadly,
|
||||
Poison.Lethal,
|
||||
Poison.Lethal
|
||||
};
|
||||
/* SOUNDS */
|
||||
private static readonly int[] fs = { 0x144, 0x154 };
|
||||
private static readonly int[] ms = { 0x144, 0x14B };
|
||||
private static readonly int[] fs2 = { 0x13F, 0x154 };
|
||||
private static readonly int[] ms2 = { 0x13F, 0x14B };
|
||||
private static readonly int[] cs1 = { 0x244 };
|
||||
private static readonly int[] exp = { 0x307 };
|
||||
private static bool installed;
|
||||
private bool m_Enabled;
|
||||
private UInt16 m_MyKey;
|
||||
private UInt16 m_TheirKey;
|
||||
private List<Item> m_Levers;
|
||||
private List<Item> m_Teles;
|
||||
private List<Item> m_Statues;
|
||||
private List<LeverPuzzleRegion> m_Tiles;
|
||||
private Mobile m_Successful;
|
||||
private LampRoomBox m_Box;
|
||||
private Region m_LampRoom;
|
||||
private Timer m_Timer;
|
||||
private Timer l_Timer;
|
||||
public LeverPuzzleController()
|
||||
: base(0x1822)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Hue = 0x4c;
|
||||
installed = true;
|
||||
int i = 0;
|
||||
|
||||
this.m_Levers = new List<Item>(); /* codes are 0x1 shifted left x # of bits, easily handled here */
|
||||
for (; i < 4; i++)
|
||||
this.m_Levers.Add(AddLeverPuzzlePart(TA[i], new LeverPuzzleLever((ushort)(1 << i), this)));
|
||||
|
||||
this.m_Tiles = new List<LeverPuzzleRegion>();
|
||||
for (; i < 9; i++)
|
||||
this.m_Tiles.Add(new LeverPuzzleRegion(this, TA[i]));
|
||||
|
||||
this.m_Teles = new List<Item>();
|
||||
for (; i < 15; i++)
|
||||
this.m_Teles.Add(AddLeverPuzzlePart(TA[i], new LampRoomTeleporter(TA[++i])));
|
||||
|
||||
this.m_Statues = new List<Item>();
|
||||
for (; i < 19; i++)
|
||||
this.m_Statues.Add(AddLeverPuzzlePart(TA[i], new LeverPuzzleStatue(TA[++i], this)));
|
||||
|
||||
if (!installed)
|
||||
this.Delete();
|
||||
else
|
||||
this.Enabled = true;
|
||||
|
||||
this.m_Box = (LampRoomBox)AddLeverPuzzlePart(TA[i], new LampRoomBox(this));
|
||||
this.m_LampRoom = new LampRoomRegion(this);
|
||||
this.GenKey();
|
||||
}
|
||||
|
||||
public LeverPuzzleController(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public UInt16 MyKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_MyKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_MyKey = value;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public UInt16 TheirKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TheirKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_TheirKey = value;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Enabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Enabled = value;
|
||||
}
|
||||
}
|
||||
public Mobile Successful
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Successful;
|
||||
}
|
||||
}
|
||||
public bool CircleComplete
|
||||
{
|
||||
get /* OSI: all 5 must be occupied */
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (this.GetOccupant(i) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("GenLeverPuzzle", AccessLevel.Administrator, new CommandEventHandler(GenLampPuzzle_OnCommand));
|
||||
CommandSystem.Register("LampPuzzleDelete", AccessLevel.Administrator, new CommandEventHandler(LampPuzzleDelete_OnCommand));
|
||||
}
|
||||
|
||||
[Usage("LampPuzzleDelete")]
|
||||
[Description("Deletes lamp room and lever puzzle in doom.")]
|
||||
public static void LampPuzzleDelete_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
WeakEntityCollection.Delete("LeverPuzzleController");
|
||||
e.Mobile.SendMessage("Lamp room puzzle successfully deleted.");
|
||||
}
|
||||
|
||||
|
||||
[Usage("GenLeverPuzzle")]
|
||||
[Description("Generates lamp room and lever puzzle in doom.")]
|
||||
public static void GenLampPuzzle_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
foreach (Item item in Map.Malas.GetItemsInRange(lp_Center, 0))
|
||||
{
|
||||
if (item is LeverPuzzleController)
|
||||
{
|
||||
e.Mobile.SendMessage("Lamp room puzzle already exists: please delete the existing controller first ...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.Mobile.SendMessage("Generating Lamp Room puzzle...");
|
||||
LeverPuzzleController controller = new LeverPuzzleController();
|
||||
WeakEntityCollection.Add("LeverPuzzleController", controller);
|
||||
controller.MoveToWorld(lp_Center, Map.Malas);
|
||||
|
||||
if (!installed)
|
||||
e.Mobile.SendMessage("There was a problem generating the puzzle.");
|
||||
else
|
||||
e.Mobile.SendMessage("Lamp room puzzle successfully generated.");
|
||||
}
|
||||
|
||||
public static Item AddLeverPuzzlePart(int[] Loc, Item newitem)
|
||||
{
|
||||
if (newitem == null || newitem.Deleted)
|
||||
{
|
||||
installed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
newitem.MoveToWorld(new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas);
|
||||
}
|
||||
return newitem;
|
||||
}
|
||||
|
||||
public static void NukeItemList(List<Item> list)
|
||||
{
|
||||
if (list != null && list.Count != 0)
|
||||
{
|
||||
foreach (Item item in list)
|
||||
{
|
||||
if (item != null && !item.Deleted)
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void MoveMobileOut(Mobile m)
|
||||
{
|
||||
if (m != null)
|
||||
{
|
||||
if (m is PlayerMobile && !m.Alive)
|
||||
{
|
||||
if (m.Corpse != null && !m.Corpse.Deleted)
|
||||
{
|
||||
m.Corpse.MoveToWorld(lr_Exit, Map.Malas);
|
||||
}
|
||||
}
|
||||
BaseCreature.TeleportPets(m, lr_Exit, Map.Malas);
|
||||
m.Location = lr_Exit;
|
||||
m.ProcessDelta();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AniSafe(Mobile m)
|
||||
{
|
||||
return (m != null && !TransformationSpellHelper.UnderTransformation(m) && m.BodyMod == 0 && m.Alive);
|
||||
}
|
||||
|
||||
public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta)
|
||||
{
|
||||
return new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + ZDelta), m.Map);
|
||||
}
|
||||
|
||||
public static void DoDamage(Mobile m, int min, int max, bool poison)
|
||||
{
|
||||
if (m != null && !m.Deleted && m.Alive)
|
||||
{
|
||||
int damage = Utility.Random(min, max);
|
||||
AOS.Damage(m, damage, (poison) ? 0 : 100, 0, 0, (poison) ? 100 : 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Point3D RandomPointIn(Point3D point, int range)
|
||||
{
|
||||
return RandomPointIn(point.X - range, point.Y - range, range * 2, range * 2, point.Z);
|
||||
}
|
||||
|
||||
public static Point3D RandomPointIn(Rectangle2D rect, int z)
|
||||
{
|
||||
return RandomPointIn(rect.X, rect.Y, rect.Height, rect.Width, z);
|
||||
}
|
||||
|
||||
public static Point3D RandomPointIn(int x, int y, int x2, int y2, int z)
|
||||
{
|
||||
return new Point3D(Utility.Random(x, x2), Utility.Random(y, y2), z);
|
||||
}
|
||||
|
||||
public static void PlaySounds(Point3D location, int[] sounds)
|
||||
{
|
||||
foreach (int soundid in sounds)
|
||||
Effects.PlaySound(location, Map.Malas, soundid);
|
||||
}
|
||||
|
||||
public static void PlayEffect(IEntity from, IEntity to, int itemid, int speed, bool explodes)
|
||||
{
|
||||
Effects.SendMovingParticles(from, to, itemid, speed, 0, true, explodes, 2, 0, 0);
|
||||
}
|
||||
|
||||
public static void SendLocationEffect(IPoint3D p, int itemID, int speed, int duration, int hue)
|
||||
{
|
||||
Effects.SendPacket(p, Map.Malas, new LocationEffect(p, itemID, speed, duration, hue, 0));
|
||||
}
|
||||
|
||||
public static void PlayerSendASCII(Mobile player, int index)
|
||||
{
|
||||
player.Send(new AsciiMessage(Serial.MinusOne, 0xFFFF, MessageType.Label, MsgParams[index][0], MsgParams[index][1], null, Msgs[index]));
|
||||
}
|
||||
|
||||
/* I cant find any better way to send "speech" using fonts other than default */
|
||||
public static void POHMessage(Mobile from, int index)
|
||||
{
|
||||
Packet p = new AsciiMessage(from.Serial, from.Body, MessageType.Regular, MsgParams[index][0], MsgParams[index][1], from.Name, Msgs[index]);
|
||||
p.Acquire();
|
||||
foreach (NetState state in from.Map.GetClientsInRange(from.Location))
|
||||
state.Send(p);
|
||||
|
||||
Packet.Release(p);
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
this.KillTimers();
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
NukeItemList(this.m_Teles);
|
||||
NukeItemList(this.m_Statues);
|
||||
NukeItemList(this.m_Levers);
|
||||
|
||||
if (this.m_LampRoom != null)
|
||||
{
|
||||
this.m_LampRoom.Unregister();
|
||||
}
|
||||
if (this.m_Tiles != null)
|
||||
{
|
||||
foreach (Region region in this.m_Tiles)
|
||||
{
|
||||
region.Unregister();
|
||||
}
|
||||
}
|
||||
if (this.m_Box != null && !this.m_Box.Deleted)
|
||||
{
|
||||
this.m_Box.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual PlayerMobile GetOccupant(int index)
|
||||
{
|
||||
LeverPuzzleRegion region = (LeverPuzzleRegion)this.m_Tiles[index];
|
||||
|
||||
if (region != null)
|
||||
{
|
||||
if (region.Occupant != null && region.Occupant.Alive)
|
||||
{
|
||||
return (PlayerMobile)region.Occupant;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual LeverPuzzleStatue GetStatue(int index)
|
||||
{
|
||||
LeverPuzzleStatue statue = (LeverPuzzleStatue)this.m_Statues[index];
|
||||
|
||||
if (statue != null && !statue.Deleted)
|
||||
{
|
||||
return statue;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual LeverPuzzleLever GetLever(int index)
|
||||
{
|
||||
LeverPuzzleLever lever = (LeverPuzzleLever)this.m_Levers[index];
|
||||
|
||||
if (lever != null && !lever.Deleted)
|
||||
{
|
||||
return lever;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void PuzzleStatus(int message, string fstring)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Item s;
|
||||
if ((s = this.GetStatue(i)) != null)
|
||||
{
|
||||
s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetPuzzle()
|
||||
{
|
||||
this.PuzzleStatus(1062053, null);
|
||||
this.ResetLevers();
|
||||
}
|
||||
|
||||
public virtual void ResetLevers()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Item l;
|
||||
if ((l = this.GetLever(i)) != null)
|
||||
{
|
||||
l.ItemID = 0x108E;
|
||||
Effects.PlaySound(l.Location, this.Map, 0x3E8);
|
||||
}
|
||||
}
|
||||
this.TheirKey ^= this.TheirKey;
|
||||
}
|
||||
|
||||
public virtual void KillTimers()
|
||||
{
|
||||
if (this.l_Timer != null && this.l_Timer.Running)
|
||||
{
|
||||
this.l_Timer.Stop();
|
||||
}
|
||||
if (this.m_Timer != null && this.m_Timer.Running)
|
||||
{
|
||||
this.m_Timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveSuccessful()
|
||||
{
|
||||
this.m_Successful = null;
|
||||
}
|
||||
|
||||
public virtual void LeverPulled(UInt16 code)
|
||||
{
|
||||
int Correct = 0;
|
||||
Mobile m_Player;
|
||||
|
||||
this.KillTimers();
|
||||
|
||||
/* if one bit in each of the four nibbles is set, this is false */
|
||||
|
||||
if ((this.TheirKey = (ushort)(code | (this.TheirKey <<= 4))) < 0x0FFF)
|
||||
{
|
||||
this.l_Timer = Timer.DelayCall(TimeSpan.FromSeconds(30.0), new TimerCallback(ResetPuzzle));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.CircleComplete)
|
||||
{
|
||||
this.PuzzleStatus(1050004, null); // The circle is the key...
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.TheirKey == this.MyKey)
|
||||
{
|
||||
this.GenKey();
|
||||
if ((this.m_Successful = (m_Player = this.GetOccupant(0))) != null)
|
||||
{
|
||||
SendLocationEffect(lp_Center, 0x1153, 0, 60, 1);
|
||||
PlaySounds(lp_Center, cs1);
|
||||
|
||||
Effects.SendBoltEffect(m_Player, true);
|
||||
m_Player.MoveToWorld(lr_Enter, Map.Malas);
|
||||
|
||||
this.m_Timer = new LampRoomTimer(this);
|
||||
this.m_Timer.Start();
|
||||
this.m_Enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */
|
||||
{
|
||||
if ((((this.MyKey >> i) & 1) == 1) && (((this.TheirKey >> i) & 1) == 1))
|
||||
{
|
||||
Correct++;
|
||||
}
|
||||
}
|
||||
|
||||
this.PuzzleStatus(Statue_Msg[Correct], (Correct > 0) ? Correct.ToString() : null);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if ((m_Player = this.GetOccupant(i)) != null)
|
||||
{
|
||||
Timer smash = new RockTimer(m_Player, this);
|
||||
smash.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ResetLevers();
|
||||
}
|
||||
|
||||
public virtual void GenKey() /* Shuffle & build key */
|
||||
{
|
||||
UInt16 tmp;
|
||||
int n, i;
|
||||
ushort[] CA = { 1, 2, 4, 8 };
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
n = (((n = Utility.Random(0, 3)) == i) ? n & ~i : n); /* if(i==n) { return pointless; } */
|
||||
tmp = CA[i];
|
||||
CA[i] = CA[n];
|
||||
CA[n] = tmp;
|
||||
}
|
||||
for (i = 0; i < 4; this.MyKey = (ushort)(CA[(i++)] | (this.MyKey <<= 4)))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.WriteItemList(this.m_Levers, true);
|
||||
writer.WriteItemList(this.m_Statues, true);
|
||||
writer.WriteItemList(this.m_Teles, true);
|
||||
writer.Write(this.m_Box);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
this.m_Levers = reader.ReadStrongItemList();
|
||||
this.m_Statues = reader.ReadStrongItemList();
|
||||
this.m_Teles = reader.ReadStrongItemList();
|
||||
|
||||
this.m_Box = reader.ReadItem() as LampRoomBox;
|
||||
|
||||
this.m_Tiles = new List<LeverPuzzleRegion>();
|
||||
for (int i = 4; i < 9; i++)
|
||||
this.m_Tiles.Add(new LeverPuzzleRegion(this, TA[i]));
|
||||
|
||||
this.m_LampRoom = new LampRoomRegion(this);
|
||||
this.m_Enabled = true;
|
||||
this.m_TheirKey = 0;
|
||||
this.m_MyKey = 0;
|
||||
this.GenKey();
|
||||
}
|
||||
|
||||
private static bool IsValidDamagable(Mobile m)
|
||||
{
|
||||
if (m != null && !m.Deleted)
|
||||
{
|
||||
if (m.Player && m.Alive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m is BaseCreature)
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
if ((bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public class RockTimer : Timer
|
||||
{
|
||||
private readonly Mobile m_Player;
|
||||
private readonly LeverPuzzleController m_Controller;
|
||||
private int Count;
|
||||
public RockTimer(Mobile player, LeverPuzzleController Controller)
|
||||
: base(TimeSpan.Zero, TimeSpan.FromSeconds(.25))
|
||||
{
|
||||
this.Count = 0;
|
||||
this.m_Player = player;
|
||||
this.m_Controller = Controller;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (this.m_Player == null || !(this.m_Player.Map == Map.Malas))
|
||||
{
|
||||
this.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Count++;
|
||||
if (this.Count == 1) /* TODO consolidate */
|
||||
{
|
||||
this.m_Player.Paralyze(TimeSpan.FromSeconds(2));
|
||||
Effects.SendTargetEffect(this.m_Player, 0x11B7, 20, 10);
|
||||
PlayerSendASCII(this.m_Player, 0); // You are pinned down ...
|
||||
|
||||
PlaySounds(this.m_Player.Location, (!this.m_Player.Female) ? fs : ms);
|
||||
PlayEffect(ZAdjustedIEFromMobile(this.m_Player, 50), this.m_Player, 0x11B7, 20, false);
|
||||
}
|
||||
else if (this.Count == 2)
|
||||
{
|
||||
DoDamage(this.m_Player, 80, 90, false);
|
||||
Effects.SendTargetEffect(this.m_Player, 0x36BD, 20, 10);
|
||||
PlaySounds(this.m_Player.Location, exp);
|
||||
PlayerSendASCII(this.m_Player, 1); // A speeding rock ...
|
||||
|
||||
if (AniSafe(this.m_Player))
|
||||
{
|
||||
this.m_Player.Animate(21, 10, 1, true, true, 0);
|
||||
}
|
||||
}
|
||||
else if (this.Count == 3)
|
||||
{
|
||||
this.Stop();
|
||||
|
||||
Effects.SendTargetEffect(this.m_Player, 0x36B0, 20, 10);
|
||||
PlayerSendASCII(this.m_Player, 1); // A speeding rock ...
|
||||
PlaySounds(this.m_Player.Location, (!this.m_Player.Female) ? fs2 : ms2);
|
||||
|
||||
int j = Utility.Random(6, 10);
|
||||
for (int i = 0; i < j; i++)
|
||||
{
|
||||
IEntity m_IEntity = new Entity(Serial.Zero, RandomPointIn(this.m_Player.Location, 10), this.m_Player.Map);
|
||||
|
||||
List<Mobile> mobiles = new List<Mobile>();
|
||||
IPooledEnumerable eable = m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
mobiles.Add(m);
|
||||
}
|
||||
eable.Free();
|
||||
for (int k = 0; k < mobiles.Count; k++)
|
||||
{
|
||||
if (IsValidDamagable(mobiles[k]) && mobiles[k] != this.m_Player)
|
||||
{
|
||||
PlayEffect(this.m_Player, mobiles[k], this.Rock(), 8, true);
|
||||
DoDamage(mobiles[k], 25, 30, false);
|
||||
|
||||
if (mobiles[k].Player)
|
||||
{
|
||||
POHMessage(mobiles[k], 2); // OUCH!
|
||||
}
|
||||
}
|
||||
}
|
||||
PlayEffect(this.m_Player, m_IEntity, this.Rock(), 8, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int Rock()
|
||||
{
|
||||
return 0x1363 + Utility.Random(0, 11);
|
||||
}
|
||||
}
|
||||
|
||||
public class LampRoomKickTimer : Timer
|
||||
{
|
||||
private readonly Mobile m;
|
||||
public LampRoomKickTimer(Mobile player)
|
||||
: base(TimeSpan.FromSeconds(.25))
|
||||
{
|
||||
this.m = player;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
MoveMobileOut(this.m);
|
||||
}
|
||||
}
|
||||
|
||||
public class LampRoomTimer : Timer
|
||||
{
|
||||
public LeverPuzzleController m_Controller;
|
||||
public int ticks;
|
||||
public int level;
|
||||
public LampRoomTimer(LeverPuzzleController controller)
|
||||
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
|
||||
{
|
||||
this.level = 0;
|
||||
this.ticks = 0;
|
||||
this.m_Controller = controller;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
this.ticks++;
|
||||
List<Mobile> mobiles = this.m_Controller.m_LampRoom.GetMobiles();
|
||||
|
||||
if (this.ticks >= 71 || this.m_Controller.m_LampRoom.GetPlayerCount() == 0)
|
||||
{
|
||||
foreach (Mobile mobile in mobiles)
|
||||
{
|
||||
if (mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet)
|
||||
{
|
||||
mobile.Kill();
|
||||
}
|
||||
}
|
||||
this.m_Controller.Enabled = true;
|
||||
this.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.ticks % 12 == 0)
|
||||
{
|
||||
this.level++;
|
||||
}
|
||||
foreach (Mobile mobile in mobiles)
|
||||
{
|
||||
if (IsValidDamagable(mobile))
|
||||
{
|
||||
if (this.ticks % 2 == 0 && this.level == 5)
|
||||
{
|
||||
if (mobile.Player)
|
||||
{
|
||||
mobile.Say(1062092);
|
||||
if (AniSafe(mobile))
|
||||
{
|
||||
mobile.Animate(32, 5, 1, true, false, 0);
|
||||
}
|
||||
}
|
||||
DoDamage(mobile, 15, 20, true);
|
||||
}
|
||||
if (Utility.Random((int)(this.level & ~0xfffffffc), 3) == 3)
|
||||
{
|
||||
mobile.ApplyPoison(mobile, PA2[this.level]);
|
||||
}
|
||||
if (this.ticks % 12 == 0 && this.level > 0 && mobile.Player)
|
||||
{
|
||||
mobile.SendLocalizedMessage(PA[this.level][0], null, PA[this.level][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i <= this.level; i++)
|
||||
{
|
||||
SendLocationEffect(RandomPointIn(lr_Rect, -1), 0x36B0, Utility.Random(150, 200), 0, PA[this.level][2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
219
Scripts/Services/Doom/LeverPuzzleItems.cs
Normal file
219
Scripts/Services/Doom/LeverPuzzleItems.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
public class LampRoomBox : Item
|
||||
{
|
||||
private LeverPuzzleController m_Controller;
|
||||
private Mobile m_Wanderer;
|
||||
public LampRoomBox(LeverPuzzleController controller)
|
||||
: base(0xe80)
|
||||
{
|
||||
this.m_Controller = controller;
|
||||
this.ItemID = 0xe80;
|
||||
this.Movable = false;
|
||||
}
|
||||
|
||||
public LampRoomBox(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (!m.InRange(this.GetWorldLocation(), 3))
|
||||
return;
|
||||
if (this.m_Controller.Enabled)
|
||||
return;
|
||||
|
||||
if ((this.m_Wanderer == null || !this.m_Wanderer.Alive))
|
||||
{
|
||||
this.m_Wanderer = new WandererOfTheVoid();
|
||||
this.m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
|
||||
this.m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002, ""); // I am the guardian of...
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(CallBackMessage));
|
||||
}
|
||||
}
|
||||
|
||||
public void CallBackMessage()
|
||||
{
|
||||
this.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060003, ""); // You try to pry the box open...
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (this.m_Controller != null && !this.m_Controller.Deleted)
|
||||
this.m_Controller.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write(this.m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
this.m_Controller = reader.ReadItem() as LeverPuzzleController;
|
||||
}
|
||||
}
|
||||
|
||||
public class LeverPuzzleStatue : Item
|
||||
{
|
||||
private LeverPuzzleController m_Controller;
|
||||
public LeverPuzzleStatue(int[] dat, LeverPuzzleController controller)
|
||||
: base(dat[0])
|
||||
{
|
||||
this.m_Controller = controller;
|
||||
this.Hue = 0x44E;
|
||||
this.Movable = false;
|
||||
}
|
||||
|
||||
public LeverPuzzleStatue(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (this.m_Controller != null && !this.m_Controller.Deleted)
|
||||
this.m_Controller.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write(this.m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
this.m_Controller = reader.ReadItem() as LeverPuzzleController;
|
||||
}
|
||||
}
|
||||
|
||||
public class LeverPuzzleLever : Item
|
||||
{
|
||||
private UInt16 m_Code;
|
||||
private LeverPuzzleController m_Controller;
|
||||
public LeverPuzzleLever(UInt16 code, LeverPuzzleController controller)
|
||||
: base(0x108E)
|
||||
{
|
||||
this.m_Controller = controller;
|
||||
this.m_Code = code;
|
||||
this.Hue = 0x66D;
|
||||
this.Movable = false;
|
||||
}
|
||||
|
||||
public LeverPuzzleLever(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public UInt16 Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Code;
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (m != null && this.m_Controller.Enabled)
|
||||
{
|
||||
this.ItemID ^= 2;
|
||||
Effects.PlaySound(this.Location, this.Map, 0x3E8);
|
||||
this.m_Controller.LeverPulled(this.m_Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendLocalizedMessage(1060001); // You throw the switch, but the mechanism cannot be engaged again so soon.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (this.m_Controller != null && !this.m_Controller.Deleted)
|
||||
this.m_Controller.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write((ushort)this.m_Code);
|
||||
writer.Write(this.m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
this.m_Code = reader.ReadUShort();
|
||||
this.m_Controller = reader.ReadItem() as LeverPuzzleController;
|
||||
}
|
||||
}
|
||||
|
||||
[TypeAlias("Server.Engines.Doom.LampRoomTelePorter")]
|
||||
public class LampRoomTeleporter : Item
|
||||
{
|
||||
public LampRoomTeleporter(int[] dat)
|
||||
{
|
||||
this.Hue = dat[1];
|
||||
this.ItemID = dat[0];
|
||||
this.Movable = false;
|
||||
}
|
||||
|
||||
public LampRoomTeleporter(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (m != null && m is PlayerMobile)
|
||||
{
|
||||
if (SpellHelper.CheckCombat(m))
|
||||
{
|
||||
m.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
|
||||
}
|
||||
else
|
||||
{
|
||||
Server.Mobiles.BaseCreature.TeleportPets(m, LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
m.MoveToWorld(LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Scripts/Services/Doom/LeverPuzzleRegions.cs
Normal file
121
Scripts/Services/Doom/LeverPuzzleRegions.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
{
|
||||
public class LampRoomRegion : BaseRegion
|
||||
{
|
||||
private readonly LeverPuzzleController Controller;
|
||||
public LampRoomRegion(LeverPuzzleController controller)
|
||||
: base(null, Map.Malas, Region.Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect)
|
||||
{
|
||||
this.Controller = controller;
|
||||
this.Register();
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Login += new LoginEventHandler(OnLogin);
|
||||
}
|
||||
|
||||
public static void OnLogin(LoginEventArgs e)
|
||||
{
|
||||
Mobile m = e.Mobile;
|
||||
Rectangle2D rect = LeverPuzzleController.lr_Rect;
|
||||
if (m.X >= rect.X && m.X <= (rect.X + 10) && m.Y >= rect.Y && m.Y <= (rect.Y + 10) && m.Map == Map.Internal)
|
||||
{
|
||||
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
|
||||
kick.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
if (m == null || m is WandererOfTheVoid)
|
||||
return;
|
||||
|
||||
if (m.IsStaff())
|
||||
return;
|
||||
|
||||
if (this.Controller.Successful != null)
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
if (m == this.Controller.Successful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m is BaseCreature)
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
if ((bc.Controlled && bc.ControlMaster == this.Controller.Successful) || bc.Summoned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
|
||||
kick.Start();
|
||||
}
|
||||
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
if (m != null && m == this.Controller.Successful)
|
||||
this.Controller.RemoveSuccessful();
|
||||
}
|
||||
|
||||
public override void OnDeath(Mobile m)
|
||||
{
|
||||
if (m != null && !m.Deleted && !(m is WandererOfTheVoid))
|
||||
{
|
||||
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
|
||||
kick.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnSkillUse(Mobile m, int Skill) /* just in case */
|
||||
{
|
||||
if ((this.Controller.Successful == null) || (m.IsStaff() && m != this.Controller.Successful))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class LeverPuzzleRegion : BaseRegion
|
||||
{
|
||||
public Mobile m_Occupant;
|
||||
private readonly LeverPuzzleController Controller;
|
||||
public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc)
|
||||
: base(null, Map.Malas, Region.Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0],loc[1],1,1))
|
||||
{
|
||||
this.Controller = controller;
|
||||
this.Register();
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Occupant
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_Occupant != null && this.m_Occupant.Alive)
|
||||
return this.m_Occupant;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
if (m != null && this.m_Occupant == null && m is PlayerMobile && m.Alive)
|
||||
this.m_Occupant = m;
|
||||
}
|
||||
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
if (m != null && m == this.m_Occupant)
|
||||
this.m_Occupant = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user