[Trigger] Can you reference Target of Ability being cast in Unit Starts the effect of an ability?

Level 7
Joined
Feb 22, 2009
Messages
260
Or are there any problems with my trigger?


  • Stormcaller
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Target unit of ability being cast)) Equal to Vrykul Sturmmagierin
      • (Level of Stormcaller for (Target unit of ability being cast)) Greater than 0
    • Actions
      • Set Caster = (Triggering unit)
      • Set Owner = (Owner of (Target unit of ability being cast))
      • Set Target_Pos = (Position of (Target unit of ability being cast))
      • Set Abilitylevel = (Level of Stormcaller for (Target unit of ability being cast))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Caster is Magic Immune) Equal to False
          • (Caster is Mechanical) Equal to False
          • (Caster is A structure) Equal to False
          • (Caster is A flying unit) Equal to False
          • (Caster is alive) Equal to True
          • (Caster is visible to Owner) Equal to True
          • (Caster belongs to an enemy of Owner) Equal to True
        • Then - Actions
          • Unit - Create 1 Dummy for Owner at Target_Pos facing Default building facing degrees
          • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
          • Unit - Add Forked Lightning (Stormcaller) to (Last created unit)
          • Unit - Set level of Forked Lightning (Stormcaller) for (Last created unit) to Abilitylevel
          • Unit - Order (Last created unit) to Neutral Naga Sea Witch - Forked Lightning Caster
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Target_Pos)



  • Mass Entangling roots
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Cenarius
      • (Level of Demigod Power for (Triggering unit)) Greater than 0
      • (Ability being cast) Equal to Entangling Roots
    • Actions
      • Set Owner = (Owner of (Casting unit))
      • Set Abilitylevel = (Level of (Ability being cast) for (Triggering unit))
      • Set Target_Pos = (Position of (Target unit of ability being cast))
      • Set TargetedGroup = (Units within AbilityStat[(Level of Demigod Power for (Triggering unit))] of Target_Pos)
      • Unit - Create 1 Dummy for Owner at Target_Pos facing Default building facing degrees
      • Unit - Add a 31.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Entangling Roots to (Last created unit)
      • Unit - Set level of Entangling Roots for (Last created unit) to Abilitylevel
      • Unit Group - Pick every unit in TargetedGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is A flying unit) Equal to False
              • ((Picked unit) is alive) Equal to True
              • (Picked unit) Not equal to (Target unit of ability being cast)
              • ((Picked unit) is visible to Owner) Equal to True
              • ((Picked unit) belongs to an enemy of Owner) Equal to True
            • Then - Actions
              • Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots (Picked unit)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Target_Pos)
      • Custom script: call DestroyGroup (udg_TargetedGroup)

  • Mass doom
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mass Doom
    • Actions
      • Set MindrotTarget = (Target unit of ability being cast)
      • Set MindrotPosition = (Position of MindrotTarget)
      • Set MindrotGroup = (Units within 300.00 of MindrotPosition)
      • Unit Group - Pick every unit in MindrotGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • (Picked unit) Not equal to MindrotTarget
              • ((Picked unit) is visible to (Triggering player)) Equal to True
              • ((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
            • Then - Actions
              • Unit - Create 1 Dummy for (Triggering player) at MindrotPosition facing Default building facing degrees
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Minor Doom to (Last created unit)
              • Custom script: call IssueTargetOrderById(bj_lastCreatedUnit, 852583, GetEnumUnit())
            • Else - Actions
      • Custom script: call RemoveLocation(udg_MindrotPosition)
      • Custom script: call DestroyGroup (udg_MindrotGroup)
 
empty.gif
line.gif
line.gif
joinbottom.gif
if.gif
(Caster belongs to an enemy of Owner) Equal to True
In the first trigger, you check if caster is an enemy to itself. This is strange.

I usually use "Casting Unit" and "Target of ability being cast" in the "A unit Starts the effect of an ability" events because they are imo clearer than "TriggeringUnit" (but triggering unit has some "special properties" and are sometimes needed).
 
Level 7
Joined
Feb 22, 2009
Messages
260
In the first trigger, you check if caster is an enemy to itself. This is strange.

I usually use "Casting Unit" and "Target of ability being cast" in the "A unit Starts the effect of an ability" events because they are imo clearer than "TriggeringUnit" (but triggering unit has some "special properties" and are sometimes needed).

The 'Owner' variable is set as the owner of the Target of Ability being Cast while 'Caster' variable is the Triggering unit.

The stormcaller ability is a passive that autocast forked lightning against any enemy that cast a single-target ability upon the hero with Stormcaller.
 
Level 7
Joined
Feb 22, 2009
Messages
260
One thing to note about this is that it requires fixed player settings to be on in the Forces tab, otherwise it will return false
What do you mean?

Have you confirmed the dummy being created for first trigger? (Confirming that the check conditions are valid)

For second trigger, is Mass Entangle a target Unit or target point ability? Same goes for Mass Doom
Target unit ability

And yeah I confirmed everything, even testing. However, I am unsure if there would be any foreseeable issue and should I make change to improve the triggers.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Glossed over the responses so forgive me if I'm just repeating what others have said:

1) You only need 1 Dummy unit to cast all of these spells. If that doesn't work then you've failed to setup your Dummy unit properly. Copy and paste the undead Locust, set it's Model = None (or Dummy.mdx), Shadow = None, Attacks Enabled = None, Movement Type = None, Speed Base = 0. Those are essential for instant casts. You may also want to play with some of the Art fields to get it looking correct.

Note that this type of Dummy CANNOT be used as a Missile (it cannot move), however, this has become obsolete ever since the addition of Special Effect functions that do this even better and more efficiently. See -> Relativistic Missiles by Chopinski.

2) Do NOT rely on (Last created unit) inside of your Loop - Actions of Pick Every Unit. Use a variable for the Dummy unit and reference that.

