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 mobile) { AllianceEntry entry = GetEntry(mobile); if (entry != null) { mobile.SendGump(new PropertiesGump(mobile, entry)); } else { e.Mobile.SendMessage("They don't belong to an alliance."); } } }); }); }
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 IsAlliedWithEodonTribes(Mobile m) { if (m is BaseCreature bc) { if (bc.GetMaster() != null) { return(IsAlliedWithEodonTribes(bc.GetMaster())); } return(bc is BaseEodonTribesman tribesman && tribesman.TribeType != EodonTribe.Barrab || bc is BritannianInfantry); } AllianceEntry entry = GetEntry(m as PlayerMobile); return(entry != null && entry.Allegiance == Allegiance.Tribes); }
public static bool IsAlliedWithMyrmidex(Mobile m) { if (m is BaseCreature bc) { if (bc.GetMaster() != null) { return(IsAlliedWithMyrmidex(bc.GetMaster())); } return(bc is MyrmidexLarvae || bc is MyrmidexWarrior || bc is MyrmidexQueen || bc is MyrmidexDrone || bc is BaseEodonTribesman man && man.TribeType == EodonTribe.Barrab); } AllianceEntry entry = GetEntry(m as PlayerMobile); return(entry != null && entry.Allegiance == Allegiance.Myrmidex); }
public void CheckAdvance() { List <BaseCreature> list = GetAll(Allegiance.Myrmidex); IEnumerable <PlayerMobile> winners = null; foreach (BaseCreature bc in list.Where(b => IsInMyrmidexObjective(b.Location) && 0.25 > Utility.RandomDouble())) { ClearWave(Allegiance.Myrmidex, GetWave(MyrmidexTeam, bc)); winners = GetPlayers(Allegiance.Myrmidex); RegionMessage(1156630); // The Myrmidex are victorious! If you are allied to the Myrmidex visit the Tinker in the Barrab village to continue the quest! Otherwise, continue the fight until your team is victorious! break; } if (winners == null) { ColUtility.Free(list); list = GetAll(Allegiance.Tribes); foreach (BaseCreature bc in list.Where(b => IsInTribalObjective(b.Location) && 0.25 > Utility.RandomDouble())) { ClearWave(Allegiance.Tribes, GetWave(TribeTeam, bc)); winners = GetPlayers(Allegiance.Tribes); RegionMessage(1156631); // The Eodonians are victorious! If you are allied to the Eodonians visit the Tinker in the Barrab village to continue the quest! Otherwise, continue the fight until your team is victorious! break; } } if (winners != null) { ColUtility.ForEach(winners.Where(pm => Players.ContainsKey(pm) && Players[pm] > MinCredit), pm => { AllianceEntry entry = MyrmidexInvasionSystem.GetEntry(pm); if (entry != null && !entry.CanRecieveQuest) { entry.CanRecieveQuest = true; } if (Players.ContainsKey(pm)) { Players.Remove(pm); } }); } ColUtility.Free(list); }
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, AllegianceType); } })); } } else { MyrmidexInvasionSystem.System.Join((PlayerMobile)from, _AllegianceType); } } else { from.SendLocalizedMessage(1149687); //You are too far away. } }
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; }); }
public void CheckAdvance() { List <BaseCreature> myrmidex = GetAll(Allegiance.Myrmidex); List <BaseCreature> tribes = GetAll(Allegiance.Tribes); IEnumerable <PlayerMobile> winners = null; Dictionary <int, BaseCreature> hasBreached = new Dictionary <int, BaseCreature>(); bool opposedBreach = false; IPooledEnumerable eable = this.Map.GetMobilesInBounds(_MyrmidexObjective); foreach (Mobile m in eable) { if (m is BaseCreature && tribes.Contains((BaseCreature)m)) { opposedBreach = true; break; // once its opposed, no winner } else if (m is BaseCreature && myrmidex.Contains((BaseCreature)m)) { int wave = GetWave(MyrmidexTeam, ((BaseCreature)m)); hasBreached[wave] = (BaseCreature)m; } } if (hasBreached.Count > 0 && !opposedBreach) { foreach (var kvp in hasBreached) { ClearWave(Allegiance.Myrmidex, GetWave(MyrmidexTeam, kvp.Value)); } winners = GetPlayers(Allegiance.Myrmidex); RegionMessage(1156630); // The Myrmidex are victorious! If you are allied to the Myrmidex visit the Tinker in the Barrab village to continue the quest! Otherwise, continue the fight until your team is victorious! } eable.Free(); hasBreached.Clear(); opposedBreach = false; if (winners == null) { eable = this.Map.GetMobilesInBounds(_TribalObjective); foreach (Mobile m in eable) { if (m is BaseCreature && myrmidex.Contains((BaseCreature)m)) { opposedBreach = true; break; // once its opposed, no winner } else if (m is BaseCreature && tribes.Contains((BaseCreature)m)) { int wave = GetWave(TribeTeam, ((BaseCreature)m)); hasBreached[wave] = (BaseCreature)m; } } if (hasBreached.Count > 0 && !opposedBreach) { foreach (var kvp in hasBreached) { ClearWave(Allegiance.Tribes, GetWave(TribeTeam, kvp.Value)); } winners = GetPlayers(Allegiance.Tribes); RegionMessage(1156631); // The Eodonians are victorious! If you are allied to the Eodonians visit Professor Raffkin in Sir Geoffrey's camp to continue the quest! Otherwise, continue the fight until your team is victorious! } } eable.Free(); hasBreached.Clear(); if (winners != null) { ColUtility.ForEach(winners.Where(pm => Players.ContainsKey(pm) && Players[pm] > MinCredit), pm => { AllianceEntry entry = MyrmidexInvasionSystem.GetEntry(pm); if (entry != null && !entry.CanRecieveQuest) { entry.CanRecieveQuest = true; } if (Players.ContainsKey(pm)) { Players.Remove(pm); } }); } ColUtility.Free(myrmidex); ColUtility.Free(tribes); }
public static bool CanRecieveQuest(PlayerMobile pm, Allegiance allegiance) { AllianceEntry entry = GetEntry(pm); return(entry != null && entry.Allegiance == allegiance && entry.CanRecieveQuest); }