You can do this with followcond and followanim.
followanim {value}
~Determines which FOLLOW animation played when followup condition is met or when counter condition is met.
~Possible values are 1, 2, 3 and 4.
~Used together with 'followcond' or 'counterframe'.
followcond {value}
~This command is to make the entity performs FOLLOW{#} if an attackbox in the animation hits.
~value determines the condition requirements before FOLLOW{#} is played.
1 = this animation will followup as long as it hits an entity.
2 = this animation will followup as long as it hits an enemy (Or player if an enemy uses it).
3 = this animation will followup as long as it hits an enemy and the target does not get killed or not block the attack.
4 = this animation will followup as long as it hits an enemy, and the target is not killed, does not block the attack, and is not set to be ungrabbable.
5 = this animation will followup as long as it hits an enemy and the target does not get killed or block the attack.
~Which FOLLOW animation played is determined by 'followanim'.