/// <summary> /// Creation of the entity's graphics /// </summary> void ICommitGumpEntity.Create() { #region page 1 // Page 1 - overview ////////////////////////////////////////////////////////////////////// StringBuilder htmlSb = new StringBuilder("<basefont color=#FFCC00><center>City Overview - ").Append(GetCityNameString()).Append("</center></basefont>"); m_Gump.AddHtml(170, 40, 409, 19, htmlSb.ToString(), (bool)false, (bool)false); //left htmlSb = new StringBuilder("<basefont color=white><p align=\"right\">City Leader :</p>"); htmlSb.Append(("<p align=\"right\">Controlling Kin :</p>")); htmlSb.Append(("<p align=\"right\">Tax Rate :</p>")); htmlSb.Append(("<p align=\"right\">Beneficiaries :</p>")); htmlSb.Append(("<p align=\"right\">Treasury :</p>")); htmlSb.Append(("<p align=\"right\">City Guards :</p>")); htmlSb.Append("</basefont>"); m_Gump.AddHtml(175, 100, 205, 361, htmlSb.ToString(), (bool)false, (bool)false); //top htmlSb = new StringBuilder("<basefont color=gray><p>").Append(m_Gump.Data.CityLeader != null ? m_Gump.Data.CityLeader.Name : "Unknown").Append("</p>"); htmlSb.Append("<p>").Append(IOBSystem.GetIOBName(m_Gump.Data.ControlingKin)).Append("</p>"); htmlSb.AppendFormat("<p>{0}</p>", string.Format("{0:0%}", m_Gump.Data.TaxRate)); htmlSb.AppendFormat("<p>{0}</p>", m_Gump.Data.BeneficiaryDataList.Count); htmlSb.AppendFormat("<p>{0}</P>", string.Format("{0:n}", m_Gump.Data.Treasury)); htmlSb.AppendFormat("<p>{0}</p>", GetGuardTypeString()); htmlSb.Append("</basefont>"); m_Gump.AddHtml(395, 100, 199, 361, htmlSb.ToString(), (bool)false, (bool)false); //right ////////////////////////////////////////////////////////////////////////////////////////////// #endregion }
public KinCityStatusGump() : base(25, 25) { this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; this.AddPage(0); this.AddImage(1, 6, 1228); this.AddButton(25, 268, 247, 249, (int)Buttons.Ok, GumpButtonType.Reply, 0); StringBuilder html = new StringBuilder("<basefont color=gray><p><center>City Status</center></p><p>"); foreach (KinFactionCities e in Enum.GetValues(typeof(KinFactionCities))) { KinCityData cd = KinCityManager.GetCityData(e); if (cd == null) { continue; } html.Append(string.Format("<P><STRONG>{0}</STRONG> : ", e.ToString())); if (cd.ControlingKin == IOBAlignment.None) { html.Append("Golem Controller King</P>"); } else { html.Append(string.Format("{0}</P>", IOBSystem.GetIOBName(cd.ControlingKin))); if (cd.GuardOption == KinCityData.GuardOptions.LordBritish) { html.Append("<p>Lord British is guarding this city.</p>"); } foreach (KinCityData.BeneficiaryData vd in cd.BeneficiaryDataList) { html.Append(string.Format("<P> * {0}</P>", vd.Pm.Name)); } } } html.Append("</P></P></basefont>"); this.AddHtml(26, 40, 348, 214, html.ToString(), (bool)false, (bool)true); }
public override void OnEnter(Mobile m) { Region left = null; PlayerMobile pm = null; if (m is PlayerMobile) { pm = (PlayerMobile)m; left = pm.LastRegionIn; } // wea: If this is an isolated region, we're going to send sparklies where // mobiles will disappear (this happens as part of an IsIsolatedFrom() check, // not explicit packet removal here) + a sound effect if we had to do this // // also send an incoming packet to all players within the region. // ____ // || if (m_Controller.IsIsolated) { if (m.Map != null) { int invissedmobiles = 0; IPooledEnumerable eable = m.GetMobilesInRange(Core.GlobalMaxUpdateRange); foreach (Mobile mir in eable) { // Regardless of whether this is mobile or playermobile, // we need to send an incoming packet to each of the mobiles // in the region if (mir.Region == m.Region) { if (mir is PlayerMobile) { // We've just walked into this mobile's region, so send incoming packet // if they're a playermobile if (Utility.InUpdateRange(m.Location, mir.Location) && mir.CanSee(m)) { // Send incoming packet to player if they're online if (mir.NetState != null) { mir.NetState.Send(new MobileIncoming(mir, m)); } } } } else { // They're in a different region, so localise sparklies // to us if we're a player mobile if (pm != null && mir.AccessLevel <= pm.AccessLevel) { Packet particles = new LocationParticleEffect(EffectItem.Create(mir.Location, mir.Map, EffectItem.DefaultDuration), 0x376A, 10, 10, 0, 0, 2023, 0); if (pm.NetState != null && particles != null) { pm.Send(particles); invissedmobiles++; } } } } if (invissedmobiles > 0) { // Play a sound effect to go with it if (pm.NetState != null) { pm.PlaySound(0x3C4); } } if (pm != null) { m.ClearScreen(); m.SendEverything(); } eable.Free(); } } // || // ____ // if were leaving a house and entering the region(already in it) dont play the enter msg if (pm != null && pm.LastRegionIn is HouseRegion) { return; } if (m_Controller.ShowEnterMessage) { m.SendMessage("You have entered {0}", this.Name); if (m_Controller.NoMurderZone) { m.SendMessage("This is a lawless area; you are freely attackable here."); } } if (m_Controller.OverrideMaxFollowers) { m.FollowersMax = m_Controller.MaxFollowerSlots; } if (m_Controller.PlayMusic) { PlayMusic(m); } PlayerMobile IOBenemy = null; if (m is PlayerMobile) { IOBenemy = (PlayerMobile)m; } //if is a iob zone/region and a iob aligned mobile with a differnt alignment then the zone enters //find all players of the zones alignment and send them a message //plasma: refactored the send message code into its own method within KinSystem if (DateTime.Now >= m_Controller.m_Msg && m_Controller.IOBZone && m_Controller.ShowIOBMsg && IOBenemy != null && IOBenemy.IOBAlignment != IOBAlignment.None && IOBenemy.IOBAlignment != m_Controller.IOBAlign && m.AccessLevel == AccessLevel.Player) //we dont want it announceing staff with iob kinship { if (m_Controller.RegionName != null && m_Controller.RegionName.Length > 0) { KinSystem.SendKinMessage(m_Controller.IOBAlign, string.Format("Come quickly, the {0} are attacking {1}!", IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment), m_Controller.RegionName)); } else { KinSystem.SendKinMessage(m_Controller.IOBAlign, string.Format("Come quickly, the {0} are attacking your stronghold!", IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment))); } m_Controller.m_Msg = DateTime.Now + m_Controller.m_Delay; } else if (DateTime.Now >= m_Controller.m_Msg && this is Engines.IOBSystem.KinCityRegion && IOBenemy != null && IOBenemy.IOBAlignment != IOBAlignment.None && IOBenemy.IOBAlignment != m_Controller.IOBAlign && m.AccessLevel == AccessLevel.Player) //we dont want it announceing staff with iob kinship { KinCityRegion r = KinCityRegion.GetKinCityAt(this.m_Controller); if (r != null) { KinCityData cd = KinCityManager.GetCityData(r.KCStone.City); if (cd != null && cd.ControlingKin != IOBAlignment.None) { Engines.IOBSystem.KinSystem.SendKinMessage(cd.ControlingKin, string.Format("Come quickly, the {0} are attacking the City of {1}!", IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment), cd.City.ToString())); m_Controller.m_Msg = DateTime.Now + m_Controller.m_Delay; } } } base.OnEnter(m); }
/// <summary> /// Called when the vortex is sucessfully killed /// All the points calculation and processing happens here /// </summary> public void VortexDeath() { CaptureData logData = new CaptureData(); logData.City = m_City.ToString(); logData.CaptureTime = DateTime.Now; logData.LogTime = DateTime.Now; //turn off expire timer if (m_Timer != null && m_Timer.Running) { m_Timer.Stop(); } if (KinSystemSettings.OutputCaptureData) { SendMessageToLocalGM(string.Format("Vortex for the city of {0} has been destroyed", m_City.ToString())); } Dictionary <PlayerMobile, double> individualCapturePoints //dual purpose damage dictionary and capture points = new Dictionary <PlayerMobile, double>(); Dictionary <IOBAlignment, int> kinDamageSpread //kin damage spread dictionary = new Dictionary <IOBAlignment, int>(); KinCapturePointList kinCapturePoints = new KinCapturePointList(); //final kin capture point list KinCapturePointList finalCapturePoints = new KinCapturePointList(); //final individual capture point list IOBAlignment winningKin = IOBAlignment.None; //Winning kin double capturePointsPerVortexDamage = 0.0; //Standardised capture points per vortex damage point double capturePointsPerDefensePoint = 0.0; //Standardised capture points per defense point double totalCapturePoints = 0.0; //total capture points int totalVortexDamage = 0; //total vortex damage //First, cycle thru the vortex's damage list and populate individual and kin damage dictionaries foreach (DamageEntry de in m_Vortex.DamageEntries) { PlayerMobile pm = null; //Check this is a real factioner or a factioner's pet if (de.Damager is PlayerMobile && ((PlayerMobile)de.Damager).IsRealFactioner) { pm = ((PlayerMobile)de.Damager); } else if (de.Damager is BaseCreature) { BaseCreature bc = ((BaseCreature)de.Damager); if (bc.ControlMaster != null && bc.ControlMaster is PlayerMobile && ((PlayerMobile)bc.ControlMaster).IsRealFactioner) { pm = ((PlayerMobile)bc.ControlMaster); } else if (bc.Summoned && bc.SummonMaster != null && bc.SummonMaster is PlayerMobile && ((PlayerMobile)bc.SummonMaster).IsRealFactioner) { pm = ((PlayerMobile)bc.SummonMaster); } } if (pm == null) { continue; } //add this player and the damage to the dictionary, to be converted into capture points in the next stage if (individualCapturePoints.ContainsKey(pm)) { individualCapturePoints[pm] += de.DamageGiven; } else { individualCapturePoints.Add(pm, de.DamageGiven); } //keep running total of all damage totalVortexDamage += de.DamageGiven; //also add this damage to the kin dictionary for later if (!kinDamageSpread.ContainsKey(pm.IOBRealAlignment)) { kinDamageSpread.Add(pm.IOBRealAlignment, de.DamageGiven); } else { kinDamageSpread[pm.IOBRealAlignment] += de.DamageGiven; } } //add anyone else from the defense points into the damage list, with 0 damage foreach (PlayerMobile pm in m_DefensePoints.Keys) { if (!individualCapturePoints.ContainsKey(pm)) { individualCapturePoints.Add(pm, 0.0); } } //add up defense points, this will act as the total amount of capture points avaliable foreach (KeyValuePair <PlayerMobile, double> pair in m_DefensePoints) { totalCapturePoints += pair.Value; } //Make sure we have at least 1 capture point to work with if (totalCapturePoints == 0) { totalCapturePoints = 1; } //standardise each damage point of the vortex damage so the vortex is worth KinSystemSettings % of the points capturePointsPerVortexDamage = ((totalCapturePoints * KinSystemSettings.VortexCaptureProportion) / totalVortexDamage); //the remainder contributes to defenders capturePointsPerDefensePoint = ((totalCapturePoints * (1.0 - KinSystemSettings.VortexCaptureProportion) / totalCapturePoints)); //output data thus far to local GM's journal if (KinSystemSettings.OutputCaptureData) { //Individual damage SendMessageToLocalGM("Individual damage to vortex:"); foreach (KeyValuePair <PlayerMobile, double> kvp in individualCapturePoints) { Player p = new Player(kvp.Key); p.Value = kvp.Value; logData.IndividualVortexDamage.Add(p); SendMessageToLocalGM(string.Format("Player {0} inflicted {1} points of damage", kvp.Key.Name, kvp.Value)); } //Total damage SendMessageToLocalGM(string.Format("Total damage inflicted on vortex: {0}", totalVortexDamage)); logData.TotalVortexDamage = totalVortexDamage; //Damage split by Kin SendMessageToLocalGM("Kin damage to vortex:"); foreach (KeyValuePair <IOBAlignment, int> kvp in kinDamageSpread) { StringDoublePair k = new StringDoublePair(); k.Name = kvp.Key.ToString(); k.Value = kvp.Value; logData.KinDamageSpread.Add(k); SendMessageToLocalGM(string.Format("Kin {0} inflicted {1} points of damage", kvp.Key.ToString(), kvp.Value)); } //Individual defense points SendMessageToLocalGM("Individual defense points earnt:"); foreach (KeyValuePair <PlayerMobile, double> kvp in m_DefensePoints) { Player p = new Player(kvp.Key); p.Value = kvp.Value; logData.IndividualDefensePoints.Add(p); SendMessageToLocalGM(string.Format("Player {0} earnt {1} defense points", kvp.Key.Name, kvp.Value)); } //Total defense points SendMessageToLocalGM(string.Format("Total defense (capture) points earnt: {0}", totalCapturePoints)); logData.TotalCapturePoints = totalCapturePoints; //Calculated points SendMessageToLocalGM(string.Format("Capture points per vortex damage : {0}", capturePointsPerVortexDamage)); SendMessageToLocalGM(string.Format("Capture points per defense point : {0}", capturePointsPerDefensePoint)); } //Reformat the individual list into capture points. List <PlayerMobile> pms = new List <PlayerMobile>(); //Temp list foreach (PlayerMobile pm in individualCapturePoints.Keys) { pms.Add(pm); } foreach (PlayerMobile pm in pms) { //reformat damage points individualCapturePoints[pm] *= capturePointsPerVortexDamage; if (m_DefensePoints.ContainsKey(pm)) { //Add any more capture points from defense individualCapturePoints[pm] += (m_DefensePoints[pm] * capturePointsPerDefensePoint); } //add this player's total capture points towards kin total kinCapturePoints.AddPoints(pm.IOBRealAlignment, individualCapturePoints[pm]); } //Free up temp list! pms.Clear(); pms = null; //Sort kin capture points (desc) kinCapturePoints.Sort(); //More output data if (KinSystemSettings.OutputCaptureData) { SendMessageToLocalGM("Total individual capture points:"); foreach (KeyValuePair <PlayerMobile, double> kvp in individualCapturePoints) { Player p = new Player(kvp.Key); p.Value = kvp.Value; logData.IndividualCapturePoints.Add(p); SendMessageToLocalGM(string.Format("Player {0} earnt {1} total capture points", kvp.Key.Name, kvp.Value)); } SendMessageToLocalGM("Total kin capture points:"); foreach (KinCapturePoints points in kinCapturePoints) { StringDoublePair k = new StringDoublePair(); k.Name = points.Obj.ToString(); k.Value = points.Points; logData.KinCapturePoints.Add(k); SendMessageToLocalGM(string.Format("Kin {0} earnt {1} total capture points", points.Obj.ToString(), points.Points)); } } //Now find a winner - but the winning kin must also have done at least x% of the vortex damage for (int i = 0; i < kinCapturePoints.Count; ++i) { IOBAlignment kin = IOBAlignment.None; if (kinCapturePoints[i].Obj is IOBAlignment) { kin = (IOBAlignment)kinCapturePoints[i].Obj; } int damage = 0; if (kinDamageSpread.ContainsKey(kin)) { damage = kinDamageSpread[kin]; } else { damage = 0; } if (damage >= (totalVortexDamage * KinSystemSettings.VortexMinDamagePercentage)) { //found our winner winningKin = kin; break; } else { if (KinSystemSettings.OutputCaptureData) { SendMessageToLocalGM(string.Format("Kin {0} would have won, but didn't do enough damage to the vortex", kin.ToString())); } } } logData.WinningKin = winningKin.ToString(); if (winningKin == IOBAlignment.None || winningKin == IOBAlignment.Healer || winningKin == IOBAlignment.OutCast) { //this shouldn't really happen. //Hand city over to golem controllers KinCityManager.TransferOwnership(m_City, IOBAlignment.None, null); } //Find and move all of this kin into the final capture point list foreach (KeyValuePair <PlayerMobile, double> pair in individualCapturePoints) { if (pair.Key.IOBRealAlignment == winningKin) { finalCapturePoints.AddPoints(pair.Key, pair.Value); } } //woo sanity if (finalCapturePoints.Count == 0) { //this should never happen. //Hand city over to golem controllers KinCityManager.TransferOwnership(m_City, IOBAlignment.None, null); } //Sort capture points list desc finalCapturePoints.Sort(); int totalBenes = 0; //now we want the top x% of this list to act as beneficiaries for the town, with a cap if (finalCapturePoints.Count < KinSystemSettings.BeneficiaryCap) { totalBenes = finalCapturePoints.Count; } else { //plasma: removing the qualification % for now, it's too inhibitive with a little amount of players. totalBenes = KinSystemSettings.BeneficiaryCap; //totalBenes = (int)Math.Round((double)finalCapturePoints.Count * KinSystemSettings.BeneficiaryQualifyPercentage, 0); //Should never happen, but possible depending on the KinSystemSettings variables if (totalBenes < 1) { totalBenes = 1; } } //Send message to winners List <PlayerMobile> winners = new List <PlayerMobile>(); for (int i = 0; i < totalBenes; ++i) { winners.Add(finalCapturePoints[i].Obj as PlayerMobile); } //Send message to all KinSystem.SendKinMessage(string.Format("The City of {0} has fallen to the {1}! ", m_City.ToString(), winningKin == IOBAlignment.None ? "Golem Controller Lord" : IOBSystem.GetIOBName(winningKin))); winners.ForEach(delegate(PlayerMobile pm) { pm.SendMessage("You have qualified as a beneficiary of {0}. Head to the city's control board to vote for a City leader.", m_City.ToString()); }); if (KinSystemSettings.OutputCaptureData) { SendMessageToLocalGM("Final beneficiaries of town:"); foreach (PlayerMobile pm in winners) { Player p = new Player(pm); logData.BeneficiariesCpaturePoints.Add(p); SendMessageToLocalGM(pm.Name); } } //Hand city over to the kin and its beneficiaries KinCityManager.TransferOwnership(m_City, winningKin, winners); m_DefensePoints.Clear(); if (KinSystemSettings.OutputCaptureData) { KinFactionLogs.Instance.AddEntityToSerialize(logData); } //Fianlly set the base next vortex spawn time for this city/sigil SetNewSpawnTime(); }