Portal System v2.5

This bundle is marked as approved. It works and satisfies the submission rules.
116571-albums8457-picture102180.png

NB: This system can be considered deprecated in favour of CustomWaygate v1.04. However, CustomWaygate does not have an in-built missile system, is coded in vJASS and has a few requirements. I'll keep this here for those who prefer something in GUI.

UPDATE v2.5
- Fixed a bug that caused units to do a very slight arc when turning after using a Portal.

UPDATE v2.4
- Added a new variable to handle the Sever Connection ability since that had to be set manually if the id of the spell was not to same per map. Set it in Portal Connect at the top. That method also allows you to use whatever no-target spell you want to disconnect portals.
- Move Portal Periodic trigger up to facilitate installation as some functions were being disabled on import bcz world edit is dumb.
- Portal Connect is no longer optional. Not sure why it was in the first place...
- fixed an issue where non-flying missiles would get stuck on units.
- Updated README.

UPDATE v2.3
- Portal missiles no longer use locust and instead of made invulnerable unless they are made targetable.
- Portals now retain unit selection.
- Updated screenshot

UPDATE v2.2
- Portal_index changed to Portal_ConfigIndex and is used only in configuration. Portal_INDEX_CASTER/TARGET/TRAVELLER were added to use as index in the rest of the system.
- Added a failsafe to prevent movable portals (like the owls) to use portals while connected as this seemed to bug out their own connections. Disconnect them to allow them to use portals.
- Checks to see whether portals are connected in the configuration now, rather than in the connection trigger. This is to avoid switching out values from portals that are already connected. I'm afraid there's no way around this.
- GUI AutoFly no longer needed. Add storm crow form to your dummy units to remove the need for autofly on dummies. (This is for reducing the amount of requirements for the system. I recommend having autofly in your maps regardless as if may come in handy in other places).

UPDATE v2.1
- No longer uses BlizzardMessage.
- Updated the README to reflect that change.

UPDATE: System upgraded from v1.0 to v2.0
- No longer uses DynamicEvents. Uses timers instead.
- ID, ID2 and ID3 Integer variabled have been replaced with Portal_index[array]
- You can now chose to let allies use your Portals with Portal_preventAllies[array]
- Added a slew of features:
- Can now apply a delay before teleportation. Unit that move outside the reach of a Portal (eg if knocked back) will automatically reingage the Portal
- Can now use dummy missiles to make teleportation happen. These missiles can be made targetable and/or use their own movement if you so desire to make them respect pathing. Eg: a tunneling teleportation. Examples available in demo map.
- Added an optional trigger where you can sever the connection between two portals. Refer to Portal Disconnect for more details.

PLEASE NOTE: The vJASS categorisation is only because I use BlizzardMessage to simulate error messages in this system. There are a total of 3 calls to BlizzardMessage in there, so if you don't want to use JNGP, you know what you get rid of. That being said, why would you not use JNGP? :p


JASS:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//      PORTAL SYSTEM v2.5 by Spellbound
//
//      The Portal System allows you to teleport your units from one portal to another. Use the Connect Portal skill to link two Portals - this means Portals are buildable.
//      A Portal that is already connected can connect to one that is not active, thus disconnecting from it's current counterpart to connect to the new one. You can make teleportation
//      work via missiles (that can be configured to be killable) or have delays before teleporting. Check out the Demo Portal folder for templates to use. Conncet Portal 1 has
//      detailed explanation on each variable.
//
//      Also, reciever Portals will make your units move to their rally points if they have one.
//
//
//      REQUIRED:
//      Unit Indexer, by Bribe          http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-2-0-2-a-197329/
//
//
//      INSTALLATION:
//      - Make sure that in File > Preferences > General, the box next to 'Automatically create unknown variables while pasting trigger data' is ticked.
//        Then copy the Variable Creator trigger to your map so that the variables are automatically generated. You may then delete it.
//      - Copy the Requirements folder to your map.
//      - Copy the Sever Connection ability to you map.
//      - Unless you already have a dummy unit, import the dummy.mdx model by Vexorian and copy one or all of the Portal Carrier (Dummy Unit - [type]) from this map to yours.
//      - Your dummies must have storm crow form if you do not use GUI Auto Fly or Auto Fly
//      - Copy the Portals folder to your map.
//      - In Portal Connect, set Portal_SeverAbility to Sever Connection (Required) or any non-target spell you want your portals to use to disconnect from a sister portal.
//      - Copy any of the four templates (recommended) alongside their corresponding abilities in the Object Editor (always copy units/abilities before triggers).
//        For example, Connect Portal 1 uses delayFX - Connect Portal 1 and FX - Blue Energy in it's setup. It also uses a flying dummy unit, so copy that as well if
//        you don't have a dummy unit.
//      - Save your map.
//        You're all done!
//
//
//      CUSTOMISATION:
//      - All customisation is done in the Connect Portal triggers in the Template folder. In there you may change the various special effects for departure/arrival
//        fx, active portal fx, the range at which the portal may catch units to teleport, allowing allies through or not, the use of a missile to carry the units,
//        it's height, and what unit will that missile be. The latter means you can chose to have a missile that can be shot down, effectively terminating the
//        teleportation prematurely. Keep in mind while I have not put in conditions to prevent flying units from using the Portals, the special effect will display
//        at their location, at ground level. If this bothers you, consider using flying dummy units to which you attach a special effect. You'll have to modify
//        Portal Periodic for that.
//      - Connect Portal 1 - 4 are template triggers. Consider copy/pasting them to your map, and then modifying their configurables.
//
//
//      SPECIAL THANKS:
//      Bribe, for his wonderful Unit Indexer and letting me know that detecting pathing would be very annoying to deal with in-game :P
//
//
//      VARIABLES:
//      Portal_activeFX - this is the special effect that will attach to your active Portals. The effect can be changed in Connect Portal.
//      Portal_departureFX - this is the special effect that plays when a unit uses a Portal. The effect can be changed in Connect Portal.
//      Portal_arrivalFX - this is the special effect that plays when a unit exits a Portal.  The effect can be changed in Connect Portal.
//      Portal_range - that's the range at which the Portals will pick unit for teleportation.
//      Portal_delay - whether you Portals have a delay before they teleport units. Units that move outside their reach (like through knockback)
//              will automatically reingage the Portal. If set to 0, the teleportation is instantaneous.
//      Portal_delayFXAbil - this is an ability that carries the special effects to apply on your units when there is a delay, to indicate teleportation
//              has started. I use an ability here instead of a special effect because abilities can have up to 6 effects, each with their own attachment
//              points if you so desire.
//      Portal_missileSpeed - if set to 0 or lower, the teleportation is instantaneous. Otherwise, will shoot a missile that will teleport
//              units when it reaches the sister Portal. If sister Portal is destroyed before it's reached, the missile and unit is carries
//              are both killed.
//      Portal_missileDummy - this is the dummy unit that will serve as your missile. I made this configurable in case you would want to have missiles
//              that can be destroyed or have missiles that have to walk to the sister Portal. Refer to Connect Portal 3 and 4.
//      Portal_missileHeight - the height of your missile. If missile speed is 0 or lower, this does nothing.
//      Portal_missileFXAbil - this is ability that carries the special effects of your missile. Can be overlooked if your dummy unit has a
//              model already.
//      Portal_preventAllies - setting this to TRUE will prevent allies from using your Portal.
//      Portal_missileTargetable - setting this to TRUE will remove locust from your missile units, making them targetable.
//      Portal_missileUseOwnMovement - setting this to TRUE will order the missile to move instead of moving them by triggers. This is useful if you want
//              your missile to respect pathing.
//
//      The rest of the variables should not be meddled with.
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Portal Connect

