/// <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(); } }
/// <summary> /// Deserializes the specified reader. /// </summary> /// <param name="reader">The reader.</param> public override void Deserialize(GenericReader reader) { base.Deserialize(reader); TimeSpan ts = TimeSpan.Zero; int version = reader.ReadInt(); switch (version) { case 1: { m_Reset = reader.ReadBool(); ts = reader.ReadDeltaTime() - DateTime.Now; m_NextMaintTime = DateTime.Now + ts; ts = reader.ReadDeltaTime() - DateTime.Now; m_NextSpawnTime = DateTime.Now + ts; m_SpawnTimeMinutes = reader.ReadInt(); m_GuardType = (KinFactionGuardTypes)reader.ReadInt(); goto case 0; } case 0: { m_City = (KinFactionCities)reader.ReadInt(); m_Owner = (PlayerMobile)reader.ReadMobile(); m_Silver = reader.ReadInt(); break; } } }
/// <summary> /// Initializes a new instance of the <see cref="KinCityData"/> class. /// </summary> /// <param name="city">The city.</param> public KinCityData(KinFactionCities city) { this.m_City = city; this.m_CaptureTime = DateTime.Now; this.m_ControlingKin = IOBAlignment.None; this.m_GuardOption = GuardOptions.LordBritish; this.SetAllNPCFlags(); }
/// <summary> /// Returns the city data class for a given city /// </summary> /// <param name="city"></param> /// <returns></returns> public static KinCityData GetCityData(KinFactionCities city) { //check this city exists in the collection if (_cityData == null || (!_cityData.ContainsKey(city))) { return(null); } return(_cityData[city]); }
/// <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 sale, adding the tax to the treasury. /// </summary> /// <param name="city">The city.</param> /// <param name="vendor">The vendor.</param> /// <param name="totalCost">The tax to add</param> public static void ProcessSale(KinFactionCities city, Mobile vendor, int totalTax) { KinCityData data = GetCityData(city); if (data == null) { return; } if (data.ControlingKin != IOBAlignment.None) { data.AddToTreasury(totalTax); } }
/// <summary> /// Initializes a new instance of the <see cref="KinGuardPost"/> class. /// </summary> /// <param name="itemID">The item ID.</param> /// <param name="owner">The owner.</param> /// <param name="guardType">Type of the guard.</param> /// <param name="city">The city.</param> public KinGuardPost(int itemID, PlayerMobile owner, KinFactionGuardTypes guardType, KinFactionCities city) { this.ItemID = itemID; Movable = false; Visible = true; m_City = city; m_Owner = owner; m_GuardType = guardType; ArrayList creaturesName = new ArrayList(); //bah *! $ arraylists creaturesName.Add(guardType.ToString()); InitSpawn(1, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), 0, 4, creaturesName); }
/// <summary> /// Initializes a new instance of the <see cref="KinCityData"/> class. /// </summary> /// <param name="reader">The reader.</param> public KinCityData(BinaryFileReader reader) { int version = reader.ReadInt(); switch (version) { case 2: { m_Treasury = reader.ReadInt(); m_TaxRate = reader.ReadDouble(); goto case 1; } case 1: { m_UnassignedGuardSlots = reader.ReadInt(); goto case 0; } case 0: { m_City = (KinFactionCities)reader.ReadInt(); m_ControlingKin = (IOBAlignment)reader.ReadInt(); m_CaptureTime = reader.ReadDeltaTime(); m_CityLeader = (PlayerMobile)reader.ReadMobile(); m_IsVotingStage = reader.ReadBool(); m_Sigil = (KinSigil)reader.ReadItem(); m_ControlPoints = reader.ReadInt(); m_ControlPointDelta = reader.ReadInt(); m_NPCFlags = (NPCFlags)reader.ReadInt(); m_GuardOption = (GuardOptions)reader.ReadInt(); m_LastGuardChangeTime = reader.ReadDeltaTime(); int length = reader.ReadInt(); if (length > 0) { for (int i = 0; i < length; ++i) { m_BeneficiaryDataList.Add(new BeneficiaryData(reader)); } } break; } } }
/// <summary> /// GCs are toggled seperately as they are not a normal part of the townspeople /// </summary> /// <param name="city"></param> /// <param name="on"></param> public static void SetGolemControllers(KinFactionCities city, bool on) { //PLASMA: This is not being used atm as I wrote ChampKinCity to do this. List <Type> typesOn = new List <Type>(); List <Type> typesOff = new List <Type>(); if (on) { typesOn.Add(typeof(GolemController)); } else { typesOff.Add(typeof(GolemController)); } SetNPCSpawners(city, typesOn, typesOff); }
/// <summary> /// Processes the activity delta. (Forwards the data on to the relevant city) /// </summary> /// <param name="city">The city.</param> /// <param name="delta">The delta.</param> public static void ProcessActivityDelta(KinFactionCities city, KinFactionActivityTypes type) { KinCityData data = GetCityData(city); if (data == null) { return; } //log that shit Logging.ActivityGranular act = new Server.Engines.IOBSystem.Logging.ActivityGranular(); act.ActivityType = type.ToString(); act.City = city.ToString(); act.Kin = data.ControlingKin.ToString(); act.LogTime = DateTime.Now; Logging.KinFactionLogs.Instance.AddEntityToSerialize(act); data.ProcessActivityDelta(GetActivityDeltaAmount(type)); }
void KinCityManager_OnLBChangeWarning(KinFactionCities city) { if (IsControllerGood() && city == KinFactionCity) { //Deal with this one here because we need access to the mobiles collection if (Mobiles != null && Mobiles.Count > 0) { foreach (KeyValuePair <Serial, Mobile> kvp in Mobiles) { if (kvp.Value is PlayerMobile) { kvp.Value.SendMessage("Lord British's guards will be returning to active duty shortly!"); } } } } }
/// <summary> /// Returns the amount of slots assigned to this city when ownership transfers /// </summary> /// <returns></returns> public static int GetCityGuardPostSlots(KinFactionCities city) { int slots = KinSystemSettings.CityGuardSlots; //Default Type t = typeof(KinFactionCities); FieldInfo fi = t.GetField(city.ToString()); foreach (KinFactionCityAttribute att in fi.GetCustomAttributes(typeof(KinFactionCityAttribute), true)) { if (att.GuardSlots > 0) { slots = att.GuardSlots; } } return(slots); }
/// <summary> /// Gets the city spawners. /// </summary> /// <param name="city">The city.</param> /// <returns></returns> private static List<Spawner> GetCitySpawners(KinFactionCities city) { return SpawnerCache.GetSpawnersByRegion(city.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="KinCityControlGump"/> class. /// </summary> /// <param name="city">The city.</param> public KinCityControlGump(KinFactionCities city, Mobile from) : this(city, 1, from) { }
/// <summary> /// Switches on/off the spawners in a given city's region where they spawn any of the provided types /// </summary> /// <param name="city"></param> /// <param name="types"></param> /// <param name="on"></param> private static void SetNPCSpawners(KinFactionCities city, List<Type> typesOn, List<Type> typesOff) { List<Spawner> regionSpawners = GetCitySpawners(city); if (regionSpawners == null || regionSpawners.Count == 0) return; List<Spawner> toSwitchOn = new List<Spawner>(); //Holds list of spawners that need changing List<Spawner> toSwitchOff = new List<Spawner>(); //Holds list of spawners that need changing foreach (Spawner spawner in regionSpawners) { bool found = false; //Check to see if the spawner contains any of the required NPC types to switch on foreach (Type t in typesOn) { foreach (string s in spawner.CreaturesName) if (t.Name.ToLower() == s) { found = true; if (spawner.Running) //already doing what it should be break; //Found a match, add this to the switch on list and break out of the loop toSwitchOn.Add(spawner); break; } //break out if found if (found) break; } //if not found, check against the off types if (!found) { //Check to see if the spawner contains any of the required NPC types to switch off foreach (Type t in typesOff) { foreach (string s in spawner.CreaturesName) if (t.Name.ToLower() == s) { found = true; if (!spawner.Running) //already doing what it should be break; //Found a match, add this to the switch off list and break out of the loop toSwitchOff.Add(spawner); break; } //break out if found if (found) break; } } } //switch on any required spawners foreach (Spawner spawner in toSwitchOn) { spawner.Start(); spawner.Spawn(); } //switch off any required spawners foreach (Spawner spawner in toSwitchOff) { //switch spawner off spawner.Stop(); //delete the active mobiles and remove them from the creature list spawner.RemoveCreatures(); } }
void KinCityManager_OnLBChangeWarning(KinFactionCities city) { if (IsControllerGood() && city == KinFactionCity) { //Deal with this one here because we need access to the mobiles collection if (Mobiles != null && Mobiles.Count > 0) { foreach (KeyValuePair<Serial,Mobile> kvp in Mobiles) { if (kvp.Value is PlayerMobile) { kvp.Value.SendMessage("Lord British's guards will be returning to active duty shortly!"); } } } } }
/// <summary> /// Handles the guard change, will switch on/off the guards depending if the new guard option is Lord British /// </summary> /// <param name="city">The city.</param> /// <param name="guardOption">The guard option.</param> private void KinCityManager_OnChangeGuards(KinFactionCities city, KinCityData.GuardOptions guardOption) { if (IsControllerGood() && KinFactionCity == city) { ((KinCityRegionStone)m_Controller).KinCityManager_OnChangeGuards(guardOption); } }
/// <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) { ChangeGuards(city, guardOption, false); }
/// <summary> /// Processes the sale, adding the tax to the treasury. /// </summary> /// <param name="city">The city.</param> /// <param name="vendor">The vendor.</param> /// <param name="totalCost">The tax to add</param> public static void ProcessSale(KinFactionCities city, Mobile vendor, int totalTax) { KinCityData data = GetCityData(city); if (data == null) return; if (data.ControlingKin != IOBAlignment.None) data.AddToTreasury(totalTax); }
/// <summary> /// Deserializes the specified reader. /// </summary> /// <param name="reader">The reader.</param> public override void Deserialize(GenericReader reader) { TimeSpan ts = TimeSpan.Zero; bool timerActive = false; base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 1: { m_ScheduledMode = reader.ReadBool(); goto case 0; } case 0: { m_City = (KinFactionCities)reader.ReadInt(); m_Vortex = (PowerVortex)reader.ReadMobile(); ts = reader.ReadDeltaTime() - DateTime.Now; m_VortexSpawnLocation = reader.ReadPoint3D(); m_Active = reader.ReadBool(); timerActive = reader.ReadBool(); break; } } if (timerActive) { //Sort out the timer state: //Whilst in capture phase, _time will represent the expire time of the current vortex, so start timer with new delay if (InCapturePhase()) { if (ts == TimeSpan.Zero) { //something weird happened, start expire timer afresh from kinsettings m_Time = DateTime.Now + TimeSpan.FromHours(KinSystemSettings.VortexExpireMinutes); } else { m_Time = DateTime.Now + ts; } if (m_Time < DateTime.Now) { //Vortex should have expired already, set it for 1 minute ts = TimeSpan.FromMinutes(1); } m_Timer = new VortexExpireTimer(ts, this); } else //if there's no vortex then the time represents the next spawn time { //Apply the delta and create a timer m_Time = DateTime.Now + ts; m_Timer = new VortexSpawnTimer(this); } //Only start the timer if Active if (m_Active) { m_Timer.Start(); } } else { m_Time = DateTime.Now + ts; } }
/// <summary> /// Deserializes the specified reader. /// </summary> /// <param name="reader">The reader.</param> public override void Deserialize(GenericReader reader) { base.Deserialize(reader); TimeSpan ts = TimeSpan.Zero; int version = reader.ReadInt(); switch (version) { case 1: { m_Reset = reader.ReadBool(); ts = reader.ReadDeltaTime() - DateTime.Now; m_NextMaintTime = DateTime.Now + ts; ts = reader.ReadDeltaTime() - DateTime.Now; m_NextSpawnTime = DateTime.Now + ts; m_SpawnTimeMinutes = reader.ReadInt(); m_GuardType = (KinFactionGuardTypes)reader.ReadInt(); goto case 0; } case 0: { m_City = (KinFactionCities)reader.ReadInt(); m_Owner = (PlayerMobile)reader.ReadMobile(); m_Silver = reader.ReadInt(); break; } } }
/// <summary> /// Updates the city NPC spawners. /// </summary> /// <param name="city">The city.</param> public static void UpdateCityNPCSpawners(KinFactionCities city) { KinCityData data = GetCityData(city); if (data == null) //woo sanity { return; } List <Type> switchOn = new List <Type>(); List <Type> switchOff = new List <Type>(); List <Type> addTo = null; //Populate the spawners to always switch off (kin stuff, fighters, rangers, etc) switchOff.Add(typeof(Fighter)); switchOff.Add(typeof(Ranger)); switchOff.Add(typeof(Paladin)); foreach (KinCityData.NPCFlags npcFlag in Enum.GetValues(typeof(KinCityData.NPCFlags))) { if (npcFlag == KinCityData.NPCFlags.None) { continue; } if (data.GetNPCFlag(npcFlag)) //set reference to relevant collection { addTo = switchOn; } else { addTo = switchOff; } switch (npcFlag) //add NPC types { case KinCityData.NPCFlags.Animal: { addTo.Add(typeof(AnimalTrainer)); addTo.Add(typeof(Veterinarian)); break; } case KinCityData.NPCFlags.Bank: { addTo.Add(typeof(Banker)); addTo.Add(typeof(Minter)); break; } case KinCityData.NPCFlags.Carpenter: { addTo.Add(typeof(GeneralContractor)); addTo.Add(typeof(Carpenter)); addTo.Add(typeof(RealEstateBroker)); addTo.Add(typeof(Architect)); addTo.Add(typeof(StoneCrafter)); break; } case KinCityData.NPCFlags.EatDrink: { addTo.Add(typeof(Barkeeper)); addTo.Add(typeof(Waiter)); addTo.Add(typeof(Cook)); addTo.Add(typeof(TavernKeeper)); addTo.Add(typeof(Farmer)); addTo.Add(typeof(Butcher)); addTo.Add(typeof(Fisherman)); break; } case KinCityData.NPCFlags.FightBroker: { addTo.Add(typeof(FightBroker)); break; } case KinCityData.NPCFlags.Gypsy: { addTo.Add(typeof(GypsyTrader)); break; } case KinCityData.NPCFlags.Healer: { addTo.Add(typeof(Healer)); addTo.Add(typeof(EvilHealer)); addTo.Add(typeof(HealerGuildmaster)); break; } case KinCityData.NPCFlags.Inn: { addTo.Add(typeof(InnKeeper)); break; } case KinCityData.NPCFlags.Mages: { addTo.Add(typeof(Mage)); addTo.Add(typeof(MageGuildmaster)); addTo.Add(typeof(Alchemist)); addTo.Add(typeof(Herbalist)); addTo.Add(typeof(HairStylist)); break; } case KinCityData.NPCFlags.Misc: { addTo.Add(typeof(Tinker)); addTo.Add(typeof(TinkerGuildmaster)); addTo.Add(typeof(Furtrader)); addTo.Add(typeof(Tanner)); addTo.Add(typeof(BardGuildmaster)); addTo.Add(typeof(Bard)); addTo.Add(typeof(Bowyer)); addTo.Add(typeof(MerchantGuildmaster)); addTo.Add(typeof(Shipwright)); addTo.Add(typeof(Mapmaker)); addTo.Add(typeof(Scribe)); addTo.Add(typeof(Jeweler)); addTo.Add(typeof(Baker)); addTo.Add(typeof(MinerGuildmaster)); addTo.Add(typeof(WarriorGuildmaster)); break; } case KinCityData.NPCFlags.Patrol: { addTo.Add(typeof(PatrolGuard)); break; } case KinCityData.NPCFlags.Provisioner: { addTo.Add(typeof(Provisioner)); addTo.Add(typeof(Cobbler)); break; } case KinCityData.NPCFlags.Quest: { addTo.Add(typeof(BaseEscortable)); addTo.Add(typeof(Noble)); addTo.Add(typeof(SeekerOfAdventure)); break; } case KinCityData.NPCFlags.Smith: { addTo.Add(typeof(Blacksmith)); addTo.Add(typeof(BlacksmithGuildmaster)); break; } case KinCityData.NPCFlags.Tailor: { addTo.Add(typeof(Tailor)); addTo.Add(typeof(Weaver)); addTo.Add(typeof(TailorGuildmaster)); break; } case KinCityData.NPCFlags.TownCrier: { addTo.Add(typeof(TownCrier)); break; } case KinCityData.NPCFlags.WeaponArmour: { addTo.Add(typeof(Armorer)); addTo.Add(typeof(Weaponsmith)); break; } } } SetNPCSpawners(city, switchOn, switchOff); }
/// <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 } }
/// <summary> /// Gets the city spawners. /// </summary> /// <param name="city">The city.</param> /// <returns></returns> private static List <Spawner> GetCitySpawners(KinFactionCities city) { return(SpawnerCache.GetSpawnersByRegion(city.ToString())); }
/// <summary> /// Switches on/off the spawners in a given city's region where they spawn any of the provided types /// </summary> /// <param name="city"></param> /// <param name="types"></param> /// <param name="on"></param> private static void SetNPCSpawners(KinFactionCities city, List <Type> typesOn, List <Type> typesOff) { List <Spawner> regionSpawners = GetCitySpawners(city); if (regionSpawners == null || regionSpawners.Count == 0) { return; } List <Spawner> toSwitchOn = new List <Spawner>(); //Holds list of spawners that need changing List <Spawner> toSwitchOff = new List <Spawner>(); //Holds list of spawners that need changing foreach (Spawner spawner in regionSpawners) { bool found = false; //Check to see if the spawner contains any of the required NPC types to switch on foreach (Type t in typesOn) { foreach (string s in spawner.CreaturesName) { if (t.Name.ToLower() == s) { found = true; if (spawner.Running) //already doing what it should be { break; } //Found a match, add this to the switch on list and break out of the loop toSwitchOn.Add(spawner); break; } } //break out if found if (found) { break; } } //if not found, check against the off types if (!found) { //Check to see if the spawner contains any of the required NPC types to switch off foreach (Type t in typesOff) { foreach (string s in spawner.CreaturesName) { if (t.Name.ToLower() == s) { found = true; if (!spawner.Running) //already doing what it should be { break; } //Found a match, add this to the switch off list and break out of the loop toSwitchOff.Add(spawner); break; } } //break out if found if (found) { break; } } } } //switch on any required spawners foreach (Spawner spawner in toSwitchOn) { spawner.Start(); spawner.Spawn(); } //switch off any required spawners foreach (Spawner spawner in toSwitchOff) { //switch spawner off spawner.Stop(); //delete the active mobiles and remove them from the creature list spawner.RemoveCreatures(); } }
/// <summary> /// Initializes a new instance of the <see cref="KinCityControlGump"/> class. /// </summary> /// <param name="city">The city.</param> /// <param name="page">The page.</param> public KinCityControlGump(KinFactionCities city, int page, Mobile from) : this(city, page, null, from) { }
/// <summary> /// Updates the city NPC spawners. /// </summary> /// <param name="city">The city.</param> public static void UpdateCityNPCSpawners(KinFactionCities city) { KinCityData data = GetCityData(city); if (data == null) //woo sanity return; List<Type> switchOn = new List<Type>(); List<Type> switchOff = new List<Type>(); List<Type> addTo = null; //Populate the spawners to always switch off (kin stuff, fighters, rangers, etc) switchOff.Add(typeof(Fighter)); switchOff.Add(typeof(Ranger)); switchOff.Add(typeof(Paladin)); foreach (KinCityData.NPCFlags npcFlag in Enum.GetValues(typeof(KinCityData.NPCFlags))) { if (npcFlag == KinCityData.NPCFlags.None) continue; if (data.GetNPCFlag(npcFlag)) //set reference to relevant collection addTo = switchOn; else addTo = switchOff; switch (npcFlag) //add NPC types { case KinCityData.NPCFlags.Animal: { addTo.Add(typeof(AnimalTrainer)); addTo.Add(typeof(Veterinarian)); break; } case KinCityData.NPCFlags.Bank: { addTo.Add(typeof(Banker)); addTo.Add(typeof(Minter)); break; } case KinCityData.NPCFlags.Carpenter: { addTo.Add(typeof(GeneralContractor)); addTo.Add(typeof(Carpenter)); addTo.Add(typeof(RealEstateBroker)); addTo.Add(typeof(Architect)); addTo.Add(typeof(StoneCrafter)); break; } case KinCityData.NPCFlags.EatDrink: { addTo.Add(typeof(Barkeeper)); addTo.Add(typeof(Waiter)); addTo.Add(typeof(Cook)); addTo.Add(typeof(TavernKeeper)); addTo.Add(typeof(Farmer)); addTo.Add(typeof(Butcher)); addTo.Add(typeof(Fisherman)); break; } case KinCityData.NPCFlags.FightBroker: { addTo.Add(typeof(FightBroker)); break; } case KinCityData.NPCFlags.Gypsy: { addTo.Add(typeof(GypsyTrader)); break; } case KinCityData.NPCFlags.Healer: { addTo.Add(typeof(Healer)); addTo.Add(typeof(EvilHealer)); addTo.Add(typeof(HealerGuildmaster)); break; } case KinCityData.NPCFlags.Inn: { addTo.Add(typeof(InnKeeper)); break; } case KinCityData.NPCFlags.Mages: { addTo.Add(typeof(Mage)); addTo.Add(typeof(MageGuildmaster)); addTo.Add(typeof(Alchemist)); addTo.Add(typeof(Herbalist)); addTo.Add(typeof(HairStylist)); break; } case KinCityData.NPCFlags.Misc: { addTo.Add(typeof(Tinker)); addTo.Add(typeof(TinkerGuildmaster)); addTo.Add(typeof(Furtrader)); addTo.Add(typeof(Tanner)); addTo.Add(typeof(BardGuildmaster)); addTo.Add(typeof(Bard)); addTo.Add(typeof(Bowyer)); addTo.Add(typeof(MerchantGuildmaster)); addTo.Add(typeof(Shipwright)); addTo.Add(typeof(Mapmaker)); addTo.Add(typeof(Scribe)); addTo.Add(typeof(Jeweler)); addTo.Add(typeof(Baker)); addTo.Add(typeof(MinerGuildmaster)); addTo.Add(typeof(WarriorGuildmaster)); break; } case KinCityData.NPCFlags.Patrol: { addTo.Add(typeof(PatrolGuard)); break; } case KinCityData.NPCFlags.Provisioner: { addTo.Add(typeof(Provisioner)); addTo.Add(typeof(Cobbler)); break; } case KinCityData.NPCFlags.Quest: { addTo.Add(typeof(BaseEscortable)); addTo.Add(typeof(Noble)); addTo.Add(typeof(SeekerOfAdventure)); break; } case KinCityData.NPCFlags.Smith: { addTo.Add(typeof(Blacksmith)); addTo.Add(typeof(BlacksmithGuildmaster)); break; } case KinCityData.NPCFlags.Tailor: { addTo.Add(typeof(Tailor)); addTo.Add(typeof(Weaver)); addTo.Add(typeof(TailorGuildmaster)); break; } case KinCityData.NPCFlags.TownCrier: { addTo.Add(typeof(TownCrier)); break; } case KinCityData.NPCFlags.WeaponArmour: { addTo.Add(typeof(Armorer)); addTo.Add(typeof(Weaponsmith)); break; } } } SetNPCSpawners(city, switchOn, switchOff); }
/// <summary> /// Initializes a new instance of the <see cref="KinGuardPost"/> class. /// </summary> /// <param name="itemID">The item ID.</param> /// <param name="owner">The owner.</param> /// <param name="guardType">Type of the guard.</param> /// <param name="city">The city.</param> public KinGuardPost(int itemID, PlayerMobile owner, KinFactionGuardTypes guardType, KinFactionCities city) { this.ItemID = itemID; Movable = false; Visible = true; m_City = city; m_Owner = owner; m_GuardType = guardType; ArrayList creaturesName = new ArrayList(); //bah *! $ arraylists creaturesName.Add(guardType.ToString()); InitSpawn(1, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), 0, 4, creaturesName); }
/// <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 } }
/// <summary> /// Deserializes the specified reader. /// </summary> /// <param name="reader">The reader.</param> public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 3: { m_LastAnnounceTime = reader.ReadDateTime(); goto case 2; } case 2: { m_ShopperQueue = new Queue<PlayerMobile>(reader.ReadMobileList<PlayerMobile>()); goto case 1; } case 1: { m_VisitorQueue = new Queue<PlayerMobile>(reader.ReadMobileList<PlayerMobile>()); m_City = (KinFactionCities)reader.ReadInt(); m_Champs = reader.ReadItemList<ChampKinCity>(); goto case 0; } case 0: break; } }
/// <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); } } }
public LBGuardTimer(KinFactionCities city) : base(TimeSpan.FromMinutes(1)) { m_City = city; }
/// <summary> /// Processes the activity delta. (Forwards the data on to the relevant city) /// </summary> /// <param name="city">The city.</param> /// <param name="delta">The delta.</param> public static void ProcessActivityDelta(KinFactionCities city, KinFactionActivityTypes type) { KinCityData data = GetCityData(city); if (data == null) return; //log that shit Logging.ActivityGranular act = new Server.Engines.IOBSystem.Logging.ActivityGranular(); act.ActivityType = type.ToString(); act.City = city.ToString(); act.Kin = data.ControlingKin.ToString(); act.LogTime = DateTime.Now; Logging.KinFactionLogs.Instance.AddEntityToSerialize(act); data.ProcessActivityDelta(GetActivityDeltaAmount(type)); }
/// <summary> /// Returns the city data class for a given city /// </summary> /// <param name="city"></param> /// <returns></returns> public static KinCityData GetCityData(KinFactionCities city) { //check this city exists in the collection if (_cityData == null || (!_cityData.ContainsKey(city))) return null; return _cityData[city]; }
/// <summary> /// Kins the city manager_ on golem controller. /// </summary> /// <param name="city">The city.</param> /// <param name="on">if set to <c>true</c> [on].</param> private void KinCityManager_OnGolemController(KinFactionCities city, bool on) { if (IsControllerGood() && city == KinFactionCity) { ((KinCityRegionStone)m_Controller).KinCityManager_OnGolemController(on); } }
/// <summary> /// GCs are toggled seperately as they are not a normal part of the townspeople /// </summary> /// <param name="city"></param> /// <param name="on"></param> public static void SetGolemControllers(KinFactionCities city, bool on) { //PLASMA: This is not being used atm as I wrote ChampKinCity to do this. List<Type> typesOn = new List<Type>(); List<Type> typesOff = new List<Type>(); if (on) { typesOn.Add(typeof(GolemController)); } else { typesOff.Add(typeof(GolemController)); } SetNPCSpawners(city, typesOn, typesOff); }
/// <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) { ChangeGuards(city, guardOption, false); }
public LBGuardTimer(KinFactionCities city) : base(TimeSpan.FromMinutes(1)) { m_City = city; }