CleverRaven / Cataclysm-DDA

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

EoC effect to terminate execution of EoC #76547

Open GuardianDll opened 1 week ago

GuardianDll commented 1 week ago

Is your feature request related to a problem? Please describe.

  {
    "type": "effect_on_condition",
    "id": "item_talks_to_you",
    "effect": [
      {
        "if": { "math": [ "n_hp('ALL')", "<", "n_hp_max('bp_null')" ] },
        "then": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_damaged>\"" },
        "else": {
          "if": { "math": [ "(u_hp('ALL') * 1.4)", "<", "u_hp_max('bp_null')" ] },
          "//": "Weapon will be concerned for you if you're significantly injured.",
          "then": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_bleeding>\"" },
          "else": {
            "if": { "and": [ "u_can_see", { "math": [ "u_monsters_nearby('radius': 10)", ">=", "1" ] } ] },
            "then": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_monster>\"" },
            "else": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_misc>\"" }
          }
        }
      }
    ]
  },

Solution you would like.

  {
    "type": "effect_on_condition",
    "id": "item_talks_to_you",
    "effect": [
      {
        "if": { "math": [ "n_hp('ALL')", "<", "n_hp_max('bp_null')" ] },
        "then": [ { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_damaged>\"" }, "terminate" ]
      },
      {
        "if": { "math": [ "(u_hp('ALL') * 1.4)", "<", "u_hp_max('bp_null')" ] },
        "//": "Weapon will be concerned for you if you're significantly injured.",
        "then": [ { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_bleeding>\"" }, "terminate" ]
      },
      {
        "if": { "and": [ "u_can_see", { "math": [ "u_monsters_nearby('radius': 10)", ">=", "1" ] } ] },
        "then": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_monster>\"" },
        "else": { "run_eocs": { "id": "normal_talk", "effect": { "u_message": "Your <npc_name> says \"<schizo_weapon_talk_misc>\"" } } }
      }
    ]
  },

Describe alternatives you have considered.

--

Additional context

Yes, i just want a bit of c++ in my json

PatrikLundell commented 1 week ago

Until someone tries to use it to terminate the EOC (so it won't be repeated), only to find it skips the processing of the rest of the section instead.

GuardianDll commented 1 week ago

i should've clarified i wanted something similar to return;

PatrikLundell commented 1 week ago

"return" is a better name, although there's probably a better name than that out there (I can't find it in my mind, though).

GuardianDll commented 1 week ago

Return assumes it would return some value, and in c++ it does, it's just for void it simply end the function, effectively terminating it. Maybe "end" gonna fit it better

Hyperseeker commented 1 week ago

JS uses break to finish its loops and switch statements prematurely.