• 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] Spell not working

Status
Not open for further replies.
Hey people
I made a GUI version of chain frost a long time ago and spent many hours trying to make it perfect but it never wants to work flawless :(
Sometimes the spell will hit the same unit 33 times per sec when no other targets is around and often go to centre. The effect never gets removed.

  • Chain frost spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chain frost
    • Actions
      • If (iChainFrostIndex Equal to 0) then do (Trigger - Turn on Chain frost loop <gen>) else do (Do nothing)
      • Set iChainFrostIndex = (iChainFrostIndex + 1)
      • Set uChainFrostC[iChainFrostIndex] = (Triggering unit)
      • Set uChainFrostT[iChainFrostIndex] = (Target unit of ability being cast)
      • Set Temp_Point = (Position of uChainFrostC[iChainFrostIndex])
      • Unit - Create 1 Chain frost for (Owner of uChainFrostC[iChainFrostIndex]) at Temp_Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Set uChainFrostE[iChainFrostIndex] = (Last created unit)
      • Set iChainFrostJumps[iChainFrostIndex] = 7
  • Chain frost loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to iChainFrostIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (uChainFrostE[Temp_Int] is paused) Equal to False
            • Then - Actions
              • Set Temp_Point = (Position of uChainFrostE[Temp_Int])
              • Set Temp_Point2 = (Position of uChainFrostT[Temp_Int])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Temp_Point and Temp_Point2) Greater than 20.00
                • Then - Actions
                  • Set Temp_Point3 = (Temp_Point offset by 8.00 towards (Angle from Temp_Point to Temp_Point2) degrees)
                  • Unit - Move uChainFrostE[Temp_Int] instantly to Temp_Point3
                  • Custom script: call RemoveLocation(udg_Temp_Point3)
                • Else - Actions
                  • Unit - Move uChainFrostE[Temp_Int] instantly to Temp_Point2
                  • Unit - Cause uChainFrostC[Temp_Int] to damage uChainFrostT[Temp_Int], dealing 250.00 damage of attack type Spells and damage type Normal
                  • Special Effect - Create a special effect at Temp_Point2 using Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set iChainFrostJumps[Temp_Int] = (iChainFrostJumps[Temp_Int] - 1)
                  • Set Temp_Group = (Units within 500.00 of Temp_Point2 matching (((Owner of (Matching unit)) is an enemy of (Owner of uChainFrostC[Temp_Int])) Equal to True))
                  • Custom script: call RemoveLocation(udg_Temp_Point2)
                  • Unit Group - Pick every unit in Temp_Group and do (Actions)
                    • Loop - Actions
                      • Set Temp_Unit = (Picked unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • Temp_Unit Equal to uChainFrostT[Temp_Int]
                              • (Temp_Unit is A structure) Equal to True
                              • (Temp_Unit is dead) Equal to True
                        • Then - Actions
                          • Unit Group - Remove Temp_Unit from Temp_Group
                        • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • iChainFrostJumps[Temp_Int] Greater than 0
                          • (Temp_Group is empty) Equal to False
                    • Then - Actions
                      • Set uChainFrostT[Temp_Int] = (Random unit from Temp_Group)
                    • Else - Actions
                      • Unit - Remove uChainFrostE[Temp_Int] from the game
                      • Set uChainFrostE[Temp_Int] = uChainFrostE[iChainFrostIndex]
                      • Set uChainFrostE[iChainFrostIndex] = No unit
                      • Set uChainFrostC[Temp_Int] = uChainFrostC[iChainFrostIndex]
                      • Set uChainFrostC[iChainFrostIndex] = No unit
                      • Set uChainFrostT[Temp_Int] = uChainFrostT[iChainFrostIndex]
                      • Set uChainFrostT[iChainFrostIndex] = No unit
                      • Set iChainFrostJumps[Temp_Int] = iChainFrostJumps[iChainFrostIndex]
                      • Set iChainFrostJumps[iChainFrostIndex] = 0
                      • Set iChainFrostIndex = (iChainFrostIndex - 1)
                      • Set Temp_Int = (Temp_Int - 1)
                      • If (iChainFrostIndex Equal to 0) then do (Trigger - Turn off (This trigger)) else do (-------- 0 --------)
                  • Custom script: call DestroyGroup(udg_Temp_Group)
              • Custom script: call RemoveLocation(udg_Temp_Point)
            • Else - Actions

I would appreciate it if someone can help me fix this
 
To stop it from hitting the same unit all the time save the unit into a unit group and check to see if picked unit does not equal any unit in unit group to damage a new target each time.

To stop it from hitting one unit multiple times but allow it to hit unit a then unit b then back to unit a. Use another unit variable to keep track of last target and new target. Check if picked unit does not equal last target and then damage that unit and set it to last target.

You should debug your code to find out what is running and what is not.
 
If you look closely I removed the current target before choosing a new target:
--------------------
  • Set Temp_Group = (Units within 500.00 of Temp_Point2 matching (((Owner of (Matching unit)) is an enemy of (Owner of uChainFrostC[Temp_Int])) Equal to True))
  • Or - Any (Conditions) are true
    • Conditions
      • Temp_Unit Equal to uChainFrostT[Temp_Int] (current target gets removed from new potential tagets)
    • Actions
      • Unit Group - Remove Temp_Unit from Temp_Group
--------------------
Its ok if a unit gets hit more than once by the spell but it must hit another target in between before returning to a target that was already been hit.

I tried the debug thing and found that when it de-index, Temp_Int goes from 4 to 3 and for the second time 2 to 1. I don't remember setting Temp_Int to 4 anywhere in the trigger.

For the second bug - I clearly defined that if Temp_Group is emty (500AoE), it should de-index but it rather go to point(0;0) miles away. I can't see why the 'else' condition wont run when group is emty.

Looks like I finally managed to slove both bugs. I replaced 'Temp_Int' with 'i'. I think that Temp_Int conflicted with another loop that were part of my damage engine. For the second bug I shouldn't have used 'OR' because jumps > 0 = true which fired 'then conditions' while the group were emty, sending the effect to the centre.

thanks dimf. :)
+rep

-must spread to others first -.-
 
Last edited:
Status
Not open for further replies.
Top