• 🏆 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!

Triggering a spell

Status
Not open for further replies.
Level 28
Joined
Feb 18, 2014
Messages
3,579
Is it for a specific unit or generic ? If it's the first then you can do this :
  • Siphon Mana
    • Events
      • Unit - Blood Mage 0000 <gen>'s mana becomes Less than 400.00
    • Conditions
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Unit - Order (Triggering unit) to Human Blood Mage - Siphon Mana (Random unit from (Units within 600.00 of Point matching ((Mana of (Matching unit)) Greater than 0.00)))
      • Custom script: call RemoveLocation (udg_Point)
If it's the latter, then remove the event on the above trigger and do this at Map Initialization :
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Siphon Mana <gen> the event (Unit - (Picked unit)'s mana becomes Less than 400.00))
 
Is it for a specific unit or generic ? If it's the first then you can do this :
  • Siphon Mana
    • Events
      • Unit - Blood Mage 0000 <gen>'s mana becomes Less than 400.00
    • Conditions
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Unit - Order (Triggering unit) to Human Blood Mage - Siphon Mana (Random unit from (Units within 600.00 of Point matching ((Mana of (Matching unit)) Greater than 0.00)))
      • Custom script: call RemoveLocation (udg_Point)
If it's the latter, then remove the event on the above trigger and do this at Map Initialization :
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Siphon Mana <gen> the event (Unit - (Picked unit)'s mana becomes Less than 400.00))

Just take care of memory leaks at the point where the unit is told to siphon Mana a target.
 
Level 9
Joined
Apr 22, 2020
Messages
430
Thank you so much guys and can i have one more request? How do you trigger a hero with a starfall ability to use its ability if thier are more than 6 units? Unfortunately my hero uses the starfall ability when there is an enemy hero so i want my hero to use starfall even if there are no enemy heroe's.
 
It will take at least 2 triggers to produce the intended effect.

First trigger: (Logic flow)
Event: Every <period> seconds of game-time
Actions:
Pick all units in <container group> and do the following:
Set <enemy count> to 0
Enumerate units within range of picked unit.
Pick all units in <enumerated group> and do the following:
(Check if picked unit is alive and an enemy)
If (Condition is true) then
Add 1 to <enemy count>
Endif
(Check if enemy count is greater than or equal to 6)
If (Condition) then
Order picked unit to Starfall
Endif

Second trigger:
Actions
Add desired unit to the <container group>
 
Level 9
Joined
Apr 22, 2020
Messages
430
It will take at least 2 triggers to produce the intended effect.

First trigger: (Logic flow)
Event: Every <period> seconds of game-time
Actions:
Pick all units in <container group> and do the following:
Set <enemy count> to 0
Enumerate units within range of picked unit.
Pick all units in <enumerated group> and do the following:
(Check if picked unit is alive and an enemy)
If (Condition is true) then
Add 1 to <enemy count>
Endif
(Check if enemy count is greater than or equal to 6)
If (Condition) then
Order picked unit to Starfall
Endif

Second trigger:
Actions
Add desired unit to the <container group>
Okay a little bit confusing can you just embed the trigger here? I only rely on embeded triggers to fully understand the triggers and also does this trigger need to have a variable?
 
Okay a little bit confusing can you just embed the trigger here? I only rely on embeded triggers to fully understand the triggers and also does this trigger need to have a variable?

Alright. Here's the first trigger: (Both triggers require variables and first trigger is not optimized yet to remove memory leaks)

  • Events
    • Game: Every <period> seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick all units in <container group> and do (Loop - Actions)
      • Loop - Actions
        • Set <enemy count> = 0
        • Set <temp unit> = (Picked unit)
        • Unit Group - Pick all units in (units in <desired range> range of (Position of <temp unit>) and do (Loop - 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 (Owner of <temp unit>) Equal to true
              • Then - Actions
                • Set <enemy count> = <enemy count> + 1
              • Else - Actions
        • If (All Conditions are True) then do (Then - Actions) else do (Else - Actions)
          • If - Conditions
            • <enemy count> Greater than or Equal to 6
          • Then - Actions
            • Unit - Order <temp unit> to Night Elf Priestess of the Moon - Starfall
          • Else - Actions
The second trigger

  • Events
  • Conditions
  • Actions
    • Unit Group - Add <desired unit> to <container group>
 
Level 9
Joined
Apr 22, 2020
Messages
430
Alright. Here's the first trigger: (Both triggers require variables and first trigger is not optimized yet to remove memory leaks)

  • Events
    • Game: Every <period> seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick all units in <container group> and do (Loop - Actions)
      • Loop - Actions
        • Set <enemy count> = 0
        • Set <temp unit> = (Picked unit)
        • Unit Group - Pick all units in (units in <desired range> range of (Position of <temp unit>) and do (Loop - 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 (Owner of <temp unit>) Equal to true
              • Then - Actions
                • Set <enemy count> = <enemy count> + 1
              • Else - Actions
        • If (All Conditions are True) then do (Then - Actions) else do (Else - Actions)
          • If - Conditions
            • <enemy count> Greater than or Equal to 6
          • Then - Actions
            • Unit - Order <temp unit> to Night Elf Priestess of the Moon - Starfall
          • Else - Actions
The second trigger

  • Events
  • Conditions
  • Actions
    • Unit Group - Add <desired unit> to <container group>
Thank you so much you have helped me alot and can i ask what's the use of the second trigger and why is it separated from the other trigger? And also as i have asked before does this trigger have a variable if thier are can you tell me what type of variable they are thanks! (Sorry for keep asking questions i just really wanna make sure that i have understood this trigger)
 
The second trigger is for adding a desired unit (who can cast Starfall) into the container group. The second trigger is a plain trigger which adds a desired unit. Due to the ambiguity of the desired unit, I have left it as is.

The two triggers presented require variables.
<container group> is a unit group variable.
<enemy count> is an integer.
<temp unit> is a unit.
 
Level 9
Joined
Apr 22, 2020
Messages
430
The second trigger is for adding a desired unit (who can cast Starfall) into the container group. The second trigger is a plain trigger which adds a desired unit. Due to the ambiguity of the desired unit, I have left it as is.

The two triggers presented require variables.
<container group> is a unit group variable.
<enemy count> is an integer.
<temp unit> is a unit.
Thank you so much for your help! Now my AI Heroes will be much more usefull.
 
Level 9
Joined
Apr 22, 2020
Messages
430
The second trigger is for adding a desired unit (who can cast Starfall) into the container group. The second trigger is a plain trigger which adds a desired unit. Due to the ambiguity of the desired unit, I have left it as is.

The two triggers presented require variables.
<container group> is a unit group variable.
<enemy count> is an integer.
<temp unit> is a unit.
Well okay sorry for the late reply but the Enemy count (Integer) does not appear in If conditions - (Enemy count) greater than equal to 6 only the temp unit variable why is this?
 
Status
Not open for further replies.
Top