Audiobellum it's likely just logic inserted into the kill animations. How exactly they coded it is something I can't tell you. But it's probably a lot of small lines of codes like (this is made up) if wall, then enemy.fall_over_wall()
or something equivalent and probably several lines of that peppered in dependent on the circumstances.
Let's just make-believe here and say you have a "kill" function that happens when an enemy dies. In that function, you likely have some sort of state machine that has functions for different animations dependent on the situation. So assuming this is the case (more made up code here):
Note this is pretty simple logic, you can probably code it more efficiently, but this will at least make it digestible if you're learning.
func _kill_animation(condition): ## you make a function to sort your kill "states" and the condition is well, the conditional
if wallContact: ## let's say you have logic that flips when you touch a wall
_aerial_wall_deathscene()
if wallContact and FloorContact:
_ground_Wall_deathscene()
## and so on and so on
Basically make functions for each "type" of death and logic to sort out what animation happens when.