• 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 works through 1st time, but bugs out upon repeated use

Status
Not open for further replies.
Level 1
Joined
Mar 1, 2012
Messages
1
Hello--a little help if you will?

I basically have a trigger that damages enemies based on a dummy unit collision that acts as a missile. It seems to work thoroughly as expected for the first time; there are three missiles that center inward from triangular points, so there is a chance to do triple damage if targeted correctly, none at all if missed, or just normal damage if only one missile hits. The spell in its entirety works for the 1st run through. However, every repeated use afterwards seems to just kill units instantly (I'm imagining that some condition check is not working, particularly with a Unit Group check), and I cannot seem to pin down how to fix the issue.

Help is greatly appreciated!

  • Justice MissileMove and Check Copy
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set Justice_RealCounter = (Justice_RealCounter + 0.01)
      • For each (Integer Justice_TempInteger) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Justice_RealCounter Less than or equal to 0.70
            • Then - Actions
              • Set Justice_TempPoint2[Justice_TempInteger] = (Position of Justice_Missiles[Justice_TempInteger])
              • Set Justice_TempPoint[Justice_TempInteger] = (Justice_TempPoint2[Justice_TempInteger] offset by ((Justice_MoveRate x (Cos((Angle from Justice_TempPoint2[Justice_TempInteger] to Justice_TempPoint[0])))), (Justice_MoveRate x (Sin((Angle from Justice_TempPoint2[Justice_TempInteger] to Justice_TempPoint[0])
              • Unit - Move Justice_Missiles[Justice_TempInteger] instantly to Justice_TempPoint[Justice_TempInteger]
              • Set Justice_UnitGroupDmg[Justice_TempInteger] = (Units within 100.00 of Justice_TempPoint[Justice_TempInteger])
              • Unit Group - Pick every unit in Justice_UnitGroupDmg[Justice_TempInteger] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Picked unit)) is an enemy of (Owner of Justice_Missiles[Justice_TempInteger])) Equal to True
                      • ((Picked unit) is in Justice_UnitGroupChecks[Justice_TempInteger]) Equal to False
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to Justice_UnitGroupChecks[Justice_TempInteger]
                      • Unit - Cause Justice_Missiles[Justice_TempInteger] to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_Justice_TempPoint[udg_Justice_TempInteger])
              • Custom script: call DestroyGroup(udg_Justice_UnitGroupDmg[udg_Justice_TempInteger])
              • Custom script: call RemoveLocation(udg_Justice_TempPoint2[udg_Justice_TempInteger])
            • Else - Actions
              • Trigger - Turn off (This trigger)
              • Unit Group - Remove all units from Justice_UnitGroupChecks[Justice_TempInteger]
              • Custom script: call DestroyGroup(udg_Justice_UnitGroupChecks[udg_Justice_TempInteger])
              • Unit - Remove Justice_Missiles[Justice_TempInteger] from the game
The trigger before, upon request:
  • Justice Phase1
    • Events
    • Conditions
    • Actions
      • Wait 0.50 seconds
      • Sound - Play MaievYesAttack2 <gen> at 100.00% volume, attached to Justice_Caster
      • For each (Integer Justice_TempInteger) from 1 to 3, do (Actions)
        • Loop - Actions
          • Animation - Play Justice_UnitArray[Justice_TempInteger]'s attack animation, using only Common animations
          • Animation - Change Justice_UnitArray[Justice_TempInteger]'s animation speed to 110.00% of its original speed
          • Animation - Change Justice_UnitArray[Justice_TempInteger]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
          • Set Justice_TempPoint[Justice_TempInteger] = (Position of Justice_UnitArray[Justice_TempInteger])
          • Unit - Create 1 Dummy Unit (Glaive Missile) for (Owner of Justice_UnitArray[Justice_TempInteger]) at Justice_TempPoint[Justice_TempInteger] facing (Facing of Justice_UnitArray[Justice_TempInteger]) degrees
          • Unit - Turn collision for (Last created unit) Off
          • Set Justice_Missiles[Justice_TempInteger] = (Last created unit)
          • Custom script: call RemoveLocation(udg_Justice_TempPoint[udg_Justice_TempInteger])
      • Set Justice_MoveRate = 10.00
      • Set Justice_RealCounter = 0.00
      • Trigger - Turn on Justice MissileMove and Check Copy <gen>
      • Wait 1.00 seconds
      • For each (Integer Justice_TempInteger) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of Justice_UnitArray[Justice_TempInteger])
          • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Animation - Play Justice_UnitArray[Justice_TempInteger]'s spell throw animation
          • Custom script: call RemoveLocation(udg_Temp_Point)
      • Wait 1.00 seconds
      • For each (Integer Justice_TempInteger) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit - Remove Justice_UnitArray[Justice_TempInteger] from the game
 
Last edited:
Level 13
Joined
Jun 22, 2004
Messages
783
- you off the trigger in the else part, also use 0.03 instead of 0.01
- 1 to 3 is not proper for an indexing system (if you're using one)

How is he/she off in the else part of the trigger?
Why should 1 to 3 not be used for indexing over 0-2?
Last of all, these suggestions do not FIX the problem.

Now to get you an answer to your problem, it took me a minute to get it.
Initially when I looked at your code I tought it had to do with the fact that you did not remove units from your "Justice_UnitGroupDmg" (allowing units still to be recorded as being in that group). but destroying a group should not allow for values within a group to be called upon any longer.

The real problem lies with destroying the "Justice_UnitGroupChecks". you do not redeclare your unitgroup "Justice_UnitGroupChecks". you might wonder so why does it work the first time? if you look at your variable window, you will see that the initial value of your unit group is "Empty Unit Group (default)" when your game launches it will create that unitgroup for you with that value. once you destroy the group with it no longer exists, so you need to remake it.

So to solve this problem, create a action that will create that unitgroup again.
You'd want to do that in the second trigger you posted above the action that will turn on your first trigger. you could use the following custom script action:

  • set udg_checkgroup = CreateGroup()
Edit: Or you can opt to not remove the group, and only the units within.(so only clearing it), which is more effecient.
 
How is he/she off in the else part of the trigger?
>>>
  • Trigger - Turn off (This trigger)
  • Unit Group - Remove all units from Justice_UnitGroupChecks[Justice_TempInteger]
  • Custom script: call DestroyGroup(udg_Justice_UnitGroupChecks[udg_Justice_TempInteger])
  • Unit - Remove Justice_Missiles[Justice_TempInteger] from the game
but this trigger is on again from the second one with no event...
Why should 1 to 3 not be used for indexing over 0-2?
I said, not proper coz if he wants to make it MUI or works on many units instead of just 3, use dynamic indexing systems...
 
Level 13
Joined
Jun 22, 2004
Messages
783
>>>
  • Trigger - Turn off (This trigger)
  • Unit Group - Remove all units from Justice_UnitGroupChecks[Justice_TempInteger]
  • Custom script: call DestroyGroup(udg_Justice_UnitGroupChecks[udg_Justice_TempInteger])
  • Unit - Remove Justice_Missiles[Justice_TempInteger] from the game
but this trigger is on again from the second one with no event...

That trigger is supposed to be turned on externally, so you have to turn it off again, otherwise it will keep on running (which is a waste).

I said, not proper coz if he wants to make it MUI or works on many units instead of just 3, use dynamic indexing systems...

The creator used that for each function to loop through all the projectiles for that spell (which are 3).
 
Status
Not open for further replies.
Top