[Solved] Auto Cast wont work on building but will manually?

Level 3
Joined
May 11, 2009
Messages
32
Im trying to get an autocast spell(Im using Fairy Fire) to autocast and take mana to spawn a unit from the building, but it wont fire and go on cooldown. This becomes even stranger because I can manually cast it on the building and the trigger see's it and fires fine.

I tried changing from (Self, Structure) to (Player Units) and put a unit nearby and it worked fine but it will not cast on the building while autocast is on.

How do I fix this or what have I done wrong?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Abilities have hardcoded behavior, it can be difficult to get them to behave the way you want.

I personally dislike this Autocast solution and would just trigger everything myself but I understand the desire for something simple.
  • Frenzy is a good ability if you need the building to cast an ability during combat. No targets required, Autocasting.
  • Bloodlust might be a good alternative, it'll definitely target Self without issues.
  • Inner Fire comes to mind as well.
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
Faerie fire would only autocast when the building is attacking an enemy so that's unlikely, you can try with the obsidian statue spell that restores mana, but I've tried it once and it's finnicky to make it autocast on self all the time
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
This may have been completely unnecessary or already possible in an easier way - but I created an Autocast system for summoning units automatically.

It relies on the Carrion Beetles ability and some Triggers to automatically generate hidden corpses which then get consumed by the ability to summon whatever you want. It's meant to be paired with buildings or any unit that doesn't move since the corpse is spawned "inside" of the caster.

You could customize the Carrion Beetles ability to modify what gets summoned, and/or take advantage of this trigger:
  • AS Summon Units
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Level of AS_Ability_Type for (Summoning unit)) Greater than 0
    • Actions
      • Set VariableSet AS_Caster = (Summoning unit)
      • -------- --------
      • -------- The summoned unit uses the (Summoned unit) Event Response: --------
      • Unit - Add classification of Summoned to (Summoned unit)
      • Unit - Add a 60.00 second Generic expiration timer to (Summoned unit)
Edit: Attached a new version of the map in one of my later posts down below (v2). It fixed some important issues.
 
Last edited:
Level 12
Joined
Jul 5, 2014
Messages
551
This may have been completely unnecessary or already possible in an easier way - but I created an Autocast system for summoning units automatically.

It relies on the Carrion Beetles ability and some Triggers to automatically generate hidden corpses which then get consumed by the ability to summon whatever you want. It's meant to be paired with buildings or any unit that doesn't move since the corpse is spawned "inside" of the caster.

You could customize the Carrion Beetles ability to modify what gets summoned, and/or take advantage of this trigger:
  • AS Summon Units
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Level of AS_Ability_Type for (Triggering unit)) Greater than 0
    • Actions
      • Set VariableSet AS_Caster = (Triggering unit)
      • -------- --------
      • -------- The summoned unit uses the (Summoned unit) Event Response: --------
      • Unit - Add classification of Summoned to (Summoned unit)
      • Unit - Add a 60.00 second Generic expiration timer to (Summoned unit)
Wouldn't enemy necromancers be able to take advantage on that?
 
Level 3
Joined
May 11, 2009
Messages
32
I like this idea of a channeled ability, Im getting nowhere with autocast, I would try this carrion thing but the there will be necromancers and maybe in mass so theres a chance to be softlocked out of units if they get in range of your base, what would be the best channeling ability to use and whats the max time I can channel for so that it appears as if its always on.

So like it would need to be a channel (only one ability can be channeled at a time right?) and you would lose mana during the channel.

I cant seem to use the Quote button, it says added to multi-quote and does nothing.
 
Last edited:
Level 12
Joined
Jul 5, 2014
Messages
551
I like this idea of a channeled ability, Im getting nowhere with autocast, I would try this carrion thing but the there will be necromancers and maybe in mass so theres a chance to be softlocked out of units if they get in range of your base, what would be the best channeling ability to use and whats the max time I can channel for so that it appears as if its always on.
Channel is a dummy ability. It does nothing on its own but it's versatile. It can be set to mimic targeted, area and instant abilities. You can also set the length of the casting animation (Illidan used this while closing Magtheridon's gates).

