protected override void OnTick() { if (m_Cycle != 5) { //Display warning message if (KinCityManager.OnLBChangeWarning != null) { KinCityManager.OnLBChangeWarning(m_City); ++m_Cycle; Start(); } } else { //Switch on LB guards KinCityData cityData = KinCityManager.GetCityData(m_City); if (cityData != null) { //Don't change the guards if it's somehow now owned by the GCs if (cityData.ControlingKin == IOBAlignment.None) { return; } cityData.GuardOption = KinCityData.GuardOptions.LordBritish; cityData.ClearAllGuardPosts(); //Switch on patrol npc guard type cityData.SetNPCFlag(KinCityData.NPCFlags.Patrol, true); //Raise event for the regions to sort themselves out with the new changes if (KinCityManager.OnChangeGuards != null) { KinCityManager.OnChangeGuards(m_City, KinCityData.GuardOptions.LordBritish); } } } }
/// <summary> /// Called when [death]. /// </summary> /// <param name="m">The m.</param> /// <returns></returns> public void OnDeath(Mobile m) { if (m is GolemController) { ProcessActivity(KinFactionActivityTypes.GCDeath); } else if (m is PlayerMobile) { PlayerMobile pm = ((PlayerMobile)m); if (pm.IOBRealAlignment == IOBAlignment.None) { return; } KinCityData data = KinCityManager.GetCityData(City); if (data == null) { return; } if (data.ControlingKin == pm.IOBRealAlignment) { ProcessActivity(KinFactionActivityTypes.FriendlyDeath); } else { ProcessActivity(KinFactionActivityTypes.Death); } } else if (m is BaseCreature) { if (((BaseCreature)m).Spawner is KinGuardPost) { ProcessActivity(KinFactionActivityTypes.GuardDeath); } } }
/// <summary> /// Changes the guards. /// </summary> /// <param name="city">The city.</param> /// <param name="guardOption">The guard option.</param> public static void ChangeGuards(KinFactionCities city, KinCityData.GuardOptions guardOption, bool overrideTimeout) { KinCityData cityData = GetCityData(city); if (cityData == null) { return; } if (cityData.GuardOption == guardOption) { return; } if (!overrideTimeout) { if (DateTime.Now <= cityData.LastGuardChangeTime + TimeSpan.FromHours(KinSystemSettings.GuardChangeTimeHours)) { return; } } cityData.LastGuardChangeTime = DateTime.Now; if (guardOption == KinCityData.GuardOptions.LordBritish) { LBGuardTimer timer = new LBGuardTimer(city); timer.Start(); } else { cityData.GuardOption = guardOption; //Switch off patrol npc guard type cityData.SetNPCFlag(KinCityData.NPCFlags.Patrol, false); if (guardOption == KinCityData.GuardOptions.None) { cityData.ClearAllGuardPosts(); } //Update existing guards with the new rules foreach (KinCityData.BeneficiaryData bd in cityData.BeneficiaryDataList) { foreach (KinGuardPost kgp in bd.GuardPosts) { if (kgp != null && !kgp.Deleted) { kgp.UpdateExisitngGuards(); } } } //Raise event for the regions to sort themselves out with the new changes if (KinCityManager.OnChangeGuards != null) { KinCityManager.OnChangeGuards(city, guardOption); } } }
/// <summary> /// Processes the vote count, designates the city leader and switches off the voting stage /// </summary> /// <param name="data"></param> public void ProcessVotes() { List <PlayerMobile> winners = new List <PlayerMobile>(); PlayerMobile winner = null; //calculate who wins the vote for this city! //grab city data if (BeneficiaryDataList.Count == 0) { //TODO: might want to log this case? //Turn town over to the golem controllers KinCityManager.TransferOwnership(this.City, IOBAlignment.None, null); return; } //Call sort BeneficiaryDataList.Sort(new KinCityData.BeneficiaryDataComparer(KinCityData.BeneficiaryDataComparer.SortFields.Votes, true)); //Find highest vote int winningVote = BeneficiaryDataList[0].Votes; //Get the winner(s) foreach (KinCityData.BeneficiaryData v in BeneficiaryDataList) { if (v.Votes == winningVote) { winners.Add(v.Pm); } } if (winners.Count == 0) { //This should be impossible // turn city over to golem controllers KinCityManager.TransferOwnership(this.City, IOBAlignment.None, null); } else { //Pick a random mobile from the winners list to be leader winner = winners[Utility.Random(0, winners.Count - 1)]; } //more sanity if (winner == null) { //TODO: something here heh. should be massively impossible } //Establish winner as the leader of this city and declare voting over IsVotingStage = false; CityLeader = winner; foreach (BeneficiaryData bd in BeneficiaryDataList) { bd.Pm.SendMessage("The voting stage for the City of {0} has ended. {1} has been selected as the City Leader.", m_City.ToString(), winner.Name); } }
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 0x00EC: // *showscore* { if (KinSystemSettings.PointsEnabled && from is PlayerMobile && from.Alive) { PlayerMobile pm = from as PlayerMobile; from.PublicOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, true, string.Format("Unassisted: {0:0.00}", pm.KinSoloPoints)); from.PublicOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, true, string.Format("Assisted: {0:0.00}", pm.KinTeamPoints)); from.SendMessage("Unassisted: {0:0.00}", pm.KinSoloPoints); from.SendMessage("Assisted: {0:0.00}", pm.KinTeamPoints); from.SendMessage("Power: {0:0.00}", pm.KinPowerPoints); } break; } } } if (e.Mobile != null && e.Mobile is PlayerMobile && e.Mobile.Alive) { if (e.Speech.ToLower().IndexOf("i wish to place a guard post") > -1) { //wooo sanity! PlayerMobile pm = e.Mobile as PlayerMobile; if (pm == null || pm.IOBRealAlignment == IOBAlignment.None) { return; } //Check player is in a faction region if (!(pm.Region is KinCityRegion)) { pm.SendMessage("You are not within a faction city where you are a beneficiary."); return; } //Check they are a beneficiary KinCityData cityData = KinCityManager.GetCityData(((KinCityRegion)pm.Region).KinFactionCity); if (cityData == null) { return; } KinCityData.BeneficiaryData bd = cityData.GetBeneficiary(pm); if (bd == null) { pm.SendMessage("You are not within a faction city where you are a beneficiary."); return; } if (cityData.GuardOption == KinCityData.GuardOptions.LordBritish || cityData.GuardOption == KinCityData.GuardOptions.None) { pm.SendMessage("You may not place a guard post with your city's current guard policy"); return; } IPooledEnumerable eable = pm.GetItemsInRange(5); if (eable != null) { try { foreach (Item i in eable) { if (i != null && i is KinGuardPost && !i.Deleted) { pm.SendMessage("You may not place a guard post this close to another guard post"); return; } } } finally { eable.Free(); eable = null; } } eable = pm.GetItemsInRange(3); if (eable != null) { try { foreach (Item i in eable) { if (i != null && i is BaseDoor && !i.Deleted) { pm.SendMessage("You may not place a guard post this close to a door"); return; } } } finally { eable.Free(); eable = null; } } //Check they have enough spare guard slots if (bd.UnassignedGuardSlots < 1) { pm.SendMessage("You do not have enough free guard slots to create a guard post"); return; } //Test the 8 squares around the target tile to make sure there is nothing blocking there. for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { if (x == 0 && y == 0) { continue; //ignore the tile where they are standing } Point3D location = pm.Location; location.X += x; location.Y += y; if (!pm.Map.CanSpawnMobile(location)) { pm.SendMessage("You must have at least one free space in every direction around you."); return; } } } //Place & register guard post KinGuardPost kgp = new KinGuardPost(0x429, pm, KinFactionGuardTypes.FactionHenchman, ((KinCityRegion)pm.Region).KinFactionCity); if (bd.RegisterGuardPost(kgp)) { pm.SendMessage("Successfully created guard post."); kgp.MoveToWorld(pm.Location, pm.Map); kgp.Visible = true; } else { kgp.Delete(); } } else if (e.Speech.ToLower().IndexOf("i wish to fund my guard post") > -1) { //wooo sanity! PlayerMobile pm = e.Mobile as PlayerMobile; if (pm == null || pm.IOBRealAlignment == IOBAlignment.None) { return; } pm.SendMessage("Select the guard post you would like to fund"); pm.Target = new KinGuardPostFundTarget(); } else if (e.Speech.ToLower().IndexOf("i renounce my kin status") > -1) { ((PlayerMobile)e.Mobile).ResetIOBRankTime(); e.Mobile.SendMessage("You have reduced your rank."); } } }
/// <summary> /// Process vendor sales /// </summary> /// <param name="m"></param> /// <param name="totalCost"></param> public void OnVendorBuy(Mobile m, int totalTax) { ProcessShopper(m as PlayerMobile); KinCityManager.ProcessSale(City, m, totalTax); }
/// <summary> /// Processes the activity. /// </summary> /// <param name="type">The type.</param> public void ProcessActivity(KinFactionActivityTypes type) { KinCityManager.ProcessActivityDelta(City, type); }
public static void AwardPoints(object winner, PlayerMobile pm) { if (winner != null) { if (winner is PlayerMobile) { PlayerMobile pmWinner = (PlayerMobile)winner; int aggressorCount = 0; foreach (AggressorInfo ai in pm.Aggressors) { if (ai.Expired == false) { aggressorCount++; } } if (aggressorCount == 1) { //winner killed loser solo double loserPts = pm.KinSoloPoints; if (loserPts > -5.0) { double toAward = loserPts * 0.10; if (toAward < 1.0) { toAward = 1.0; } pm.KinSoloPoints -= toAward; pmWinner.KinSoloPoints += toAward; pmWinner.SendMessage("You've earned {0:0.00} individual points for slaying your enemy unassisted.", toAward); //Don't award defense capture points for killing players under 400 skill if (pm.SkillsTotal > 400) { //see if the loser is in a capture zone if (KinCityManager.InCaptureArea(pm)) { //find out if the loser was within range of any power vortexes foreach (PowerVortex pv in KinCityManager.GetVortexesInRange(pm)) { //Apply 1 defense capture point to the vortex's sigil pv.Sigil.AddDefensePoints(pmWinner, 1.0); pmWinner.SendMessage("You've earned 1 defense capture point for slaying your enemy unassisted."); if (pv.Sigil.RemoveDefensePoints(pm, 1.0)) { pm.SendMessage("You've lost a defense capture point."); } } } } } else { pmWinner.SendMessage("You gain no individual points from vanquishing that feeble foe."); } } else { //winner had some help double loserPts = pm.KinTeamPoints; if (loserPts > -5.0) { double toAward = loserPts * 0.10; if (toAward < 1.0) { toAward = 1.0; } pm.KinTeamPoints -= toAward; pmWinner.KinTeamPoints += toAward; pmWinner.SendMessage("You've earned {0:0.00} team points for slaying your enemy.", toAward); //Don't award defense capture points for killing players under 400 skill if (pm.SkillsTotal > 400) { if (KinCityManager.InCaptureArea(pm)) { //Find out if the loser was within range of any power vortexes foreach (PowerVortex pv in KinCityManager.GetVortexesInRange(pm)) { pv.Sigil.AddDefensePoints(pmWinner, 1.0); pmWinner.SendMessage("You've earned 1 defense capture point for slaying your enemy."); if (pv.Sigil.RemoveDefensePoints(pm, 1.0)) { pm.SendMessage("You've lost a defense capture point."); } } } } } else { pmWinner.SendMessage("You gain no team points from vanquishing that feeble foe."); } } } else { //winner is party if (winner is Server.Engines.PartySystem.Party) { Server.Engines.PartySystem.Party party = (Server.Engines.PartySystem.Party)winner; double loserPts = pm.KinTeamPoints; double toAward = 0.0; if (loserPts > -5.0) { toAward = loserPts * 0.10; if (toAward < 1.0) { toAward = 1.0; } } double toAwardEach = toAward / party.Members.Count; foreach (Server.Engines.PartySystem.PartyMemberInfo pmi in party.Members) { if (pmi != null) { if (pmi.Mobile != null) { if (pmi.Mobile is PlayerMobile) { if (toAward > 0) { ((PlayerMobile)pmi.Mobile).KinTeamPoints += toAwardEach; ((PlayerMobile)pmi.Mobile).SendMessage("You've earned {0:0.00} points for your party slaying your enemy.", toAwardEach); //Don't award defense capture points for killing players under 400 skill if (pm.SkillsTotal > 400) { if (KinCityManager.InCaptureArea(pm)) { double defensePoints = (1 / party.Members.Count); //find out if they are within range of any power vortexes foreach (PowerVortex pv in KinCityManager.GetVortexesInRange(pm)) { //Only ever give out 1 capture point per kill pv.Sigil.AddDefensePoints((pmi.Mobile as PlayerMobile), defensePoints); pmi.Mobile.SendMessage("You've earned {0:0.00} of a defense capture point for slaying your enemy assisted.", defensePoints); if (pv.Sigil.RemoveDefensePoints(pm, defensePoints)) { pm.SendMessage(string.Format("You've lost {0:0.00} of a defense capture point.", defensePoints)); } } } } } else { ((PlayerMobile)pmi.Mobile).SendMessage("You gain nothing from vanquishing that feeble foe."); } } } } } } } } }