Ok first of all you need 3 triggers to make this work successfully. You also need to make 4 variables:
1 . SpellCopied(Array) = Ability variable array with a max of 2
2. SpellsCopied = Integer variable (No array)
3. SpellCopierUnit = Unit variable (No array)
4. SpellCopiedTimer(Array) = Timer variable array with a max of 2
Ok, so your first trigger should be this:
Trigger 1
-
Events
-
Unit - A unit starts the effect of an ability
-
Conditions
-
Actions
-

Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Triggering Unit)) matching (((Matching Unit) has buff YourCopySpell) Equal to True and do (Actions)
-

Loop - Actions
-


Unit - Add (Ability being cast) to (Picked Unit)
-


Set SpellCopierUnit = (Picked Unit)
-


Set SpellsCopied = (SpellsCopied +1)
-


Set SpellCopied[SpellsCopied] = (Ability being cast)
-


Countdown Timer - Start SpellCopiedTimer[SpellsCopied] as a One-shot timer that will expire in 30.00 seconds
-


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


If - Conditions
-


Then - Actions
-



Trigger - Turn off (This trigger)
-



Wait 30.00 seconds
-



Trigger - Turn on (This trigger)
-


Else - Actions
Second Trigger:
-
Events
-
Time - SpellCopiedTimer[1] expires
-
Conditions
-
Actions
-
Unit - Remove SpellCopied[1] from SpellCopierUnit
-
Set SpellsCopied = (SpellsCopied - 1)
Third trigger is similar to the second
-
Events
-
Time - SpellCopiedTimer[2] expires
-
Conditions
-
Actions
-
Unit - Remove SpellCopied[2] from SpellCopierUnit
-
Set SpellsCopied = (SpellsCopied - 1)
The last thing you need to do is put
-
Set SpellsCopied = 0
in one of your map initialization triggers.
I did not test this, but it should work. This is how it will basically function:
When the map initializes, it will set the integer variable SpellsCopied to 0. Once someone playing the map gains the buff that copies spells and someone cast a spell within 1200 units of him, that spell will be stored as SpellCopied[1], the unit who stole the spell will be set as SpellCopierUnit, and a timer SpellCopiedTimer[1] will be created and start counting down from 30 seconds, and after the 30 seconds expire the second trigger will function and remove SpellCopied[1] from the unit, and it will also subtract 1 from SpellsCopied so the game recognizes that you have one less copied spell currently learned.
Then, when a second spell is cast while the unit still has your spell copying buff, it will do the same thing it did with SpellCopied[1] except it will be SpellCopied[2]. The only difference with this is that the first trigger will recognize that you have copied 2 spells, and it will disable itself for 30 seconds using that wait action. (You can change how long it disables itself based on how long you want before the unit can copy spells again)
This should work, and i did not check for leaks.