예제 #1
0
파일: Fishing.cs 프로젝트: Jascen/UOSmart
        public override Item Construct(Type type, Mobile from)
        {
            if (type == typeof(TreasureMap))
            {
                int level;
                if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from))
                {
                    level = 0;
                }
                else
                {
                    level = 1;
                }

                return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel));
            }
            else if (type == typeof(MessageInABottle))
            {
                return(new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel));
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                List <SOS> messages = pack.FindItemsByType <SOS>();

                for (int i = 0; i < messages.Count; ++i)
                {
                    SOS sos = messages[i];

                    if ((from.Map == Map.Felucca || from.Map == Map.Trammel) && from.InRange(sos.TargetLocation, 60))
                    {
                        Item preLoot = null;

                        switch (Utility.Random(8))
                        {
                        case 0:     // Body parts
                        {
                            int[] list = new int[]
                            {
                                0x1CDD, 0x1CE5,        // arm
                                0x1CE0, 0x1CE8,        // torso
                                0x1CE1, 0x1CE9,        // head
                                0x1CE2, 0x1CEC         // leg
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 1:     // Bone parts
                        {
                            int[] list = new int[]
                            {
                                0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4,                         // skulls
                                0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                0x1B15, 0x1B16                                                  // pelvis bones
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 2:     // Paintings and portraits
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10));
                            break;
                        }

                        case 3:     // Pillows
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11));
                            break;
                        }

                        case 4:     // Shells
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9));
                            break;
                        }

                        case 5:         //Hats
                        {
                            if (Utility.RandomBool())
                            {
                                preLoot = new SkullCap();
                            }
                            else
                            {
                                preLoot = new TricorneHat();
                            }

                            break;
                        }

                        case 6:     // Misc
                        {
                            int[] list = new int[]
                            {
                                0x1EB5,                        // unfinished barrel
                                0xA2A,                         // stool
                                0xC1F,                         // broken clock
                                0x1047, 0x1048,                // globe
                                0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves
                            };

                            if (Utility.Random(list.Length + 1) == 0)
                            {
                                preLoot = new Candelabra();
                            }
                            else
                            {
                                preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            }

                            break;
                        }
                        }

                        if (preLoot != null)
                        {
                            if (preLoot is IShipwreckedItem)
                            {
                                ((IShipwreckedItem)preLoot).IsShipwreckedItem = true;
                            }

                            return(preLoot);
                        }

                        LockableContainer chest;

                        if (Utility.RandomBool())
                        {
                            chest = new MetalGoldenChest();
                        }
                        else
                        {
                            chest = new WoodenChest();
                        }

                        if (sos.IsAncient)
                        {
                            chest.Hue = 0x481;
                        }

                        TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(4, sos.Level)));

                        if (sos.IsAncient)
                        {
                            chest.DropItem(new FabledFishingNet());
                        }
                        else
                        {
                            chest.DropItem(new SpecialFishingNet());
                        }

                        chest.Movable   = true;
                        chest.Locked    = false;
                        chest.TrapType  = TrapType.None;
                        chest.TrapPower = 0;
                        chest.TrapLevel = 0;

                        sos.Delete();

                        return(chest);
                    }
                }
            }

            return(base.Construct(type, from));
        }
예제 #2
0
        public static double GetPoints(Item item)
        {
            if (item is IVvVItem && ((IVvVItem)item).IsVvVItem)
            {
                return(0);
            }

            double points = 0;

            Type type = item.GetType();

            if (Entries.ContainsKey(type))
            {
                points = Entries[type];

                // Kind of ametuar, but if this arrizes more, we'll make a seperate function
                if (item is SOS && ((SOS)item).IsAncient)
                {
                    points = 2500;
                }

                if (item.Stackable)
                {
                    points = points * item.Amount;
                }

                return(points);
            }
            else
            {
                if (item is RunicHammer)
                {
                    RunicHammer hammer = (RunicHammer)item;

                    if (hammer.Resource == CraftResource.DullCopper)
                    {
                        points = 5 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.ShadowIron)
                    {
                        points = 10 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Copper)
                    {
                        points = 25 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Bronze)
                    {
                        points = 100 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Gold)
                    {
                        points = 250 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Agapite)
                    {
                        points = 1000 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Verite)
                    {
                        points = 4000 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Valorite)
                    {
                        points = 8000 * hammer.UsesRemaining;
                    }
                }
                else if (item is RunicSewingKit)
                {
                    RunicSewingKit sewing = (RunicSewingKit)item;

                    if (sewing.Resource == CraftResource.SpinedLeather)
                    {
                        points = 10 * sewing.UsesRemaining;
                    }
                    else if (sewing.Resource == CraftResource.HornedLeather)
                    {
                        points = 100 * sewing.UsesRemaining;
                    }
                    else if (sewing.Resource == CraftResource.BarbedLeather)
                    {
                        points = 400 * sewing.UsesRemaining;
                    }
                }
                else if (item is PowerScroll)
                {
                    PowerScroll ps = (PowerScroll)item;

                    if (ps.Value == 105)
                    {
                        points = 50;
                    }
                    else if (ps.Value == 110)
                    {
                        points = 100;
                    }
                    else if (ps.Value == 115)
                    {
                        points = 500;
                    }
                    else if (ps.Value == 120)
                    {
                        points = 2500;
                    }
                }
                else if (item is ScrollOfTranscendence)
                {
                    SpecialScroll sot = (SpecialScroll)item;

                    points = sot.Value / 0.1 * 2;
                }
                else if (item is Bait)
                {
                    Bait bait = (Bait)item;

                    points = 10 * bait.UsesRemaining;
                }
                else if (item is TreasureMap)
                {
                    TreasureMap tmap = (TreasureMap)item;

                    switch (tmap.Level)
                    {
                    default:
                    case 0:
                    case 1: return(50);

                    case 2: return(250);

                    case 3: return(750);

                    case 4: return(1000);
                    }
                }
                else if (item is MonsterStatuette)
                {
                    MonsterStatuette ms = (MonsterStatuette)item;

                    if (ms.Type == MonsterStatuetteType.Slime)
                    {
                        points = 5000;
                    }
                }
                else if (item is PigmentsOfTokuno || item is LesserPigmentsOfTokuno)
                {
                    BasePigmentsOfTokuno pigments = (BasePigmentsOfTokuno)item;
                    points = 500 * pigments.UsesRemaining;
                }
                else if (item is ICombatEquipment)
                {
                    points = GetPointsForEquipment(item);
                }

                if (item.LootType != LootType.Blessed && points < 100 && item is IShipwreckedItem && ((IShipwreckedItem)item).IsShipwreckedItem)
                {
                    points = 100;
                }

                return(points);
            }
        }
