I have made a spell that is supposed to make target unit asleep for a random time depending on the spell level. Here's my trigger:
The problem is that when waiting time is too long, the buff isn't removed. Is there any other option than using wait function? The spell must remain MUI.
Code:
Sleep
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
Custom script: local unit t = GetSpellTargetUnit()
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Hypnosis
(Random integer number between 1 and 100) Less than or equal to 80
Then - Actions
Unit - Create 1 caster for (Owner of (Casting unit)) at (Position of (Target unit of ability being cast)) facing Default building facing degrees
Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
Unit - Hide (Last created unit)
Unit - Add sleep to (Last created unit)
Custom script: call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", t )
Wait (1.00 + ((Real((Level of Hypnosis for (Triggering unit)))) x (Random real number between 1.00 and 5.00))) seconds
Custom script: call UnitRemoveBuffBJ( 'B00H', t )
Else - Actions
Custom script: set t = null