Portal Target

Portal Periodic

Portal Disengage

Portal Death

Portal Missile Order

Portal Disconnect

  • Portal Connect
    • Events
    • Conditions
    • Actions
      • Custom script: if udg_Portal_SeverAbility == null then
      • Set Portal_SeverAbility = Sever Connection (Required)
      • Custom script: endif
      • -------- NB --------
      • -------- Portal_portal[Portal_INDEX_CASTER] is the sister portal --------
      • -------- Portal_portal[Portal_INDEX_TARGET] is the caster portal --------
      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Portal_active[Portal_INDEX_CASTER] Equal to True
          • (Target unit of ability being cast) Not equal to Portal_portal[Portal_INDEX_CASTER]
          • Portal_active[Portal_INDEX_TARGET] Equal to False
        • Then - Actions
          • -------- TRAVELLER here is the index of the existing sister portal. Therefore, Portal_portal[Portal_INDEX_TRAVELLER] is the caster portal --------
          • -------- Anything else indexed to TRAVELLER, however, is for the currently connected sister portal. TRAVELLER is used here to disengage her from the caster --------
          • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_portal[Portal_INDEX_CASTER])
          • Special Effect - Destroy Portal_FX[Portal_INDEX_CASTER]
          • Special Effect - Destroy Portal_FX[Portal_INDEX_TRAVELLER]
          • Unit - Remove Portal_SeverAbility from Portal_portal[Portal_INDEX_CASTER]
          • Unit - Remove Portal_SeverAbility from Portal_portal[Portal_INDEX_TRAVELLER]
          • Set Portal_active[Portal_INDEX_TRAVELLER] = False
          • Set Portal_portal[Portal_INDEX_TRAVELLER] = No unit
          • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
          • -------- Portal_portal[Portal_INDEX_CASTER] is set to the new sister portal --------
          • Set Portal_portal[Portal_INDEX_CASTER] = (Target unit of ability being cast)
          • Set Portal_portal[Portal_INDEX_TARGET] = (Triggering unit)
          • Set Portal_active[Portal_INDEX_TARGET] = True
          • Special Effect - Create a special effect attached to the origin of Portal_portal[Portal_INDEX_TARGET] using Portal_activeFX[Portal_INDEX_CASTER]
          • Set Portal_FX[Portal_INDEX_CASTER] = (Last created special effect)
          • Special Effect - Create a special effect attached to the origin of Portal_portal[Portal_INDEX_CASTER] using Portal_activeFX[Portal_INDEX_TARGET]
          • Set Portal_FX[Portal_INDEX_TARGET] = (Last created special effect)
          • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
          • Unit - Add Portal_SeverAbility to Portal_portal[Portal_INDEX_TARGET]
          • Unit - Add Portal_SeverAbility to Portal_portal[Portal_INDEX_CASTER]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Portal_active[Portal_INDEX_TARGET] Equal to True
              • (Target unit of ability being cast) Not equal to Portal_portal[Portal_INDEX_CASTER]
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to Portal_portal[Portal_INDEX_TARGET]
                • Then - Actions
                • Else - Actions
                  • -------- If the targeted Portal, and the cast, are not active, connect them to one another --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Portal_active[Portal_INDEX_CASTER] Equal to False
                      • Portal_active[Portal_INDEX_TARGET] Equal to False
                    • Then - Actions
                      • Set Portal_active[Portal_INDEX_CASTER] = True
                      • Set Portal_active[Portal_INDEX_TARGET] = True
                      • Set Portal_portal[Portal_INDEX_CASTER] = (Target unit of ability being cast)
                      • Set Portal_portal[Portal_INDEX_TARGET] = (Triggering unit)
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Portal_activeFX[Portal_INDEX_CASTER]
                      • Set Portal_FX[Portal_INDEX_CASTER] = (Last created special effect)
                      • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using Portal_activeFX[Portal_INDEX_TARGET]
                      • Set Portal_FX[Portal_INDEX_TARGET] = (Last created special effect)
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • Unit - Add Portal_SeverAbility to Portal_portal[Portal_INDEX_TARGET]
                      • Unit - Add Portal_SeverAbility to Portal_portal[Portal_INDEX_CASTER]
                    • Else - Actions
  • Portal Target
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Portal_active[(Custom value of (Target unit of issued order))] Equal to True
      • ((Triggering unit) is in Portal_teleMissiles) Equal to False
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(move))
      • ((Triggering unit) belongs to an ally of (Owner of (Target unit of issued order))) Equal to True
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
      • Set Portal_INDEX_TARGET = (Custom value of (Target unit of issued order))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Portal_active[Portal_INDEX_CASTER] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffffcc00Movable P...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Portal_preventAllies[Portal_INDEX_TARGET] Equal to True
              • (Owner of (Triggering unit)) Not equal to (Owner of (Target unit of issued order))
            • Then - Actions
            • Else - Actions
              • Set Portal_targeted[Portal_INDEX_CASTER] = (Target unit of issued order)
              • Unit Group - Add (Triggering unit) to Portal_group
              • Set Portal_delay[Portal_INDEX_CASTER] = Portal_delay[Portal_INDEX_TARGET]
              • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Portal Periodic <gen> is on) Equal to False
                • Then - Actions
                  • Trigger - Turn on Portal Periodic <gen>
                • Else - Actions
  • Portal Periodic
    • Events
      • Time - Every (1.00 / 32.00) seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Portal_group and do (Actions)
        • Loop - Actions
          • Set Portal_traveller = (Picked unit)
          • Set Portal_INDEX_CASTER = (Custom value of Portal_traveller)
          • Set Portal_INDEX_TARGET = (Custom value of Portal_targeted[Portal_INDEX_CASTER])
          • Set Portal_loc1 = (Position of Portal_traveller)
          • Set Portal_loc3 = (Position of Portal_targeted[Portal_INDEX_CASTER])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Portal_loc1 and Portal_loc3) Less than or equal to Portal_range[Portal_INDEX_TARGET]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Portal_delay[Portal_INDEX_CASTER] Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Portal_isTeleporting[Portal_INDEX_CASTER] Equal to False
                    • Then - Actions
                      • Set Portal_isTeleporting[Portal_INDEX_CASTER] = True
                      • Set Portal_delayFXAbil[Portal_INDEX_CASTER] = Portal_delayFXAbil[Portal_INDEX_TARGET]
                      • Unit - Add Portal_delayFXAbil[Portal_INDEX_CASTER] to Portal_traveller
                    • Else - Actions
                  • Set Portal_delay[Portal_INDEX_CASTER] = (Portal_delay[Portal_INDEX_CASTER] - (1.00 / 32.00))
                • Else - Actions
                  • Set Portal_isTeleporting[Portal_INDEX_CASTER] = False
                  • Set Portal_loc2 = (Position of Portal_traveller)
                  • Special Effect - Create a special effect at Portal_loc2 using Portal_departureFX[Portal_INDEX_TARGET]
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Remove Portal_delayFXAbil[Portal_INDEX_CASTER] from Portal_traveller
                  • Custom script: call RemoveLocation(udg_Portal_loc2)
                  • Set Portal_loc2 = (Position of Portal_portal[Portal_INDEX_TARGET])
                  • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Portal_missileUseOwnMovement[Portal_INDEX_TARGET] Equal to True
                    • Then - Actions
                      • Unit - Create 1 Portal_missileDummy[Portal_INDEX_TARGET] for (Owner of Portal_traveller) at Portal_loc1 facing Portal_loc2
                      • Set Portal_dummy = (Last created unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Portal_traveller is selected by (Owner of Portal_traveller)) Equal to True
                        • Then - Actions
                          • Selection - Add Portal_dummy to selection for (Owner of Portal_traveller)
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Portal_missileTargetable[Portal_INDEX_TARGET] Equal to True
                        • Then - Actions
                          • Unit - Make Portal_dummy Vulnerable
                        • Else - Actions
                      • Unit - Order Portal_dummy to Move To Portal_loc2
                      • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_dummy)
                      • Set Portal_missileSpeed[Portal_INDEX_TRAVELLER] = 0.00
                      • Set Portal_portal[Portal_INDEX_TRAVELLER] = Portal_portal[Portal_INDEX_TARGET]
                      • Set Portal_targeted[Portal_INDEX_TRAVELLER] = Portal_traveller
                      • Unit Group - Add Portal_dummy to Portal_teleMissiles
                      • Unit - Hide Portal_traveller
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Portal_missileSpeed[Portal_INDEX_TARGET] Greater than 0.00
                        • Then - Actions
                          • Unit - Create 1 Portal_missileDummy[Portal_INDEX_TARGET] for (Owner of Portal_traveller) at Portal_loc1 facing Portal_loc2
                          • Set Portal_dummy = (Last created unit)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Portal_traveller is selected by (Owner of Portal_traveller)) Equal to True
                            • Then - Actions
                              • Selection - Add Portal_dummy to selection for (Owner of Portal_traveller)
                            • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Portal_missileTargetable[Portal_INDEX_TARGET] Equal to True
                            • Then - Actions
                              • Unit - Make Portal_dummy Vulnerable
                            • Else - Actions
                          • Unit - Add Portal_missileFXAbil[Portal_INDEX_TARGET] to Portal_dummy
                          • Animation - Change Portal_dummy flying height to Portal_missileHeight[Portal_INDEX_TARGET] at 0.00
                          • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_dummy)
                          • Set Portal_missileSpeed[Portal_INDEX_TRAVELLER] = Portal_missileSpeed[Portal_INDEX_TARGET]
                          • Set Portal_portal[Portal_INDEX_TRAVELLER] = Portal_portal[Portal_INDEX_TARGET]
                          • Set Portal_targeted[Portal_INDEX_TRAVELLER] = Portal_traveller
                          • Unit - Turn collision for Portal_dummy Off
                          • Unit Group - Add Portal_dummy to Portal_teleMissiles
                          • Unit - Hide Portal_traveller
                        • Else - Actions
                          • Custom script: call RemoveLocation(udg_Portal_loc3)
                          • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_portal[Portal_INDEX_TARGET])
                          • Set Portal_loc3 = (Portal_loc2 offset by (Random real number between 0.00 and Portal_range[Portal_INDEX_TRAVELLER]) towards (Random angle) degrees)
                          • Unit - Move Portal_traveller instantly to Portal_loc3
                          • Set Portal_loc4 = (Rally-Point of Portal_targeted[Portal_INDEX_CASTER] as a point)
                          • Unit - Order Portal_traveller to Attack-Move To Portal_loc4
                          • Custom script: call RemoveLocation(udg_Portal_loc4)
                          • Special Effect - Create a special effect at Portal_loc3 using Portal_arrivalFX[Portal_INDEX_TRAVELLER]
                          • Special Effect - Destroy (Last created special effect)
                  • Custom script: call RemoveLocation(udg_Portal_loc2)
                  • Set Portal_targeted[Portal_INDEX_CASTER] = No unit
                  • Unit Group - Remove Portal_traveller from Portal_group
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Portal_isTeleporting[Portal_INDEX_CASTER] Equal to True
                • Then - Actions
                  • -------- This is here in case of a unit being knockbacked outside the Portal's reach --------
                  • Set Portal_isTeleporting[Portal_INDEX_CASTER] = False
                  • Unit - Order Portal_traveller to Right-Click Portal_targeted[Portal_INDEX_CASTER]
                • Else - Actions
          • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
          • Custom script: call RemoveLocation(udg_Portal_loc3)
          • Custom script: call RemoveLocation(udg_Portal_loc1)
      • Unit Group - Pick every unit in Portal_teleMissiles and do (Actions)
        • Loop - Actions
          • -------- In this group, the Portal_traveller is the missile unit, not the actual unit being teleported --------
          • -------- The unit is Portal_targeted --------
          • Set Portal_traveller = (Picked unit)
          • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_traveller)
          • Set Portal_INDEX_CASTER = (Custom value of Portal_targeted[Portal_INDEX_TRAVELLER])
          • Set Portal_INDEX_TARGET = (Custom value of Portal_portal[Portal_INDEX_TRAVELLER])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Portal_traveller is alive) Equal to True
            • Then - Actions
              • Set Portal_loc1 = (Position of Portal_traveller)
              • Set Portal_loc2 = (Position of Portal_portal[Portal_INDEX_TRAVELLER])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Portal_missileSpeed[Portal_INDEX_TRAVELLER] Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Portal_loc1 and Portal_loc2) Less than or equal to (Portal_missileSpeed[Portal_INDEX_TRAVELLER] / 33.00)
                    • Then - Actions
                      • Unit - Unhide Portal_targeted[Portal_INDEX_TRAVELLER]
                      • Set Portal_loc3 = (Portal_loc1 offset by (Random real number between 0.00 and Portal_range[(Custom value of Portal_portal[Portal_INDEX_TRAVELLER])]) towards (Random angle) degrees)
                      • Unit - Move Portal_targeted[Portal_INDEX_TRAVELLER] instantly to Portal_loc3
                      • Unit - Add a 0.01 second Generic expiration timer to Portal_traveller
                      • Unit Group - Remove Portal_traveller from Portal_teleMissiles
                      • Unit Group - Remove Portal_targeted[Portal_INDEX_TRAVELLER] from Portal_group
                      • Special Effect - Create a special effect at Portal_loc3 using Portal_arrivalFX[(Custom value of Portal_portal[Portal_INDEX_TRAVELLER])]
                      • Special Effect - Destroy (Last created special effect)
                      • Set Portal_loc4 = (Rally-Point of Portal_portal[Portal_INDEX_TRAVELLER] as a point)
                      • Unit - Order Portal_targeted[Portal_INDEX_TRAVELLER] to Attack-Move To Portal_loc4
                      • Custom script: call RemoveLocation(udg_Portal_loc4)
                      • Custom script: call RemoveLocation(udg_Portal_loc3)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Portal_traveller is selected by (Owner of Portal_traveller)) Equal to True
                        • Then - Actions
                          • Selection - Add Portal_targeted[Portal_INDEX_TRAVELLER] to selection for (Owner of Portal_traveller)
                        • Else - Actions
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Portal_portal[Portal_INDEX_TRAVELLER] is alive) Equal to True
                        • Then - Actions
                          • Set Portal_loc3 = (Portal_loc1 offset by (Portal_missileSpeed[Portal_INDEX_TRAVELLER] / 33.00) towards (Angle from Portal_loc1 to Portal_loc2) degrees)
                          • Unit - Move Portal_traveller instantly to Portal_loc3, facing Portal_loc2
                          • Custom script: call RemoveLocation(udg_Portal_loc3)
                        • Else - Actions
                          • Unit - Add a 0.01 second Generic expiration timer to Portal_traveller
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Portal_loc1 and Portal_loc2) Less than or equal to Portal_range[Portal_INDEX_TARGET]
                    • Then - Actions
                      • Unit - Unhide Portal_targeted[Portal_INDEX_TRAVELLER]
                      • Unit - Move Portal_targeted[Portal_INDEX_TRAVELLER] instantly to Portal_loc1
                      • Unit - Add a 0.01 second Generic expiration timer to Portal_traveller
                      • Unit Group - Remove Portal_traveller from Portal_teleMissiles
                      • Unit Group - Remove Portal_targeted[Portal_INDEX_TRAVELLER] from Portal_group
                      • Special Effect - Create a special effect at Portal_loc1 using Portal_arrivalFX[Portal_INDEX_TARGET]
                      • Special Effect - Destroy (Last created special effect)
                      • Set Portal_loc4 = (Rally-Point of Portal_portal[Portal_INDEX_TRAVELLER] as a point)
                      • Unit - Order Portal_targeted[Portal_INDEX_TRAVELLER] to Attack-Move To Portal_loc4
                      • Custom script: call RemoveLocation(udg_Portal_loc4)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Portal_traveller is selected by (Owner of Portal_traveller)) Equal to True
                        • Then - Actions
                          • Selection - Add Portal_targeted[Portal_INDEX_TRAVELLER] to selection for (Owner of Portal_traveller)
                        • Else - Actions
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Portal_portal[Portal_INDEX_TRAVELLER] is alive) Equal to True
                        • Then - Actions
                        • Else - Actions
                          • Unit - Add a 0.01 second Generic expiration timer to Portal_traveller
              • Custom script: call RemoveLocation(udg_Portal_loc2)
              • Custom script: call RemoveLocation(udg_Portal_loc1)
            • Else - Actions
              • Unit - Unhide Portal_targeted[Portal_INDEX_TRAVELLER]
              • Set Portal_loc1 = (Position of Portal_traveller)
              • Unit - Move Portal_targeted[Portal_INDEX_TRAVELLER] instantly to Portal_loc1
              • Custom script: call RemoveLocation(udg_Portal_loc1)
              • Animation - Change Portal_targeted[Portal_INDEX_TRAVELLER] flying height to (Current flying height of Portal_traveller) at 0.00
              • Unit - Explode Portal_targeted[Portal_INDEX_TRAVELLER]
              • Unit Group - Remove Portal_targeted[Portal_INDEX_TRAVELLER] from Portal_group
              • Unit Group - Remove Portal_traveller from Portal_teleMissiles
              • Unit - Remove Portal_delayFXAbil[Portal_INDEX_TRAVELLER] from Portal_traveller
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Portal_traveller is selected by (Owner of Portal_traveller)) Equal to True
                • Then - Actions
                  • Selection - Add Portal_targeted[Portal_INDEX_TRAVELLER] to selection for (Owner of Portal_traveller)
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Portal_group is empty) Equal to True
          • (Portal_teleMissiles is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Portal Disengage
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Portal_group) Equal to True
      • (Target unit of issued order) Not equal to Portal_targeted[(Custom value of (Triggering unit))]
    • Actions
      • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
      • Set Portal_INDEX_TARGET = (Custom value of Portal_targeted[Portal_INDEX_CASTER])
      • Set Portal_delay[Portal_INDEX_CASTER] = 0.00
      • Set Portal_isTeleporting[Portal_INDEX_CASTER] = False
      • Set Portal_targeted[Portal_INDEX_CASTER] = No unit
      • Unit Group - Remove (Triggering unit) from Portal_group
      • Unit - Remove Portal_delayFXAbil[Portal_INDEX_TARGET] from (Triggering unit)
  • Portal Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • Portal_active[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
      • Set Portal_INDEX_TARGET = (Custom value of Portal_portal[Portal_INDEX_CASTER])
      • Unit Group - Pick every unit in Portal_group and do (Actions)
        • Loop - Actions
          • Set Portal_traveller = (Picked unit)
          • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_traveller)
          • Unit - Remove Portal_delayFXAbil[Portal_INDEX_CASTER] from Portal_traveller
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Portal_targeted[Portal_INDEX_TRAVELLER]
            • Then - Actions
              • Set Portal_targeted[Portal_INDEX_TRAVELLER] = No unit
              • Set Portal_delay[Portal_INDEX_TRAVELLER] = 0.00
              • Set Portal_isTeleporting[Portal_INDEX_TRAVELLER] = False
              • Unit Group - Remove Portal_traveller from Portal_group
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Portal_portal[Portal_INDEX_CASTER] Equal to Portal_targeted[Portal_INDEX_TRAVELLER]
            • Then - Actions
              • Set Portal_targeted[Portal_INDEX_TRAVELLER] = No unit
              • Set Portal_delay[Portal_INDEX_TRAVELLER] = 0.00
              • Set Portal_isTeleporting[Portal_INDEX_TRAVELLER] = False
              • Unit Group - Remove Portal_traveller from Portal_group
            • Else - Actions
      • Set Portal_active[Portal_INDEX_CASTER] = False
      • Set Portal_active[Portal_INDEX_TARGET] = False
      • Special Effect - Destroy Portal_FX[Portal_INDEX_CASTER]
      • Special Effect - Destroy Portal_FX[Portal_INDEX_TARGET]
      • Set Portal_portal[Portal_INDEX_CASTER] = No unit
      • Set Portal_portal[Portal_INDEX_TARGET] = No unit
  • Portal Missile Order
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • ((Triggering unit) is in Portal_teleMissiles) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
      • Set Portal_loc1 = (Position of Portal_portal[Portal_INDEX_CASTER])
      • Unit - Order (Triggering unit) to Move To Portal_loc1
      • Custom script: call RemoveLocation(udg_Portal_loc1)
      • Trigger - Turn on (This trigger)
  • Portal Disconnect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Portal_active[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Portal_SeverAbility
        • Then - Actions
          • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
          • Set Portal_INDEX_TARGET = (Custom value of Portal_portal[Portal_INDEX_CASTER])
          • Unit - Remove Portal_SeverAbility from (Triggering unit)
          • Unit - Remove Portal_SeverAbility from Portal_portal[Portal_INDEX_CASTER]
          • Unit Group - Pick every unit in Portal_group and do (Actions)
            • Loop - Actions
              • Set Portal_traveller = (Picked unit)
              • Set Portal_INDEX_TRAVELLER = (Custom value of Portal_traveller)
              • Unit - Remove Portal_delayFXAbil[Portal_INDEX_CASTER] from Portal_traveller
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to Portal_targeted[Portal_INDEX_TRAVELLER]
                • Then - Actions
                  • Set Portal_targeted[Portal_INDEX_TRAVELLER] = No unit
                  • Set Portal_delay[Portal_INDEX_TRAVELLER] = 0.00
                  • Set Portal_isTeleporting[Portal_INDEX_TRAVELLER] = False
                  • Unit Group - Remove Portal_traveller from Portal_group
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Portal_portal[Portal_INDEX_CASTER] Equal to Portal_targeted[Portal_INDEX_TRAVELLER]
                • Then - Actions
                  • Set Portal_targeted[Portal_INDEX_TRAVELLER] = No unit
                  • Set Portal_delay[Portal_INDEX_TRAVELLER] = 0.00
                  • Set Portal_isTeleporting[Portal_INDEX_TRAVELLER] = False
                  • Unit Group - Remove Portal_traveller from Portal_group
                • Else - Actions
          • Set Portal_active[Portal_INDEX_CASTER] = False
          • Set Portal_active[Portal_INDEX_TARGET] = False
          • Special Effect - Destroy Portal_FX[Portal_INDEX_CASTER]
          • Special Effect - Destroy Portal_FX[Portal_INDEX_TARGET]
          • Set Portal_portal[Portal_INDEX_CASTER] = No unit
          • Set Portal_portal[Portal_INDEX_TARGET] = No unit
        • Else - Actions
-------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------



This is in a loop because both Portals need to be setup at the same time. A loop simplifies the process.

  • Connect Portal 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Connect Portals 1
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of ability being cast)) Equal to (Unit-type of (Triggering unit))
        • Then - Actions
          • Set Portal_INDEX_CASTER = (Custom value of (Triggering unit))
          • Set Portal_INDEX_TARGET = (Custom value of (Target unit of ability being cast))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Portal_active[Portal_INDEX_TARGET] Equal to True
              • (Target unit of ability being cast) Not equal to Portal_portal[Portal_INDEX_CASTER]
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffffcc00This Port...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to Portal_portal[Portal_INDEX_TARGET]
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffffcc00Those two...
                • Else - Actions
                  • Set Portal_ConfigIndex[1] = Portal_INDEX_CASTER
                  • Set Portal_ConfigIndex[2] = Portal_INDEX_TARGET
                  • For each (Integer A) from 1 to 2, do (Actions)
                    • Loop - Actions
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- CONFIGURE HERE --------
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is the special effect that will play when a teleport begins --------
                      • Set Portal_departureFX[Portal_ConfigIndex[(Integer A)]] = Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is the special effect that will play when a teleport ends --------
                      • Set Portal_arrivalFX[Portal_ConfigIndex[(Integer A)]] = Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is the special effect that indicates whether a portal is active or not --------
                      • Set Portal_activeFX[Portal_ConfigIndex[(Integer A)]] = Abilities\Spells\NightElf\Starfall\StarfallCaster.mdl
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is the special effect that indicates that the delay has been engaged. You may ignore this if your delay is 0 --------
                      • -------- I use an ability here because it allows for up to 6 different attachment points, each with their own effects if you so desire. --------
                      • Set Portal_delayFXAbil[Portal_ConfigIndex[(Integer A)]] = delayFX - Connect Portal 1
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is the range at which portals can catch units to be teleported --------
                      • Set Portal_range[Portal_ConfigIndex[(Integer A)]] = 165.00
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This is time that portals need to teleport unit. If the value is 0, the teleportation is instantaneous --------
                      • Set Portal_delay[Portal_ConfigIndex[(Integer A)]] = 3.00
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- if this boolean is set to TRUE, only Player Units will be allowed to use the Portals. FALSE by default. --------
                      • Set Portal_preventAllies[Portal_ConfigIndex[(Integer A)]] = False
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- if Portal_missileSpeed is 0, the teleportation is instantaneous and Portal_missileHeight is ignored --------
                      • Set Portal_missileSpeed[Portal_ConfigIndex[(Integer A)]] = 1600.00
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- If missileSpeed and/or missileUseOwnMovement in non-zero/TRUE, this will set the height of the missile unit --------
                      • Set Portal_missileHeight[Portal_ConfigIndex[(Integer A)]] = 200.00
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- I use an ability for applying special effects to the missile since you can have up to 6 effects and, if applicable, they carry team colour --------
                      • Set Portal_missileFXAbil[Portal_ConfigIndex[(Integer A)]] = FX - Blue Energy
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- You can customise the missile unit here. Eg: if you want to use a fast-moving ground unit for tunnel-type portals, you may put it here --------
                      • Set Portal_missileDummy[Portal_ConfigIndex[(Integer A)]] = Portal Carrier (Dummy Unit - Flying)
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This will decided whether the missile units can be targeted and destroyed by enemy units. This will remove locust from your dummy units. --------
                      • Set Portal_missileTargetable[Portal_ConfigIndex[(Integer A)]] = False
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- This decides if your missile unit will use it's own movement instead of being moved by triggers. I enforce orders with Ward classification to avoid... weirdness --------
                      • Set Portal_missileUseOwnMovement[Portal_ConfigIndex[(Integer A)]] = False
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                      • -------- //END CONFIGURATION --------
                      • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                  • Set Portal_INDEX_CASTER = Portal_ConfigIndex[1]
                  • Set Portal_INDEX_TARGET = Portal_ConfigIndex[2]
                  • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
                  • Trigger - Run Portal Connect <gen> (ignoring conditions)
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffffcc00Must targ...
Keywords:
Way Gate, Waygate, Portal, Teleporter, Nydus, Canal, Transporter, Warp gate, Warpgate, Translocator, Gate, Door, Dimensional Door
Contents

