Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
61
Scripts/Services/ChampionSystem/ChampionAltar.cs
Normal file
61
Scripts/Services/ChampionSystem/ChampionAltar.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class ChampionAltar : PentagramAddon
|
||||
{
|
||||
private ChampionSpawn m_Spawn;
|
||||
public ChampionAltar(ChampionSpawn spawn)
|
||||
{
|
||||
m_Spawn = spawn;
|
||||
Hue = 0x455;
|
||||
}
|
||||
|
||||
public ChampionAltar(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (m_Spawn != null)
|
||||
m_Spawn.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(m_Spawn);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Spawn = reader.ReadItem() as ChampionSpawn;
|
||||
|
||||
if (m_Spawn == null)
|
||||
Delete();
|
||||
else if (!m_Spawn.Active)
|
||||
Hue = 0x455;
|
||||
else
|
||||
Hue = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
129
Scripts/Services/ChampionSystem/ChampionPlatform.cs
Normal file
129
Scripts/Services/ChampionSystem/ChampionPlatform.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class ChampionPlatform : BaseAddon
|
||||
{
|
||||
private ChampionSpawn m_Spawn;
|
||||
public ChampionPlatform(ChampionSpawn spawn)
|
||||
{
|
||||
m_Spawn = spawn;
|
||||
|
||||
for (int x = -2; x <= 2; ++x)
|
||||
for (int y = -2; y <= 2; ++y)
|
||||
AddComponent(0x3EE, x, y, -5);
|
||||
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
AddComponent(0x3EE, x, y, 0);
|
||||
|
||||
for (int i = -1; i <= 1; ++i)
|
||||
{
|
||||
AddComponent(0x3EF, i, 2, 0);
|
||||
AddComponent(0x3F0, 2, i, 0);
|
||||
|
||||
AddComponent(0x3F1, i, -2, 0);
|
||||
AddComponent(0x3F2, -2, i, 0);
|
||||
}
|
||||
|
||||
AddComponent(0x03F7, -2, -2, 0);
|
||||
AddComponent(0x03F8, 2, 2, 0);
|
||||
AddComponent(0x03F9, -2, 2, 0);
|
||||
AddComponent(0x03FA, 2, -2, 0);
|
||||
}
|
||||
|
||||
public ChampionPlatform(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public void AddComponent(int id, int x, int y, int z)
|
||||
{
|
||||
AddonComponent ac = new AddonComponent(id);
|
||||
|
||||
ac.Hue = 0x452;
|
||||
|
||||
AddComponent(ac, x, y, z);
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (m_Spawn != null)
|
||||
m_Spawn.Delete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)2); // version
|
||||
|
||||
writer.Write(m_Spawn);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 2:
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
m_Spawn = reader.ReadItem() as ChampionSpawn;
|
||||
|
||||
if (m_Spawn == null)
|
||||
Delete();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 2)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10), FixComponents);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixComponents()
|
||||
{
|
||||
foreach (var comp in Components)
|
||||
{
|
||||
comp.Hue = 0x452;
|
||||
|
||||
if (comp.ItemID == 0x750)
|
||||
comp.ItemID = 0x3EE;
|
||||
|
||||
if (comp.ItemID == 0x751)
|
||||
comp.ItemID = 0x3EF;
|
||||
|
||||
if (comp.ItemID == 0x752)
|
||||
comp.ItemID = 0x3F0;
|
||||
|
||||
if (comp.ItemID == 0x753)
|
||||
comp.ItemID = 0x3F1;
|
||||
|
||||
if (comp.ItemID == 0x754)
|
||||
comp.ItemID = 0x3F2;
|
||||
|
||||
if (comp.ItemID == 0x759)
|
||||
comp.ItemID = 0x3F7;
|
||||
|
||||
if (comp.ItemID == 0x75A)
|
||||
comp.ItemID = 0x3F8;
|
||||
|
||||
if (comp.ItemID == 0x75B)
|
||||
comp.ItemID = 0x3F9;
|
||||
|
||||
if (comp.ItemID == 0x75C)
|
||||
comp.ItemID = 0x3FA;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Scripts/Services/ChampionSystem/ChampionSkull.cs
Normal file
91
Scripts/Services/ChampionSystem/ChampionSkull.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Server.Engines.CannedEvil;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class ChampionSkull : Item
|
||||
{
|
||||
public static readonly ChampionSkullType[] Types = //
|
||||
Enum.GetValues(typeof(ChampionSkullType))
|
||||
.Cast<ChampionSkullType>()
|
||||
.Where(o => o != ChampionSkullType.None)
|
||||
.ToArray();
|
||||
|
||||
public static ChampionSkullType RandomType { get { return Types[Utility.Random(Types.Length)]; } }
|
||||
|
||||
private ChampionSkullType m_Type;
|
||||
|
||||
[Constructable]
|
||||
public ChampionSkull()
|
||||
: this(RandomType)
|
||||
{ }
|
||||
|
||||
[Constructable]
|
||||
public ChampionSkull(ChampionSkullType type)
|
||||
: base(0x1AE1)
|
||||
{
|
||||
m_Type = type;
|
||||
|
||||
LootType = LootType.Cursed;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ChampionSkullType.Power:
|
||||
Hue = 0x159;
|
||||
break;
|
||||
case ChampionSkullType.Venom:
|
||||
Hue = 0x172;
|
||||
break;
|
||||
case ChampionSkullType.Greed:
|
||||
Hue = 0x1EE;
|
||||
break;
|
||||
case ChampionSkullType.Death:
|
||||
Hue = 0x025;
|
||||
break;
|
||||
case ChampionSkullType.Pain:
|
||||
Hue = 0x035;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public ChampionSkull(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ChampionSkullType Type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set
|
||||
{
|
||||
m_Type = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get { return 1049479 + (int)m_Type; }
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write((int)m_Type);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.ReadInt();
|
||||
|
||||
m_Type = (ChampionSkullType)reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
203
Scripts/Services/ChampionSystem/ChampionSkullBrazier.cs
Normal file
203
Scripts/Services/ChampionSystem/ChampionSkullBrazier.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class ChampionSkullBrazier : AddonComponent
|
||||
{
|
||||
private ChampionSkullPlatform m_Platform;
|
||||
private ChampionSkullType m_Type;
|
||||
private Item m_Skull;
|
||||
public ChampionSkullBrazier(ChampionSkullPlatform platform, ChampionSkullType type)
|
||||
: base(0x19BB)
|
||||
{
|
||||
this.Hue = 0x455;
|
||||
this.Light = LightType.Circle300;
|
||||
|
||||
this.m_Platform = platform;
|
||||
this.m_Type = type;
|
||||
}
|
||||
|
||||
public ChampionSkullBrazier(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ChampionSkullPlatform Platform
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Platform;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ChampionSkullType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Type = value;
|
||||
this.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Item Skull
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Skull;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Skull = value;
|
||||
if (this.m_Platform != null)
|
||||
this.m_Platform.Validate();
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1049489 + (int)this.m_Type;
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (this.m_Platform != null)
|
||||
this.m_Platform.Validate();
|
||||
|
||||
this.BeginSacrifice(from);
|
||||
}
|
||||
|
||||
public void BeginSacrifice(Mobile from)
|
||||
{
|
||||
if (this.Deleted)
|
||||
return;
|
||||
|
||||
if (this.m_Skull != null && this.m_Skull.Deleted)
|
||||
this.Skull = null;
|
||||
|
||||
if (from.Map != this.Map || !from.InRange(this.GetWorldLocation(), 3))
|
||||
{
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
else if (!Harrower.CanSpawn)
|
||||
{
|
||||
from.SendMessage("The harrower has already been spawned.");
|
||||
}
|
||||
else if (this.m_Skull == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1049485); // What would you like to sacrifice?
|
||||
from.Target = new SacrificeTarget(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SendLocalizedMessageTo(from, 1049487, ""); // I already have my champions awakening skull!
|
||||
}
|
||||
}
|
||||
|
||||
public void EndSacrifice(Mobile from, ChampionSkull skull)
|
||||
{
|
||||
if (this.Deleted)
|
||||
return;
|
||||
|
||||
if (this.m_Skull != null && this.m_Skull.Deleted)
|
||||
this.Skull = null;
|
||||
|
||||
if (from.Map != this.Map || !from.InRange(this.GetWorldLocation(), 3))
|
||||
{
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
else if (!Harrower.CanSpawn)
|
||||
{
|
||||
from.SendMessage("The harrower has already been spawned.");
|
||||
}
|
||||
else if (skull == null)
|
||||
{
|
||||
this.SendLocalizedMessageTo(from, 1049488, ""); // That is not my champions awakening skull!
|
||||
}
|
||||
else if (this.m_Skull != null)
|
||||
{
|
||||
this.SendLocalizedMessageTo(from, 1049487, ""); // I already have my champions awakening skull!
|
||||
}
|
||||
else if (!skull.IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1049486); // You can only sacrifice items that are in your backpack!
|
||||
}
|
||||
else
|
||||
{
|
||||
if (skull.Type == this.Type)
|
||||
{
|
||||
skull.Movable = false;
|
||||
skull.MoveToWorld(this.GetWorldTop(), this.Map);
|
||||
|
||||
this.Skull = skull;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SendLocalizedMessageTo(from, 1049488, ""); // That is not my champions awakening skull!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((int)this.m_Type);
|
||||
writer.Write(this.m_Platform);
|
||||
writer.Write(this.m_Skull);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Type = (ChampionSkullType)reader.ReadInt();
|
||||
this.m_Platform = reader.ReadItem() as ChampionSkullPlatform;
|
||||
this.m_Skull = reader.ReadItem();
|
||||
|
||||
if (this.m_Platform == null)
|
||||
this.Delete();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.Hue == 0x497)
|
||||
this.Hue = 0x455;
|
||||
|
||||
if (this.Light != LightType.Circle300)
|
||||
this.Light = LightType.Circle300;
|
||||
}
|
||||
|
||||
private class SacrificeTarget : Target
|
||||
{
|
||||
private readonly ChampionSkullBrazier m_Brazier;
|
||||
public SacrificeTarget(ChampionSkullBrazier brazier)
|
||||
: base(12, false, TargetFlags.None)
|
||||
{
|
||||
this.m_Brazier = brazier;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
this.m_Brazier.EndSacrifice(from, targeted as ChampionSkull);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
129
Scripts/Services/ChampionSystem/ChampionSkullPlatform.cs
Normal file
129
Scripts/Services/ChampionSystem/ChampionSkullPlatform.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class ChampionSkullPlatform : BaseAddon
|
||||
{
|
||||
private ChampionSkullBrazier m_Power, m_Enlightenment, m_Venom, m_Pain, m_Greed, m_Death;
|
||||
[Constructable]
|
||||
public ChampionSkullPlatform()
|
||||
{
|
||||
this.AddComponent(new AddonComponent(0x71A), -1, -1, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), 0, -1, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), 1, -1, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), -1, 0, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), 0, 0, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), 1, 0, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), -1, 1, -1);
|
||||
this.AddComponent(new AddonComponent(0x709), 0, 1, -1);
|
||||
this.AddComponent(new AddonComponent(0x71B), 1, 1, -1);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), 0, -1, 4);
|
||||
this.AddComponent(this.m_Power = new ChampionSkullBrazier(this, ChampionSkullType.Power), 0, -1, 5);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), 1, -1, 4);
|
||||
this.AddComponent(this.m_Enlightenment = new ChampionSkullBrazier(this, ChampionSkullType.Enlightenment), 1, -1, 5);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), -1, 0, 4);
|
||||
this.AddComponent(this.m_Venom = new ChampionSkullBrazier(this, ChampionSkullType.Venom), -1, 0, 5);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), 1, 0, 4);
|
||||
this.AddComponent(this.m_Pain = new ChampionSkullBrazier(this, ChampionSkullType.Pain), 1, 0, 5);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), -1, 1, 4);
|
||||
this.AddComponent(this.m_Greed = new ChampionSkullBrazier(this, ChampionSkullType.Greed), -1, 1, 5);
|
||||
|
||||
this.AddComponent(new AddonComponent(0x50F), 0, 1, 4);
|
||||
this.AddComponent(this.m_Death = new ChampionSkullBrazier(this, ChampionSkullType.Death), 0, 1, 5);
|
||||
|
||||
AddonComponent comp = new LocalizedAddonComponent(0x20D2, 1049495);
|
||||
comp.Hue = 0x482;
|
||||
this.AddComponent(comp, 0, 0, 5);
|
||||
|
||||
comp = new LocalizedAddonComponent(0x0BCF, 1049496);
|
||||
comp.Hue = 0x482;
|
||||
this.AddComponent(comp, 0, 2, -7);
|
||||
|
||||
comp = new LocalizedAddonComponent(0x0BD0, 1049497);
|
||||
comp.Hue = 0x482;
|
||||
this.AddComponent(comp, 2, 0, -7);
|
||||
}
|
||||
|
||||
public ChampionSkullPlatform(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (this.Validate(this.m_Power) && this.Validate(this.m_Enlightenment) && this.Validate(this.m_Venom) && this.Validate(this.m_Pain) && this.Validate(this.m_Greed) && this.Validate(this.m_Death))
|
||||
{
|
||||
Mobile harrower = Harrower.Spawn(new Point3D(this.X, this.Y, this.Z + 6), this.Map);
|
||||
|
||||
if (harrower == null)
|
||||
return;
|
||||
|
||||
this.Clear(this.m_Power);
|
||||
this.Clear(this.m_Enlightenment);
|
||||
this.Clear(this.m_Venom);
|
||||
this.Clear(this.m_Pain);
|
||||
this.Clear(this.m_Greed);
|
||||
this.Clear(this.m_Death);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear(ChampionSkullBrazier brazier)
|
||||
{
|
||||
if (brazier != null)
|
||||
{
|
||||
Effects.SendBoltEffect(brazier);
|
||||
|
||||
if (brazier.Skull != null)
|
||||
brazier.Skull.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Validate(ChampionSkullBrazier brazier)
|
||||
{
|
||||
return (brazier != null && brazier.Skull != null && !brazier.Skull.Deleted);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(this.m_Power);
|
||||
writer.Write(this.m_Enlightenment);
|
||||
writer.Write(this.m_Venom);
|
||||
writer.Write(this.m_Pain);
|
||||
writer.Write(this.m_Greed);
|
||||
writer.Write(this.m_Death);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Power = reader.ReadItem() as ChampionSkullBrazier;
|
||||
this.m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
|
||||
this.m_Venom = reader.ReadItem() as ChampionSkullBrazier;
|
||||
this.m_Pain = reader.ReadItem() as ChampionSkullBrazier;
|
||||
this.m_Greed = reader.ReadItem() as ChampionSkullBrazier;
|
||||
this.m_Death = reader.ReadItem() as ChampionSkullBrazier;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Scripts/Services/ChampionSystem/ChampionSkullType.cs
Normal file
15
Scripts/Services/ChampionSystem/ChampionSkullType.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public enum ChampionSkullType
|
||||
{
|
||||
None = -1,
|
||||
Power,
|
||||
Enlightenment,
|
||||
Venom,
|
||||
Pain,
|
||||
Greed,
|
||||
Death
|
||||
}
|
||||
}
|
||||
1710
Scripts/Services/ChampionSystem/ChampionSpawn.cs
Normal file
1710
Scripts/Services/ChampionSystem/ChampionSpawn.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
// This class is only here to remove legacy controller items
|
||||
public class ChampionSpawnController : Item
|
||||
{
|
||||
public ChampionSpawnController(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
reader.ReadItemList();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
reader.ReadBool();
|
||||
reader.ReadItemList();
|
||||
reader.ReadItemList();
|
||||
reader.ReadItemList();
|
||||
reader.ReadItemList();
|
||||
reader.ReadItemList();
|
||||
reader.ReadTimeSpan();
|
||||
reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
DeleteAll();
|
||||
Delete();
|
||||
}
|
||||
|
||||
private void DeleteAll()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
foreach (Item item in World.Items.Values)
|
||||
{
|
||||
if (item is ChampionSpawn && !item.Deleted)
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
foreach (ChampionSpawn cs in list)
|
||||
{
|
||||
cs.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
189
Scripts/Services/ChampionSystem/ChampionSpawnType.cs
Normal file
189
Scripts/Services/ChampionSystem/ChampionSpawnType.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public enum ChampionSpawnType
|
||||
{
|
||||
Abyss,
|
||||
Arachnid,
|
||||
ColdBlood,
|
||||
ForestLord,
|
||||
VerminHorde,
|
||||
UnholyTerror,
|
||||
SleepingDragon,
|
||||
Glade,
|
||||
Corrupt,
|
||||
#region Stygian Abyss
|
||||
Terror,
|
||||
Infuse,
|
||||
#endregion
|
||||
#region TOL
|
||||
DragonTurtle,
|
||||
#endregion
|
||||
Khaldun
|
||||
}
|
||||
|
||||
public class ChampionSpawnInfo
|
||||
{
|
||||
private readonly string m_Name;
|
||||
private readonly Type m_Champion;
|
||||
private readonly Type[][] m_SpawnTypes;
|
||||
private readonly string[] m_LevelNames;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
public Type Champion
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Champion;
|
||||
}
|
||||
}
|
||||
public Type[][] SpawnTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SpawnTypes;
|
||||
}
|
||||
}
|
||||
public string[] LevelNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LevelNames;
|
||||
}
|
||||
}
|
||||
|
||||
public ChampionSpawnInfo(string name, Type champion, string[] levelNames, Type[][] spawnTypes)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Champion = champion;
|
||||
m_LevelNames = levelNames;
|
||||
m_SpawnTypes = spawnTypes;
|
||||
}
|
||||
|
||||
public static ChampionSpawnInfo[] Table
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Table;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly ChampionSpawnInfo[] m_Table = new ChampionSpawnInfo[]
|
||||
{
|
||||
new ChampionSpawnInfo("Abyss", typeof(Semidar), new string[] { "Foe", "Assassin", "Conqueror" }, new Type[][] // Abyss
|
||||
{ // Abyss
|
||||
new Type[] { typeof(GreaterMongbat), typeof(Imp) }, // Level 1
|
||||
new Type[] { typeof(Gargoyle), typeof(Harpy) }, // Level 2
|
||||
new Type[] { typeof(FireGargoyle), typeof(StoneGargoyle) }, // Level 3
|
||||
new Type[] { typeof(Daemon), typeof(Succubus) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Arachnid", typeof(Mephitis), new string[] { "Bane", "Killer", "Vanquisher" }, new Type[][] // Arachnid
|
||||
{ // Arachnid
|
||||
new Type[] { typeof(Scorpion), typeof(GiantSpider) }, // Level 1
|
||||
new Type[] { typeof(TerathanDrone), typeof(TerathanWarrior) }, // Level 2
|
||||
new Type[] { typeof(DreadSpider), typeof(TerathanMatriarch) }, // Level 3
|
||||
new Type[] { typeof(PoisonElemental), typeof(TerathanAvenger) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Cold Blood", typeof(Rikktor), new string[] { "Blight", "Slayer", "Destroyer" }, new Type[][] // Cold Blood
|
||||
{ // Cold Blood
|
||||
new Type[] { typeof(Lizardman), typeof(Snake) }, // Level 1
|
||||
new Type[] { typeof(LavaLizard), typeof(OphidianWarrior) }, // Level 2
|
||||
new Type[] { typeof(Drake), typeof(OphidianArchmage) }, // Level 3
|
||||
new Type[] { typeof(Dragon), typeof(OphidianKnight) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Forest Lord", typeof(LordOaks), new string[] { "Enemy", "Curse", "Slaughterer" }, new Type[][] // Forest Lord
|
||||
{ // Forest Lord
|
||||
new Type[] { typeof(Pixie), typeof(ShadowWisp) }, // Level 1
|
||||
new Type[] { typeof(Kirin), typeof(Wisp) }, // Level 2
|
||||
new Type[] { typeof(Centaur), typeof(Unicorn) }, // Level 3
|
||||
new Type[] { typeof(EtherealWarrior), typeof(SerpentineDragon) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Vermin Horde", typeof(Barracoon), new string[] { "Adversary", "Subjugator", "Eradicator" }, new Type[][] // Vermin Horde
|
||||
{ // Vermin Horde
|
||||
new Type[] { typeof(GiantRat), typeof(Slime) }, // Level 1
|
||||
new Type[] { typeof(DireWolf), typeof(Ratman) }, // Level 2
|
||||
new Type[] { typeof(HellHound), typeof(RatmanMage) }, // Level 3
|
||||
new Type[] { typeof(RatmanArcher), typeof(SilverSerpent) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Unholy Terror", typeof(Neira), new string[] { "Scourge", "Punisher", "Nemesis" }, new Type[][] // Unholy Terror
|
||||
{ // Unholy Terror
|
||||
(Core.AOS ? new Type[] { typeof(Bogle), typeof(Ghoul), typeof(Shade), typeof(Spectre), typeof(Wraith) }// Level 1 (Pre-AoS)
|
||||
: new Type[] { typeof(Ghoul), typeof(Shade), typeof(Spectre), typeof(Wraith) }), // Level 1
|
||||
|
||||
new Type[] { typeof(BoneMagi), typeof(Mummy), typeof(SkeletalMage) }, // Level 2
|
||||
new Type[] { typeof(BoneKnight), typeof(Lich), typeof(SkeletalKnight) }, // Level 3
|
||||
new Type[] { typeof(LichLord), typeof(RottingCorpse) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Sleeping Dragon", typeof(Serado), new string[] { "Rival", "Challenger", "Antagonist" }, new Type[][]
|
||||
{ // Unholy Terror
|
||||
new Type[] { typeof(DeathwatchBeetleHatchling), typeof(Lizardman) },
|
||||
new Type[] { typeof(DeathwatchBeetle), typeof(Kappa) },
|
||||
new Type[] { typeof(LesserHiryu), typeof(RevenantLion) },
|
||||
new Type[] { typeof(Hiryu), typeof(Oni) }
|
||||
}),
|
||||
new ChampionSpawnInfo("Glade", typeof(Twaulo), new string[] { "Banisher", "Enforcer", "Eradicator" }, new Type[][]
|
||||
{ // Glade
|
||||
new Type[] { typeof(Pixie), typeof(ShadowWisp) },
|
||||
new Type[] { typeof(Centaur), typeof(MLDryad) },
|
||||
new Type[] { typeof(Satyr), typeof(CuSidhe) },
|
||||
new Type[] { typeof(FeralTreefellow), typeof(RagingGrizzlyBear) }
|
||||
}),
|
||||
new ChampionSpawnInfo("Corrupt", typeof(Ilhenir), new string[] { "Cleanser", "Expunger", "Depurator" }, new Type[][]
|
||||
{ // Corrupt
|
||||
new Type[] { typeof(PlagueSpawn), typeof(Bogling) },
|
||||
new Type[] { typeof(PlagueBeast), typeof(BogThing) },
|
||||
new Type[] { typeof(PlagueBeastLord), typeof(InterredGrizzle) },
|
||||
new Type[] { typeof(FetidEssence), typeof(PestilentBandage) }
|
||||
}),
|
||||
|
||||
new ChampionSpawnInfo("Terror", typeof(AbyssalInfernal), new string[] { "Banisher", "Enforcer", "Eradicator" }, new Type[][]
|
||||
{ // Terror
|
||||
new Type[] { typeof(HordeMinion), typeof(ChaosDaemon) }, // Level 1
|
||||
new Type[] { typeof(StoneHarpy), typeof(ArcaneDaemon) }, // Level 2
|
||||
new Type[] { typeof(PitFiend), typeof(Moloch) }, // Level 3
|
||||
new Type[] { typeof(ArchDaemon), typeof(AbyssalAbomination) }// Level 4
|
||||
}),
|
||||
new ChampionSpawnInfo("Infuse", typeof(PrimevalLich), new string[] { "Cleanser", "Expunger", "Depurator" }, new Type[][]
|
||||
{ // Infused
|
||||
new Type[] { typeof(GoreFiend), typeof(VampireBat) }, // Level 1
|
||||
new Type[] { typeof(FleshGolem), typeof(DarkWisp) }, // Level 2
|
||||
new Type[] { typeof(UndeadGargoyle), typeof(Wight) }, // Level 3
|
||||
new Type[] { typeof(SkeletalDrake), typeof(DreamWraith) }// Level 4
|
||||
}),
|
||||
|
||||
new ChampionSpawnInfo( "Valley", typeof( DragonTurtle ), new string[]{ "Explorer", "Huntsman", "Msafiri", } , new Type[][]
|
||||
{ // DragonTurtle
|
||||
new Type[]{ typeof( MyrmidexDrone ), typeof( MyrmidexLarvae ) }, // Level 1
|
||||
new Type[]{ typeof( SilverbackGorilla ), typeof( WildTiger ) }, // Level 2
|
||||
new Type[]{ typeof( GreaterPhoenix ), typeof( Infernus ) }, // Level 3
|
||||
new Type[]{ typeof( Dimetrosaur ), typeof( Allosaurus ) } // Level 4
|
||||
} ),
|
||||
|
||||
new ChampionSpawnInfo( "Khaldun", typeof( KhalAnkur ), new string[]{ "Banisher", "Enforcer", "Eradicator" } , new Type[][]
|
||||
{ // KhalAnkur
|
||||
new Type[]{ typeof( SkelementalKnight ), typeof( KhaldunBlood ) }, // Level 1
|
||||
new Type[]{ typeof( SkelementalMage ), typeof( Viscera ) }, // Level 2
|
||||
new Type[]{ typeof( CultistAmbusher ), typeof( ShadowFiend ) }, // Level 3
|
||||
new Type[]{ typeof( KhalAnkurWarriors ) } // Level 4
|
||||
} ),
|
||||
};
|
||||
|
||||
public static ChampionSpawnInfo GetInfo(ChampionSpawnType type)
|
||||
{
|
||||
int v = (int)type;
|
||||
|
||||
if (v < 0 || v >= m_Table.Length)
|
||||
v = 0;
|
||||
|
||||
return m_Table[v];
|
||||
}
|
||||
}
|
||||
}
|
||||
425
Scripts/Services/ChampionSystem/ChampionSystem.cs
Normal file
425
Scripts/Services/ChampionSystem/ChampionSystem.cs
Normal file
@@ -0,0 +1,425 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Server.Gumps;
|
||||
using Server.Commands;
|
||||
using System.Xml;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class ChampionSystem
|
||||
{
|
||||
private static bool m_Enabled = false;
|
||||
private static bool m_Initialized = false;
|
||||
private static readonly string m_Path = Path.Combine("Saves", "Champions", "ChampionSystem.bin");
|
||||
private static readonly string m_ConfigPath = Path.Combine("Config", "ChampionSpawns.xml");
|
||||
private static DateTime m_LastRotate;
|
||||
private static TimeSpan m_RotateDelay;
|
||||
private static List<ChampionSpawn> m_AllSpawns = new List<ChampionSpawn>();
|
||||
private static InternalTimer m_Timer;
|
||||
private static int m_GoldShowerPiles;
|
||||
private static int m_GoldShowerMinAmount;
|
||||
private static int m_GoldShowerMaxAmount;
|
||||
private static int m_HarrowerGoldPiles;
|
||||
private static int m_HarrowerGoldMinAmount;
|
||||
private static int m_HarrowerGoldMaxAmount;
|
||||
private static int m_PowerScrollAmount;
|
||||
private static int m_StatScrollAmount;
|
||||
private static int[] m_Rank = new int[16];
|
||||
private static int[] m_MaxKill = new int[4];
|
||||
private static double m_TranscendenceChance;
|
||||
private static double m_ScrollChance;
|
||||
private static bool m_ForceGenerate = false;
|
||||
|
||||
public static int GoldShowerPiles { get { return m_GoldShowerPiles; } }
|
||||
public static int GoldShowerMinAmount { get { return m_GoldShowerMinAmount; } }
|
||||
public static int GoldShowerMaxAmount { get { return m_GoldShowerMaxAmount; } }
|
||||
public static int HarrowerGoldShowerPiles { get { return m_HarrowerGoldPiles; } }
|
||||
public static int HarrowerGoldShowerMinAmount { get { return m_HarrowerGoldMinAmount; } }
|
||||
public static int HarrowerGoldShowerMaxAmount { get { return m_HarrowerGoldMaxAmount; } }
|
||||
public static int PowerScrollAmount { get { return m_PowerScrollAmount; } }
|
||||
public static int StatScrollAmount { get { return m_StatScrollAmount; } }
|
||||
|
||||
public static List<ChampionSpawn> AllSpawns { get { return m_AllSpawns; } }
|
||||
|
||||
public static int RankForLevel(int l)
|
||||
{
|
||||
if (l < 0)
|
||||
return 0;
|
||||
if (l >= m_Rank.Length)
|
||||
return 3;
|
||||
return m_Rank[l];
|
||||
}
|
||||
public static int MaxKillsForLevel(int l)
|
||||
{
|
||||
return m_MaxKill[RankForLevel(l)];
|
||||
}
|
||||
public static double SpawnRadiusModForLevel(int l)
|
||||
{
|
||||
switch (RankForLevel(l))
|
||||
{
|
||||
case 0: return 1.0d;
|
||||
case 1: return 0.75d;
|
||||
case 2: return 0.5d;
|
||||
default: return 0.25d;
|
||||
}
|
||||
}
|
||||
public static double TranscendenceChance { get { return m_TranscendenceChance; } }
|
||||
public static double ScrollChance { get { return m_ScrollChance; } }
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
m_Enabled = Config.Get("Champions.Enabled", true);
|
||||
m_RotateDelay = Config.Get("Champions.RotateDelay", TimeSpan.FromDays(1.0d));
|
||||
m_GoldShowerPiles = Config.Get("Champions.GoldPiles", 50);
|
||||
m_GoldShowerMinAmount = Config.Get("Champions.GoldMin", 4000);
|
||||
m_GoldShowerMaxAmount = Config.Get("Champions.GoldMax", 5500);
|
||||
m_HarrowerGoldPiles = Config.Get("Champions.HarrowerGoldPiles", 75);
|
||||
m_HarrowerGoldMinAmount = Config.Get("Champions.HarrowerGoldMin", 5000);
|
||||
m_HarrowerGoldMaxAmount = Config.Get("Champions.HarrowerGoldMax", 10000);
|
||||
m_PowerScrollAmount = Config.Get("Champions.PowerScrolls", 6);
|
||||
m_StatScrollAmount = Config.Get("Champions.StatScrolls", 16);
|
||||
m_ScrollChance = Config.Get("Champions.ScrollChance", 0.1d) / 100.0d;
|
||||
m_TranscendenceChance = Config.Get("Champions.TranscendenceChance", 50.0d) / 100.0d;
|
||||
int rank2 = Config.Get("Champions.Rank2RedSkulls", 5);
|
||||
int rank3 = Config.Get("Champions.Rank3RedSkulls", 10);
|
||||
int rank4 = Config.Get("Champions.Rank4RedSkulls", 10);
|
||||
for (int i = 0; i < m_Rank.Length; ++i)
|
||||
{
|
||||
if (i < rank2)
|
||||
m_Rank[i] = 0;
|
||||
else if (i < rank3)
|
||||
m_Rank[i] = 1;
|
||||
else if (i < rank4)
|
||||
m_Rank[i] = 2;
|
||||
else
|
||||
m_Rank[i] = 3;
|
||||
}
|
||||
m_MaxKill[0] = Config.Get("Champions.Rank1MaxKills", 256);
|
||||
m_MaxKill[1] = Config.Get("Champions.Rank2MaxKills", 128);
|
||||
m_MaxKill[2] = Config.Get("Champions.Rank3MaxKills", 64);
|
||||
m_MaxKill[3] = Config.Get("Champions.Rank4MaxKills", 32);
|
||||
EventSink.WorldLoad += EventSink_WorldLoad;
|
||||
EventSink.WorldSave += EventSink_WorldSave;
|
||||
}
|
||||
private static void EventSink_WorldSave(WorldSaveEventArgs e)
|
||||
{
|
||||
Persistence.Serialize(
|
||||
m_Path,
|
||||
writer =>
|
||||
{
|
||||
writer.Write(1); // Version
|
||||
writer.Write(m_Initialized);
|
||||
writer.Write(m_LastRotate);
|
||||
writer.WriteItemList(m_AllSpawns, true);
|
||||
});
|
||||
}
|
||||
|
||||
private static void EventSink_WorldLoad()
|
||||
{
|
||||
Persistence.Deserialize(
|
||||
m_Path,
|
||||
reader =>
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Initialized = reader.ReadBool();
|
||||
m_LastRotate = reader.ReadDateTime();
|
||||
m_AllSpawns.AddRange(reader.ReadItemList().Cast<ChampionSpawn>());
|
||||
|
||||
if(version == 0)
|
||||
{
|
||||
//m_ForceGenerate = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("GenChampSpawns", AccessLevel.GameMaster, GenSpawns_OnCommand);
|
||||
CommandSystem.Register("DelChampSpawns", AccessLevel.GameMaster, DelSpawns_OnCommand);
|
||||
|
||||
CommandSystem.Register("ChampionInfo", AccessLevel.GameMaster, new CommandEventHandler(ChampionInfo_OnCommand));
|
||||
|
||||
if (!m_Enabled || m_ForceGenerate)
|
||||
{
|
||||
m_Initialized = false;
|
||||
|
||||
if (m_Enabled)
|
||||
{
|
||||
LoadSpawns();
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSpawns();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Enabled)
|
||||
{
|
||||
m_Timer = new InternalTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenSpawns_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
LoadSpawns();
|
||||
e.Mobile.SendMessage("Champ Spawns Generated!");
|
||||
}
|
||||
|
||||
public static void DelSpawns_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
RemoveSpawns();
|
||||
e.Mobile.SendMessage("Champ Spawns Removed!");
|
||||
}
|
||||
|
||||
public static void LoadSpawns()
|
||||
{
|
||||
if (m_Initialized)
|
||||
return;
|
||||
|
||||
RemoveSpawns();
|
||||
|
||||
Utility.PushColor(ConsoleColor.White);
|
||||
Console.WriteLine("Generating Champion Spawns");
|
||||
Utility.PopColor();
|
||||
|
||||
ChampionSpawn spawn;
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(m_ConfigPath);
|
||||
foreach (XmlNode node in doc.GetElementsByTagName("championSystem")[0].ChildNodes)
|
||||
{
|
||||
if (node.Name.Equals("spawn"))
|
||||
{
|
||||
spawn = new ChampionSpawn();
|
||||
spawn.SpawnName = GetAttr(node, "name", "Unamed Spawner");
|
||||
string value = GetAttr(node, "type", null);
|
||||
|
||||
if (value == null)
|
||||
spawn.RandomizeType = true;
|
||||
else
|
||||
spawn.Type = (ChampionSpawnType)Enum.Parse(typeof(ChampionSpawnType), value);
|
||||
|
||||
value = GetAttr(node, "spawnMod", "1.0");
|
||||
spawn.SpawnMod = XmlConvert.ToDouble(value);
|
||||
value = GetAttr(node, "killsMod", "1.0");
|
||||
spawn.KillsMod = XmlConvert.ToDouble(value);
|
||||
|
||||
foreach (XmlNode child in node.ChildNodes)
|
||||
{
|
||||
if (child.Name.Equals("location"))
|
||||
{
|
||||
int x = XmlConvert.ToInt32(GetAttr(child, "x", "0"));
|
||||
int y = XmlConvert.ToInt32(GetAttr(child, "y", "0"));
|
||||
int z = XmlConvert.ToInt32(GetAttr(child, "z", "0"));
|
||||
int r = XmlConvert.ToInt32(GetAttr(child, "radius", "0"));
|
||||
string mapName = GetAttr(child, "map", "Felucca");
|
||||
Map map = Map.Parse(mapName);
|
||||
|
||||
spawn.SpawnRadius = r;
|
||||
spawn.MoveToWorld(new Point3D(x, y, z), map);
|
||||
}
|
||||
}
|
||||
|
||||
spawn.GroupName = GetAttr(node, "group", null);
|
||||
m_AllSpawns.Add(spawn);
|
||||
|
||||
if (spawn.Type == ChampionSpawnType.Infuse)
|
||||
{
|
||||
PrimevalLichPuzzle.GenLichPuzzle(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rotate();
|
||||
|
||||
m_Initialized = true;
|
||||
}
|
||||
|
||||
public static void RemoveSpawns()
|
||||
{
|
||||
if (m_AllSpawns != null && m_AllSpawns.Count > 0)
|
||||
{
|
||||
foreach (ChampionSpawn s in m_AllSpawns.Where(sp => sp != null && !sp.Deleted))
|
||||
{
|
||||
s.Delete();
|
||||
}
|
||||
|
||||
m_AllSpawns.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAttr(XmlNode node, string name, string def)
|
||||
{
|
||||
XmlAttribute attr = node.Attributes[name];
|
||||
if (attr != null)
|
||||
return attr.Value;
|
||||
return def;
|
||||
}
|
||||
|
||||
[Usage("ChampionInfo")]
|
||||
[Description("Opens a UI that displays information about the champion system")]
|
||||
private static void ChampionInfo_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
{
|
||||
e.Mobile.SendMessage("The champion system is not enabled.");
|
||||
return;
|
||||
}
|
||||
if (m_AllSpawns.Count <= 0)
|
||||
{
|
||||
e.Mobile.SendMessage("The champion system is enabled but no altars exist");
|
||||
return;
|
||||
}
|
||||
e.Mobile.SendGump(new ChampionSystemGump());
|
||||
}
|
||||
|
||||
private static void Rotate()
|
||||
{
|
||||
Dictionary<String, List<ChampionSpawn>> groups = new Dictionary<string, List<ChampionSpawn>>();
|
||||
m_LastRotate = DateTime.UtcNow;
|
||||
|
||||
foreach (ChampionSpawn spawn in m_AllSpawns.Where(spawn => spawn != null && !spawn.Deleted))
|
||||
{
|
||||
List<ChampionSpawn> group;
|
||||
if (spawn.GroupName == null)
|
||||
{
|
||||
spawn.AutoRestart = true;
|
||||
if (!spawn.Active)
|
||||
spawn.Active = true;
|
||||
continue;
|
||||
}
|
||||
if (!groups.TryGetValue(spawn.GroupName, out group))
|
||||
{
|
||||
group = new List<ChampionSpawn>();
|
||||
groups.Add(spawn.GroupName, group);
|
||||
}
|
||||
group.Add(spawn);
|
||||
}
|
||||
|
||||
foreach (string key in groups.Keys)
|
||||
{
|
||||
List<ChampionSpawn> group = groups[key];
|
||||
foreach (ChampionSpawn spawn in group)
|
||||
{
|
||||
spawn.AutoRestart = false;
|
||||
}
|
||||
ChampionSpawn s = group[Utility.Random(group.Count)];
|
||||
s.AutoRestart = true;
|
||||
if (!s.Active)
|
||||
s.Active = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSlice()
|
||||
{
|
||||
if (DateTime.UtcNow > m_LastRotate + m_RotateDelay)
|
||||
Rotate();
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
public InternalTimer()
|
||||
: base(TimeSpan.FromMinutes(1.0d))
|
||||
{
|
||||
this.Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
OnSlice();
|
||||
}
|
||||
}
|
||||
|
||||
private class ChampionSystemGump : Gump
|
||||
{
|
||||
private const int gBoarder = 20;
|
||||
private const int gRowHeight = 25;
|
||||
private const int gFontHue = 0;
|
||||
private static readonly int[] gWidths = { 20, 100, 100, 40, 40, 40, 80, 60, 50, 50, 50, 20 };
|
||||
private static readonly int[] gTab;
|
||||
private static readonly int gWidth;
|
||||
|
||||
public List<ChampionSpawn> Spawners { get; set; }
|
||||
|
||||
static ChampionSystemGump()
|
||||
{
|
||||
gWidth = gWidths.Sum();
|
||||
int tab = 0;
|
||||
gTab = new int[gWidths.Length];
|
||||
for(int i = 0; i < gWidths.Length; ++i)
|
||||
{
|
||||
gTab[i] = tab;
|
||||
tab += gWidths[i];
|
||||
}
|
||||
}
|
||||
|
||||
public ChampionSystemGump()
|
||||
: base(40, 40)
|
||||
{
|
||||
Spawners = m_AllSpawns.Where(spawn => spawn != null && !spawn.Deleted).ToList();
|
||||
|
||||
AddBackground(0, 0, gWidth, gBoarder * 2 + Spawners.Count * gRowHeight + gRowHeight * 2, 0x13BE);
|
||||
|
||||
int top = gBoarder;
|
||||
AddLabel(gBoarder, top, gFontHue, "Champion Spawn System Gump");
|
||||
top += gRowHeight;
|
||||
|
||||
AddLabel(gTab[1], top, gFontHue, "Spawn Name");
|
||||
AddLabel(gTab[2], top, gFontHue, "Spawn Group");
|
||||
AddLabel(gTab[3], top, gFontHue, "X");
|
||||
AddLabel(gTab[4], top, gFontHue, "Y");
|
||||
AddLabel(gTab[5], top, gFontHue, "Z");
|
||||
AddLabel(gTab[6], top, gFontHue, "Map");
|
||||
AddLabel(gTab[7], top, gFontHue, "Active");
|
||||
AddLabel(gTab[8], top, gFontHue, "Auto");
|
||||
AddLabel(gTab[9], top, gFontHue, "Go");
|
||||
AddLabel(gTab[10], top, gFontHue, "Info");
|
||||
top += gRowHeight;
|
||||
|
||||
for(int i = 0; i < Spawners.Count; i++)
|
||||
{
|
||||
ChampionSpawn spawn = Spawners[i];
|
||||
AddLabel(gTab[1], top, gFontHue, spawn.SpawnName);
|
||||
AddLabel(gTab[2], top, gFontHue, spawn.GroupName != null ? spawn.GroupName : "None");
|
||||
AddLabel(gTab[3], top, gFontHue, spawn.X.ToString());
|
||||
AddLabel(gTab[4], top, gFontHue, spawn.Y.ToString());
|
||||
AddLabel(gTab[5], top, gFontHue, spawn.Z.ToString());
|
||||
AddLabel(gTab[6], top, gFontHue, spawn.Map == null ? "null" : spawn.Map.ToString());
|
||||
AddLabel(gTab[7], top, gFontHue, spawn.Active ? "Y" : "N");
|
||||
AddLabel(gTab[8], top, gFontHue, spawn.AutoRestart ? "Y" : "N");
|
||||
AddButton(gTab[9], top, 0xFA5, 0xFA7, 1 + i, GumpButtonType.Reply, 0);
|
||||
AddButton(gTab[10], top, 0xFA5, 0xFA7, 1001 + i, GumpButtonType.Reply, 0);
|
||||
top += gRowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(Network.NetState sender, RelayInfo info)
|
||||
{
|
||||
ChampionSpawn spawn;
|
||||
int idx;
|
||||
|
||||
if (info.ButtonID > 0 && info.ButtonID <= 1000)
|
||||
{
|
||||
idx = info.ButtonID - 1;
|
||||
if (idx < 0 || idx >= Spawners.Count)
|
||||
return;
|
||||
spawn = Spawners[idx];
|
||||
sender.Mobile.MoveToWorld(spawn.Location, spawn.Map);
|
||||
sender.Mobile.SendGump(this);
|
||||
}
|
||||
else if (info.ButtonID > 1000)
|
||||
{
|
||||
idx = info.ButtonID - 1001;
|
||||
if (idx < 0 || idx > Spawners.Count)
|
||||
return;
|
||||
spawn = Spawners[idx];
|
||||
spawn.SendGump(sender.Mobile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Scripts/Services/ChampionSystem/GoldShower.cs
Normal file
98
Scripts/Services/ChampionSystem/GoldShower.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class GoldShower
|
||||
{
|
||||
public static void DoForChamp(Point3D center, Map map)
|
||||
{
|
||||
Do(center, map, ChampionSystem.GoldShowerPiles, ChampionSystem.GoldShowerMinAmount, ChampionSystem.GoldShowerMaxAmount);
|
||||
}
|
||||
public static void DoForHarrower(Point3D center, Map map)
|
||||
{
|
||||
Do(center, map, ChampionSystem.HarrowerGoldShowerPiles, ChampionSystem.HarrowerGoldShowerMinAmount, ChampionSystem.HarrowerGoldShowerMaxAmount);
|
||||
}
|
||||
public static void Do(Point3D center, Map map, int piles, int minAmount, int maxAmount)
|
||||
{
|
||||
new GoodiesTimer(center, map, piles, minAmount, maxAmount).Start();
|
||||
}
|
||||
|
||||
private class GoodiesTimer : Timer
|
||||
{
|
||||
private readonly Map m_Map;
|
||||
private readonly Point3D m_Location;
|
||||
private readonly int m_PilesMax;
|
||||
private int m_PilesDone = 0;
|
||||
private readonly int m_MinAmount;
|
||||
private readonly int m_MaxAmount;
|
||||
public GoodiesTimer(Point3D center, Map map, int piles, int minAmount, int maxAmount)
|
||||
: base(TimeSpan.FromSeconds(0.25d), TimeSpan.FromSeconds(0.25d))
|
||||
{
|
||||
m_Location = center;
|
||||
m_Map = map;
|
||||
m_PilesMax = piles;
|
||||
m_MinAmount = minAmount;
|
||||
m_MaxAmount = maxAmount;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if(m_PilesDone >= m_PilesMax)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Point3D p = FindGoldLocation(m_Map, m_Location, m_PilesMax / 8);
|
||||
Gold g = new Gold(m_MinAmount, m_MaxAmount);
|
||||
g.MoveToWorld(p, this.m_Map);
|
||||
|
||||
switch (Utility.Random(3))
|
||||
{
|
||||
case 0: // Fire column
|
||||
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), 0x3709, 10, 30, 5052);
|
||||
Effects.PlaySound(g, g.Map, 0x208);
|
||||
break;
|
||||
case 1: // Explosion
|
||||
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), 0x36BD, 20, 10, 5044);
|
||||
Effects.PlaySound(g, g.Map, 0x307);
|
||||
break;
|
||||
case 2: // Ball of fire
|
||||
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), 0x36FE, 10, 10, 5052);
|
||||
break;
|
||||
}
|
||||
++m_PilesDone;
|
||||
}
|
||||
|
||||
private static Point3D FindGoldLocation(Map map, Point3D center, int range)
|
||||
{
|
||||
int cx = center.X;
|
||||
int cy = center.Y;
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
int x = cx + Utility.Random(range * 2) - range;
|
||||
int y = cy + Utility.Random(range * 2) - range;
|
||||
if ((cx - x) * (cx - x) + (cy - y) * (cy - y) > range * range)
|
||||
continue;
|
||||
|
||||
int z = map.GetAverageZ(x, y);
|
||||
if (!map.CanFit(x, y, z, 6, false, false))
|
||||
continue;
|
||||
|
||||
int topZ = z;
|
||||
foreach (Item item in map.GetItemsInRange(new Point3D(x, y, z), 0))
|
||||
{
|
||||
topZ = Math.Max(topZ, item.Z + item.ItemData.CalcHeight);
|
||||
}
|
||||
return new Point3D(x, y, topZ);
|
||||
}
|
||||
return center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
Scripts/Services/ChampionSystem/HarrowerGate.cs
Normal file
64
Scripts/Services/ChampionSystem/HarrowerGate.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class HarrowerGate : Moongate
|
||||
{
|
||||
private Mobile m_Harrower;
|
||||
public HarrowerGate(Mobile harrower, Point3D loc, Map map, Point3D targLoc, Map targMap)
|
||||
: base(targLoc, targMap)
|
||||
{
|
||||
this.m_Harrower = harrower;
|
||||
|
||||
this.Dispellable = false;
|
||||
this.ItemID = 0x1FD4;
|
||||
this.Light = LightType.Circle300;
|
||||
|
||||
this.MoveToWorld(loc, map);
|
||||
}
|
||||
|
||||
public HarrowerGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1049498;
|
||||
}
|
||||
}// dark moongate
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(this.m_Harrower);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Harrower = reader.ReadMobile();
|
||||
|
||||
if (this.m_Harrower == null)
|
||||
this.Delete();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.Light != LightType.Circle300)
|
||||
this.Light = LightType.Circle300;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Scripts/Services/ChampionSystem/RestartTimer.cs
Normal file
20
Scripts/Services/ChampionSystem/RestartTimer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class RestartTimer : Timer
|
||||
{
|
||||
private readonly ChampionSpawn m_Spawn;
|
||||
public RestartTimer(ChampionSpawn spawn, TimeSpan delay)
|
||||
: base(delay)
|
||||
{
|
||||
this.m_Spawn = spawn;
|
||||
this.Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
this.m_Spawn.EndRestart();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Scripts/Services/ChampionSystem/SliceTimer.cs
Normal file
20
Scripts/Services/ChampionSystem/SliceTimer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Engines.CannedEvil
|
||||
{
|
||||
public class SliceTimer : Timer
|
||||
{
|
||||
private readonly ChampionSpawn m_Spawn;
|
||||
public SliceTimer(ChampionSpawn spawn)
|
||||
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
this.m_Spawn = spawn;
|
||||
this.Priority = TimerPriority.OneSecond;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
this.m_Spawn.OnSlice();
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Scripts/Services/ChampionSystem/StarRoomGate.cs
Normal file
113
Scripts/Services/ChampionSystem/StarRoomGate.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class StarRoomGate : Moongate
|
||||
{
|
||||
private bool m_Decays;
|
||||
private DateTime m_DecayTime;
|
||||
private Timer m_Timer;
|
||||
[Constructable]
|
||||
public StarRoomGate()
|
||||
: this(false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public StarRoomGate(bool decays, Point3D loc, Map map)
|
||||
: this(decays)
|
||||
{
|
||||
this.MoveToWorld(loc, map);
|
||||
Effects.PlaySound(loc, map, 0x20E);
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public StarRoomGate(bool decays)
|
||||
: base(new Point3D(5143, 1774, 0), Map.Felucca)
|
||||
{
|
||||
this.Dispellable = false;
|
||||
this.ItemID = 0x1FD4;
|
||||
|
||||
if (decays)
|
||||
{
|
||||
this.m_Decays = true;
|
||||
this.m_DecayTime = DateTime.UtcNow + TimeSpan.FromMinutes(2.0);
|
||||
|
||||
this.m_Timer = new InternalTimer(this, this.m_DecayTime);
|
||||
this.m_Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public StarRoomGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1049498;
|
||||
}
|
||||
}// dark moongate
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (this.m_Timer != null)
|
||||
this.m_Timer.Stop();
|
||||
|
||||
base.OnAfterDelete();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(this.m_Decays);
|
||||
|
||||
if (this.m_Decays)
|
||||
writer.WriteDeltaTime(this.m_DecayTime);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Decays = reader.ReadBool();
|
||||
|
||||
if (this.m_Decays)
|
||||
{
|
||||
this.m_DecayTime = reader.ReadDeltaTime();
|
||||
|
||||
this.m_Timer = new InternalTimer(this, this.m_DecayTime);
|
||||
this.m_Timer.Start();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private readonly Item m_Item;
|
||||
public InternalTimer(Item item, DateTime end)
|
||||
: base(end - DateTime.UtcNow)
|
||||
{
|
||||
this.m_Item = item;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
this.m_Item.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user