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

Nature Cleave Trigger (Liquid Fire)

Status
Not open for further replies.
Level 11
Joined
Jul 9, 2009
Messages
927
I am trying to make a trigger where in, whenever a unit attacks, it has a 10% chance to damage and slow the attackspeed of a unit within 400 range. Here is the trigger I made.

  • Nature Cleave Trigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Nature Cleave for (Attacking unit)) Greater than or equal to 1
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Nature Cleave for (Attacking unit)) Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 100) Less than or equal to 10
            • Then - Actions
              • Unit Group - Pick every unit in (Random 1 units from (Units within 400.00 of (Position of (Attacking unit)) matching (((Picked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True))) and do (Actions)
                • Loop - Actions
                  • Unit - Create 1 Dummy (Nature Cleave) for (Owner of (Attacking unit)) at (Position of (Attacking unit)) facing Default building facing degrees
                  • Unit - Set level of Nature Cleave Slow (Neutral Hostile) for (Last created unit) to (Level of Nature Cleave for (Attacking unit))
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) has buff Shadow Strike) Equal to True
                    • Then - Actions
                      • Unit - Kill (Last created unit)
                    • Else - Actions
            • Else - Actions
        • Else - Actions
I dont see anything wrong with the trigger. If you see something wrong, please state the problem :D
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
  • (((Picked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True)))
Picked unit needs to be Matching unit. You should also check if the matching unit is alive.

Why do you have this condition?
  • (Level of Nature Cleave for (Attacking unit)) Equal to 1
Is the spell only supposed to work for one level?

You should use an expiration timer to remove the dummy since the buff won't instantly be on the affected unit.

You're also leaking locations and a unit group.
 
Level 11
Joined
Jul 9, 2009
Messages
927
Oh, so picked unit must be matching unit, thanks
and for the condition you were asking, There would be four levels, but different chances on working.
For the dummy, I shall follow your suggestion.
and for the leaks, I would fix it later. thanks for the help + rep :D Ill test it if it works

Offtopic :
Azumanga Daioh! :D
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
If the chance increases linearly with level, (like 5% increase per level) I would suggest doing something like this:
  • (Random integer number between 1 and 100) Less than or equal to 5 + 5 * (Level of Nature Cleave for (Attacking unit))
If it's not in a nice formula then use a global integer array to store the chance. This would save you from code duplication.

OT: Yay, someone recognizes my avatar! ^_^
 
Level 11
Joined
Nov 15, 2007
Messages
800
You definitely don't want to do a bunch of if/then/elses when you could do it the way watermelon suggested. It's very inefficient even by GUI standards.
 
Level 11
Joined
Jul 9, 2009
Messages
927
I followed every suggestions you made and it resulted into this trigger

  • Nature Cleave Trigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Nature Cleave for (Attacking unit)) Greater than or equal to 1
    • Actions
      • Set NCPosition = (Position of (Attacking unit))
      • Set NCRange = (Units within 400.00 of NCPosition matching ((((Matching unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Set NCEffect = (Position of (Picked unit))
      • Custom script: set bj_wantDestroyGroup=true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to (5 + (5 x (Level of Nature Cleave for (Attacking unit))))
        • Then - Actions
          • Unit - Create 1 Dummy (Nature Cleave) for (Owner of (Attacking unit)) at NCPosition facing Default building facing degrees
          • Unit - Set level of Nature Cleave Slow (Neutral Hostile) for (Last created unit) to (Level of Nature Cleave for (Attacking unit))
          • Unit Group - Pick every unit in (Random 1 units from NCRange) and do (Actions)
            • Loop - Actions
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Picked unit)
              • Special Effect - Create a special effect at NCEffect using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
              • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_NCPosition)
      • Custom script: call RemoveLocation(udg_NCEffect)
Is it right now ?? :D

EDIT :
  • Custom script: set bj_wantDestroyGroup=true
The trigger would not work when this line is present. When I tried to disable it, it worked. Where should I put this line to clear the unit group leak. or is it not necessary ?
 
Level 11
Joined
Jul 9, 2009
Messages
927
oh, ok then. Thanks for the help both of you, +rep :D

EDIT:
Clearing the group leak still makes the trigger not work. maybe I should not clear the group leak anymore ?
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
1,084
"set bj_wantDestroyGroup = true"
not "set bj_wantDestroyGroup=true"
The spaces actually don't matter except for making it look nicer.

You shouldn't be using it though because it conflicts with
  • Unit Group - Pick every unit in (Random 1 units from NCRange) and do (Actions)
Instead, have a unit variable and set that to
  • (Random 1 units from NCRange)
Then, NCEffect should be set to the position of that unit. When you clear the location leaks, destroy the group NCRange as well with
  • Custom script: call DestroyGroup(udg_NCRange )
I'd also suggesting setting all the variables only when the chance occurs (inside the if-part) because you would be wasting calls if the chance didn't occur.
 
Level 11
Joined
Jul 9, 2009
Messages
927
ok, I have set everything right now I think :D
  • Nature Cleave Trigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Nature Cleave for (Attacking unit)) Greater than or equal to 1
    • Actions
      • Set NCPosition = (Position of (Attacking unit))
      • Set NCRange = (Units within 400.00 of (Position of (Attacking unit)) matching ((((Matching unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Greater than or equal to (5 + (5 x (Level of Nature Cleave for (Attacking unit))))
        • Then - Actions
          • Unit - Create 1 Dummy (Nature Cleave) for (Owner of (Attacking unit)) at NCPosition facing Default building facing degrees
          • Unit - Set level of Nature Cleave Slow (Neutral Hostile) for (Last created unit) to (Level of Nature Cleave for (Attacking unit))
          • Unit Group - Pick every unit in (Random 1 units from NCRange) and do (Actions)
            • Loop - Actions
              • Set NCUnit = (Picked unit)
              • Set NCEffect = (Position of (Picked unit))
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike NCUnit
              • Special Effect - Create a special effect at NCEffect using NewSparksEX.mdx
              • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_NCPosition)
      • Custom script: call RemoveLocation(udg_NCEffect)
      • Custom script: call DestroyGroup(udg_NCRange)
Thank you for helping me, now I know more about leaks :D
Only one question though, how can I make the special effect show only after the projectile missile of Nature Cleave have hit the opponent ?
As of now, the special effect comes first even before the projectile of Nature Cleave hits the opponent :D
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
That's not quite what I meant.
  • Set NCPosition = (Position of (Attacking unit))
  • Set NCRange = (Units within 400.00 of (Position of (Attacking unit)) matching ((((Matching unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
should be in the if-part after
  • (Random integer number between 1 and 100) Greater than or equal to (5 + (5 x (Level of Nature Cleave for (Attacking unit))))
You would also move clearing the leaks inside the if part as well. They would be after you destroyed the effect.

Now
  • Set NCUnit = (Picked unit)
should be
  • Set NCUnit = (Random unit from NCRange)
This avoids the useless group enumeration and saves you from having to clear that leak.

For the special effect, is it possible for you to show it as part of the slow buff or the target art of the ability? The other way might be to wait Distance between the units / Speed of the missile and then create the effect, but it's pretty inaccurate.
 
Level 11
Joined
Jul 9, 2009
Messages
927
I tried to set NCUnit as random unit from NCRange, but then the random unit that the variable gets is not the random unit that the trigger gets. so for example there are two opponents, necrolyte and a ghoul, the ghoul gets hit by the skill, but then the explosion shows up on the necrolyte. :D

Anyway, thanks again for helping me and teaching me about leaks. Problem Solved :)
 
Status
Not open for further replies.
Top