public static void AddLootTable([NotNull] LootTable lootTable) { var key = lootTable.Object; if (string.IsNullOrEmpty(key)) { EpicLoot.LogError("Loot table missing Object name!"); return; } EpicLoot.Log($"Added LootTable: {key}"); if (!LootTables.ContainsKey(key)) { LootTables.Add(key, new List <LootTable>()); } var refKey = lootTable.RefObject; if (string.IsNullOrEmpty(refKey)) { LootTables[key].Add(lootTable); } else { if (!LootTables.ContainsKey(refKey)) { EpicLoot.LogError("Loot table missing RefObject name!"); return; } else { LootTables[key] = LootTables[refKey]; } } }
public static void AddDebugMagicEffects(MagicItem item) { if (!string.IsNullOrEmpty(ForcedMagicEffect) && !item.HasEffect(ForcedMagicEffect)) { EpicLoot.Log($"AddDebugMagicEffect {ForcedMagicEffect}"); item.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(ForcedMagicEffect), item.Rarity)); } }
public static void Add(MagicItemEffectDefinition effectDef) { if (AllDefinitions.ContainsKey(effectDef.Type)) { EpicLoot.LogWarning($"Removed previously existing magic effect type: {effectDef.Type}"); AllDefinitions.Remove(effectDef.Type); } EpicLoot.Log($"Added MagicItemEffect: {effectDef.Type}"); AllDefinitions.Add(effectDef.Type, effectDef); }
public static void AddLootTables([NotNull] IEnumerable <LootTable> lootTables) { // Add loottables for mobs or objects that do not reference another template foreach (var lootTable in lootTables.Where(x => x.RefObject == null || x.RefObject == "")) { AddLootTable(lootTable); EpicLoot.Log($"Added loottable for {lootTable.Object}"); } // Add loottables that are based off mob or object templates foreach (var lootTable in lootTables.Where(x => x.RefObject != null && x.RefObject != "")) { AddLootTable(lootTable); EpicLoot.Log($"Added loottable for {lootTable.Object} using {lootTable.RefObject} as reference"); } }
public static MagicItemEffect RollEffect(MagicItemEffectDefinition effectDef, ItemRarity itemRarity, MagicItemEffectDefinition.ValueDef valuesOverride = null) { float value = 0; var valuesDef = valuesOverride ?? effectDef.GetValuesForRarity(itemRarity); if (valuesDef != null) { value = valuesDef.MinValue; if (valuesDef.Increment != 0) { EpicLoot.Log($"RollEffect: {effectDef.Type} {itemRarity} value={value} (min={valuesDef.MinValue} max={valuesDef.MaxValue})"); var incrementCount = (int)((valuesDef.MaxValue - valuesDef.MinValue) / valuesDef.Increment); value = valuesDef.MinValue + (Random.Range(0, incrementCount + 1) * valuesDef.Increment); } } return(new MagicItemEffect(effectDef.Type, value)); }
private static void AddItemSets([NotNull] IEnumerable <LootItemSet> itemSets) { foreach (var itemSet in itemSets) { if (string.IsNullOrEmpty(itemSet.Name)) { EpicLoot.LogError($"Tried to add ItemSet with no name!"); continue; } if (!ItemSets.ContainsKey(itemSet.Name)) { EpicLoot.Log($"Added ItemSet: {itemSet.Name}"); ItemSets.Add(itemSet.Name, itemSet); } else { EpicLoot.LogError($"Tried to add ItemSet {itemSet.Name}, but it already exists!"); } } }
public static void Postfix(Container __instance) { if (__instance == null || __instance.m_piece == null) { return; } var containerName = __instance.m_piece.name.Replace("(Clone)", "").Trim(); var lootTables = LootRoller.GetLootTable(containerName); if (lootTables != null && lootTables.Count > 0) { var items = LootRoller.RollLootTable(lootTables, 1, __instance.m_piece.name, __instance.transform.position); EpicLoot.Log($"Rolling on loot table: {containerName}, spawned {items.Count} items at drop point({__instance.transform.position.ToString("0")})."); foreach (var item in items) { __instance.m_inventory.AddItem(item); EpicLoot.Log($" - {item.m_shared.m_name}" + (item.IsMagic() ? $": {string.Join(", ", item.GetMagicItem().Effects.Select(x => x.EffectType.ToString()))}" : "")); } } }
public static void Postfix(CharacterDrop __instance, ref List <KeyValuePair <GameObject, int> > __result) { if (__instance.m_character != null && __instance.m_character.IsBoss() && EpicLoot.GetBossTrophyDropMode() != BossDropMode.Default) { for (var index = 0; index < __result.Count; index++) { var entry = __result[index]; var prefab = entry.Key; var itemDrop = prefab.GetComponent <ItemDrop>(); if (itemDrop == null) { continue; } if (itemDrop.m_itemData?.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophie) { int dropCount; var playerList = ZNet.instance.GetPlayerList(); switch (EpicLoot.GetBossTrophyDropMode()) { case BossDropMode.OnePerPlayerOnServer: dropCount = playerList.Count; break; case BossDropMode.OnePerPlayerNearBoss: dropCount = Math.Max(Player.GetPlayersInRangeXZ(__instance.m_character.transform.position, EpicLoot.GetBossTrophyDropPlayerRange()), playerList.Count(x => Vector3.Distance(x.m_position, __instance.m_character.transform.position) <= EpicLoot.GetBossTrophyDropPlayerRange())); break; default: dropCount = 1; break; } EpicLoot.Log($"Dropping trophies: {dropCount} (mode={EpicLoot.GetBossTrophyDropMode()})"); __result[index] = new KeyValuePair <GameObject, int>(prefab, dropCount); } } } }