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

Allow "repeat" for character-map placement of items #28723

Merged
merged 1 commit into from Mar 15, 2019

Conversation

Projects
None yet
4 participants
@ralreegorganon
Copy link
Contributor

commented Mar 15, 2019

Summary

SUMMARY: Bugfixes "Allow 'repeat' for character-map placement of items"

Purpose of change

All over the mapgen json, map developers have been attempting to have item placement repeat, like this:

{
  "items": {
    "o": { "item": "novels", "chance": 70 },
    "$": { "item": "vault", "chance": 95, "repeat": 5 },
    "T": { "item": "vault", "chance": 20, "repeat": 5 },
    "e": { "item": "fridge", "chance": 70, "repeat": [ 2, 3 ] },
    "d": { "item": "office", "chance": 50 },
    "L": { "item": "cop_weapons", "chance": 40 }
  }
}

One problem: repeat on a character-map based placement of items doesn't do anything. "repeat" is completely ignored. The item spawn is only attempted once.

To make matters more confusing for map developers, if you used the place_items version of it like the following, it did work:

{
  "place_items": [
    { "item": "office", "x": [ 4, 9 ], "y": 8, "chance": 30 },
    { "item": "office", "x": [ 3, 5 ], "y": 12, "chance": 30 },
    { "item": "office", "x": 16, "y": [ 14, 15 ], "chance": 70 },
    { "item": "vault", "x": 3, "y": [ 19, 20 ], "chance": 30, "repeat": 5 },
    { "item": "vault", "x": [ 3, 5 ], "y": 16, "chance": 90, "repeat": 5 }
  ]
}

I'm sure this has led to confusion, inappropriately balanced item spawns, and users experiencing something other than what map developers intended. For example, these two variations above are both taken from the same mapgen file for the bank. Ever feel like the one bank variant has a lot more loot in the vault than the other? This is why.

Describe the solution

  • Update the jmapgen_piece class to have a repeat property (defaulted to 1)
  • Update jmapgen_item_group and jmapgen_spawn_item classes to load this property
  • Update the jmapgen_objects::apply method to consider the repeat property when determining the number of times to repeat the apply call of the piece

Additional context

The mapgen json is full of cases of repeat being used to place items that was not actually doing anything--once this is merged, it'll start actually working. In general, that'll mean more items spawning everywhere that used this.

@ralreegorganon ralreegorganon force-pushed the ralreegorganon:mapgen-repeat branch from 186b862 to ddf8b62 Mar 15, 2019

@I-am-Erk

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2019

It warms my heart to know that my project to increase item spawns isn't going to have nearly as much work to do as I'd thought.

@ZhilkinSerg ZhilkinSerg self-assigned this Mar 15, 2019

@ZhilkinSerg ZhilkinSerg merged commit ffa79fd into CleverRaven:master Mar 15, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
gorgon-ghprb Build finished.
Details

@ZhilkinSerg ZhilkinSerg removed their assignment Mar 15, 2019

@kevingranade

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/8604-win-tiles-possible-item-spawn-bug-in-mansion/19309/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.