I don't have the game in front of me, so I'll tell the basic idea: you make two custom ability based on channel (it's a hero ability). You give one to the building under the name of "automatic summoning" or something. You make a trigger that recognizes its use and when you use it, it switches the channel ability to the second one which is the "deactivate autocast". It also turns on a trigger that makes the building use the summon ability every time it has enough mana. Clicking the "deactivate autocast" switches it back to the "activate autocast" and turns off the summon trigger.

It's more tricky if you have more of these buildings though.
 
Level 3
Joined
May 11, 2009
Messages
32
Channel is a dummy ability. It does nothing on its own but it's versatile. It can be set to mimic targeted, area and instant abilities. You can also set the length of the casting animation (Illidan used this while closing Magtheridon's gates).

I don't have the game in front of me, so I'll tell the basic idea: you make two custom ability based on channel (it's a hero ability). You give one to the building under the name of "automatic summoning" or something. You make a trigger that recognizes its use and when you use it, it switches the channel ability to the second one which is the "deactivate autocast". It also turns on a trigger that makes the building use the summon ability every time it has enough mana. Clicking the "deactivate autocast" switches it back to the "activate autocast" and turns off the summon trigger.

It's more tricky if you have more of these buildings though.
Well Im looking for this to be a universal spell for all 8 players with alot of buildings for every unit in melee, so yea once I get the ability and trigger right it will be copied 50 times. but thats better than making 1000 triggers for each unit, location and race. Um I'll give it a look, I lost focus while reading halfway through but it seems pretty straight forward, worrying comments at the end but I'll give it a shot.
 
Level 12
Joined
Jul 5, 2014
Messages
551
Well Im looking for this to be a universal spell for all 8 players with alot of buildings for every unit in melee, so yea once I get the ability and trigger right it will be copied 50 times. but thats better than making 1000 triggers for each unit, location and race. Um I'll give it a look, I lost focus while reading halfway through but it seems pretty straight forward, worrying comments at the end but I'll give it a shot.
I doubt you'd need 50 triggers. If you don't want the buildings to have the ability of individually turn on and off autocast but it applies to all, then it's much easier. It's even easier if you don't want the buildings to have a deactivated autocast. Because then, all you need is a single trigger for the unit-type to cast the spell if it has enough mana.
 
Level 3
Joined
May 11, 2009
Messages
32
I doubt you'd need 50 triggers. If you don't want the buildings to have the ability of individually turn on and off autocast but it applies to all, then it's much easier. It's even easier if you don't want the buildings to have a deactivated autocast. Because then, all you need is a single trigger for the unit-type to cast the spell if it has enough mana.
Oh yea I forgot you can do if/then/else and just list all units one by one over and over.

I'd probably still split it into 4 triggers, one per race just so I can find everything faster.
 
Level 3
Joined
May 11, 2009
Messages
32
I got it working, Any suggestions going forward? Thanks for the help, this trigger took me like 50 attempts over the past 10 years, finally got it working.
 

Attachments

  • Screenshot_2.png
    Screenshot_2.png
    10.8 KB · Views: 7
Level 3
Joined
May 11, 2009
Messages
32
Just my luck, now Im having issues turning the spell off, If I turn "Disable other Abilities" off then it will fire all units at once which I dont want and I cant turn it off.

But if I set it to true then I get a black loadout on the building and cant disable the channel.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
  • "Center of (Region centered at (Position of (Triggering Unit)) with size..." is unnecessarily convoluted and causes two points and a region (rect) to leak. Just use Position of (Triggering Unit) directly. And clean it up.
  • That condition will fail if any other unit casts any spell anywhere on the map during the Wait. Ability Being Cast functions as a global variable, not a local.
The whole reason you have to do any of this that Faerie Fire won't autocast on the building. So just pick a different autocast ability that has better behavior. Here is an okay resource explaining some of the triggers for AI to cast abilities. A better place to look (with many more words) is the WC3 Ability Insight Document, which explains why FF wasn't working for you:
KitsuneTailsPower said:
However, Both Curse and Faerie Fire will only auto cast on targets that can attack.
So you could try to place a nearby unit that the building can cast on, give the building itself an attack (maybe with 0 targets allowed or with Cargo Hold you can disable the display of the attack on the UI but allow the autocasting to work properly), or find some other solution in that vein. I would also look through the other Autocast-flagged abilities and see what other behavior you could manipulate.

The solution you're trying to do here with the trigger is... messy and has edge cases just like Uncle's example system does.
 
Last edited:
Level 3
Joined
May 11, 2009
Messages
32
  • "Center of (Region centered at (Position of (Triggering Unit)) with size..." is unnecessarily convoluted and causes two points and a region (rect) to leak. Just use Position of (Triggering Unit) directly. And clean it up.
  • That condition will fail if any other unit casts any spell anywhere on the map during the Wait. Ability Being Cast functions as a global variable, not a local.
The whole reason you have to do any of this that Faerie Fire won't autocast on the building. So just pick a different autocast ability that has better behavior. Here is an okay resource explaining some of the triggers for AI to cast abilities. A better place to look (with many more words) is the WC3 Ability Insight Document, which explains why FF wasn't working for you:

So you could try to place a nearby unit that the building can cast on, give the building itself an attack (maybe with 0 targets allowed or with Cargo Hold you can disable the display of the attack on the UI but allow the autocasting to work properly), or find some other solution in that vein. I would also look through the other Autocast-flagged abilities and see what other behavior you could manipulate.

The solution you're trying to do here with the trigger is... messy and has edge cases just like Uncle's example system does.
Ok, so I fixed the trigger.

I've gone back to finding a suitable Auto-Cast ability.

I'm currently trying to place a dummy Gold mine without invulnerability but cannot be targeted and alot of health, set the health of the unit in the editor before the game starts to 50% and now I'm using heal as a base, the amount healed is set to 0 and the targets allowed is set to Neutral, the range is set to 1000.

Still not working.
 
Level 12
Joined
Jul 5, 2014
Messages
551
I got it working, Any suggestions going forward? Thanks for the help, this trigger took me like 50 attempts over the past 10 years, finally got it working.
You should use "begin casting an ability" not "begins channeling". And instead of creating unit, you should order the building to cast the summon spell.

I don't know what your end goal is though. Do you want permanent units? Only carrion beetles are permanent as far as I know. In this case, you should fiddle with mercenary camps' hire unit ability.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I would try this carrion thing but the there will be necromancers and maybe in mass so theres a chance to be softlocked out of units if they get in range of your base
It was an easy enough problem to fix (see map below). I made the hidden Corpse I use classified as Suicidal and made every other ability that targets corpses have the Non-Suicidal option in it's Targets Allowed field. Now the Necromancers will never attempt to cast Raise Dead on that specific Corpse. These types of abilities are found in the Human/Undead/Special categories, there's about 10 of them (Resurrection, Cannibalize, Animate Dead, etc). I think I covered all of them in my demo map. I also realized that I had used the wrong Event Response in my AS Summon Units trigger and fixed that.

Anyway, I'm not saying that you have to use this system but I figured I'd leave it in a working state. I also wanted to show how you can expand the concept and fix any issues as they arise.

Regarding the Wait solution you're currently using, I suggest the following:

1) Use Array variables which store data like Unit-Types and For Loops. If you're using a long chain of If Then Else statements then you're doing things the hard way. This is especially important if you plan on adding many more summons (this applies to my system as well). Scalable solutions will help you avoid headaches in the future. To take it a step further, use Hashtables as your database to get maximum efficiency.

