This should be easy. Every time a hero attack an enemy unit, he has a chance to receive mana. Code below:
And
-
Manaverage
-

Events
-


Unit - A unit Is attacked
-
-

Conditions
-


(Unit-type of (Attacking unit)) Equal to Demon Warlock
-
-

Actions
-


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



If - Conditions
-




(Level of Manaverage for DemonWarlock) Equal to 1
-
-



Then - Actions
-




Set Manaverage = (Random integer number between 1 and 100)
-




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





If - Conditions
-






Manaverage Less than or equal to 15
-
-





Then - Actions
-






Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 20.00)
-






Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
-






Special Effect - Destroy (Last created special effect)
-
-





Else - Actions
-
-
-



Else - Actions
-
-


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



If - Conditions
-




(Level of Manaverage for DemonWarlock) Equal to 2
-
-



Then - Actions
-




Set Manaverage = (Random integer number between 1 and 100)
-




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





If - Conditions
-






Manaverage Less than or equal to 30
-
-





Then - Actions
-






Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 40.00)
-






Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
-






Special Effect - Destroy (Last created special effect)
-
-





Else - Actions
-
-
-



Else - Actions
-
-


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



If - Conditions
-




(Level of Manaverage for DemonWarlock) Equal to 3
-
-



Then - Actions
-




Set Manaverage = (Random integer number between 1 and 100)
-




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





If - Conditions
-






Manaverage Less than or equal to 45
-
-





Then - Actions
-






Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + 60.00)
-






Special Effect - Create a special effect attached to the origin of (Attacking unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
-






Special Effect - Destroy (Last created special effect)
-
-





Else - Actions
-
-
-



Else - Actions
-
-
-
-
Set DemonWarlock = (Attacking unit)
And
-
Set Manaverage = (Random integer number between 1 and 100)



