Telegraphing attacks and particle systems
For this week, another useful mini-rabbit hole! It all started after reading some post about...
Telegraphing Abilities
It seems that I developed a system to support such abilities long before I knew what the term meant (blog post from 2017). What I never considered was: how does the player know when enemies are preparing an attack that's going to strike sooner or later? Here's where telegraphing came in, 7.5 years later! Since I already have functionality to display affected tiles by an ability (both targets and associated AoE), it wasn't a stretch to add a bit more functionality to get those affected tiles and highlight them for the duration of preparation. This happens for either player or non-player abilities. Alright! But we need to colorize the highlighted tiles, from a dull white to a warning red. Ok sounds like we need to use some sort of color palette
Color Names
Looking at the existing color name sets that I use, I noticed several inconsistencies. There's Godot colors, there are web colors, there are web colors chosen for their nice-as-unidentified-item name, etc. So there was a bit of cleanup and refactoring to just a single color set as a base (Godot's, which is web/X11 colors), and draw subsets of that if necessary. Nothing too exciting on this front. After this was done, I see the telegraphed attack, then the meteor storm is supposed to show up and it ... doesn't! So, somewhere along the lines in the last year or two, the effect got removed and/or stopped working. Ok, back to particle system editing I suppose! But I want to escape caveman-style particle system coding, so I used my new reflective imgui functionality to spin up a GUI in about 10 minutes (ok 10 more with some helper functionality), named ...
Particle System Explorer
So this is yet another tool window (the aim is that these tools are compiled out when making release builds) where I can try and edit particle systems on the fly. I can set up easy targets (center point, focal point, paths, areas) and execute a particle effect from the database. But the database is also modifiable with the reflective gui, and the shader is easily reloaded, so it's a nice system to quickly iterate on shaders. The only time I need to recompile is when I need to change the type/number of parameters accessible to the shader, which is an ok price to pay. So, after a bit of work on this, I created a particle system type called "drop and splash" which, as the name suggests, dropping several particles and they can play a splash animation. This is what I used to have but apparently I had refactored out, so it's back in the game, and it's being used as a based for the meteor storm spell. Other parameters that can be tweaked are: size range of particles, sprites for particles and splash, angle(s) that they're coming from, drop speed, if we should angle the sprites accordingly, etc etc. And this gets us to ...
Meteor Storm
And this is the culmination of above efforts - the re-implementation of the "meteor storm" spell. We select a target tile, then AI plays (while telegraphing tiles to be hit) then the particle effect is fired -- actually two of them: the actual "meteor storm" effect where fireballs are coming from north-east and explode on target tiles, and the second effect results in tiles catching fire. Add a bit of screenshake and a bit of timing, and the result looks coherent!