public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack)) { return; } if (info.ButtonID == 2) // Combine { m_From.SendGump(new LargeBODGump(m_From, m_Deed)); m_Deed.BeginCombine(m_From); } else if (info.ButtonID == 3) // bank button { BODContext c = BulkOrderSystem.GetContext(m_From); if (c != null) { switch (c.PointsMode) { case PointsMode.Enabled: c.PointsMode = PointsMode.Disabled; break; case PointsMode.Disabled: c.PointsMode = PointsMode.Automatic; break; case PointsMode.Automatic: c.PointsMode = PointsMode.Enabled; break; } } m_From.SendGump(new LargeBODGump(m_From, m_Deed)); } else if (info.ButtonID == 4) // combine from container { m_From.BeginTarget(-1, false, Targeting.TargetFlags.None, (m, targeted) => { if (!m_Deed.Deleted && targeted is Container container) { List <SmallBOD> list = new List <SmallBOD>(); for (var index = 0; index < container.Items.Count; index++) { Item item = container.Items[index]; if (item is SmallBOD bod) { list.Add(bod); } } for (var index = 0; index < list.Count; index++) { SmallBOD item = list[index]; m_Deed.EndCombine(m_From, item); } list.Clear(); } }); } }
public static TimeSpan GetNextBulkOrder(BODType type, PlayerMobile pm) { BODContext context = GetContext(pm); if (context != null) { if (NewSystemEnabled) { DateTime last = context.Entries[type].LastBulkOrder; return((last + TimeSpan.FromHours(Delay)) - DateTime.UtcNow); } else if (context.Entries.ContainsKey(type)) { DateTime dt = context.Entries[type].NextBulkOrder; if (dt < DateTime.UtcNow) { return(TimeSpan.Zero); } return(DateTime.UtcNow - dt); } } return(TimeSpan.MaxValue); }
public static bool CanGetBulkOrder(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null && context.Entries.ContainsKey(type)) { var entry = context.Entries[type]; if (entry != null) { if (entry.CachedDeeds > 0) { entry.CachedDeeds--; return(true); } else if (entry.LastBulkOrder + TimeSpan.FromHours(Delay) < DateTime.UtcNow) { if (entry.LastBulkOrder == DateTime.MinValue) { entry.LastBulkOrder = DateTime.UtcNow - TimeSpan.FromHours(Delay); } entry.LastBulkOrder = entry.LastBulkOrder + TimeSpan.FromHours(Delay); return(true); } } } return(false); }
public static void SetNextBulkOrder(BODType type, PlayerMobile pm, TimeSpan ts) { BODContext context = GetContext(pm); if (context != null) { if (NewSystemEnabled) { if (context.Entries.ContainsKey(type)) { if (context.Entries[type].LastBulkOrder < DateTime.UtcNow - TimeSpan.FromHours(Delay * MaxCachedDeeds)) { context.Entries[type].LastBulkOrder = DateTime.UtcNow - TimeSpan.FromHours(Delay * MaxCachedDeeds); } else { context.Entries[type].LastBulkOrder = (context.Entries[type].LastBulkOrder + ts) - TimeSpan.FromHours(Delay); } } } else if (context.Entries.ContainsKey(type)) { context.Entries[type].NextBulkOrder = DateTime.UtcNow + ts; } } }
public static void AddToPending(Mobile m, BODType type, int points) { BODContext context = GetContext(m); if (context != null) { context.AddPending(type, points); } }
public static void RemovePending(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null) { context.RemovePending(type); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack)) { return; } switch (info.ButtonID) { case 2: // Combine { m_From.SendGump(new SmallBODGump(m_From, m_Deed)); m_Deed.BeginCombine(m_From); break; } case 3: // points mode { BODContext c = BulkOrderSystem.GetContext(m_From); if (c != null) { switch (c.PointsMode) { case PointsMode.Enabled: c.PointsMode = PointsMode.Disabled; break; case PointsMode.Disabled: c.PointsMode = PointsMode.Automatic; break; case PointsMode.Automatic: c.PointsMode = PointsMode.Enabled; break; } } m_From.SendGump(new SmallBODGump(m_From, m_Deed)); break; } case 4: // combine from container { m_From.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, (m, targeted) => { if (!m_Deed.Deleted && targeted is Container) { List <Item> list = new List <Item>(((Container)targeted).Items); foreach (Item item in list) { m_Deed.EndCombine(m_From, item); } } }); break; } } }
public static bool CanClaimRewards(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null) { return(context.CanClaimRewards(type)); } return(true); }
public static int GetPendingRewardFor(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null && context.Entries.ContainsKey(type)) { return(context.Entries[type].PendingRewardPoints); } return(0); }
public static double GetPoints(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null) { if (context.Entries.ContainsKey(type)) { return(context.Entries[type].BankedPoints); } } return(0); }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack)) { return; } if (info.ButtonID == 2) // Combine { m_From.SendGump(new LargeBODGump(m_From, m_Deed)); m_Deed.BeginCombine(m_From); } else if (info.ButtonID == 3) // bank button { BODContext c = BulkOrderSystem.GetContext(m_From); if (c != null) { switch (c.PointsMode) { case PointsMode.Enabled: c.PointsMode = PointsMode.Disabled; break; case PointsMode.Disabled: c.PointsMode = PointsMode.Automatic; break; case PointsMode.Automatic: c.PointsMode = PointsMode.Enabled; break; } } m_From.SendGump(new LargeBODGump(m_From, m_Deed)); } else if (info.ButtonID == 4) // combine from container { m_From.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, (m, targeted) => { if (!m_Deed.Deleted && targeted is Container) { List <SmallBOD> list = ((Container)targeted).Items.OfType <SmallBOD>().ToList(); foreach (SmallBOD item in list) { m_Deed.EndCombine(m_From, item); } list.Clear(); } }); } }
public static void SetPoints(Mobile m, BODType type, double points) { if (points < 0) { points = 0.0; } BODContext context = GetContext(m); if (context != null) { if (context.Entries.ContainsKey(type)) { context.Entries[type].BankedPoints += points; } } }
public void Deserialize(GenericReader reader) { int version = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile player = reader.ReadMobile() as PlayerMobile; BODContext context = new BODContext(reader); if (player != null) { BODPlayerData[player] = context; } } }
public static bool CanGetBulkOrder(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null && context.Entries.ContainsKey(type)) { if (context.Entries[type].CachedDeeds == 0) { DateTime last = context.Entries[type].LastBulkOrder; int tocache = 0; if (last + TimeSpan.FromHours(Delay) < DateTime.UtcNow) { int minutes = (int)(DateTime.UtcNow - last).TotalMinutes; tocache = (int)(minutes / ((double)Delay * 60)); } if (tocache > 0) { context.Entries[type].CachedDeeds = Math.Min(MaxCachedDeeds, context.Entries[type].CachedDeeds + tocache); } } if (context.Entries[type].CachedDeeds > 0) { if (context.Entries[type].CachedDeeds >= MaxCachedDeeds) { context.Entries[type].LastBulkOrder = DateTime.UtcNow - TimeSpan.FromHours(Delay * MaxCachedDeeds); } context.Entries[type].LastBulkOrder += TimeSpan.FromHours(Delay); context.Entries[type].CachedDeeds--; if (context.Entries[type].CachedDeeds == 0 && context.Entries[type].LastBulkOrder < DateTime.UtcNow - TimeSpan.FromHours(Delay)) { context.Entries[type].LastBulkOrder = DateTime.UtcNow; } return(true); } } return(false); }
public static BODContext GetContext(Mobile m, bool create = true) { BODContext context = null; if (m is PlayerMobile pm) { if (Instance.BODPlayerData.ContainsKey(pm)) { context = Instance.BODPlayerData[pm]; } else if (create) { Instance.BODPlayerData[pm] = context = new BODContext(); } } return(context); }
public static BODContext GetContext(Mobile m) { BODContext context = null; if (m is PlayerMobile) { PlayerMobile pm = m as PlayerMobile; if (Instance.BODPlayerData.ContainsKey(pm)) { context = Instance.BODPlayerData[pm]; } else { Instance.BODPlayerData[pm] = context = new BODContext(); } } return(context); }
public static bool CanGetBulkOrder(Mobile m, BODType type) { BODContext context = GetContext(m); if (context != null && context.Entries.ContainsKey(type)) { DateTime last = context.Entries[type].LastBulkOrder; if (context.Entries[type].CachedDeeds == 0) { int tocache = 0; if (last + TimeSpan.FromHours(Delay) < DateTime.UtcNow) { int minutes = (int)(DateTime.UtcNow - last).TotalMinutes; tocache = (int)(minutes / ((double)Delay * 60)); } if (tocache > 0) { context.Entries[type].CachedDeeds = Math.Min(MaxCachedDeeds, context.Entries[type].CachedDeeds + tocache); } } if (context.Entries[type].CachedDeeds > 0) { if (context.Entries[type].CachedDeeds == MaxCachedDeeds) { context.Entries[type].LastBulkOrder = DateTime.UtcNow - TimeSpan.FromHours(Delay * (MaxCachedDeeds)); } context.Entries[type].LastBulkOrder += TimeSpan.FromHours(Delay); context.Entries[type].CachedDeeds--; return(true); } /*int cached = context.Entries[type].CachedDeeds; * * if (cached > 0) * { * if (cached == MaxCachedDeeds) * { * context.Entries[type].LastBulkOrder = DateTime.UtcNow; * } * else * { * //TimeSpan remainder = last - TimeSpan.FromHours(Delay); * TimeSpan remainder = (DateTime.UtcNow - last) + TimeSpan.FromHours(Delay); * * context.Entries[type].LastBulkOrder = DateTime.UtcNow - remainder; * } * * context.Entries[type].CachedDeeds--; * * return true; * }*/ } return(false); }
public override void OnResponse(NetState sender, RelayInfo info) { if (this.m_Deed.Deleted || !this.m_Deed.IsChildOf(this.m_From.Backpack)) { return; } if (info.ButtonID == 2) // Combine { this.m_From.SendGump(new LargeBODGump(this.m_From, this.m_Deed)); this.m_Deed.BeginCombine(this.m_From); } else if (info.ButtonID == 3) // bank button { BODContext c = BulkOrderSystem.GetContext(m_From); if (c != null) { switch (c.PointsMode) { case PointsMode.Enabled: c.PointsMode = PointsMode.Disabled; break; case PointsMode.Disabled: c.PointsMode = PointsMode.Automatic; break; case PointsMode.Automatic: c.PointsMode = PointsMode.Enabled; break; } } this.m_From.SendGump(new LargeBODGump(this.m_From, this.m_Deed)); } else if (info.ButtonID == 4) // combine from container { m_From.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, (m, targeted) => { if (!m_Deed.Deleted && targeted is Container) { List <SmallBOD> list = ((Container)targeted).Items.OfType <SmallBOD>().ToList(); foreach (SmallBOD item in list) { m_Deed.EndCombine(m_From, item); } list.Clear(); } }); } // // NOT SURE HOW TO IMPLEMENT WITH NEWER SYSTEM YET ~ ZERODOWNED // /* * //daat99 OWLTR start - custom bods * else if (info.ButtonID >= 3) * { * bool IsFound = false; * IPooledEnumerable eable = m_From.GetMobilesInRange(6); * foreach (Mobile vendor in eable) * { * switch (info.ButtonID) * { * case 3: IsFound = (vendor is Blacksmith || vendor is Weaponsmith || vendor is Armorer); break; * case 4: IsFound = (vendor is Tailor || vendor is Weaver); break; * case 5: IsFound = (vendor is Carpenter); break; * case 6: IsFound = (vendor is Bowyer); break; * } * if (IsFound == true) * break; * } * if (IsFound == false) * switch (info.ButtonID) * { * case 3: m_From.SendMessage("You must be near a Blacksmith, Weaponsmith or Armorer to claim that."); break; * case 4: m_From.SendMessage("You must be near a Tailor or Weaver to claim that."); break; * case 5: m_From.SendMessage("You must be near a Carpenter to claim that."); break; * case 6: m_From.SendMessage("You must be near a Bowyer to claim that."); break; * } * else * daat99.daat99.ClaimBods(m_From, m_Deed); * * } * //daat99 OWLTR end - custom bods */ }
public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25) { m_From = from; m_Deed = deed; m_From.CloseGump(typeof(LargeBODGump)); m_From.CloseGump(typeof(SmallBODGump)); AddPage(0); int height = 0; if (BulkOrderSystem.NewSystemEnabled) { if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { height += 24; } if (deed.RequireExceptional) { height += 24; } if (deed.Material != BulkMaterialType.None) { height += 24; } } AddBackground(50, 10, 455, 245 + height, 5054); AddImageTiled(58, 20, 438, 226 + height, 2624); AddAlphaRegion(58, 20, 438, 226 + height); AddImage(45, 5, 10460); AddImage(480, 5, 10460); AddImage(45, 230 + height, 10460); AddImage(480, 230 + height, 10460); AddHtmlLocalized(225, 25, 120, 20, 1045133, 0x7FFF, false, false); // A bulk order AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddLabel(275, 48, 1152, deed.AmountMax.ToString()); AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: AddHtmlLocalized(75, 72, 120, 20, 1045136, 0x7FFF, false, false); // Item requested: AddItem(410, 72, deed.Graphic, deed.GraphicHue); AddHtmlLocalized(75, 96, 210, 20, deed.Number, 0x7FFF, false, false); AddLabel(275, 96, 0x480, deed.AmountCur.ToString()); int y = 120; if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: y += 24; } if (deed.RequireExceptional) { AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. y += 24; } if (deed.Material != BulkMaterialType.None) { AddHtmlLocalized(75, y, 300, 20, GetMaterialNumberFor(deed.Material), 0x7FFF, false, false); // All items must be made with x material. y += 24; } if (from is PlayerMobile && BulkOrderSystem.NewSystemEnabled) { BODContext c = BulkOrderSystem.GetContext((PlayerMobile)from); int points = 0; double banked = 0.0; BulkOrderSystem.ComputePoints(deed, out points, out banked); AddHtmlLocalized(75, y, 300, 20, 1157301, string.Format("{0}\t{1}", points, banked.ToString("0.000000")), 0x7FFF, false, false); // Worth ~1_POINTS~ turn in points and ~2_POINTS~ bank points. y += 24; AddButton(125, y, 4005, 4007, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, c.PointsMode == PointsMode.Enabled ? 1157302 : c.PointsMode == PointsMode.Disabled ? 1157303 : 1157309, 0x7FFF, false, false); // Banking Points Enabled/Disabled/Automatic y += 24; AddButton(125, y, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, 1045154, 0x7FFF, false, false); // Combine this deed with the item requested. y += 24; AddButton(125, y, 4005, 4007, 4, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, 1157304, 0x7FFF, false, false); // Combine this deed with contained items. y += 24; } else { AddButton(125, y, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, 1045154, 0x7FFF, false, false); // Combine this deed with the item requested. y += 24; } AddButton(125, y, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 120, 20, 1011441, 0x7FFF, false, false); // EXIT }
public static void SetBOBFilter(PlayerMobile pm, BOBFilter filter) { BODContext context = GetContext(pm); context.BOBFilter = filter; }
public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25) { m_From = from; m_Deed = deed; m_From.CloseGump(typeof(LargeBODGump)); m_From.CloseGump(typeof(SmallBODGump)); LargeBulkEntry[] entries = deed.Entries; AddPage(0); int height = 0; if (BulkOrderSystem.NewSystemEnabled) { if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { height += 24; } if (deed.RequireExceptional) { height += 24; } if (deed.Material != BulkMaterialType.None) { height += 24; } } AddBackground(50, 10, 455, 218 + height + (entries.Length * 24), 5054); AddImageTiled(58, 20, 438, 200 + height + (entries.Length * 24), 2624); AddAlphaRegion(58, 20, 438, 200 + height + (entries.Length * 24)); AddImage(45, 5, 10460); AddImage(480, 5, 10460); AddImage(45, 203 + height + (entries.Length * 24), 10460); AddImage(480, 203 + height + (entries.Length * 24), 10460); AddHtmlLocalized(225, 25, 120, 20, 1045134, 0x7FFF, false, false); // A large bulk order AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddLabel(275, 48, 1152, deed.AmountMax.ToString()); AddHtmlLocalized(75, 72, 120, 20, 1045137, 0x7FFF, false, false); // Items requested: AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: int y = 96; for (int i = 0; i < entries.Length; ++i) { LargeBulkEntry entry = entries[i]; SmallBulkEntry details = entry.Details; AddHtmlLocalized(75, y, 210, 20, details.Number, 0x7FFF, false, false); AddLabel(275, y, 0x480, entry.Amount.ToString()); y += 24; } if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: y += 24; } if (deed.RequireExceptional) { AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. y += 24; } if (deed.Material != BulkMaterialType.None) { AddHtmlLocalized(75, y, 300, 20, SmallBODGump.GetMaterialNumberFor(deed.Material), 0x7FFF, false, false); // All items must be made with x material. y += 24; } if (BulkOrderSystem.NewSystemEnabled) { BODContext c = BulkOrderSystem.GetContext((PlayerMobile)from); int points = 0; double banked = 0.0; BulkOrderSystem.ComputePoints(deed, out points, out banked); AddHtmlLocalized(75, y, 300, 20, 1157301, string.Format("{0}\t{1}", points, banked.ToString("0.000000")), 0x7FFF, false, false); // Worth ~1_POINTS~ turn in points and ~2_POINTS~ bank points. y += 24; AddButton(125, y, 4005, 4007, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, c.PointsMode == PointsMode.Enabled ? 1157302 : c.PointsMode == PointsMode.Disabled ? 1157303 : 1157309, 0x7FFF, false, false); // Banking Points Enabled/Disabled/Automatic y += 24; AddButton(125, y, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, 1045154, 0x7FFF, false, false); // Combine this deed with the item requested. y += 24; AddButton(125, y, 4005, 4007, 4, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 300, 20, 1157304, 0x7FFF, false, false); // Combine this deed with contained items. y += 24; AddButton(125, y, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(160, y, 120, 20, 1011441, 0x7FFF, false, false); // EXIT } else { AddButton(125, 168 + (entries.Length * 24), 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(160, 168 + (entries.Length * 24), 300, 20, 1045155, 0x7FFF, false, false); // Combine this deed with another deed. AddButton(125, 192 + (entries.Length * 24), 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(160, 192 + (entries.Length * 24), 120, 20, 1011441, 0x7FFF, false, false); // EXIT } }