Portal System v2.5 (Map)

Reviews
17th October Bribe: An intricate system which has been tested and refined to work properly. Thanks for contributing these resources of yours!

Moderator

M

Moderator

17th October
Bribe: An intricate system which has been tested and refined to work properly. Thanks for contributing these resources of yours!
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,176
Hm.. seems like too much code considering how simple this is.

You COULD pick all portal unit types and check for every unit close to it. Teleport to connected portal.. and that's that. That's five actions (+ leak removal) or something.

If I were to make it perfectly efficient I would create a trigger for each portal with the event unit comes within range..
Kind of hard to describe with words but something like this, concept wise:
JASS:
function Teleport takes nothing returns nothing
	call SetUnitX(...)
	call SetUnitY(...)
endfunction

function CreatePortal takes nothing returns nothing
    trigger t = CreateTrigger()
    call TriggerRegisterUnitInRangeSimple( gg_trg_Untitled_Trigger_002, 100, CreateUnit(...))
	call TriggerAddAction(t, function Teleport)
endfunction
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,176
Well, I did the following. This is only handles teleportation for now, I will work more on it when I am bored. Point being that the code is much shorter.
JASS:
library portals initializer myInit

	globals
		private hashtable h = InitHashtable()
	endglobals
	
	function Teleport takes nothing returns nothing
		local unit u = LoadUnitHandle(h, GetHandleId(GetTriggeringTrigger()), 1)
		local real x = LoadReal(h, GetHandleId(u), 2)
		local real y = LoadReal(h, GetHandleId(u), 3)
		call SetUnitPositionLoc(GetTriggerUnit(), PolarProjectionBJ(Location(x, y), 260, GetRandomDirectionDeg()))
	endfunction
	function ConnectPortals takes unit u, unit u2 returns nothing
		call SaveReal(h, GetHandleId(u), 2, GetUnitX(u2))
		call SaveReal(h, GetHandleId(u), 3, GetUnitY(u2))
		call SaveReal(h, GetHandleId(u2), 2, GetUnitX(u))
		call SaveReal(h, GetHandleId(u2), 3, GetUnitY(u))
		
	endfunction
	
	function SetPortal takes unit u returns nothing
		local trigger t = CreateTrigger()
		call TriggerRegisterUnitInRangeSimple(t, 150, u)
		call TriggerAddAction(t, function Teleport)
		call SaveTriggerHandle(h, GetHandleId(u), 1, t)
		call SaveUnitHandle(h, GetHandleId(t), 1, u)
	endfunction

	private function myInit takes nothing returns nothing
		call SetPortal(gg_unit_hhou_0000)
		call SetPortal(gg_unit_halt_0002)
		call ConnectPortals(gg_unit_hhou_0000, gg_unit_halt_0002)
	endfunction
