feat/improve: create "custom loot" for monsters #3080
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This update introduces several enhancements to the loot system, allowing for more flexible loot management across different monsters without the need to modify each monster's individual script. A global loot option has been added, which is disabled by default, to assign items that any monster can drop. This feature simplifies the addition of common loot across multiple monsters, enhancing the modularity of loot management.
The
registerLoot
function has been improved to eliminate code duplication and enhance efficiency. ThecloseContainer
function has been updated to remove problematic code that could cause crashes when "container" used before "erase". Additionally, a new Lua function,getMonsterTypeByName
, has been introduced to facilitate getting monster types.Behaviour
Actual
Previously, adding or modifying loot required changes to each monster's script individually, which was cumbersome and error-prone.
Expected
With the new system, it's now possible to assign specific loot to monsters or set global loot defaults without direct script modifications. This update also ensures more stability and performance in managing loot containers.
Type of change
How Has This Been Tested
Testing focused on ensuring that the new global loot system functions correctly without impacting the specific loot settings for individual monsters. Tests were also conducted to ensure that the modifications to the
closeContainer
function did not lead to crashes under various scenarios.closeContainer
function.Checklist