3) If the Dummy ability launches a Missile and therefore it's positioning is important to you, then simply Move the Dummy to where it needs to be prior to casting the abiltiy.

4) In some cases you're Setting variables regardless of whether they're needed. You can optimize that by organizing your Actions in a more logical way.
IE: Stormcaller doesn't need to Set the Pos/AbilLevel if it fails to pass the If - Conditions.

5) The Expiration Timer of your Dummy should sync up with the full duration of an Ability. For example, Forked Lightning is practically instant, therefore an Expiration Timer as low as 0.20 seconds is safe. A spell like Acid Bomb on the other hand throws a slow moving Missile which takes a random amount of time to reach it's target (if ever). In that case, you'll want a much longer Expiration Timer so that your Dummy will exist and get kill credit from the Damage that Acid Bomb deals. (There's always the chance that this doesn't matter in your map and can be ignored)

6) Regarding this Dummy (Killing unit) issue. Your Hero is not getting the kill credit from these Dummy abilities (assuming that they deal damage). One solution to fix this is by having a single "A unit Dies" Event, which uses a custom "Killing_Unit" variable which gets set to the TRUE killer. This could be done like so:
  • Actions
    • Set Variable Caster = (Casting unit)
    • Unit - Create 1 Dummy...
    • Set Variable Dummy = (Last created unit)
    • Set Variable Dummy_Hero[(Custom value of Dummy)] = Caster
    • Unit - Order Dummy to Neutral Naga Sea Witch - Forked Lightning (Target unit of ability being cast)
  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If all conditions are true then do (Actions)
      • If - Conditions
        • Dummy_Hero[(Custom value of (Killing unit))] Equal to No unit
      • Then - Actions
        • Set Variable Killing_Unit = (Killing unit)
      • Else - Actions
        • Set Variable Killing_Unit = Dummy_Hero[(Custom value of (Killing unit))]
    • -------- Fire all of the Unit_Death_Events --------
    • Set Variable Unit_Death_Event = 0.00
    • Set Variable Unit_Death_Event = 1.00
    • Set Variable Unit_Death_Event = 0.00
The rest of your triggers can now rely on this custom Event instead of "Unit - A unit Dies":
  • Events
    • Game - Unit_Death_Event Becomes equal to 1.00
  • Conditions
  • Actions
    • -------- Use Killing_Unit instead of (Killing unit) here! --------
    • -------- If a Dummy kills something, the Hero that "created it" will be the Killing_Unit. --------
    • Game - Display to (All players) for 30.00 seconds the text: (Name of Killing_Unit)
This example relies on Unit Indexing to pair the Dummy and the Hero that "created it" together. This concept can be applied to Damage Events as well, allowing your Dummy abilities to benefit from your Hero's custom stats, for example Ability Power like seen in League of Legends.
IE: Dummy deals damage -> Damage modifiers reference the Dummy_Hero's stats rather than the Dummy's stats.
 
Last edited:
Level 7
Joined
Feb 22, 2009
Messages
260
View attachment 513836

If those options are unticked, for example even though player 1 and player 2 would be hostile ingame, the boolean "belongs to an enemy player X" would be false, it's a weird quirk with player slots
But that just doesn't make sense, so freaking weird! Then how the heck do I even reference an enemy player?

Do I have to make a trigger that activate at map initialization that makes players in a group enemies to those not in their group?

This is a melee map btw
 
Last edited:
Top