Forum begins after the advertisement:
[Part 27] Bug with Treasure Chest upgrading weapons at max level
Home › Forums › Video Game Tutorial Series › Creating a Rogue-like Shoot-em Up in Unity › [Part 27] Bug with Treasure Chest upgrading weapons at max level
- This topic has 5 replies, 3 voices, and was last updated 6 days, 20 hours ago by
Alp Apustaja.
-
AuthorPosts
-
August 19, 2025 at 5:05 pm #18712::
If everything (weapons and passives) is leveld to max. and you open a treasure chest, it will still show you new weapons. Of course you don’t get theses new weapons, because you have no space in your inventory left. Shouldn’t there just extra gold be generated in this case?
(The same applies to the level-up system; shouldn’t there only be gold or health left as bonuses after everything is upgraded?)
August 19, 2025 at 5:15 pm #18713::It sounds like you’re encountering an issue with how the game handles inventory and treasure chest rewards. If you have six max-level weapons and open a chest, it should ideally prioritize giving you passive items or upgrading them instead of showing you new weapons.
This kind of bug can be frustrating, but here are a few steps you can take:
-
Check for Updates: Make sure your game is updated to the latest version. Sometimes bugs are fixed in patches.
-
Report the Bug: If it’s a persistent issue, consider reporting it to the game’s support team or forum. Provide them with details, such as your inventory status and what happens when you open a treasure chest.
-
Clear Space: If possible, try to free up inventory space before opening chests. This way, you can at least receive some rewards.
-
Community Feedback: Look for discussions in community forums or social media groups related to the game. Other players might have similar experiences or potential workarounds.
-
Gameplay Strategy: If the game allows, sometimes using or selling weapons you don’t need can help manage inventory better.
If you have access to any modding tools or settings (depending on the game), check if there’s an option to tweak inventory management or rewards.
August 19, 2025 at 6:02 pm #18714::You’re right. Let me schedule a stream for Thursday to address these.
Thank you for highlighting this! Here’s another badge:
- 1 anonymous person
August 19, 2025 at 6:30 pm #18715August 19, 2025 at 6:35 pm #18716::You’re welcome, Grim Rubbish! If you have any more questions or need further assistance with the game or anything else, feel free to ask. I’m here to help! 😊
- 1 anonymous person
August 21, 2025 at 4:33 pm #18745::This one’s now fixed: https://blog.terresquall.com/community/topic/part-27-problem-with-weapons-passives/#post-18742
August 21, 2025 at 11:46 pm #18759::Hey Terence, thanks again. Sadly this didn’t fix the problem. I already had this line corrected in the “PlayerInventory.cs” but the problem explained above is still there. Maybe I can make a short video to illustrate the problem if this would help you?
August 22, 2025 at 7:19 pm #18761::Hi Grim, yes, if you can make a video that will be great.
@Alp.Apustaja, there was a problem with the
ApplyUpgradeOptions()
inPlayerInventory
that caused weapons / passives that were at max level to become an upgrade option. By changing the sign from<=
to<
in the line:if (obj.currentLevel <= data.maxLevel)
It fixed the problem for me. But can you see any other area that would cause this bug to occur where weapons at max levels are still eligible for upgrades?
Below is the full
ApplyUpgradeOptions()
that should be similar to what you have in your knowledge base.// Determines what upgrade options should appear. void ApplyUpgradeOptions() { // <availableUpgrades> is an empty list that will be filtered from // <allUpgrades>, which is the list of ALL upgrades in PlayerInventory. // Not all upgrades can be applied, as some may have already been // maxed out the player, or the player may not have enough inventory slots. List<ItemData> availableUpgrades = new List<ItemData>(); List<ItemData> allUpgrades = new List<ItemData>(availableWeapons); allUpgrades.AddRange(availablePassives); // We need to know how many weapon / passive slots are left. int weaponSlotsLeft = GetSlotsLeft(weaponSlots); int passiveSlotsLeft = GetSlotsLeft(passiveSlots); // Filters through the available weapons and passives and add those // that can possibly be an option. foreach (ItemData data in allUpgrades) { // If a weapon of this type exists, allow for the upgrade if the // level of the weapon is not already maxed out. Item obj = Get(data); if (obj) { if (obj.currentLevel <
=data.maxLevel) availableUpgrades.Add(data); } else { // If we don't have this item in the inventory yet, check if // we still have enough slots to take new items. if (data is WeaponData && weaponSlotsLeft > 0) availableUpgrades.Add(data); else if (data is PassiveData && passiveSlotsLeft > 0) availableUpgrades.Add(data); } } // Show the UI upgrade window if we still have available upgrades left. int availUpgradeCount = availableUpgrades.Count; if (availUpgradeCount > 0) { bool getExtraItem = 1f - 1f / player.Stats.luck > UnityEngine.Random.value; if (getExtraItem || availUpgradeCount < 4) upgradeWindow.SetUpgrades(this, availableUpgrades, 4); else upgradeWindow.SetUpgrades(this, availableUpgrades, 3, "Increase your Luck stat for a chance to get 4 items!"); } else if (GameManager.instance != null && GameManager.instance.choosingUpgrade) { GameManager.instance.EndLevelUp(); } }August 22, 2025 at 7:20 pm #18762::Based on the reference information and the provided code, there are a few potential areas that could cause max-level weapons to still be eligible for upgrades:
-
The code change you mentioned (changing
<=
to<
) is the primary fix for preventing max-level items from being upgrade options. -
Another potential issue could be in the
Get(data)
method or howcurrentLevel
andmaxLevel
are defined in theItem
class. -
The logic for checking
weaponSlotsLeft
andpassiveSlotsLeft
might inadvertently allow max-level items to be added.
However, without more context about the implementation of the
Item
class and other related methods, I cannot definitively point to additional specific areas that would cause this bug.Would you be willing to share the implementation of the
Item
class, particularly howcurrentLevel
andmaxLevel
are defined and managed? -
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: