You use this Event to detect that a unit is PREPARING to cast an ability, it's like the wind-up:
-
Unit - A unit Begins casting an ability
Then you use this Event to detect that a unit has SUCCESSFULLY cast an ability:
-
Unit - A unit Starts the effect of an ability
You should NOT be using "Begins casting" if you're trying to detect a successful cast. An ability beginning it's cast can be interrupted, preventing it from spending mana, going on cooldown, launching it's effects, etc. However, it'll still trigger the "Begins casting" Event. This is easily exploitable, causes bugs, and not what you want
MOST of the time.
But if I understand your situation then here's a setup that would work nicely:
1) Make sure your Magic Box unit has an Art - Cast Point of 0.01 and an Art - Cast Backswing of 0.00. Modify these values in the Object Editor, they're at the very top. These values represent how long the unit prepares an ability (Cast Point) and how long a unit continues playing it's spell animation after a successful cast (Backswing).
2) Let's create a little system for these Item Combinations. Hopefully this isn't too complicated. Start by creating the Variables and the Triggers.
3) First let's have a central trigger for detecting the usage of Transmute Items:
-
Transmute Box Begins
-

Events
-


Unit - A unit Begins casting an ability
-

Conditions
-


(Ability being cast) Equal to Transmute Items
-

Actions
-


Set Magic_Box_Unit = (Triggering unit)
-


-------- --------
-


-------- The Magic_Box_Outcome variable represents the different possible outcomes: --------
-


-------- 1 = Successful item transmutation (combined 2 or more items). --------
-


-------- 2 = Not enough items (box has less than 2 items). --------
-


-------- 3 = No item combinations found (had enough items, but no matches). --------
-


-------- --------
-


-------- Default it to 3, it will be modified throughout the rest of these triggers: --------
-


Set Magic_Box_Outcome = 3
-


-------- --------
-


-------- Try to combine items: --------
-


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



If - Conditions
-




(Number of items carried by Magic_Box_Unit) Greater than 1
-



Then - Actions
-




Trigger - Run Transmute Box Check Items <gen> (ignoring conditions)
-



Else - Actions
-




-------- It has less than 2 items: --------
-




Set Magic_Box_Outcome = 2
-


-------- --------
-


-------- Determine the final outcome based on the previous actions: --------
-


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



If - Conditions
-




Magic_Box_Outcome Equal to 1
-



Then - Actions
-




-------- [SUCCESS] --------
-




Trigger - Run Transmute Box Success <gen> (ignoring conditions)
-



Else - Actions
-




-------- [FAILURE] --------
-




Trigger - Run Transmute Box Failure <gen> (ignoring conditions)
We're splitting things up into multiple triggers to keep it nice and organized. We take advantage of Variables to track what's happening at the different stages and Run the appropriate triggers whenever necessary.
4) This
Check Items trigger is a central place for us to Run our different types of item combinations (like Potion of Restoration). So you'd end up adding every single type of combination in here. I made a new one, Belt of Giant Strength, as part of the example:
-
Transmute Box Check Items
-

Events
-

Conditions
-

Actions
-


-------- Try to transmute the items in the magic box: --------
-


Trigger - Run Transmute Potion of Restoration <gen> (checking conditions)
-


Trigger - Run Transmute Belt of Giant Strength <gen> (checking conditions)
5) This is a modified version of your
Potion of Restoration trigger. It's no longer dealing with the actual Creation/Removal/Special Effects, instead it simply sets a bunch of variables that will tell the system what to do next.
-
Transmute Potion of Restoration
-

Events
-

Conditions
-


Magic_Box_Outcome Not equal to 1
-

Actions
-


-------- Define what item-types will be created and removed to make this combination: --------
-


Set Magic_Box_Created_Item = Potion of Restoration
-


Set Magic_Box_Removed_Item[1] = Potion of Mana
-


Set Magic_Box_Removed_Item[2] = Potion of Healing
-


-------- --------
-


-------- Check if the magic box has these items: --------
-


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



If - Conditions
-




(Magic_Box_Unit has an item of type Magic_Box_Remove_Item[1]) Equal to True
-




(Magic_Box_Unit has an item of type Magic_Box_Remove_Item[2]) Equal to True
-



Then - Actions
-




-------- This tells the system that it was a success and that we can move on: --------
-




Set Magic_Box_Outcome = 1
-



Else - Actions
6) Once that's all said and done we will either Run the
Success trigger or the
Failure trigger, depending on the final outcome.
Success:
-
Transmute Box Success
-

Events
-

Conditions
-

Actions
-


-------- Items were successfully transmuted. --------
-


-------- --------
-


Set Magic_Box_Point = (Position of Magic_Box_Unit)
-


Special Effect - Create a special effect at Magic_Box_Point using Abilities\Spells\Other\Charm\CharmTarget.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call RemoveLocation( udg_Magic_Box_Point )
-


-------- --------
-


Item - Remove (Item carried by Magic_Box_Unit of type Magic_Box_Removed_Item[1])
-


Item - Remove (Item carried by Magic_Box_Unit of type Magic_Box_Removed_Item[2])
-


Hero - Create Magic_Box_Created_Item and give it to Magic_Box_Unit
Failure:
-
Transmute Box Failure
-

Events
-

Conditions
-

Actions
-


-------- Items failed to transmute. --------
-


-------- --------
-


-------- Determine your error messages: --------
-


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



If - Conditions
-




Magic_Box_Outcome Equal to 2
-



Then - Actions
-




Set Magic_Box_Error_Message = Not enough items!
-



Else - Actions
-




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





If - Conditions
-






Magic_Box_Outcome Equal to 3
-





Then - Actions
-






Set Magic_Box_Error_Message = No combinations found!
-





Else - Actions
-


-------- --------
-


-------- Display error message to the casting player: --------
-


Set Magic_Box_PG = (Player group((Owner of Magic_Box_Unit)))
-


Game - Display to Magic_Box_PG for 4.00 seconds the text: Magic_Box_Error_Message
-


Custom script: call DestroyForce( udg_Magic_Box_PG )
-


-------- --------
-


-------- Cancel the ability being cast: --------
-


Unit - Order Magic_Box_Unit to Stop.
Here are all of the Variables used:
View attachment 507753