示例#1
0
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
            if (!(from is PlayerMobile))
            {
                return;
            }

            PlayerMobile pm = ((PlayerMobile)from);

            if (pm.IOBRealAlignment == IOBAlignment.None)
            {
                return;
            }

            KinCityData cd = KinCityManager.GetCityData(FactionCity);

            if (cd == null)
            {
                return;
            }

            from.SendMessage("Target the silver that you wish to hire the scout party with");
            from.Target = new ScoutingSilverTarget(this);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="city"></param>
        /// <param name="page"></param>
        /// <param name="session"></param>
        private KinCityControlGump(KinFactionCities city, int page, GumpSession session, Mobile from)
            : base(page, session, from)
        {
            //This ctor gets called the first time the gump is opened
            m_Data = KinCityManager.GetCityData(city);
            if (m_Data == null)
            {
                return;
            }

            Session["City"] = city;

            //If in the vote stage, sett page to 5 now
            if (m_Data.IsVotingStage)
            {
                Page = 5;
            }

            SetCurrentPage();
            if (MasterPage != null)
            {
                MasterPage.Create();
                if (CurrentPage != null)
                {
                    this.AddPage(1);
                }
            }
            if (CurrentPage != null)
            {
                CurrentPage.Create();
            }
        }
示例#3
0
 /// <summary>
 /// Called when [delete].
 /// </summary>
 public override void OnDelete()
 {
     base.OnDelete();
     if (KinCityManager.IsSigilRegistered(this))
     {
         KinCityManager.UnRegisterSigil(this);
     }
 }
示例#4
0
 /// <summary>
 /// Called if the vortex was not killed quick enough
 /// </summary>
 public void VortexTimeOut()
 {
     if (m_Vortex != null && !m_Vortex.Deleted)             //sanity
     {
         m_Vortex.TimedOut = true;
         m_Vortex.Kill();
         //Hand town over to golem controllers and set next spawn time
         KinCityManager.TransferOwnership(m_City, IOBAlignment.None, null);
         SetNewSpawnTime();
     }
 }
示例#5
0
            /// <summary>
            /// Gets the benificary data of the Owner
            /// </summary>
            /// <returns></returns>
            private KinCityData.BeneficiaryData GetBenData()
            {
                KinCityData cityData = KinCityManager.GetCityData(GuardPost.City);

                if (cityData == null)
                {
                    return(null);
                }
                KinCityData.BeneficiaryData benData = cityData.BeneficiaryDataList.Find(delegate(KinCityData.BeneficiaryData bd) { return(bd.Pm == GuardPost.Owner); });
                return(benData);
            }
示例#6
0
            private int GetDaysUntilSpawn()
            {
                KinCityData cd = KinCityManager.GetCityData(m_KinSigil.FactionCity);

                if (cd == null)
                {
                    return(0);
                }
                TimeSpan ts = (DateTime.Now - m_KinSigil.NextEventTime);

                return(Math.Abs(ts.Days));
            }
示例#7
0
        /// <summary>
        /// Called when [chop].
        /// </summary>
        /// <param name="from">From.</param>
        void IChopable.OnChop(Mobile from)
        {
            KinCityData data = KinCityManager.GetCityData(m_City);

            if (data == null)
            {
                Delete();
            }
            if (from == m_Owner || (data.CityLeader != null && from == data.CityLeader) || from.AccessLevel > AccessLevel.Counselor)
            {
                Delete();
            }
        }
示例#8
0
        /// <summary>
        /// Called when [single click].
        /// </summary>
        /// <param name="from">From.</param>
        public override void OnSingleClick(Mobile from)
        {
            //Show which city this sigil relates to
            if (KinCityManager.IsSigilRegistered(this))
            {
                string city = Enum.GetName(typeof(KinFactionCities), m_City);
                LabelTo(from, "Kin Sigil for the City of " + city);
            }
            else
            {
                LabelTo(from, "An unused Kin Sigil");
            }

            //If this is a GM also show which phase the sigil is in and the time to the next
            //vortex spawn, or the expire time of the current vortex
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                if (!KinCityManager.IsSigilRegistered(this))
                {
                    LabelTo(from, "[Not assigned to a city]");
                    return;
                }

                if (m_Active)
                {
                    if (InCapturePhase())
                    {
                        LabelTo(from, "Capture phase in progress!");
                        LabelTo(from, "Vortex expire time : " + m_Time.ToLongDateString() + " " + m_Time.ToLongTimeString());
                    }
                    else
                    {
                        if (IsVortexSpawning())
                        {
                            LabelTo(from, "Final stage active.");
                            LabelTo(from, "Vortex will spawn at : " + m_Time.ToLongDateString() + " " + m_Time.ToLongTimeString());
                        }
                        else
                        {
                            LabelTo(from, "Awaiting next heartbeat.");
                            LabelTo(from, "Current next spawn time : " + m_Time.ToLongDateString() + " " + m_Time.ToLongTimeString());
                        }
                    }
                }
                else
                {
                    LabelTo(from, "Currently Inactive.  Please switch me on!");
                }
            }
        }
