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

[Solved] Problem with trigger

Status
Not open for further replies.
Level 3
Joined
Sep 1, 2011
Messages
25
I want a unit to cast a strong nova when he reaches 10 mana, damaging all surrounding enemy units, atm I got this trigger:

  • Events
    • Unit - Prince Davan Denerthor 0000 <gen>'s mana becomes Equal to 10.00
  • Conditions
  • Actions
    • Unit Group - Pick every unit in (Units within 100.00 of (Position of Prince Davan Denerthor 0000 <gen>) matching ((Owner of (Picked unit)) Equal to Neutral Hostile)) and do (Actions)
      • Loop - Actions
        • Unit - Cause Prince Davan Denerthor 0000 <gen> to damage (Picked unit), dealing 100000.00 damage of attack type Spells and damage type Normal
        • Special Effect - Create a special effect attached to the origin of Prince Davan Denerthor 0000 <gen> using Holy Nova.mdx
        • Set Davan_10_mana = (Last created special effect)
        • Unit - Set mana of Prince Davan Denerthor 0000 <gen> to 0.00
        • Wait 2.00 seconds
        • Special Effect - Destroy Davan_10_mana
I tried with removing the "matching condition" and then it worked, but then my other units got damage obviously. So, got any tips?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The condition function does not define a "Picked unit" as no unit was picked yet. What you want is "Matching unit".

Also Waits are not permitted in group/force/destructables/items loops and you would overwrite your global variable anyway before the 2 seconds are over, thereby only destroying the last effect.
 
(Matching unit) instead of (Picked unit).
Leaks group and location handle.

  • Events
    • Unit - Prince Davan Denerthor 0000 <gen>'s mana becomes Equal to 10.00
  • Conditions
  • Actions
    • Set p = (Position of Prince Davan Denerthor 0000 <gen>)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 100.00 of p matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Actions)
      • Loop - Actions
        • Unit - Cause Prince Davan Denerthor 0000 <gen> to damage (Picked unit), dealing 100000.00 damage of attack type Spells and damage type Normal
        • Special Effect - Create a special effect attached to the origin of Prince Davan Denerthor 0000 <gen> using Holy Nova.mdx
        • Special Effect - Destroy (Last created special effect)
        • Unit - Set mana of Prince Davan Denerthor 0000 <gen> to 0.00
    • Custom script: call RemoveLocation(udg_p)
To give delay before destroy effect you should do something like:
  • init
    • Events
    • Conditions
    • Actions
      • Custom script: local effect e = bj_lastCreatedEffect
      • Wait 2.00
      • Custom script: call DestroyEffect(e)
      • Custom script: set e = null
And in your main trigger, just after creating special effect add (remember not to add Special effect - Destroy (...) like I did above, if you are going to follow this way):
  • Special Effect - Create a special effect attached to the origin of Prince Davan Denerthor 0000 <gen> using Holy Nova.mdx
  • Trigger - Run init <gen> (Ignoring ocniditons)
 
Last edited:
Level 3
Joined
Sep 1, 2011
Messages
25
I have:
  • Events
    • Unit - Prince Davan Denerthor 0000 <gen>'s mana becomes Equal to 10.00
  • Conditions
  • Actions
    • Set Davan_position = (Position of Prince Davan Denerthor 0000 <gen>)
    • Custom script: bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 100.00 of Davan_position matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Actions)
      • Loop - Actions
        • Unit - Cause Prince Davan Denerthor 0000 <gen> to damage (Matching unit), dealing 100000.00 damage of attack type Spells and damage type Normal
        • Unit - Set mana of Prince Davan Denerthor 0000 <gen> to 0.00
    • Custom script: call RemoveLocation(udg_Davan_position)
    • Special Effect - Create a special effect attached to the origin of Prince Davan Denerthor 0000 <gen> using Holy Nova.mdx
    • Set Davan_10_mana = (Last created special effect)
    • Wait 2.00 seconds
    • Special Effect - Destroy Davan_10_mana
But every time I try to start the map to try it out I get the error message "Expected 'set'" on line:
call ForGroupBJ( GetUnitsInRangeOfLocMatching(100.00, udg_Davan_position, Condition(function Trig_Davan_Max_Mana_Func003001003)), function Trig_Davan_Max_Mana_Func003A )
 
Level 3
Joined
Sep 1, 2011
Messages
25
The trigger still don't work for some reason. The damage nor effect won't appear.

  • Davan Max Mana
    • Events
      • Unit - Prince Davan Denerthor 0000 <gen>'s mana becomes Equal to 10.00
    • Conditions
    • Actions
      • Set Davan_position = (Position of Prince Davan Denerthor 0000 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 100.00 of Davan_position matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Actions)
        • Loop - Actions
          • Unit - Cause Prince Davan Denerthor 0000 <gen> to damage (Matching unit), dealing 100000.00 damage of attack type Spells and damage type Normal
          • Unit - Set mana of Prince Davan Denerthor 0000 <gen> to 0.00
      • Custom script: call RemoveLocation(udg_Davan_position)
      • Special Effect - Create a special effect attached to the origin of Prince Davan Denerthor 0000 <gen> using Holy Nova.mdx
      • Set Davan_10_mana = (Last created special effect)
      • Wait 2.00 seconds
      • Special Effect - Destroy Davan_10_mana
 
Level 3
Joined
Sep 1, 2011
Messages
25
I finally fixed it :) turns out the event didn't work for some odd reason. I changed to
  • Unit - Prince Davan Denerthor 0000 <gen>'s mana becomes Greater than or equal to 9.00
and now it works perfectly. Thanks guys! :)

EDIT: I tried with both matching and picked unit and both didn't work until I changed the event.
 
Status
Not open for further replies.
Top