So I've come across an issue in the game I'm working on, but it seems to be a pretty fundamental thing that probably comes up in a lot of games.
My game requires that some gameplay function occurs at a very specific point in time during a character animation. And so, as the title says, I'm wondering what are some good techniques and fundamental strategies for syncing gameplay-related events/functions/actions to specific points in a character's animation.
Here are some simple examples of what I'm talking about in various types of games:
Your character reloads their gun in a shooter. Your character plays his/her 'reload' animation, but it's important that the function that sets the currentAmmo variable is only called at the exact moment after the magazine is swapped and the gun is cocked. This might be some point in the middle of the reload animation.
In a turn-based RPG your characters stand in a line facing a line of enemies. When commanded to attack, one of your characters runs/jumps up to one of the enemies and slashes their giant sword before running/jumping back to their standing place. You want to make sure that the enemy is damaged at the exact moment that the slashing animation is played - some point between running up and running back.
In a stealth game, your character can sneak up and interact with computers and buttons in the world. Maybe there is a button that turns off the power supply to the lights of the outpost that you're infiltrating. When the action button is pressed, your character reaches out and pushes the button and then returns to their idle stance. You want the lights to turn off at the exact point in the 'push_button' animation when the button is pushed in.
Admittedly, my particular case is most like the second example, in which I have created an animation where my turn-based character lunges forward during an attack and I want the damage to be applied at the exact moment that the animation seems to be making contact. Because my game using a turn-based system (imagine something like Final Fantasy or Fire Emblem) I want the damage/healing/magic/etc. to be applied at the correct time during each character animation even though I'm not actually using collision/hitboxes.
I should mention that I'm making my game in a popular game engine, and that right now I'm handling this by using their animation events or notifies to achieve something close to the desired results - my character performs a certain command and triggers a command-specific animation (i.e.: 'attack_command') and the animation assets for each one of my commands must include an animation event/notify 'callback' into my characters ExecuteCommand function. In other words - the character tells the attack animation to play, and then the attack animation emits an event/notify callback into the character at the exact moment during the animation when the damage should be dealt.
Honestly, this works for now, but it just feels wrong - like I'm missing some part of the bigger picture here! Part of the reason that this method feels wrong is that it couples the game logic with the animation assets; if my animation asset forgets to include an ExecuteCommand() event/callback, the command wont execute properly and extra code is needed to check if a command animation finished without executing the command. It's messy and it means that my gameplay has a strange dependency on its assets. Of course I want the damage to occur at a specific point during my attack animation, but I feel really weird about calling gameplay code inside animation assets..
So what am I overlooking here? What are some good general techniques for handling these types of situations in which you want certain important gameplay actions to occur at specific times during animations?
Edit: To clarify, this isn't an engine-specific question nor am I looking for engine-specific designs/techniques. I'm interested in general animation/gameplay synchronization techniques that one might use in your game projects regardless of technologies used.