public bool TryTurnInToSlim(Mobile from, TradeOrderCrate order, SlimTheFence slim) { if (order == null || from == null || slim == null || order.Entry == null) { return(false); } TradeEntry entry = order.Entry; if (!order.Fulfilled) { slim.SayTo(from, 1151732); // This trade order has not been fulfilled. Fill the trade order with all necessary items and try again. } else { CityLoyaltySystem.OnSlimTradeComplete(from, order.Entry); CityTradeEntry pentry = GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); if (pentry != null) { pentry.Points++; pentry.DistanceTraveled += entry.Distance; pentry.CompletedSlim++; CheckTitle(pentry); } slim.SayTo(from, 1151736); // Haha! These goods will fetch me quite a bit o' coin! Thanks fer yer help! Here's a little something I was able to get me hands on... order.Delete(); return(true); } return(false); }
public bool TryOfferTrade(Mobile from, TradeMinister minister) { if (from == null || from.Backpack == null) { return(true); } if (ActiveTrades.ContainsKey(from)) { minister.SayTo(from, 1151722); // It appears you are already delivering a trade order. Deliver your current order before requesting another. } else { City origin = minister.City; City destination; do { destination = CityLoyaltySystem.GetRandomCity(); }while (destination == origin); int distance = GetDistance(minister, destination); int trades = Utility.RandomMinMax(1, GetMaxTrades(from)); TradeEntry entry = new TradeEntry(destination, origin, distance); TradeOrderCrate crate = new TradeOrderCrate(from, entry); GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); for (int i = 0; i < trades; i++) { int worth = 1; string name = null; Type t = GetRandomTrade(origin, destination, ref worth, ref name); if (t != null) { int amount = Utility.RandomList(5, 10, 15, 20); entry.Details.Add(new TradeEntry.TradeDetails(t, worth, amount, name)); } else { minister.SayTo(from, "There are no trades available at this time."); return(false); } } if (from.Backpack == null || !from.Backpack.TryDropItem(from, crate, false)) { crate.Delete(); from.SendLocalizedMessage(114456); // Your backpack cannot hold the Trade Order. Free up space and speak to the Trade Minister again. } ActiveTrades[from] = crate; return(true); } return(false); }
public static void OnSlimTradeComplete(Mobile from, TradeEntry entry) { var dest = GetCityInstance(entry.Destination); var origin = GetCityInstance(entry.Origin); origin.AwardHate(from, 25); dest.AwardHate(from, 25); }
public TradeOrderCrate(Mobile from, TradeEntry entry) : base(Utility.Random(0xE3C, 4)) { Owner = from; Entry = entry; Expires = DateTime.UtcNow + TimeSpan.FromHours(CityTradeSystem.CrateDuration); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int v = reader.ReadInt(); Owner = reader.ReadMobile(); Expires = reader.ReadDateTime(); Entry = new TradeEntry(reader); }
public TradeOrderCrate(Mobile from, TradeEntry entry) : base(Utility.Random(0x46A2, 4)) { Weight = 10.0; Hue = Utility.Random(100); Owner = from; Entry = entry; Expires = DateTime.UtcNow + TimeSpan.FromHours(CityTradeSystem.CrateDuration); }
public bool TryTurnIn(Mobile from, TradeOrderCrate order, Mobile turninMobile) { if (order == null || from == null || turninMobile == null || order.Entry == null) { return(false); } TradeEntry entry = order.Entry; if (from.AccessLevel == AccessLevel.Player && turninMobile is TradeMinister minister && minister.City != entry.Destination) { turninMobile.SayTo(from, 1151738, string.Format("#{0}", CityLoyaltySystem.GetCityLocalization(entry.Destination))); // Begging thy pardon, but those goods are destined for the City of ~1_city~ }
public TradeOrderCrate(Mobile from, TradeEntry entry) : base(GetID()) { Owner = from; Entry = entry; if (CityTradeSystem.KrampusEncounterActive) { Weight = 10.0; Hue = Utility.Random(100); } Expires = DateTime.UtcNow + TimeSpan.FromHours(CityTradeSystem.CrateDuration); }
public static void OnTradeComplete(Mobile from, TradeEntry entry) { var dest = GetCityInstance(entry.Destination); var origin = GetCityInstance(entry.Origin); int gold = entry.CalculateGold(); origin.AddToTreasury(from, gold); from.SendLocalizedMessage(1154761, String.Format("{0}\t{1}", gold.ToString("N0", CultureInfo.GetCultureInfo("en-US")), origin.Definition.Name)); // ~1_val~ gold has been deposited into the ~2_NAME~ City treasury for your efforts! origin.AwardLove(from, 150); dest.AwardLove(from, 150); origin.CompletedTrades++; }
private Item GiveReward(TradeEntry entry) { if (0.01 > Utility.RandomDouble()) { switch (Utility.Random(2)) { default: case 0: return(CityBook.GetRandom()); case 1: return(new RewardSign()); } } switch (Utility.Random(2)) { default: case 1: return(RandomResource(entry)); case 2: return(ScrollOfTranscendence.CreateRandom(1, 10)); } }
public bool TryTurnIn(Mobile from, TradeOrderCrate order, Mobile turninMobile) { if (order == null || from == null || turninMobile == null || order.Entry == null) { return(false); } TradeEntry entry = order.Entry; TradeMinister minister = turninMobile as TradeMinister; if (from.AccessLevel == AccessLevel.Player && minister != null && minister.City != entry.Destination) { turninMobile.SayTo(from, 1151738, string.Format("#{0}", CityLoyaltySystem.GetCityLocalization(entry.Destination))); // Begging thy pardon, but those goods are destined for the City of ~1_city~ } else if (!order.Fulfilled) { turninMobile.SayTo(from, 1151732); // This trade order has not been fulfilled. Fill the trade order with all necessary items and try again. } else { CityLoyaltySystem.OnTradeComplete(from, order.Entry); CityTradeEntry pentry = GetPlayerEntry <CityTradeEntry>(from as PlayerMobile); if (pentry != null) { pentry.Points++; pentry.DistanceTraveled += entry.Distance; pentry.Completed++; CheckTitle(pentry); } order.Delete(); return(true); } return(false); }
public bool TryOfferTrade(Mobile from, TradeMinister minister) { if (from == null || from.Backpack == null) { return(true); } if (ActiveTrades.ContainsKey(from)) { minister.SayTo(from, 1151722); // It appears you are already delivering a trade order. Deliver your current order before requesting another. } else if (KrampusEncounterActive && (KrampusEvent.Instance.Krampus != null || KrampusEvent.Instance.KrampusSpawning)) { Point3D p = KrampusEvent.Instance.SpawnLocation; Map map = KrampusEvent.Instance.SpawnMap; minister.SayTo( from, 1158790, string.Format("{0}\t{1}", WorldLocationInfo.GetLocationString(p, map), Sextant.GetCoords(p, map)), 1150); // Take notice! The vile Krampus has been spotted near ~2_where~ at ~1_coords~! New Trade Orders are suspended until Krampus has been defeated! } else { City origin = minister.City; City destination; do { destination = CityLoyaltySystem.GetRandomCity(); }while (destination == origin); int distance = GetDistance(minister, destination); int trades = Utility.RandomMinMax(1, GetMaxTrades(from)); TradeEntry entry = new TradeEntry(destination, origin, distance); TradeOrderCrate crate = new TradeOrderCrate(from, entry); GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); for (int i = 0; i < trades; i++) { int worth = 1; string name = null; Type t = GetRandomTrade(origin, destination, ref worth, ref name); if (t != null) { if (entry.Details.Any(x => x.ItemType.Name == t.Name)) { continue; } int amount = Utility.RandomList(5, 10, 15, 20); entry.Details.Add(new TradeEntry.TradeDetails(t, worth, amount, name)); } else { minister.SayTo(from, "There are no trades available at this time."); return(false); } } if (from.Backpack == null || !from.Backpack.TryDropItem(from, crate, false)) { crate.Delete(); from.SendLocalizedMessage(114456); // Your backpack cannot hold the Trade Order. Free up space and speak to the Trade Minister again. } ActiveTrades[from] = crate; return(true); } return(false); }
private Item RandomResource(TradeEntry entry) { int amount = 40; if (entry.Details.Count > 1) { amount = 40 + Utility.RandomMinMax(10, entry.Details.Count * 20); } switch (Utility.Random(4)) { case 0: switch (Utility.Random(9)) { case 0: return(new IronIngot(amount)); case 1: return(new DullCopperIngot(amount)); case 2: return(new ShadowIronIngot(amount)); case 3: return(new CopperIngot(amount)); case 4: return(new BronzeIngot(amount)); case 5: return(new GoldIngot(amount)); case 6: return(new AgapiteIngot(amount)); case 7: return(new VeriteIngot(amount)); case 8: return(new ValoriteIngot(amount)); } break; case 1: switch (Utility.Random(4)) { case 0: return(new Leather(amount)); case 1: return(new SpinedLeather(amount)); case 2: return(new HornedLeather(amount)); case 3: return(new BarbedLeather(amount)); } break; case 2: switch (Utility.Random(7)) { case 0: return(new Board(amount)); case 1: return(new OakBoard(amount)); case 2: return(new AshBoard(amount)); case 3: return(new YewBoard(amount)); case 4: return(new BloodwoodBoard(amount)); case 5: return(new HeartwoodBoard(amount)); case 6: return(new FrostwoodBoard(amount)); } break; case 3: Item item = Loot.Construct(SkillHandlers.Imbuing.IngredTypes[Utility.Random(SkillHandlers.Imbuing.IngredTypes.Length)]); amount /= 10; if (item != null && item.Stackable) { item.Amount = amount; } return(item); } return(null); }