garbagemule / MobArena

MobArena plugin for Minecraft
GNU General Public License v3.0
195 stars 151 forks source link

[Feature] Wave Chances. #709

Open Maroon28 opened 2 years ago

Maroon28 commented 2 years ago

Feature request

Short description Currently, any arena you make becomes predictable very quickly after playing a few matches. That's due to how the wave system is currently built, waves are basically 'static' to some extent.

By defining a 'wave-chance' for each wave, waves will become much less predictable and a lot more fun!

Implementation details This is going to drag on for a while because there's a lot to consider, so bear with me here!

Each wave, either single or recurrent, will have an optional parameter that you can define called 'chance:' . Here's a quick example:

waves:
  recurrent:
    def1:
      type: default
      priority: 1
      chance: 0.7 # This means there's a 70% chance for def1 to spawn when its turn comes. 
      frequency: 1
      monsters:
        zombies: 10
        skeletons: 4
        exploding_sheep: 5

Seems pretty simple from a quick glance, but again, there's a lot to consider before making it fit in nicely. Here are some cases that come to mind:

What if its the only wave in the arena and it has a chance? Simply just ignore the chance. Its a pretty rare case but definitely still possible to do.

What if the chance fails? This is probably the hardest thing to get past. If the 70% chance doesn't come up, what do we do? It took a bit to think this through but either A) Nothing spawns, which is definitely boring, or B) something spawns, but where do we get it from?

That's where we'd have to look at another solution, Fallback Waves. It's pretty simple and self-explanatory. You define a chance and you define a fallback wave. If you don't have a chance, then you shouldn't have a fallback either. If the chance succeeds, great! Your wave comes into life! But if it doesn't, then MobArena checks the fallback: option right under chance, and runs that. Here's a configuration example

waves:
  recurrent:
    def1:
      type: default
      priority: 1
      chance: 0.7 # This means there's a 70% chance for def1 to spawn when its turn comes. 
      fallback: def2 # A wave called def2 will be run if this one fails
      frequency: 1
      monsters:
        zombies: 10
        skeletons: 4
        exploding_sheep: 5

What if the user defines a chance but no fallback? This is a pretty tricky one, but we could have it so that MobArena uses the nearest wave in the configuration file, or it forces this wave to run because it doesn't know exactly where to go.

What if the fallback also has a chance to run? We can either A) Ignore that chance, and run it anyways, or go through the process of trying to run it based on the chance, and if that chance also fails, then look for the fallback of the second wave. This may overcomplicate things though, but it would allow for much more complex trees to be built.

There are probably some edge cases I missed, so if you have any ideas then feel free to comment them below!