示例#9
0
        /// <summary>
        /// Called when [double click].
        /// </summary>
        /// <param name="from">From.</param>
        public override void OnDoubleClick(Mobile from)
        {
            if (!(from is PlayerMobile))
            {
                return;
            }
            if (CheckRange(from))
            {
                KinCityRegion region = KinCityRegion.GetKinCityAt(this);
                if (region == null)
                {
                    from.SendMessage("This board is not placed within a Kin City");
                    return;
                }

                if (from.AccessLevel <= AccessLevel.Player)
                {
                    KinCityData data = KinCityManager.GetCityData(region.KinFactionCity);
                    if (data == null)
                    {
                        return;
                    }

                    if (data.ControlingKin == IOBAlignment.None)
                    {
                        from.SendMessage("This city is controlled by the Golem Controller Lord!");
                        return;
                    }

                    if (((PlayerMobile)from).IOBRealAlignment != data.ControlingKin)
                    {
                        from.SendMessage("You are not aligned with {0}", data.ControlingKin.ToString());
                        return;
                    }
                }

                from.CloseGump(typeof(KinCityControlGump));
                from.SendGump(new KinCityControlGump(region.KinFactionCity, from));
            }
            else
            {
                from.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045);                 // I can't reach that.
            }
        }
示例#10
0
        /// <summary>
        /// Called when [delete].
        /// </summary>
        public override void OnDelete()
        {
            //Give guard post slots back
            KinCityData data = KinCityManager.GetCityData(m_City);

            if (data == null)
            {
                base.OnDelete();
                return;
            }
            KinCityData.BeneficiaryData bd = data.GetBeneficiary(m_Owner);
            if (bd == null)
            {
                base.OnDelete();
                return;
            }
            bd.UnRegisterGuardPost(this);
            base.OnDelete();
        }
示例#11
0
        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);
        }
示例#12
0
            void ICommitGumpEntity.CommitChanges()
            {
                //Page 3
                //NPC toggle
                if (m_State.NPCsChanged)
                {
                    //test each flag to see what's different and flip the neccesary flags
                    for (long l = 1; l <= 0x80000000; l <<= 1)
                    {
                        long flagA = (l & m_State.NPCData);
                        long flagB = (l & m_Gump.Data.NPCCurrentFlags);
                        if (flagA != flagB)
                        {
                            m_Gump.Data.ToggleNPCFlag((KinCityData.NPCFlags)l);
                        }
                    }
                    //Update the city NPC spawners
                    KinCityManager.UpdateCityNPCSpawners(m_Gump.City);
                    m_Gump.From.SendMessage("Allowable professions successfully updated");
                }

                if (m_State.GuardsChanged)
                {
                    if (!((ICommitGumpEntity)this).Validate())
                    {
                        m_Gump.From.SendMessage("You are not allowed to change the guards yet");
                    }
                    else
                    {
                        //Commit  (gm+ overrides the guard chage timeout)
                        KinCityManager.ChangeGuards(m_Gump.City, m_State.GuardOption, m_Gump.From.AccessLevel >= AccessLevel.Counselor);
                        if (m_State.GuardOption == KinCityData.GuardOptions.LordBritish)
                        {
                            m_Gump.From.SendMessage("Lord British's guards will return within the next few minutes.");
                        }
                        else
                        {
                            m_Gump.From.SendMessage("Guards changed successfully");
                        }
                    }
                }
            }
示例#13
0
        /// <summary>
        /// Called when [double click].
        /// </summary>
        /// <param name="from">From.</param>
        public override void OnDoubleClick(Mobile from)
        {
            if (from.AccessLevel > AccessLevel.Counselor)
            {
                base.OnDoubleClick(from);
            }

            KinCityData data = KinCityManager.GetCityData(m_City);

            if (data == null)
            {
                Delete();
            }

            //Only faction leader and the player assigned to this post should be able to see the gump
            if (from == Owner || (data.CityLeader != null && from == data.CityLeader) || from.AccessLevel > AccessLevel.Counselor)
            {
                from.CloseGump(typeof(KinGuardPostGump));
                from.SendGump(new KinGuardPostGump(this, from));
            }
        }
