• 🏆 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!

Auto Casting Units

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
I tried to make units autocast "purge" ( a custom purge ability I made, not the base one)

  • Greater VW
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Dummy
    • Actions
      • Unit - Order (Casting unit) to Orc Shaman - Purge (Target unit of ability being cast)
It doesn't seem to work. The unit casts purge, if I manually use my dummy ability (searing arrow) but on auto cast it just won't trigger purge. Maybe someone can help me! I need the auto-cast of the dummy ability to activate purge.
 
Level 7
Joined
May 30, 2018
Messages
290
You need two triggers, one for detecting when autocast is turned on and when damage is dealt with autocast on. A simple way to do it is in this Detect when casting frost, flamme or dark arrow link.

I would however suggest using damage functions in the second trigger + variable to indicate that the unit has autocast in the first trigger for MUIness and buglessness.

But what about the auto cast spell not dealing any damage? Since purge doesn't deal any damage. Or do I need damage on the dummy ability anyways?
 
Level 12
Joined
Jan 30, 2020
Messages
875
Well it's not purge that will deal damage but the unit that has purge.

To autocast a spell that doesn't automatically autocast, as @Clanzion said, you need 2 triggers.

The first trigger is used to save the autocast state (ON or OFF).

I use this in my map. I use the unit custom value (Unit User Data in Jass) to avoid having to use a unit indexer.
So when the unit enters the game, if I want the spell to be autocast from the start, I set the casting unit custom value to a number, if not I set it to 0.
When a player changes the autocast state (in other words issues an order to the unit with the order sting : for example slowon or slowoff), then I change the custom value to O for OFF or a number for ON.

Now let's explain the number in question.
I use a string array containing the spell order strings (not the spell id, but the order string to cast the ability).

So when an enemy is attacked or damaged, and the attacker is my casting unit, I read the custom value. If it is 0 then nothing happens (no autocast), if the custom value is not 0, I order my attacking unit with the order string from my array.

You can chose any value if you want depending on how many autocast spells your map will need, all that matters is that when the caster enters the map or when the players changes the autocast state, just make sure that you give your unit a custom value that will correspond to the index of your array where the order for your spell is stored.

I could show you my triggers, but they're 100% in Jass and got more complicated over the months as I added other things like incapacitated state check and other things.

I hope you understand the idea.
 
Status
Not open for further replies.
Top