Page 1 of 1

joined recipe outputs dependent on probability

Posted: Fri Sep 13, 2024 6:43 am
by protocol_1903
I don't really know how to put it all into one sentence. Hopefully I can properly explain what I wish to do. I also hope I haven't missed a previous post on this topic, but I found it hard to title this one and searching for someone else's title was proving difficult

I wish that you could specify a product of a recipe with a probability, and if that probability check fails, then another item will be returned instead. Like so:

An example recipe where you try to fill a water barrel, but spill some.

Code: Select all

ingredients = {
  { type = "item", name = "barrel", amount = 1 },
  { type = "fluid", name = "water", amount = 100 }
},
results = {
  {
    type = "chance",
    probability = 0.8,
    success = { type = "item", name = "water-barrel", amount = 1 },
    failure = { type = "item", name = "barrel", amount = 1 }
  },
  { type = "fluid", name = "water", amount = 20 } -- normal fluid output
}
Another example recipe where you try to fill a water barrel, but get all the water back if you fail

Code: Select all

ingredients = {
  { type = "item", name = "barrel", amount = 1 },
  { type = "fluid", name = "water", amount = 100 }
},
results = {
  {
    type = "chance",
    probability = 0.8,
    success = { type = "item", name = "water-barrel", amount = 1 },
    failure = {
      { type = "item", name = "barrel", amount = 1 },
      { type = "fluid", name = "water", amount = 100 }
    }
  }
}
You could also not specify a failure product, so you can get multiple items if the probability check passes, but nothing if it fails.

This might be useful in certain recipes in SA and mods, where some percent of products should be x, and the rest y, but the total number of products is the same across different trials. In general gameplay, as a common recipe, it wouldn't be noticeable and could be easily replicated with the current probability system (although the number of barrels might fluctuate in some cases). It's the edge case of specialized recipes, stuff like satellite launches, that I'm interested in.

Re: joined recipe outputs dependent on probability

Posted: Fri Sep 13, 2024 9:23 am
by curiosity