예제 #3
0
        public override Item Construct(Type type, Mobile from, Item tool)
        {
            // Searing Weapon Support
            if (type == typeof(BaseWeapon))
            {
                return(null);
            }

            if (type == typeof(TreasureMap))
            {
                int level;
                if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from))
                {
                    level = 0;
                }
                else
                {
                    level = 1;
                }

                return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel));
            }
            else if (type == typeof(MessageInABottle))
            {
                return(new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel));
            }
            else if (type == typeof(WhitePearl))
            {
                return(new WhitePearl());
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                List <SOS> messages = pack.FindItemsByType <SOS>();

                for (int i = 0; i < messages.Count; ++i)
                {
                    SOS sos = messages[i];

                    if ((from.Map == Map.Felucca || from.Map == Map.Trammel) && from.InRange(sos.TargetLocation, 60))
                    {
                        Item preLoot = null;
                        bool dredge  = HasTypeHook(tool, HookType.Dredging);

                        switch (Utility.Random(Core.HS ? 17 : 16))
                        {
                        case 0:     // Body parts
                        case 1:
                        {
                            int[] list = new int[]
                            {
                                0x1CDD, 0x1CE5,        // arm
                                0x1CE0, 0x1CE8,        // torso
                                0x1CE1, 0x1CE9,        // head
                                0x1CE2, 0x1CEC         // leg
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge);
                            break;
                        }

                        case 2:     // Bone parts
                        case 3:
                        {
                            int[] list = new int[]
                            {
                                0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4,                         // skulls
                                0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                0x1B15, 0x1B16                                                  // pelvis bones
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge);
                            break;
                        }

                        case 4:     // Paintings and portraits
                        case 5:
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10), dredge);
                            break;
                        }

                        case 6:     // Pillows
                        case 7:
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11), dredge);
                            break;
                        }

                        case 8:     // Shells
                        case 9:
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9), dredge);
                            break;
                        }

                        case 10:     //Hats
                        case 11:
                        {
                            if (Utility.RandomBool())
                            {
                                preLoot = new SkullCap();
                            }
                            else
                            {
                                preLoot = new TricorneHat();
                            }

                            break;
                        }

                        case 12:     // Misc
                        case 13:
                        {
                            int[] list = new int[]
                            {
                                0x1EB5,                        // unfinished barrel
                                0xA2A,                         // stool
                                0xC1F,                         // broken clock
                                0x1047, 0x1048,                // globe
                                0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves
                            };

                            if (Utility.Random(list.Length + 1) == 0)
                            {
                                preLoot = new Candelabra();
                            }
                            else
                            {
                                preLoot = new ShipwreckedItem(Utility.RandomList(list), dredge);
                            }

                            break;
                        }

                            #region High Seas
                        case 14:
                        {
                            int[] list = new int[]
                            {
                                0x1E19, 0x1E1A, 0x1E1B,         //Fish heads
                                0x1E2A, 0x1E2B,                 //Oars
                                0x1E71, 0x1E7A,                 //Unfinished drawers
                                0x1E75,                         //Unfinished legs
                            };

                            double ran = Utility.RandomDouble();

                            if (ran < 0.05)
                            {
                                preLoot = new YellowPolkaDotBikini();
                            }
                            else if (ran < 0.25)
                            {
                                preLoot = new ShipwreckedItem(list[Utility.RandomMinMax(3, 7)], dredge);
                            }
                            else
                            {
                                preLoot = new ShipwreckedItem(list[Utility.Random(3)], dredge);
                            }
                            break;
                        }
                            #endregion
                        }

                        if (preLoot != null)
                        {
                            if (preLoot is IShipwreckedItem)
                            {
                                ((IShipwreckedItem)preLoot).IsShipwreckedItem = true;
                            }

                            return(preLoot);
                        }

                        LockableContainer chest;

                        if (0.01 > Utility.RandomDouble())
                        {
                            chest = new ShipsStrongbox(sos.Level);
                        }
                        else
                        {
                            if (Utility.RandomBool())
                            {
                                chest = new MetalGoldenChest();
                            }
                            else
                            {
                                chest = new WoodenChest();
                            }
                        }

                        if (sos.IsAncient)
                        {
                            chest.Hue = 0x481;
                        }

                        TreasureMapChest.Fill(chest, from is PlayerMobile ? ((PlayerMobile)from).RealLuck : from.Luck, Math.Max(1, Math.Min(4, sos.Level)), true, from.Map);
                        sos.OnSOSComplete(chest);

                        if (sos.IsAncient)
                        {
                            chest.DropItem(new FabledFishingNet());
                        }
                        else
                        {
                            chest.DropItem(new SpecialFishingNet());
                        }

                        chest.Movable   = true;
                        chest.Locked    = false;
                        chest.TrapType  = TrapType.None;
                        chest.TrapPower = 0;
                        chest.TrapLevel = 0;

                        chest.IsShipwreckedItem = true;

                        sos.Delete();

                        return(chest);
                    }
                }
            }

            return(base.Construct(type, from, tool));
        }
