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: spawn active items on mapgen #4283

Merged
merged 9 commits into from Mar 7, 2024

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Mar 2, 2024

Purpose of change

Describe the solution

cherry-picked solutions from #4073 and #4266:

  • for individual items: inlined map::spawn_item in src/mapgen.cpp and replaced with map::spawn_an_item as it allows passing item ptr (so we can activate it first)
  • for item groups: sent ACTIVATE_ON_PLACE flag to Item_modifier.custom_flags in src/item_factory.cpp and checked its presence in src/item_group.cpp.
  • added postprocess_fns: vector<detached_ptr -> detached_ptr> field in Item_modifier class that lets you postprocess spawned item in Command pattern.

Describe alternatives you've considered

  • send lambdas in item modifier to make sending messages less hacky. skipped for this one as this meant header modification and this would have been the only usage.
  • unify item and item groups spawning by spawning single items via item groups

Testing

Cataclysm: Bright Nights - 0 C-57204-g083f635262fe-dirty_01
Cataclysm: Bright Nights - 0 C-57204-g083f635262fe-dirty_02

  • spawned grenades on top of shelter, one via individual item and one via item group. both are activated.
  • have to write a test to ensure it gets activated but i'm not sure which API to use.
  • to test, revert last commit and load a evac shelter in fresh map.

Checklist

  • Document the changes in the appropriate location in the doc/ folder.
  • If documentation for this feature does not exist, please write it or at least note its lack in PR description.
  • New localizable fields need to be added to the lang/bn_extract_json_strings.sh script if it does not support them yet.
  • If applicable, add checks on game load that would validate the loaded data.
  • If it modifies format of save files, please add migration from the old format.

Now you can spawn grenades active in houses, or you know, atomic lights
@github-actions github-actions bot added src PR changes related to source code. data PRs related to datas. Won't crash game (probably) labels Mar 2, 2024
@scarf005 scarf005 changed the title feat: spawn active items on mapgen feat: spawn active items on mapgen Mar 2, 2024
@github-actions github-actions bot added the docs PRs releated to docs page label Mar 2, 2024
@github-actions github-actions bot removed the data PRs related to datas. Won't crash game (probably) label Mar 2, 2024
src/item_factory.cpp Outdated Show resolved Hide resolved
scarf005 and others added 2 commits March 2, 2024 19:14
@cataclysmbnteam cataclysmbnteam deleted a comment from autofix-ci bot Mar 2, 2024
@scarf005 scarf005 requested a review from Coolthulhu March 5, 2024 23:49
Coolthulhu
Coolthulhu previously approved these changes Mar 7, 2024
scarf005 and others added 2 commits March 7, 2024 12:02
Co-authored-by: Coolthulhu <Coolthulhu@gmail.com>
Co-authored-by: Coolthulhu <Coolthulhu@gmail.com>
@chaosvolt chaosvolt merged commit 4e22dfd into cataclysmbnteam:main Mar 7, 2024
13 checks passed
@scarf005 scarf005 deleted the feat-mapgen-active branch March 7, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page src PR changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants