• 🏆 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] Town Portal Trigger

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2010
Messages
190
How to create a Town Portal
In my last rpg map, there were great distances between the battleground and a revive stone, it always annoyed me walking the whole distance. So I wondered if you could make a Town Portal System/ Trigger like in DiabloI+II, I read a lot of Threads on different sites, but never found someone who did exactly what I was planning to do.

So after some tries, here is my result:
1. First of all I made an Item called Townportal
2. I made two trigger, the first is for opening the potal in the level

  • TP
    • Events
      • Unit - A unit owned by Player 1 (Red) Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Stadtportal
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit - Create 1 Portal for Neutral Passive at (Position of (Triggering unit)) facing Default building facing (270.0) degrees
      • Set Location[1] = (Position of (Last created unit))
      • Set Port[1] = (Last created unit)
      • Wait 0.10 seconds
      • Unit - Move (Triggering unit) instantly to (Center of Gebiet 001 <gen>)
      • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
      • Unit - Create 1 Portal for Neutral Passive at (Center of Gebiet 001 <gen>) facing Default building facing (270.0) degrees
      • Set Port[2] = (Last created unit)
3. The last thing to do is writing the Return-Trigger

  • TP 1
    • Events
      • Unit - A unit enters Gebiet 002 <gen>
    • Conditions
      • (Unit-type of (Last created unit)) Equal to Portal
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit - Move (Triggering unit) instantly to Location[1]
      • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
      • Unit - Remove Port[1] from the game
      • Unit - Remove Port[2] from the game
Its quite simple, but it works fine. Most important is setting the right variables.

Please correct me if I´m wrong or if you got a better way to realize it.
 
Level 9
Joined
Oct 11, 2009
Messages
477
Your trigger leaks, you should put a Custom Script function at the end of the second trigger and put this code: call RemoveLocation(udg_Location[1])
 
Level 6
Joined
Apr 1, 2010
Messages
190
Trigger leaks

Thanks, I´m going to add it. It could fix the problem that sometimes the port does not disappear and is unusable....

:con:
 
Level 9
Joined
Oct 11, 2009
Messages
477
Not only that, without the Custom Script code that I gave you, when the ability is used very often, your map will lag for sure, a headaching lag!
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
  • (Unit-type of (Last created unit)) Equal to Portal
´

Wait.. What?

Use
  • (Unit-type of (Last created unit)) Equal to Port(1)
  • Or -
    • (Unit-type of (Last created unit)) Equal to Port(2)
 
Level 6
Joined
Apr 1, 2010
Messages
190
Hmm good point with the lag, I´ve noticed that before, using point variables seem to be lagging at all.
Thx Etzer I´m not that good in setting trigger, so sometimes I think far too complicated....
 
Level 6
Joined
Apr 1, 2010
Messages
190
Allright the Sroll does nothing at all... but it need to be usable (not consumerable). I think thats all, in my case I used the scroll of haste. just to move faster once you are in town.
Thx all for fixing the trigger!
 
Level 6
Joined
Apr 1, 2010
Messages
190
Fixed TP-Trigger

Allright it took some time but here I post the fixed TownPortal-Trigger

1. Create an Item called Townportal, I used the Scroll of Haste so my Hero could move faster in town, but its up to you what to choose

2. Create a Portal Unit, I´ve chosen the portal from the human campaign. Make it invulnerable otherwise creeps will attack it.

3. The first trigger initiates the Tp-Creation, Unit uses the item which was created before. I´ve made two special townportal areas, one that leads you into town (Area001) and one that let you return (Area002).

  • TP INI
  • Events
  • Unit - A unit owned by Player 1 (Red) Uses an item
  • Conditions
  • (Item-type of (Item being manipulated)) Equal to Stadtportal
  • ((Triggering unit) is A Hero) Equal to True
  • Actions
  • Unit - Create 1 Portal for Neutral Passive at (Position of (Triggering unit)) facing Default building facing (270.0) degrees
  • Set Location[1] = (Position of (Last created unit))
  • Set Port[1] = (Last created unit)
  • Wait 0.10 seconds
  • Unit - Move (Triggering unit) instantly to (Center of Gebiet 001 <gen>)
  • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
  • Unit - Create 1 Portal for Neutral Passive at (Center of Gebiet 001 <gen>) facing Default building facing (270.0) degrees
  • Set Port[2] = (Last created unit)
4. Now write the return trigger

  • TP BACK
  • Events
  • Unit - A unit enters Gebiet 002 <gen>
  • Conditions
  • (Unit-type of (Last created unit)) Equal to to Port(1)
  • ((Triggering unit) is A Hero) Equal to True
  • Actions
  • Unit - Move (Triggering unit) instantly to Location[1]
  • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
  • Unit - Remove Port[1] from the game
  • Unit - Remove Port[2] from the game
  • Custom script: call RemoveLocation(udg_Location[1])
 
Level 9
Joined
Oct 11, 2009
Messages
477
Each trigger leaks a location, better check the first trigger and the action:
  • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
and at the second trigger:
  • Camera - Pan camera for Player 1 (Red) to (Position of (Triggering unit)) over 0.00 seconds
It leaks the location (Position of (Triggering unit)).
 
Status
Not open for further replies.
Top