• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Making Mind Rot autocast

Status
Not open for further replies.
Level 21
Joined
May 29, 2013
Messages
1,567
I'm trying to make the Mind Rot ability (ANmr) look and behave like an autocast ability, so I made a dummy ability based on Frenzy (Afzy) because it is never used when I set the Targets Allowed to Wall.

I want to detect when the dummy ability is manually used, replace it with the real Mind Rot and force the player to press its hotkey; and then switch back the two abilities when the unit stops or finishes casting Mind Rot.
  • Add Unit to Autocasting Group
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(frenzyon))
    • Actions
      • Unit Group - Add (Triggering unit) to AutocastingFrenzy
  • Remove Unit from Autocasting Group
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(frenzyoff))
    • Actions
      • Unit Group - Remove (Triggering unit) from AutocastingFrenzy
  • Unit Starts Casting
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Frenzy)
    • Actions
      • Unit - For (Triggering unit), Ability Mind Rot (Mind Rot), Hide ability: False
      • Unit - For (Triggering unit), Ability Mind Rot (Frenzy), Hide ability: True
      • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 50.00)
      • -------- ^This refunds the mana cost of the dummy ability --------
      • Wait 0.01 seconds
      • -------- ^It doesn't seem to work without this wait --------
      • Game - Force (Owner of (Triggering unit)) to press the key R
  • Unit Stops Casting
    • Events
      • Unit - A unit Stops casting an ability
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Mind Rot)
    • Actions
      • Unit - For (Triggering unit), Ability Mind Rot (Frenzy), Hide ability: False
      • Unit - For (Triggering unit), Ability Mind Rot (Mind Rot), Hide ability: True
  • Autocast Order
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
      • (Mana of (Attacking unit)) Greater than 30.00
    • Actions
      • Set MR_Point = (Position of (Attacked unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 600.00 of MR_Point) and do (Actions)
        • Loop - Actions
          • Set MR_Caster = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (MR_Caster is alive) Equal to True
              • (Level of Mind Rot (Frenzy) for MR_Caster) Greater than 0
              • (MR_Caster is in AutocastingFrenzy) Equal to True
              • (MR_Caster belongs to an ally of (Owner of (Attacked unit))) Equal to True
            • Then - Actions
              • Unit - For (Triggering unit), Ability Mind Rot (Mind Rot), Hide ability: False
              • Unit - For (Triggering unit), Ability Mind Rot (Frenzy), Hide ability: True
              • Custom script: call IssueTargetOrderById (udg_MR_Caster, 852565, GetAttacker())
            • Else - Actions
      • Custom script: call RemoveLocation(udg_MR_Point)
These triggers kinda work, but the unit is often left with the real ability instead of the dummy one (or even both of them) since I can't detect when the cast is cancelled before a target is selected (by clicking the cancel button, pressing the esc key or right-clicking anywhere).

Also, hiding and unhiding an ability messes up the cooldown indicator; the ability looks like it's ready for use even though it's actually on cooldown. I tried adding and removing the ability instead, but that seems even slower and more inconsistent.
 
Last edited:
Level 7
Joined
Oct 3, 2008
Messages
183
Hmm, sadly I don't think there is an auto-cast ability that takes mana in account for behaviour in game right now, otherwise I'd just suggest having say, a modified Curse with values set to 0 on your unit, and then when cast spawning a dummy caster that casts the actual mind rot, but then you won't have targeting preference towards units with mana.
 
Level 12
Joined
May 16, 2020
Messages
660
Regarding preference towards unit with mana: There are 2 abilities which would only activate based on if a unit with mana is nearby (Spirit Touch + Replenish Mana and Life). I guess the problem with them is that, even if you adjusted them to work for enemies, they won't automatically cast when the enemy is still at 100% mana...

Autocast

So like Atrella said, most likely this part would need to be omitted.
 
Level 21
Joined
May 29, 2013
Messages
1,567
I know there are no standard abilities that take mana in account the way I want, but I can't figure out how to make a trigger that orders the unit to cast Mind Rot when a nearby friendly unit is attacked by an enemy unit that has mana.
 
Level 12
Joined
May 16, 2020
Messages
660
Are you using Bribe's DamageEngine? If yes, maybe like this (I believe that should work):

  • Mind Rot Autocast
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource belongs to an enemy of (Owner of DamageEventTarget).) Equal to True
      • (Max Mana of DamageEventSource) Not equal to 0
    • Actions
      • Set VariableSet MR_Point = (Position of DamageEventTarget)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 600.00 of MR_Point.) and do (Actions)
        • Loop - Actions
          • Set VariableSet MR_Caster = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (MR_Caster is alive) Equal to True
              • (Level of Mind Rot for MR_Caster) Greater than 0
              • (MR_Caster belongs to an ally of (Owner of DamageEventTarget).) Equal to True
            • Then - Actions
              • Custom script: call IssueTargetOrderById (udg_MR_UnitTemp, 852565, udg_DamageEventSource)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_MR_Point)
