godot_dialogue_manager icon indicating copy to clipboard operation
godot_dialogue_manager copied to clipboard

Random Options

Open miradosamurai opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. Just to preface, this isn't a major issue, so I don't mind if it's something that's never done or is put on the back burner, especially since I'm sure you're working on the Godot 4 port. Either way, thank you for this awesome plugin!

But on to the request, I thought it would be very useful if there was a way similar to the response system to have a random option selected out of a set of options, preferably with a way to add weight to which is selected. For examples of this, you could have a character that you want to greet you with a few random greetings (Hi, Hello, Heyo, etc), or a quest giving character give you different random quests (clear x area of enemies, fetch x item, another settlement needs your help, etc), or the player can be doing something with a few possible outcomes (critical success, success, fail, critical fail, etc).

There is a way to do this already that I'll list in the alternatives section, but it's nowhere near as elegant/streamlined as the response system. Also, if you want a better idea of what I'm talking about, most Paradox games (CK2/CK3, Stellaris, etc) make HEAVY use of this in their event systems, both for which events may happen, and for what may happen for a event response you choose.

Describe the solution you'd like Like I said, something along the lines of the response system would likely be the most intuitive, most likely with a different symbol than the hyphen/dash (-). Possibly the percent sign (%), though I don't know if that's used in variable or condition processing and if that would interfere. Then if you wanted the randomization to be weighted, you could just put a number after the symbol for that option's weight, or leave it at just the symbol for a default weight(1 I would assume, though you could also create an option for people to change it in the dialogue editor settings). Default weight example: % Option 1, 33 percent chance % Option 2, 33 percent chance % Option 3, 33 percent chance For this, each option has the same weight (i.e. 1) so each option has a 1/3 chance of being chosen.

Weighted example: %1 Option 1, 10 percent chance (This would also be the same as "% Option 1, 10 percent chance", if default weight is 1) %3 Option 2, 30 percent chance %6 Option 3, 60 percent chance For this, the total of the weights added together (1 + 3 + 6) equals 10. Option 1 has a weight of 1, so it has a 1/10 (10%) chance of being selected, option 2 has a weight of 3, so it has a 3/10 (30%) chance of being selected, and option 3 has a weight of 6, so it has a 6/10 (60%) chance of being selected.

Describe alternatives you've considered The way I would do it at the moment, would be to use a method to get which option it would be, then if and elif conditions. And while this isn't difficult, it can get tedious, with having to make you add the weight for each new option, or if you have several options with some having the same weight it could be annoying if you want to change one of the weights (i.e. 1, 3, 3, 3, 6). Example: do weightRandom([1, 3, 6]) (sets a variable named random in a global used by Dialogue Manager) if random == 1: Option 1, 10 percent chance elif random == 2: Option 2, 30 percent chance elif random == 3: Option 3, 60 percent chance

miradosamurai avatar Aug 06 '22 21:08 miradosamurai

Something like this has been on my list of a while. I'm still figuring out a syntax that I'm happy with but this will most likely be something added in version 2.

nathanhoad avatar Aug 06 '22 23:08 nathanhoad

I've added random chunks in a single line but the weighted random line thing is still on my radar for the near future.

nathanhoad avatar Aug 27 '22 11:08 nathanhoad