public override void OnDoubleClick(Mobile from) { if (m_Faction == null) { return; } if (!from.InRange(GetWorldLocation(), 2)) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } else if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (from is PlayerMobile) { Faction existingFaction = Faction.Find(from); if (existingFaction == m_Faction || from.AccessLevel >= AccessLevel.GameMaster) { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.IsLeaving) { from.SendLocalizedMessage(1005051); // You cannot use the faction stone until you have finished quitting your current faction } else { from.SendGump(new FactionStoneGump((PlayerMobile)from, m_Faction)); } } else if (existingFaction != null) { // TODO: Validate from.SendLocalizedMessage(1005053); // This is not your faction stone! } else { from.SendGump(new JoinStoneGump((PlayerMobile)from, m_Faction)); } } }
public override bool IsEnemy(Mobile m) { Faction ourFaction = m_Faction; Faction theirFaction = Faction.Find(m); if (theirFaction == null && m is BaseFactionGuard) { theirFaction = ((BaseFactionGuard)m).Faction; } if (ourFaction != null && theirFaction != null && ourFaction != theirFaction) { ReactionType reactionType = Orders.GetReaction(theirFaction).Type; if (reactionType == ReactionType.Attack) { return(true); } if (theirFaction != null) { List <AggressorInfo> list = m.Aggressed; for (int i = 0; i < list.Count; ++i) { AggressorInfo ai = list[i]; if (ai.Defender is BaseFactionGuard) { BaseFactionGuard bf = (BaseFactionGuard)ai.Defender; if (bf.Faction == ourFaction) { return(true); } } } } } return(false); }
public override void OnDoubleClick(Mobile from) { if (m_Faction == null) { return; } if (!from.InRange(GetWorldLocation(), 2)) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } else if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (Faction.Find(from) == null && from is PlayerMobile) { from.SendGump(new JoinStoneGump((PlayerMobile)from, m_Faction)); } }
public override void VendorBuy(Mobile from) { if (Faction == null || Faction.Find(from, true) != Faction) { PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1042201, // You are not in my faction, I cannot sell you a horse! from.NetState ); } else if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (from is PlayerMobile mobile) { mobile.SendGump(new HorseBreederGump(mobile, Faction)); } }
public override void OnMovement(Mobile m, Point3D oldLocation) { if (m.Player && m.Alive && this.InRange(m, 10) && !this.InRange(oldLocation, 10) && this.InLOS(m) && this.m_Orders.GetReaction(Faction.Find(m)).Type == ReactionType.Warn) { this.Direction = this.GetDirectionTo(m); string warning = null; switch (Utility.Random(6)) { case 0: warning = "I warn you, {0}, you would do well to leave this area before someone shows you the world of gray."; break; case 1: warning = "It would be wise to leave this area, {0}, lest your head become my commanders' trophy."; break; case 2: warning = "You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt."; break; case 3: warning = "Your presence here is an insult, {0}. Be gone now, knave."; break; case 4: warning = "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer."; break; case 5: warning = "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick."; break; } Faction faction = Faction.Find(m); this.Say(warning, m.Name, faction == null ? "civilians" : faction.Definition.FriendlyName); } }
public void EndCapture(Mobile m, bool successful) { if (successful) { Faction f = Faction.Find(m); if (f != null) { Owner = f; foreach (Faction faction in Faction.Factions) { string factionName, townName; if (faction == f) { factionName = "Your faction"; } else { factionName = f.Definition.FriendlyName; } townName = m_Monolith.Town.Definition.FriendlyName; string broadcastString = String.Format("{0} has gained control over a control point in {1}!", factionName, townName); faction.Broadcast(0x27, broadcastString); } } } else if (Owner != null) { StartNeutralTimer(); } m_Capturer = null; if (m_CaptureTimer != null) { m_CaptureTimer.Stop(); m_CaptureTimer = null; } }
private static void EventSink_Speech(SpeechEventArgs e) { Mobile from = e.Mobile; int[] keywords = e.Keywords; for (int i = 0; i < keywords.Length; ++i) { switch (keywords[i]) { case 0x00E4: // *i wish to access the city treasury* { Town town = Town.FromRegion(from.Region); if (town == null || !town.IsFinance(from) || !from.Alive) { break; } if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (town.Owner != null && from is PlayerMobile) { from.SendGump(new FinanceGump((PlayerMobile)from, town.Owner, town)); } break; } case 0x0ED: // *i am sheriff* { Town town = Town.FromRegion(from.Region); if (town == null || !town.IsSheriff(from) || !from.Alive) { break; } if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (town.Owner != null) { from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town)); } break; } case 0x00EF: // *you are fired* { Town town = Town.FromRegion(from.Region); if (town == null) { break; } if (town.IsFinance(from) || town.IsSheriff(from)) { town.BeginOrderFiring(from); } break; } case 0x00E5: // *i wish to resign as finance minister* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.Finance != null) { pl.Finance.Finance = null; from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister } break; } case 0x00EE: // *i wish to resign as sheriff* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.Sheriff != null) { pl.Sheriff.Sheriff = null; from.SendLocalizedMessage(1010270); // You have been fired as Sheriff } break; } case 0x00E9: // *what is my faction term status* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.IsLeaving) { if (Faction.CheckLeaveTimer(from)) { break; } TimeSpan remaining = (pl.Leaving + Faction.LeavePeriod) - DateTime.UtcNow; if (remaining.TotalDays >= 1) { from.SendLocalizedMessage(1042743, remaining.TotalDays.ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days. } else if (remaining.TotalHours >= 1) { from.SendLocalizedMessage(1042741, remaining.TotalHours.ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours. } else { from.SendLocalizedMessage(1042742); // Your term of service will come to an end in less than one hour. } } else if (pl != null) { from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. } break; } case 0x00EA: // *message faction* { Faction faction = Faction.Find(from); if (faction == null || !faction.IsCommander(from)) { break; } if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) { from.SendLocalizedMessage(1010264); // The required time has not yet passed since the last message was sent } else { faction.BeginBroadcast(from); } break; } case 0x00EC: // *showscore* { PlayerState pl = PlayerState.Find(from); if (pl != null) { Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl); } break; } case 0x0178: // i honor your leadership { Faction faction = Faction.Find(from); if (faction != null) { faction.BeginHonorLeadership(from); } break; } } } }
private void Sigil_OnTarget(Mobile from, object obj) { if (Deleted || !IsChildOf(from.Backpack)) { return; } #region Give To Mobile if (obj is Mobile) { if (obj is PlayerMobile) { PlayerMobile targ = (PlayerMobile)obj; Faction toFaction = Faction.Find(targ); Faction fromFaction = Faction.Find(from); if (toFaction == null) { from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction } else if (fromFaction != toFaction) { from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction } else if (Sigil.ExistsOn(targ)) { from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil } else if (!targ.Alive) { from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person. } else if (from.NetState != null && targ.NetState != null) { Container pack = targ.Backpack; if (pack != null) { pack.DropItem(this); } } } else { from.SendLocalizedMessage(1005221); //You cannot give the sigil to them } } #endregion else if (obj is BaseMonolith) { #region Put in Stronghold if (obj is StrongholdMonolith) { StrongholdMonolith m = (StrongholdMonolith)obj; if (m.Faction == null || m.Faction != Faction.Find(from)) { from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith } else if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042247); // That is not the correct faction monolith } else { m.Sigil = this; Faction newController = m.Faction; Faction oldController = m_Corrupting; if (oldController == null) { if (m_Corrupted != newController) { BeginCorrupting(newController); } } else if (m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.UtcNow) { if (m_Corrupted != newController) { BeginCorrupting(newController); // grace time over, reset period } else { ClearCorrupting(); } m_GraceStart = DateTime.MinValue; } else if (newController == oldController) { m_GraceStart = DateTime.MinValue; // returned within grace period } else if (m_GraceStart == DateTime.MinValue) { m_GraceStart = DateTime.UtcNow; } m_PurificationStart = DateTime.MinValue; } } #endregion #region Put in Town else if (obj is TownMonolith) { TownMonolith m = (TownMonolith)obj; if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith } else if (m_Corrupted == null || m_Corrupted != Faction.Find(from)) { from.SendLocalizedMessage(1042244); // Your faction did not corrupt this sigil. Take it to your stronghold. } else { m.Sigil = this; m_Corrupting = null; m_PurificationStart = DateTime.UtcNow; m_CorruptionStart = DateTime.MinValue; m_Town.Capture(m_Corrupted); m_Corrupted = null; } } #endregion } else { from.SendLocalizedMessage(1005224); // You can't use the sigil on that } Update(); }
private void Sigil_OnTarget(Mobile from, object obj) { if (Deleted || !IsChildOf(from.Backpack)) { return; } #region Give To Mobile if (obj is Mobile) { if (obj is PlayerMobile) { PlayerMobile targ = (PlayerMobile)obj; Faction toFaction = Faction.Find(targ); Faction fromFaction = Faction.Find(from); if (toFaction == null) { from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction } else if (fromFaction != toFaction) { from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction } else if (Sigil.ExistsOn(targ)) { from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil } else if (!targ.Alive) { from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person. } else if (from.NetState != null && targ.NetState != null) { Container pack = targ.Backpack; if (pack != null) { pack.DropItem(this); } } } else { from.SendLocalizedMessage(1005221); //You cannot give the sigil to them } } #endregion else if (obj is BaseMonolith) { #region Put in Stronghold if (obj is StrongholdMonolith) { StrongholdMonolith m = (StrongholdMonolith)obj; if (m.Faction == null || m.Faction != Faction.Find(from)) { from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith } else if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042247); // That is not the correct faction monolith } else { m.Sigil = this; Faction newController = m.Faction; Faction oldController = m_Corrupting; if (m_OriginalThief != null && newController != PlayerState.Find(m_OriginalThief).Faction) { UpdateThief(null); } if (oldController == null) { if (m_Corrupted != newController) { BeginCorrupting(newController); } } else if (m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.UtcNow) { if (m_Corrupted != newController) { BeginCorrupting(newController); // grace time over, reset period } else { ClearCorrupting(); } m_GraceStart = DateTime.MinValue; } else if (newController == oldController) { m_GraceStart = DateTime.MinValue; // returned within grace period } else if (m_GraceStart == DateTime.MinValue) { m_GraceStart = DateTime.UtcNow; } m_PurificationStart = DateTime.MinValue; } } #endregion #region Put in Town else if (obj is TownMonolith) { TownMonolith m = (TownMonolith)obj; if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith } else if (m_Corrupted == null || m_Corrupted != Faction.Find(from)) { from.SendLocalizedMessage(1042244); // Your faction did not corrupt this sigil. Take it to your stronghold. } else { m.Sigil = this; m_Corrupting = null; m_PurificationStart = DateTime.UtcNow; m_CorruptionStart = DateTime.MinValue; bool isTownAlreadyOwned = (m_Town.Owner == m_Corrupted); m_Town.Capture(m_Corrupted); m_Corrupted = null; if (!isTownAlreadyOwned && m_OriginalThief != null && m_OriginalThief.NetState != null) { int punkte = 10; int silver = 750; PlayerState ps = PlayerState.Find(m_OriginalThief); Faction deliverersfaction = Faction.Find(from); Faction originalthiefsfaction = Faction.Find(m_OriginalThief); if (ps != null && deliverersfaction == originalthiefsfaction) { ps.KillPoints += punkte; ps.Faction.AwardSilver(m_OriginalThief, silver); string args = String.Format("{0}\t{1}", punkte, silver); m_OriginalThief.SendLocalizedMessage(1094922, args); // Thine heroic efforts in capturing the sigil has yielded ~1_POINTS~ kill points and ~2_SILVER~ silver. } } m_OriginalThief = null; m_PreviousThief = null; } } #endregion } else { from.SendLocalizedMessage(1005224); // You can't use the sigil on that } Update(); }
private static void EventSink_Speech(SpeechEventArgs e) { Mobile from = e.Mobile; // jakob, added 2 new commands if (e.Speech.ToLower().IndexOf("i wish to appoint a deputy commander") > -1) { Faction faction = Faction.Find(from); if (faction != null && faction.IsCommander(from) && !faction.IsDeputyCommander(from)) { faction.BeginAppointDeputyCommander(from); } } else if (e.Speech.ToLower().IndexOf("i wish to demote the deputy commander") > -1) { Faction faction = Faction.Find(from); if (faction != null && faction.IsCommander(from) && !faction.IsDeputyCommander(from) && faction.DeputyCommander != null) { faction.DeputyCommander = null; from.SendMessage("You have fired the deputy commander."); } } // Kamron, added this else if (e.Speech.ToLower().IndexOf("i wish to renew my spirit") > -1) { PlayerState ps = PlayerState.Find(from); if (ps != null && from is PlayerMobile) { PlayerMobile pm = (PlayerMobile)from; if (ps.KillPoints <= 1) { from.SendMessage("Your spirit cannot be cleansed."); } else if (Faction.InSkillLoss(pm)) { ps.KillPoints--; Faction.ClearSkillLoss(pm); from.SendMessage("You cleanse your spirit and remove your sins."); } else { from.SendMessage("Your spirit does not need cleansing."); } } } // end int[] keywords = e.Keywords; for (int i = 0; i < keywords.Length; ++i) { switch (keywords[i]) { case 0x00E4: // *i wish to access the city treasury* { Town town = Town.FromRegion(from.Region); if (town == null || !town.IsFinance(from) || !from.Alive) { break; } if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (town.Owner != null && from is PlayerMobile) { from.SendGump(new FinanceGump((PlayerMobile)from, town.Owner, town)); } break; } case 0x0ED: // *i am sheriff* { Town town = Town.FromRegion(from.Region); if (town == null || !town.IsSheriff(from) || !from.Alive) { break; } if (FactionGump.Exists(from)) { from.SendLocalizedMessage(1042160); // You already have a faction menu open. } else if (town.Owner != null) { from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town)); } break; } case 0x00EF: // *you are fired* { Town town = Town.FromRegion(from.Region); if (town == null) { break; } if (town.IsFinance(from) || town.IsSheriff(from)) { town.BeginOrderFiring(from); } break; } case 0x00E5: // *i wish to resign as finance minister* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.Finance != null) { pl.Finance.Finance = null; from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister } break; } case 0x00EE: // *i wish to resign as sheriff* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.Sheriff != null) { pl.Sheriff.Sheriff = null; from.SendLocalizedMessage(1010270); // You have been fired as Sheriff } break; } case 0x00E9: // *what is my faction term status* { PlayerState pl = PlayerState.Find(from); if (pl != null && pl.IsLeaving) { if (Faction.CheckLeaveTimer(from)) { break; } TimeSpan remaining = (pl.Leaving + Faction.LeavePeriod) - DateTime.Now; if (remaining.TotalDays >= 1) { from.SendLocalizedMessage(1042743, remaining.TotalDays.ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days. } else if (remaining.TotalHours >= 1) { from.SendLocalizedMessage(1042741, remaining.TotalHours.ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours. } else { from.SendLocalizedMessage(1042742); // Your term of service will come to an end in less than one hour. } } else if (pl != null) { from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. } break; } case 0x00EA: // *message faction* { Faction faction = Faction.Find(from); if (faction == null || !faction.IsCommander(from)) { break; } if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) { from.SendLocalizedMessage(1010264); // The required time has not yet passed since the last message was sent } else { faction.BeginBroadcast(from); } break; } case 0x00EC: // *showscore* { PlayerState pl = PlayerState.Find(from); if (pl != null) { Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl); } break; } /* * case 0x0178: // i honor your leadership * { * Faction faction = Faction.Find( from ); * * if ( faction != null ) * faction.BeginHonorLeadership( from ); * * break; * } */ } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1) { return; } if (Faction.Find(m_From) != m_Faction) { return; } Container pack = m_From.Backpack; if (pack == null) { return; } FactionWarHorse horse = new FactionWarHorse(m_Faction); if ((m_From.Followers + horse.ControlSlots) > m_From.FollowersMax) { // TODO: Message? horse.Delete(); } else { if (pack.GetAmount(typeof(Silver)) < FactionWarHorse.SilverPrice) { sender.Mobile.SendLocalizedMessage(1042204); // You do not have enough silver. horse.Delete(); } else if (pack.GetAmount(typeof(Gold)) < FactionWarHorse.GoldPrice) { sender.Mobile.SendLocalizedMessage(1042205); // You do not have enough gold. horse.Delete(); } else if (pack.ConsumeTotal(typeof(Silver), FactionWarHorse.SilverPrice) && pack.ConsumeTotal(typeof(Gold), FactionWarHorse.GoldPrice)) { horse.Controlled = true; horse.ControlMaster = m_From; horse.ControlOrder = OrderType.Follow; horse.ControlTarget = m_From; horse.MoveToWorld(m_From.Location, m_From.Map); if (info.IsSwitched(1)) { horse.Hue = m_Faction.Definition.HuePrimary; } else if (info.IsSwitched(2)) { horse.Hue = m_Faction.Definition.HueSecondary; } } else { horse.Delete(); } } }