• 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] Portal

Status
Not open for further replies.
Hey people I made a portal spell which spawns 2 portals. When you get close to one then you move to its partner.


  • Portal spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Portal
    • Actions
      • If (iPortalIndex Equal to 0) then do (Trigger - Turn on Portal loop <gen>) else do (-------- 0 --------)
      • Set iPortalIndex = (iPortalIndex + 1)
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Point = (Position of Temp_Unit)
      • Set Temp_Point2 = (Target point of ability being cast)
      • Set Temp_Point3 = (Temp_Point offset by 120.00 towards (Facing of Temp_Unit) degrees)
      • Unit - Create 1 Portal for (Owner of Temp_Unit) at Temp_Point2 facing (Angle from Temp_Point3 to Temp_Point2) degrees
      • Set uPortalIn[iPortalIndex] = (Last created unit)
      • Animation - Play uPortalIn[iPortalIndex]'s Birth animation
      • Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 Portal for (Owner of Temp_Unit) at Temp_Point3 facing (Angle from Temp_Point2 to Temp_Point3) degrees
      • Set uPortalOut[iPortalIndex] = (Last created unit)
      • Animation - Play uPortalOut[iPortalIndex]'s Birth animation
      • Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: call RemoveLocation(udg_Temp_Point3)
=============================================
  • Portal loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to iPortalIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((uPortalIn[Temp_Int] is dead) Equal to False) and ((uPortalOut[Temp_Int] is dead) Equal to False)
            • Then - Actions
              • Set Temp_Point = (Position of uPortalOut[Temp_Int])
              • Set Temp_Point2 = (Position of uPortalIn[Temp_Int])
              • Set Temp_Group = (Units within 150.00 of Temp_Point matching ((((Matching unit) is A structure) Equal to False) or ((Level of (Matching unit)) Less than 50)))
              • 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
                      • (Temp_Unit is in gPortalIn[Temp_Int]) Equal to False
                    • Then - Actions
                      • Custom script: call SetUnitX(udg_Temp_Unit,GetLocationX(udg_Temp_Point2))
                      • Custom script: call SetUnitY(udg_Temp_Unit,GetLocationY(udg_Temp_Point2))
                      • Unit Group - Add Temp_Unit to gPortalOut[Temp_Int]
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_Temp_Group)
              • Set Temp_Group = (Units within 150.00 of Temp_Point2 matching ((((Matching unit) is A structure) Equal to False) or ((Level of (Matching unit)) Less than 50)))
              • 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
                      • (Temp_Unit is in gPortalOut[Temp_Int]) Equal to False
                    • Then - Actions
                      • Custom script: call SetUnitX(udg_Temp_Unit,GetLocationX(udg_Temp_Point))
                      • Custom script: call SetUnitY(udg_Temp_Unit,GetLocationY(udg_Temp_Point))
                      • Unit Group - Add Temp_Unit to gPortalIn[Temp_Int]
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_Temp_Group)
              • Unit Group - Pick every unit in gPortalIn[Temp_Int] and do (Actions)
                • Loop - Actions
                  • Set Temp_Point3 = (Position of (Picked unit))
                  • If ((Distance between Temp_Point and Temp_Point3) Greater than 175.00) then do (Unit Group - Remove (Picked unit) from gPortalIn[Temp_Int]) else do (-------- 0 --------)
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
              • Unit Group - Pick every unit in gPortalOut[Temp_Int] and do (Actions)
                • Loop - Actions
                  • Set Temp_Point3 = (Position of (Picked unit))
                  • If ((Distance between Temp_Point2 and Temp_Point3) Greater than 175.00) then do (Unit Group - Remove (Picked unit) from gPortalOut[Temp_Int]) else do (-------- 0 --------)
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
              • Custom script: call RemoveLocation(udg_Temp_Point)
              • Custom script: call RemoveLocation(udg_Temp_Point2)
            • Else - Actions
              • Set uPortalIn[Temp_Int] = uPortalIn[iPortalIndex]
              • Set uPortalIn[iPortalIndex] = No unit
              • Set uPortalOut[Temp_Int] = uPortalOut[iPortalIndex]
              • Set uPortalOut[iPortalIndex] = No unit
              • Set gPortalIn[Temp_Int] = gPortalIn[iPortalIndex]
              • Custom script: call GroupClear(udg_gPortalIn[udg_iPortalIndex])
              • Set gPortalOut[Temp_Int] = gPortalOut[iPortalIndex]
              • Custom script: call GroupClear(udg_gPortalOut[udg_iPortalIndex])
              • Set iPortalIndex = (iPortalIndex - 1)
              • Set Temp_Int = (Temp_Int - 1)
              • If (iPortalIndex Equal to 0) then do (Trigger - Turn off (This trigger)) else do (-------- 0 --------)
======================
loop concept: Picks units in range. If they isn't in a "teleport proof" group then they are moved to the portal's partner. They are also added to a "teleport proof" group so that they won't get teleported back. The only way to get out of the group is by stepping away from the portal.



When I cast a second portal while the first one is still running then it seems like the unit gets teleported forward and back for every interval of the loop between the last created portals. After that the spell stays corrupt.

I think that the unit isn't removed from gPortalIn/Out[] that causes the unit to be teleported again and again. Please tell me where I am going wrong.