endlibrary
 
Of course, the danger to wanting the shortest code possible is that before too long somebody might come along with a library that lets you write even shorter code. For example, suppose you had a library SlickCommon that provided a more object oriented approach to many of the functions in common.j. You could express even the vJASS you just posted with even less code:

JASS:
library portals initializer myInit requires SlickCommon
	struct PortalTransportTrigger extends Trigger
		private real destinationX
		private real destinationY
		public static method create takes unit portal, real destinationX, real destinationY returns PortalTransportTrigger
			local PortalTransportTrigger this = .allocate()
			set this.destinationX = destinationX
			set this.destinationY = destinationY
			call this.registerUnitInRange(150, portal, null)
			return this
		endmethod
		public method doActions takes nothing returns nothing
			local real ang = GetRandomReal(0,bj_PI*2)
			call SetUnitPosition(GetTriggerUnit(), destinationX + Cos(ang)*260, destinationY + Sin(ang)*260)
		endmethod
	endstruct
	
	private function myInit takes nothing returns nothing
		call PortalTransportTrigger.create(gg_unit_hhou_0000,GetUnitX(gg_unit_halt_0002),GetUnitY(gg_unit_halt_0002))
		call PortalTransportTrigger.create(gg_unit_halt_0002,GetUnitX(gg_unit_hhou_0000),GetUnitY(gg_unit_hhou_0000))
	endfunction