예제 #4
0
        public override Item Construct(Type type, Mobile from)
        {
            if (type == typeof(TreasureMap))
            {
                int level;
                if (from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from))
                {
                    level = 0;
                }
                else
                {
                    level = 1;
                }

                return(new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel));
            }
            else if (type == typeof(MessageInABottle))
            {
                return(new MessageInABottle(SafeMap(from.Map)));
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                Item[] messages = pack.FindItemsByType(typeof(SOS));

                for (int i = 0; i < messages.Length; ++i)
                {
                    SOS sos = (SOS)messages[i];

                    if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60))
                    {
                        Item preLoot = null;

                        switch (Utility.Random(7))
                        {
                        case 0:                                 // Body parts
                        {
                            int[] list = new int[]
                            {
                                0x1CDD, 0x1CE5,                                                // arm
                                0x1CE0, 0x1CE8,                                                // torso
                                0x1CE1, 0x1CE9,                                                // head
                                0x1CE2, 0x1CEC                                                 // leg
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 1:                                 // Bone parts
                        {
                            int[] list = new int[]
                            {
                                0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4,                         // skulls
                                0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                0x1B15, 0x1B16                                                  // pelvis bones
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 2:                                 // Paintings and portraits
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10));
                            break;
                        }

                        case 3:                                 // Pillows
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11));
                            break;
                        }

                        case 4:                                 // Shells
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9));
                            break;
                        }

                        case 5:                                 // Misc
                        {
                            int[] list = new int[]
                            {
                                0x1EB5,                                         // unfinished barrel
                                0xA2A,                                          // stool
                                0xC1F,                                          // broken clock
                                0x1047, 0x1048,                                 // globe
                                0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4,                 // barrel staves
                                0xB5B, 0xB4F, 0xB5E, 0xB57, 0xB53,              // chairs
                                0x1560, 0x1562, 0x155D, 0x155E, 0x1582, 0x1634, //Deco Bows/Swords
                                0x156C, 0x157E, 0x1580, 0x1565, 0x1578, 0x1569, //Deco Shields/Axe
                                0xC1B, 0xC10, 0xC19, 0xC2C, 0xC2D, 0xB95,       // Ruined things/Sign
                                0xE31, 0x19AA, 0x1853, 0x9FB, 0xA05, 0xA26,     // Light sources
                                0x1EA7, 0x26AC, 0x1879, 0x1005, 0x185B, 0xEFB,  // Misc items
                                0x1810, 0xEFC, 0X14F8, 0x166E                   // More Misc Items
                                //
                                // *** Can easily add more stuff to fish up while doing chest!!
                                //
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            // This statement converts to Item and tags "... from shipwreck"
                            break;
                        }
                        }

                        if (preLoot != null)                    // Drew a "0-5" in above Case Stmt and have preLoot
                        {
                            if (0.143 > Utility.RandomDouble()) // Spawn weak monster ~ every 7 tries
                            {
                                BaseCreature serp1;

                                switch (Utility.Random(5))
                                {
                                case 0:  { serp1 = new IcebergSnake(); break; }

                                case 1:  { serp1 = new SeaSlime(); break; }

                                case 2:  { serp1 = new SeaWorm(); break; }

                                case 3:  { serp1 = new ToxicSlime(); break; }

                                default: { serp1 = new OilSlime(); break; }
                                }

                                int x = from.X, y = from.Y;
                                Map map = from.Map;

                                for (int ii = 0; map != null && ii < 20; ++ii)
                                {
                                    int  tx = from.X - 10 + Utility.Random(21);
                                    int  ty = from.Y - 10 + Utility.Random(21);
                                    Tile t  = map.Tiles.GetLandTile(tx, ty);

                                    if (t.Z == -5 && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !Spells.SpellHelper.CheckMulti(new Point3D(tx, ty, -5), map))
                                    {
                                        x = tx;
                                        y = ty;
                                        break;
                                    }
                                }

                                serp1.MoveToWorld(new Point3D(x, y, -5), map);
                                serp1.Home      = serp1.Location;
                                serp1.RangeHome = 10;
                                from.SendLocalizedMessage(503170); // Uh oh! That doesn't look like a fish!
                            }

                            return(preLoot);
                        }

                        sos.Delete();

                        WoodenChest chest = new WoodenChest();

                        TreasureMapChest.Fill(chest, Utility.RandomMinMax(1, 4));

                        // TODO: Are there chances on this? All MIB's I've done had nets..
                        chest.DropItem(new SpecialFishingNet());

                        chest.Movable   = true;
                        chest.Locked    = false;
                        chest.TrapType  = TrapType.None;
                        chest.TrapPower = 0;

                        return(chest);
                    }
                }
            }

            return(base.Construct(type, from));
        }
