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

Applying Crowd Controll per Trigger

Status
Not open for further replies.
Level 3
Joined
May 5, 2013
Messages
56
I have got a simple question: How can I apply Crowd Controll (like Stun, Slow, Silence, Sleep) per Trigger?

For example:
A Unit casts a spell and stuns the target, and all unit around the target.

How can I do that by trigger? (Is "Pause/Unpause" a good idea or is it something like "Unit - Add Classification"?)
 
Level 3
Joined
May 5, 2013
Messages
56
The most usual way is creating an invisible unit and ordering it to cast the ability.
For instance, stunning is done by using a 0-damage storm bolt ability.

And if I want multiple Units being stunned, I change the cooldown of the storm bolt ability to 0 and do something like:

Pick up every Unit in [Area of Effect] and oder "Stunning Unit" to use [Storm bolt] on Picked Unit

right?
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Pause is bad because it pauses buff and screws up the death animation. I am not exactly sure what you mean by adding classification.

As Xonok said, you can use a dummy unit to cast the buff placing abilities. If this is a primary feature of your map, create a system to do that automatically for you instead of repeating actions for each spell.

You can use a single unit to cast a 0s cd ability consecutively on multiple targets. Just set the ms to 0 and the backswings and cast time all to 0 too. Oh and don't forget to put an expiration timer on it. Otherwise, create a dummy next to each target to cast the ability individually.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
yes Redteal. The hard thing with it is detecting exactly when the unit is being stunned. Most maps (like Sven's Dota Stun) uses a Dummy Unnit with some model moving towards the target, when it reaches it then picks the units around. Another work around would be doing a WarStomp instead of a 1 by 1 stun trigger.
 
Level 6
Joined
Apr 23, 2011
Messages
182
Pause is bad because it pauses buff and screws up the death animation. I am not exactly sure what you mean by adding classification.

I did use pause a lot of times in a unit and never have a problem with the animations. Even more pausing the unit is the only way you can get some animations play.

I will suggest you using pause + special effect + animation. And then unpause and destroy the effect and reset the animation.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
I did use pause a lot of times in a unit and never have a problem with the animations. Even more pausing the unit is the only way you can get some animations play.

I will suggest you using pause + special effect + animation. And then unpause and destroy the effect and reset the animation.

That is playing the animation forcibly when it is paused. Try pausing a unit then killing it. It would continue to freeze for a short time and then a corpse appears on the ground. Unless you unpause it immediately after it is killed, the death animation is basically lost. The pause buff thing is also true. Try pausing a stunned unit and see for yourself.

Unless you can disprove my claim, I still stand against using pauses of any kind.
 
Level 3
Joined
May 5, 2013
Messages
56
That is playing the animation forcibly when it is paused. Try pausing a unit then killing it. It would continue to freeze for a short time and then a corpse appears on the ground. Unless you unpause it immediately after it is killed, the death animation is basically lost. The pause buff thing is also true. Try pausing a stunned unit and see for yourself.

Unless you can disprove my claim, I still stand against using pauses of any kind.

yes I know that problem. By pausing, all buffs keep running until unpaused. For example if a unit is sleeped for 1s and then paused for 10 sec (paused while sleeping) the sleep buff (I mean that overhead zzZ) keeps running for the whole 10s and is lost when unpaused.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I myself dislike using pauses, mainly if I pause multiple targets by a specific spell. The reason for that is that if I use multiple spells, that pause unit on the same target, that target may get unintentionally unpaused when one effect ends, while it should be paused until the later effect ends.

Unless you take care of checking all other possible pause-factors, the above may happen.

---------
Pick up every Unit in [Area of Effect] and oder "Stunning Unit" to use [Storm bolt] on Picked Unit
If "Stunning Unit" is the caster that you control, then no, your line is not correct.
If "Stunning Unit" is dummy unit, then yes, that line is correct.

As for what dummy unit is:
It is a unit which has ability "locust" (= that makes it invulnerable and unable to be targeted); has Food Cost 0, does not show on minimap, has no shadow, has Fly movement type, does not use any upgrades.

That is the basic of a dummy unit. Then, there are 2 uses for dummies:
a) Effect dummy = has set Attacks Enables to none, so it cannot attack and its "Art - Model File" is set to a spell effect.
- This type of dummy is used when you want to create a nice effect, scale it, slow it, etc.