2) Use Timers which run on Repeat. Each building can have it's own Timer or you can use one central Timer + a Unit Group variable + Unit Indexing to track the amount of elapsed time per unit. The central Timer is probably the easier of the two solutions but won't be perfectly precise (you can get it pretty close though).

3) Don't use Waits. Waits are asking for trouble and your current trigger may be exploitable. They're imprecise and need to be synced in online multiplayer (A Wait of 2.00 seconds is probably more like ~2.10 seconds on average). You need to use something that acts like a stopwatch where it resets whenever you try to start it again - rather than a Wait which can never be interrupted once started. In other words, use the Timer solution from #2.
 

Attachments

  • Autocast Summon 2.w3m
    27.2 KB · Views: 5
Last edited:
Level 3
Joined
May 11, 2009
Messages
32
It was an easy enough problem to fix (see map below). I made the hidden Corpse I use classified as Suicidal and made every other ability that targets corpses have the Non-Suicidal option in it's Targets Allowed field. Now the Necromancers will never attempt to cast Raise Dead on that specific Corpse. These types of abilities are found in the Human/Undead/Special categories, there's about 10 of them (Resurrection, Cannibalize, Animate Dead, etc). I think I covered all of them in my demo map. I also realized that I had used the wrong Event Response in my AS Summon Units trigger and fixed that.

