Initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
namespace Server.Customs.Invasion_System
|
||||
{
|
||||
public enum TownMonsterType
|
||||
{
|
||||
Abyss,
|
||||
Arachnid,
|
||||
DragonKind,
|
||||
Elementals,
|
||||
Humanoid,
|
||||
OrcsandRatmen,
|
||||
OreElementals,
|
||||
Ophidian,
|
||||
Snakes,
|
||||
Undead
|
||||
}
|
||||
|
||||
public enum TownChampionType
|
||||
{
|
||||
Barracoon,
|
||||
Harrower,
|
||||
LordOaks,
|
||||
Mephitis,
|
||||
Neira,
|
||||
Rikktor,
|
||||
Semidar,
|
||||
Serado
|
||||
}
|
||||
|
||||
public enum InvasionTowns
|
||||
{
|
||||
BuccaneersDen,
|
||||
Cove,
|
||||
Delucia,
|
||||
Jhelom,
|
||||
Minoc,
|
||||
Moonglow,
|
||||
Nujel,
|
||||
Ocllo,
|
||||
Papua,
|
||||
SkaraBrae,
|
||||
Vesper,
|
||||
Yew
|
||||
}
|
||||
}
|
||||
+471
@@ -0,0 +1,471 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
using Server.Spells.Ninjitsu;
|
||||
|
||||
namespace Server.Customs.Invasion_System
|
||||
{
|
||||
public class TownInvasion
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(30.0), GlobalSync);
|
||||
}
|
||||
|
||||
#region Private Variables
|
||||
|
||||
private int _MinSpawnZ;
|
||||
private int _MaxSpawnZ;
|
||||
|
||||
private bool _FinalStage;
|
||||
|
||||
private Point3D _Top = new Point3D(4394, 1058, 30);
|
||||
private Point3D _Bottom = new Point3D(4481, 1173, 0);
|
||||
private Map _SpawnMap = Map.Felucca;
|
||||
|
||||
private List<Mobile> _Spawned;
|
||||
|
||||
private TownMonsterType _TownMonsterType = TownMonsterType.OrcsandRatmen;
|
||||
private TownChampionType _TownChampionType = TownChampionType.Barracoon;
|
||||
private InvasionTowns _InvasionTown = InvasionTowns.BuccaneersDen;
|
||||
private DateTime _StartTime;
|
||||
private bool _AlwaysMurderer = false;
|
||||
|
||||
private string _TownInvaded = "Moonglow";
|
||||
|
||||
private Timer _SpawnTimer;
|
||||
|
||||
private DateTime _lastAnnounce = DateTime.UtcNow;
|
||||
|
||||
private bool WasDisabledRegion;
|
||||
private bool Active;
|
||||
#endregion
|
||||
|
||||
#region Public Variables
|
||||
|
||||
public int MinSpawnZ { get { return _MinSpawnZ; } set { _MinSpawnZ = value; } }
|
||||
public int MaxSpawnZ { get { return _MaxSpawnZ; } set { _MaxSpawnZ = value; } }
|
||||
public Point3D Top { get { return _Top; } set { _Top = value; } }
|
||||
public Point3D Bottom { get { return _Bottom; } set { _Bottom = value; } }
|
||||
public Map SpawnMap { get { return _SpawnMap; } set { _SpawnMap = value; } }
|
||||
public List<Mobile> Spawned { get { return _Spawned; } set { _Spawned = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TownMonsterType TownMonsterType { get { return _TownMonsterType; } set { _TownMonsterType = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TownChampionType TownChampionType { get { return _TownChampionType; } set { _TownChampionType = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public InvasionTowns InvasionTown { get { return _InvasionTown; } set { _InvasionTown = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime StartTime { get { return _StartTime; } set { _StartTime = value; } }
|
||||
|
||||
public bool IsRunning { get { return _SpawnTimer != null && _SpawnTimer.Running; }}
|
||||
public string TownInvaded { get { return _TownInvaded; } set { _TownInvaded = value; } }
|
||||
|
||||
public Timer SpawnTimer { get { return _SpawnTimer; } set { _SpawnTimer = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public TownInvasion(InvasionTowns town, TownMonsterType monster, TownChampionType champion, DateTime time)
|
||||
{
|
||||
_Spawned = new List<Mobile>();
|
||||
|
||||
_InvasionTown = town;
|
||||
_TownMonsterType = monster;
|
||||
_TownChampionType = champion;
|
||||
_StartTime = time;
|
||||
|
||||
InvasionControl.Invasions.Add(this);
|
||||
}
|
||||
|
||||
public TownInvasion(GenericReader reader)
|
||||
{
|
||||
Deserialize(reader);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void OnStart()
|
||||
{
|
||||
if (!IsRunning)
|
||||
{
|
||||
InvasionTowns invading = InvasionTown;
|
||||
|
||||
switch (invading)
|
||||
{
|
||||
case InvasionTowns.BuccaneersDen:
|
||||
{
|
||||
Top = new Point3D(2608, 2060, 0);
|
||||
Bottom = new Point3D(2824, 2296, 0);
|
||||
MinSpawnZ = 50; //Not sure about this one - don't want them in the tunnels
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Buccaneer's Den";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Cove:
|
||||
{
|
||||
Top = new Point3D(2213, 1148, 0);
|
||||
Bottom = new Point3D(2284, 1233, 0);
|
||||
MinSpawnZ = 50; //shouldn't this be 0?
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Cove";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Delucia:
|
||||
{
|
||||
Top = new Point3D(5171, 3980, 41);
|
||||
Bottom = new Point3D(5300, 4040, 39);
|
||||
MinSpawnZ = 29;
|
||||
MaxSpawnZ = 32;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Delucia";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Jhelom:
|
||||
{
|
||||
Top = new Point3D(1304, 3682, 0);
|
||||
Bottom = new Point3D(1465, 3877, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Jhelom";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Minoc:
|
||||
{
|
||||
Top = new Point3D(2443, 420, 15);
|
||||
Bottom = new Point3D(2520, 539, 0);
|
||||
MinSpawnZ = 10;
|
||||
MaxSpawnZ = 16;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Minoc";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Moonglow:
|
||||
{
|
||||
Top = new Point3D(4394, 1058, 30);
|
||||
Bottom = new Point3D(4481, 1173, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Moonglow";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Nujel:
|
||||
{
|
||||
Top = new Point3D(3665, 1189, 0);
|
||||
Bottom = new Point3D(3774, 1357, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Nujel'm";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Ocllo:
|
||||
{
|
||||
Top = new Point3D(3617, 2482, 0);
|
||||
Bottom = new Point3D(3712, 2630, 20);
|
||||
MinSpawnZ = 5;
|
||||
MaxSpawnZ = 21;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Ocllo";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Papua:
|
||||
{
|
||||
Top = new Point3D(5644, 3112, -15);
|
||||
Bottom = new Point3D(5826, 3315, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Papua";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.SkaraBrae:
|
||||
{
|
||||
Top = new Point3D(577, 2131, -90);
|
||||
Bottom = new Point3D(634, 2234, -90);
|
||||
MinSpawnZ = 25;
|
||||
MaxSpawnZ = 65;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Skara Brae";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Yew:
|
||||
{
|
||||
Top = new Point3D(452, 928, 0);
|
||||
Bottom = new Point3D(669, 1104, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Yew";
|
||||
break;
|
||||
}
|
||||
case InvasionTowns.Vesper:
|
||||
{
|
||||
Top = new Point3D(2835, 656, 0);
|
||||
Bottom = new Point3D(2940, 988, 0);
|
||||
MinSpawnZ = 50;
|
||||
MaxSpawnZ = 61;
|
||||
SpawnMap = Map.Felucca;
|
||||
TownInvaded = "Vesper";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Region r in Region.Regions)
|
||||
{
|
||||
if (r is GuardedRegion && r.Name == TownInvaded)
|
||||
{
|
||||
WasDisabledRegion = ((GuardedRegion) r).Disabled;
|
||||
|
||||
((GuardedRegion)r).Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Spawn();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnStop()
|
||||
{
|
||||
Despawn();
|
||||
|
||||
if (!WasDisabledRegion)
|
||||
{
|
||||
foreach (Region r in Region.Regions)
|
||||
{
|
||||
if (r is GuardedRegion && r.Name == TownInvaded)
|
||||
{
|
||||
((GuardedRegion)r).Disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SpawnTimer != null)
|
||||
_SpawnTimer.Stop();
|
||||
|
||||
InvasionControl.Invasions.Remove(this);
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
writer.Write((int)InvasionTown);
|
||||
writer.Write((int)TownMonsterType);
|
||||
writer.Write((int)TownChampionType);
|
||||
writer.Write(StartTime);
|
||||
writer.Write(Spawned);
|
||||
|
||||
if (IsRunning)
|
||||
Active = true;
|
||||
else
|
||||
Active = false;
|
||||
|
||||
writer.Write(Active);
|
||||
}
|
||||
|
||||
public void Deserialize(GenericReader reader)
|
||||
{
|
||||
var version = reader.ReadInt();
|
||||
InvasionTown = (InvasionTowns)reader.ReadInt();
|
||||
TownMonsterType = (TownMonsterType)reader.ReadInt();
|
||||
TownChampionType = (TownChampionType)reader.ReadInt();
|
||||
StartTime = reader.ReadDateTime();
|
||||
Spawned = reader.ReadStrongMobileList();
|
||||
Active = reader.ReadBool();
|
||||
|
||||
if (Spawned == null)
|
||||
Spawned = new List<Mobile>();
|
||||
|
||||
if (Active)
|
||||
InitTimer();
|
||||
}
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static void GlobalSync()
|
||||
{
|
||||
var index = InvasionControl.Invasions.Count;
|
||||
|
||||
while (--index >= 0)
|
||||
{
|
||||
if (index >= InvasionControl.Invasions.Count)
|
||||
continue;
|
||||
|
||||
var obj = InvasionControl.Invasions[index];
|
||||
|
||||
if (obj._StartTime <= DateTime.UtcNow)
|
||||
{
|
||||
obj.OnStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitTimer()
|
||||
{
|
||||
if (!IsRunning)
|
||||
_SpawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(15.0), CheckSpawn);
|
||||
}
|
||||
|
||||
private void Spawn()
|
||||
{
|
||||
Despawn();
|
||||
|
||||
MonsterTownSpawnEntry[] entries = null;
|
||||
|
||||
switch (_TownMonsterType)
|
||||
{
|
||||
default:
|
||||
case TownMonsterType.Abyss: entries = MonsterTownSpawnEntry.Abyss; break;
|
||||
case TownMonsterType.Arachnid: entries = MonsterTownSpawnEntry.Arachnid; break;
|
||||
case TownMonsterType.DragonKind: entries = MonsterTownSpawnEntry.DragonKind; break;
|
||||
case TownMonsterType.Elementals: entries = MonsterTownSpawnEntry.Elementals; break;
|
||||
case TownMonsterType.Humanoid: entries = MonsterTownSpawnEntry.Humanoid; break;
|
||||
case TownMonsterType.Ophidian: entries = MonsterTownSpawnEntry.Ophidian; break;
|
||||
case TownMonsterType.OrcsandRatmen: entries = MonsterTownSpawnEntry.OrcsandRatmen; break;
|
||||
case TownMonsterType.OreElementals: entries = MonsterTownSpawnEntry.OreElementals; break;
|
||||
case TownMonsterType.Snakes: entries = MonsterTownSpawnEntry.Snakes; break;
|
||||
case TownMonsterType.Undead: entries = MonsterTownSpawnEntry.Undead; break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; ++i)
|
||||
for (int count = 0; count < entries[i].Amount; ++count)
|
||||
AddMonster(entries[i].Monster);
|
||||
|
||||
if (_Spawned.Count == 0)
|
||||
{
|
||||
OnStop();
|
||||
return;
|
||||
}
|
||||
|
||||
InitTimer();
|
||||
}
|
||||
|
||||
public void CheckSpawn()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < _Spawned.Count; ++i)
|
||||
if (_Spawned[i] != null && !_Spawned[i].Deleted && _Spawned[i].Alive)
|
||||
++count;
|
||||
|
||||
if (!_FinalStage) //Monsters
|
||||
{
|
||||
if (count == 0) //All monsters have been slayed
|
||||
SpawnChamp();
|
||||
}
|
||||
else //Champion
|
||||
{
|
||||
if (count == 0) //Champion is dead
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(5), OnStop);
|
||||
}
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow >= _lastAnnounce + TimeSpan.FromMinutes(1))
|
||||
{
|
||||
string message = String.Format("{0} is being invaded by {1}. Please come help!", TownInvaded, TownMonsterType);
|
||||
|
||||
foreach (TownCrier tc in TownCrier.Instances)
|
||||
{
|
||||
tc.PublicOverheadMessage(MessageType.Yell, 0, false, message);
|
||||
}
|
||||
|
||||
_lastAnnounce = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
private void Despawn()
|
||||
{
|
||||
foreach (Mobile m in _Spawned)
|
||||
if (m != null && !m.Deleted)
|
||||
m.Delete();
|
||||
|
||||
_Spawned.Clear();
|
||||
|
||||
_FinalStage = false;
|
||||
}
|
||||
|
||||
private Point3D FindSpawnLocation()
|
||||
{
|
||||
int x, y, z;
|
||||
|
||||
var count = 100;
|
||||
|
||||
do
|
||||
{
|
||||
x = Utility.Random(_Top.X, (_Bottom.X - _Top.X));
|
||||
y = Utility.Random(_Top.Y, (_Bottom.Y - _Top.Y));
|
||||
z = SpawnMap.GetAverageZ(x, y);
|
||||
}
|
||||
while (!SpawnMap.CanSpawnMobile(x, y, z) && --count >= 0);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
x = y = z = 0;
|
||||
}
|
||||
|
||||
return new Point3D(x, y, z);
|
||||
}
|
||||
|
||||
private void AddMonster(Type type)
|
||||
{
|
||||
object monster = Activator.CreateInstance(type);
|
||||
|
||||
if (monster != null && monster is Mobile)
|
||||
{
|
||||
Point3D location = FindSpawnLocation();
|
||||
|
||||
if (location == Point3D.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Mobile from = (Mobile)monster;
|
||||
|
||||
from.OnBeforeSpawn(location, SpawnMap);
|
||||
from.MoveToWorld(location, SpawnMap);
|
||||
from.OnAfterSpawn();
|
||||
|
||||
if (from is BaseCreature)
|
||||
{
|
||||
((BaseCreature)from).Tamable = false;
|
||||
}
|
||||
|
||||
_Spawned.Add(from);
|
||||
}
|
||||
}
|
||||
|
||||
public void SpawnChamp()
|
||||
{
|
||||
Despawn();
|
||||
|
||||
_FinalStage = true;
|
||||
|
||||
switch (_TownChampionType)
|
||||
{
|
||||
default:
|
||||
case TownChampionType.Barracoon: AddMonster(typeof(Barracoon)); break;
|
||||
case TownChampionType.Harrower: AddMonster(typeof(Harrower)); break;
|
||||
case TownChampionType.LordOaks: AddMonster(typeof(LordOaks)); break;
|
||||
case TownChampionType.Mephitis: AddMonster(typeof(Mephitis)); break;
|
||||
case TownChampionType.Neira: AddMonster(typeof(Neira)); break;
|
||||
case TownChampionType.Rikktor: AddMonster(typeof(Rikktor)); break;
|
||||
case TownChampionType.Semidar: AddMonster(typeof(Semidar)); break;
|
||||
case TownChampionType.Serado: AddMonster(typeof(Serado)); break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Commands;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Customs.Invasion_System
|
||||
{
|
||||
public static class InvasionControl
|
||||
{
|
||||
public static List<TownInvasion> Invasions = new List<TownInvasion>();
|
||||
|
||||
static Mobile _caller;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("ListInvasions", AccessLevel.Administrator, ListInvasions_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("ListInvasions")]
|
||||
[Description("Lists all active invasions.")]
|
||||
public static void ListInvasions_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
_caller = e.Mobile;
|
||||
|
||||
if (Invasions.Count == 0)
|
||||
{
|
||||
_caller.SendMessage("There are no invasions!");
|
||||
return;
|
||||
}
|
||||
_caller.SendGump(new InvasionGump(Invasions));
|
||||
}
|
||||
}
|
||||
|
||||
public class InvasionGump : Gump
|
||||
{
|
||||
public InvasionGump(List<TownInvasion> invasions) : base(100, 100)
|
||||
{
|
||||
Closable = true;
|
||||
Disposable = true;
|
||||
Dragable = true;
|
||||
Resizable = false;
|
||||
|
||||
AddBackground(100, 100, 620, 500, 5054);
|
||||
AddAlphaRegion(100, 100, 620, 500);
|
||||
|
||||
int y = 110;
|
||||
int x = 110;
|
||||
int id = 0;
|
||||
|
||||
AddHtml(x, y, 120, 20, "<BASEFONT COLOR=#ff33cc><BIG>Town", false, false);
|
||||
AddHtml(x+120, y, 120, 20, "<BASEFONT COLOR=#ff33cc><BIG>Monster Type", false, false);
|
||||
AddHtml(x+240, y, 120, 20, "<BASEFONT COLOR=#ff33cc><BIG>Champion", false, false);
|
||||
AddHtml(x+360, y, 140, 20, "<BASEFONT COLOR=#ff33cc><BIG>Time Scheduled", false, false);
|
||||
AddHtml(x+520, y, 50, 20, "<BASEFONT COLOR=#ff33cc><BIG>Stop", false, false);
|
||||
AddHtml(x+565, y, 50, 20, "<BASEFONT COLOR=#ff33cc><BIG>Props", false, false);
|
||||
|
||||
foreach ( var invasion in invasions)
|
||||
{
|
||||
y += 30;
|
||||
id += 1;
|
||||
AddLabel(x, y, 2100, invasion.InvasionTown.ToString());
|
||||
AddLabel(x+120, y, 2100, invasion.TownMonsterType.ToString());
|
||||
AddLabel(x+240, y, 2100, invasion.TownChampionType.ToString());
|
||||
AddLabel(x+360, y, 2100, invasion.IsRunning ? "Active" : invasion.StartTime.ToString());
|
||||
AddButton(x+525, y, 210, 211, id, GumpButtonType.Reply, 0);
|
||||
AddButton(x+570, y, 210, 211, id+100, GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
|
||||
if (info.ButtonID == 0)
|
||||
return;
|
||||
|
||||
if (info.ButtonID > 100)
|
||||
{
|
||||
int i = info.ButtonID - 101;
|
||||
var prop = InvasionControl.Invasions[i];
|
||||
from.SendGump(new PropertiesGump(from, prop));
|
||||
}
|
||||
else if (info.ButtonID >= 0 && info.ButtonID < 100)
|
||||
{
|
||||
int i = info.ButtonID - 1;
|
||||
TownInvasion invasion = InvasionControl.Invasions[i];
|
||||
|
||||
invasion.OnStop();
|
||||
from.SendMessage("You have deleted the selected invasion!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvasionPersistence
|
||||
{
|
||||
private static string FilePath = Path.Combine("Saves", "Invasions", "Persistence.bin");
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.WorldSave += OnSave;
|
||||
EventSink.WorldLoad += OnLoad;
|
||||
}
|
||||
|
||||
private static void OnSave(WorldSaveEventArgs e)
|
||||
{
|
||||
Persistence.Serialize(
|
||||
FilePath,
|
||||
writer =>
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(InvasionControl.Invasions.Count);
|
||||
|
||||
foreach (var m in InvasionControl.Invasions)
|
||||
{
|
||||
m.Serialize(writer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void OnLoad()
|
||||
{
|
||||
Persistence.Deserialize(
|
||||
FilePath,
|
||||
reader =>
|
||||
{
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
var count = reader.ReadInt();
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
var invasion = new TownInvasion(reader);
|
||||
|
||||
InvasionControl.Invasions.Add(invasion);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Server.Commands;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Customs.Invasion_System
|
||||
{
|
||||
public class InvasionMainGump : Gump
|
||||
{
|
||||
static Mobile _caller;
|
||||
public InvasionTowns SelectedTown;
|
||||
public TownMonsterType SelectedMonster;
|
||||
public TownChampionType SelectedChamp;
|
||||
private Timer _mStartTimer;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("InvasionSystem", AccessLevel.Administrator, InvasionMainGump_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("InvasionSystem")]
|
||||
[Description("Makes a call to your custom gump.")]
|
||||
public static void InvasionMainGump_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
_caller = e.Mobile;
|
||||
|
||||
if (_caller.HasGump(typeof(InvasionMainGump)))
|
||||
_caller.CloseGump(typeof(InvasionMainGump));
|
||||
|
||||
_caller.SendGump(new InvasionMainGump(_caller));
|
||||
}
|
||||
|
||||
public InvasionMainGump(Mobile from) : this()
|
||||
{
|
||||
_caller = from;
|
||||
}
|
||||
|
||||
public InvasionMainGump() : base( 0, 0 )
|
||||
{
|
||||
Closable=true;
|
||||
Disposable=true;
|
||||
Dragable=true;
|
||||
Resizable=false;
|
||||
int y;
|
||||
|
||||
AddBackground(60, 44, 672, 448, 9200);
|
||||
AddLabel(300, 80, 53, @"Ravenwolfe's Invasion System");
|
||||
|
||||
AddLabel(387, 119, 0, @"Invasion Time (UTC):");
|
||||
AddImageTiled(512, 119, 170, 20, 0xBBC);
|
||||
AddTextEntry(514, 119, 168, 20, 23, 5, DateTime.UtcNow.ToString(), 22);
|
||||
|
||||
AddLabel(120, 120, 0, @"Randomize All");
|
||||
AddCheck(90, 120, 210, 211, false, 0);
|
||||
|
||||
// City Section
|
||||
AddLabel(210, 175, 0, @"City");
|
||||
AddGroup(1);
|
||||
var cityLength = Enum.GetNames(typeof(InvasionTowns)).Length;
|
||||
y = 200;
|
||||
for (int i = 0; i < cityLength; i++)
|
||||
{
|
||||
y += 25;
|
||||
if (i < 9)
|
||||
{
|
||||
AddLabel(120, y, 0, Enum.GetName(typeof(InvasionTowns), i));
|
||||
AddRadio(90, y, 208, 209, false, i + 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
int y2 = y - 225;
|
||||
AddLabel(290, y2, 0, Enum.GetName(typeof(InvasionTowns), i));
|
||||
AddRadio(250, y2, 208, 209, false, i + 100);
|
||||
}
|
||||
}
|
||||
AddLabel(120, 450, 0, @"Random City");
|
||||
AddRadio(90, 450, 208, 209, false, 13);
|
||||
|
||||
//Monster Section
|
||||
AddLabel(387, 175, 0, @"Monster Type");
|
||||
AddGroup(2);
|
||||
var monsterLength = Enum.GetNames(typeof(TownMonsterType)).Length;
|
||||
y = 200;
|
||||
for (int i = 0; i < monsterLength; i++)
|
||||
{
|
||||
y += 25;
|
||||
AddLabel(410, y, 0, Enum.GetName(typeof(TownMonsterType),i));
|
||||
AddRadio(387, y, 208, 209, false, i + 200);
|
||||
}
|
||||
|
||||
//Champion Section
|
||||
AddLabel(594, 175, 0, @"Champion");
|
||||
AddGroup(3);
|
||||
var champLength = Enum.GetNames(typeof(TownChampionType)).Length;
|
||||
y = 200;
|
||||
for (int i = 0; i < champLength; i++)
|
||||
{
|
||||
y += 25;
|
||||
AddLabel(620, y, 0, Enum.GetName(typeof(TownChampionType), i));
|
||||
AddRadio(590, y, 208, 209, false, i + 300);
|
||||
}
|
||||
|
||||
AddButton(525, 450, 247, 248, 1, GumpButtonType.Reply, 0); // Okay
|
||||
AddButton(625, 450, 241, 248, 0, GumpButtonType.Reply, 0); // Cancel
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
string time = info.GetTextEntry(5).Text;
|
||||
DateTime timeToStart;
|
||||
|
||||
DateTime.TryParse(time, out timeToStart);
|
||||
|
||||
if (timeToStart.Equals(DateTime.MinValue))
|
||||
{
|
||||
from.SendMessage("You entered an invalid date. Please follow the pattern.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeToStart < DateTime.UtcNow)
|
||||
{
|
||||
from.SendMessage("You must pick a time in the future!");
|
||||
from.SendMessage("Time is {0}, you picked {1}", DateTime.UtcNow, timeToStart);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.IsSwitched(0))
|
||||
{
|
||||
SelectedTown = (InvasionTowns)Utility.Random(0, Enum.GetNames(typeof(InvasionTowns)).Length);
|
||||
SelectedMonster = (TownMonsterType)Utility.Random(0, Enum.GetNames(typeof(TownMonsterType)).Length);
|
||||
SelectedChamp = (TownChampionType)Utility.Random(0, Enum.GetNames(typeof(TownChampionType)).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.IsSwitched(13))
|
||||
{
|
||||
SelectedTown = (InvasionTowns)Utility.Random(0, Enum.GetNames(typeof(InvasionTowns)).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 100; i < 200; i++)
|
||||
{
|
||||
if (info.IsSwitched(i))
|
||||
{
|
||||
SelectedTown = (InvasionTowns)i - 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 200; i < 300; i++)
|
||||
{
|
||||
if (info.IsSwitched(i))
|
||||
{
|
||||
SelectedMonster = (TownMonsterType)i - 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 300; i < 400; i++)
|
||||
{
|
||||
if (info.IsSwitched(i))
|
||||
{
|
||||
SelectedChamp = (TownChampionType)i - 300;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from.SendMessage("You have scheduled an invasion for {0} at {1}", SelectedTown, timeToStart);
|
||||
|
||||
new TownInvasion(SelectedTown, SelectedMonster, SelectedChamp, timeToStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Customs.Invasion_System
|
||||
{
|
||||
public class MonsterTownSpawnEntry
|
||||
{
|
||||
#region MonsterSpawnEntries
|
||||
|
||||
public static MonsterTownSpawnEntry[] Undead = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Zombie ), 165 ),
|
||||
new MonsterTownSpawnEntry( typeof( Skeleton ), 65 ),
|
||||
new MonsterTownSpawnEntry( typeof( SkeletalMage ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( BoneKnight ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( SkeletalKnight ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( Lich ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( Ghoul ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( BoneMagi ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( Wraith ), 35 ),
|
||||
new MonsterTownSpawnEntry( typeof( RottingCorpse ), 35 ),
|
||||
new MonsterTownSpawnEntry( typeof( LichLord ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( Spectre ), 30 ),
|
||||
new MonsterTownSpawnEntry( typeof( Shade ), 30 ),
|
||||
new MonsterTownSpawnEntry( typeof( AncientLich ), 50 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Humanoid = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Brigand ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( Executioner ), 30 ),
|
||||
new MonsterTownSpawnEntry( typeof( EvilMage ), 70 ),
|
||||
new MonsterTownSpawnEntry( typeof( EvilMageLord ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( Ettin ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( Ogre ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( OgreLord ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( ArcticOgreLord ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( Troll ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( Cyclops ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( Titan ), 40 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] OrcsandRatmen = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Orc ), 80 ),
|
||||
new MonsterTownSpawnEntry( typeof( OrcishMage ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( OrcishLord ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( OrcCaptain ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( OrcBomber ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( OrcBrute ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( Ratman ), 80 ),
|
||||
new MonsterTownSpawnEntry( typeof( RatmanArcher ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( RatmanMage ), 45 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Elementals = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( EarthElemental ), 95 ),
|
||||
new MonsterTownSpawnEntry( typeof( AirElemental ), 70 ),
|
||||
new MonsterTownSpawnEntry( typeof( FireElemental ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( WaterElemental ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( SnowElemental ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( IceElemental ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( Efreet ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( PoisonElemental ), 35 ),
|
||||
new MonsterTownSpawnEntry( typeof( BloodElemental ), 35 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] OreElementals = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( DullCopperElemental ), 90 ),
|
||||
new MonsterTownSpawnEntry( typeof( CopperElemental ), 80 ),
|
||||
new MonsterTownSpawnEntry( typeof( BronzeElemental ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( ShadowIronElemental ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( GoldenElemental ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( AgapiteElemental ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( VeriteElemental ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( ValoriteElemental ), 40 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Ophidian = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( OphidianWarrior ), 100 ),
|
||||
new MonsterTownSpawnEntry( typeof( OphidianMage ), 70 ),
|
||||
new MonsterTownSpawnEntry( typeof( OphidianArchmage ), 30 ),
|
||||
new MonsterTownSpawnEntry( typeof( OphidianKnight ), 35 ),
|
||||
new MonsterTownSpawnEntry( typeof( OphidianMatriarch ), 35 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Arachnid = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Scorpion ), 75 ),
|
||||
new MonsterTownSpawnEntry( typeof( GiantSpider ), 75 ),
|
||||
new MonsterTownSpawnEntry( typeof( TerathanDrone ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( TerathanWarrior ), 30 ),
|
||||
new MonsterTownSpawnEntry( typeof( TerathanMatriarch ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( TerathanAvenger ), 45 ),
|
||||
new MonsterTownSpawnEntry( typeof( DreadSpider ), 40 ),
|
||||
new MonsterTownSpawnEntry( typeof( FrostSpider ), 35 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Snakes = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Snake ), 95 ),
|
||||
new MonsterTownSpawnEntry( typeof( GiantSerpent ), 95 ),
|
||||
new MonsterTownSpawnEntry( typeof( LavaSnake ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( LavaSerpent ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( IceSnake ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( IceSerpent ), 55 ),
|
||||
new MonsterTownSpawnEntry( typeof( SilverSerpent ), 40 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] Abyss = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Gargoyle ), 100 ),
|
||||
new MonsterTownSpawnEntry( typeof( StoneGargoyle ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( FireGargoyle ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( Daemon ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( IceFiend ), 50 ),
|
||||
new MonsterTownSpawnEntry( typeof( Balron ), 30 )
|
||||
};
|
||||
|
||||
public static MonsterTownSpawnEntry[] DragonKind = new MonsterTownSpawnEntry[]
|
||||
{
|
||||
//Monster //Amount
|
||||
new MonsterTownSpawnEntry( typeof( Wyvern ), 100 ),
|
||||
new MonsterTownSpawnEntry( typeof( Drake ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( Dragon ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( WhiteWyrm ), 60 ),
|
||||
new MonsterTownSpawnEntry( typeof( ShadowWyrm ), 10 ),
|
||||
new MonsterTownSpawnEntry( typeof( AncientWyrm ), 30 )
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
private Type m_Monster;
|
||||
private int m_Amount;
|
||||
|
||||
public Type Monster { get { return m_Monster; } set { m_Monster = value; } }
|
||||
public int Amount { get { return m_Amount; } set { m_Amount = value; } }
|
||||
|
||||
public MonsterTownSpawnEntry( Type monster, int amount )
|
||||
{
|
||||
m_Monster = monster;
|
||||
m_Amount = amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user