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

How to damage units once

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
How do I damage units once they come near the Ball using either buff or unit groups?

I've been trying with both, and it led me to failure.

Here's the trigger if you need it:
  • Ball Of Lightning Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- ================================================ --------
      • For each (Integer BoL_Loop) from 1 to BoL_MaxIndex, do (Actions)
        • Loop - Actions
          • -------- ================================================ --------
          • Set BoL_Point[1] = (Position of BoL_Dummy2[BoL_Loop])
          • Set BoL_Point[2] = (Position of BoL_Dummy[BoL_Loop])
          • -------- ================================================ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between BoL_Point[1] and BoL_Point[2]) Greater than 1000.00
            • Then - Actions
              • -------- ================================================ --------
              • Unit - Kill BoL_Dummy[BoL_Loop]
              • Unit - Kill BoL_Dummy2[BoL_Loop]
              • -------- ================================================ --------
              • Set BoL_TrigUnit[BoL_Loop] = BoL_TrigUnit[BoL_MaxIndex]
              • Set BoL_TrigUnit[BoL_MaxIndex] = No unit
              • Set BoL_Dummy[BoL_Loop] = BoL_Dummy[BoL_MaxIndex]
              • Set BoL_Dummy[BoL_MaxIndex] = No unit
              • Set BoL_Dummy2[BoL_Loop] = BoL_Dummy2[BoL_MaxIndex]
              • Set BoL_Dummy2[BoL_MaxIndex] = No unit
              • Set BoL_SpellLvl[BoL_Loop] = BoL_SpellLvl[BoL_MaxIndex]
              • Set BoL_DamageDealt[BoL_Loop] = BoL_DamageDealt[BoL_MaxIndex]
              • Set BoL_Angle[BoL_Loop] = BoL_Angle[BoL_MaxIndex]
              • Set BoL_MaxIndex = (BoL_MaxIndex - 1)
              • Set BoL_Loop = (BoL_Loop - 1)
              • -------- ================================================ --------
            • Else - Actions
              • -------- ================================================ --------
              • Set BoL_Point[3] = (BoL_Point[2] offset by 10.00 towards BoL_Angle[BoL_Loop] degrees)
              • Set BoL_UnitGroup[1] = (Units within 150.00 of BoL_Point[2] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is in BoL_UnitGroup[2]) Equal to False) and (((Life of (Matching unit)) Greater than 0.41) and (((Matching unit) belongs to an enemy of (Ow
              • -------- ================================================ --------
              • Unit Group - Pick every unit in BoL_UnitGroup[1] and do (Actions)
                • Loop - Actions
                  • Unit - Cause BoL_TrigUnit[BoL_Loop] to damage (Picked unit), dealing BoL_DamageDealt[BoL_Loop] damage of attack type Spells and damage type Normal
                  • Unit Group - Add (Picked unit) to BoL_UnitGroup[2]
              • -------- ================================================ --------
              • Unit - Move BoL_Dummy[BoL_Loop] instantly to BoL_Point[3]
              • -------- ================================================ --------
              • Custom script: call RemoveLocation(udg_BoL_Point[3])
              • Custom script: call DestroyGroup(udg_BoL_UnitGroup[1])
              • -------- ================================================ --------
          • -------- ================================================ --------
          • Custom script: call RemoveLocation(udg_BoL_Point[1])
          • Custom script: call RemoveLocation(udg_BoL_Point[2])
          • -------- ================================================ --------
      • -------- ================================================ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BoL_MaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • -------- ================================================ --------
      • Custom script: set udg_BoL_UnitGroup[1] = null
      • Custom script: set udg_BoL_Point[2] = null
      • Custom script: set udg_BoL_Point[3] = null
 
What's the point of adding a group then? :eek: He could just use bj_wantDestroyGroup and a group pick with an ITE. I think if Phoenix Fire does not work, he could separately index a caster-target relationship (instead of caster-group) so he could set a timer for all targets individually.
 
This is how to do it very simply.

  • UnitInRangeSingleDamage
    • Events
      • Unit - A unit comes within 256.00 of BallUnit
    • Conditions
      • ((Triggering unit) is in ballSingleDamageUnitGroup) Equal to False
    • Actions
      • Set tempUnit = (Triggering unit)
      • Unit - Cause BallUnit to damage tempUnit, dealing 100.00 damage of attack type Spells and damage type Normal
      • Unit Group - Add tempUnit to ballSingleDamageUnitGroup
      • Set tempUnit = No unit
The ball unit must be placed on the map in order for this to work. You can change the event and add it later when the ball gets created.

The unit group should never get removed and never be touched.

This will check if unit is in unit group then damage and add it to group if it is not in the unit group. That is how you make something only attack a unit once and that is all.

If you make multiple Balls and spawn them I can make a new way that is more efficient thanadding tons of triggers. The above works perfect and is efficient but only for one unit.
 
Last edited:
Level 18
Joined
May 11, 2012
Messages
2,103
@OP

I sent the spell back to you through pm. You may want to post it on here so people can see how to damage a unit once with a unit group in a spell.

Good Idea m8.

There you go:
  • Ball Of Lightning
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ball Of Lightning
    • Actions
      • -------- ================================================ --------
      • Set BoL_MaxIndex = (BoL_MaxIndex + 1)
      • Set BoL_TrigUnit[BoL_MaxIndex] = (Triggering unit)
      • Set BoL_SpellLvl[BoL_MaxIndex] = (Level of Ball Of Lightning for BoL_TrigUnit[BoL_MaxIndex])
      • Set BoL_DamageDealt[BoL_MaxIndex] = BoL_Damage[BoL_SpellLvl[BoL_MaxIndex]]
      • Set BoL_Point[1] = (Position of BoL_TrigUnit[BoL_MaxIndex])
      • Set BoL_Point[2] = (Target point of ability being cast)
      • Set BoL_Angle[BoL_MaxIndex] = (Angle from BoL_Point[1] to BoL_Point[2])
      • -------- ================================================ --------
      • Unit - Create 1 Ball Of Lightning for (Triggering player) at BoL_Point[1] facing Default building facing degrees
      • Set BoL_Dummy[BoL_MaxIndex] = (Last created unit)
      • Unit - Add Dummy Ball Of Lightning to BoL_Dummy[BR_MaxIndex]
      • Unit - Set level of Dummy Ball Of Lightning for BoL_Dummy[BoL_MaxIndex] to (Level of Ball Of Lightning for BoL_TrigUnit[BoL_MaxIndex])
      • -------- ================================================ --------
      • Unit - Create 1 Dummy Ball Of Lightning 2 for (Triggering player) at BoL_Point[1] facing Default building facing degrees
      • Set BoL_Dummy2[BoL_MaxIndex] = (Last created unit)
      • -------- ================================================ --------
      • Custom script: set udg_BoL_UnitGroup[udg_BoL_MaxIndex] = CreateGroup()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BoL_MaxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on Ball Of Lightning Loop <gen>
        • Else - Actions
      • -------- ================================================ --------
      • Custom script: call RemoveLocation(udg_BoL_Point[1])
      • Custom script: call RemoveLocation(udg_BoL_Point[2])
  • Ball Of Lightning Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- ================================================ --------
      • For each (Integer BoL_Loop) from 1 to BoL_MaxIndex, do (Actions)
        • Loop - Actions
          • -------- ================================================ --------
          • Set BoL_Point[1] = (Position of BoL_Dummy2[BoL_Loop])
          • Set BoL_Point[2] = (Position of BoL_Dummy[BoL_Loop])
          • -------- ================================================ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between BoL_Point[1] and BoL_Point[2]) Greater than 1000.00
            • Then - Actions
              • -------- ================================================ --------
              • Unit - Kill BoL_Dummy[BoL_Loop]
              • Unit - Kill BoL_Dummy2[BoL_Loop]
              • -------- ================================================ --------
              • Set BoL_TrigUnit[BoL_Loop] = BoL_TrigUnit[BoL_MaxIndex]
              • Set BoL_TrigUnit[BoL_MaxIndex] = No unit
              • Set BoL_Dummy[BoL_Loop] = BoL_Dummy[BoL_MaxIndex]
              • Set BoL_Dummy[BoL_MaxIndex] = No unit
              • Set BoL_Dummy2[BoL_Loop] = BoL_Dummy2[BoL_MaxIndex]
              • Set BoL_Dummy2[BoL_MaxIndex] = No unit
              • Set BoL_SpellLvl[BoL_Loop] = BoL_SpellLvl[BoL_MaxIndex]
              • Set BoL_DamageDealt[BoL_Loop] = BoL_DamageDealt[BoL_MaxIndex]
              • Set BoL_Angle[BoL_Loop] = BoL_Angle[BoL_MaxIndex]
              • Custom script: call DestroyGroup(udg_BoL_UnitGroup[udg_BoL_Loop])
              • Set BoL_UnitGroup[BoL_Loop] = BoL_UnitGroup[BoL_MaxIndex]
              • Custom script: set udg_BoL_UnitGroup[udg_BoL_MaxIndex] = null
              • Set BoL_MaxIndex = (BoL_MaxIndex - 1)
              • Set BoL_Loop = (BoL_Loop - 1)
              • -------- ================================================ --------
            • Else - Actions
              • -------- ================================================ --------
              • Set BoL_Point[3] = (BoL_Point[2] offset by 10.00 towards BoL_Angle[BoL_Loop] degrees)
              • -------- ================================================ --------
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 150.00 of BoL_Point[2]) and do (Actions)
                • Loop - Actions
                  • Set TempUnit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TempUnit is A structure) Equal to False
                      • (TempUnit belongs to an enemy of (Owner of BoL_TrigUnit[BoL_Loop])) Equal to True
                      • (TempUnit is dead) Equal to False
                      • (TempUnit is in BoL_UnitGroup[BoL_Loop]) Equal to False
                    • Then - Actions
                      • Unit - Cause BoL_TrigUnit[BoL_Loop] to damage TempUnit, dealing BoL_DamageDealt[BoL_Loop] damage of attack type Spells and damage type Normal
                      • Unit Group - Add TempUnit to BoL_UnitGroup[BoL_Loop]
                    • Else - Actions
              • Unit - Move BoL_Dummy[BoL_Loop] instantly to BoL_Point[3]
              • -------- ================================================ --------
              • Custom script: call RemoveLocation(udg_BoL_Point[3])
              • -------- ================================================ --------
          • -------- ================================================ --------
          • Custom script: call RemoveLocation(udg_BoL_Point[1])
          • Custom script: call RemoveLocation(udg_BoL_Point[2])
          • -------- ================================================ --------
      • -------- ================================================ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BoL_MaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • -------- ================================================ --------
      • Custom script: set udg_BoL_Point[2] = null
      • Custom script: set udg_BoL_Point[3] = null
 
Last edited:
This is something I've been trying to do a year ago, I failed a lot though (probably because I put enums in TempGroup, then removed units in group[] off TempGroup and finally added TempGroup to group[], which is rather weird and unnecessarily lengthy compared to this technique). I think you should submit it to the spell section, dimf. :thumbs_up:
 
Status
Not open for further replies.
Top