endlibrary
 
Sorta makes sense, just gotta be careful. Speaking of performance, your sample code leaks a location handle every time a unit steps through a portal because the inline call to PolarProjectionBJ creates a new location handle that is never destroyed. Might want to warn people who use it to fix that.
 
Alone the installation looks quite specific, hardcoded and restrictive, if you ask me.
Systems should be as configurable as possible to be compatible for more different requests.
Can't really argue there, though I'm not sure what I could do to make it more configurable. If anyone has any ideas, I'll see about implementing them if I can.

Like this event system now. When you use/need other systems, link to them so we can check them out.

I... I did... in the documentation :|
 
I'm actually thinking of using a timer everytime a unit right-clicks a portal so that people won't have to use DynamicEvents and edit the variables for the accompanying trigger, but would that be a worthwhile update? It would make the installation less annoying, but... periodic timers.

EDIT: Updated to version 2.0!
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
Lol, this is not something that you should use that Unit In Range event for actually :D
I made that to show you how to do that for units that are created throughout the game that require something better than pick every unit in range and give you the event response to give the unit that the target came in range of.

In this case, using smart would work the best imo.
 
It's not using DynamicEvents anymore. I should point out that the thing about this system is that it gives you buildable portals that you can connect, reconnect and disconnect as you see fit.