This is not a true "autocast" ability though. The owner of mind rot will just be forced to cast it on enemies near him (with mana) who are attacking allies in a range 600.
 
Level 21
Joined
May 29, 2013
Messages
1,567
Are you using Bribe's DamageEngine?
I don't think it's needed for this spell. The "A unit is attacked" event is good enough for me.

I will probably have to use it for something in the future, but I've been avoiding it since it breaks some standard abilities.
This is not a true "autocast" ability though. The owner of mind rot will just be forced to cast it on enemies near him (with mana) who are attacking allies in a range 600.
I see; thanks for the help. Added triggers to the first post.
 
Level 12
Joined
May 16, 2020
Messages
660
These triggers kinda work, but the unit is often left with the real ability instead of the dummy one (or even both of them) since I can't detect when the cast is cancelled before a target is selected (by clicking the cancel button, pressing the esc key or right-clicking anywhere).

Just an idea: Why not delete the "stops" and "finishes" trigger and instead "hide/unhide" within the same trigger (after the 0.01 sec wait and after pressing r)?

Also, hiding and unhiding an ability messes up the cooldown indicator; the ability looks like it's ready for use even though it's actually on cooldown. I tried adding and removing the ability instead, but that seems even slower and more inconsistent.

Not sure which version you use, but in my version there is a "For X unit, Set cooldown of ability Y to ZZZ".
@Uncle can probably help here best.
 
Level 21
Joined
May 29, 2013
Messages
1,567
Just an idea: Why not delete the "stops" and "finishes" trigger and instead "hide/unhide" within the same trigger (after the 0.01 sec wait and after pressing r)?
I don't think that would work because the time it takes to select a valid target (after the player is forced to press the hotkey) is not 0.01 seconds; it's highly variable.
Not sure which version you use
1.29
"For X unit, Set cooldown of ability Y to ZZZ".
Thanks, I completely forgot about that action. I tried adding it to the end of the second trigger, but it still doesn't seem to work when autocasting is toggled on.

I'm also baffled by the inconsistencies with the mana cost and cooldown; sometimes they work as intended and sometimes they don't.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
On the newer patches you have greater control over things like. That being said maybe something like this this will work if I understood your goal correctly:

1) When your Mind Rot-caster is attacked and you find an eligible target, add the WALL classification to your caster and order it to cast Frenzy.
2) Remove the WALL classification from the caster a moment later as well as after the caster starts the effect of the ability. (Give it enough time to target itself with Frenzy)
3) Create and order a Dummy unit to cast Mind Rot on the target. This Dummy unit should have 0/99999 mana by default and 0 mana regen.
4) Add an X second Expiration Timer to the Dummy that is 0.01 seconds longer than Mind Rot's duration.
5) Keep track of your Dummy unit's mana and continuously add it to the Mind Rot-caster. Link the Dummy to the Caster using a Unit Indexer or Hashtable then add the Dummy to a Unit Group.
6) An example of periodically checking, adding, and resetting your Dummy's mana:
  • MR Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • -------- Using a Unit Indexer: --------
      • Unit Group - Pick every unit in MR_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set Variable MR_CV = (Custom value of (Picked unit))
              • Unit - Set mana of MR_Caster[MR_CV] to ((Mana of MR_Caster[MR_CV]) + (Mana of (Picked unit)))
              • Unit - Set mana of (Picked unit) to 0.00
            • Else - Actions
              • Unit Group - Remove (Picked unit) from MR_Group.
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in MR_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Obviously you could trigger the effects of Mind Rot yourself and avoid the Dummy unit but I figured there was a reason you wanted to use the real ability in all of this.

Edit: I realize that doesn't fix the issue with manual casting. Perhaps you could base the ability off of Curse, make it only target WALLS, and add the WALL classification to the target right before the ability is actually cast? I don't think that's possible on 1.29 though...
 