Anyway, I'm not saying that you have to use this system but I figured I'd leave it in a working state. I also wanted to show how you can expand the concept and fix any issues as they arise.

Regarding the Wait solution you're currently using, I suggest the following:

1) Use Array variables which store data like Unit-Types and For Loops. If you're using a long chain of If Then Else statements then you're doing things the hard way. This is especially important if you plan on adding many more summons (this applies to my system as well). Scalable solutions will help you avoid headaches in the future. To take it a step further, use Hashtables as your database to get maximum efficiency.

2) Use Timers which run on Repeat. Each building can have it's own Timer or you can use one central Timer + a Unit Group variable + Unit Indexing to track the amount of elapsed time per unit. The central Timer is probably the easier of the two solutions but won't be perfectly precise (you can get it pretty close though).

3) Don't use Waits. Waits are asking for trouble and your current trigger may be exploitable. They're imprecise and need to be synced in online multiplayer (A Wait of 2.00 seconds is probably more like ~2.10 seconds on average). You need to use something that acts like a stopwatch where it resets whenever you try to start it again - rather than a Wait which can never be interrupted once started. In other words, use the Timer solution from #2.
Very much apreciate working this entire setup for me, I couldn't do half of whats in the trigger list. I'm struggling to find where and how I introduce more units into the summoning paramaters, Like a building having all Human units available but you can only summon 1 at a time. It just defaults to unit 1. I dont know anything about Hastables.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Very much apreciate working this entire setup for me, I couldn't do half of whats in the trigger list. I'm struggling to find where and how I introduce more units into the summoning paramaters, Like a building having all Human units available but you can only summon 1 at a time. It just defaults to unit 1. I dont know anything about Hastables.

You can only realistically have one Carrion Beetles ability per Unit since Abilities use an Order Id system. Whenever a Unit does just about anything in the game it will issue an Order based on that action -> "move", "attack", "stop", "bloodlust", etc. These Orders occur before any actual actions are taken (unit begins casting, moving, attacking, etc). The issue occurs when a Unit has two or more Abilities with the same Order Id. The game has difficulty determining which of those abilities you're trying to cast since it sees them as the "same thing".

It's sort of like if you were holding two apples and I asked you to "give me an apple" without specifying which one - you would hand me one at random. The game handles the casting of the two Abilities in a similar way. Although, it seems to prioritize whichever of the two Abilities were added to the unit first (so in this case the first to appear in the Abilities field in the Object Editor).

Edit: Probably not worth reading the rest of this post, see my next post.

Long story short, it's going to be near impossible to have multiple Autocast abilities on a single Unit that all behave the same way without issues. So if you need a system like that then you'll likely want to rely on something other than Autocast. The Channel method that others suggested could work since that ability has special functionality allowing you to specify it's Order Id. It could even take advantage of what I'm doing here with a few tweaks.

Anyway, if you don't need multiple Summon Abilities on the same Unit then you can use my current solution. Here's the lazy approach:
  • AS Summon Units
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to AS_Dummy_Type
    • Actions
      • Set VariableSet AS_Caster = (Summoning unit)
      • -------- --------
      • -------- The summoned units uses the (Summoned unit) Event Response: --------
      • Unit - Replace (Summoned unit) with a Footman using The new unit's max life and mana
      • Unit - Add classification of Summoned to (Last replaced unit)
      • Unit - Add a 60.00 second Generic expiration timer to (Last replaced unit)
I changed the Summon Ability to summon a Dummy unit instead of the original Carrion Beetle. This is useful since it won't interfere with anything else. I then use the revised Summon Units trigger to detect when it's summoned and Replace it with our desired Unit. In this example I replace it with a Footman, but you could modify the Footman to be anything you want. IE: It could be based on the type of (Summoning unit) to get different outcomes.

Alternatively, and only if you plan on sticking with 1 Ability per Building, you could create multiple versions of the Summon Ability each having their own unique summon type. You wouldn't even need the above trigger in that case, but you would need to tweak some triggers to account for the different types of Abilities since the system currently assumes that you have one central Summon ability.

