Use charm as the base skill. Make a unit variable and a player variable called MC_Unit and MC_Player. If you use other names make sure you update the variable names in the custom script lines below, but keep the udg_ prefix
If this doesn't work because the unit has already changed ownership due to Charm's cast you can use another event like begins casting to circumvent it, though it's not an ideal solution.
Events
Unit - A unit starts the effect of an ability
Conditions
(Ability being cast) equal to CONTROL
Actions
Custom script: local unit udg_MC_Unit
Custom script: local player udg_MC_Player
Set MC_Unit = (Target unit of ability being cast)
Set MC_Player = (Owner of MC_Unit)
Wait 10.00 game-time seconds
Unit - Change owner of MC_Unit to MC_Player and change color
-------- might not need these lines, but my suspicion is you will: --------
A prefix so you know what the variable is for. You could also make a LocalUnit, LocalPlayer, LocalPoint etc. variables that you just use for shadowing any time you need them.
Unit Group - Add Unit_MC to Group_MC[(Player number of (Owner of Unit_MC))]
Unit - Set the custom value of Unit_MC to 10
Unit - Change ownership of Unit_MC to (Owner of (Triggering unit)) and Change color
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Remaining time for Timer_MC) Greater than 0.00
Then - Actions
Do nothing
Else - Actions
Countdown Timer - Start Timer_MC as a One-shot timer that will expire in 1.00 seconds
Timer Trigger:
Timer MC
Events
Time - Timer_MC expires
Conditions
Actions
Set Boolean_MC = False
For each (Integer A) from 1 to 28, do (Actions)
Loop - Actions
Unit Group - Pick every unit in Group_MC[(Integer A)] and do (Actions)
Loop - Actions
Set Boolean_MC = True
Set Unit_MC = (Picked unit)
Unit - Set the custom value of Unit_MC to ((Custom value of Unit_MC) - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Custom value of Unit_MC) Less than or equal to 0
Then - Actions
Unit Group - Remove Unit_MC from Group_MC[(Integer A)]
Unit - Change ownership of Unit_MC to (Player((Integer A))) and Change color
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Boolean_MC Equal to True
Then - Actions
Countdown Timer - Start Timer_MC as a One-shot timer that will expire in 1.00 seconds
Else - Actions
PS: You can use this trigger with any unit target ability, just add a condition to filter which ability you want it to trigger on (like, stormbolt mind control, or w/e ^^).
The code I posted will work for groups, and from/to any player without leaks. It's just that if you use unit custom values in other triggers then it won't work since you can't use those for multiple purposes (which is why people end up using unit indexers).
Unit custom values are just a number that you can use that's attached to a unit (via triggers).
If you didn't use any with triggers, then you're not using any.
I'll get it done sometime later today.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.