public int getTemplateIdFromIndex(int index, Asda2GuildWaveItemRecord record) { switch (index) { case 0: return(record.Item1); case 1: return(record.Item2); case 2: return(record.Item3); case 3: return(record.Item4); case 4: return(record.Item5); case 5: return(record.Item6); case 6: return(record.Item7); case 7: return(record.Item8); } return(record.Item1); }
public void GuildWaveResultAndItems(Character chr) { if (chr.IsDead) { chr.Resurrect(); } Asda2TitleChecker.OnGuildWaveEnd(chr, LastWinnedWave); Asda2GuildWaveItemRecord waveItem = null; foreach (Asda2GuildWaveItemRecord record in Asda2ItemMgr.GuildWaveRewardRecords) { if (record.Wave == LastWinnedWave + 1 && record.Lvl == (int)Math.Ceiling(chr.Level / 10.0F) * 10 && record.Difficulty == _difficulty) { waveItem = record; break; } } if (waveItem != null) { List <KeyValuePair <int, int> > pairs = new List <KeyValuePair <int, int> >(); pairs.Add(new KeyValuePair <int, int>(1, waveItem.Chance1)); pairs.Add(new KeyValuePair <int, int>(2, waveItem.Chance2)); pairs.Add(new KeyValuePair <int, int>(3, waveItem.Chance3)); pairs.Add(new KeyValuePair <int, int>(4, waveItem.Chance4)); pairs.Add(new KeyValuePair <int, int>(5, waveItem.Chance5)); pairs.Add(new KeyValuePair <int, int>(6, waveItem.Chance6)); pairs.Add(new KeyValuePair <int, int>(7, waveItem.Chance7)); pairs.Add(new KeyValuePair <int, int>(8, waveItem.Chance8)); pairs.Sort((a, b) => a.Value.CompareTo(b.Value)); int templateId1 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); int templateId2 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); int templateId3 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); Asda2Item item1 = Asda2Item.CreateItem(templateId1, chr, 1); Asda2Item wavecoin = null; int amount = getAverageLevel() / CharacterFormulas.WaveCoinsDivider; if (amount > 0) { wavecoin = Asda2Item.CreateItem(33712, chr, amount); chr.Asda2Inventory.TryAdd(33712, amount, true, ref wavecoin); } chr.Asda2Inventory.TryAdd(templateId1, 1, true, ref item1); if (_difficulty > 0) { Asda2Item item2 = Asda2Item.CreateItem(templateId2, chr, 1); chr.Asda2Inventory.TryAdd(templateId2, 1, true, ref item2); if (_difficulty == 2) { Asda2Item item3 = Asda2Item.CreateItem(templateId3, chr, 1); chr.Asda2Inventory.TryAdd(templateId3, 1, true, ref item3); } } Asda2GuildWaveHandler.GuildWaveResult(this, chr, wavecoin == null ? 0 : wavecoin.Amount, templateId1, templateId2, templateId3); } }