• 🏆 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] Help getting an ability working.

Status
Not open for further replies.
Level 8
Joined
Mar 15, 2007
Messages
230
So I started another thread looking for ideas for abilities when I got a response with this:
Chooser of the Slain (Active): Targets an area. Friendly units in the area deal increased damage but take damage over time. On death, deals damage to all surrounding enemies and restores X mana to the Archdruid.
Here are my triggers
  • Chosen Roar
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • ((Summoned unit) is in (Units of type Chooser of the Slain Dummy 1).) Equal to True
    • Actions
      • Set VariableSet UDex = (Custom value of (Summoning unit))
      • Set VariableSet Chooser_Caster[UDex] = (Casting unit)
      • Set VariableSet Chosen_RoarPoint = (Position of (Summoned unit))
      • Unit - Order (Summoned unit) to Night Elf Druid Of The Claw - Roar.
      • Unit - Add a 2.00 second Generic expiration timer to (Summoned unit)
      • Wait 2.00 game-time seconds
      • Unit Group - Pick every unit in (Units within 500.00 of Chosen_RoarPoint matching (((Picked unit) has buff Chooser of the Slain ) Equal to True).) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to Chosen_Units[UDex]
          • Wait until (((Picked unit) has buff Chooser of the Slain ) Equal to False), checking every 0.20 seconds
          • Unit Group - Remove (Picked unit) from Chosen_Units[UDex].
      • Custom script: call RemoveLocation(udg_Chosen_RoarPoint)
  • Chosen Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is in Chosen_Units[UDex].) Equal to True
    • Actions
      • Set VariableSet Chosen_Blast = (Position of (Dying unit))
      • Unit - Create 1 Chooser of the Slain Dummy 2 for (Owner of (Dying unit)) at Chosen_Blast facing Default building facing degrees
      • Unit - Order (Last created unit) to Neutral - Kaboom! Chosen_Blast
      • Special Effect - Create a special effect at Chosen_Blast using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Set mana of Chooser_Caster[UDex] to ((Mana of Chooser_Caster[UDex]) + 15.00)
      • Custom script: call RemoveLocation(udg_Chosen_Blast)
The way it works is that the caster summons a dummy unit that casts a modified Roar. My problem with the first trigger is that it's either not adding the units to the unit group, or it's removing them before the buff is applied. I'm not sure what I did wrong. Other pertinent information is that I'm using the Unit Indexer by Bribe.
 
Level 14
Joined
Feb 7, 2020
Messages
387
(Picked Unit) doesn't survive wait steps (which makes sense because Picked Unit aka GetEnumUnit() is ambiguously referenced in your current trigger due to it being re-used throughout the loop, similar to any of the last X bj_ variables). You'll probably want to rethink this spell and convert the waits into a timer which checks for the buff being absent then remove the unit from the unit group.

This should be Matching Unit not Picked Unit: Unit Group - Pick every unit in (Units within 500.00 of Chosen_RoarPoint matching (((Picked unit) has buff Chooser of the Slain ) Equal to True).) and do (Actions)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
In Chosen Death you're referencing UDex without ever setting it. That variable gets changed every single time a Unit is Indexed into the system so you're basically referencing a random Integer value.

Here is how I would trigger it. I attached an example map as well:
  • Chosen Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Configure some variables for the spell --------
      • Set VariableSet Chosen_Summoned_Unit = Dummy
      • Set VariableSet Chosen_Buff = Chooser of the Slain
      • Set VariableSet Chosen_Buff_AoE = 500.00
      • Set VariableSet Chosen_Damage_Aoe = 250.00
      • Set VariableSet Chosen_Damage_Amount = 75.00
  • Chosen Roar
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Chosen_Summoned_Unit
    • Actions
      • Unit - Order (Summoned unit) to Night Elf Druid Of The Claw - Roar.
      • -------- --------
      • -------- Add Allies To Chosen Group --------
      • Set VariableSet Chosen_Point = (Position of (Summoned unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within Chosen_Buff_AoE of Chosen_Point.) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an ally of (Owner of (Summoned unit)).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is hidden) Equal to False
            • Then - Actions
              • Set VariableSet UDex = (Custom value of (Picked unit))
              • Set VariableSet Chosen_Caster[UDex] = (Summoning unit)
              • -------- --------
              • -------- Don't Add Them To The Group If They're Already In It (from a previous cast) --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in Chosen_Group.) Equal to False
                • Then - Actions
                  • Unit Group - Add (Picked unit) to Chosen_Group
                • Else - Actions
            • Else - Actions
      • -------- --------
      • -------- Turn On Chosen Timer (It should be Initially OFF by default) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Chosen Timer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Chosen Timer <gen>
        • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation (udg_Chosen_Point)