I attached v3 below since I changed a few things, but this "replace unit" concept works on the previous versions as well.
 

Attachments

  • Autocast Summon 3.w3m
    27.8 KB · Views: 4
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Alright, I couldn't help myself. Here's a more advanced system that rids the need of the weird corpse stuff. It should fix every issue I mentioned before and allows for what I assume you wanted. A lot of tricks were used to get it to work properly but I'm fairly confident it won't cause any problems.

How To Use It:

1) Go into the Object Editor and ensure that all of your desired Summoners (the Guard Tower in my example) have the new Is Summoner (SAS) ability. This acts as a Condition to determine which types of units use the system. ANY number and any types of units can use the system so feel free to add it to anything. The ability is hidden and has no actual effects so it won't interfere with your map.

2) Go into the Object Editor and copy and paste an existing summon Ability (see my two examples for the Footman and Knight). Then customize the ability settings to your liking. The system will read that Object Editor data and use that information to determine the Mana Cost, Cooldown, and Unit-Type of what gets summoned (I could easily add more customization options if you'd like).

3) Go into the Trigger Editor and copy and paste an existing Register trigger (again, I have two examples for the Footman and Knight):
  • SAS Register Footman
    • Events
      • Game - Button for ability Summon Footman (SAS) and order Night Elf Avatar Of Vengeance - Activate Spirit Of Vengeance pressed.
    • Conditions
    • Actions
      • Set VariableSet SAS_Caster = (Triggering unit)
      • Set VariableSet SAS_CV = (Custom value of SAS_Caster)
      • -------- --------
      • -------- SET THIS AND IGNORE EVERYTHING ELSE: --------
      • Set VariableSet SAS_Active_Ability[SAS_CV] = Summon Footman (SAS)
      • -------- --------
      • Trigger - Run SAS Disable Other Abilities <gen> (ignoring conditions)
^ Edit the Event to reference your new Ability and edit the SAS_Active_Ability variable to reference your new Ability.

4) Go into the Trigger Editor and edit the Setup trigger to reference all of your Abilities:
  • SAS Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Import the summoner class ability into your map and define it: --------
      • Set VariableSet SAS__Is_Summoner = Is Summoner (SAS)
      • -------- --------
      • -------- Define the number and types of autocast abilities that are using this system: --------
      • Set VariableSet SAS__Summon_Ability_Size = 2
      • Set VariableSet SAS__Summon_Ability_Type[1] = Summon Footman (SAS)
      • Set VariableSet SAS__Summon_Ability_Type[2] = Summon Knight (SAS)
^ Add your Summon abilities to the Array following the pattern -> [1], [2], [3], [4], etc. Then make sure the Size variable is set to how many of these you have in total. So you'll always need to do steps #3 and #4 after creating a new summon ability.

5) That's it, you're all finished.

[Edit] Current limitations and quirks (forgot to mention these):
  • It does not support Default Active Abilities or triggered Autocast toggling. You must manually Right click the Autocast ability for the system to turn on the correct ability + get the associated data from that ability.
  • It does not support manually casting the ability. Everything is handled through toggling on Autocast. This seems fine and helps prevent it from being abused.
  • The created units are NOT summoned from the ability, but you can mimic all of that behavior using the Unit Was Summoned trigger.
  • The ability never actually casts, it's all simulated using triggers.
  • It snapshots the ability information upon enabling Autocast, so if you modify a Summon Ability while it's already on it will NOT take those changes into consideration until you toggle it off/on again. A fix to this is possible and I can add it if you'd like.
  • Since this system relies on a Unit Indexer, you must NEVER modify a unit's Custom Value yourself. Fortunately, the system offers a far better alternative to that - feel free to ask me about this alternative if you're confused (or just check out the Unit Indexer documentation/demo map).
 

Attachments

  • Summon Autocast System.w3m
    36.4 KB · Views: 5
Last edited:
Level 3
Joined
May 11, 2009
Messages
32
Hey Uncle, thnx again for the overhaul. It works fine in your map but when I move it over to mine it encounters this issue.
 

Attachments

  • Screenshot_7.png
    Screenshot_7.png
    62.2 KB · Views: 7
Top