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

make u_spawn_item to support the item group whose subtype is collection #71014

Merged
merged 3 commits into from
Jan 18, 2024
Merged

make u_spawn_item to support the item group whose subtype is collection #71014

merged 3 commits into from
Jan 18, 2024

Conversation

PipeYume
Copy link
Contributor

@PipeYume PipeYume commented Jan 17, 2024

Summary

Features "make u_spawn_item to support the item group whose subtype is collection"

Purpose of change

Close #71000

Describe the solution

Modify the receive_item function which is used by set_spawn_item and set_u_buy_item.

If the use_item_group is true, then it will call the item_group::items_from function and create one item (distribution) or collection of items (collection) from that item group, then do the same things as previous. (The popup message will be shown once)

Since the count and containter are defined in item group, "count" and "container" options of "u_spawn_item" will be ignored.

Describe alternatives you've considered

Testing

[
  {
    "id": "test_EOC_spawn_item_group_collection",
    "type": "item_group",
    "//": "This is for testing u_spawn_item",
    "subtype": "collection",
    "entries": [
      { "item": "bodysuit_lycra", "variant": "superhero_suit_purple" },
      { "item": "mask_bal", "prob": 50 },
      { "item": "long_patchwork_scarf", "count": [ 2, 4 ] },
      { "item": "rock", "charges": [ 2, 4 ] }
    ]
  },
  {
    "id": "test_EOC_spawn_item_group_distribution",
    "type": "item_group",
    "//": "This is for testing u_spawn_item",
    "subtype": "distribution",
    "entries": [
      { "item": "bodysuit_lycra", "variant": "superhero_suit_purple" },
      { "item": "mask_bal", "prob": 50 },
      { "item": "long_patchwork_scarf", "count": [ 2, 4 ] },
      { "item": "rock", "charges": [ 2, 4 ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_spawn_item_group_test",
    "//": "tests for spawning item group (collection / distribution). Alpha and beta talker is for showing the popup message",
    "effect": [
      { "message": "collection: ", "popup": true },
      {
        "run_eoc_with": {
          "id": "_EOC_spawn_item_group_test_collection",
          "effect": {
            "u_spawn_item": "test_EOC_spawn_item_group_collection",
            "use_item_group": true,
            "force_equip": true,
            "flags": [ "UNBREAKABLE" ]
          }
        },
        "alpha_talker": "avatar",
        "beta_talker": "avatar"
      },
      { "message": "distribution: ", "popup": true },
      {
        "run_eoc_with": {
          "id": "_EOC_spawn_item_group_test_distribution",
          "effect": {
            "u_spawn_item": "test_EOC_spawn_item_group_distribution",
            "use_item_group": true,
            "force_equip": true,
            "flags": [ "UNBREAKABLE" ]
          }
        },
        "alpha_talker": "avatar",
        "beta_talker": "avatar"
      }
    ]
  }
]

Additional context

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. NPC / Factions NPCs, AI, Speech, Factions, Ownership [JSON] Changes (can be) made in JSON Spawn Creatures, items, vehicles, locations appearing on map Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` [Markdown] Markdown issues and PRs <Bugfix> This is a fix for a bug (or closes open issue) <Enhancement / Feature> New features, or enhancements on existing json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jan 17, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 17, 2024
Co-authored-by: Procyonae <[email protected]>
@Maleclypse Maleclypse merged commit 84fc61e into CleverRaven:master Jan 18, 2024
21 of 26 checks passed
@PipeYume PipeYume deleted the U_SPAWN_ITEM_GROUP branch February 11, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs NPC / Factions NPCs, AI, Speech, Factions, Ownership Spawn Creatures, items, vehicles, locations appearing on map
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] u_spawn_item only spawn one item when the item group's subtype is "collection"
3 participants