Exemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Mobile          m     = reader.ReadMobile();
                TradeOrderCrate crate = reader.ReadItem() as TradeOrderCrate;

                if (m != null && crate != null)
                {
                    ActiveTrades[m] = crate;
                }
            }

            _NameBuffer = new Dictionary <Type, string>();

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Type   t    = ScriptCompiler.FindTypeByName(reader.ReadString());
                string name = reader.ReadString();

                if (t != null)
                {
                    _NameBuffer[t] = name;
                }
            }
        }
Exemplo n.º 2
0
                protected override void OnTarget(Mobile from, object targeted)
                {
                    TradeOrderCrate order = targeted as TradeOrderCrate;

                    if (order != null)
                    {
                        if (CityLoyaltySystem.CityTrading.TryTurnIn(from, order, Minister))
                        {
                            if (List.ContainsKey(from))
                            {
                                List[from].StopTimer();
                            }

                            if (order.Entry != null && order.Entry.Distance > 0)
                            {
                                from.AddToBackpack(Minister.GiveReward(order.Entry));
                                from.SendLocalizedMessage(1073621); // Your reward has been placed in your backpack.
                            }

                            Titles.AwardKarma(from, 100, true);
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1151731); // That is not a valid trade order. Please try again.
                        from.Target = new InternalTarget(Minister);
                    }
                }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public static void CancelTradeOrder(Mobile from, TradeOrderCrate crate)
        {
            if (from == null)
            {
                from = crate.Owner;
            }

            if (from != null)
            {
                var items = new List <Item>(crate.Items);

                for (int i = 0; i < items.Count; i++)
                {
                    from.Backpack.DropItem(items[i]);
                }

                ColUtility.Free(items);

                if (from is PlayerMobile pm)
                {
                    CityTradeEntry entry = CityLoyaltySystem.CityTrading.GetPlayerEntry <CityTradeEntry>(pm, true);

                    if (entry != null)
                    {
                        entry.Canceled++;
                    }
                }
            }

            crate.Delete();
        }
Exemplo n.º 5
0
 public void RemoveCrate(Mobile from, TradeOrderCrate crate)
 {
     if (ActiveTrades.ContainsKey(from))
     {
         ActiveTrades.Remove(from);
     }
 }
