CleverRaven / Cataclysm-DDA

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

Testing the working of ibuprofen. Results not as expected #76830

Open IdleSol opened 2 months ago

IdleSol commented 2 months ago

Describe the bug

It's me again and medicine again. I'll start right away by saying that maybe this is my misconception of how this all works.

Let me start with the initial data: the corresponding json https://github.com/CleverRaven/Cataclysm-DDA/blob/5f6f5e06a32ce82eac22e3ccebac27f1d1640c0f/data/json/items/comestibles/med.json#L150

    "type": "COMESTIBLE",
    "name": { "str_sp": "ibuprofen" },
...
    "use_action": {
      "type": "consume_drug",
      "activation_message": "You take some %s.",
      "effects": [ { "id": "pkill1_nsaid", "duration": 9000 } ]
    },
    "vitamins": [ [ "vit_ibuprofen", 216 ] ]

https://github.com/CleverRaven/Cataclysm-DDA/blob/65aca7f154933aa62002d95d3e178a0fe8619452/data/json/effects.json#L2460

    "type": "effect_type",
    "id": "pkill1_nsaid",
    "max_duration": "4 m",
    "base_mods": { "pkill_tick": [ 42 ], "pkill_min": [ 1 ], "pkill_max_val": [ 15 ] },
    "rating": "good",
    "blood_analysis_description": "Minor Painkiller (NSAID-based)"

https://github.com/CleverRaven/Cataclysm-DDA/blob/65aca7f154933aa62002d95d3e178a0fe8619452/data/json/vitamin.json#L75

My expectations:

  1. Effect duration 9000 / 60 /60 = 2.5 hours. Based on "effects": [ { "id": "pkill1_nsaid", "duration": 9000 } ]
  2. Effect name: Minor Painkiller (NSAID-based). Based on "blood_analysis_description": "Minor Painkiller (NSAID-based)"
  3. Repeated use of the pill. Doubles the duration of the effect and adds an additional 216 vitamins after 30 minutes.

Based on the hidden parameter “dur_add_perc”. Defaults to 100%. https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/EFFECTS_JSON.md

"dur_add_perc": 150 - Defaults to 100(%) "dur_add_perc" is the percentage value of the normal duration for adding to an existing

  1. There should be a point about expectation about the effect. But I don't know what to expect. Whether the effect will increase or stay the same? I don't know. And I don't know how to test it either.

The results I got: 00:00 - taking the first tablet 00:06 ... 00:40 1 00:45 ... 04:00 2 04:05 ...25:00 3 25:05 4

Additionally, I checked the increase in the duration of the effect of taking two tablets. 00:00 - taking the first tablet 00:06 - taking the second tablet Between 04:10 and 04:15, the Minor Painkiller (NSAID-based) effect disappears Between 26:05 and 31:10, the Painkiller effect disappears

Result

  1. The effect duration specified in "effects": [ { "id": "pkill1_nsaid", "duration": 9000 } ] is ignored. Probably because it exceeds the maximum duration specified in "max_duration": "4 m",. The effect lasts exactly 4 minutes.

  2. The simultaneous presence of two effects:

    • Minor Painkiller (NSAID-based)
    • Painkiller

I'm basing it on the name on the blood test: "blood_analysis_description": "Painkiller" https://github.com/CleverRaven/Cataclysm-DDA/blob/65aca7f154933aa62002d95d3e178a0fe8619452/data/json/effects.json#L4267

    "type": "effect_type",
    "id": "pkill",
    "name": [ "Painkillers" ],
    "desc": [ "You are under the influence of analgesic substances to relieve pain, but they may numb you a bit." ],
    "max_intensity": 30,
    "int_dur_factor": "10 s",
    "scaling_mods": { "speed_mod": [ -1 ] },
    "rating": "good",
    "blood_analysis_description": "Painkiller"

I assume that the occurrence of the Painkiller effect is hard-coded somewhere in the functions.

  1. No increase in the duration of effect from taking the second tablet.
  2. On a separate note, I have no idea what the Painkiller effect time is based on. Hardcode?

Attach save file

n/a

Steps to reproduce

n/a

Expected behavior

n/a

Screenshots

No response

Versions and configuration

cdda-windows-tiles-x64-2024-10-04-0532

Additional context

UPD. I forgot to mention the vitamins.

Their performance is completely as expected. After 30 minutes I was getting 215 (instead of 216) vitamins each. Every 100 seconds I lost 1. The maximum number of vitamins is 432. I.e. fully consistent with json. Except that one vitamin is lost immediately upon consumption.

IdleSol commented 2 months ago

I think I'm right. I changed the duration parameter:

  {
    "type": "effect_type",
    "id": "pkill1_nsaid",
--    "max_duration": "4 m",
++    "max_duration": "4 h",
    "base_mods": { "pkill_tick": [ 42 ], "pkill_min": [ 1 ], "pkill_max_val": [ 15 ] },
    "rating": "good",
    "blood_analysis_description": "Minor Painkiller (NSAID-based)"
  },

Minor Painkiller (NSAID-based) effect is gone after 2.5 hours (or 9000 seconds). The Painkiller effect disappeared after about 3 hours. Which tells us that its duration is somehow related to the duration of the Minor Painkiller effect.

IdleSol commented 1 month ago

Another problem. For the test, I specifically selected the time for ease of counting. So, for the test, I took the pill at 9:00:00. The vitamins were added 30 minutes later, at 9:30. Great?

But if I take the pill at 8:59:50. I'll get the vitamins at 9:00. That's 10 seconds later. Although the documentation says 30 minutes, without specifying that the cycle is hard-coded somewhere.