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

[Solved] Is there anyway to make a trigger only shoot an action once?

Status
Not open for further replies.
Level 30
Joined
Jul 23, 2009
Messages
1,033
I am trying to make a spell that shoots a projectile that travels to the target location. This is working as intended but when it is supposed to deal damage it gets out of hand.

Here is the first trigger for casting the spell (I will fix MUI, leaks etc later)

  • Hammer of Light Cast Test
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Hammer of Light
    • Actions
      • Set HoL_Caster = (Triggering unit)
      • Set HoL_Target_Loc = (Target point of ability being cast)
      • Set HoL_Angle = (Angle from (Position of HoL_Caster) to HoL_Target_Loc)
      • Unit - Create 1 Hammer of Light Dummy for Player 1 (Red) at (Position of HoL_Caster) facing HoL_Angle degrees
      • Set HoL_Dummy = (Last created unit)
      • Set HoL_LifeTime = 500.00
And here is the trigger for constantly searching for targets to impact and then deal damage to ONE enemy.

  • Hammer of Light Dummy Move Test
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • (HoL_Dummy is alive) Equal to (==) True
    • Actions
      • Set HoL_Dummy_Loc = (Position of HoL_Dummy)
      • Unit - Move HoL_Dummy instantly to (HoL_Dummy_Loc offset by 20.00 towards HoL_Angle degrees)
      • Set HoL_LifeTime = (HoL_LifeTime - 20.00)
      • Unit Group - Pick every unit in (Units within 100.00 of HoL_Dummy_Loc) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (==) Neutral Hostile
            • Then - Actions
              • Unit - Cause HoL_Caster to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
              • Unit - Kill HoL_Dummy
            • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • HoL_LifeTime Less than or equal to (<=) 0.00
          • Then - Actions
            • Unit - Kill HoL_Dummy
          • Else - Actions
It does damage the enemy but it is possible to damage several enemies as it might catch more than one enemy on impact. Let's say, on the final moving of the dummy it appears in range of 3 enemies then the trigger will do the whole damage part for each enemy. So it shoots one instance for each enemy in range. I really need the spell to only deal damage to the first enemy it hits (Like ezreal's Mystic Shot for you who play League of Legends).
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
destroy the unitgroup when the first unit is picked maybe. Or pick random unit from unitgroup

edit:
JASS:
FirstOfGroup
gotta be the best solution. And long time no see ^^
edit2:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set temp = (Units in (Playable map area))
      • Custom script: set udg_u = FirstOfGroup(udg_temp)
      • Game - Display to (All players) the text: (Name of u)
 
Status
Not open for further replies.
Top