Posted May 04, 2021 by Human
#action sequences
Next installment in the series breaks down swarm, a deceptively difficult attack to program.
Everyone hates waiting for 8 enemies to attack, one by one, slowly. Swarm was designed to be as fast as a single enemy's attack, but with all 8 bees. Making them attack simultaneously is not easy given the limitations of RM action sequences. Thanks to Visustella Battle core for making it possible! The entire attack occurs within 40 frames, with a 12 frame wait to give time for all the bees to reset. That means the entire attack is 52 frames - less than one second.
Basically, all 8 movements and attacks are a single action sequence, complete with overlapping motion, damage effects, and conditional branches to check for which bees are dead. My first step, using pen and paper, I wrote out basically what you see in the table below so I could get my mind around what I wanted to happen.
Frame 0 | Bee 1 moves to target | |
Frame 4 | Bee 2 moves to target | |
Frame 8 | Bee 3 moves to target | |
Frame 12 | Bee 1 hits and returns to home | Bee 4 moves to target |
Frame 16 | Bee 2 hits and returns to home | Bee 5 moves to target |
Frame 20 | Bee 3 hits and returns to home | Bee 6 moves to target |
. . . | ... | ... |
Frame 40 | Bee 8 hits and returns to home | |
Frame 52 | Finish action |
Take a look at the first few lines of events and you'll see I carefully labeled everything to make the process easier and more fixable in case of bugs. I used a MOVE: Jump command to with a bit of randomness inserted to make the flying feel a little more natural and varied. Math.randomInt (-200, 200) means the height of the bees jump falls somewhere between -200 (an arc below) or 200 (arc above).
Another puzzle was making sure that damage would not occur to the actors if the bee was dead. So I just made a conditional branch so the action effect and animation would not occur if the target was dead.