I haven't actually looked at the code of DynamicEvents either though :p I don't know how to read JASS (at least I didn't know then). I might take a look at it now, but I doubt I'm that more enlightened since then :D

Anyway, it works the way it should now (hopefully). Waiting for that mod mark of approval :p

PS: What do you mean by using smart? D'you mean right-clicking the portal when the unit is in range?
 
UPDATE v2.2
• Portal_index changed to Portal_ConfigIndex and is used only in configuration. Portal_INDEX_CASTER/TARGET/TRAVELLER were added to use as index in the rest of the system.
• Added a failsafe to prevent movable portals (like the owls) to use portals while connected as this seemed to bug out their own connections. Disconnect them to allow them to use portals.
• Checks to see whether portals are connected in the configuration now, rather than in the connection trigger. This is to avoid switching out values from portals that are already connected. I'm afraid there's no way around this.
• GUI AutoFly no longer needed. Add storm crow form to your dummy units to remove the need for autofly on dummies. (This is for reducing the amount of requirements for the system. I recommend having autofly in your maps regardless as if may come in handy in other places).

Also made some small changes here and there to fix some bugs.
 
Level 12
Joined
May 28, 2015
Messages
385
I could make the missiles invulnerable instead of unselectable and attach the value of the units to them. If they are still selected when destroyed, select the units as they are unhidden.


Well, I'm no expert but I think you still can retain the locust and making the unit hidden part. Just put an action in the trigger where it selects the teleported unit after it has done teleporting.
 
UPDATE v2.4
- Added a new variable to handle the Sever Connection ability since that had to be set manually if the id of the spell was not to same per map. Set it in Portal Connect at the top. That method also allows you to use whatever no-target spell you want to disconnect portals.
- Move Portal Periodic trigger up to facilitate installation as some functions were being disabled on import bcz world edit is dumb.
- Portal Connect is no longer optional. Not sure why it was in the first place...
- fixed an issue where non-flying missiles would get stuck on units.
- Updated README.
 
Level 6
Joined
Oct 31, 2015
Messages
89
First thing: Nice system, very useful to me :D

I tested the map and I found a bug when a ground unit is teleported. When the unit reaches its destination it begins to walk in little circles when turning. It also (more rarely) cause the unit to literally walk in circles when trying to execute an order to attack.

Note: I've used the missile teleport from Arcane Vault and don't know if the others have any bugs.
 
Level 6
Joined
Oct 31, 2015
Messages
89
The unit I've used was the Spell Breaker and the Sorceress (don't know if Fly movement based units are affected). The unit that walked in circles when trying to attack was a custom demon hunter. The difference appears after using the portal. The unit walks one way before using the portal and another after using the portal (forming a subtle arc to turn around).Literally walking in circles is rare but it happened once or twice (try replicate with a melee unit maybe you see). I think when the turning bug is fixed the unit won't walk in circles anymore. I tried to fix myself but I could not figure out where the bug is.
The portal I've used was the Arcane Vault Missile one, not the instant one.