Last edited:
Level 21
Joined
May 29, 2013
Messages
1,567
@Uncle, I’m afraid I don’t follow you. Why do I need to add the Wall classification to the caster and why do I need a dummy unit?

Sorry if I wasn't clear in the original post; I'll try to explain it better.

As you probably already know, some abilities do not need to be manually activated by the player and can be set to be automatically cast by the unit when needed. Right-clicking on the ability icon toggles the ability on or off. When autocasting is toggled on the borders of the ability are highlighted, indicating that it will then be automatically cast by the computer when the unit encounters a situation that would call for the casting.

I'm trying to make a togglable ability that drains mana from an enemy unit (Mind Rot). When it is toggled on, the unit will cast it on nearby enemies that have a mana pool. If toggled off, the unit will not cast the ability unless manually ordered to do so by the player.

If Frenzy is toggled on, it is normally used every time the unit that has the ability is attacked, but I prevented this behavior by setting the "Stats - Targets Allowed" field to Wall, since I don't actually need it for anything else except for the borders of the button to be highlighted like all standard autocast abilities.

The reason why I used Frenzy (no target autocast) as a dummy ability instead of Curse, Slow, Faerie Fire or Parasite (unit target autocast) is because those abilities are automatically cast on all enemy units, not only on those that have mana.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
I wanted to avoid using "Force Hotkey" and juggling between 2 disabled/enabled abilities because those cause all sorts of unwanted side effects. But I overlooked the whole Manual Casting thing.

You'll probably need to use an Autocast ability that targets units for this to work smoothly, but how to do that I don't know yet. It can be done on 1.31+ without issue but not 1.29 as far as I'm aware.

If there was a unit-targetable Autocast ability that we could prevent the AI from casting that would fix all of the issues. This can actually be done by giving the target a permanent buff associated with the ability, since for example a unit's AI won't try to cast Curse on an already Cursed unit. Unfortunately, this would require you to give a permanent buff to every single unit... I doubt that's something you'd want.

Or if we could mimic the Autocast visual because that's all you're really after.
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
When your unit is attacked you look for a nearby enemy unit with mana, and order your attacked unit to cast Frost Armor on it. Or just order it to cast Frost Armor on the attacking unit.

Then you do what I said before using a Dummy unit / Loop to periodically drain the target's mana.

With this setup your caster only needs the Frost Armor ability and we can use it's Cooldown/Mana Cost without needing to toggle between 2 abilities. It also gets rid of the need for the Force Hotkey stuff.
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
Oh, I misunderstood how Mind Rot worked, I thought it DRAINED mana as in it siphoned it from the Target to the Caster... That makes things even easier, no need for a Loop/Unit Indexer.

Here's a working setup:
  • Mind Rot Toggle
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Level of Mind Rot (Autocast) for (Triggering unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(frostarmoron))
        • Then - Actions
          • Unit Group - Add (Triggering unit) to mr_isToggledOn
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(frostarmoroff))
            • Then - Actions
              • Unit Group - Remove (Triggering unit) from mr_isToggledOn.
            • Else - Actions
  • Mind Rot Autocast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Mind Rot (Autocast) for (Triggering unit)) Greater than 0
    • Actions
      • -------- If the attacked unit cannot cast Mind Rot (toggled off or on cooldown) then skip the rest of the trigger --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) is in mr_isToggledOn.) Equal to False
              • ((Triggering unit) is in mr_isOnCooldown.) Equal to True
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • Set VariableSet randomTarget = No unit
      • Set VariableSet point = (Position of (Triggering unit))
      • Set VariableSet group = (Units within 800.00 of point.)
      • -------- --------
      • -------- Remove unwanted units --------
      • Unit Group - Pick every unit in group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) is dead) Equal to True
                  • ((Picked unit) is A structure) Equal to True
                  • ((Picked unit) belongs to an ally of (Owner of (Triggering unit)).) Equal to True
                  • ((Picked unit) is invulnerable) Equal to True
                  • (Mana of (Picked unit)) Equal to 0.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from group.
            • Else - Actions
      • -------- --------
      • -------- Find a random unit from the group --------
      • Set VariableSet randomTarget = (Random unit from group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • randomTarget Not equal to No unit
        • Then - Actions
          • -------- Order our attacked unit to cast Mind Rot (Frost Armor) on the random target --------
          • Unit - Order (Triggering unit) to Undead Lich - Frost Armor randomTarget
        • Else - Actions
      • -------- --------
      • -------- Clean up leaks --------
      • Custom script: call DestroyGroup (udg_group)
      • Custom script: call RemoveLocation (udg_point)
  • Mind Rot Successful Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Autocast)
    • Actions
      • -------- Put the ability "on cooldown", preventing the Autocast trigger from happening again --------
      • Unit Group - Add (Triggering unit) to mr_isOnCooldown
      • -------- --------
      • -------- Create Dummy unit --------
      • Set VariableSet point = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy for (Triggering player) at point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_point)
      • -------- --------
      • -------- Setup Dummy unit --------
      • Unit - Add Mind Rot (Dummy) to (Last created unit)
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • -------- --------
      • -------- Order the Dummy to cast Mind Rot on the target unit of ability being cast --------
      • Custom script: call IssueTargetOrderById ( GetLastCreatedUnit(), 852565, GetSpellTargetUnit() )
      • -------- --------
      • -------- Cooldown is finished, allow the unit to autocast the ability again --------
      • Wait 5.00 seconds
      • Unit Group - Remove (Triggering unit) from mr_isOnCooldown.