示例#14
0
 /// <summary>
 /// Restore data from the session
 /// </summary>
 void ICommitGumpEntity.LoadStateInfo()
 {
     m_State = (m_Gump.Session[((ICommitGumpEntity)this).ID] as DirtyState);
     if (m_State == null)
     {
         m_State = new DirtyState();
         m_Gump.Session[((ICommitGumpEntity)this).ID] = m_State;
         m_State.SetValue("Type", GuardPost.GuardType);
         KinCityData data = KinCityManager.GetCityData(GuardPost.City);
         if (data == null)
         {
             return;
         }
         KinCityData.BeneficiaryData bdata = data.BeneficiaryDataList.Find(delegate(KinCityData.BeneficiaryData b) { return(b.Pm == GuardPost.Owner); });
         if (bdata == null && m_Gump.From.AccessLevel <= AccessLevel.Player)
         {
             return;
         }
         m_State.SetValue("Slots", GetSlotsAvailable());
         m_State.SetValue("Target", GuardPost.FightMode);
         m_State.SetValue("Speed", GuardPost.HireSpeed);
     }
 }
示例#15
0
        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);
        }
示例#16
0
        /// <summary>
        /// Setup mob with owner's IOB alignment, the guard post's and the City's fight settings
        /// </summary>
        /// <param name="bc"></param>
        private void PreapareCreature(BaseCreature bc)
        {
            if (bc == null)
            {
                return;
            }

            //Set the IOBAlignment to that of the owner
            bc.IOBAlignment = Owner.IOBRealAlignment;
            if (!bc.Owners.Contains(Owner))
            {
                bc.Owners.Add(Owner);
            }

            //Set the fight mode and fight style to that the owner chose
            //NAND wipe the strongest, weakest and closest flags
            // 0x7
            bc.FightMode &= ~FightMode.Strongest;
            bc.FightMode &= ~FightMode.Weakest;
            bc.FightMode &= ~FightMode.Closest;

            //OR in the one we care about
            bc.FightMode |= m_FightMode;

            ////////////////////////////////////////////////
            //PLASMA: Fightsyle not being used currently
            ////////////////////////////////////////////////
            //NAND out mage and melee
            //0x3
            //bc.FightStyle &= ~FightStyle.Magic;
            //bc.FightStyle &= ~FightStyle.Melee;

            //OR in the one we care about
            //bc.FightStyle |= m_FightStyle;
            ////////////////////////////////////////////////


            //NAND out the attack settings
            //1F
            bc.FightMode &= ~FightMode.All; bc.FightMode &= ~FightMode.Aggressor;
            bc.FightMode &= ~FightMode.Criminal; bc.FightMode &= ~FightMode.Murderer;
            bc.FightMode &= ~FightMode.Evil;


            //OR in the ones we care about
            KinCityData data = KinCityManager.GetCityData(City);

            if (data != null)
            {
                switch (data.GuardOption)
                {
                case KinCityData.GuardOptions.None:
                case KinCityData.GuardOptions.LordBritish:
                    //These two cases shouldn't be possible
                    break;

                case KinCityData.GuardOptions.FactionOnly:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    break;
                }

                case KinCityData.GuardOptions.FactionAndReds:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    bc.FightMode |= FightMode.Murderer;
                    break;
                }

                case KinCityData.GuardOptions.FactionAndRedsAndCrim:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    bc.FightMode |= FightMode.Murderer;
                    bc.FightMode |= FightMode.Criminal;
                    break;
                }

                case KinCityData.GuardOptions.Everyone:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    bc.FightMode |= FightMode.All;
                    break;
                }

                case KinCityData.GuardOptions.RedsAndCrim:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    bc.FightMode |= FightMode.Murderer;
                    bc.FightMode |= FightMode.Criminal;
                    break;
                }

                case KinCityData.GuardOptions.Crim:
                {
                    bc.FightMode |= FightMode.Aggressor;
                    bc.FightMode |= FightMode.Criminal;
                    break;
                }

                default:
                    break;
                }
            }
            //bc.FightMode |= m_FightStyle;
            bc.AIObject.Think();
        }
示例#17
0
 public static void OnCommand(CommandEventArgs e)
 {
     KinCityManager.ProcessAndOutputLogs();
 }
