Esempio n. 1
0
File: Item.cs Progetto: Vinna/aura
        /// <summary>
        /// Drops item at location.
        /// </summary>
        /// <param name="region">Region to drop the item in.</param>
        /// <param name="pos">
        /// Center point of the drop, which is slightly randomized in this method.
        /// </param>
        /// <param name="owner">
        /// The only entity that is allowed to pick up the item for a
        /// certain period of time. Set to null to not protect item from
        /// being picked up.
        /// </param>
        /// <param name="playerDrop">
        /// Whether the item is being dropped by a player, the owner.
        /// If it is, normal items aren't protected.
        /// </param>
        public void Drop(Region region, Position pos, Creature owner, bool playerDrop)
        {
            var rnd = RandomProvider.Get();

            // Get random drop position
            var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1);
            var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1);

            //this.SetNewEntityId();
            this.Move(region.Id, x, y);

            // Keys don't disappear (?)
            if (!this.HasTag("/key/"))
            {
                this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60));
            }

            // Specify who can pick up the item when
            if (owner != null)
            {
                this.OwnerId = owner.EntityId;

                // Personal items can never be picked up by anyone else
                var isPersonal =
                    (this.Data.Action == ItemAction.StaticItem || this.Data.Action == ItemAction.AccountPersonalItem || this.Data.Action == ItemAction.CharacterPersonalItem) ||
                    this.Is(ItemFlags.Personalized);

                // Set protection if item wasn't dropped by a player
                // and it's not a dungeon room key
                var standardProtection = (!isPersonal && !playerDrop && !this.IsDungeonRoomKey);

                if (isPersonal)
                {
                    this.ProtectionLimit = DateTime.MaxValue;
                }
                else if (standardProtection)
                {
                    var seconds = ChannelServer.Instance.Conf.World.LootStealProtection;
                    if (seconds > 0)
                    {
                        this.ProtectionLimit = DateTime.Now.AddSeconds(seconds);
                    }
                    else
                    {
                        this.ProtectionLimit = null;
                    }
                }
            }
            else
            {
                this.OwnerId         = 0;
                this.ProtectionLimit = null;
            }

            // Add item to region
            region.AddItem(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a random magic attack damage value.
        /// </summary>
        /// <returns></returns>
        public int GetRandomMAtk()
        {
            var rnd = RandomProvider.Get();

            var min = this.Properties.GetInt(PropertyId.PC.MINMATK);
            var max = this.Properties.GetInt(PropertyId.PC.MAXMATK);

            return(rnd.Next(min, max + 1));
        }
Esempio n. 3
0
    // Returns index 0~7 for equip level 70-
    // Returns index 8~15 for equip level 70+
    private static int Roll(int itemId)
    {
        float  itemLevelFactor = ItemMetadataStorage.GetOptionLevelFactor(itemId);
        Random random          = RandomProvider.Get();

        if (itemLevelFactor >= 70)
        {
            return(random.NextDouble() switch
            {
Esempio n. 4
0
    public static void GiveRandomGifts(Creature creature)
    {
        var rnd = RandomProvider.Get();

        var item1 = Item.GetRandomDrop(rnd, rewards);
        var item2 = Item.GetRandomDrop(rnd, rewardsAdv);

        creature.AcquireItem(item1);
        creature.AcquireItem(item2);
    }
Esempio n. 5
0
            /// <summary>
            /// Get unique color for a locked place.
            /// </summary>
            public uint GetLockColor()
            {
                if (_availableColors.Count == 0)
                {
                    // We out of awailable colours, lets return random one
                    return((uint)RandomProvider.Get().Next(0xFFFFFF));
                }

                return(_availableColors.Dequeue());
            }
Esempio n. 6
0
    public void CreateRegionAndWarp(Creature creature)
    {
        var region = new DynamicRegion(118);

        ChannelServer.Instance.World.AddRegion(region);

        var rnd         = RandomProvider.Get();
        var sheepAmount = SheepAmount;

        // After x ms (success)
        var timer = SetTimeout(Time, () =>
        {
            // Unofficial, I think the msg also depends on how well you did.
            // Official >10: Thanks to my dilligent supervision, over 10 sheep are safe.
            Send.Notice(creature, NoticeType.MiddleSystem, L("The time is over, you did it."));
            Send.RemoveQuestTimer(creature);
            creature.Keywords.Give("TirChonaill_Tutorial_Thinking");
            creature.Warp(1, 27622, 42125);
        });

        // Spawn sheep
        for (int i = 0; i < sheepAmount; ++i)
        {
            var pos = Center.GetRandomInRect(6000, 4000, rnd);

            var npc = new NPC(40001);             // Sheep
            npc.Death += (killed, killer) =>
            {
                sheepAmount--;

                // Cancel if success is not possible anymore.
                if (sheepAmount < SheepMinAmount)
                {
                    Send.Notice(creature, NoticeType.MiddleSystem, L("You've failed to save the sheep."));
                    Send.RemoveQuestTimer(creature);
                    StopTimer(timer);
                    creature.Warp(1, 27622, 42125);
                    return;
                }

                Send.UpdateQuestTimerCounter(creature, L("Remaining sheep: {0}"), sheepAmount);
            };
            npc.Spawn(region.Id, pos.X, pos.Y);
        }

        // Spawn wolves
        for (int i = 0; i < WolfAmount; ++i)
        {
            SpawnWolf(region.Id, rnd);
        }

        // Warp to region and start visible timer
        creature.Warp(region.Id, 60000, 58000);
        Send.SetQuestTimer(creature, Time, L("Protect the sheep from wolves"), L("Deadline: {0}"), L("Remaining sheep: {0}"), sheepAmount);
    }
Esempio n. 7
0
        /// <summary>
        /// Returns a unique number of random parameters,
        /// useful when you need unique random numbers for example.
        /// </summary>
        /// <example>
        /// var n = UniqueRnd(3, 1,2,3,4,5); // n = int[] { 3, 1, 5 }
        /// var s = UniqueRnd(2, "test", "foo", "bar"); // s = string[] { "bar", "foo" }
        /// </example>
        /// <typeparam name="T"></typeparam>
        /// <param name="amount"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        protected T[] UniqueRnd <T>(int amount, params T[] values)
        {
            if (values == null || values.Length == 0 || values.Length < amount)
            {
                throw new ArgumentException("Values may not be null, empty, or smaller than amount.");
            }

            var rnd = RandomProvider.Get();

            return(values.OrderBy(a => rnd.Next()).Take(amount).ToArray());
        }
        public int GenerateColor()
        {
            //Generate a random color...
            int color = RandomProvider.Get().Next(0xFFFFFF);

            if (color == 0xFF0000)             //Boss key exception
            {
                return(this.GenerateColor());
            }

            return(color);
        }
Esempio n. 9
0
        // Functions
        // ------------------------------------------------------------------

        /// <summary>
        /// Heals a certain amount of life, mana, and stamina.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="life"></param>
        /// <param name="mana"></param>
        /// <param name="stamina"></param>
        protected void Heal(Creature creature, double life, double mana, double stamina, double toxicity)
        {
            // Potion poisoning heal mount increase
            // http://wiki.mabinogiworld.com/view/Potion_Poisoning#Stages_of_Potion_Poisoning
            var multiplier    = 1.0;
            var toxicityStage = GetToxicityStage(creature.Toxic);

            if (toxicityStage != ToxicityStage.Normal)
            {
                var rnd = RandomProvider.Get();
                switch (toxicityStage)
                {
                case ToxicityStage.Stage1: multiplier = 1.0 + rnd.NextDouble() * 0.3; break;

                case ToxicityStage.Stage2: multiplier = 1.3; break;

                case ToxicityStage.Stage3: multiplier = 1.3 + rnd.NextDouble() * 0.3; break;

                case ToxicityStage.Stage4: multiplier = 1.6; break;

                case ToxicityStage.Stage5: multiplier = 1.6 + rnd.NextDouble() * 0.4; break;

                case ToxicityStage.Stage6: multiplier = 2.0 + rnd.NextDouble() * 1.0; break;
                }

                life    *= multiplier;
                mana    *= multiplier;
                stamina *= multiplier;
            }

            // Friday: All potions become more potent. (Potion effect x 1.5 including toxicity).
            // +50%? Seems a lot, but that's what the Wiki says.
            if (ErinnTime.Now.Month == ErinnMonth.AlbanElved)
            {
                life    *= 1.5;
                mana    *= 1.5;
                stamina *= 1.5;
            }

            var beforeLife    = creature.Life;
            var beforeMana    = creature.Mana;
            var beforeStamina = creature.Stamina;

            creature.Life    += (float)life;
            creature.Mana    += (float)mana;
            creature.Stamina += (float)stamina * creature.StaminaRegenMultiplicator;

            var diffLife    = creature.Life - beforeLife;
            var diffMana    = creature.Mana - beforeMana;
            var diffStamina = creature.Stamina - beforeStamina;

            this.Poison(creature, diffLife, diffMana, diffStamina, toxicity);
        }
Esempio n. 10
0
        /// <summary>
        /// Randomizes colors of all items in all tabs.
        /// </summary>
        protected virtual void RandomizeItemColors()
        {
            var rand = RandomProvider.Get();

            lock (_tabs)
            {
                foreach (var tab in _tabs.Values)
                {
                    tab.RandomizeItemColors();
                }
            }
        }
Esempio n. 11
0
        // Roll new bonus stats and values except the locked stat
        public static List <ItemStat> RollBonusStatsWithStatLocked(Item item, short ignoreStat, bool isSpecialStat)
        {
            int id = item.Id;

            int randomId = ItemMetadataStorage.GetOptionRandom(id);
            ItemOptionRandom randomOptions = ItemOptionRandomMetadataStorage.GetMetadata(randomId, item.Rarity);

            if (randomOptions == null)
            {
                return(null);
            }

            List <ItemStat> itemStats = new List <ItemStat>();

            List <ParserStat>        attributes        = isSpecialStat ? randomOptions.Stats : randomOptions.Stats.Where(x => (short)x.Id != ignoreStat).ToList();
            List <ParserSpecialStat> specialAttributes = isSpecialStat ? randomOptions.SpecialStats.Where(x => (short)x.Id != ignoreStat).ToList() : randomOptions.SpecialStats;

            foreach (ParserStat attribute in attributes)
            {
                Dictionary <ItemAttribute, List <ParserStat> > dictionary = GetRange(randomId);
                if (!dictionary.ContainsKey(attribute.Id))
                {
                    continue;
                }

                NormalStat normalStat = new NormalStat(dictionary[attribute.Id][Roll(id)]);
                if (randomOptions.MultiplyFactor > 0)
                {
                    normalStat.Flat    *= (int)Math.Ceiling(randomOptions.MultiplyFactor);
                    normalStat.Percent *= randomOptions.MultiplyFactor;
                }
                itemStats.Add(normalStat);
            }

            foreach (ParserSpecialStat attribute in specialAttributes)
            {
                Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > dictionary = GetSpecialRange(randomId);
                if (!dictionary.ContainsKey(attribute.Id))
                {
                    continue;
                }

                SpecialStat specialStat = new SpecialStat(dictionary[attribute.Id][Roll(id)]);
                if (randomOptions.MultiplyFactor > 0)
                {
                    specialStat.Flat    *= (int)Math.Ceiling(randomOptions.MultiplyFactor);
                    specialStat.Percent *= randomOptions.MultiplyFactor;
                }
                itemStats.Add(specialStat);
            }

            return(itemStats.OrderBy(x => RandomProvider.Get().Next()).Take(item.Stats.BonusStats.Count).ToList());
        }
Esempio n. 12
0
        /// <summary>
        /// Starts fishing with given delay.
        /// </summary>
        /// <remarks>
        /// This method uses async Tasks to control when the skill continues
        /// (basically timers). Since the player could cancel the skill before
        /// the method continues, or props could be removed because of a reload,
        /// we need to make sure not to continue and not to crash because of
        /// a change in the prop situation.
        ///
        /// TODO: Use cancellation tokens?
        /// TODO: Don't reload spawned props, but only scripted ones?
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="delay"></param>
        public async void StartFishing(Creature creature, int delay)
        {
            var rnd  = RandomProvider.Get();
            var prop = creature.Temp.FishingProp;

            await Task.Delay(delay);

            // Check that the prop is still the same (player could have canceled
            // and restarted, spawning a new one) and the prop wasn't removed
            // from region (e.g. >reloadscripts).
            if (creature.Temp.FishingProp != prop || creature.Temp.FishingProp.Region == Region.Limbo)
            {
                return;
            }

            // Update prop state
            creature.Temp.FishingProp.SetState("normal");

            await Task.Delay(rnd.Next(5000, 120000));

            if (creature.Temp.FishingProp != prop || creature.Temp.FishingProp.Region == Region.Limbo)
            {
                return;
            }

            // Update prop state
            creature.Temp.FishingProp.SetState("hooked");

            // Get fishing drop
            creature.Temp.FishingDrop = this.GetFishingDrop(creature, rnd);

            // Random time
            var time = 10000;

            switch (rnd.Next(4))
            {
            case 0: time = 4000; break;

            case 1: time = 8000; break;

            case 2: time = 6000; break;

            case 3: time = 10000; break;
            }

            var catchSize = CatchSize.Something;
            var fishSpeed = 1f;

            // Request action
            creature.Temp.FishingActionRequested = true;
            Send.FishingActionRequired(creature, catchSize, time, fishSpeed);
        }
Esempio n. 13
0
        public void DyePaletteReq(ChannelClient client, Packet packet)
        {
            var creature = client.GetCreatureSafe(packet.Id);

            var rnd = RandomProvider.Get();

            var a1 = creature.Temp.DyeDistortA1 = rnd.Next(256);
            var a2 = creature.Temp.DyeDistortA2 = rnd.Next(256);
            var a3 = creature.Temp.DyeDistortA3 = rnd.Next(256);
            var a4 = creature.Temp.DyeDistortA4 = rnd.Next(256);

            Send.DyePaletteReqR(creature, a1, a2, a3, a4);
        }
Esempio n. 14
0
        /// <summary>
        /// Reduces weapon's durability and increases its proficiency.
        /// Only updates weapon type items that are not null.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="weapon"></param>
        public static void UpdateWeapon(Creature attacker, Creature target, params Item[] weapons)
        {
            if (attacker == null)
            {
                return;
            }

            var rnd = RandomProvider.Get();

            foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon))
            {
                // Durability
                if (!ChannelServer.Instance.Conf.World.NoDurabilityLoss)
                {
                    var reduce = rnd.Next(1, 30);

                    // Half dura loss if blessed
                    if (weapon.IsBlessed)
                    {
                        reduce = Math.Max(1, reduce / 2);
                    }

                    weapon.Durability -= reduce;
                    Send.ItemDurabilityUpdate(attacker, weapon);
                }

                // Proficiency
                // Only if the weapon isn't broken and the target is not "Weakest".
                if (weapon.Durability != 0 && attacker != null && attacker.GetPowerRating(target) >= PowerRating.Weak)
                {
                    short prof = 0;

                    if (attacker.Age >= 10 && attacker.Age <= 12)
                    {
                        prof = 48;
                    }
                    else if (attacker.Age >= 13 && attacker.Age <= 19)
                    {
                        prof = 60;
                    }
                    else
                    {
                        prof = 72;
                    }

                    weapon.Proficiency += prof;

                    Send.ItemExpUpdate(attacker, weapon);
                }
            }
        }
Esempio n. 15
0
    public static void GiveItemFromSelectBox(GameSession session, Item sourceItem, int index)
    {
        SelectItemBox    box      = sourceItem.Function.SelectItemBox;
        ItemDropMetadata metadata = ItemDropMetadataStorage.GetItemDropMetadata(box.BoxId);

        if (metadata == null)
        {
            session.Send(NoticePacket.Notice("No items found", NoticeType.Chat));
            return;
        }

        Inventory inventory = session.Player.Inventory;

        inventory.ConsumeItem(session, sourceItem.Uid, 1);

        // Select boxes disregards group ID. Adding these all to a filtered list
        List <DropGroupContent> dropContentsList = new();

        foreach (DropGroup group in metadata.DropGroups)
        {
            foreach (DropGroupContent dropGroupContent in group.Contents)
            {
                if (dropGroupContent.SmartDropRate == 100)
                {
                    List <Job> recommendJobs = ItemMetadataStorage.GetRecommendJobs(dropGroupContent.ItemIds.First());
                    if (recommendJobs.Contains(session.Player.Job) || recommendJobs.Contains(Job.None))
                    {
                        dropContentsList.Add(dropGroupContent);
                    }
                    continue;
                }
                dropContentsList.Add(dropGroupContent);
            }
        }

        DropGroupContent dropContents = dropContentsList[index];

        Random rng    = RandomProvider.Get();
        int    amount = rng.Next((int)dropContents.MinAmount, (int)dropContents.MaxAmount);

        foreach (int id in dropContents.ItemIds)
        {
            Item newItem = new(id)
            {
                Enchants = dropContents.EnchantLevel,
                Amount   = amount,
                Rarity   = dropContents.Rarity
            };
            inventory.AddItem(session, newItem, true);
        }
    }
Esempio n. 16
0
        /// <summary>
        /// Sets new randomized session key for the account and returns it.
        /// </summary>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public static uint CreateSession(MySqlConnection dbconn, string accountId)
        {
            using (var mc = new MySqlCommand("UPDATE `Users` SET `Ticket` = @ticketKey WHERE `Username` = @user", dbconn))
            {
                var ticketKey = RandomProvider.Get().NextUInt32();

                mc.Parameters.AddWithValue("@user", accountId);
                mc.Parameters.AddWithValue("@ticketKey", ticketKey);

                mc.ExecuteNonQuery();

                return(ticketKey);
            }
        }
Esempio n. 17
0
        public void Between()
        {
            var rnd = RandomProvider.Get();

            for (var i = 0; i < 1000000; ++i)
            {
                Assert.InRange(rnd.Between(10, 20), 10, 20);
            }

            for (var i = 0; i < 1000000; ++i)
            {
                Assert.InRange(rnd.Between(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20)), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Drops item in location with a new entity id.
        /// </summary>
        /// <param name="region"></param>
        /// <param name="pos"></param>
        public void Drop(Region region, Position pos)
        {
            var rnd = RandomProvider.Get();

            // Get random drop position
            var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1);
            var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1);

            //this.SetNewEntityId();
            this.Move(region.Id, x, y);
            this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60));

            region.AddItem(this);
        }
        public static int GetCustomSellPrice(int itemId)
        {
            // get random selling price from price points
            List <int> pricePoints = map.GetValueOrDefault(itemId)?.SellPriceCustom;

            if (pricePoints == null || !pricePoints.Any())
            {
                return(0);
            }

            int rand = RandomProvider.Get().Next(0, pricePoints.Count);

            return(pricePoints.ElementAt(rand));
        }
Esempio n. 20
0
 public void OnCreatureFinished(Creature creature, Creature killer)
 {
     if (creature.RegionId == 600 && creature.HasTag("/rat/"))
     {
         var rnd = RandomProvider.Get();
         var pos = creature.GetPosition();
         if (rnd.NextDouble() * 100 < 4 * ChannelServer.Instance.Conf.World.DropRate)
         {
             var catsBellDropPos = pos.GetRandomInRange(50, rnd);
             var catsBellItem    = new Item(91108);              // Cat Bell
             catsBellItem.Drop(creature.Region, catsBellDropPos, Item.DropRadius, killer, true);
         }
     }
 }
Esempio n. 21
0
        public static int GetWeaponObjectItemId(int mapId, CoordB coord)
        {
            MapWeaponObject weaponObject = WeaponObjects.GetValueOrDefault(mapId).FirstOrDefault(x => x.Coord == coord);

            if (weaponObject == null)
            {
                return(0);
            }

            Random random = RandomProvider.Get();
            int    index  = random.Next(weaponObject.WeaponItemIds.Count);

            return(weaponObject.WeaponItemIds[index]);
        }
Esempio n. 22
0
        public static List <CoordF> SelectPoints(int spawnRadius = Block.BLOCK_SIZE)
        {
            List <CoordF> spawnOffsets = new List <CoordF>();
            int           spawnSize    = 2 * (spawnRadius / Block.BLOCK_SIZE);

            for (int i = 0; i <= spawnSize; i++)
            {
                for (int j = 0; j <= spawnSize; j++)
                {
                    spawnOffsets.Add(CoordF.From(i * Block.BLOCK_SIZE - spawnRadius, j * Block.BLOCK_SIZE - spawnRadius, 0));
                }
            }
            return(spawnOffsets.OrderBy(x => RandomProvider.Get().Next()).ToList());
        }
Esempio n. 23
0
    protected void ContributorDrops(Creature boss, List <DropData> drops)
    {
        var hitters = boss.GetAllHitters();
        var rnd     = RandomProvider.Get();

        foreach (var hitter in hitters)
        {
            var pos    = hitter.GetPosition();
            var item   = Item.GetRandomDrop(rnd, drops);
            var region = hitter.Region;

            item.Drop(region, pos, 100);
        }
    }
Esempio n. 24
0
        /// <summary>
        /// Creates new placement provider.
        /// </summary>
        /// <param name="positionType"></param>
        /// <param name="radius"></param>
        public PlacementProvider(Placement positionType, int radius = 600)
        {
            _positionQueue     = new Queue <int[]>();
            _positionType      = positionType;
            _radius            = radius;
            _reservedPositions = new List <Position>();

            float[,] offsets = null;
            switch (positionType)
            {
            case Placement.Corner4:
                offsets = _corner4Offsets;
                break;

            case Placement.Corner8:
                offsets = _corner8Offsets;
                break;

            case Placement.Treasure8:
                offsets = _treasure8Offsets;
                break;

            case Placement.Center9:
                offsets = _center9Offsets;
                break;

            case Placement.Center:
                offsets = _centerOffset;
                break;

            case Placement.Ore:
                offsets = _oreOffsets;
                break;
            }

            if (offsets == null)
            {
                return;
            }

            var rnd     = RandomProvider.Get();
            var shuffle = Enumerable.Range(0, offsets.GetLength(0));

            shuffle = shuffle.OrderBy(a => rnd.Next());
            foreach (int i in shuffle)
            {
                _positionQueue.Enqueue(new int[] { (int)(offsets[i, 0] * radius), (int)(offsets[i, 1] * radius), (int)offsets[i, 2] });
            }
        }
Esempio n. 25
0
File: NPC.cs Progetto: Vinna/aura
		/// <summary>
		/// NPCs may survive randomly.
		/// </summary>
		/// <remarks>
		/// http://wiki.mabinogiworld.com/view/Stats#Life
		/// More Will supposedly increases the chance. Unknown if this
		/// applies to players as well. Before certain Gs, NPCs weren't
		/// able to survive attacks under any circumstances.
		/// </remarks>
		/// <param name="damage"></param>
		/// <param name="from"></param>
		/// <param name="lifeBefore"></param>
		/// <returns></returns>
		protected override bool ShouldSurvive(float damage, Creature from, float lifeBefore)
		{
			// No surviving once you're in deadly
			if (lifeBefore < 0)
				return false;

			if (!ChannelServer.Instance.Conf.World.DeadlyNpcs)
				return false;

			// Chance = Will/10, capped at 50%
			// (i.e 80 Will = 8%, 500+ Will = 50%)
			// Actual formula unknown
			var chance = Math.Min(50, this.Will / 10);
			return (RandomProvider.Get().Next(101) < chance);
		}
Esempio n. 26
0
    public void SetRandomMesh(int[] meshIds, bool isVisible, byte meshCount, int arg4, int delayTime)
    {
        Random random = RandomProvider.Get();

        int[] pickedMeshIds = meshIds.OrderBy(x => random.Next()).Take(meshCount).ToArray();
        Task.Run(async() =>
        {
            foreach (int triggerMeshId in pickedMeshIds)
            {
                Field.State.TriggerMeshes[triggerMeshId].IsVisible = isVisible;
                Field.BroadcastPacket(TriggerPacket.UpdateTrigger(Field.State.TriggerMeshes[triggerMeshId]));
                await Task.Delay(delayTime);
            }
        });
    }
Esempio n. 27
0
        /// <summary>
        /// Sets new randomized session key for the account and returns it.
        /// </summary>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public long CreateSession(string accountId)
        {
            using (var conn = this.Connection)
                using (var mc = new MySqlCommand("UPDATE `accounts` SET `sessionKey` = @sessionKey WHERE `accountId` = @accountId", conn))
                {
                    var sessionKey = RandomProvider.Get().NextInt64();

                    mc.Parameters.AddWithValue("@accountId", accountId);
                    mc.Parameters.AddWithValue("@sessionKey", sessionKey);

                    mc.ExecuteNonQuery();

                    return(sessionKey);
                }
        }
Esempio n. 28
0
    public override void OnUse(Creature cr, Item i, string param)
    {
        List <DropData> list;

        list = new List <DropData>();

        // Hats
        list.Add(new DropData(itemId: 18955, chance: 30));         // Heart Eyepatch
        list.Add(new DropData(itemId: 18957, chance: 30));         // Lollipop Heart Eyepatch
        list.Add(new DropData(itemId: 18392, chance: 30));         // Heart-shaped Glasses
        list.Add(new DropData(itemId: 28610, chance: 20));         // Macaroon Mistress Hat
        list.Add(new DropData(itemId: 210363, chance: 20));        // Macaroon Mistress Wig
        list.Add(new DropData(itemId: 18834, chance: 20));         // Lady Waffle Cone Bow
        list.Add(new DropData(itemId: 28725, chance: 10));         // Waffle Witch Wig
        list.Add(new DropData(itemId: 28726, chance: 10));         // Waffle Witch Wig and Hat
        list.Add(new DropData(itemId: 28727, chance: 10));         // Waffle Witch Hat

        // Clothing
        list.Add(new DropData(itemId: 80736, chance: 20));         // Macaroon Mistress Dress
        list.Add(new DropData(itemId: 15785, chance: 20));         // Lady Waffle Cone Dress
        list.Add(new DropData(itemId: 80858, chance: 10));         // Waffle Witch Dress

        // Shoes
        list.Add(new DropData(itemId: 17429, chance: 20));          // Macaroon Mistress Shoes
        list.Add(new DropData(itemId: 17373, chance: 20));          // Lady Waffle Cone Ribbon Shoes
        list.Add(new DropData(itemId: 17826, chance: 10));          // Waffle Witch Shoes

        // Gloves
        list.Add(new DropData(itemId: 16200, chance: 20));          // Lady Waffle Cone Heart Ring

        // Weapons
        list.Add(new DropData(itemId: 40723, chance: 20));         // Heart Lightning Wand
        list.Add(new DropData(itemId: 40724, chance: 20));         // Heart Fire Wand
        list.Add(new DropData(itemId: 40725, chance: 20));         // Heart Ice Wand
        list.Add(new DropData(itemId: 41141, chance: 20));         // Lady Waffle Cone Heart Clutch
        list.Add(new DropData(itemId: 41275, chance: 15));         // Heart Glow Stick (red)

        // Wings
        list.Add(new DropData(itemId: 19194, chance: 5));         // Hot Pink Heart Wings

        // Useables
        list.Add(new DropData(itemId: 45118, chance: 30, amount: 5));         // Heart Shaped Fireworks Kit

        var rnd  = RandomProvider.Get();
        var item = Item.GetRandomDrop(rnd, list);

        cr.Inventory.Add(item, true);
    }
Esempio n. 29
0
    public override void OnUse(Creature cr, Item i, string param)
    {
        List <DropData> list;

        list = new List <DropData>();

        // Hats
        list.Add(new DropData(itemId: 18955, chance: 30));         // Heart Eyepatch
        list.Add(new DropData(itemId: 18957, chance: 30));         // Lollipop Heart Eyepatch
        list.Add(new DropData(itemId: 18392, chance: 30));         // Heart-shaped Glasses
        list.Add(new DropData(itemId: 28609, chance: 20));         // Count Cookie Hat (M)
        list.Add(new DropData(itemId: 210361, chance: 20));        // Count Cookie Wig
        list.Add(new DropData(itemId: 18833, chance: 20));         // Lord Waffle Cone Hat
        list.Add(new DropData(itemId: 28722, chance: 10));         // Waffle Wizard Wig
        list.Add(new DropData(itemId: 28723, chance: 10));         // Waffle Wizard Wig and Hat
        list.Add(new DropData(itemId: 28724, chance: 10));         // Waffle Wizard Hat

        // Clothing
        list.Add(new DropData(itemId: 80735, chance: 20));         // Count Cookie Suit
        list.Add(new DropData(itemId: 15784, chance: 20));         // Lord Waffle Cone Suit
        list.Add(new DropData(itemId: 80857, chance: 10));         // Waffle Wizard Suit

        // Shoes
        list.Add(new DropData(itemId: 17428, chance: 20));          // Count Cookie Shoes
        list.Add(new DropData(itemId: 17372, chance: 20));          // Lord Waffle Cone Shoes
        list.Add(new DropData(itemId: 17825, chance: 10));          // Waffle Wizard Shoes

        // Gloves
        list.Add(new DropData(itemId: 16199, chance: 20));          // Lord Waffle Cone Bracelet

        // Weapons
        list.Add(new DropData(itemId: 40723, chance: 20));         // Heart Lightning Wand
        list.Add(new DropData(itemId: 40724, chance: 20));         // Heart Fire Wand
        list.Add(new DropData(itemId: 40725, chance: 20));         // Heart Ice Wand
        list.Add(new DropData(itemId: 41140, chance: 20));         // Lord Waffle Cone Heart Key
        list.Add(new DropData(itemId: 41275, chance: 15));         // Heart Glow Stick (red)

        // Wings
        list.Add(new DropData(itemId: 19194, chance: 5));         // Hot Pink Heart Wings

        // Useables
        list.Add(new DropData(itemId: 45118, chance: 30, amount: 5));         // Heart Shaped Fireworks Kit

        var rnd  = RandomProvider.Get();
        var item = Item.GetRandomDrop(rnd, list);

        cr.Inventory.Add(item, true);
    }
Esempio n. 30
0
        /// <summary>
        /// Loads default information from race data.
        /// </summary>
        /// <param name="fullyFunctional">Fully functional creatures have an inv, regens, etc.</param>
        public override void LoadDefault(bool fullyFunctional = true)
        {
            base.LoadDefault(fullyFunctional);

            var rnd = RandomProvider.Get();

            // Equipment
            foreach (var itemData in this.RaceData.Equip)
            {
                var item = new Item(itemData.GetRandomId(rnd));
                if (itemData.Color1s.Count > 0)
                {
                    item.Info.Color1 = itemData.GetRandomColor1(rnd);
                }
                if (itemData.Color2s.Count > 0)
                {
                    item.Info.Color2 = itemData.GetRandomColor2(rnd);
                }
                if (itemData.Color3s.Count > 0)
                {
                    item.Info.Color3 = itemData.GetRandomColor3(rnd);
                }

                var pocket = (Pocket)itemData.Pocket;
                if (pocket != Pocket.None)
                {
                    this.Inventory.Add(item, pocket);
                }
            }

            // Face
            if (this.RaceData.Face.EyeColors.Count > 0)
            {
                this.EyeColor = (byte)this.RaceData.Face.GetRandomEyeColor(rnd);
            }
            if (this.RaceData.Face.EyeTypes.Count > 0)
            {
                this.EyeType = (short)this.RaceData.Face.GetRandomEyeType(rnd);
            }
            if (this.RaceData.Face.MouthTypes.Count > 0)
            {
                this.MouthType = (byte)this.RaceData.Face.GetRandomMouthType(rnd);
            }
            if (this.RaceData.Face.SkinColors.Count > 0)
            {
                this.SkinColor = (byte)this.RaceData.Face.GetRandomSkinColor(rnd);
            }
        }