• 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.

[Trigger] What is wrong with this trigger?

Level 7
Joined
Feb 22, 2009
Messages
239
The premise of this trigger is when Debuffer A2 0 casts a firebolt at an enemy, the trigger will create one dummy per enemies around the target and each will cast a firebolt at these enemies.


  • Firebolt
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Firebolt (Neutral Hostile)
      • (Unit-type of (Triggering unit)) Equal to Debuffer A2 0
    • Actions
      • Set FireboltTarget = (Target unit of ability being cast)
      • Set FireboltPosition = (Position of FireboltTarget)
      • Unit Group - Pick every unit in (Units within 300.00 of MindrotPosition matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at FireboltPosition facing Default building facing degrees
          • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
          • Unit - Add Firebolt (Neutral Hostile) to (Last created unit)
          • Unit - Order (Last created unit) to Neutral - Firebolt (Picked unit)
 
Last edited:

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
I don't see anything wrong with your trigger. Perhaps you could tell us what kind of issues you're dealing with related to this trigger?

Also some of my feedbacks regarding the code would be:
  • Make sure MindrotArea[] is defined so it can enumerate units properly
  • Don't forget to remove location reference when you're done, because it has a memory leak if not removed. I'm talking about MindrotPosition, you can clean it up by Custom script: call RemoveLocation(udg_MindrotPosition)
  • You can replace (Owner of (Triggering unit)) with Triggering Player, it should have the same effect
  • A unit finishes casting an ability event means you'll have to wait until the unit is no longer casting the spell before the action triggers, use A unit starts the effect of an ability if you want the action to trigger as soon as the ability is cast. No need to change this if it was intended.
  • You should store Unit Group to a variable and destroy it to prevent memory leak, or you can use Custom script: set bj_wantDestroyGroup = true before doing enumeration.
  • You mentioned you couldn't copy the entire matching condition, I would advise to replace your action with something like this
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 512.00 of YourLocationVar) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is alive) Equal to True
            • ((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
          • Then - Actions
          • Else - Actions
    • Custom script: call RemoveLocation(udg_YourLocationVar)
    This way, your code becomes more readable and it essentially does the same thing.
 
Level 7
Joined
Feb 22, 2009
Messages
239
I don't see anything wrong with your trigger. Perhaps you could tell us what kind of issues you're dealing with related to this trigger?

Also some of my feedbacks regarding the code would be:
  • Make sure MindrotArea[] is defined so it can enumerate units properly
  • Don't forget to remove location reference when you're done, because it has a memory leak if not removed. I'm talking about MindrotPosition, you can clean it up by Custom script: call RemoveLocation(udg_MindrotPosition)
  • You can replace (Owner of (Triggering unit)) with Triggering Player, it should have the same effect
  • A unit finishes casting an ability event means you'll have to wait until the unit is no longer casting the spell before the action triggers, use A unit starts the effect of an ability if you want the action to trigger as soon as the ability is cast. No need to change this if it was intended.
  • You should store Unit Group to a variable and destroy it to prevent memory leak, or you can use Custom script: set bj_wantDestroyGroup = true before doing enumeration.
  • You mentioned you couldn't copy the entire matching condition, I would advise to replace your action with something like this
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 512.00 of YourLocationVar) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is alive) Equal to True
            • ((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
          • Then - Actions
          • Else - Actions
    • Custom script: call RemoveLocation(udg_YourLocationVar)
    This way, your code becomes more readable and it essentially does the same thing.

The reason why I didn't write the clean up is because this trigger wasn't working so I leave those details for later.

The issue is even when the hero finished casting the firebolt, dummy was not created and nothing happens to the enemies around the primary target.

The original trigger is much more elaborated with the array for MindrotArea.

Back to the issue, The 'order last created unit to cast the firebolt to the picked unit' has a problem. The ability I want to trigger originally was mindrot and not firebolt but there was no option to choose mindrot. Is there anyway to force a unit to use an ability that was not listed in the dropdown list?
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
I see. If that's the case, there is some things you can do to troubleshoot.

First thing you can do is to make sure you enumerate the units correctly, you can check this by putting a debug message inside the unit group loop. Game - Display to (All players) the text: I found enemy! right under
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at FireboltPosition facing Default building facing degrees
This way, you know that the message appear after you create the dummy.

Now, if you've created the dummy units properly. The problem must be in object editor. Because your code should work at this point.
Make sure the firebolt has no casting time, no mana cost (or if it has mana cost, make sure your dummy units have enough mana to cast it), no cooldown. You must also check for Stats - Targets Allowed in your firebolt data. You need to make sure firebolt can be cast at the targets.
You also have to make sure Art - Animation - Cast Backswing is 0, Art - Animation - Cast Backswing is 0, Movement - Speed Base is 0 for the dummy unit in object editor. This allows for instant casting.

Please let us know about the results. Hope it helps.

The ability I want to trigger originally was mindrot and not firebolt but there was no option to choose mindrot. Is there anyway to force a unit to use an ability that was not listed in the dropdown list?
If your mindrot ability is based on firebolt, you can use order firebolt for it. But if you want to use an ability that was not listed in the dropdown list, you'll need to use custom script for that and you need to know the order ID of your ability.
Custom script: call IssueTargetOrderById(bj_lastCreatedUnit(), udg_YourAbilityId, GetEnumUnit())
 
Last edited:
Level 7
Joined
Feb 22, 2009
Messages
239
I see. If that's the case, there is some things you can do to troubleshoot.

First thing you can do is to make sure you enumerate the units correctly, you can check this by putting a debug message inside the unit group loop. Game - Display to (All players) the text: I found enemy! right under
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at FireboltPosition facing Default building facing degrees
This way, you know that the message appear after you create the dummy.

Now, if you've created the dummy units properly. The problem must be in object editor. Because your code should work at this point.
Make sure the firebolt has no casting time, no mana cost (or if it has mana cost, make sure your dummy units have enough mana to cast it), no cooldown. You must also check for Stats - Targets Allowed in your firebolt data. You need to make sure firebolt can be cast at the targets.
You also have to make sure Art - Animation - Cast Backswing is 0, Art - Animation - Cast Backswing is 0, Movement - Speed Base is 0 for the dummy unit in object editor. This allows for instant casting.

Please let us know about the results. Hope it helps.


If your mindrot ability is based on firebolt, you can use order firebolt for it. But if you want to use an ability that was not listed in the dropdown list, you'll need to use custom script for that and you need to know the order ID of your ability.
Custom script: call IssueTargetOrderById(bj_lastCreatedUnit(), udg_YourAbilityId, GetEnumUnit())


There seems to be something wrong with the loop.

These are the check lines I added.

If the trigger is triggered, it will display "Casting recognised!"

If The loop works, it will display "Dummy created!"


Only "Casting recognised!" was shown and now I have no fricking idea what was wrong. I even changed the 'matching unit' in the loop condition to 'picked unit' but nothing works.

  • MindRot
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Firebolt (Neutral Hostile)
    • Actions
      • Game - Display to (All players) the text: Casting recognised!
      • Set MindrotTarget = (Target unit of ability being cast)
      • Set MindrotPosition = (Position of MindrotTarget)
      • Unit Group - Pick every unit in (Units within 300.00 of MindrotPosition matching (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: Dummy created!
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at MindrotPosition facing Default building facing degrees
          • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
          • Unit - Add Firebolt (Neutral Hostile) to (Last created unit)
          • Unit - Order (Last created unit) to Neutral - Firebolt (Picked unit)
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
I tried to simulate your code and apparently replacing
  • Events
    • Unit - A unit Finishes casting an ability
with
  • Events
    • Unit - A unit Starts the effect of an ability
fixed the issue.

I think Unit - A unit Finishes casting an ability is the problem, although I'm not sure why.
Hopefully, someone with better knowledge can help out with that.

Edit: after a little bit of searching. Uncle made an explanation about it before.
 
Level 7
Joined
Feb 22, 2009
Messages
239
I tried to simulate your code and apparently replacing
  • Events
    • Unit - A unit Finishes casting an ability
with
  • Events
    • Unit - A unit Starts the effect of an ability
fixed the issue.

I think Unit - A unit Finishes casting an ability is the problem, although I'm not sure why.
Hopefully, someone with better knowledge can help out with that.

Edit: after a little bit of searching. Uncle made an explanation about it before.
So everything leads me back to unit indexer then.

Wonder if I can set up a simple indexer for my map since I don't want to import too many other people's stuff.

The start the effect of an ability has a problem because people can abuse it with the stop animation thing and if the spell animation backswing is not 0, they can cancel the activation of the spell leading to the spell not being used but the effects being triggered allowing no-cooldown exploit of the trigger.
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
I think you've mistaken
  • Unit - A unit Begins casting an ability
as
  • Unit - A unit Starts the effect of an ability
The first one can be abused but the second one cannot, as far as I know.
Unit - A unit Starts the effect of an ability only fires when the spell is activated.
Unit - A unit Begins casting an ability however, fires before the spell is activated, thus leading to possibility of being abused with the no-cooldown exploit.
 
Level 7
Joined
Feb 22, 2009
Messages
239
I think you've mistaken
  • Unit - A unit Begins casting an ability
as
  • Unit - A unit Starts the effect of an ability
The first one can be abused but the second one cannot, as far as I know.
Unit - A unit Starts the effect of an ability only fires when the spell is activated.
Unit - A unit Begins casting an ability however, fires before the spell is activated, thus leading to possibility of being abused with the no-cooldown exploit.
You're right. I mistook those two. Thank you for all the help!
 
Level 7
Joined
Feb 22, 2009
Messages
239
No problem! Glad I can help.


I got an error.

1725785763801.png
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
You shouldn't write "Custom script" inside your Custom script. Instead, it should look something like this:
  • Custom script: call IssueTargetOrderById(bj_lastCreatedUnit, 852565, GetEnumUnit())
and the example I gave you previously had a little error, bj_lastCreatedUnit is without ().
So you can use the example from this post instead.
 
Top