CleverRaven / Cataclysm-DDA

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

Allow active mutations to accept math for costs/active time, unify cost parameters #74746

Open Standing-Storm opened 4 months ago

Standing-Storm commented 4 months ago

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

Right now, there are thirst, kcal, and sleepiness parameters for mutations, allowing an active mutation to cost one of those resources every time interval. If you want to use another type of cost (such as mana, or hp, or something), you need to build a complicated EoC that takes all that into account.

Solution you would like.

Remove the kcal/thirst/sleepiness mutation parameters and change cost to accept math, so that a kcal cost would be { "math": [ "u_calories()", "-=", "15" ] }, a thirst cost would be { "math": [ "u_val('thirst')", "-=", "4" ] }, and so on. That would allow the cost to be anything math can cover, including mod-added traits. (It may also be useful to have some way to specify a threshold at which the mutation shuts off for said mod traits, like "min_cost_value": { "math": [ "u_val('mana')", ">=", "1" ] }) or something).

Allowing the time parameter to accept math would make it similarly flexible.

Describe alternatives you have considered.

74729 has examples of the sort of workarounds necessary to have active traits that cost anything other than kcal, thirst, or sleepiness.

Additional context

No response

zachary-kaelan commented 4 months ago

Yeah, having a single cost field and then a variety of bool fields to select the type, is not optimal.

I also noticed that a few mutations have a separate ability definition for climbing which has a different, more reasonable way of specifying cost, that can also support "damage" and "pain":

{
  "type": "climbing_aid",
  "id": "ability_WEB_RAPPEL",
  "//": "Extremely safe descent regardless of height by spinning webs.",
  "copy-from": "generic_superpower",
...
    "cost": { "kcal": 87, "thirst": 10 },
...
  },
  "condition": {
    "type": "trait",
    "flag": "WEB_RAPPEL"
  }
}

I also notice that some activated mutations have EOCs that do nothing but call the EOC_GENERIC_SPELL_MUTATION with parameters for turn cost and stamina cost that in turn calls the EOC_GENERIC_SPELL_MUTATION_ACT to cast the spell. Spells can use math for calculating the cost, but the only values accepted for energy_source are MANA, BIONIC, HP, STAMINA, NONE.

My initial idea is to create a generic cost object that is like the cost object in the climbing abilities, except with some extra possible costs added, including a run_eoc field.

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

Standing-Storm commented 3 weeks ago

Partially alleviated by #77013, though using vitamins is still not possible