wobbly wrote: ↑Fri Mar 04, 2022 6:59 amI could certainly rewrite it if you believe it would be more readable or efficient...
In this case, it's inside some other scripts that can't be moved to activation or scope, so it's probably fine, but just keep in mind that using activation and scope where reasonable is preferable to trying to encode everything within the effect itself.
Also, note that the details of what the scripted effectsgroups will do is also different with different constructions in cases where there are multiple target objects. Scripting with Random in the activation condition lets one pick whether an effectsgroup should execute on all potential targets at the same time, but can only ensure that exactly one of the possible effects is applied by using stacking groups and multiple effectsgroups that contain the different effects and suitable priority ordering of those effectsgroups. Scripting with an If condition = Random effect or OneOf valueref within an effect lets one pick one of several options independnetly for each target, but not to ensure all targets get the same effect applied.
It would probably be useful to add another valueref operation that works like OneOf but which is only evaluated once per execution, rather than once per target object or condition candidate object, but actually doing that would be tricky. There is a mechanism to evaluate valuerefs within effects or other valuerefs or conditions just once if their result is not dependent on (called "invariant to") the separate objects that are being considered in a condition or separate targets being acted on by an effect, but whether that get evaluated once or multiple happends usually requires all the parameters to an effect or condition to be invariant, and not each parameter independently of the others. So really, doing that with the activation condition would be more realistic and already-supported.
This is something I'm finding a bit awkward. ensuring 1 of 2 seems straightforward. What happens when you want to ensure 1 of 3? e.g. guard ship/ancient guardians/stealth. Unless I'm missing the simple method, this is hard to do without making the scripting cumbersome.
You can chain the if-else effects... If condition = C1 effects = E1 else = If condition = C2 effects = E2 else = E3
A second issue is OneOf is great if the probabilities are equal, but what about the case of unequal probabilities?
There was some discussion about weighted OneOf:
viewtopic.php?p=107531#p107531