As far as I know: no, there is not a way to detect if spell killed a unit - when unit dies, the information about damage is not available.
You can, however, detect when unit takes damage - that happens before the damage is applied. At that point you can detect attack type and damage type.
The drawback is that attack and damage type comparisons are not available in GUI. You would need to use a little bit of JASS to get that. Also, you would need to correctly calculate if the damage unit is about to take will actually kill it (for example, you need to consider if unit has Runed Bracers ability, which reduces spell damage taken, etc.)
All of the above can be avoided if you use some damage detection system like Bribe's (
Damage Engine 5.9.0.0) which already gives you a nice access to the attack and damage type in GUI as well as event for detecting lethal damage dealt to unit.
But even then, you do not know for certain which spell killed the unit: if you want to summon a unit when another unit has been killed by a "specific" spell with lightning damage, then you will have a hard time.
Consider the following situation:
- Let's say you have a hero with 2 lightning abilities - one is a debuff that deals periodic lightning damage, the second spell is like chain lightning- it deals lightning damage immediately
- You want to summon a unit if any unit has been killed by the chain lightning spell
- Your hero casts the lightning debuff on a unit and then casts chain lightning on the unit, killing it
- Just based on the attack and damage type taken, how will you know which spell killed the unit? Was it the debuff or the chain lightning? Both have same attack and damage type
You can avoid these situations by making sure that the [attack type] and [damage type] of the spell is unique for the hero - that way you know for sure which spell killed it. Another option is to make the damage difference between the spells big enough that you just know if it was one spell or the other.
Edit: there may be also some other (more complicated) solutions to the dilemma, like caching the information that hero just casted that spell on that specific target. But if that is a viable solution depends on how the spell that summons unit actually works.