Exemplo n.º 6
0
        public static void CheckAmbush(TradeOrderCrate crate)
        {
            if (crate == null || crate.Deleted || crate.Entry == null || crate.Expired || crate.Entry.LastAmbush + TimeSpan.FromMinutes(AmbushWaitDuration) > DateTime.UtcNow)
            {
                return;
            }

            if (crate.RootParentEntity is Mobile && !((Mobile)crate.RootParentEntity).Region.IsPartOf <GuardedRegion>())
            {
                Mobile m = crate.RootParentEntity as Mobile;

                if (m.NetState != null && m.Map != null && m.Map != Map.Internal)
                {
                    double chance = crate.Entry.LastAmbush == DateTime.MinValue ? 0.25 : .05;

                    if (chance > Utility.RandomDouble())
                    {
                        double dif = (double)(Math.Min(7200, m.SkillsTotal) + m.RawStr + m.RawInt + m.RawDex) / 10000;

                        m.RevealingAction();

                        SpawnCreatures(m, dif);
                        crate.Entry.LastAmbush = DateTime.UtcNow;
                    }
                }
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public bool HasTurnIn(Mobile from, TradeMinister minister)
        {
            if (from == null || minister == null || !ActiveTrades.ContainsKey(from) || ActiveTrades[from] == null)
            {
                return(false);
            }

            TradeOrderCrate crate = ActiveTrades[from];

            return(crate.Entry != null && crate.Entry.Origin != minister.City);
        }
Exemplo n.º 9
0
        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~
            }
Exemplo n.º 10
0
            public override void OnClick()
            {
                //Cancel Trade Order
                //Are you sure you wish to cancel this trade order?  All contents of the trade crate will be placed in your backpack.
                Player.SendGump(new WarningGump(1151727, 30720, 1151728, 32512, 300, 200, (m, ok, obj) =>
                {
                    if (ok)
                    {
                        TradeOrderCrate crate = obj as TradeOrderCrate;

                        if (crate != null && crate.IsChildOf(Player.Backpack))
                        {
                            CityTradeSystem.CancelTradeOrder(Player, crate);
                        }
                    }
                }, Crate, true));
            }
Exemplo n.º 11
0
        public override void ProcessKill(Mobile victim, Mobile damager)
        {
            if (victim is BaseCreature && Ambushers != null && Ambushers.ContainsKey((BaseCreature)victim))
            {
                if (ActiveTrades.ContainsKey(damager))
                {
                    TradeOrderCrate crate = ActiveTrades[damager];

                    if (crate.Entry != null)
                    {
                        crate.Entry.Kills++;
                    }
                }

                Ambushers.Remove((BaseCreature)victim);
            }
        }
Exemplo n.º 12
0
        public CancelTradeOrderGump(TradeOrderCrate crate, Mobile player)
            : base(100, 100)
        {
            Crate  = crate;
            Player = player;

            AddPage(0);

            AddBackground(0, 0, 291, 93, 0x13BE);
            AddImageTiled(5, 5, 280, 60, 0xA40);

            AddHtmlLocalized(9, 9, 272, 60, 1151728, 0x7FFF, false, false); // Are you sure you wish to cancel this trade order?  All contents of the trade crate will be placed in your backpack.

            AddButton(160, 67, 0xFB7, 0xFB8, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(195, 69, 120, 20, 1006044, 0x7FFF, false, false); // OKAY

            AddButton(5, 67, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(40, 69, 100, 20, 1060051, 0x7FFF, false, false); // CANCEL
        }
Exemplo n.º 13
0
                protected override void OnTarget(Mobile from, object targeted)
                {
                    TradeOrderCrate order = targeted as TradeOrderCrate;

                    if (order != null)
                    {
                        if (CityLoyaltySystem.CityTrading.TryTurnInToSlim(from, order, Slim))
                        {
                            from.AddToBackpack(Slim.GiveAward());
                            from.SendLocalizedMessage(1073621); // Your reward has been placed in your backpack.

                            Titles.AwardKarma(from, -100, true);
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1151731);                         // That is not a valid trade order. Please try again.
                        from.Target = new InternalTarget(Slim);
                    }
                }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        public static void CancelTradeOrder(Mobile from, TradeOrderCrate crate)
        {
            if (from == null)
            {
                from = crate.Owner;
            }

            if (from != null)
            {
                crate.Items.ForEach(i =>
                {
                    from.Backpack.DropItem(i);
                });

                CityTradeEntry entry = CityLoyaltySystem.CityTrading.GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true);

                if (entry != null)
                {
                    entry.Canceled++;
                }
            }

            crate.Delete();
        }
Exemplo n.º 16
0
			public CancelOrderEntry(TradeOrderCrate crate, Mobile player) : base(1151727, 3) // cancel trade order
			{
				Crate = crate; 
				Player = player;
			}
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
 public FillFromPackEntry(TradeOrderCrate crate, Mobile player) : base(1154908, 3) // Fill from pack
 {
     Crate  = crate;
     Player = player;
 }
Exemplo n.º 19
0
 public CancelOrderEntry(TradeOrderCrate crate, Mobile player) : base(1151727, 3) // cancel trade order
 {
     Crate  = crate;
     Player = player;
 }
Exemplo n.º 20
0
 public int Count(TradeOrderCrate crate)
 {
     return(crate.Items.Where(i => Match(i.GetType())).Sum(item => item.Amount));
 }
Exemplo n.º 21
0
			public FillFromPackEntry(TradeOrderCrate crate, Mobile player) : base(1154908, 3) // Fill from pack
			{
				Crate = crate; 
				Player = player;
			}