CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.34k stars 4.14k forks source link

Duplicate "use_action" types do not work #71814

Open ANickelN opened 8 months ago

ANickelN commented 8 months ago

Describe the bug

For items that have two use_actions, only the first of the actions is applied. As shown in the block below, only the "Turn to high power" transformation will work.

  "use_action": [
      {
        "menu_text": "Turn to high power",
        "type": "transform",
        "msg": "You turn the flashlight to the high setting.",
        "target": "tac_flashlight_on_high",
        "ammo_scale": 0
      },
      {
        "menu_text": "Turn off",
        "type": "transform",
        "msg": "You turn the flashlight off.",
        "target": "tac_flashlight",
        "ammo_scale": 0
      }   
    ],

Setting the second action to a "delayed_transform" works as shown below:

    "use_action": [
      {
        "menu_text": "Turn to High",
        "type": "transform",
        "msg": "You turn the flashlight to the high setting.",
        "target": "tac_flashlight_on_high",
        "ammo_scale": 0
      },
      {
        "menu_text": "Turn off",
        "type": "delayed_transform",
        "transform_age" : 1,
        "msg": "You turn the flashlight off.",
        "not_ready_msg" : "You shouldn't see this message.",
        "target": "tac_flashlight",
        "ammo_scale": 0
      }
    ],

Attach save file

N/A

Steps to reproduce

Load the following local mod I use for testing: LocalTesting.zip

Spawn in the "tactical flashlight", reload the battery and attempt to turn off the flashlight from "low" mode. You'll be forced into "high" mode despite the two actions in the JSON.

Expected behavior

The player should be able to choose between the two actions.

Screenshots

No response

Versions and configuration

Additional context

No response

RedMisao commented 8 months ago

This isn't limited to "type": "transform", it's a general issue with use_action: if there is more than a single type, only the first is detected while the rest are ignored. Combining different types work as intended, as long as there is a single one of each.

(I wasn't aware this hasn't been reported before)

ZhilkinSerg commented 8 months ago

(I wasn't aware this hasn't been reported before)

It was reported - see https://github.com/CleverRaven/Cataclysm-DDA/issues/28975 and https://github.com/CleverRaven/Cataclysm-DDA/issues/50277