private Item GetItemDrop(MonsterDefinition monster, DropItemGroup selectedGroup) { if (selectedGroup != null) { if (selectedGroup.PossibleItems?.Count > 0) { var item = new TemporaryItem(); item.Definition = selectedGroup.PossibleItems.SelectRandom(this.randomizer); this.ApplyRandomOptions(item); return(item); } switch (selectedGroup.ItemType) { case SpecialItemType.Ancient: return(this.GetRandomAncient()); case SpecialItemType.Excellent: return(this.GetRandomExcellentItem((int)monster[Stats.Level])); case SpecialItemType.RandomItem: return(this.GetRandomItem((int)monster[Stats.Level], false)); case SpecialItemType.SocketItem: return(this.GetRandomItem((int)monster[Stats.Level], true)); default: // none return(null); } } return(null); }
/// <summary> /// Gets a random excellent item. /// </summary> /// <param name="monsterLvl">The monster level.</param> /// <returns>A random excellent item.</returns> protected Item GetRandomExcellentItem(int monsterLvl) { if (monsterLvl < 25) { return(null); } var possible = this.GetPossibleList(monsterLvl - 25); if (possible == null || !possible.Any()) { return(null); } var itemDef = possible.SelectRandom(this.randomizer); var item = new TemporaryItem(); item.Definition = itemDef; this.ApplyRandomOptions(item); if (itemDef.Skill != null && item.Definition.QualifiedCharacters.Any()) { item.HasSkill = true; // every excellent item got skill } this.AddRandomExcOptions(item); return(item); }
private static void AssignTo(this QuestItemRequirement itemRequirement, QuestCondition condition, RemotePlayer player) { condition.Type = ConditionType.Item; condition.RequiredCount = (uint)itemRequirement.MinimumNumber; condition.CurrentCount = (uint)player.Inventory.Items.Count(item => item.Definition == itemRequirement.Item); condition.RequirementId = itemRequirement.Item.GetItemType(); var temporaryItem = new TemporaryItem(); temporaryItem.Definition = itemRequirement.Item; temporaryItem.Durability = temporaryItem.GetMaximumDurabilityOfOnePiece(); player.ItemSerializer.SerializeItem(condition.RequiredItemData, temporaryItem); }
private static void AddAncientBonusOption(TemporaryItem item, ItemChatCommandArgs arguments) { if (item.Definition != null && arguments.Ancient > default(byte) && item.Definition.PossibleItemSetGroups.FirstOrDefault(set => set.AncientSetDiscriminator == arguments.Ancient) is { } ancientSet && ancientSet.Items.FirstOrDefault(i => i.ItemDefinition == item.Definition) is { } itemOfItemSet) { var optionLink = new ItemOptionLink { ItemOption = itemOfItemSet.BonusOption, Level = arguments.AncientBonusLevel }; item.ItemOptions.Add(optionLink); item.ItemSetGroups.Add(ancientSet); } }
private static void AddLuckOption(TemporaryItem item, ItemChatCommandArgs arguments) { if (item.Definition != null && arguments.Luck) { var optionLink = new ItemOptionLink { ItemOption = item.Definition.PossibleItemOptions .SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Luck), }; item.ItemOptions.Add(optionLink); } }
private static void AddOption(TemporaryItem item, ItemChatCommandArgs arguments) { if (item.Definition != null && arguments.Opt > default(byte)) { var itemOption = item.Definition.PossibleItemOptions .SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Option); var level = arguments.Opt; var optionLink = new ItemOptionLink { ItemOption = itemOption, Level = level }; item.ItemOptions.Add(optionLink); } }
private static Item CreateItem(Player gameMaster, ItemChatCommandArgs arguments) { var item = new TemporaryItem(); item.Definition = GetItemDefination(gameMaster, arguments); item.Durability = item.Definition.Durability; item.HasSkill = item.Definition.Skill != null && arguments.Skill; item.Level = GetItemLevel(item.Definition, arguments); item.SocketCount = item.Definition.MaximumSockets; AddOption(item, arguments); AddLuckOption(item, arguments); AddExcellentOptions(item, arguments); AddAncientBonusOption(item, arguments); return(item); }
/// <summary> /// Gets a random item. /// </summary> /// <param name="monsterLvl">The monster level.</param> /// <param name="socketItems">if set to <c>true</c> [socket items].</param> /// <returns>A random item.</returns> protected Item GetRandomItem(int monsterLvl, bool socketItems) { var possible = this.GetPossibleList(monsterLvl); if (possible == null || !possible.Any()) { return(null); } var itemDef = possible.ElementAt(this.randomizer.NextInt(0, possible.Count)); var item = new TemporaryItem(); item.Definition = itemDef; item.Level = (byte)((monsterLvl - itemDef.DropLevel) / 3); this.ApplyRandomOptions(item); return(item); }
private static void AddExcellentOptions(TemporaryItem item, ItemChatCommandArgs arguments) { if (item.Definition != null && arguments.ExcellentNumber > default(byte)) { var excellentOptions = item.Definition.PossibleItemOptions .SelectMany(o => o.PossibleOptions) .Where(o => o.OptionType == ItemOptionTypes.Excellent) .Where(o => (o.Number & arguments.ExcellentNumber) > default(byte)) .ToList(); ushort appliedOptions = default; foreach (var excellentOption in excellentOptions) { var optionLink = new ItemOptionLink { ItemOption = excellentOption }; item.ItemOptions.Add(optionLink); appliedOptions++; } // every excellent item has skill (if is in item definition) item.HasSkill = appliedOptions > default(ushort) && item.Definition.Skill != null; } }
/// <summary> /// Gets a random ancient item. /// </summary> /// <returns>A random ancient item.</returns> protected Item GetRandomAncient() { Item item = new TemporaryItem(); item.Definition = this.ancientItems.SelectRandom(this.randomizer); this.ApplyRandomOptions(item); var itemDef = item.Definition; if (itemDef.Skill != null && item.Definition.QualifiedCharacters.Any()) { item.HasSkill = true; } var ancientSet = item.ItemSetGroups.Where(g => g.Options.Any(o => o.OptionType == ItemOptionTypes.AncientOption)).SelectRandom(this.randomizer); item.ItemSetGroups.Add(ancientSet); var bonusOption = ancientSet.Items.First(i => i.ItemDefinition == item.Definition).BonusOption; // for example: +5str or +10str var bonusOptionLink = new ItemOptionLink(); bonusOptionLink.ItemOption = bonusOption; bonusOptionLink.Level = bonusOption.LevelDependentOptions.Select(o => o.Level).SelectRandom(); item.ItemOptions.Add(bonusOptionLink); return(item); }
private static Item CreateItem(Player player, Arguments arguments) { var item = new TemporaryItem(); var itemDefinition = player.GameContext.Configuration.Items.FirstOrDefault(def => def.Group == arguments.Group && def.Number == arguments.Number); if (itemDefinition == null) { throw new ArgumentException($"[GM][/item] {arguments.Group} {arguments.Number} does not exists"); } item.Definition = itemDefinition; item.Level = arguments.Level; item.Durability = itemDefinition.Durability; item.HasSkill = itemDefinition.Skill != null && arguments.Skill; if (arguments.Opt > 0) { var optionLink = new ItemOptionLink { ItemOption = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Option), Level = arguments.Opt, }; item.ItemOptions.Add(optionLink); } if (arguments.Luck) { var optionLink = new ItemOptionLink { ItemOption = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Luck), }; item.ItemOptions.Add(optionLink); } if (arguments.Exc > 0) { var excellentOptions = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .Where(o => o.OptionType == ItemOptionTypes.Excellent) .Where(o => (o.Number & arguments.Exc) > 0); var appliedOptions = 0; excellentOptions.ForEach(option => { var optionLink = new ItemOptionLink { ItemOption = option, }; item.ItemOptions.Add(optionLink); appliedOptions++; }); // every excellent item has skill (if is in item definition) if (appliedOptions > 0 && itemDefinition.Skill != null) { item.HasSkill = true; } } return(item); }
private static Item CreateItem(Player player, Arguments arguments) { var item = new TemporaryItem(); var itemDefinition = player.GameContext.Configuration.Items.FirstOrDefault(def => def.Group == arguments.Group && def.Number == arguments.Number); if (itemDefinition is null) { throw new ArgumentException($"[GM][/item] {arguments.Group} {arguments.Number} does not exist."); } if (arguments.Level > itemDefinition.MaximumItemLevel) { throw new ArgumentException($"[GM][/item] Level cannot be greater than {itemDefinition.MaximumItemLevel}."); } item.Definition = itemDefinition; item.Level = arguments.Level; item.Durability = itemDefinition.Durability; item.HasSkill = itemDefinition.Skill != null && arguments.Skill; if (arguments.Opt > 0) { var optionLink = new ItemOptionLink { ItemOption = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Option), Level = arguments.Opt, }; item.ItemOptions.Add(optionLink); } if (arguments.Luck) { var optionLink = new ItemOptionLink { ItemOption = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Luck), }; item.ItemOptions.Add(optionLink); } if (arguments.Exc > 0) { var excellentOptions = item.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .Where(o => o.OptionType == ItemOptionTypes.Excellent) .Where(o => (o.Number & arguments.Exc) > 0); var appliedOptions = 0; excellentOptions.ForEach(option => { var optionLink = new ItemOptionLink { ItemOption = option, }; item.ItemOptions.Add(optionLink); appliedOptions++; }); // every excellent item has skill (if is in item definition) if (appliedOptions > 0 && itemDefinition.Skill != null) { item.HasSkill = true; } } if (arguments.Ancient > 0 && item.Definition.PossibleItemSetGroups.FirstOrDefault(set => set.AncientSetDiscriminator == arguments.Ancient) is { } ancientSet && ancientSet.Items.FirstOrDefault(i => i.ItemDefinition == item.Definition) is { } itemOfItemSet) { var optionLink = new ItemOptionLink { ItemOption = itemOfItemSet.BonusOption, Level = arguments.AncientBonusLevel, }; item.ItemOptions.Add(optionLink); item.ItemSetGroups.Add(ancientSet); } item.SocketCount = item.Definition.MaximumSockets; return(item); }