/// <summary> /// Function called from heartbeat job /// </summary> public static void ProcessSigils() { //This job is called every two hours, and is responsible for updating the cities' next capture times based on their //capture points. If a city will fall in less than four hours, its precise vortex spawn timer is started. //run if factions is on if (KinSystemSettings.CityCaptureEnabled) { //iterate through all the cities and update their capture time as neccesary foreach (KinFactionCities e in Enum.GetValues(typeof(KinFactionCities))) { KinCityData data = GetCityData(e); if (data == null) { continue; //should be impossible except "Other" } Logging.ActivityProcessing act = new ActivityProcessing(); act.City = data.City.ToString(); act.Kin = data.ControlingKin.ToString(); act.LogTime = DateTime.Now; //sanity if (data.Sigil == null || data.Sigil.Deleted) { Console.WriteLine("Warning: The faction city of " + e.ToString() + "'s sigil appears to have been deleted or not yet assigned."); continue; } if (!data.Sigil.Active) { continue; } //see if this city is in a voting stage which has now expired if (data.HasVotingStageExpired) { //process vote results and move on data.ProcessVotes(); } /* * //if not, but city is still within voting stage then ignore * else if (data.IsVotingStage) * { * continue; * } */ //Ignore if a vortex is already spawned, or in the process of spawning if (data.Sigil.InCapturePhase() || data.Sigil.IsVortexSpawning()) { continue; } //Update the control points / times ////////////////////////////////////////////////////////////////////////////// //Plasma: Explanation on how this works! ////////////////////////////////////////////////////////////////////////////// //A city starts off with 7 days on the clock. Each day passed will always reduce this by one day. //Each two hours, the actvity delta is taken which will be sitting at a max of +/- 100 //This is used to work out a percentage of pro or negative activity. //Note that pro activity counts for only a third that of negativity. This levels the algorithm //as it is constantly declining anyway and thus is balanced. ////////////////////////////////////////////////////////////////////////////// if (data.Sigil.NextEventTime == DateTime.MinValue) { return; } act.PointsProcessed = data.ActivityDelta; act.PreviousDecayTime = data.Sigil.NextEventTime; //plasma: skip all activity stuff if the sigil is in scheduled mode if (!data.Sigil.ScheduledMode) { //data.Sigil.NextEventTime = data.Sigil.NextEventTime.AddHours(-2.0); int activityDelta = data.ActivityDelta; int delayMinutes = 0; if (activityDelta > 0) { //Work out the slight additional increase that at max each beat will allow four extra days in delay delayMinutes = Convert.ToInt32(Math.Floor((double)(activityDelta / 100.0) * 36)); } else { //Work out the possibly massive additional decrease (up to 2.6 hours EXTRA so thats 3.6 hours) delayMinutes = -Convert.ToInt32(Math.Floor((double)(activityDelta / 100.0) * 160)); } //Reduce/increase minutes based on activity data.Sigil.NextEventTime = data.Sigil.NextEventTime.AddMinutes(delayMinutes); } act.NewDecayTime = data.Sigil.NextEventTime; act.TimeDeltaMinutes = (act.PreviousDecayTime - act.NewDecayTime).Minutes; KinFactionLogs.Instance.AddEntityToSerialize(act); //Wipe activity data.ClearActivityDelta(); //If the city's new capture time is in under 4 hours, start vortex spawn timer TimeSpan t = data.Sigil.NextEventTime - DateTime.Now; if (t <= TimeSpan.FromHours(4)) { data.Sigil.StartVortexSpawnTimer(); } } } else { Console.WriteLine("Nothing to do.. Faction town capture not switched on in KinSettings"); } }
/// <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 } }