예제 #5
0
        private List <InventoryItemSerialized> SerializeInventory(List <InventoryItem> inv)
        {
            int index = 0;
            List <InventoryItemSerialized> ret = Enumerable.Repeat <InventoryItemSerialized>(null, inv.Count()).ToList();

            foreach (InventoryItem item in inv)
            {
                if (item == null)
                {
                    ret[index] = null;
                    index++;
                    continue;
                }

                InventoryItemSerialized iszd = new InventoryItemSerialized();
                iszd.itemKey       = item.itemKey;
                iszd.stackedAmount = item.amountStacked;

                // Special cases
                if (item.itemKey.Equals("treasureMapItem"))
                {
                    iszd.treasureMaps = new Dictionary <int, TreasureMapItemSerialized>();
                    TreasureMapItemSerialized tms = new TreasureMapItemSerialized();
                    TreasureMap m = (TreasureMap)item;
                    tms.digLocation      = m.digTileLoc;
                    tms.treasureInRegion = m.treasureInRegion;
                    if (m.rewarded != null)
                    {
                        tms.storageType = m.storageTierType;
                        tms.reward      = SerializeInventory(m.rewarded.inventory); // risk of infite loop recusion, but only if you bury treasure maps in storage that you have a map for. It shouuuuld reach a base case.. lol
                    }

                    iszd.treasureMaps.Add(index, tms);
                }
                else if (item is IStorageItem)
                {
                    iszd.storageItems = new Dictionary <int, List <InventoryItemSerialized> >();
                    Storage st           = (Storage)item.placeableVersion;
                    int     indexStorage = 0;
                    List <InventoryItemSerialized> storageInventorySzd = Enumerable.Repeat <InventoryItemSerialized>(null, st.inventory.Count()).ToList();
                    foreach (InventoryItem stItem in st.inventory)
                    {
                        if (stItem == null)
                        {
                            storageInventorySzd[indexStorage] = null;
                            indexStorage++;
                            continue;
                        }

                        InventoryItemSerialized stItemSzd = new InventoryItemSerialized();
                        stItemSzd.itemKey       = stItem.itemKey;
                        stItemSzd.stackedAmount = stItem.amountStacked;
                        if (stItem.itemKey.Equals("treasureMapItem"))
                        {
                            stItemSzd.treasureMaps = new Dictionary <int, TreasureMapItemSerialized>();
                            TreasureMapItemSerialized tm = new TreasureMapItemSerialized();
                            TreasureMap m = (TreasureMap)stItem;
                            tm.digLocation      = m.digTileLoc;
                            tm.treasureInRegion = m.treasureInRegion;
                            if (tm.reward != null)
                            {
                                tm.reward = SerializeInventory(m.rewarded.inventory); // risk of infite loop recusion, but only if you bury treasure maps in storage that you have a map for. It shouuuuld reach a base case.. lol
                            }
                            stItemSzd.treasureMaps.Add(indexStorage, tm);
                        }
                        // do not need to check for more storage here because I have prevented storage from being placed within storage.. TODO

                        storageInventorySzd[indexStorage] = stItemSzd;
                        indexStorage++;
                    }
                    iszd.storageItems.Add(index, storageInventorySzd);
                }

                ret[index] = iszd;
                index++;
            }

            return(ret);
        }
예제 #6
0
        public int ConsumeTatteredWallMapRes(Mobile from, ConsumeType type)
        {
            Item[]      maps      = from.Backpack.FindItemsByType(typeof(TreasureMap));
            List <Item> toConsume = new List <Item>();

            int one   = 10;
            int three = 5;
            int four  = 3;
            int five  = 1;

            foreach (Item item in maps)
            {
                TreasureMap map = item as TreasureMap;

                if (map != null)
                {
                    switch (map.Level)
                    {
                    case 1:
                        if (map.CompletedBy == from)
                        {
                            one--;
                            toConsume.Add(map);
                        }
                        break;

                    case 3:
                        if (map.CompletedBy == from)
                        {
                            three--;
                            toConsume.Add(map);
                        }
                        break;

                    case 4:
                        if (map.CompletedBy == from)
                        {
                            four--;
                            toConsume.Add(map);
                        }
                        break;

                    case 5:
                        if (map.CompletedBy == from)
                        {
                            five--;
                            toConsume.Add(map);
                        }
                        break;
                    }
                }
            }

            int message = 0;

            if (one > 0)
            {
                message = 1073495;
            }
            else if (three > 0)
            {
                message = 1073499;
            }
            else if (four > 0)
            {
                message = 1073501;
            }
            else if (five > 0)
            {
                message = 1073503;
            }

            if (message == 0 && type == ConsumeType.All)
            {
                foreach (Item item in toConsume)
                {
                    item.Consume();
                }
            }

            toConsume.Clear();
            return(message);
        }
