Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/improve: create "custom loot" for monsters #3080

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dudantas
Copy link
Contributor

@dudantas dudantas commented Nov 8, 2024

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. The closeContainer 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

  • New feature (non-breaking change which adds functionality)

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.

  • Tested global loot functionality across multiple monster types.
  • Verified stability improvements in the closeContainer function.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

This has two different options:
Adding "global" items that can drop on any monster (it is disabled by default)

Add specific items for each monster, without having to modify each monster's script. This allows a certain freedom to work with loot, without having to edit each script.

Added "const ref" to getBestiaryList, avoid copying large bestiary map.

Improved "registerLoot" function to avoid code duplication.
Removed "bad" code in "closeContainer", this may crash if the container is used (it is removed right before)

New lua function "getMonsterTypeByName".
@dudantas dudantas force-pushed the dudantas/feat-custom-loot-monsters branch from 2b89e4b to 34db7f7 Compare November 8, 2024 03:59
Copy link

sonarcloud bot commented Nov 10, 2024

Please retry analysis of this Pull-Request directly on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant