• 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] Heal depends on heroes number

Status
Not open for further replies.
  1. Enumerate all units within range of that unit.
  2. Filter out Heroes from units within the group, either in filtering phase or enumeration phase (
    • Unit Group - Pick all units in <unit group> and do (Actions)
    )
  3. Get the resulting number of units in the group.
  4. Do your healing mechanic here. (Edited)
Btw, how would your healing mechanic work exactly?
 
Level 8
Joined
Jul 10, 2018
Messages
383
  1. Enumerate all units within range of that unit.
  2. Filter out Heroes from units within the group, either in filtering phase or enumeration phase (
    • Unit Group - Pick all units in <unit group> and do (Actions)
    )
  3. Get the resulting number of units in the group.
  4. Do your healing mechanic here. (Edited)
Btw, how would your healing mechanic work exactly?
I want it to have 5 seconds before happening so player get a chance to run before the boss healing off them and i tried to do all you just said but its not working :(
 
So the healing mechanic behaves like this? (Pseudo-code below)
Lua:
PlayerEvent:watch(EVENT_PLAYER_UNIT_SPELL_EFFECT, function()
    doAfter(5.00, function()
        enumUnitsInRange()
        filterHeroes()
        getGroupCount()
        doHeal()
    end)
end)

If so, then 2 triggers can be configured to do what you need to do in GUI (if map script is in vJASS, otherwise it would be trivial in Lua).

Delayed Trigger Effect:
  • Delayed Trigger Effect
    • Events
      • Event - Every <interval> seconds of game-time
    • Conditions
    • Actions
      • For each (Integer <index_var>) from 1 to <spell_max_index>, do (Actions)
        • Loop - Actions
          • Set <remaining_dur_var>[<index_var>] = <remaining_dur_var>[<index_var>] - <interval>
          • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • <remaining_dur_var>[<index_var>] less than or equal to 0.00
            • Then - Actions
              • -------- Do the enumeration and filtering portion here --------
              • Set <temp_point> = (Position of <spell_unit>[<index_var>])
              • Set <enum_group> = Units within <spell_range> of <temp_point>
              • Unit Group - Pick every unit in <enum_group> and do (Actions)
                • Loop - Actions
                  • -------- Apply filter here. If the unit doesn't pass the filter, remove it from the group --------
              • Set <hero_count> = (Number of units in <enum_group>)
              • -------- Do the healing mechanic here --------
              • -------- Dynamic Indexing clean-up --------
              • Set <spell_unit>[<index_var>] = <spell_unit>[<spell_max_index>]
              • Set <spell_unit>[<spell_max_index>] = No unit
              • Set <spell_max_index> = <spell_max_index> - 1
              • Set <index_var> = <index_var> - 1
            • Else - Actions
Watching Trigger (The trigger that will activate the Delayed Effect Trigger)
  • Watching Trigger
    • Events
    • Conditions
    • Actions
      • -------- The Core actions --------
      • Set <spell_max_index> = <spell_max_index> + 1
      • Set <spell_unit>[<spell_max_index>] = (The Desired unit)
      • -------- Activate the Delayed Trigger Effect --------
      • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • <spell_max_index> Equal To 1
        • Then - Actions
          • Trigger - Turn on Delayed Trigger Effect
        • Else - Actions
 
Level 8
Joined
Jul 10, 2018
Messages
383
So the healing mechanic behaves like this? (Pseudo-code below)
Lua:
PlayerEvent:watch(EVENT_PLAYER_UNIT_SPELL_EFFECT, function()
    doAfter(5.00, function()
        enumUnitsInRange()
        filterHeroes()
        getGroupCount()
        doHeal()
    end)
end)

If so, then 2 triggers can be configured to do what you need to do in GUI (if map script is in vJASS, otherwise it would be trivial in Lua).

Delayed Trigger Effect:
  • Delayed Trigger Effect
    • Events
      • Event - Every <interval> seconds of game-time
    • Conditions
    • Actions
      • For each (Integer <index_var>) from 1 to <spell_max_index>, do (Actions)
        • Loop - Actions
          • Set <remaining_dur_var>[<index_var>] = <remaining_dur_var>[<index_var>] - <interval>
          • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • <remaining_dur_var>[<index_var>] less than or equal to 0.00
            • Then - Actions
              • -------- Do the enumeration and filtering portion here --------
              • Set <temp_point> = (Position of <spell_unit>[<index_var>])
              • Set <enum_group> = Units within <spell_range> of <temp_point>
              • Unit Group - Pick every unit in <enum_group> and do (Actions)
                • Loop - Actions
                  • -------- Apply filter here. If the unit doesn't pass the filter, remove it from the group --------
              • Set <hero_count> = (Number of units in <enum_group>)
              • -------- Do the healing mechanic here --------
              • -------- Dynamic Indexing clean-up --------
              • Set <spell_unit>[<index_var>] = <spell_unit>[<spell_max_index>]
              • Set <spell_unit>[<spell_max_index>] = No unit
              • Set <spell_max_index> = <spell_max_index> - 1
              • Set <index_var> = <index_var> - 1
            • Else - Actions
Watching Trigger (The trigger that will activate the Delayed Effect Trigger)
  • Watching Trigger
    • Events
    • Conditions
    • Actions
      • -------- The Core actions --------
      • Set <spell_max_index> = <spell_max_index> + 1
      • Set <spell_unit>[<spell_max_index>] = (The Desired unit)
      • -------- Activate the Delayed Trigger Effect --------
      • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • <spell_max_index> Equal To 1
        • Then - Actions
          • Trigger - Turn on Delayed Trigger Effect
        • Else - Actions
i dont want it to be every second lol just heals instantly if there are units around him
 
Level 8
Joined
Jul 10, 2018
Messages
383
So the healing mechanic behaves like this? (Pseudo-code below)
Lua:
PlayerEvent:watch(EVENT_PLAYER_UNIT_SPELL_EFFECT, function()
    doAfter(5.00, function()
        enumUnitsInRange()
        filterHeroes()
        getGroupCount()
        doHeal()
    end)
end)

If so, then 2 triggers can be configured to do what you need to do in GUI (if map script is in vJASS, otherwise it would be trivial in Lua).

Delayed Trigger Effect:
  • Delayed Trigger Effect
    • Events
      • Event - Every <interval> seconds of game-time
    • Conditions
    • Actions
      • For each (Integer <index_var>) from 1 to <spell_max_index>, do (Actions)
        • Loop - Actions
          • Set <remaining_dur_var>[<index_var>] = <remaining_dur_var>[<index_var>] - <interval>
          • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • <remaining_dur_var>[<index_var>] less than or equal to 0.00
            • Then - Actions
              • -------- Do the enumeration and filtering portion here --------
              • Set <temp_point> = (Position of <spell_unit>[<index_var>])
              • Set <enum_group> = Units within <spell_range> of <temp_point>
              • Unit Group - Pick every unit in <enum_group> and do (Actions)
                • Loop - Actions
                  • -------- Apply filter here. If the unit doesn't pass the filter, remove it from the group --------
              • Set <hero_count> = (Number of units in <enum_group>)
              • -------- Do the healing mechanic here --------
              • -------- Dynamic Indexing clean-up --------
              • Set <spell_unit>[<index_var>] = <spell_unit>[<spell_max_index>]
              • Set <spell_unit>[<spell_max_index>] = No unit
              • Set <spell_max_index> = <spell_max_index> - 1
              • Set <index_var> = <index_var> - 1
            • Else - Actions
Watching Trigger (The trigger that will activate the Delayed Effect Trigger)
  • Watching Trigger
    • Events
    • Conditions
    • Actions
      • -------- The Core actions --------
      • Set <spell_max_index> = <spell_max_index> + 1
      • Set <spell_unit>[<spell_max_index>] = (The Desired unit)
      • -------- Activate the Delayed Trigger Effect --------
      • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • <spell_max_index> Equal To 1
        • Then - Actions
          • Trigger - Turn on Delayed Trigger Effect
        • Else - Actions
and no jass please!
 
and no jass please!
i dont want it to be every second lol just heals instantly if there are units around him
It actually doesn't heal the unit periodically. It just waits until the remaining duration reaches 0, and does its' business once it does, and gets removed from the loop thereafter. The principles behind this can be read here: Visualize: Dynamic Indexing

Also, jass cannot be avoided in this situation, since there are leaks in the given triggers. However, they are mostly one-liner scripts. A guide can be found here: Memory Leaks

The desired objects to clean up are the group and point variables. They are mostly located in the Delayed Trigger Effect.

  • Delayed Trigger Effect
    • Events
      • Event - Every <interval> seconds of game-time
    • Conditions
    • Actions
      • For each (Integer <index_var>) from 1 to <spell_max_index>, do (Actions)
        • Loop - Actions
          • Set <remaining_dur_var>[<index_var>] = <remaining_dur_var>[<index_var>] - <interval>
          • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • <remaining_dur_var>[<index_var>] less than or equal to 0.00
            • Then - Actions
              • -------- Do the enumeration and filtering portion here --------
              • Set <temp_point> = (Position of <spell_unit>[<index_var>])
              • Set <enum_group> = Units within <spell_range> of <temp_point>
              • Unit Group - Pick every unit in <enum_group> and do (Actions)
                • Loop - Actions
                  • -------- Apply filter here. If the unit doesn't pass the filter, remove it from the group --------
              • Set <hero_count> = (Number of units in <enum_group>)
              • -------- Do the healing mechanic here --------
              • -------- Dynamic Indexing clean-up --------
              • Set <spell_unit>[<index_var>] = <spell_unit>[<spell_max_index>]
              • Set <spell_unit>[<spell_max_index>] = No unit
              • Set <spell_max_index> = <spell_max_index> - 1
              • Set <index_var> = <index_var> - 1
            • Else - Actions
  • Watching Trigger
    • Events
    • Conditions
    • Actions
      • -------- The Core actions --------
      • Set <spell_max_index> = <spell_max_index> + 1
      • Set <spell_unit>[<spell_max_index>] = (The Desired unit)
      • -------- Activate the Delayed Trigger Effect --------
      • If - If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • <spell_max_index> Equal To 1
        • Then - Actions
          • Trigger - Turn on Delayed Trigger Effect
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
What MyPad suggested is for creating an MUI spell. This design is done so that the spell works for multiple units/multiple casts from the same unit. This is great to learn and pretty much required for making MUI spells in GUI.

However, I know from seeing your other triggers that you probably only have 1 Boss casting this spell (Or whatever Event it is that you're using) and MUI is not an issue.

So I think this is what you're looking for:
  • Boss Heal
    • Events
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Set Variable TempPoint = (Position of YourBossUnit)
      • Set Variable HealCount = 0
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 500.00 of TempPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set Variable HealCount = (HealCount + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealCount Greater than 0
        • Then - Actions
          • Unit - Set life of YourBossUnit to ((Percentage life of YourBossUnit) + ((Real(HealCount)) x 10.00))%
        • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
This will Heal the boss for 10% health for each nearby Hero after a 5.00 second delay. I don't know what Events you wanted to use so I left them blank.

You need to explain what you want/your issues in greater detail so people can help you out properly. Remember that it can be difficult to provide a solution when there's so many different methods to solving a problem. Try to remember this when asking for help!
 
Last edited:
Level 8
Joined
Jul 10, 2018
Messages
383
What MyPad suggested is for creating an MUI spell. This design is done so that the spell works for multiple units/multiple casts from the same unit. This is great to learn and pretty much required for making MUI spells in GUI.

However, I know from seeing your other triggers that you probably only have 1 Boss casting this spell (Or whatever Event it is that you're using) and MUI is not an issue.

So I think this is what you're looking for:
  • Boss Heal
    • Events
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Set Variable TempPoint = (Position of YourBossUnit)
      • Set Variable HealCount = 0
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 500.00 of TempPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set Variable HealCount = (HealCount + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealCount Greater than 0
        • Then - Actions
          • Unit - Set life of YourBossUnit to ((Percentage life of YourBossUnit) + ((Real(HealCount)) x 10.00))%
        • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
This will Heal the boss for 10% health for each nearby Hero after a 5.00 second delay. I don't know what Events you wanted to use so I left them blank.

You need to explain what you want/your issues in greater detail so people can help you out properly. Remember that it can be difficult to provide a solution when there's so many different methods to solving a problem. Try to remember this when asking for help!
i sure will do!
 
Status
Not open for further replies.
Top