예제 #7
0
        public void DrawInventory(SpriteBatch sb, List <InventoryItem> itemsPlayer, List <InventoryItem> itemsShip, Storage storage)
        {
            storageContainer = storage;
            Vector2 itemDrawLoc = itemDrawLocStart;

            menuOpen = true;

            List <InventoryItem> items = itemsPlayer;
            int showSlots = maxInventorySlots;

            List <InventoryItem> itemsStorage = null;

            // draw item stat panel
            Texture2D textureItemStat = new Texture2D(_graphics, 140, 50);

            Color[] csdata = new Color[50 * 140];
            for (int j = 0; j < csdata.Length; ++j)
            {
                csdata[j] = Color.Gray;
            }
            textureItemStat.SetData(csdata);
            Vector2 itemStatLoc = new Vector2(itemDrawLoc.X + 100, itemDrawLoc.Y - 80);

            itemMenuButtonLocations["itemStat"] = new Rectangle((int)itemStatLoc.X, (int)itemStatLoc.Y, textureItemStat.Width, textureItemStat.Height);
            sb.Begin();
            sb.Draw(textureItemStat, itemStatLoc, Color.Gray);
            sb.End();

            tempInventory = Enumerable.Repeat <InventoryItem>(null, maxInventorySlots).ToList();

            // ship inv button
            if (itemsShip != null)
            {
                Texture2D textureShipButton = new Texture2D(_graphics, 90, 50);
                Color[]   data = new Color[50 * 90];
                for (int j = 0; j < data.Length; ++j)
                {
                    data[j] = Color.Gray;
                }
                textureShipButton.SetData(data);
                Vector2 shipButtonLoc = new Vector2(itemDrawLoc.X, itemDrawLoc.Y - 80);
                itemMenuButtonLocations["ship"] = new Rectangle((int)shipButtonLoc.X, (int)shipButtonLoc.Y, textureShipButton.Width, textureShipButton.Height);
                sb.Begin();
                sb.Draw(textureShipButton, shipButtonLoc, Color.Gray);
                sb.DrawString(font, "ship", shipButtonLoc, Color.Black);
                sb.End();

                if (openShipInventory)
                {
                    // ship inv addon
                    Texture2D textureInventoryShip = new Texture2D(_graphics, 440, 220);
                    Color[]   cdata = new Color[440 * 220];
                    for (int i = 0; i < cdata.Length; ++i)
                    {
                        cdata[i] = Color.DimGray;
                    }
                    textureInventoryShip.SetData(cdata);
                    sb.Begin();
                    sb.Draw(textureInventoryShip, new Vector2(location.X - _texture.Width / 2, location.Y + _texture.Height / 2), Color.White);
                    sb.End();

                    items.AddRange(itemsShip);
                    shipInventorySlots = inventoryOfPlayer.playerOnShip.maxInventorySlots;
                    showSlots          = maxInventorySlots + shipInventorySlots;
                    tempInventory      = Enumerable.Repeat <InventoryItem>(null, maxInventorySlots + shipInventorySlots).ToList();
                }
            }

            // storage inv add on
            else if (storage != null)
            {
                itemsStorage = storage.inventory;
                Texture2D textureInvStorage = new Texture2D(_graphics, 150, 400);
                Color[]   cdata             = new Color[400 * 150];
                for (int i = 0; i < cdata.Length; ++i)
                {
                    cdata[i] = Color.DimGray;
                }
                textureInvStorage.SetData(cdata);
                sb.Begin();
                sb.Draw(textureInvStorage, new Vector2(location.X + (_texture.Width / 2) + 50, location.Y - (_texture.Height / 2)), Color.White);
                sb.End();

                items.AddRange(itemsStorage);
                storageInvSlots         = itemsStorage.Count;
                showSlots               = maxInventorySlots + storageInvSlots; // BUG?
                storageItemDrawLocStart = new Vector2(location.X + (_texture.Width / 2) + 90, location.Y - (_texture.Height / 2) + 30);
                storageItemDrawLoc      = storageItemDrawLocStart;
                tempInventory           = Enumerable.Repeat <InventoryItem>(null, maxInventorySlots + storageInvSlots).ToList();
            }

            int textureHW           = 64;
            int inventorySeparation = 20;

            // draw slots
            for (int i = 0; i < showSlots; i++)
            {
                // some separation between ship/storage and player inventory
                if (i == maxInventorySlots && itemsShip != null)
                {
                    itemDrawLoc.Y += inventorySeparation;
                }

                // position storage items in storage
                if (i >= maxInventorySlots && itemsStorage != null)
                {
                    itemDrawLoc           = storageItemDrawLoc;
                    storageItemDrawLoc.X += 70;
                    if (storageItemDrawLoc.X > location.X + (GetWidth() / 2) - 50)
                    {
                        storageItemDrawLoc.X  = storageItemDrawLocStart.X;
                        storageItemDrawLoc.Y += 70;
                    }
                }

                // draw slots
                Texture2D textureSlot = new Texture2D(_graphics, textureHW, textureHW);
                Color[]   data        = new Color[64 * 64];
                Color     color       = Color.DarkGray;
                if (i == selectedIndex)
                {
                    color = Color.Crimson;
                }
                for (int j = 0; j < data.Length; ++j)
                {
                    data[j] = color;
                }
                textureSlot.SetData(data);

                Rectangle slotLoc = new Rectangle((int)itemDrawLoc.X, (int)itemDrawLoc.Y, textureHW, textureHW);
                slotLocations[i] = slotLoc;
                sb.Begin();
                sb.Draw(textureSlot, itemDrawLoc, Color.DarkGray);
                sb.End();

                itemDrawLoc.X += 70;
                if (itemDrawLoc.X > location.X + GetWidth() / 2 - 50)
                {
                    itemDrawLoc.X  = itemDrawLocStart.X;
                    itemDrawLoc.Y += 70;
                }
            }

            // draw items in list and set new list order if needed
            List <InventoryItem> tempPlayerInv  = Enumerable.Repeat <InventoryItem>(null, maxInventorySlots).ToList();
            List <InventoryItem> tempShipInv    = Enumerable.Repeat <InventoryItem>(null, shipInventorySlots).ToList();
            List <InventoryItem> tempStorageInv = Enumerable.Repeat <InventoryItem>(null, storageInvSlots).ToList();

            List <InventoryItem> invMap = itemsPlayer;

            itemDrawLoc        = itemDrawLocStart;
            storageItemDrawLoc = storageItemDrawLocStart;
            int emptyIndex = -1; // used to denote when an item is dragged into an empty slot

            for (int i = 0; i < showSlots; i++)
            {
                InventoryItem item = null;
                if (items.ElementAtOrDefault(i) != null)
                {
                    item = items[i];
                    Vector2 offsetLocation;
                    Vector2 itemLoc = itemDrawLoc;

                    // offset the item location by the ships inventory separation
                    if (i >= maxInventorySlots && itemsShip != null)
                    {
                        itemLoc.Y += inventorySeparation;
                    }
                    // position storage items in storage
                    if (i >= maxInventorySlots && itemsStorage != null)
                    {
                        itemLoc = storageItemDrawLoc;
                    }

                    // dragging
                    if (draggingItem && selectDragIndex == i)
                    {
                        itemLoc = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                    }

                    // dropping on drag
                    if (dropDragIndex >= 0 && selectDragIndex == i)
                    {
                        // prevent storage items from being put into storage --- recursionnnn
                        if (invMap[selectDragIndex] is IStorageItem && dropDragIndex > maxInventorySlots && itemsStorage != null)
                        {
                            dropDragIndex = -1;
                        }
                        else
                        {
                            itemLoc = slotLocations[dropDragIndex].Location.ToVector2();
                            if (invMap[dropDragIndex] != null) // switch spots
                            {
                                if (invMap[dropDragIndex].bbKey.Equals(invMap[selectDragIndex].bbKey) && invMap[dropDragIndex].stackable)
                                {
                                    // stack items
                                    item.amountStacked            += invMap[selectDragIndex].amountStacked;
                                    tempInventory[selectDragIndex] = null;
                                    emptyIndex = selectDragIndex;
                                }
                                else
                                {
                                    tempInventory[selectDragIndex] = invMap[dropDragIndex];
                                }
                            }
                            else
                            {
                                tempInventory[selectDragIndex] = null;
                                emptyIndex = selectDragIndex;
                            }
                            tempInventory[dropDragIndex] = item;
                            dropDragIndex = -1;
                        }
                    }

                    // track sprite scale
                    if (!saveItemSpriteScale.ContainsKey(item))
                    {
                        saveItemSpriteScale[item] = item.spriteScale;
                    }

                    // draw the items TODO: could move it icon method like CraftingMenu
                    if (item is IHandHeld) // handhelds display action frames so scaling them will make them too tiny and offset
                    {
                        item.spriteScale     = 1.3f;
                        offsetLocation       = new Vector2(itemLoc.X + textureHW / 3, itemLoc.Y + textureHW / 3);
                        item.currRowFrame    = 0;
                        item.currColumnFrame = 0;
                    }
                    else
                    {
                        item.spriteScale = (float)(itemDisplaySizePix / item.targetRectangle.Width);
                        offsetLocation   = new Vector2(itemLoc.X + textureHW / 2, itemLoc.Y + textureHW / 1.7f); // move Y down a little to leave room for stack number display
                    }

                    item.location = offsetLocation;
                    item.Draw(sb, null);

                    sb.Begin();
                    //stack amount display
                    sb.DrawString(font, "x" + item.amountStacked.ToString(), itemLoc, Color.Black);
                    //name display
                    if (i == selectedIndex)
                    {
                        sb.DrawString(font, item.itemKey, itemStatLoc, Color.Black);
                        if (item.bbKey.Equals("treasureMapItem"))
                        {
                            TreasureMap map          = (TreasureMap)item;
                            Vector2     extraInfoLoc = new Vector2(itemStatLoc.X, itemStatLoc.Y + 20);
                            sb.DrawString(font, map.treasureInRegion, extraInfoLoc, Color.Black);
                        }
                    }
                    sb.End();
                }

                // advance inventory spot
                itemDrawLoc.X += 70;
                if (itemDrawLoc.X > location.X + GetWidth() / 2 - 50)
                {
                    itemDrawLoc.X  = itemDrawLocStart.X;
                    itemDrawLoc.Y += 70;
                }
                // advance storage spot if we are in that range
                if (i >= maxInventorySlots && itemsStorage != null)
                {
                    storageItemDrawLoc.X += 70;
                    if (storageItemDrawLoc.X > location.X + (GetWidth() / 2) - 50)
                    {
                        storageItemDrawLoc.X  = storageItemDrawLocStart.X;
                        storageItemDrawLoc.Y += 70;
                    }
                }

                // keep the items that were not dragged the same
                if (tempInventory[i] == null && i != emptyIndex)
                {
                    tempInventory[i] = item;
                }

                // clear any zero stacked items
                if (tempInventory[i] != null && tempInventory[i].stackable && tempInventory[i].amountStacked <= 0)
                {
                    tempInventory[i] = null;
                }
            }

            // copy new inventory with any inventory movements
            for (int i = 0; i < tempInventory.Count; i++)
            {
                if (i < maxInventorySlots)
                {
                    tempPlayerInv[i] = tempInventory[i];
                }
                else if (i >= maxInventorySlots && itemsShip != null && openShipInventory)
                {
                    tempShipInv[i - maxInventorySlots] = tempInventory[i];
                }
                else if (i >= maxInventorySlots && itemsStorage != null)
                {
                    tempStorageInv[i - maxInventorySlots] = tempInventory[i];
                }
            }

            // set any inventory movements
            inventoryOfPlayer.inventory = tempPlayerInv;
            if (openShipInventory && itemsShip != null)
            {
                inventoryOfPlayer.playerOnShip.actionInventory = tempShipInv;
            }
            // storage movements
            if (itemsStorage != null)
            {
                storage.inventory = tempStorageInv;
            }

            if (openItemMenu)
            {
                DrawItemMenu(sb, itemsPlayer);
            }

            // draw cursor
            sb.Begin();
            sb.Draw(cursor, cursorPos, Color.White);
            sb.End();

            // reset itemDrawLoc
            itemDrawLoc = itemDrawLocStart;
        }