If you don't want the Autocast trigger to find a Random Target from the Group then you can easily adjust it to instead cast Frost Armor on the Attacking unit.

Object Editor Requirements:
Mind Rot (Autocast) --- This is the ability your attacked unit will turn on/off, it's based on Frost Armor with Targets Allowed set to Enemies only
Mind Rot (Real) --- The actual Mind Rot ability that will be cast by our Dummy unit
Dummy --- The unit that will cast Mind Rot

Variables:
mr_isOnCooldown = Unit Group
mr_isToggledOn = Unit Group
point = Point
group = Unit Group
randomTarget = Unit

I attached an example map but it was made on the most recent patch.
 

Attachments

  • Mind Rot Autocast Fix.w3m
    20.8 KB · Views: 28
Last edited:
Level 21
Joined
May 29, 2013
Messages
1,567
I'm not on my PC so I can't test it right now, but it seems to me like the caster will only autocast in response to being attacked and I want it to also react when nearby friendly and allied units are attacked.

The "Must target a unit with mana" error message that appears when an invalid target is selected is another reason why I juggled between 2 disabled/enabled abilities, but it looks like the player won't get that error with these triggers.

Also, won't using waits prevent the ability from being MUI?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
Ah, well you can always make a fake error message. Also, you can make the Autocast ability any way you'd like, the concept is what's important.

Waits are fine if you're referencing local variables like Triggering Unit, it won't change to something else.
 
Level 21
Joined
May 29, 2013
Messages
1,567
Does anyone know why the autocasting doesn't work?

  • Mind Rot Toggle
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Level of Mind Rot (Autocast) for (Triggering unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(frostarmoron))
        • Then - Actions
          • Unit Group - Add (Triggering unit) to MR_isToggledOn
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(frostarmoroff))
            • Then - Actions
              • Unit Group - Remove (Triggering unit) from MR_isToggledOn
            • Else - Actions
  • Mind Rot Autocast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an enemy of (Owner of (Attacked unit))) Equal to True
      • (Mana of (Attacking unit)) Greater than 29.00
      • ((Attacking unit) is invulnerable) Equal to False
      • ((Attacking unit) is Magic Immune) Equal to False
      • ((Attacking unit) has buff Mind Rot (Custom)) Equal to False
    • Actions
      • Set MR_Attacker = (Attacking unit)
      • Set MR_VictimPoint = (Position of (Attacked unit))
      • Set MR_RandomCaster = No unit
      • Set MR_CasterGroup = (Units within 800.00 of MR_VictimPoint)
      • Unit Group - Pick every unit in MR_CasterGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) is in MR_isToggledOn) Equal to False
                  • ((Picked unit) is dead) Equal to True
                  • ((Picked unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False
                  • (Mana of (Picked unit)) Less than 50.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from MR_CasterGroup
            • Else - Actions
              • Set MR_RandomCaster = (Random unit from MR_CasterGroup)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MR_RandomCaster Not equal to No unit
                • Then - Actions
                  • Unit - Order MR_RandomCaster to Undead Lich - Frost Armor MR_Attacker
                • Else - Actions
      • Set MR_Attacker = No unit
      • Custom script: call DestroyGroup (udg_MR_CasterGroup)
      • Custom script: call RemoveLocation (udg_MR_VictimPoint)
  • Mind Rot Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Autocast)
    • Actions
      • Set MR_TargetPoint = (Position of (Target unit of ability being cast))
      • Unit - Create 1 MR_Dummy for (Triggering player) at MR_TargetPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_MR_TargetPoint)
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • Custom script: call IssueTargetOrderById ( GetLastCreatedUnit(), 852565, GetSpellTargetUnit() )
  • Mind Rot Stop
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Autocast)
      • (Mana of (Target unit of ability being cast)) Less than 1.00
    • Actions
      • Animation - Play (Triggering unit)'s stand animation
      • Unit - Order (Triggering unit) to Stop
      • Custom script: if udg_MR_ErrorSound == null then
      • Custom script: set udg_MR_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
      • Custom script: endif
      • Set MR_ErrorPlayer = (Owner of (Triggering unit))
      • Custom script: if GetLocalPlayer() == udg_MR_ErrorPlayer then
      • Custom script: call ClearTextMessages()
      • Custom script: call DisplayTimedTextToPlayer( udg_MR_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_MR_ErrorMessage+"|r" )
      • Custom script: call StartSound(udg_MR_ErrorSound)
      • Custom script: endif
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
Your Pick Every unit function is setup incorrectly. The way you're using the Else - Actions will order ANY unit, regardless of whether it has Mind Rot toggled on, to cast the ability. Also, you're never adding the Mind Rot ability to your Dummy unit, but you may have done this through the Object Editor instead. Make sure your Dummy unit is setup correctly, Movement Type = None, Speed Base = 0, Art-Cast Backswing/Point set to 0.00.

