@Div_S: That's a nice spell, a bit like Anti-Mage's Mana Void.. The concept is OK and the spell is a bit imbalanced.
However, the triggering is lacking.
Effect
Events
Unit - A unit Is attacked
Conditions
((Attacking unit) has buff Voiding Blade (Effect)) Equal to True
Actions
Set Caster = (Attacking unit)
Set Target = (Attacked unit)
Trigger - Turn on Damage
Set Chance = (Random integer number between 1 and 100)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Chance Less than or equal to 27
Then - Actions
Unit - Cause Caster to damage Target, dealing (((Max mana of Target) - (Mana of Target)) x 0.50) damage of attack type Chaos and damage type Normal
Wait 0.10 seconds
Special Effect - Create a special effect at (Position of Target) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
Set Burst = (Last created special effect)
Wait 0.20 seconds
Special Effect - Destroy Burst
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Feedback for Caster) Equal to 1
Then - Actions
Unit - Set mana of Target to ((Mana of Target) - 5.00)
Unit - Cause Caster to damage Target, dealing 5.00 damage of attack type Hero and damage type Normal
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Feedback for Caster) Equal to 2
Then - Actions
Unit - Set mana of Target to ((Mana of Target) - 10.00)
Unit - Cause Caster to damage Target, dealing 10.00 damage of attack type Hero and damage type Normal
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Feedback for Caster) Equal to 3
Then - Actions
Unit - Set mana of Target to ((Mana of Target) - 15.00)
Unit - Cause Caster to damage Target, dealing 15.00 damage of attack type Hero and damage type Normal
Else - Actions
Do nothing
Instead of all this code, you could have had this:
function Trig_Effect_Conditions takes nothing returns boolean
return UnitHasBuff(GetAttacker(), 'B001')
endfunction
function Trig_Effect_Actions take nothing returns nothing
local unit u = GetAttacker()
local unit t = GetAttackedUnit()
local integer i = GetRandomInt(1,100)
local effect fx = "Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl"
local integer lvl = GetUnitAbilityLevel(u, 'A001')
call UnitDamageTarget( u, t, ( ( ( GetUnitStateSwap(UNIT_STATE_MAX_MANA, t) - GetUnitStateSwap(UNIT_STATE_MANA, t) ) * 0.50 ) + (5 * lvl ) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
call SetUnitMana( t, ( GetUnitStateSwap(UNIT_STATE_MANA, t) - ( 5.00 * lvl) ) )
call TriggerSleepAction( 0.25 ) //The wait function does not use values smaller than 0.25. If you put 0.10 in the Wait action, it will consider it as 0.25.
call AddSpecialEffectLoc( GetUnitLoc(t), fx)
call TriggerSleepAction( 0.25 )
call DestroyEffect( fx )
set fx = null
set u = null
set t = null
@Zalvurek: The variables are used instead of values to prevent memory leaks.