Make a spell based off "Channel" ability, modify its fields so it targets unit, has description, etc.
Into "Data - Base order ID" set "holybolt", which is the order id of Holy Light spell.
The variables I used are:
- caster, target: variable of type "unit"
- amount: variable of type "real"
-
Holy Light
-
Events
-
Unit - A unit Starts the effect of an ability
-
Conditions
-
(Ability being cast) Equal to Holy Light (Custom)
-
Actions
-
Set caster = (Triggering unit)
-
Set target = (Target unit of ability being cast)
-
Set amount = (200.00 x (Real((Level of Holy Light (Custom) for caster))))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(target is Undead) Equal to True
-
Then - Actions
-
Unit - Cause caster to damage target, dealing amount damage of attack type Spells and damage type Normal
-
Else - Actions
-
Unit - Set life of target to ((Life of target) + (0.50 x amount))
-
Special Effect - Create a special effect attached to the origin of target using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
-
Special Effect - Destroy (Last created special effect)
This will make the spell deal "amount" damage to undead unit or 0,5* "amount" as a heal for living units.
Notice the calculation for amount. The function "level of ability for unit" returns an integer, but our "amount" variable is of type "real". To convert integer into real, you need to use the function "Conversion - Convert integer to real".
I left this trigger like this for reason, because I made another trigger, which checks the target of this ability when the caster is
ordered to go and cast this spell.
-
Holy Light Check
-
Events
-
Unit - A unit Is issued an order targeting an object
-
Conditions
-
(Issued order) Equal to (Order(holybolt))
-
(Level of Holy Light (Custom) for (Triggering unit)) Greater than 0
-
Actions
-
Set caster = (Triggering unit)
-
Set target = (Target unit of issued order)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(target belongs to an enemy of (Owner of caster)) Equal to True
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(target is Undead) Equal to False
-
Then - Actions
-
Unit - Order caster to Stop
-
-------- Display error message that you must target Undead units --------
-
Else - Actions
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(target belongs to an ally of (Owner of caster)) Equal to True
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(target is Undead) Equal to True
-
Then - Actions
-
Unit - Order caster to Stop
-
-------- Display error message that you must target Living units --------
-
Else - Actions
-
Else - Actions
This second trigger is the reason why you need to set the "Order ID" for the custom Holy Light to "holybolt", as it is one of the conditions.
This trigger may seem confusing as there are many If/Then/Else-s, but once understood, it is really simple.
1) The trigger checks, if the target is an enemy. If yes, it checks if that target is an undead. If the target is not undead, the spell has been cast on enemy living unit, which is not what Holy Light does, hence the caster will be stopped from even approaching the enemy.
2) The second part uses same logic but for an ally. It checks if the target is an ally and if yes, if it is not undead. If it is undead unit, the caster is stopped.
All you really have to do is put in a custom error message, telling to player that he has to target an undead in case 1), or a living in case 2).
You may want to search the forum/tutorial section for how to make custom error messages.