示例#18
0
        /// <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();
        }
        protected override void OnTarget(Mobile from, object targeted)
        {
            if( targeted == null || !(targeted  is Item) )
                return;

            if (_guardPost == null)
            {
                //Guard post stage
                if (!(targeted is KinGuardPost))
                {
                    from.SendMessage("You may only fund guard posts");
                    return;
                }

                //Grab guardpost
                KinGuardPost gp = targeted as KinGuardPost;
                if (gp == null) return;

                //Verify owner
                KinCityData data = KinCityManager.GetCityData(gp.City);
                if( data == null )
                {
                    from.SendMessage("That guard post does not appear to be a valid part of a faction city");
                    return;
                }

                //Owner or city leader can fund
                if (gp.Owner != from && gp.Owner != data.CityLeader )
                {
                    from.SendMessage("That guard post does not belong to you");
                    return;
                }

                from.SendMessage("Select the silver you wish to fund it with");

                //Issue new target
                from.Target = new KinGuardPostFundTarget(gp);
            }
            else
            {
                Silver silver = targeted as Silver;
              //Silver stage
                if (silver == null)
                {
                    from.SendMessage("You may only fund the guard post with silver");
                    return;
                }
                if (!from.Backpack.Items.Contains(targeted))
                {
                    from.SendMessage("The silver must be in your backpack");
                }
                if (from.GetDistanceToSqrt(_guardPost.Location) > 3)
                {
                    from.SendMessage("You are not close enough to the guard post");
                    return;
                }

                //Verify owner
                KinCityData data = KinCityManager.GetCityData(_guardPost.City);
                if (data == null)
                {
                    from.SendMessage("That guard post does not appear to be a valid part of a faction city");
                    return;
                }

                //check again that the guard post exists and they are the owner
                if (_guardPost.Deleted || (_guardPost.Owner != from && _guardPost.Owner != data.CityLeader))
                {
                    from.SendMessage("The guard post no longer or exists or you are no longer the rightful owner");
                    return;
                }

                int amount = silver.Amount;

                if (amount <= 0)
                {
                    //should be impossible
                    from.SendMessage("Your guard post was not successfully funded");
                    return;
                }

                //Fund guardpost
                silver.Delete();
                _guardPost.Silver += amount;
                //if( !_guardPost.Running ) _guardPost.Running = true;
                from.SendMessage("Your guard post was successfully funded with {0} silver",amount);
            }
        }
示例#20
0
            /// <summary>
            /// Commit any outstanding changes
            /// </summary>
            /// <param name="sender"></param>
            void ICommitGumpEntity.CommitChanges()
            {
                if (!((ICommitGumpEntity)this).Validate())
                {
                    m_Gump.From.SendMessage("The guard post has been changed since you were modifying it. Please make the changes again.");
                    return;
                }
                if (m_State.IsValueDirty <KinFactionGuardTypes>("Type"))
                {
                    //set guard type

                    //TODO: - check some delay?
                    GuardPost.GuardType = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type");
                    m_Gump.From.SendMessage("Guard type changed to {0}.", KinSystem.GetEnumTypeDescription <KinFactionGuardTypes>((KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type")));
                }
                if (m_State.IsValueDirty <KinGuardPost.HireSpeeds>("Speed"))
                {
                    GuardPost.HireSpeed = (KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed");
                    m_Gump.From.SendMessage("Hire rate successfully changed to {0}", KinSystem.GetEnumTypeDescription <KinGuardPost.HireSpeeds>((KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed")));
                    GuardPost.RefreshNextSpawnTime();
                }
                if (m_State.IsValueDirty <int>("Slots"))
                {
                    KinFactionGuardTypes currentType = (KinFactionGuardTypes)m_State.GetOriginalValue <KinFactionGuardTypes>("Type");
                    KinFactionGuardTypes type        = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type");
                    int cost        = KinSystem.GetGuardCostType(type);
                    int currentCost = KinSystem.GetGuardCostType(currentType);
                    int slots       = 0;
                    slots += (currentCost - cost);
                    KinCityData data = KinCityManager.GetCityData(GuardPost.City);
                    if (data == null)
                    {
                        return;
                    }
                    KinCityData.BeneficiaryData bd = data.GetBeneficiary(GuardPost.Owner);
                    if (bd == null)
                    {
                        return;
                    }
                    bd.ModifyGuardSlots(slots);
                    m_Gump.From.SendMessage("Unassigned guard slots modified by {0}.", slots);
                }

                /*
                 * if (m_State.StyleChanged)
                 * {
                 *      //Assign new style
                 *      GuardPost.FightStyle = m_State.Style;
                 * }
                 */
                if (m_State.IsValueDirty <FightMode>("Target"))
                {
                    //Dont overwrite this one
                    // 0 the strongest, weakest, closest
                    //NAND out the options so these bits are all 0
                    GuardPost.FightMode &= ~FightMode.Strongest;
                    GuardPost.FightMode &= ~FightMode.Weakest;
                    GuardPost.FightMode &= ~FightMode.Closest;
                    //write new version
                    GuardPost.FightMode |= (FightMode)m_State.GetValue <FightMode>("Target");
                    m_Gump.From.SendMessage("Guard target priority successfully changed.");
                    GuardPost.UpdateExisitngGuards();
                }
            }