public void CompleteCraft() { if (RandomUtilities.IsLuck(LuckChance) && IsActive) //todo Craft chance { if (RandomUtilities.IsLuck(Recipe.CriticalChancePercent) && Recipe.CriticalChancePercent != 0) { SystemMessages.CraftedItem("@item:" + Recipe.CriticalResultItem.Key).Send(Player.Connection); Communication.Global.StorageService.AddItem(Player, Player.Inventory, Recipe.CriticalResultItem.Key, Recipe.CriticalResultItem.Value); } else { SystemMessages.CraftedItem("@item:" + Recipe.ResultItem.Key).Send(Player.Connection); Communication.Global.StorageService.AddItem(Player, Player.Inventory, Recipe.ResultItem.Key, Recipe.ResultItem.Value); } if (RandomUtilities.IsLuck(ProgressStatChance)) { Communication.Global.CraftLearnService.ProcessCraftStat(Player, Recipe.CraftStat); } new SpCraftProgress(100).Send(Player.Connection); new SpCharacterEmotions(Player, PlayerEmotion.CraftSuccess).Send(Player.Connection); } else { new SpCraftProgress(100).Send(Player.Connection); SystemMessages.FailedToCraftItem("@item:" + Recipe.ResultItem.Key).Send(Player.Connection); } }
protected void CompleteGather() { Gather.IsInProcess = false; byte chance = 0; bool isQuest = Gather.GatherTemplate().TypeName == TypeName.Quest; if (!isQuest) { switch (Gather.GatherTemplate().Grade) { case 1: chance = Player.PlayerCraftStats.GetGatherStat(Gather.GatherTemplate().TypeName) - Gather.GatherTemplate().NeededProficiency > 50 ? EasyProbUnder : EasyProbOver; break; case 2: chance = Player.PlayerCraftStats.GetGatherStat(Gather.GatherTemplate().TypeName) - Gather.GatherTemplate().NeededProficiency > 50 ? NormalProbUnder : NormalProbOver; break; case 3: chance = Player.PlayerCraftStats.GetGatherStat(Gather.GatherTemplate().TypeName) - Gather.GatherTemplate().NeededProficiency > 50 ? HardProbUnder : HardProbOver; break; } } else { chance = 100; } if (RandomUtilities.IsLuck(chance) && IsActive) { Global.VisibleService.Send(Player, new SpGatherEnd(Player, Gather, GatherEndCode.Normal)); if (!isQuest) { if (RandomUtilities.IsLuck(StatUpChance)) { Global.CraftLearnService.ProcessGatherStat(Player, Gather.GatherTemplate().TypeName); } int itemid = 1001; //todo gather datas and buffs #region CollectItemIdSwitch if (Gather.Id >= 7 && Gather.Id <= 12) { itemid = 1005; } else if (Gather.Id >= 13 && Gather.Id <= 21) { itemid = 1009; } else if (Gather.Id >= 22 && Gather.Id <= 30) { itemid = 1013; } else if (Gather.Id >= 31 && Gather.Id <= 48) { itemid = 1017; } else if (Gather.Id >= 101 && Gather.Id <= 106) { itemid = 1002; } else if (Gather.Id >= 107 && Gather.Id <= 112) { itemid = 1006; } else if (Gather.Id >= 113 && Gather.Id <= 121) { itemid = 1010; } else if (Gather.Id >= 122 && Gather.Id <= 130) { itemid = 1014; } else if (Gather.Id >= 131 && Gather.Id <= 148) { itemid = 1018; } else if (Gather.Id >= 301 && Gather.Id <= 306) { itemid = 1003; } else if (Gather.Id >= 307 && Gather.Id <= 312) { itemid = 1007; } else if (Gather.Id >= 313 && Gather.Id <= 321) { itemid = 1011; } else if (Gather.Id >= 322 && Gather.Id <= 330) { itemid = 1015; } else if (Gather.Id >= 331 && Gather.Id <= 348) { itemid = 1019; } #endregion Global.StorageService.AddItem(Player, Player.Inventory, itemid, 1); } else { //TODO: QuestEngine implementation } ((GatherAi)Gather.Ai).ProcessGather(); } else { Global.VisibleService.Send(Player, new SpGatherEnd(Player, Gather, GatherEndCode.Failed)); } }
public void CreateDrop(Npc npc, Player player) { if (RandomUtilities.IsLuck(75)) { var money = (int)(10 * Data.Data.NpcExperience[npc.GetLevel()] / RandomUtilities.Random().Next(20, 60)); player.Instance.AddDrop( new Item { Owner = player, Npc = npc, ItemId = 20000000, Count = money, Position = Geom.RandomCirclePosition(npc.Position, RandomUtilities.Random().Next(60, 100)), Instance = player.Instance, }); } if (!Data.Data.Drop.ContainsKey(npc.NpcTemplate.FullId)) { return; } List <int> items = Data.Data.Drop[npc.NpcTemplate.FullId]; if (items == null) { return; } int count = 0; int rate = RandomUtilities.Random().Next(0, 2500); if (rate < 10) { count = 6; } else if (rate < 30) { count = 5; } else if (rate < 90) { count = 4; } else if (rate < 270) { count = 3; } else if (rate < 600) { count = 2; } else if (rate < 1800) { count = 1; } if (items.Count < count) { count = items.Count; } for (int i = 0; i < count; i++) { int itemId = items[RandomUtilities.Random().Next(0, items.Count)]; if (!Data.Data.ItemTemplates.ContainsKey(itemId)) { continue; } player.Instance.AddDrop( new Item { Owner = player, Npc = npc, ItemId = itemId, Count = 1, Position = Geom.RandomCirclePosition(npc.Position, RandomUtilities.Random().Next(60, 100)), Instance = player.Instance, }); } }