Here's a working setup, I added some new variables and adjusted it to help with performance:

Mind Rot Autocast is now set to Initially OFF, and is now only turned on when a unit actually has Mind Rot toggled on. This will help with performance since Mind Rot Autocast doesn't need to run when nobody is using the ability. This new Mind Rot Toggle trigger will manage the turning on/off of Mind Rot Autocast and I also use an Integer variable called mr_toggleCount to help keep track of the number of units with Mind Rot Autocast enabled. This is a minor performance increase.
  • Mind Rot Toggle
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Level of Mind Rot (Autocast) for (Triggering unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(frostarmoron))
        • Then - Actions
          • Unit Group - Add (Triggering unit) to mr_isToggledOn
          • Set VariableSet mr_toggleCount = (mr_toggleCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • mr_toggleCount Equal to 1
            • Then - Actions
              • Trigger - Turn on Mind Rot Autocast <gen>
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(frostarmoroff))
            • Then - Actions
              • Unit Group - Remove (Triggering unit) from mr_isToggledOn.
              • Set VariableSet mr_toggleCount = (mr_toggleCount - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • mr_toggleCount Equal to 0
                • Then - Actions
                  • Trigger - Turn off Mind Rot Autocast <gen>
                • Else - Actions
            • Else - Actions
I totally restructured this trigger. I added some new Unit Groups like mr_alreadyTargeted to prevent units from getting targeted multiple times. This way the Mind Rot buffs are spread out amongst the enemies instead of sometimes getting focused on one single target.
  • Mind Rot Autocast
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set VariableSet mr_player = (Owner of (Triggering unit))
      • Set VariableSet mr_points[0] = (Position of (Triggering unit))
      • Set VariableSet mr_casters = (Units within 800.00 of mr_points[0].)
      • -------- --------
      • -------- Find nearby allied units with Mind Rot (autocast enabled) --------
      • Unit Group - Pick every unit in mr_casters and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in mr_isOnCooldown.) Equal to False
              • ((Picked unit) is in mr_isToggledOn.) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an ally of mr_player.) Equal to True
              • (Mana of (Picked unit)) Greater than or equal to 50.00
            • Then - Actions
              • Set VariableSet mr_pickedAlly = (Picked unit)
              • Set VariableSet mr_randomTarget = No unit
              • Set VariableSet mr_points[1] = (Position of mr_pickedAlly)
              • Set VariableSet mr_targets = (Units within 800.00 of mr_points[1].)
              • -------- --------
              • -------- Remove unwanted units from mr_targets, these are the units that will get targeted by Mind Rot --------
              • Unit Group - Pick every unit in mr_targets and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • ((Picked unit) is alive) Equal to False
                          • ((Picked unit) belongs to an ally of mr_player.) Equal to True
                          • (Mana of (Picked unit)) Less than 30.00
                          • (Max mana of (Picked unit)) Equal to 0.00
                          • ((Picked unit) has buff Mind Rot (Real)) Equal to True
                          • ((Picked unit) is in mr_alreadyTargeted.) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from mr_targets.
                    • Else - Actions
              • -------- --------
              • -------- Order our allied unit to cast Mind Rot on a random eligible target --------
              • Set VariableSet mr_randomTarget = (Random unit from mr_targets)
              • Unit Group - Add mr_randomTarget to mr_alreadyTargeted
              • Unit - Order mr_pickedAlly to Undead Lich - Frost Armor mr_randomTarget
              • -------- --------
              • -------- Clean up leaks --------
              • Custom script: call DestroyGroup (udg_mr_targets)
              • Custom script: call RemoveLocation (udg_mr_points[1])
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in mr_casters) Greater than 0
        • Then - Actions
          • -------- Clean up leaks --------
          • Unit Group - Remove all units from mr_alreadyTargeted.
          • Custom script: call DestroyGroup (udg_mr_casters)
          • Custom script: call RemoveLocation (udg_mr_points[0])
          • -------- --------
          • -------- Prevent the trigger from spamming --------
          • Trigger - Turn off Mind Rot Autocast <gen>
          • Wait 0.75 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • mr_toggleCount Greater than 0
            • Then - Actions
              • Trigger - Turn on Mind Rot Autocast <gen>
            • Else - Actions
        • Else - Actions
          • -------- Clean up leaks --------
          • Unit Group - Remove all units from mr_alreadyTargeted.
          • Custom script: call DestroyGroup (udg_mr_casters)
          • Custom script: call RemoveLocation (udg_mr_points[0])
