• 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] All about indexing

Status
Not open for further replies.
Hi everyone
I made a 'system' for my map where every spell that has a missle and a target point can use the same loop. For some reason, when casting a missile, it moves instantly to the center of the map.
  • Missile cast 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Titan
    • Actions
      • If (iIndex2 Equal to 0) then do (Trigger - Turn on Missile loop 2 <gen>) else do (Do nothing)
      • Set iIndex2 = (iIndex2 + 1)
      • Set uC2[iIndex2] = (Triggering unit)
      • Set Temp_Point = (Position of uC2[iIndex2])
      • Set Temp_Point2 = (Target point of ability being cast)
      • Set rDirection[iIndex2] = (Angle from Temp_Point to Temp_Point2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Titan
        • Then - Actions
          • Unit - Create 1 Titan for (Owner of uC2[iIndex2]) at Temp_Point facing rDirection[iIndex2] degrees
          • Set uE2[iIndex2] = (Last created unit)
          • Set rSpeed2[iIndex2] = 7.00
          • Set rDamage2[iIndex2] = 200.00
          • Set iDurationE[iIndex2] = 200
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
  • Missile loop 2
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to iIndex2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (uE2[Temp_Int] is paused) Equal to False
            • Then - Actions
              • Set Temp_Point = (Position of uE[Temp_Int])
              • Set iDurationE[Temp_Int] = (iDurationE[Temp_Int] - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • iDurationE[Temp_Int] Greater than 0
                • Then - Actions
                  • Set Temp_Point2 = (Temp_Point offset by rSpeed2[Temp_Int] towards rDirection[Temp_Int] degrees)
                  • Unit - Move uE2[Temp_Int] instantly to Temp_Point2, facing rDirection[Temp_Int] degrees
                  • Custom script: call RemoveLocation(udg_Temp_Point2)
                • Else - Actions
                  • Unit - Kill uE2[Temp_Int]
              • Custom script: call RemoveLocation(udg_Temp_Point)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (uE2[Temp_Int] is dead) Equal to True
            • Then - Actions
              • Set uC2[Temp_Int] = uC2[iIndex2]
              • Set uC2[Temp_Int] = No unit
              • Set rDamage2[Temp_Int] = rDamage2[iIndex2]
              • Set rDamage2[iIndex2] = 0.00
              • Set rDirection[Temp_Int] = rDirection[iIndex2]
              • Set rDirection[iIndex2] = 0.00
              • Set uE2[Temp_Int] = uE2[iIndex2]
              • Set uE2[iIndex2] = No unit
              • Set rSpeed2[Temp_Int] = rSpeed2[iIndex2]
              • Set rSpeed2[iIndex2] = 0.00
              • Set iIndex2 = (iIndex2 - 1)
              • Set Temp_Int = (Temp_Int - 1)
            • Else - Actions
Please help!
 
u set uE2 in cast trigger u dont set uE in cast trigger.

Sorry thats what I met. I used 'uE[]' in a trigger that has a target to follow. All spells like strom blot will run through that loop. This one - where I use 'uE2' is for spells that has a fixed direction. So I set 'uE2' in the casting trigger that runs this loop.
 
Here is a new case... It's the first time I make a spell with a 2D index. Anyways I didn't start with the loop yet but I have trouble spawing the effects. It's suppose to spawn 24 missiles that evenly surrounds the caster. It spawns only one -.-

  • Plasma field spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Plasma field
    • Actions
      • If (iPlasmaField Equal to 0) then do (Trigger - Turn on Plasma field loop <gen>) else do (-------- 0 --------)
      • Set iPlasmaField = (iPlasmaField + 1)
      • Set uPlasmaFieldC[iPlasmaField] = (Triggering unit)
      • Set rPlasmaField[iPlasmaField] = 0.00
      • Set Temp_Player = (Owner of uPlasmaFieldC[iPlasmaField])
      • Set Temp_Point = (Position of uPlasmaFieldC[iPlasmaField])
      • For each (Integer Temp_Int) from (25 x iPlasmaField) to ((25 x iPlasmaField) + 24), do (Actions)
        • Loop - Actions
          • Unit - Create 1 Electric for Temp_Player at (Temp_Point offset by 256.00 towards (15.00 x (Real(Temp_Int))) degrees) facing (15.00 x (Real(Temp_Int))) degrees
      • Custom script: call RemoveLocation(udg_Temp_Point)
 
Ok same spell, and as I said - it's my first spell with a 2D index and I have abselutely no idea how to de-index that :/ I don't think it's nessesary to read the whole trigger but just incase... Go stright to the bottom if you want to.

  • Plasma field spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Plasma field
    • Actions
      • If (iPlasmaField Equal to 0) then do (Trigger - Turn on Plasma field loop <gen>) else do (-------- 0 --------)
      • Set iPlasmaField = (iPlasmaField + 1)
      • Set uPlasmaFieldC[iPlasmaField] = (Triggering unit)
      • Set rPlasmaField[iPlasmaField] = 0.00
      • Set Temp_Player = (Owner of uPlasmaFieldC[iPlasmaField])
      • Set Temp_Point = (Position of uPlasmaFieldC[iPlasmaField])
      • For each (Integer Temp_Int) from (25 x iPlasmaField) to ((25 x iPlasmaField) + 24), do (Actions)
        • Loop - Actions
          • Set rPlasmaFieldWay[Temp_Int] = (15.00 x (Real(Temp_Int)))
          • Unit - Create 1 Electric for Temp_Player at Temp_Point facing rPlasmaFieldWay[Temp_Int] degrees
          • Set uPlasmaFieldE[Temp_Int] = (Last created unit)
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Set iPlasmaFieldTime[iPlasmaField] = 250
  • Plasma field loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to iPlasmaField, do (Actions)
        • Loop - Actions
          • If (iPlasmaFieldTime[Temp_Int] Equal to 125) then do (Custom script: call DestroyGroup(udg_gPlasmaField[udg_Temp_Int])) else do (-------- 0 --------)
          • Set Temp_Point = (Position of uPlasmaFieldC[Temp_Int])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • iPlasmaFieldTime[Temp_Int] Greater than or equal to 125
            • Then - Actions
              • Set Temp_Real = ((3.00 x (Real(iPlasmaFieldTime[Temp_Int]))) - 750.00)
            • Else - Actions
              • Set Temp_Real = (3.00 x (Real(iPlasmaFieldTime[Temp_Int])))
          • For each (Integer Temp_IntB) from (25 x Temp_Int) to ((25 x Temp_Int) + 24), do (Actions)
            • Loop - Actions
              • Set Temp_Point2 = (Temp_Point offset by Temp_Real towards rPlasmaFieldWay[Temp_IntB] degrees)
              • Unit - Move uPlasmaFieldE[Temp_IntB] instantly to Temp_Point2
              • Custom script: call RemoveLocation(udg_Temp_Point2)
          • Set Temp_Group = (Units within Temp_Real of Temp_Point)
          • Unit Group - Pick every unit in Temp_Group and do (Actions)
            • Loop - Actions
              • Set Temp_Unit = (Picked unit)
              • Set Temp_Point = (Position of Temp_Unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Temp_Unit is A structure) Equal to False
                      • ((Owner of uPlasmaFieldC[Temp_Int]) is an enemy of (Owner of Temp_Unit)) Equal to True
                      • (Temp_Unit is A flying unit) Equal to False
                      • (Distance between Temp_Point and Temp_Point2) Greater than or equal to (Temp_Real - 5.00)
                      • (Temp_Unit is in gPlasmaField[Temp_Int]) Equal to False
                • Then - Actions
                  • Unit - Cause uPlasmaFieldC[Temp_Int] to damage Temp_Unit, dealing Temp_Real damage of attack type Spells and damage type Normal
                  • Unit Group - Add Temp_Unit to gPlasmaField[Temp_Int]
                  • Special Effect - Create a special effect attached to the orign of Temp_Unit using Abilities\Weapons\Bolt\BoltImpact.mdl
                • Else - Actions
          • Custom script: call RemoveLocation(udg_Temp_Point)
          • Custom script: call DestroyGroup(udg_Temp_Group)
          • Set iPlasmaFieldTime[Temp_Int] = (iPlasmaFieldTime[Temp_Int] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • iPlasmaFieldTime[Temp_Int] Equal to 0
            • Then - Actions
              • Set uPlasmaFieldC[Temp_Int] = uPlasmaFieldC[iPlasmaField]
              • Set uPlasmaFieldC[iPlasmaField] = No unit
              • Set rPlasmaField[Temp_Int] = rPlasmaField[iPlasmaField]
              • Set gPlasmaField[Temp_Int] = gPlasmaField[iPlasmaField]
              • Custom script: call DestroyGroup(udg_gPlasmaField[udg_iPlasmaField])
              • For each (Integer Temp_IntB) from (25 x Temp_Int) to ((25 x Temp_Int) + 24), do (Actions)
                • Loop - Actions
                  • -------- Now what?! --------
              • Set iPlasmaField = (iPlasmaField - 1)
              • Set Temp_Int = (Temp_Int - 1)
              • If (iPlasmaField Equal to 0) then do (Trigger - Turn off (This trigger)) else do (-------- 0 --------)
            • Else - Actions
 
Status
Not open for further replies.
Top