private string GenerateEnchantTooltip(EnchantRecipe recipe) { var sb = new StringBuilder(); var rarityColor = EpicLoot.GetRarityColor(SelectedRarity); var rarityDisplay = EpicLoot.GetRarityDisplayName(SelectedRarity); sb.AppendLine(); sb.AppendLine(); sb.AppendLine($"{recipe.FromItem.m_shared.m_name} \u2794 <color={rarityColor}>{rarityDisplay}</color> {recipe.FromItem.GetDecoratedName(rarityColor)}"); sb.AppendLine($"<color={rarityColor}>"); var effectCountWeights = LootRoller.GetEffectCountsPerRarity(SelectedRarity); float totalWeight = effectCountWeights.Sum(x => x.Value); foreach (var effectCountEntry in effectCountWeights) { var count = effectCountEntry.Key; var weight = effectCountEntry.Value; var percent = (int)(weight / totalWeight * 100.0f); var label = count == 1 ? $"{count} $mod_epicloot_enchant_effect" : $"{count} $mod_epicloot_enchant_effects"; sb.AppendLine($" ‣ {label} {percent}%"); } sb.Append("</color>"); return(sb.ToString()); }
private static string GetAugmentSelectorText(MagicItem magicItem, int i, IReadOnlyList <MagicItemEffect> augmentableEffects, ItemRarity rarity) { var pip = EpicLoot.GetMagicEffectPip(magicItem.IsEffectAugmented(i)); bool free = EnchantCostsHelper.EffectIsDeprecated(augmentableEffects[i].EffectType); return($"{pip} {Localization.instance.Localize(MagicItem.GetEffectText(augmentableEffects[i], rarity, true))}{(free ? " [FREE]" : "")}"); }
protected virtual void ActivateStatusEffectAction() { if (AbilityDef.Action != AbilityAction.StatusEffect) { EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) that was not marked as Action=StatusEffect!"); return; } var statusEffectName = AbilityDef.ActionParams.FirstOrDefault(); if (string.IsNullOrEmpty(statusEffectName)) { EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) but the status effect name param was missing!"); return; } var statusEffect = EpicLoot.LoadAsset <StatusEffect>(statusEffectName); if (statusEffect == null) { EpicLoot.LogError($"Tried to activate a status effect ability ({AbilityDef.ID}) but the status effect asset could not be found ({statusEffectName})!"); return; } _player.GetSEMan().AddStatusEffect(statusEffect); }
public static void Postfix(InventoryGui __instance, Player player, Recipe recipe, ItemDrop.ItemData item, bool canCraft) { var selectedCraftingItem = __instance.InCraftTab() && recipe.m_item != null; var selectedUpgradeItem = __instance.InUpradeTab() && item != null; if (selectedCraftingItem || selectedUpgradeItem) { var thisItem = selectedCraftingItem ? recipe.m_item.m_itemData : item; if (thisItem.UseMagicBackground()) { var element = __instance.m_recipeList.LastOrDefault(); if (element != null) { var image = element.transform.Find("icon").GetComponent <Image>(); var bgImage = Object.Instantiate(image, image.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = thisItem.GetRarityColor(); if (!canCraft) { bgImage.color -= new Color(0, 0, 0, 0.66f); } var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.color = canCraft ? thisItem.GetRarityColor() : new Color(0.66f, 0.66f, 0.66f, 1f); } } } }
public static void Postfix(Transform elementRoot, Piece.Requirement req, Player player, bool craft, int quality) { var instance = InventoryGui.instance; if ((instance.InCraftTab() || instance.InUpradeTab()) && req?.m_resItem != null) { var item = req.m_resItem; var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var bgIconTransform = elementRoot.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, elementRoot, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } } }
public void Load() { if (_player.m_knownTexts.TryGetValue(SaveDataKey, out var data)) { try { SaveData = JSON.ToObject <AdventureSaveDataList>(data, _saveLoadParams); // Clean up old bounties var removed = 0; foreach (var saveData in SaveData.AllSaveData) { removed += saveData.Bounties.RemoveAll(x => x.State == BountyState.InProgress && x.PlayerID == 0); } if (removed > 0) { EpicLoot.LogWarning($"Removed {removed} invalid bounties"); Save(); } } catch (Exception) { SaveData = new AdventureSaveDataList(); } } else { SaveData = new AdventureSaveDataList(); } }
public bool PurchasedTreasureMap(int interval, Heightmap.Biome biome, Vector3 position, Vector3 circleOffset) { if (!DebugMode) { if (HasPurchasedTreasureMap(interval, biome)) { EpicLoot.LogError($"Player has already purchased treasure map! (interval={interval} biome={biome})"); return(false); } } else if (IntervalOverride != 0) { interval = IntervalOverride; } TreasureMaps.Add(new TreasureMapChestInfo() { Interval = interval, Biome = biome, State = TreasureMapState.Purchased, Position = position, MinimapCircleOffset = circleOffset, }); NumberOfTreasureMapsOrBountiesStarted++; return(true); }
public static bool Prefix(Attack __instance) { if (__instance.m_character.IsPlayer() && __instance.m_weapon != null) { var player = (Player)__instance.m_character; var weaponDamage = __instance.GetWeapon()?.GetDamage(); if (player.HasActiveMagicEffect(MagicEffectType.FrostDamageAOE) && weaponDamage.HasValue && weaponDamage.Value.m_frost > 0) { Modified = true; __instance.m_triggerEffect.m_effectPrefabs = __instance.m_triggerEffect.m_effectPrefabs.AddItem(new EffectList.EffectData { m_prefab = EpicLoot.LoadAsset <GameObject>(FxPrefabName), m_enabled = true }).ToArray(); var colliderPrefab = EpicLoot.LoadAsset <GameObject>("IceSpikesCollider"); var transform = player.transform; var attackOrigin = __instance.GetAttackOrigin(); var effectPosition = attackOrigin.position + Vector3.up * __instance.m_attackHeight + transform.forward * __instance.m_attackRange + transform.right * __instance.m_attackOffset; var collider = Object.Instantiate(colliderPrefab, effectPosition, transform.rotation, attackOrigin); var damageController = collider.AddComponent <FrostAOEDamageController>(); var damage = __instance.m_weapon.GetDamage(); damage.Modify(__instance.m_damageMultiplier); damage.Modify(player.GetRandomSkillFactor(__instance.m_weapon.m_shared.m_skillType)); damage.Modify(__instance.GetLevelDamageFactor()); damageController.SetDamage(damage, player); } } return(true); }
public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player) { var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); amountText.color = Color.white; } return(true); }
public void RPC_SlayBountyTarget(long sender, ZPackage pkg, string monsterID, bool isAdd) { var isServer = Common.Utils.IsServer(); if (isServer) { EpicLoot.LogWarning($"SERVER: RPC_SlayBountyTarget: {monsterID} ({(isAdd ? "minion" : "target")})"); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SlayBountyTargetFromServer", pkg, monsterID, isAdd); } else { EpicLoot.LogWarning($"CLIENT: RPC_SlayBountyTarget: {monsterID} ({(isAdd ? "minion" : "target")})"); } var bounty = BountyInfo.FromPackage(pkg); if (isServer) { AddSlainBountyTargetToLedger(bounty, monsterID, isAdd); } if (Player.m_localPlayer == null || bounty.PlayerID != Player.m_localPlayer.GetPlayerID()) { // Not my bounty return; } OnBountyTargetSlain(bounty.ID, monsterID, isAdd); }
public static List <KeyValuePair <ItemDrop, int> > GetDisenchantProducts(ItemDrop.ItemData item) { var productsDef = EnchantCostsHelper.GetDisenchantProducts(item); if (productsDef == null) { return(null); } var products = new List <KeyValuePair <ItemDrop, int> >(); foreach (var itemAmountConfig in productsDef) { var prefab = ObjectDB.instance.GetItemPrefab(itemAmountConfig.Item); if (prefab == null) { EpicLoot.LogWarning($"Tried to add unknown item ({itemAmountConfig.Item}) to disenchant product for item ({item.m_shared.m_name})"); continue; } var itemDrop = prefab.GetComponent <ItemDrop>(); if (itemDrop == null) { EpicLoot.LogWarning($"Tried to add object with no ItemDrop ({itemAmountConfig.Item}) to disenchant product for item ({item.m_shared.m_name})"); continue; } products.Add(new KeyValuePair <ItemDrop, int>(itemDrop, itemAmountConfig.Amount)); } return(products); }
public void Setup(Player player, Heightmap.Biome biome, int treasureMapInterval) { Reinitialize(biome, treasureMapInterval, false, player.GetPlayerID()); var container = GetComponent <Container>(); var zdo = container?.m_nview.GetZDO(); if (container != null && zdo != null && zdo.IsValid()) { container.GetInventory().RemoveAll(); zdo.Set("TreasureMapChest.Interval", Interval); zdo.Set("TreasureMapChest.Biome", Biome.ToString()); zdo.Set("creator", player.GetPlayerID()); var items = LootRoller.RollLootTable(LootTableName, 1, LootTableName, transform.position); items.ForEach(item => container.m_inventory.AddItem(item)); var biomeConfig = AdventureDataManager.Config.TreasureMap.BiomeInfo.Find(x => x.Biome == biome); if (biomeConfig?.ForestTokens > 0) { container.m_inventory.AddItem("ForestToken", biomeConfig.ForestTokens, 1, 0, 0, ""); } container.Save(); } else { EpicLoot.LogError($"Trying to set up TreasureMapChest ({biome} {treasureMapInterval}) but there was no Container component!"); } }
public static void Postfix(InventoryGui __instance, Player player, float dt) { var activeTab = GetActiveTabController(); if (activeTab != null) { var icon = EpicLoot.HasAuga ? Auga.API.RequirementsPanel_GetIcon(activeTab.AugaTabData.RequirementsPanelGO) : __instance.m_recipeIcon; var magicItemBG = icon.transform.parent.Find("MagicItemBG"); Image bgImage; if (magicItemBG == null) { bgImage = Object.Instantiate(icon, icon.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(icon.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = Color.white; bgImage.rectTransform.anchorMin = new Vector2(0, 0); bgImage.rectTransform.anchorMax = new Vector2(1, 1); bgImage.rectTransform.sizeDelta = new Vector2(0, 0); bgImage.rectTransform.anchoredPosition = new Vector2(0, 0); } else { bgImage = magicItemBG.GetComponent <Image>(); } activeTab.UpdateRecipe(__instance, player, dt, bgImage); } }
protected static List <SecretStashItemInfo> CollectItems( List <SecretStashItemConfig> itemList, Func <SecretStashItemConfig, string> itemIdPredicate, Func <ItemDrop.ItemData, bool> itemOkayToAddPredicate) { var results = new List <SecretStashItemInfo>(); foreach (var itemConfig in itemList) { var itemId = itemIdPredicate(itemConfig); var itemDrop = CreateItemDrop(itemId); if (itemDrop == null) { EpicLoot.LogWarning($"[AdventureData] Could not find item type (gated={itemId} orig={itemConfig}) in ObjectDB!"); continue; } var itemData = itemDrop.m_itemData; if (itemOkayToAddPredicate(itemData)) { results.Add(new SecretStashItemInfo(itemId, itemData, itemConfig.GetCost())); } Object.Destroy(itemDrop.gameObject); } return(results); }
private List <SecretStashItemInfo> GetAvailableGambles() { var availableGambles = new List <SecretStashItemInfo>(); foreach (var itemConfig in AdventureDataManager.Config.Gamble.Gambles) { var gatingMode = EpicLoot.GetGatedItemTypeMode(); if (gatingMode == GatedItemTypeMode.Unlimited) { gatingMode = GatedItemTypeMode.MustKnowRecipe; } var itemId = GatedItemTypeHelper.GetGatedItemID(itemConfig, gatingMode); var itemDrop = CreateItemDrop(itemId); if (itemDrop == null) { EpicLoot.LogWarning($"[AdventureData] Could not find item type (gated={itemId} orig={itemConfig}) in ObjectDB!"); continue; } var itemData = itemDrop.m_itemData; var cost = GetGambleCost(itemId); availableGambles.Add(new SecretStashItemInfo(itemId, itemData, cost, true)); Object.Destroy(itemDrop.gameObject); } return(availableGambles); }
public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage) { if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count) { var recipe = Recipes[SelectedRecipe]; var itemData = recipe.FromItem; var rarityColor = EpicLoot.GetRarityColor(recipe.ToRarity); var rarityColorARGB = EpicLoot.GetRarityColorARGB(recipe.ToRarity); __instance.m_recipeIcon.enabled = true; __instance.m_recipeIcon.sprite = itemData.GetIcon(); __instance.m_recipeName.enabled = true; __instance.m_recipeName.text = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor)); __instance.m_recipeDecription.enabled = true; __instance.m_recipeDecription.text = Localization.instance.Localize(GenerateEnchantTooltip(recipe)); bgImage.color = rarityColorARGB; bgImage.enabled = true; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); SetupRequirementList(__instance, player, recipe); __instance.m_minStationLevelIcon.gameObject.SetActive(false); var canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1); __instance.m_craftButton.interactable = canCraft; __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant"; __instance.m_craftButton.GetComponent <UITooltip>().m_text = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement"); } }
public static List <KeyValuePair <ItemDrop, int> > GetAugmentCosts(ItemDrop.ItemData item) { var rarity = item.GetRarity(); var augmentCostDef = EnchantCostsHelper.GetAugmentCost(item, rarity); if (augmentCostDef == null) { return(null); } var costList = new List <KeyValuePair <ItemDrop, int> >(); foreach (var itemAmountConfig in augmentCostDef) { var prefab = ObjectDB.instance.GetItemPrefab(itemAmountConfig.Item); if (prefab == null) { EpicLoot.LogWarning($"Tried to add unknown item ({itemAmountConfig.Item}) to augment cost for item ({item.m_shared.m_name})"); continue; } var itemDrop = prefab.GetComponent <ItemDrop>(); if (itemDrop == null) { EpicLoot.LogWarning($"Tried to add item without ItemDrop ({itemAmountConfig.Item}) to augment cost for item ({item.m_shared.m_name})"); continue; } costList.Add(new KeyValuePair <ItemDrop, int>(itemDrop, itemAmountConfig.Amount)); } return(costList); }
private void AddSlainBountyTargetToLedger(BountyInfo bounty, string monsterID, bool isAdd) { if (!Common.Utils.IsServer()) { return; } if (BountyLedger == null) { EpicLoot.LogError("[BountyLedger] Server tried to add kill log to bounty ledger but BountyLedger was null"); return; } if (Player.m_localPlayer != null && Player.m_localPlayer.GetPlayerID() == bounty.PlayerID) { EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is the local player"); return; } var characterZdos = ZNet.instance.GetAllCharacterZDOS(); var playerIsOnline = characterZdos.Select(zdo => zdo.GetLong("playerID")).Any(playerID => playerID == bounty.PlayerID); if (playerIsOnline) { EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is connected to server, don't log the kill, they'll get the RPC"); return; } BountyLedger.AddKillLog(bounty.PlayerID, bounty.ID, monsterID, isAdd); SaveBountyLedger(); }
public static void CheckAndDoLifeSteal(HitData hit) { try { if (!hit.HaveAttacker()) { return; } var attacker = hit.GetAttacker() as Humanoid; if (attacker == null) { return; } // TODO track actual weapon which made a hit for better life-steal calculation var weapon = attacker.GetCurrentWeapon(); // in case weapon's durability is destroyed after hit? // OR in case damage is delayed and player hides weapon - see to-do above if (weapon == null || !weapon.IsMagic() || !(attacker is Player player)) { return; } var lifeStealMultiplier = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.LifeSteal, effect => lifeStealMultiplier += player.GetTotalActiveMagicEffectValue(effect, 0.01f)); if (lifeStealMultiplier == 0) { return; } var healOn = hit.m_damage.GetTotalDamage() * lifeStealMultiplier; EpicLoot.Log("lifesteal " + healOn); var healFromQueue = false; if (attacker.IsPlayer()) { var healingQueue = attacker.GetComponent <HealingQueueMono>(); if (healingQueue) { healFromQueue = true; healingQueue.HealRequests.Add(healOn); } } if (!healFromQueue) { // mostly for NPC with lifeSteal weapon attacker.Heal(healOn); } } catch (Exception e) { EpicLoot.LogError(e.Message); } }
public static bool Prefix(ItemDrop.ItemData item) { if (item.IsMagicCraftingMaterial()) { var variant = EpicLoot.GetRarityIconIndex(item.GetCraftingMaterialRarity()); item.m_variant = variant; } return(true); }
public static void Initialize(RecipesConfig config) { Config = config; if (EpicLoot.IsObjectDBReady()) { SetupRecipes(); } }
private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item) { if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item)) { var recipe = new EnchantRecipe { FromItem = item.Extended() }; Recipes.Add(recipe); } }
public static void RPC_AddKnownRecipe(long sender, string recipe) { if (!PlayerKnownRecipes.TryGetValue(sender, out var knownRecipes)) { EpicLoot.LogWarning($"PlayerKnownManager.RPC_AddKnownRecipe: hashset is null for peer {sender}"); return; } knownRecipes.Add(recipe); EpicLoot.Log($"Received add known recipe from peer {sender}: {recipe}"); }
private void OnDeath() { EpicLoot.LogWarning("BountyTarget.OnDeath"); var pkg = new ZPackage(); _bountyInfo.ToPackage(pkg); EpicLoot.LogWarning($"SENDING -> RPC_SlayBountyTarget: {_monsterID} ({(_isAdd ? "minion" : "target")})"); ZRoutedRpc.instance.InvokeRoutedRPC("SlayBountyTarget", pkg, _monsterID, _isAdd); }
public static void RPC_AddKnownMaterial(long sender, string material) { if (!PlayerKnownMaterial.TryGetValue(sender, out var knownMaterial)) { EpicLoot.LogWarning($"PlayerKnownManager.RPC_AddKnownMaterial: hashset is null for peer {sender}"); return; } knownMaterial.Add(material); EpicLoot.Log($"Received add known material from peer {sender}: {material}"); }
public static string GetGatedItemID(string itemID, GatedItemTypeMode mode) { if (string.IsNullOrEmpty(itemID)) { EpicLoot.LogError($"Tried to get gated itemID with null or empty itemID!"); return(null); } if (mode == GatedItemTypeMode.Unlimited) { return(itemID); } if (!EpicLoot.IsObjectDBReady()) { EpicLoot.LogError($"Tried to get gated itemID ({itemID}) but ObjectDB is not initialized!"); return(null); } if (!ItemInfoByID.TryGetValue(itemID, out var info)) { return(itemID); } var itemName = GetItemName(itemID); if (string.IsNullOrEmpty(itemName)) { return(null); } while (CheckIfItemNeedsGate(mode, itemName)) { //EpicLoot.Log("Yes..."); var index = info.Items.IndexOf(itemID); if (index < 0) { // Items list is empty, no need to gate any items from of this type return(itemID); } if (index == 0) { //EpicLoot.Log($"Reached end of gated list. Fallback is ({info.Fallback}), returning ({(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback)}){(string.IsNullOrEmpty(info.Fallback) ? "" : " (fallback)")}"); return(string.IsNullOrEmpty(info.Fallback) ? itemID : info.Fallback); } itemID = info.Items[index - 1]; itemName = GetItemName(itemID); //EpicLoot.Log($"Next lower tier item is ({itemID})"); } //EpicLoot.Log($"No, return ({itemID})"); return(itemID); }
public void SetItem(SecretStashItemInfo itemInfo, Currencies currencies) { ItemInfo = itemInfo; var canAfford = CanAfford(currencies); Icon.sprite = ItemInfo.Item.GetIcon(); Icon.color = canAfford ? Color.white : new Color(1.0f, 0.0f, 1.0f, 0.0f); NameText.text = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName(canAfford ? null : "grey")); CoinsCostText.text = ItemInfo.Cost.Coins.ToString(); CoinsCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.Coins > 0); ForestTokenCostText.text = ItemInfo.Cost.ForestTokens.ToString(); ForestTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.ForestTokens > 0); IronBountyTokenCostText.text = ItemInfo.Cost.IronBountyTokens.ToString(); IronBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.IronBountyTokens > 0); GoldBountyTokenCostText.text = ItemInfo.Cost.GoldBountyTokens.ToString(); GoldBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.GoldBountyTokens > 0); if (!canAfford) { CoinsCostText.color = Color.grey; ForestTokenCostText.color = Color.grey; IronBountyTokenCostText.color = Color.grey; GoldBountyTokenCostText.color = Color.grey; } MagicBG.enabled = itemInfo.GuaranteedRarity || ItemInfo.Item.UseMagicBackground(); if (canAfford) { MagicBG.color = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColorARGB(itemInfo.Rarity) : ItemInfo.Item.GetRarityColor(); } else { MagicBG.color = new Color(1.0f, 0.0f, 1.0f, 0.0f); } Button.onClick.RemoveAllListeners(); Button.onClick.AddListener(() => OnSelected?.Invoke(ItemInfo)); Tooltip.m_topic = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName()); Tooltip.m_text = Localization.instance.Localize(ItemInfo.Item.GetTooltip()); if (ItemInfo.IsGamble) { var color = canAfford ? (itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColor(itemInfo.Rarity) : "white") : "grey"; var rarityDisplay = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityDisplayName(itemInfo.Rarity) : "$mod_epicloot_merchant_unknown"; NameText.text = Localization.instance.Localize($"<color={color}>{rarityDisplay} {ItemInfo.Item.m_shared.m_name}</color>"); Tooltip.m_topic = NameText.text; Tooltip.m_text = GetGambleTooltip(); } }
public static void Postfix(Inventory __instance) { foreach (var item in __instance.m_inventory) { if (item.IsMagicCraftingMaterial()) { var rarity = item.GetCraftingMaterialRarity(); var variant = EpicLoot.GetRarityIconIndex(rarity); item.m_variant = variant; } } }
public void BuyItem(Player player, BuyListElement listItem) { ItemDrop.ItemData item; if (listItem.ItemInfo.IsGamble) { item = AdventureDataManager.Gamble.GenerateGambleItem(listItem.ItemInfo); } else { var itemDrop = AdventureFeature.CreateItemDrop(listItem.ItemInfo.ItemID); item = itemDrop.m_itemData; Destroy(itemDrop.gameObject); } var inventory = player.GetInventory(); if (item == null || !inventory.AddItem(item)) { EpicLoot.LogWarning($"Could not buy item {listItem.ItemInfo.Item.m_shared.m_name}"); return; } if (listItem.ItemInfo.IsGamble) { GambleSuccessDialog.Show(item); } if (listItem.ItemInfo.Cost.Coins > 0) { inventory.RemoveItem(GetCoinsName(), listItem.ItemInfo.Cost.Coins); } if (listItem.ItemInfo.Cost.ForestTokens > 0) { inventory.RemoveItem(GetForestTokenName(), listItem.ItemInfo.Cost.ForestTokens); } if (listItem.ItemInfo.Cost.IronBountyTokens > 0) { inventory.RemoveItem(GetIronBountyTokenName(), listItem.ItemInfo.Cost.IronBountyTokens); } if (listItem.ItemInfo.Cost.GoldBountyTokens > 0) { inventory.RemoveItem(GetGoldBountyTokenName(), listItem.ItemInfo.Cost.GoldBountyTokens); } StoreGui.instance.m_trader.OnBought(null); StoreGui.instance.m_buyEffects.Create(player.transform.position, Quaternion.identity); Player.m_localPlayer.ShowPickupMessage(listItem.ItemInfo.Item, listItem.ItemInfo.Item.m_stack); //Gogan.LogEvent("Game", "BoughtItem", selectedStashItem.Item, 0L); }
private static void OnBountyTargetSlain(string bountyID, string monsterID, bool isAdd) { var player = Player.m_localPlayer; if (player == null) { return; } var saveData = player.GetAdventureSaveData(); var bountyInfo = saveData.GetBountyInfoByID(bountyID); if (bountyInfo == null || bountyInfo.PlayerID != player.GetPlayerID()) { // Someone else's bounty return; } if (!saveData.HasAcceptedBounty(bountyInfo.Interval, bountyInfo.ID) || bountyInfo.State != BountyState.InProgress) { return; } EpicLoot.Log($"Bounty Target Slain: bounty={bountyInfo.ID} monsterId={monsterID} ({(isAdd ? "add" : "main target")})"); if (!isAdd && bountyInfo.Target.MonsterID == monsterID) { bountyInfo.Slain = true; player.SaveAdventureSaveData(); } if (isAdd) { foreach (var addConfig in bountyInfo.Adds) { if (addConfig.MonsterID == monsterID && addConfig.Count > 0) { addConfig.Count--; player.SaveAdventureSaveData(); break; } } } var isComplete = bountyInfo.Slain && bountyInfo.Adds.Sum(x => x.Count) == 0; if (isComplete) { MessageHud.instance.ShowBiomeFoundMsg("$mod_epicloot_bounties_completemsg", true); bountyInfo.State = BountyState.Complete; player.SaveAdventureSaveData(); } }