Set experience gained for kill to 0 (at game constats). Then make a recipe which converts unit level to exp. Example:
==========
For solo RPG
==========
Even - Unit dies
Set exp = MAX(0,(Level of unit (dying unit)) - (Level of (killing unit))).
Add experience - Add exp experience to killing unit.
==========
For multi RPG
==========
Even - Unit dies
Set exp = MAX(0,(Level of unit (dying unit)) - (Level of (killing unit))).
Pick every unit in reange of 800 of dying unit
-If picked unit is hero = true then
--Add experience - Add exp experience to picked unit.
==========
For melees
==========
Even - Unit dies
Pick every unit in range of 1000 of dying unit
-If picked unit is hero = true then
--Set exp = MAX(0,(Level of unit (dying unit)) - (Level of (picked unit))).
--Add experience - Add exp experience to picked unit.