• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Custom stun ability! [Solved]

Level 11
Joined
Jun 20, 2017
Messages
380
I have a channel ability that should stun the unit in range!
This is what I want,
Ability: Creates a blast that stuns any structures within blast radius for 5 seconds.
Area of Effect: 300.
Cast Range: 1000.
Cooldown: 45 seconds.
Note: Does not work on Walls.
  • Pulse Grenade
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pulse Grenade [Channel] [Custom] Item
    • Actions
      • -------- Increase Index. --------
      • Set VariableSet PG_Index = (PG_Index + 1)
      • -------- --------
      • -------- Set Caster. --------
      • Set VariableSet PG_Caster[PG_Index] = (Triggering unit)
      • -------- --------
      • -------- Set Casting Player. --------
      • Set VariableSet PG_CastingPlayer[PG_Index] = (Triggering player)
      • -------- --------
      • -------- Setup Points. --------
      • Set VariableSet PG_Point[PG_Index] = (Position of PG_Caster[PG_Index])
      • Set VariableSet PG_Point[0] = (Target point of ability being cast)
      • -------- --------
      • -------- Configure Ability Settings. --------
      • Set VariableSet PG_AreaOfEffect[PG_Index] = 300.00
      • Set VariableSet PG_CastRange[PG_Index] = 1000.00
      • Set VariableSet PG_Duration[PG_Index] = 5.00
      • Set VariableSet PG_Cooldown[PG_Index] = 45.00
      • -------- --------
      • -------- Setup Special Effect. --------
      • Special Effect - Create a special effect at PG_Point[PG_Index] using Abilities\Spells\Human\StormBolt\StormBoltMissile.mdl
      • Set VariableSet PG_SpecialEffect[PG_Index] = (Last created special effect)
      • -------- --------
      • -------- Setup Dummy. --------
      • Unit - Create 1 [Dummy] Pulse Grenade for (Triggering player) at PG_Point[0] facing Default building facing degrees
      • Set VariableSet PG_Dummy[PG_Index] = (Last created unit)
      • Unit - Add Pulse Grenade [Custom] Dummy to PG_Dummy[PG_Index]
      • Unit - Set level of Pulse Grenade [Custom] Dummy for PG_Dummy[PG_Index] to (Level of (Ability being cast) for PG_Caster[PG_Index])
      • -------- --------
      • Custom script: set udg_PG_HitGroup[udg_PG_Index] = CreateGroup()
      • Custom script: call RemoveLocation(udg_PG_Point[0])
      • -------- --------
      • -------- Start Loop (If it's currently off). --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PG_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Pulse Grenade Loop <gen>
        • Else - Actions
  • Pulse Grenade Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer PG_Loop) from 1 to PG_Index, do (Actions)
        • Loop - Actions
          • -------- Search for units around the Ability and deal Damage (You could add other effects here besides damage). --------
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within PG_AreaOfEffect[PG_Loop] of PG_Point[0].) and do (Actions)
            • Loop - Actions
              • Set VariableSet PG_PickedUnit = (Picked unit)
              • -------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PG_PickedUnit belongs to an enemy of PG_CastingPlayer[PG_Loop].) Equal to True
                  • (PG_PickedUnit is alive) Equal to True
                  • (PG_PickedUnit is A structure) Equal to True
                  • (PG_PickedUnit is hidden) Equal to False
                  • (PG_PickedUnit is invulnerable) Equal to False
                  • (PG_PickedUnit is Magic Immune) Equal to False
                  • (PG_PickedUnit is in PG_HitGroup[PG_Loop].) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of PG_PickedUnit) Not equal to Wall
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (2)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (3)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (4)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (5)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (6)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (7)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (8)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (9)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (10)
                      • (Unit-type of PG_PickedUnit) Not equal to Wall (11)
                • Then - Actions
                  • Unit Group - Add PG_PickedUnit to PG_HitGroup[PG_Loop]
                  • -------- --------
                  • -------- Dummy (Stun). --------
                  • Custom script: call SetUnitPosition(udg_PG_Dummy[udg_PG_Loop], GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()))
                  • Unit - Order PG_Dummy[PG_Loop] to Human Mountain King - Storm Bolt PG_PickedUnit
                • Else - Actions
          • Custom script: call RemoveLocation(udg_PG_Point[0])
          • -------- --------
          • -------- Destroy the Special Effect/Missile Point/Hit Group. --------
          • Special Effect - Destroy PG_SpecialEffect[PG_Loop]
          • Unit - Remove PG_Dummy[PG_Loop] from the game
          • Custom script: call RemoveLocation(udg_PG_Point[udg_PG_Loop])
          • Custom script: call DestroyGroup(udg_PG_HitGroup[udg_PG_Loop])
          • -------- --------
          • -------- Adjust Index/Loop Variables (Explanation: https://www.hiveworkshop.com/threads/visualize-dynamic-indexing.241896/ ). --------
          • Set VariableSet PG_Caster[PG_Loop] = PG_Caster[PG_Index]
          • Set VariableSet PG_CastingPlayer[PG_Loop] = PG_CastingPlayer[PG_Index]
          • Set VariableSet PG_Point[PG_Loop] = PG_Point[PG_Index]
          • Set VariableSet PG_AreaOfEffect[PG_Loop] = PG_AreaOfEffect[PG_Index]
          • Set VariableSet PG_CastRange[PG_Loop] = PG_CastRange[PG_Index]
          • Set VariableSet PG_Duration[PG_Loop] = PG_Duration[PG_Index]
          • Set VariableSet PG_Cooldown[PG_Loop] = PG_Cooldown[PG_Index]
          • Set VariableSet PG_SpecialEffect[PG_Loop] = PG_SpecialEffect[PG_Index]
          • Set VariableSet PG_Dummy[PG_Loop] = PG_Dummy[PG_Index]
          • Set VariableSet PG_HitGroup[PG_Loop] = PG_HitGroup[PG_Index]
          • -------- --------
          • Set VariableSet PG_Index = (PG_Index - 1)
          • Set VariableSet PG_Loop = (PG_Loop - 1)
          • -------- --------
          • -------- Turn off this Trigger if there are no more Ability. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PG_Index Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Does not work! It does not stun the structures!
There is no longer a PG_Point[0], you meant to reference PG_Point[PG_Loop]:
  • Unit Group - Pick every unit in (Units within PG_AreaOfEffect[PG_Loop] of PG_Point[0].) and do (Actions)

Anyway, there's no reason for you to use Dynamic Indexing for a spell like this. You only use these indexing methods when you want to keep track of things over time, but this trigger does everything immediately.

So your trigger can be as simple as this:
  • Pulse Grenade
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pulse Grenade [Channel] [Custom] Item
    • Actions
      • -------- Set Caster. --------
      • Set VariableSet PG_Caster = (Triggering unit)
      • -------- --------
      • -------- Set Casting Player. --------
      • Set VariableSet PG_CastingPlayer = (Triggering player)
      • -------- --------
      • -------- Setup Point. --------
      • Set VariableSet PG_Point = (Target point of ability being cast)
      • -------- --------
      • -------- Setup Special Effect. --------
      • Special Effect - Create a special effect at PG_Point using Abilities\Spells\Human\StormBolt\StormBoltMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • -------- Setup Dummy. --------
      • Unit - Create 1 [Dummy] Pulse Grenade for PG_CastingPlayer at PG_Point facing Default building facing degrees
      • Set VariableSet PG_Dummy = (Last created unit)
      • Unit - Add Pulse Grenade [Custom] Dummy to PG_Dummy
      • Unit - Set level of Pulse Grenade [Custom] Dummy for PG_Dummy to (Level of (Ability being cast) for PG_Caster)
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 1000.00 of PG_Point.) and do (Actions)
        • Loop - Actions
          • Set VariableSet PG_PickedUnit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PG_PickedUnit belongs to an enemy of PG_CastingPlayer.) Equal to True
              • (PG_PickedUnit is alive) Equal to True
              • (PG_PickedUnit is A structure) Equal to True
              • (PG_PickedUnit is hidden) Equal to False
              • (PG_PickedUnit is invulnerable) Equal to False
              • (PG_PickedUnit is Magic Immune) Equal to False
              • (Unit-type of PG_PickedUnit) Not equal to Wall
              • (Unit-type of PG_PickedUnit) Not equal to Wall (2)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (3)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (4)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (5)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (6)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (7)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (8)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (9)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (10)
              • (Unit-type of PG_PickedUnit) Not equal to Wall (11)
            • Then - Actions
              • -------- Dummy (Stun). --------
              • Custom script: call SetUnitPosition(udg_PG_Dummy, GetUnitX(udg_PG_PickedUnit), GetUnitY(udg_PG_PickedUnit))
              • Unit - Order PG_Dummy to Human Mountain King - Storm Bolt PG_PickedUnit
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_PG_Point)
Then of course make sure that the Dummy ability can actually target Structures, has 0 cooldown, 0 mana cost, 99999 cast range, etc. Also, buffs won't show up for structures unless you enable it in the Gameplay Constants.

