What
@Chonky Dwarf wrote is correct. Each damage has attack type (normal, piercing, spells, hero,...) and damage type (normal, fire, sonic, ...).
When you deal damage via trigger, you can specify attack and damage type, like so:
-
Unit - Cause unit_a to damage unit_b, dealing 500.00 damage of attack type Spells and damage type Fire
As for object editor spells, those have hard-coded attack and damage type, so you cannot change it easily.
However it is possible to use the "Unit is about to take damage" event and in it you can change the attack and damage type.
For example this will change damage type to "Fire" for any spell damage done by Firelord:
-
Firelord Spell Damage
-

Events
-


Unit - A unit About to take damage
-

Conditions
-


(Unit-type of (Damage source)) Equal to Firelord
-


(Damage From Normal Attack) Equal to False
-

Actions
-


Event Response - Set Damage Type of Unit Damaged Event to Fire
You can also change attack/damage type for selected spells as long as you can identify them via damage amount and/or its original attack/damage type.
For example let's say I have a custom Shockwave spell that I want to deal "Lightning" damage type.
If only Mountain Kings have this custom spell and I know that this spell originally deals attack type "Spells" and damage type "Sonic" - and it is the only spell on Mountain King that does that, then I can just swap the damage type via trigger, like so:
-
Modified Shockwave
-

Events
-


Unit - A unit About to take damage
-

Conditions
-


(Unit-type of (Damage source)) Equal to Mountain King
-


(Damage From Normal Attack) Equal to False
-

Actions
-


Set VariableSet dmgType = (Damage Type)
-


Custom script: set udg_isSonicDamageType = udg_dmgType == DAMAGE_TYPE_SONIC
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




isSonicDamageType Equal to True
-



Then - Actions
-




Event Response - Set Damage Type of Unit Damaged Event to Lightning
-



Else - Actions
GUI triggers do not have conditions to compare damage type, so the comparison must be done via custom script.
However the above has one issue - the attack/damage pair of the spell must be unique for given unit.
For example Mountain King has Thunder Clap spell which also deals attack type Spells, damage type Sonic. So the above trigger would change Thunder Clap's damage type to Lightning as well, which may not be desired.
In such situations, comparing the amount of damage may help resolve which spell it is: Thunder clap deals for example 60.00 damage, while shockwave deals 75.00 damage, so I just compare if damage is > 74.50 and < 75.50 and if so, I can reasonable assume it is the Shockwave spell, so I can change the damage type.