Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.MyrmidexInvasion
|
||||
{
|
||||
public class AllegianceIdol : Item
|
||||
{
|
||||
private Allegiance _AllegianceType;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Allegiance AllegianceType
|
||||
{
|
||||
get { return _AllegianceType; }
|
||||
set
|
||||
{
|
||||
_AllegianceType = value;
|
||||
|
||||
if(_AllegianceType == Allegiance.Myrmidex)
|
||||
{
|
||||
ItemID = 9730;
|
||||
Hue = 2503;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemID = 17099;
|
||||
Hue = 0;
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public AllegianceIdol(Allegiance allegiance) : base(allegiance == Allegiance.Myrmidex ? 9730 : 17099)
|
||||
{
|
||||
AllegianceType = allegiance;
|
||||
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if(from is PlayerMobile && from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
AllianceEntry entry = MyrmidexInvasionSystem.GetEntry((PlayerMobile)from);
|
||||
|
||||
if(entry != null)
|
||||
{
|
||||
if (entry.Allegiance == _AllegianceType)
|
||||
{
|
||||
from.SendLocalizedMessage(1156637, String.Format("#{0}", ((int)entry.Allegiance).ToString())); // You have already declared allegiance to the ~1_SIDE~! You may only change your allegiance once every 2 hours.
|
||||
}
|
||||
else if (entry.JoinTime + TimeSpan.FromHours(2) > DateTime.UtcNow)
|
||||
{
|
||||
from.SendLocalizedMessage(1156633); // You cannot declare allegiance to that side.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump(
|
||||
new ConfirmCallbackGump((PlayerMobile)from,
|
||||
(int)_AllegianceType,
|
||||
String.Format("Your current allegiance is with the {0}. Select yes to pledge your allegiance to the {1}.", entry.Allegiance == Allegiance.Tribes ? "Eodonians" : "Myrmidex", _AllegianceType == Allegiance.Tribes ? "Eodonians" : "Myrmidex"),
|
||||
entry,
|
||||
confirm: (m, state) =>
|
||||
{
|
||||
if (m.Region.IsPartOf<BattleRegion>())
|
||||
{
|
||||
m.SendLocalizedMessage(1156632); // You cannot switch allegiance in the midst of the battle field!
|
||||
}
|
||||
else
|
||||
{
|
||||
MyrmidexInvasionSystem.System.Join((PlayerMobile)from, this.AllegianceType);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
MyrmidexInvasionSystem.System.Join((PlayerMobile)from, _AllegianceType);
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage(1149687); //You are too far away.
|
||||
}
|
||||
|
||||
public override void AddNameProperty( ObjectPropertyList list )
|
||||
{
|
||||
list.Add(1156640, "#1156638"); // ~1_TEAMS~ Allegiance Idol
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1156639); // Double click to declare or check allegiance
|
||||
}
|
||||
|
||||
public AllegianceIdol(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write((int)_AllegianceType);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int v = reader.ReadInt();
|
||||
|
||||
_AllegianceType = (Allegiance)reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.MyrmidexInvasion
|
||||
{
|
||||
public class BattleFlag : Item
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BattleSpawner BattleSpawner { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Allegiance Allegiance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BattleSpawner != null)
|
||||
{
|
||||
if (this == BattleSpawner.MyrmidexFlag)
|
||||
return Allegiance.Myrmidex;
|
||||
|
||||
return Allegiance.Tribes;
|
||||
}
|
||||
|
||||
return Allegiance.None;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime NextSpawn { get; set; }
|
||||
|
||||
[Constructable]
|
||||
public BattleFlag(int itemid, int hue)
|
||||
: base(itemid)
|
||||
{
|
||||
Hue = hue;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (m.InRange(Location, 3))
|
||||
{
|
||||
BattleSpawner spawner = BattleSpawner.Instance;
|
||||
|
||||
if (spawner != null)
|
||||
{
|
||||
DisplayWaveInfo(spawner, m);
|
||||
}
|
||||
}
|
||||
else
|
||||
m.SendLocalizedMessage(500618); // That is too far away!
|
||||
}
|
||||
|
||||
public static void DisplayWaveInfo(BattleSpawner spawner, Mobile m)
|
||||
{
|
||||
int delay = 0;
|
||||
foreach (var kvp in spawner.MyrmidexTeam)
|
||||
{
|
||||
if (kvp.Value.Count > 0)
|
||||
{
|
||||
int wave = kvp.Key + 1;
|
||||
int count = kvp.Value.Where(bc => bc.Alive).Count();
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(delay), () =>
|
||||
{
|
||||
m.SendLocalizedMessage(1156606, String.Format("{0}\t{1}\t{2}", (BattleSpawner.WaveCount - count).ToString(), BattleSpawner.WaveCount.ToString(), wave.ToString())); // Myrmidex have lost ~1_VAL~ of ~2_VAL~ from wave ~3_VAL~ of their front line.
|
||||
});
|
||||
}
|
||||
|
||||
delay++;
|
||||
}
|
||||
|
||||
delay = 0;
|
||||
foreach (var kvp in spawner.TribeTeam)
|
||||
{
|
||||
if (kvp.Value.Count > 0)
|
||||
{
|
||||
int wave = kvp.Key + 1;
|
||||
int count = kvp.Value.Where(bc => bc.Alive).Count();
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(delay), () =>
|
||||
{
|
||||
m.SendLocalizedMessage(1156607, String.Format("{0}\t{1}\t{2}", (BattleSpawner.WaveCount - count).ToString(), BattleSpawner.WaveCount.ToString(), wave.ToString())); // Myrmidex have lost ~1_VAL~ of ~2_VAL~ from wave ~3_VAL~ of their front line.
|
||||
});
|
||||
}
|
||||
|
||||
delay++;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement { get { return BattleSpawner != null && NextSpawn < DateTime.UtcNow; } }
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m is BaseCreature && NextSpawn < DateTime.UtcNow)
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
Point3D check = Allegiance == Allegiance.Myrmidex ? new Point3D(914, 1807, 0) : Location;
|
||||
|
||||
if (this.Allegiance == Allegiance.Myrmidex && bc.InRange(check, 8))
|
||||
{
|
||||
if (bc is BritannianInfantry || (bc is BaseEodonTribesman && ((BaseEodonTribesman)bc).TribeType != EodonTribe.Barrab))
|
||||
{
|
||||
Spawn(false, typeof(MyrmidexDrone), typeof(MyrmidexWarrior), typeof(TribeWarrior));
|
||||
}
|
||||
}
|
||||
else if (this.Allegiance == Allegiance.Tribes && bc.InRange(check, 8))
|
||||
{
|
||||
if (bc is MyrmidexDrone || bc is MyrmidexWarrior || (bc is BaseEodonTribesman && ((BaseEodonTribesman)bc).TribeType == EodonTribe.Barrab))
|
||||
{
|
||||
Spawn(true, typeof(BritannianInfantry));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Spawn(bool tribe, params Type[] types)
|
||||
{
|
||||
if (Map == null)
|
||||
return;
|
||||
|
||||
NextSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(10);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Type t = types[Utility.Random(types.Length)];
|
||||
BaseCreature bc = null;
|
||||
|
||||
if (t.IsSubclassOf(typeof(BaseEodonTribesman)))
|
||||
bc = Activator.CreateInstance(t, new object[] { EodonTribe.Barrab }) as BaseCreature;
|
||||
else
|
||||
bc = Activator.CreateInstance(t) as BaseCreature;
|
||||
|
||||
if (bc != null)
|
||||
{
|
||||
Rectangle2D rec = new Rectangle2D(this.X, this.Y, 3, 3);
|
||||
Point3D p = this.Location;
|
||||
|
||||
bc.NoLootOnDeath = true;
|
||||
|
||||
do
|
||||
{
|
||||
p = this.Map.GetRandomSpawnPoint(rec);
|
||||
}
|
||||
while (p == this.Location || !this.Map.CanSpawnMobile(p));
|
||||
|
||||
bc.MoveToWorld(p, this.Map);
|
||||
|
||||
if (tribe)
|
||||
{
|
||||
bc.Home = new Point3D(914, 1872, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bc.Home = new Point3D(913, 1792, 0);
|
||||
}
|
||||
|
||||
bc.RangeHome = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BattleFlag(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(1);
|
||||
|
||||
writer.Write(NextSpawn);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (version > 0)
|
||||
NextSpawn = reader.ReadDateTime();
|
||||
else
|
||||
NextSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using System.Collections.Generic;
|
||||
using Server.Regions;
|
||||
using System.Xml;
|
||||
|
||||
namespace Server.Engines.MyrmidexInvasion
|
||||
{
|
||||
public class BattleRegion : DungeonRegion
|
||||
{
|
||||
public BattleSpawner Spawner { get; set; }
|
||||
|
||||
public BattleRegion(XmlElement xml, Map map, Region parent)
|
||||
: base(xml, map, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDeath(Mobile m)
|
||||
{
|
||||
base.OnDeath(m);
|
||||
|
||||
bool nomaster = m is BaseCreature && ((BaseCreature)m).GetMaster() == null;
|
||||
|
||||
if (BattleSpawner.Instance != null && BattleSpawner.Instance.Active && nomaster && Spawner != null)
|
||||
{
|
||||
Timer.DelayCall<BaseCreature>(TimeSpan.FromSeconds(.25), Spawner.RegisterDeath, (BaseCreature)m);
|
||||
}
|
||||
|
||||
// the delay ensures the corpse is created after death
|
||||
Timer.DelayCall(() =>
|
||||
{
|
||||
if (m.Corpse != null && (m is BritannianInfantry || m is TribeWarrior || m is TribeShaman || m is TribeChieftan || m is MyrmidexDrone || m is MyrmidexWarrior))
|
||||
{
|
||||
Mobile killer = m.LastKiller;
|
||||
|
||||
if (killer == null || (killer is BaseCreature && !(((BaseCreature)killer).GetMaster() is PlayerMobile)))
|
||||
{
|
||||
m.Corpse.Delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile && Spawner != null)
|
||||
Spawner.OnLeaveRegion((PlayerMobile)m);
|
||||
|
||||
base.OnExit(m);
|
||||
}
|
||||
|
||||
public override bool OnDamage(Mobile m, ref int Damage)
|
||||
{
|
||||
Mobile attacker = m.FindMostRecentDamager(false);
|
||||
|
||||
if (MyrmidexInvasionSystem.AreEnemies(m, attacker) && EodonianPotion.IsUnderEffects(attacker, PotionEffect.Kurak))
|
||||
{
|
||||
Damage *= 3;
|
||||
|
||||
if (Damage > 0)
|
||||
m.FixedEffect(0x37B9, 10, 5);
|
||||
}
|
||||
|
||||
return base.OnDamage(m, ref Damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,585 @@
|
||||
using Server;
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class MoonstonePowerGeneratorAddon : BaseAddon
|
||||
{
|
||||
public override bool ShareHue { get { return false; } }
|
||||
|
||||
public Timer ActiveTimer { get; set; }
|
||||
public InternalComponent Activator1 { get; set; }
|
||||
public InternalComponent Activator2 { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Activated { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool SetActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return Activated;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (ActiveTimer != null)
|
||||
{
|
||||
ActiveTimer.Stop();
|
||||
ActiveTimer = null;
|
||||
}
|
||||
|
||||
Activated = true;
|
||||
CheckNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Link { get; set; }
|
||||
|
||||
public MoonstonePowerGenerator Generator { get; set; }
|
||||
|
||||
[Constructable]
|
||||
public MoonstonePowerGeneratorAddon(bool link)
|
||||
{
|
||||
AddonComponent c = new AddonComponent(39759);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 0, 0, 0);
|
||||
|
||||
c = new AddonComponent(39759);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, -1, 0, 0);
|
||||
|
||||
c = new AddonComponent(39759);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 1, 0, 0);
|
||||
|
||||
c = new AddonComponent(39759);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 0, -1, 0);
|
||||
|
||||
c = new AddonComponent(39759);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 0, 1, 0);
|
||||
|
||||
c = new AddonComponent(39818);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, -1, -1, 0);
|
||||
|
||||
c = new AddonComponent(39818);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, -1, 1, 0);
|
||||
|
||||
c = new AddonComponent(39818);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 1, -1, 0);
|
||||
|
||||
c = new AddonComponent(39818);
|
||||
c.Hue = 2955;
|
||||
AddComponent(c, 1, 1, 0);
|
||||
|
||||
Activator1 = new InternalComponent(40158);
|
||||
Activator2 = new InternalComponent(40203);
|
||||
|
||||
AddComponent(Activator1, 0, -1, 5);
|
||||
AddComponent(Activator2, 0, 1, 5);
|
||||
|
||||
AddComponent(new LocalizedAddonComponent(40155, 1156623), 1, 0, 5);
|
||||
AddComponent(new LocalizedAddonComponent(40155, 1156623), -1, 0, 5);
|
||||
|
||||
AddComponent(new LocalizedAddonComponent(40156, 1156628), -1, 0, 10);
|
||||
AddComponent(new LocalizedAddonComponent(40156, 1156628), 1, 0, 10);
|
||||
|
||||
//AddComponent(new LocalizedAddonComponent(40147, 1124171), 0, 0, 5);
|
||||
AddComponent(new LocalizedAddonComponent(40157, 1124171), 0, 0, 20);
|
||||
|
||||
Generator = new MoonstonePowerGenerator(this);
|
||||
|
||||
Link = link;
|
||||
|
||||
if (link)
|
||||
Generators.Add(this);
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldlocation)
|
||||
{
|
||||
base.OnLocationChange(oldlocation);
|
||||
|
||||
if (Generator != null && !Generator.Deleted)
|
||||
{
|
||||
Generator.MoveToWorld(new Point3D(this.X, this.Y, this.Z + 5), this.Map);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
|
||||
if (Generator != null && !Generator.Deleted)
|
||||
{
|
||||
Generator.Map = this.Map;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnComponentUsed(AddonComponent component, Mobile from)
|
||||
{
|
||||
if (!Activated && component != null && component is InternalComponent && from.InRange(component.Location, 2))
|
||||
{
|
||||
InternalComponent comp = component as InternalComponent;
|
||||
|
||||
if (!comp.Active)
|
||||
{
|
||||
comp.Active = true;
|
||||
comp.WhoActivated = from;
|
||||
|
||||
if (Activator1.Active && Activator2.Active && Activator1.WhoActivated != Activator2.WhoActivated)
|
||||
{
|
||||
if (ActiveTimer != null)
|
||||
{
|
||||
ActiveTimer.Stop();
|
||||
ActiveTimer = null;
|
||||
}
|
||||
|
||||
Activated = true;
|
||||
CheckNetwork();
|
||||
}
|
||||
else if (ActiveTimer == null)
|
||||
ActiveTimer = Timer.DelayCall(TimeSpan.FromSeconds(1), Reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
if (Activator1 != null)
|
||||
Activator1.Active = false;
|
||||
|
||||
if (Activator2 != null)
|
||||
Activator2.Active = false;
|
||||
|
||||
ActiveTimer = null;
|
||||
}
|
||||
|
||||
public class InternalComponent : LocalizedAddonComponent
|
||||
{
|
||||
private bool _Active;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Active
|
||||
{
|
||||
get { return _Active; }
|
||||
set
|
||||
{
|
||||
if (!_Active && value)
|
||||
{
|
||||
ItemID = ActiveID;
|
||||
Effects.PlaySound(this.Location, this.Map, 0x051);
|
||||
}
|
||||
else if (_Active && !value)
|
||||
{
|
||||
ItemID = InactiveID;
|
||||
WhoActivated = null;
|
||||
Effects.PlaySound(this.Location, this.Map, 0x051);
|
||||
}
|
||||
|
||||
_Active = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile WhoActivated { get; set; }
|
||||
|
||||
public int ActiveID { get; set; }
|
||||
public int InactiveID { get; set; }
|
||||
|
||||
public InternalComponent(int itemid)
|
||||
: base(itemid, 1156624)
|
||||
{
|
||||
InactiveID = itemid;
|
||||
|
||||
if (itemid == 40203)
|
||||
ActiveID = 40158;
|
||||
else
|
||||
ActiveID = 40203;
|
||||
}
|
||||
|
||||
public InternalComponent(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(ActiveID);
|
||||
writer.Write(InactiveID);
|
||||
|
||||
writer.Write(_Active);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int v = reader.ReadInt();
|
||||
|
||||
ActiveID = reader.ReadInt();
|
||||
InactiveID = reader.ReadInt();
|
||||
|
||||
Active = reader.ReadBool();
|
||||
|
||||
MoonstonePowerGeneratorAddon chamber = Addon as MoonstonePowerGeneratorAddon;
|
||||
|
||||
if (chamber != null)
|
||||
{
|
||||
if (chamber.Activator1 == null)
|
||||
chamber.Activator1 = this;
|
||||
else
|
||||
chamber.Activator2 = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
base.Delete();
|
||||
|
||||
if (Generators.Contains(this))
|
||||
Generators.Remove(this);
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
Generators = new List<MoonstonePowerGeneratorAddon>();
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
bool active = true;
|
||||
|
||||
foreach (MoonstonePowerGeneratorAddon c in Generators)
|
||||
{
|
||||
if (!c.Activated)
|
||||
{
|
||||
active = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!active)
|
||||
{
|
||||
ResetGenerators(true);
|
||||
}
|
||||
else if (Boss == null)
|
||||
{
|
||||
ResetGenerators();
|
||||
}
|
||||
|
||||
CommandSystem.Register("ActivateChambers", AccessLevel.Administrator, e =>
|
||||
{
|
||||
if (Boss == null)
|
||||
{
|
||||
Generators.ForEach(c => c.Activated = true);
|
||||
CheckNetwork();
|
||||
}
|
||||
});
|
||||
|
||||
CommandSystem.Register("MorphChamberItems", AccessLevel.Administrator, e =>
|
||||
{
|
||||
MorphItems();
|
||||
});
|
||||
}
|
||||
|
||||
public static List<MoonstonePowerGeneratorAddon> Generators { get; set; }
|
||||
public static Zipactriotl Boss { get; set; }
|
||||
|
||||
public static readonly Point3D GroundZero = new Point3D(896, 2304, -19);
|
||||
|
||||
public static void CheckNetwork()
|
||||
{
|
||||
bool allactive = true;
|
||||
|
||||
foreach (MoonstonePowerGeneratorAddon c in Generators)
|
||||
{
|
||||
if (!c.Activated)
|
||||
{
|
||||
allactive = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allactive)
|
||||
{
|
||||
Boss = new Zipactriotl(true);
|
||||
Boss.MoveToWorld(new Point3D(899, 2303, -20), Map.TerMur);
|
||||
|
||||
foreach (var c in Generators.Where(c => c.Generator != null))
|
||||
{
|
||||
c.Generator.CanSpawn = true;
|
||||
}
|
||||
|
||||
MorphItems();
|
||||
}
|
||||
}
|
||||
|
||||
public static void MorphItems()
|
||||
{
|
||||
IPooledEnumerable eable = Map.TerMur.GetItemsInRange(GroundZero, 15);
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (item.ItemID == 40161)
|
||||
item.ItemID = 40159;
|
||||
else if (item.ItemID == 40142)
|
||||
item.ItemID = 40173;
|
||||
else if (item.ItemID == 40169)
|
||||
item.ItemID = 40174;
|
||||
else if (item.ItemID == 40165)
|
||||
item.ItemID = 40160;
|
||||
|
||||
else if (item.ItemID == 40159)
|
||||
item.ItemID = 40161;
|
||||
else if (item.ItemID == 40173)
|
||||
item.ItemID = 40142;
|
||||
else if (item.ItemID == 40174)
|
||||
item.ItemID = 40169;
|
||||
else if (item.ItemID == 40160)
|
||||
item.ItemID = 40165;
|
||||
}
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
public static void ResetGenerators(bool startup = false)
|
||||
{
|
||||
Generators.ForEach(c =>
|
||||
{
|
||||
c.Activated = false;
|
||||
c.Reset();
|
||||
|
||||
if (c.Generator == null || c.Generator.Deleted)
|
||||
{
|
||||
c.Generator = new MoonstonePowerGenerator(c);
|
||||
c.Generator.MoveToWorld(new Point3D(c.X, c.Y, c.Z + 5), c.Map);
|
||||
}
|
||||
|
||||
c.Generator.CanSpawn = false;
|
||||
|
||||
c.Components.ForEach(comp =>
|
||||
{
|
||||
if (!comp.Visible)
|
||||
comp.Visible = true;
|
||||
});
|
||||
});
|
||||
|
||||
if(!startup)
|
||||
MorphItems();
|
||||
|
||||
if (Boss != null)
|
||||
Boss = null;
|
||||
}
|
||||
|
||||
public MoonstonePowerGeneratorAddon(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(Activated);
|
||||
writer.Write(Link);
|
||||
writer.Write(Generator);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int v = reader.ReadInt();
|
||||
|
||||
Activated = reader.ReadBool();
|
||||
|
||||
if (reader.ReadBool())
|
||||
{
|
||||
Generators.Add(this);
|
||||
Link = true;
|
||||
}
|
||||
|
||||
Generator = reader.ReadItem() as MoonstonePowerGenerator;
|
||||
|
||||
if (Generator != null)
|
||||
Generator.Addon = this;
|
||||
}
|
||||
}
|
||||
|
||||
public class MoonstonePowerGenerator : DamageableItem
|
||||
{
|
||||
public override int LabelNumber { get { return 1156854; } } // Moonstone Power Generator
|
||||
|
||||
public List<BaseCreature> Spawn;
|
||||
public Timer Timer { get; set; }
|
||||
|
||||
private bool _CanSpawn;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool CanSpawn
|
||||
{
|
||||
get { return _CanSpawn; }
|
||||
set
|
||||
{
|
||||
_CanSpawn = value;
|
||||
|
||||
if (_CanSpawn)
|
||||
{
|
||||
Spawn = new List<BaseCreature>();
|
||||
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
Timer = Timer.DelayCall(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30), OnTick);
|
||||
Timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public MoonstonePowerGeneratorAddon Addon
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public MoonstonePowerGenerator(MoonstonePowerGeneratorAddon addon = null)
|
||||
: base(40147, 40153)
|
||||
{
|
||||
Addon = addon;
|
||||
|
||||
Level = ItemLevel.Average;
|
||||
Name = "Moonstone Power Generator";
|
||||
}
|
||||
|
||||
public void OnTick()
|
||||
{
|
||||
if (Spawn.Count >= 7 || this.Deleted || this.Map == null)
|
||||
return;
|
||||
|
||||
IPooledEnumerable eable = this.Map.GetMobilesInRange(this.Location, 8);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
if (m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile))
|
||||
{
|
||||
DoSpawn();
|
||||
break;
|
||||
}
|
||||
}
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
private void DoSpawn()
|
||||
{
|
||||
if (Spawn.Count >= 7 || this.Deleted || this.Map == null)
|
||||
return;
|
||||
|
||||
BaseCreature bc = new IgnisFatalis();
|
||||
|
||||
int x = Utility.RandomBool() ? 2 : -2;
|
||||
int y = Utility.RandomBool() ? 2 : -2;
|
||||
|
||||
bc.MoveToWorld(new Point3D(this.X + x, this.Y + y, this.Map.GetAverageZ(x, y)), this.Map);
|
||||
Spawn.Add(bc);
|
||||
}
|
||||
|
||||
public override void OnDamage(int amount, Mobile from, bool willkill)
|
||||
{
|
||||
base.OnDamage(amount, from, willkill);
|
||||
|
||||
int oldhits = Hits;
|
||||
|
||||
if (this.ItemID == IDHalfHits && this.Hits <= (HitsMax * .10))
|
||||
{
|
||||
ItemID = 40154;
|
||||
}
|
||||
|
||||
if (0.033 > Utility.RandomDouble())
|
||||
{
|
||||
from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 0x23, 1156855, from.NetState); // *Arcing energy from the generator zaps you!*
|
||||
AOS.Damage(from, Utility.RandomMinMax(50, 100), 0, 0, 0, 0, 100);
|
||||
from.FixedParticles(0x3818, 1, 11, 0x13A8, 0, 0, EffectLayer.Waist);
|
||||
Effects.PlaySound(this.Location, this.Map, 0x1DC);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDestroyed()
|
||||
{
|
||||
Effects.PlaySound(this.Location, this.Map, 0x665);
|
||||
|
||||
if (Spawn != null)
|
||||
{
|
||||
Spawn.ForEach(bc =>
|
||||
{
|
||||
if(bc != null && bc.Alive)
|
||||
bc.Kill();
|
||||
});
|
||||
|
||||
Spawn.Clear();
|
||||
Spawn.TrimExcess();
|
||||
Spawn = null;
|
||||
}
|
||||
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
if (Addon != null)
|
||||
{
|
||||
AddonComponent comp = Addon.Components.FirstOrDefault(c => c.ItemID == 40157);
|
||||
|
||||
if (comp != null)
|
||||
comp.Visible = false;
|
||||
}
|
||||
|
||||
base.OnAfterDestroyed();
|
||||
}
|
||||
|
||||
public MoonstonePowerGenerator(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 v = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Targeting;
|
||||
using Server.Gumps;
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Engines.MyrmidexInvasion
|
||||
{
|
||||
public enum Allegiance
|
||||
{
|
||||
None = 0,
|
||||
Myrmidex = 1156634,
|
||||
Tribes = 1156635
|
||||
}
|
||||
|
||||
public class MyrmidexInvasionSystem
|
||||
{
|
||||
public static readonly bool Active = true;
|
||||
|
||||
public static string FilePath = Path.Combine("Saves", "MyrmidexInvasion.bin");
|
||||
public static MyrmidexInvasionSystem System { get; set; }
|
||||
|
||||
public static List<AllianceEntry> AllianceEntries { get; set; }
|
||||
|
||||
public MyrmidexInvasionSystem()
|
||||
{
|
||||
AllianceEntries = new List<AllianceEntry>();
|
||||
}
|
||||
|
||||
public void Join(PlayerMobile pm, Allegiance type)
|
||||
{
|
||||
AllianceEntry entry = GetEntry(pm);
|
||||
|
||||
if(entry != null)
|
||||
AllianceEntries.Remove(entry);
|
||||
|
||||
pm.SendLocalizedMessage(1156636, String.Format("#{0}", ((int)type).ToString())); // You have declared allegiance to the ~1_SIDE~! You may only change your allegiance once every 2 hours.
|
||||
|
||||
AllianceEntries.Add(new AllianceEntry(pm, type));
|
||||
}
|
||||
|
||||
public static bool IsAlliedWith(Mobile a, Mobile b)
|
||||
{
|
||||
return (IsAlliedWithMyrmidex(a) && IsAlliedWithMyrmidex(b)) || (IsAlliedWithEodonTribes(a) && IsAlliedWithEodonTribes(b));
|
||||
}
|
||||
|
||||
public static bool AreEnemies(Mobile a, Mobile b)
|
||||
{
|
||||
if ((IsAlliedWithEodonTribes(a) && !IsAlliedWithMyrmidex(b)) || (IsAlliedWithEodonTribes(b) && !IsAlliedWithMyrmidex(a)) ||
|
||||
(IsAlliedWithMyrmidex(a) && !IsAlliedWithEodonTribes(b)))
|
||||
return false;
|
||||
|
||||
return !IsAlliedWith(a, b);
|
||||
}
|
||||
|
||||
public static bool IsAlliedWith(Mobile m, Allegiance allegiance)
|
||||
{
|
||||
return allegiance == Allegiance.Myrmidex ? IsAlliedWithMyrmidex(m) : IsAlliedWithEodonTribes(m);
|
||||
}
|
||||
|
||||
public static bool IsAlliedWithMyrmidex(Mobile m)
|
||||
{
|
||||
if(m is BaseCreature)
|
||||
{
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
|
||||
if(bc.GetMaster() != null)
|
||||
return IsAlliedWithMyrmidex(bc.GetMaster());
|
||||
|
||||
return m is MyrmidexLarvae || m is MyrmidexWarrior || m is MyrmidexQueen || m is MyrmidexDrone || (m is BaseEodonTribesman && ((BaseEodonTribesman)m).TribeType == EodonTribe.Barrab);
|
||||
}
|
||||
|
||||
AllianceEntry entry = GetEntry(m as PlayerMobile);
|
||||
|
||||
return entry != null && entry.Allegiance == Allegiance.Myrmidex;
|
||||
}
|
||||
|
||||
public static bool IsAlliedWithEodonTribes(Mobile m)
|
||||
{
|
||||
if(m is BaseCreature)
|
||||
{
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
|
||||
if(bc.GetMaster() != null)
|
||||
return IsAlliedWithEodonTribes(bc.GetMaster());
|
||||
|
||||
return (m is BaseEodonTribesman && ((BaseEodonTribesman)m).TribeType != EodonTribe.Barrab) || m is BritannianInfantry;
|
||||
}
|
||||
|
||||
AllianceEntry entry = GetEntry(m as PlayerMobile);
|
||||
|
||||
return entry != null && entry.Allegiance == Allegiance.Tribes;
|
||||
}
|
||||
|
||||
public static bool CanRecieveQuest(PlayerMobile pm, Allegiance allegiance)
|
||||
{
|
||||
AllianceEntry entry = GetEntry(pm);
|
||||
|
||||
return entry != null && entry.Allegiance == allegiance && entry.CanRecieveQuest;
|
||||
}
|
||||
|
||||
public static AllianceEntry GetEntry(PlayerMobile pm)
|
||||
{
|
||||
if(pm == null)
|
||||
return null;
|
||||
|
||||
return AllianceEntries.FirstOrDefault(e => e.Player == pm);
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
System = new MyrmidexInvasionSystem();
|
||||
|
||||
EventSink.WorldSave += OnSave;
|
||||
EventSink.WorldLoad += OnLoad;
|
||||
|
||||
CommandSystem.Register("GetAllianceEntry", AccessLevel.GameMaster, e =>
|
||||
{
|
||||
e.Mobile.BeginTarget(10, false, TargetFlags.None, (from, targeted) =>
|
||||
{
|
||||
if (targeted is PlayerMobile)
|
||||
{
|
||||
AllianceEntry entry = GetEntry((PlayerMobile)targeted);
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
((PlayerMobile)targeted).SendGump(new PropertiesGump((PlayerMobile)targeted, entry));
|
||||
}
|
||||
else
|
||||
e.Mobile.SendMessage("They don't belong to an alliance.");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void OnSave(WorldSaveEventArgs e)
|
||||
{
|
||||
Persistence.Serialize(
|
||||
FilePath,
|
||||
writer =>
|
||||
{
|
||||
writer.Write((int)0);
|
||||
|
||||
writer.Write(AllianceEntries.Count);
|
||||
AllianceEntries.ForEach(entry => entry.Serialize(writer));
|
||||
|
||||
writer.Write(MoonstonePowerGeneratorAddon.Boss);
|
||||
});
|
||||
}
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
Persistence.Deserialize(
|
||||
FilePath,
|
||||
reader =>
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
AllianceEntry entry = new AllianceEntry(reader);
|
||||
|
||||
if(entry.Player != null)
|
||||
AllianceEntries.Add(entry);
|
||||
}
|
||||
|
||||
MoonstonePowerGeneratorAddon.Boss = reader.ReadMobile() as Zipactriotl;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[PropertyObject]
|
||||
public class AllianceEntry
|
||||
{
|
||||
public PlayerMobile Player { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Allegiance Allegiance { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime JoinTime { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool CanRecieveQuest { get; set; }
|
||||
|
||||
public AllianceEntry(PlayerMobile pm, Allegiance allegiance)
|
||||
{
|
||||
Player = pm;
|
||||
Allegiance = allegiance;
|
||||
JoinTime = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public AllianceEntry(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Player = reader.ReadMobile() as PlayerMobile;
|
||||
Allegiance = (Allegiance)reader.ReadInt();
|
||||
JoinTime = reader.ReadDateTime();
|
||||
CanRecieveQuest = reader.ReadBool();
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(Player);
|
||||
writer.Write((int)Allegiance);
|
||||
writer.Write(JoinTime);
|
||||
writer.Write(CanRecieveQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user