[Solved] empty

Status
Not open for further replies.
Level 42
Joined
Feb 27, 2007
Messages
5,273
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: --------
    • Custom script: set udg_MC_Unit = null
    • Custom script: set udg_MC_Player = null
 
Last edited:
Level 11
Joined
Feb 23, 2009
Messages
577
This trigger will not be MUI btw, not sure if it will be a problem, but if more than one unit is mind controlled it will run into bugs.

To fix it you need to use a unit ID (or unit custom values for simplified version) to remember it's own timer and it's original player.

-

Example using custom value as remaining seconds for timer, and group index to locate original player (this is very simplified but works):

Requires Variables:

Boolean: Boolean_MC
Unit Group: Group_MC (Array, 28)
Timer: Timer_MC
Unit: Unit_MC (Optional)


Cast Trigger:
  • Cast MC
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Unit_MC = (Target unit of ability being cast)
      • 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 ^^).
 
Last edited by a moderator:
Level 42
Joined
Feb 27, 2007
Messages
5,273
There’s no reason to make something THAT complex if it’s not MUI, ThisPOT.... This accomplishes the same exact thing with 5 lines and no timer:

  • ...
  • Actions
    • Set Unit = (Target unit of ability being cast)
    • Set Player = (Owner of Unit)
    • Unit - Change owner of Unit to (Triggering Player) without changing color
    • Wait 10.00 game-time seconds
    • Unit - Change owner of Unit to Player without changing color
 
Level 11
Joined
Feb 23, 2009
Messages
577
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).
 
Status
Not open for further replies.

Similar threads

Replies
3
Views
896
Replies
9
Views
1K
Replies
9
Views
1K
  • Locked
  • Poll
[Solved] empty
Replies
6
Views
1K
Replies
4
Views
848
Top