I hope I helped a bit =D
 
Okay, fixed. At first I couldn't tell what you meant by walking in little circles, but eventually I noticed the slight bobbing in a direction when the unit turned. The issue was being caused by SetPropWindow, which in retrospect was a pointless function to use here since flying units are going to drift away from one another regardless of whether the PropWindow is 0 or not. Damn flyers /shake fist

UPDATE v2.5
- Fixed a bug that caused units to do a very slight arc when turning after using a Portal.
 
It's explained in the README under CUSTOMISATION. Look at the Connect Portal 1 trigger to see what can be customised.

Specifcally, look for this:
All variables within is described.

  • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
  • -------- CONFIGURE HERE --------
  • -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
 
Level 5
Joined
May 29, 2013
Messages
101
Hello. I applied this to my map but some units stop on their way. In your test map, all units are naturally teleported with a single command. do you know what the problem is? thanks.
 
Level 5
Joined
May 29, 2013
Messages
101
I found problem. If the portal unit is walkable, there is a same problem of mine.
I hope others who apply this system do not make the same mistakes as me.
 
Level 5
Joined
May 29, 2013
Messages
101
Hello. I am trying to use this system, but there is a problem with making the neutral portal unit. In one direction, unit moves normally, but in the other direction, the unit does not return and is teleported to its original position.
How can I solve this problem and use neutral portal unit? It works perfectly when the portal is playerself-owned.
To tell you the exact situation, attach a map that is causing the same problem.
 