mr_isOnCooldown is important in preventing units that can't cast Mind Rot (because it's on cooldown) from being Picked in the Autocast trigger:
  • Mind Rot Successful Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Rot (Autocast)
    • Actions
      • -------- Start Cooldown: --------
      • Unit Group - Add (Triggering unit) to mr_isOnCooldown
      • -------- --------
      • -------- Create Dummy unit --------
      • Set VariableSet mr_points[2] = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy for (Triggering player) at mr_points[2] facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_mr_points[2])
      • -------- --------
      • -------- Setup Dummy unit --------
      • Unit - Add Mind Rot (Dummy) to (Last created unit)
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • -------- --------
      • -------- Order the Dummy to cast Mind Rot on the target unit of ability being cast --------
      • Custom script: call IssueTargetOrderById ( GetLastCreatedUnit(), 852565, GetSpellTargetUnit() )
      • -------- --------
      • -------- Wait for the cooldown to finish: --------
      • Wait 5.00 seconds
      • Unit Group - Remove (Triggering unit) from mr_isOnCooldown.
New Variables:
mr_points = Point (Array)
mr_alreadyTargeted = Unit Group
mr_toggleCount = Integer
mr_player = Player
mr_pickedAlly = Unit
mr_casters = Unit Group
mr_targets = Unit Group
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,458
No problem, glad it worked.

One thing you may want to change is the Conditions in Mind Rot Autocast, as of right now it's running whenever any unit is attacked, and creating a point/unit group each time. I can't think of an easy way of handling this.

Maybe some sort of Aura and buff check?

A unit is attacked -> If attacked unit has the buff: Mind Rot Aura -> Proceed with the rest of the trigger.

And all of the units with the Mind Rot ability would emit this aura. This way you know for a fact that any unit with this buff is near a unit that has the Mind Rot ability.
 
Last edited:
Level 21
Joined
May 29, 2013
Messages
1,567
One thing you may want to change is the Conditions in Mind Rot Autocast, as of right now it's running whenever any unit is attacked, and creating a point/unit group each time.
What about my initial conditions (below)? It's better to add them than leave the trigger with no conditions, right?
  • Mind Rot Autocast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an enemy of (Owner of (Attacked unit))) Equal to True
      • (Mana of (Attacking unit)) Greater than 29.00
      • ((Attacking unit) is invulnerable) Equal to False
      • ((Attacking unit) is Magic Immune) Equal to False
      • ((Attacking unit) has buff Mind Rot (Custom)) Equal to False
Maybe some sort of Aura and buff check?
I would use this if there was a way for units to have a buff without it being visible.
 
Status
Not open for further replies.
Top