Exemplo n.º 1
0
        /// <summary>
        /// Processes the visitor.
        /// </summary>
        /// <param name="pm">The pm.</param>
        private void ProcessVisitor(PlayerMobile pm)
        {
            if (CityData == null)
            {
                return;
            }
            if (CityData.ControlingKin != IOBAlignment.None && pm.IOBRealAlignment != CityData.ControlingKin && pm.IOBRealAlignment != IOBAlignment.None)
            {
                if (DateTime.Now > m_LastAnnounceTime.AddMinutes(15))
                {
                    m_LastAnnounceTime = DateTime.Now;
                    KinSystem.SendKinMessage(CityData.ControlingKin, string.Format("The City of {0} is under attack!  Come quickly to defend!", CityData.City.ToString()));

                    //a 25% chance this will be broadcast to all kin
                    if (Utility.RandomChance(25))
                    {
                        KinSystem.SendKinMessage(KinSystem.BroadcastOptions.ExcludeKin, new IOBAlignment[] { CityData.ControlingKin, pm.IOBRealAlignment }, string.Format("Spies report enemy Kin activity within the City of {0}..", CityData.City.ToString()));
                    }
                }
            }

            if (m_VisitorQueue.Contains(pm))
            {
                return;
            }

            if (m_VisitorQueue.Count > KinSystemSettings.A_MaxVisitors)
            {
                m_VisitorQueue.Dequeue();
            }

            m_VisitorQueue.Enqueue(pm);

            if (pm.IOBRealAlignment == IOBAlignment.None || pm.IOBRealAlignment == CityData.ControlingKin)
            {
                //good (or non factioned) guys, + activity
                ProcessActivity(KinFactionActivityTypes.FriendlyVisitor);
            }
            else
            {
                //bad dudes, - activity
                ProcessActivity(KinFactionActivityTypes.Visitor);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Transfers owership of a city to a kin or golem controller king
        /// </summary>
        /// <param name="city"></param>
        /// <param name="winners"></param>
        public static void TransferOwnership(KinFactionCities city, IOBAlignment kin, List <PlayerMobile> winners)
        {
            KinCityData cd = GetCityData(city);

            if (cd == null)
            {
                Console.WriteLine("Error in KinCityManager.TransferOwnership() - City Data not found");
                return;
            }

            //Set props that apply to both GC and Kin
            cd.CityLeader  = null;
            cd.CaptureTime = DateTime.Now;
            cd.ClearAllGuardPosts();
            cd.ClearActivityDelta();

            if (kin == IOBAlignment.None)             //GCs!
            {
                cd.ControlingKin = kin;
                //setup defaults for a controller city
                cd.IsVotingStage = false;
                cd.TaxRate       = 0.0;
                cd.BeneficiaryDataList.Clear();
                cd.UnassignedGuardPostSlots = 0;
                //Absorb treasury
                cd.EmptyTreasury();
                ChangeGuards(city, KinCityData.GuardOptions.None, true);
                cd.ClearNPCFLags();
                //Update townspeople spawners and switch on GCs
                UpdateCityNPCSpawners(cd.City);
                if (OnGolemController != null)
                {
                    OnGolemController(cd.City, true);
                }
            }
            else
            {
                //check to see if the city was previously owned by the controllers
                if (cd.ControlingKin == IOBAlignment.None)
                {
                    //if so then apply default settings for a town
                    cd.SetAllNPCFlags();
                    ChangeGuards(city, KinCityData.GuardOptions.None, true);
                    //Set last change time so they can change the guards immediately
                    cd.LastGuardChangeTime = DateTime.Now.AddHours(-KinSystemSettings.GuardChangeTimeHours);
                    //Update townspeople spawners and switch off GCs
                    UpdateCityNPCSpawners(cd.City);
                    SetGolemControllers(cd.City, false);
                    if (OnGolemController != null)
                    {
                        OnGolemController(cd.City, false);
                    }
                }
                else
                {
                    cd.LastGuardChangeTime = DateTime.Now.AddHours(-KinSystemSettings.GuardChangeTimeHours);
                }

                cd.ControlingKin = kin;
                //Assign voting info
                cd.BeneficiaryDataList.Clear();
                foreach (PlayerMobile pm in winners)
                {
                    cd.BeneficiaryDataList.Add(new KinCityData.BeneficiaryData(pm, 0));
                }

                //Change the guards to none if it is LB incase the new owners are all red
                if (cd.GuardOption == KinCityData.GuardOptions.LordBritish)
                {
                    ChangeGuards(cd.City, KinCityData.GuardOptions.None, true);
                }

                //Skip voting if only one beneficiary
                if (cd.BeneficiaryDataList.Count == 1)
                {
                    cd.CityLeader = cd.BeneficiaryDataList[0].Pm;
                }
                else
                {
                    cd.IsVotingStage = true;
                }

                cd.UnassignedGuardPostSlots = KinSystem.GetCityGuardPostSlots(city);
                //Voting is controlled by heartbeat
            }
        }