예제 #8
0
        public static double GetPoints(Item item)
        {
            if (item.LootType == LootType.Blessed)
            {
                return(0);
            }

            double points = 0;

            Type type = item.GetType();

            if (Entries.ContainsKey(type))
            {
                points = Entries[type];

                if (item.Stackable)
                {
                    points = points * item.Amount;
                }

                return(points);
            }
            else
            {
                if (item is RunicHammer)
                {
                    RunicHammer hammer = (RunicHammer)item;

                    if (hammer.Resource == CraftResource.DullCopper)
                    {
                        points = 5 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.ShadowIron)
                    {
                        points = 10 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Copper)
                    {
                        points = 25 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Bronze)
                    {
                        points = 100 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Gold)
                    {
                        points = 250 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Agapite)
                    {
                        points = 1000 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Verite)
                    {
                        points = 4000 * hammer.UsesRemaining;
                    }
                    else if (hammer.Resource == CraftResource.Valorite)
                    {
                        points = 8000 * hammer.UsesRemaining;
                    }
                }
                else if (item is RunicSewingKit)
                {
                    RunicSewingKit sewing = (RunicSewingKit)item;

                    if (sewing.Resource == CraftResource.SpinedLeather)
                    {
                        points = 10 * sewing.UsesRemaining;
                    }
                    else if (sewing.Resource == CraftResource.HornedLeather)
                    {
                        points = 100 * sewing.UsesRemaining;
                    }
                    else if (sewing.Resource == CraftResource.BarbedLeather)
                    {
                        points = 400 * sewing.UsesRemaining;
                    }
                }
                else if (item is PowerScroll)
                {
                    PowerScroll ps = (PowerScroll)item;

                    if (ps.Value == 105)
                    {
                        points = 50;
                    }
                    else if (ps.Value == 110)
                    {
                        points = 100;
                    }
                    else if (ps.Value == 115)
                    {
                        points = 500;
                    }
                    else if (ps.Value == 120)
                    {
                        points = 2500;
                    }
                }
                else if (item is ScrollofTranscendence)
                {
                    SpecialScroll sot = (SpecialScroll)item;

                    points = sot.Value / 0.1 * 2;
                }
                else if (item is Bait)
                {
                    Bait bait = (Bait)item;

                    points = 10 * bait.UsesRemaining;
                }
                else if (item is TreasureMap)
                {
                    TreasureMap tmap = (TreasureMap)item;

                    if (tmap.Level == 1)
                    {
                        points = 50;
                    }
                    else if (tmap.Level == 2)
                    {
                        points = 100;
                    }
                    else if (tmap.Level == 3)
                    {
                        points = 250;
                    }
                    else if (tmap.Level == 4)
                    {
                        points = 500;
                    }
                    else if (tmap.Level == 5)
                    {
                        points = 750;
                    }
                    else if (tmap.Level == 6)
                    {
                        points = 1000;
                    }
                }
                else if (item is MidnightBracers && item.LootType == LootType.Cursed)
                {
                    points = 5000;
                }
                else if (item is MonsterStatuette)
                {
                    MonsterStatuette ms = (MonsterStatuette)item;

                    if (ms.Type == MonsterStatuetteType.Slime)
                    {
                        points = 5000;
                    }
                }
                else if (item is PigmentsOfTokuno || item is LesserPigmentsOfTokuno)
                {
                    BasePigmentsOfTokuno pigments = (BasePigmentsOfTokuno)item;
                    points = 500 * pigments.UsesRemaining;
                }

                return(points);
            }
        }
