• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Help me with this Town Portal Trigger :]

Status
Not open for further replies.
Level 10
Joined
May 27, 2009
Messages
494
I have just found out a GetClosestUnit() Library and use it for my town portal trigger to work with just like d ota.

Here is My triggers:

  • Town Portal
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Town Portal
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TP_Index[1] Equal to 0
        • Then - Actions
          • Trigger - Turn on Town Portal Loop <gen>
        • Else - Actions
      • Set TP_Index[1] = (TP_Index[1] + 1)
      • Set TP_Index[2] = (TP_Index[2] + 1)
      • Set TP_Caster[TP_Index[2]] = (Triggering unit)
      • Unit - Order TP_Caster[TP_Index[2]] to Hold Position
      • Set TP_TargetPoint[TP_Index[2]] = (Target point of ability being cast)
      • Set TP_EndProccess[TP_Index[2]] = False
      • Set TP_BooleanOn[TP_Index[2]] = True
      • Set TP_CasterAquisition[TP_Index[2]] = (Default acquisition range of TP_Caster[TP_Index[2]])
      • Unit - Set TP_Caster[TP_Index[2]] acquisition range to 1.00
      • Set TP_WaitCount[TP_Index[2]] = 0.00
      • Set TP_CastTime[TP_Index[2]] = 3.50
      • Set TP_UnitGroup[TP_Index[2]] = (Units in (Playable map area) matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) belongs to an ally of (Owner of TP_Caster[TP_Index[2]])) Equal to True) and ((Owner of (Matching unit)) Not equal to Neutral Passive))))
      • Set TP_X[TP_Index[2]] = (X of TP_TargetPoint[TP_Index[2]])
      • Set TP_Y[TP_Index[2]] = (Y of TP_TargetPoint[TP_Index[2]])
      • Custom script: set udg_TP_TargetUnitPoint[udg_TP_Index[2]] = GetUnitLoc(GetClosestUnitInGroup(udg_TP_X[udg_TP_Index[2]], udg_TP_Y[udg_TP_Index[2]], udg_TP_UnitGroup[udg_TP_Index[2]] ))
      • Special Effect - Create a special effect at TP_TargetUnitPoint[TP_Index[2]] using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
      • Set TP_SFX[TP_Index[2]] = (Last created special effect)
      • Special Effect - Create a special effect attached to the origin of TP_Caster[TP_Index[2]] using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
      • Set TP_SFXUnit[TP_Index[2]] = (Last created special effect)
  • Town Portal Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer TP_Index[3]) from 1 to TP_Index[2], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TP_BooleanOn[TP_Index[3]] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TP_Caster[TP_Index[3]] has buff Stunned (Pause)) Equal to True
                • Then - Actions
                  • Special Effect - Destroy TP_SFX[TP_Index[3]]
                  • Special Effect - Destroy TP_SFXUnit[TP_Index[3]]
                  • Set TP_EndProccess[TP_Index[3]] = True
                  • Unit - Set TP_Caster[TP_Index[3]] acquisition range to TP_CasterAquisition[TP_Index[3]]
                  • Custom script: call DestroyGroup(udg_TP_UnitGroup[udg_TP_Index[3]])
                  • Custom script: call RemoveLocation(udg_TP_TargetUnitPoint[udg_TP_Index[3]])
                  • Custom script: call RemoveLocation(udg_TP_TargetPoint[udg_TP_Index[3]])
                  • Set TP_BooleanOn[TP_Index[3]] = False
                  • Set TP_Index[1] = (TP_Index[1] - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TP_Index[1] Equal to 0
                    • Then - Actions
                      • Set TP_Index[2] = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TP_Caster[TP_Index[3]] is alive) Equal to False
                    • Then - Actions
                      • Special Effect - Destroy TP_SFX[TP_Index[3]]
                      • Special Effect - Destroy TP_SFXUnit[TP_Index[3]]
                      • Set TP_EndProccess[TP_Index[3]] = True
                      • Unit - Set TP_Caster[TP_Index[3]] acquisition range to TP_CasterAquisition[TP_Index[3]]
                      • Custom script: call DestroyGroup(udg_TP_UnitGroup[udg_TP_Index[3]])
                      • Custom script: call RemoveLocation(udg_TP_TargetUnitPoint[udg_TP_Index[3]])
                      • Custom script: call RemoveLocation(udg_TP_TargetPoint[udg_TP_Index[3]])
                      • Set TP_BooleanOn[TP_Index[3]] = False
                      • Set TP_Index[1] = (TP_Index[1] - 1)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TP_Index[1] Equal to 0
                        • Then - Actions
                          • Set TP_Index[2] = 0
                          • Trigger - Turn off (This trigger)
                        • Else - Actions
                    • Else - Actions
              • Set TP_WaitCount[TP_Index[3]] = (TP_WaitCount[TP_Index[3]] + 0.20)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TP_WaitCount[TP_Index[3]] Greater than or equal to TP_CastTime[TP_Index[3]]
                • Then - Actions
                  • Special Effect - Destroy TP_SFX[TP_Index[3]]
                  • Special Effect - Destroy TP_SFXUnit[TP_Index[3]]
                  • Set TP_EndProccess[TP_Index[3]] = True
                  • Unit - Move TP_Caster[TP_Index[3]] instantly to TP_TargetUnitPoint[TP_Index[3]]
                  • Unit - Set TP_Caster[TP_Index[3]] acquisition range to TP_CasterAquisition[TP_Index[3]]
                  • Custom script: call DestroyGroup(udg_TP_UnitGroup[udg_TP_Index[3]])
                  • Custom script: call RemoveLocation(udg_TP_TargetUnitPoint[udg_TP_Index[3]])
                  • Custom script: call RemoveLocation(udg_TP_TargetPoint[udg_TP_Index[3]])
                  • Set TP_BooleanOn[TP_Index[3]] = False
                  • Set TP_Index[1] = (TP_Index[1] - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TP_Index[1] Equal to 0
                    • Then - Actions
                      • Set TP_Index[2] = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
            • Else - Actions

  • Town Portal Cancel
    • 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
    • Actions
      • For each (Integer TP_Index[3]) from 1 to TP_Index[2], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TP_BooleanOn[TP_Index[3]] Equal to True
              • TP_EndProccess[TP_Index[3]] Equal to False
            • Then - Actions
              • Special Effect - Destroy TP_SFX[TP_Index[3]]
              • Special Effect - Destroy TP_SFXUnit[TP_Index[3]]
              • Unit - Set TP_Caster[TP_Index[3]] acquisition range to TP_CasterAquisition[TP_Index[3]]
              • Custom script: call DestroyGroup(udg_TP_UnitGroup[udg_TP_Index[3]])
              • Custom script: call RemoveLocation(udg_TP_TargetUnitPoint[udg_TP_Index[3]])
              • Custom script: call RemoveLocation(udg_TP_TargetPoint[udg_TP_Index[3]])
              • Set TP_BooleanOn[TP_Index[3]] = False
              • Set TP_Index[1] = (TP_Index[1] - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TP_Index[1] Less than or equal to 0
                • Then - Actions
                  • Set TP_Index[2] = 0
                  • Trigger - Turn off Town Portal Loop <gen>
                • Else - Actions
            • Else - Actions
If you want to take a look at the GetClosestUnit() library i used, its here:
http://www.hiveworkshop.com/forums/jass-functions-413/getclosestunit-s-59254/

Here are the list of problems that i have and needs to be fixed about it or help me :cry: :
*Sometimes, when casted on at least the farthest unit from the casting point, it would work but once use again, the teleport point will always be that point.
*And Is there any script or ability that would make a unit disable for attacking while in the Town Portal phase, just like the normal Town Portal ability but the other Commands (like Stop, Hold Position and Patrol) is enabled but the unit can still attack.

Help PLs

btw, I use the Channel Ability for this.
*I use begin casting an ability event because the Unit start the effect of an ability is bugging on my map i don't know why.
 
Status
Not open for further replies.
Top