Thank you for your time
 
I've found the problem but a new bug occurred :(. I needed to set the group array to 1892.

Anyway I've found that when the first portal closes then all the "portal out's" is killed and the trigger sops running. Why does that happens?

  • Portal spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Portal
    • Actions
      • If (iPortalIndex Equal to 0) then do (Trigger - Turn on Portal loop <gen>) else do (-------- 0 --------)
      • Set iPortalIndex = (iPortalIndex + 1)
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Point = (Position of Temp_Unit)
      • Set Temp_Point2 = (Target point of ability being cast)
      • Set Temp_Point3 = (Temp_Point offset by 120.00 towards (Facing of Temp_Unit) degrees)
      • Unit - Create 1 Portal for (Owner of Temp_Unit) at Temp_Point2 facing (Angle from Temp_Point3 to Temp_Point2) degrees
      • Set uPortalIn[iPortalIndex] = (Last created unit)
      • Animation - Play uPortalIn[iPortalIndex]'s Birth animation
      • Unit - Create 1 Portal for (Owner of Temp_Unit) at Temp_Point3 facing (Angle from Temp_Point2 to Temp_Point3) degrees
      • Set uPortalOut[iPortalIndex] = (Last created unit)
      • Animation - Play uPortalOut[iPortalIndex]'s Birth animation
      • Set rPortal[iPortalIndex] = 20.00
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: call RemoveLocation(udg_Temp_Point3)
  • Portal loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to iPortalIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • rPortal[Temp_Int] Greater than 0.00
            • Then - Actions
              • Set Temp_Point = (Position of uPortalOut[Temp_Int])
              • Set Temp_Point2 = (Position of uPortalIn[Temp_Int])
              • Set Temp_Group = (Units within 150.00 of Temp_Point matching ((((Matching unit) is A structure) Equal to False) or ((Level of (Matching unit)) Less than 50)))
              • 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
                      • (Temp_Unit is in gPortalIn[Temp_Int]) Equal to False
                    • Then - Actions
                      • Custom script: call SetUnitX(udg_Temp_Unit,GetLocationX(udg_Temp_Point2))
                      • Custom script: call SetUnitY(udg_Temp_Unit,GetLocationY(udg_Temp_Point2))
                      • Unit Group - Add Temp_Unit to gPortalOut[Temp_Int]
                      • Game - Display to (All players) the text: ((String(Temp_Int)) + (String((Number of units in gPortalOut[Temp_Int]))))
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_Temp_Group)
              • Set Temp_Group = (Units within 150.00 of Temp_Point2 matching ((((Matching unit) is A structure) Equal to False) or ((Level of (Matching unit)) Less than 50)))
              • 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
                      • (Temp_Unit is in gPortalOut[Temp_Int]) Equal to False
                    • Then - Actions
                      • Custom script: call SetUnitX(udg_Temp_Unit,GetLocationX(udg_Temp_Point))
                      • Custom script: call SetUnitY(udg_Temp_Unit,GetLocationY(udg_Temp_Point))
                      • Unit Group - Add Temp_Unit to gPortalIn[Temp_Int]
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_Temp_Group)
              • Unit Group - Pick every unit in gPortalIn[Temp_Int] and do (Actions)
                • Loop - Actions
                  • Set Temp_Point3 = (Position of (Picked unit))
                  • If ((Distance between Temp_Point and Temp_Point3) Greater than 175.00) then do (Unit Group - Remove (Picked unit) from gPortalIn[Temp_Int]) else do (-------- 0 --------)
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
              • Unit Group - Pick every unit in gPortalOut[Temp_Int] and do (Actions)
                • Loop - Actions
                  • Set Temp_Point3 = (Position of (Picked unit))
                  • If ((Distance between Temp_Point2 and Temp_Point3) Greater than 175.00) then do (Unit Group - Remove (Picked unit) from gPortalOut[Temp_Int]) else do (-------- 0 --------)
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
              • Custom script: call RemoveLocation(udg_Temp_Point)
              • Custom script: call RemoveLocation(udg_Temp_Point2)
              • Set rPortal[Temp_Int] = (rPortal[Temp_Int] - 0.02)
            • Else - Actions
              • Unit - Kill uPortalIn[Temp_Int]
              • Unit - Kill uPortalOut[Temp_Int]
              • Set rPortal[Temp_Int] = rPortal[iPortalIndex]
              • Set uPortalIn[Temp_Int] = uPortalIn[iPortalIndex]
              • Set uPortalIn[iPortalIndex] = No unit
              • Set uPortalOut[Temp_Int] = uPortalOut[iPortalIndex]
              • Set uPortalOut[iPortalIndex] = No unit
              • Set gPortalIn[Temp_Int] = gPortalIn[iPortalIndex]
              • Custom script: call GroupClear(udg_gPortalIn[udg_iPortalIndex])
              • Set gPortalOut[Temp_Int] = gPortalOut[iPortalIndex]
              • Custom script: call GroupClear(udg_gPortalOut[udg_iPortalIndex])
              • Set iPortalIndex = (iPortalIndex - 1)
              • Set Temp_Int = (Temp_Int - 1)
              • If (iPortalIndex Equal to 0) then do (Trigger - Turn off (This trigger)) else do (-------- 0 --------)
 
Status
Not open for further replies.
Top