예제 #9
0
        private TreasureMap Construct(TreasureMapEntry entry)
        {
            if (entry == null)
            {
                return(null);
            }


            TreasureMap map;

            if (entry.QuestItem)
            {
                map = new HiddenTreasuresTreasureMap(entry.Level, entry.Map, new Point2D(entry.Location.X, entry.Location.Y));
            }
            else
            {
                map = new TreasureMap();

                map.Facet         = entry.Map;
                map.Level         = entry.Level;
                map.Package       = (TreasurePackage)entry.Package;
                map.ChestLocation = new Point2D(entry.Location.X, entry.Location.Y);
            }

            bool eodon = map.TreasureFacet == TreasureFacet.Eodon;

            map.Completed   = entry.Completed;
            map.CompletedBy = entry.CompletedBy;
            map.Decoder     = entry.Decoder;
            map.NextReset   = entry.NextReset;

            map.Width  = 300;
            map.Height = 300;
            int x = entry.Location.X;
            int y = entry.Location.Y;
            int width, height;
            Map facet = entry.Map;

            map.GetWidthAndHeight(facet, out width, out height);

            int x1 = x - Utility.RandomMinMax(width / 4, (width / 4) * 3);
            int y1 = y - Utility.RandomMinMax(height / 4, (height / 4) * 3);

            if (x1 < 0)
            {
                x1 = 0;
            }
            if (y1 < 0)
            {
                y1 = 0;
            }

            int x2, y2;

            map.AdjustMap(facet, out x2, out y2, x1, y1, width, height, eodon);

            x1 = x2 - width;
            y1 = y2 - height;

            map.Bounds    = new Rectangle2D(x1, y1, width, height);
            map.Protected = true;

            map.AddWorldPin(x, y);

            return(map);
        }