Also, your use of OR - Multiple conditions to check for the different types of Walls was unnecessary. You use OR if you want to check if ONE of those many Conditions are true. In this case you want to make sure that NONE of those Conditions are true. Remember, once a Condition fails to be true the rest of the conditions are ignored. So if the (picked unit) is a Wall (2) then it doesn't need to check if it's a Wall (3), (4), etc.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Again that’s kind of like telling your mechanic “my car can’t drive all the way to work” and then not elaborating on what exactly you mean or the symptoms you encounter.

You can troubleshoot this; I know you are competent enough. Break the issue into as many little steps as possible and check each one along the way in sequence until you find something unexpected:
  • Is it detecting the hero spell cast? Is the point variable in the right place and correctly saved?
  • Is the dummy created? Is it given its ability properly? Is it saved into a variable to be referenced later?
  • Is the dummy being moved properly? (Technically this isn’t necessary.)
  • Is the dummy properly configured to instant-cast? That is necessary here since you’re using one dummy per cast.
  • Can it cast its dummy ability on structures? (Targets allowed, range, mana, line of sight, fog of war, etc.)
  • Is the aoe search for hit targets actually finding units in range? Does HitGroup properly exclude units? Is HitGroup initialized for each cast?
  • Does the dummy cast or attempt to cast its ability on every found unit? Does it exist as long as it should or is it being removed prematurely?
  • Can structures be stunned in general? (I presume so but maybe Frost Breath is the only real way, and it definitely is if you want to freeze the production queue too.)
There are probably more things to check that I didn’t write here, and many of these can be skipped over by checking something further y down the line that depends on the first things working properly.
 
Level 11
Joined
Jun 20, 2017
Messages
380
Thanks a lot.
And I have this ability to unstun them! Is there a more efficient way to do this?
  • Holy Water
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Water [Channel]
    • Actions
      • -------- Setup Point. --------
      • Set VariableSet HW_Point = (Target point of ability being cast)
      • -------- --------
      • -------- Setup Special Effect. --------
      • Special Effect - Create a special effect at PG_Point using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
      • Set VariableSet HW_SpecialEffect = (Last created special effect)
      • Special Effect - Destroy HW_SpecialEffect
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 400.00 of HW_Point.) and do (Actions)
        • Loop - Actions
          • Set VariableSet PG_PickedUnit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PG_PickedUnit is alive) Equal to True
              • (PG_PickedUnit is A structure) Equal to True
              • (PG_PickedUnit has buff Pulse Grenade [Custom] Item) Equal to True
            • Then - Actions
              • Unit - Remove Pulse Grenade [Custom] Item buff from PG_PickedUnit
              • Unit - Remove Pulse Grenade [Custom] Dummy from PG_PickedUnit
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_HW_Point)
 
Top