Attachments

  • Portal System v2.5.w3x
    92.6 KB · Views: 22
Level 6
Joined
Jun 18, 2011
Messages
159
I reproduced a bug that is occuring in my map in your test map. I wanted to make the portals change ownership to an allied computer player when any user player walks in range. When I input this into your map it causes you to no longer be able to teleport from the casting portal and the casting portal also leaks a spell effect that never gets destroyed. You can still teleport from the targeted portal of the link spell and then the targeted portal will destroy it's spell effect, but the caster one as I said will leak even when you use the unlink spell. I thought it would be an easy fix for you since you made it. I've spent, too long trying to find the issue to no avail. I probably need sleep.

Edit: I finally thought of a possible workaround after seeing again that it does at least work when the portals don't start as neutral passive. I'm going to try having them either just be created when the user walks in range. Or start as CPU, then switch to neutral passive and re-create FoW on that region.

Edit 2: The starting them as my computer ally, switching to neutral passive at 1 sec in (already have too much at init and at 0 sec I feel idk) and creating a FoW after a sec wait totally worked. I am very happy. Thank you for this system. I was going to use the vJass one but I have too many libraries and am not very sure if I could make whichever ones backwards compatible. I have no vJass knowledge.
 

Attachments

  • Portal System v2.5_rescue_bug.w3x
    93.3 KB · Views: 19
Last edited:
Top