need help creating boss attacks

Started by AceleracerX on

Topic category: Help with MCreator software

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
need help creating boss attacks

so i'm making a boss that is supposed to summon lightning every 4 seconds and explode with that same delay, but instead after waiting 4 seconds the boss just repeatedly summons all of his attacks every tick (and also kills himself lmao), can someone tell me what's going on?

 

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem is that this…
Fri, 12/08/2023 - 12:25

The problem is that this procedure is still running every single game tick. That means every twentieth of a second, it tells the boss to wait four seconds, and then spawn lightning. Which means the boss waits four seconds, and then spawns a constant stream of lightning.

Instead, you need some sort of variable, (either a custom NBT number tag, or if there's only ever going to be one boss, a global number variable), that keeps track of the cooldown between the boss's attacks, and decreases by one every tick it's greater than zero. That way, you can check if the cooldown has expired before attacking, and reset the cooldown every time the boss attacks so it doesn't spam.