This trigger (Chosen Timer) needs to be Initially OFF (Check Box next to Enabled)
  • Chosen Timer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • -------- Remove Units From Chosen Group (If they no longer have the buff) --------
      • Unit Group - Pick every unit in Chosen_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Chosen_Buff) Equal to False
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Chosen_Group.
            • Else - Actions
      • -------- --------
      • -------- Turn Off Timer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Chosen_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off Chosen Timer <gen>
        • Else - Actions
  • Chosen Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Chosen_Group.) Equal to True
    • Actions
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • -------- --------
      • -------- Restore Mana --------
      • Unit - Set mana of Chosen_Caster[UDex] to ((Mana of Chosen_Caster[UDex]) + 15.00)
      • -------- --------
      • Set VariableSet Chosen_Point = (Position of (Triggering unit))
      • -------- --------
      • Special Effect - Create a special effect at Chosen_Point using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • -------- Deal AoE Damage --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within Chosen_Damage_Aoe of Chosen_Point.) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit)).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is hidden) Equal to False
            • Then - Actions
              • Unit - Cause Chosen_Caster[UDex] to damage (Picked unit), dealing Chosen_Damage_Amount damage of attack type Spells and damage type Normal
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation (udg_Chosen_Point)

Note that with this design the spell has a catch. That catch is if two Heroes cast Chooser of the Slain on the same target(s), only the most recent Casting Hero will be selected when restoring mana/dealing aoe damage. In my opinion this makes more sense since it matches the Warcraft 3 mechanics. For example, if you cast Shadow Strike on an enemy unit that already has the Shadow Strike buff, the old buff is replaced with the new buff, and the old source of the buff is overwritten with the new source of the buff. In other words, only the most recent cast applies it's effect.

However, if you'd like it so that multiple casts "stack", meaning that a unit dying under the effects of this ability can restore mana to multiple Casters at the same time, then I would recommend using Dynamic Indexing. Visualize: Dynamic Indexing
 

Attachments

  • Chosen Example.w3m
    28.5 KB · Views: 21
Last edited:
Level 8
Joined
Mar 15, 2007
Messages
230
Wow, thanks guys! That trigger works perfectly, Uncle. I did have one hiccup though. It didn't work at first and it turned out the problem was the Animation Cast Point for my dummy unit - which caused my units to be removed from the unit group before the spell was even cast. Well, I set the cast point to 0, and now it works like a charm.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
I recommend basing your Dummy unit off of the one in my map, it has all of the proper settings that a Dummy unit should have.

When a Dummy unit is setup properly it will cast spells almost instantly. This means it won't need to turn to face it's target or have target limits, so 1 single Dummy can cast Storm Bolt on 100+ units in an AoE for example. It seems to be a common myth that you need to create a new Dummy unit for each target in your "Pick every unit in group" function, but that's not true.

This trigger would work just fine as long as Storm Bolt has a 0 second cooldown/mana cost and the Dummy has the correct settings:
  • Actions
    • Unit - Create 1 Dummy for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Unit Group - Pick every unit in (Units within 512.00 of (Center of (Playable map area)).) and do (Actions)
      • Loop - Actions
        • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
 
Last edited:
Status
Not open for further replies.
Top