b) Spell dummy = this is used in triggered spells - like the one you want. This dummy has "Art - Model File" set to "none", so it does not have a model (is invisible); depending on what you want to do, you may leave (but modify to your liking) its "Combat - Attack" stats, so it can auto-attack (this is used mostly when you want to continually damage enemy, but do no additional effect); or you set Combat - Attacks Enabled to none and instead give it a spell (this is used when you want to cause special effect -like damage and stun, etc.)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Pausing units also pauses any expiration timer

Guys, lets try to remain in the topic. He's asking for AoE effect on single target abilities. That has been already answered: Triggering "Pick every unit in area around target" and affecting them one by one or having a dummy cast a similar AoE ability provided by Wc3 on the target position. Let's wait for his answer.
 
Level 3
Joined
May 5, 2013
Messages
56
If "Stunning Unit" is the caster that you control, then no, your line is not correct.
If "Stunning Unit" is dummy unit, then yes, that line is correct.

It was supposed to be the Stunning Dummy.



Lets now just imagine I want to do a spell like:
Most maps (like Sven's Dota Stun) uses a Dummy Unnit with some model moving towards the target, when it reaches it then picks the units around. Another work around would be doing a WarStomp instead of a 1 by 1 stun trigger.

I create a Dummy, which moves to the tagret and then does a warstomp (stun).

So I would do something like:

  • Unit - Create 1 "Stun Dummy" at position of "Casting Unit"
  • Unit - Order "Stun Dummy" to move to position of "Targeted Unit"

  • Event:
  • Unit - Unit enters Region - "Stun Dummy" enters Region centered at Position of "Targeted Unit"
  • Actions:
  • Unit - Cause "Stun Dummy" to use "Warstomp"
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Actually, it is like this.

Create dummy at target's loc
Order it to cast War Stomp (must have 0 mana War Stomp first)

What Spartipilo mean to say:

Event Start ability effect
Cond Ability = Stun (missle)
Action
Create a dummy unit acting as the missle
Turn on a periodic trigger to move the dummy

Periodic Trigger

Event Every 0.03s
Action
If distance between missle and target < 100
Then
Order dummy to War Stomp
Kill missle
Turn off This trigger
Else
Locate the to-move-to point based on the angle between the dummy and the target
Move the dummy to it

I am on a phone so I can only post pseudo-code. I am sorry for the inconvenience.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oh... if you need no missile moving towards target then it's even easier and faster, just las Doomlord said.

No need of a region. You can look around for dummy movement tutorials. I could do it but not right now.
 
Level 3
Joined
May 5, 2013
Messages
56
Actually, it is like this.

Create dummy at target's loc
Order it to cast War Stomp (must have 0 mana War Stomp first)

Ok, I got another anti-leak question:
If I create one dummy doing that all the time, after a couple of minutes the map would start leaking (too much dummys). Thats why I have to remove them, so I go a general (maybe stupid) question.

Every time I use "Last created Unit" I'm not sure if does actually work, because it could catch another unit that is spawned.

I make an example:
I create a Unit A at elapsed game time: 10s (which I want to remove at time 20s).
Another trigger creates a Unit B at 15s.
Time is 20s and the trigger in which I wanted to create the unit at 10s and remove it at 20s now removes unit B. (because it was last spawned)

I know this is off topic but I would like to know a better way then:
Unitgroup - Pick up every unit in Entire map
If Unit type of Picked Unit is equal to Unit B then do Remove Picked Unit from the game
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
There's an actions: Unit - Add expiration timer.

There you add expiration timer to (last created unit) and you're safe. It will be killed when the timer expires.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Add an expiration timer to the dummy. Set its death type to Can't raise, Does not decay so that it will be removed from the map afterwards.

@Spartipilo: expiration timers aren't the best choice as death dummies leak for a default 88s before removal. Maker discovered the death type setting to replace manually removing the dummies as an alternative to dead unit leak clearing.

Last created unit will catch your dummy. Warcraft is single-threaded i.e do everything step-by-step, trigger-by-trigger. Therefore Last created unit right after a unit creation will always return the correct unit.
 
Level 3
Joined
May 5, 2013
Messages
56
There's an actions: Unit - Add expiration timer.

There you add expiration timer to (last created unit) and you're safe. It will be killed when the timer expires.

Good Idea, thanks.

Event Start ability effect
Cond Ability = Stun (missle)
Action
Create a dummy unit acting as the missle
Turn on a periodic trigger to move the dummy

Periodic Trigger

Event Every 0.03s
Action
If distance between missle and target < 100
Then
Order dummy to War Stomp
Kill missle
Turn off This trigger
Else
Locate the to-move-to point based on the angle between the dummy and the target
Move the dummy to it

Wouldnt it be better to set "If distance between missle and target < 100" to "If distance between missle and target < 1" (The effect now starts when the missile is at the exact position of the target, not 100 units next to it.


  • Locate the to-move-to point based on the angle between the dummy and the target
I dont understand what you mean, sorry.
I think this should not be in the "If then Else", this should be in the periodic event:
Event Every 0.03s
Action
Locate the to-move-to point based on the angle between the dummy and the target
If distance between missle and target < 100
Then
Order dummy to War Stomp
Kill missle
Turn off This trigger
Else Do Nothing
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Like this? (this is just doomlord's technique)
  • Cast Trigger
  • Events -
    • Unit - A unit starts the effect of an ability
  • Conditions -
    • (Ability being cast) equal to your ability
  • Actions -
    • Set Missile Speed = 1000 (the speed of the custom missle)
    • Set temp location = Position of triggering unit
    • Set temp location 1 = Position of target unit of ability being cast
    • Unit - create 1 dummy for (owner of (triggering unit) at (temp location) facing (Angle between temp location and temp location 1)
    • Trigger - Turn (Move Trigger) On
    • Set TARGET = target unit of ability being cast
    • Set DUMMY = Last Created Unit
    • Custom Script: Call RemoveLocation(udg_temp location)
    • Custom Script: Call RemoveLocation(udg_temp location 1)
  • Move Trigger
  • Events -
    • Time - Every 0.03 of game time
  • Conditions -
  • Actions -
    • Set temp location = Position of (DUMMY)
    • Set temp location 1 = Position of (TARGET)
    • Set temp location 2 = (temp location 1 offset by (Missile Speed) * 0.03 with angle (Angle between temp location and temp location 1
    • Unit - Move TARGET to temp location 2 instantly
    • If (Conditions) Then (Actions) Else (Actions) -
      • Conditions -
        • Distance between temp location and temp location 1 less than or equal to 60
      • Then -
        • Unit - Issue DUMMY to Human - Blood Mage - Banish TARGET
        • Unit - Kill DUMMY
        • Trigger - Turn (This Trigger) Off
      • Else -
    • Custom Script: Call RemoveLocation(udg_temp location)
    • Custom Script: Call RemoveLocation(udg_temp location 1)
    • Custom Script: Call RemoveLocation(udg_temp location 1)

1 is just too much. The units will never get that distance. As you can see, 100 is just a relative value. The actual AoE won't change much.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
You don't need the set the effect when the missile is in the exact same spot as the target. You want to cause the effect when the missile *hits* the target. Depending on target's size, 50-60 range should be enough (if the target is too oversized, you may want to increase the range... though you may have hard time finding out unit's size, unless you store it beforehand)
 
Level 3
Joined
May 5, 2013
Messages
56
This is what I have done so far:

  • Q Area Stun
    • Events
      • Unit - A unit starts the Effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Electric Elemental
      • (Ability being cast) Equal to Electric Stun
    • Actions
      • Set Electric_Stun_Target = (Target unit of ability being cast)
      • Wait 1.00 game-time seconds
      • Unit - Create 1 Electric Stun Dummy for (Owner of (Triggering unit)) at (Position of Electric_Stun_Target) facing 0 degrees
      • Unit - Hide (Last created unit)
      • Unit - Order (Last created unit) to Orc-Chieftain - 'Warstomp'
      • Special Effect - Create a special effect at (Position of Electric_Stun_Target) using war3mapImported\Lightnings Long.mdx
But I have one problem: The "Electric Stun Dummy" is not created at the exact position of the target (For example: The collision size of the target is 30. The Dummy is then created right next to (30 units next to) the target). The dummy has a collision size of 0 and the ability "locust" (I dont know if that is the exact english word, but I mean the ability where it cannot be targeted).

But still it isn't created at the exact position of the target.



Btw: I decided to not make an Ability WITHOUT the missile, because I think it fits better to the Hero. But still you helped me by describing how to make it. Maybe could use it for another Hero.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hidden units can't do anything.

You're not using the point variable on the dummy creation, you should..

You're not removing the location leak

you're not cleaning the especial effect leak.
 
Level 3
Joined
May 5, 2013
Messages
56
Hidden units can't do anything.

You're not using the point variable on the dummy creation, you should..

You're not removing the location leak

you're not cleaning the especial effect leak.

  • Q Area Stun
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Electric Elemental
      • (Ability being cast) Equal to Electric Stun
    • Actions
      • Set Electric_Stun_Target = (Target unit of ability being cast)
      • Wait 1.00 game-time seconds
      • Unit - Create 1 Electric Stun Dummy for (Owner of (Triggering unit)) at (Position of Electric_Stun_Target) facing 0 degrees
      • Unit - Add a 1.00 second Standard expiration timer to (Last created unit)
      • Unit - Hide (Last created unit)
      • Unit - Order (Last created unit) to Orc-Tauren-Häuptling - 'Kriegsdonner'
      • Special effekt - Create a special effect at (Position of Electric_Stun_Target) using war3mapImported\Lightnings Long.mdx
      • Set Area_Stun_Electric_Elemental = (Last created special effect)
      • Wait 1.00 seconds
      • Special effekt - Destroy Area_Stun_Electric_Elemental

I removed the dummy leak (by expiration timer)

I removed the Special effect leak (by destryoing it after 1 sec)

But I dont know what you mean by:
You're not using the point variable on the dummy creation, you should..

You're not removing the location leak

I thought that I dont have location leaks because I dont use a location variable.

And why should I use a location Variable on the dummy creation? Currently it works with my way.

Hidden Units can do anything? Yes they can: If I force the hidden unit to use his stun, he does. The only thing he does not is the graphic of the stun, but i have done that by using a special effect.





Edit:

set movement type to "fly"

I just forgot that, thanks. Now he does it at the exact position.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
There a 2 things with triggers:

1- Leaks

When you use (Position of (Triggering Unit)) te game Creates a Location: After you use it, it remains there in the data: After a while, you'll find you have hundreds and dousands of locations you're not using, and you can't use, since they're only created for one purpuse like this one: creating a unit.

For that, you declare a position in a variable, just as you did, then you use it in the unit creation, then you use a custom script to remove/clear/clean that variable.
  • Set Electric_Stun_Target = (Target unit of ability being cast)
  • Unit - Create unit at Electric_Sun_Target
  • Custom script: call RemoveLocation(udg_Electric_Sun_Target)
That happens for ANY case. Else, you will experience some lag after several leaks stack up, making your map unplayable.


2- Optimization

Have you seen the parentheses in your actions? Each pair of parentheses is an argument Wc3 uses to run the functions. If you use (Owner of (Triggering Unit)) you have 2 Pair of parentheses. (Owner of...) and (Triggering Unit). In any "Unit - Generic event" you can replace that with (Triggering Player) and voilá, a pair of parentheses is gone. It means Wc3 has less work to do, so it will run faster and smoother.

Now, you're using (Last Created Unit) 3 times, that's like telling Wc3 to search for the same thing three times. That's a time and resource waste. You can create the unit, and declare the Last Created Unit into a variable (lest call it TempUnit) . Then, you use that variable to store the last created unit (Set TempUnit = (last created Unit)). After that, in the remaining actions, you use TempUnit instead of (last created unit) and you'll notice the parentheses dissapear. Again, less work, faster work, smoother result. That MUST be done every time you use anything more than twice in a trigger.

In GUI, most of these functions have BJ's, which are functions that calls other functions. It's like asking your mom to tell your dad to call your brother to give you the ketchup when you're all in the same table; you can do it directly, but the GUI functions doesn't allow it.

The only way to access them is with JASS scripts (GUI turned to JASS and optimized to remove BJ's and replacing globals with locals)
 
Last edited:
Level 3
Joined
May 5, 2013
Messages
56
There a 2 things with triggers:

1- Leaks

When you use (Position of (Triggering Unit)) te game Creates a Location: After you use it, it remains there in the data: After a while, you'll find you have hundreds and dousands of locations you're not using, and you can't use, since they're only created for one purpuse like this one: creating a unit.

For that, you declare a position in a variable, just as you did, then you use it in the unit creation, then you use a custom script to remove/clear/clean that variable.
  • Set Electric_Stun_Target = (Target unit of ability being cast)
  • Unit - Create unit at Electric_Sun_Target
  • Custom script: call RemoveLocation(udg_Electric_Sun_Target)
That happens for ANY case. Else, you will experience some lag after several leaks stack up, making your map unplayable.


When I use a Unit Variable (e.g. for target unit of ability being cast), I thought I can only remove the Unit (with custon script: call RemoveUnit(udg_VariableA)...

Because how can I remove a point from a unit Variable?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oh, my bad. I missread. I tough it was "Target POINT of ability being cast". My bad, my bad. At least you get what i meant.
 
Level 3
Joined
May 5, 2013
Messages
56
Oh, my bad. I missread. I tough it was "Target POINT of ability being cast". My bad, my bad. At least you get what i meant.

Yup :)

So we wont have any location leaks, when I use "Position of Unit" instead of making a point variable.
Because he doesnt save the point, right?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Wc3 creates the location if you use the location (Like "Position of Anything" or "Target Point of Anything")

What variable does is alllow you to access that location to destroy it. That's why you have to declare the location in the variable, use the variable, then clear/destroy the variable (the data stored in it)
 
Level 3
Joined
May 5, 2013
Messages
56
  • Q Area Stun
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Electric Elemental
      • (Ability being cast) Equal to Electric Stun
    • Actions
      • Set Electric_Stun_Target_Position = (Position of (Target unit of ability being cast))
      • Wait 1.00 game-time seconds
      • Unit - Create 1 Electric Stun Dummy for (Triggering player) at Electric_Stun_Target_Position facing 0 degrees
      • Set Electric_Stun_Dummy = (Last created unit)
      • Unit - Add a 1.00 second Standard expiration timer to Electric_Stun_Dummy
      • Unit - Hide Electric_Stun_Dummy
      • Unit - Order Electric_Stun_Dummy to Orc-Chieftain 'Warstomp'
      • Special effect - Create a special effect at Electric_Stun_Target_Position using war3mapImported\Lightnings Long.mdx
      • Set Area_Stun_Electric_Elemental = (Last created special effect)
      • Wait 1.00 seconds
      • special effect - Destroy Area_Stun_Electric_Elemental
      • Custom script: call RemoveLocation(udg_Electric_Stun_Target_Position)

That better? Or still leakings?
I now changed:
- Loaction leak (by using a Variable and removing the location of the targeted unit)
- Not using 3 times "Last created unit" (making a variable instead)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1- You shouldn't use wait actions. During that second the value of your variables may change.

2- Hidden units can't cast abilities.

If you remove the waits, and that "Hidden" thing, you're done.
 
Level 3
Joined
May 5, 2013
Messages
56
1- You shouldn't use wait actions. During that second the value of your variables may change.

2- Hidden units can't cast abilities.

If you remove the waits, and that "Hidden" thing, you're done.


Hidden Units can cast abilities, I tested it. If I force the hidden unit to Orc-Chieftain 'Warstomp', the targets around are stunned. The only thing that does not happen is the animation (I guess because it's also hidden).

And why should I remove the "wait"? I need it because the spell is not supposed to be instant (The unit casts the spell and a second after that the effect starts).
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Add 1 second cast time to the Dummy war stomp. You create it instantly, and order instantly, but it will take 1 second to cast in the dummy.

Good to know about the hidden thing.
 
Status
Not open for further replies.
Top