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

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
(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
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
  • Unit - Cause Prince Davan Denerthor 0000 <gen> to damage (Matching unit), dealing 100000.00 damage of attack type Spells and damage type Normal
(Picked unit) instead of (Matching unit) - have you looked at my script?

HolyNova.mdx is a custom model, check the textures and ensure model works properly.
 
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