예제 #10
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                // = GOLD PIECES
                // WIZARD FOR THE GOLD STONE LIMITER ////////////////////////////////////
                int money = 1000;

                double w = money * (DifficultyLevel.GetGoldCutRate() * .01);

                money = (int)w;

                if (targeted is TreasureMap && from.Backpack != null)
                {
                    TreasureMap tmap      = targeted as TreasureMap;
                    Container   pack      = from.Backpack;
                    int         toConsume = tmap.Level * money;

                    if (BeggingPose(from) > 0)                       // LET US SEE IF THEY ARE BEGGING - WIZARD
                    {
                        toConsume = toConsume - (int)((from.Skills[SkillName.Begging].Value * 0.005) * toConsume);
                    }

                    if (toConsume == 0)
                    {
                        return;
                    }

                    if (tmap.Decoder != null)
                    {
                        m_CartographersGuildmaster.SayTo(from, "That map has already been deciphered.");
                    }
                    else if (pack.ConsumeTotal(typeof(Gold), toConsume))
                    {
                        if (BeggingPose(from) > 0)
                        {
                            Titles.AwardKarma(from, -BeggingKarma(from), true);
                        }                                                                                                               // DO ANY KARMA LOSS
                        if (tmap.Level == 1)
                        {
                            m_CartographersGuildmaster.SayTo(from, "This map was really quite simple.");
                        }
                        else if (tmap.Level == 2)
                        {
                            m_CartographersGuildmaster.SayTo(from, "Seemed pretty easy...so here it is.");
                        }
                        else if (tmap.Level == 3)
                        {
                            m_CartographersGuildmaster.SayTo(from, "This map was a bit of a challenge.");
                        }
                        else if (tmap.Level == 4)
                        {
                            m_CartographersGuildmaster.SayTo(from, "Whoever drew this map, did not want it found.");
                        }
                        else if (tmap.Level == 5)
                        {
                            m_CartographersGuildmaster.SayTo(from, "This took more research than normal.");
                        }
                        else
                        {
                            m_CartographersGuildmaster.SayTo(from, "With the ancient writings and riddles, this map should now lead you there.");
                        }

                        from.SendMessage(String.Format("You pay {0} gold.", toConsume));
                        Effects.PlaySound(from.Location, from.Map, 0x249);
                        tmap.Decoder = from;
                    }
                    else
                    {
                        m_CartographersGuildmaster.SayTo(from, "It would cost you {0} gold for me to decipher that map.", toConsume);
                        from.SendMessage("You do not have enough gold.");
                    }
                }
                else
                {
                    m_CartographersGuildmaster.SayTo(from, "That does not need my services.");
                }
            }