• 🏆 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!

[Spell] Creating portals and changing their directions

Status
Not open for further replies.
Level 4
Joined
Feb 9, 2010
Messages
48
Grettings chaps,

I want to create a certain mechanic for a unit type. This unit type would be a limited one, with a limit set to 4. How would this mechanic work like:

This unit will have a spell called 'Create a portal', which will create a permament 'portal' at the location of cast. As long as the unit which cast the spell alive, the portal is alive, or unless enemy units simply destroy the portal. (So not a timed portal) Each of the units can create only one portal, meaning if the unit has already created a portal, and casts it again, the previous one is automaticaly destroyed.

That's it about the creating portals. Now moving onto the portals:

The portals would be able to connect with each other and then serving as 'real' portals, allowing players to instantly move units from one portal to another. When portal is created, by default it is 'inactive'. However it has an ability to 'connect' with another portal, thus creating a link between these two, and well, becoming active. Each portal can be connected to only one portal, and each of them can 'change' their destination, so basically disconnect with their current portal and connect with a diffrent one.

I imagine this will probably require hashtables, which I'm really a newbie in. That's why I'm asking you guys for help.
 
Level 4
Joined
Feb 9, 2010
Messages
48
I think this should solve all of your problems: Portal System.

Aye it is, but it's hell-of-overcomplicated for me. It also implements 3 other portal systems that I'm not looking for, I just need the non-missle instant portal system. Aside from that I can see that it indexes all units in the map, has event that runs every 1/32 seconds (Though it turns off after it's done with it's job), which overall seems like a lot of unwanted lags.

Perhaps not lags, but it simply takes hell of more space, compared to a simplier system that would just do the stuff for the mechanic I'm looking for. Since I'm trying to minimize all the data I'm implementing to reduce the lags and size of the map, the system you proposed it's kinda not for me.

I could edit the portal system, but I do not require the skills to do so without breaking the mechanic itself.
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Trigger it yourself with the native waypoint functions. Don't think they're available in GUI but you could implement them with custom script calls. The advantage of this is that units will automatically use the portals (waypoints) to move around the map if it would be faster than not using them.
 
Level 8
Joined
Jan 28, 2016
Messages
486
Trigger it yourself with the native waypoint functions. Don't think they're available in GUI but you could implement them with custom script calls. The advantage of this is that units will automatically use the portals (waypoints) to move around the map if it would be faster than not using them.

Well the original issue with Waygates is that they are apparently hard-coded to allow units from any and all players to use them, as outlined in this discussion by the maker of the Portal System.

Aye it is, but it's hell-of-overcomplicated for me. It also implements 3 other portal systems that I'm not looking for, I just need the non-missle instant portal system. Aside from that I can see that it indexes all units in the map, has event that runs every 1/32 seconds (Though it turns off after it's done with it's job), which overall seems like a lot of unwanted lags.

Perhaps not lags, but it simply takes hell of more space, compared to a simplier system that would just do the stuff for the mechanic I'm looking for. Since I'm trying to minimize all the data I'm implementing to reduce the lags and size of the map, the system you proposed it's kinda not for me.

I could edit the portal system, but I do not require the skills to do so without breaking the mechanic itself.

Fair enough but the system seems free of leaks so it shouldn't lag. It can be a made somewhat simpler, but not by much with respect to the triggers. You would still need a periodic trigger or timers to keep track of the distance between a unit and the target portal when it's ordered to right-click or move to a portal. Won't matter too much whether you use hashtables or unit indexing because they both achieve the same result.
 
Level 4
Joined
Feb 9, 2010
Messages
48
I've tried doing it on my own, but I failed, I'm not that experienced with hashtables. Care to help me with it?

Here are my triggers:
  • Create Portal
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Create Portal
    • Actions
      • Set TempLoc = (Target point of ability being cast)
      • Unit - Create 1 Dimensional Gate (facing southeast) for Player 1 (Red) at TempLoc facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempLoc)
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Hashtable - Save Handle Of(Last created unit) as 0 of (Key TempHandle) in PortalHash
      • Set TempUnit = (Last created unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Hashtable - Save Handle Of(Triggering unit) as 1 of (Key TempHandle) in PortalHash
      • Unit - Remove Create Portal from (Triggering unit)
      • Unit - Add Create Portal [Limited to one condition] to (Triggering unit)
  • Connect Portal
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Connect gates
    • 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 Dimensional Gate (facing southeast)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Connect gates for (Target unit of ability being cast)) Equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage life of (Target unit of ability being cast)) Equal to 100.00
                • Then - Actions
                  • Set TempUnit = (Triggering unit)
                  • Custom script: set udg_TempHandle = udg_TempUnit
                  • Hashtable - Save Handle Of(Target unit of ability being cast) as 0 of (Key TempHandle) in PortalHash
                  • Set TempUnit = (Target unit of ability being cast)
                  • Custom script: set udg_TempHandle = udg_TempUnit
                  • Hashtable - Save Handle Of(Triggering unit) as 0 of (Key TempHandle) in PortalHash
                  • Set TempLoc = ((Position of (Target unit of ability being cast)) offset by 300.00 towards 310.00 degrees)
                  • Neutral Building - Set (Triggering unit) destination to TempLoc
                  • Custom script: call RemoveLocation (udg_TempLoc)
                  • Set TempLoc = ((Position of (Triggering unit)) offset by 300.00 towards 310.00 degrees)
                  • Neutral Building - Set (Target unit of ability being cast) destination to TempLoc
                  • Custom script: call RemoveLocation (udg_TempLoc)
                  • Neutral Building - Enable (Triggering unit)
                  • Neutral Building - Enable (Target unit of ability being cast)
                  • Animation - Reset (Target unit of ability being cast)'s animation
                  • Animation - Reset (Triggering unit)'s animation
                  • Unit - Remove Connect gates from (Triggering unit)
                  • Unit - Remove Connect gates from TempUnit
                  • Unit - Add Sever Connection to (Triggering unit)
                  • Unit - Add Sever Connection to TempUnit
                • Else - Actions
                  • Game - Display to Player Group - Player 1 (Red) the text: The gate must be co...
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: Targeted gate is al...
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Must target a dimen...
  • SeverConnection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sever Connection
    • Actions
      • Unit - Remove Sever Connection from (Triggering unit)
      • Unit - Add Connect gates to (Triggering unit)
      • Neutral Building - Disable (Triggering unit)
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Neutral Building - Disable (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Remove Sever Connection from (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Add Connect gates to (Load 0 of (Key TempHandle) in PortalHash)
      • Set TempUnit = (Load 0 of (Key TempHandle) in PortalHash)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
  • Portal Summoner dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • -------- Berserk = Sever Connection spell --------
      • Unit - Order (Load 0 of (Key TempHandle) in PortalHash) to Orc Troll Berserker - Berserk
      • Set TempUnit = (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Kill (Load 0 of (Key TempHandle) in PortalHash)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
  • Portal dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dimensional Gate (facing southeast)
    • Actions
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • -------- Berserk = Sever Connection spell --------
      • Unit - Order (Load 0 of (Key TempHandle) in PortalHash) to Orc Troll Berserker - Berserk
      • Set TempUnit = (Load 1 of (Key TempHandle) in PortalHash)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Unit - Remove Create Portal [Limited to one condition] from TempUnit
      • Unit - Add Create Portal to (Triggering unit)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash

The triggers are within uploaded map
 

Attachments

  • Gates.w3x
    22.2 KB · Views: 33
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
You were on the right track with the triggers and they work well for the most part but I tried out your test map and discovered those problems with respect to the summoner not dying at times. Anyway here's my rundown of your triggers at the moment.


Create Portal
With your Create Portal trigger, it's all good. Personally I'd save each unit as "0 of Key(...)" so that 0 for the unit is the portal and vice versa but as long as you keep track of it all, it won't matter.

Connect Portal
Here you have a couple of location leaks. Within the Point with Polar Offset actions, it leaks a location whenever you use Position of (Triggering unit) without a variable to reference it and remove it later on. The trigger in the spoiler will make more sense. Other than that, it's fine with respect to the hashtable actions and everything else.

  • Point with Polar Offset leak
    • Events
    • Conditions
    • Actions
      • -------- The following will leak a location at the position of the triggering unit --------
      • Set TempLoc = ((Position of (Triggering unit)) offset by 300.00 towards 310.00 degrees)
      • Custom script: call RemoveLocation (udg_TempLoc)
      • -------- --- --------
      • -------- --- --------
      • -------- This will fix it --------
      • Set TempLoc = (Position of (Triggering unit))
      • Set TempLocOffset = (TempLoc offset by 300.00 towards 310.00 degrees)
      • Custom script: call RemoveLocation (udg_TempLoc)
      • Custom script: call RemoveLocation (udg_TempLocOffset)

Sever Connection
This seems alright. I'd store the triggering unit into the TempUnit variable at the start of the actions so you could use it in the other actions but that's not really an issue here, just me being picky! There might be some issues with clearing the child hashtables but it's mainly a result of the two remaining triggers.

Portal Summoner Dies
This is where things become unstuck. I did a quick test on this by getting the trigger to display the name of the summoner after you load it from the hashtable; it returns 'Footman' until you connect the portal with another, at which point it returns 'null' and your summoner doesn't get killed. I haven't discovered exactly what's going on (yet...) but suspect it has something to do with ordering the summoner's portal to cast Sever Connection (Berserk) which ends up running the associated trigger and clearing all the child hashtables before the rest of the actions are executed. Again, check the spoiler for a more visual representation.

  • Portal Summoner Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • -------- --- --------
      • -------- When you order it to Berserk, the Sever Connection trigger runs and this trigger pauses until it is finished --------
      • Unit - Order (Load 0 of (Key TempHandle) in PortalHash) to Orc Troll Berserker - Berserk
      • -------- --- --------
      • -------- If my assumption is correct, this is returning null 'coz 0 of Key TempHandle has been cleared in the Sever Connection trigger --------
      • Set TempUnit = (Load 0 of (Key TempHandle) in PortalHash)
      • -------- --- --------
      • -------- Therefore the Kill Unit action won't work since there's no unit to kill in TempUnit --------
      • Unit - Kill (Load 0 of (Key TempHandle) in PortalHash)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash

Portal Dies
Unlike above, I haven't run into any issues with this trigger even though it's almost a 1:1 copy of it. This is probably because the summoner is saved as 1 of Key TempHandle back in the first trigger.



---

I'd have to look into it in some more detail as I've pretty much only added some debug messages to work out what the problems are. Also, I always use Jass when working with hashtables so I've most likely missed a few things after reading all these GUI hashtable actions.
 
Last edited:
Level 4
Joined
Feb 9, 2010
Messages
48
Aye, it seems like ordering unit to sever connection was creating the mess. Also thanks for pointing out the location leak, didn't know about it.

I've changed the triggers when portal or summoner dies and now everything seems to be working correctly.

  • Portal Summoner dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • -------- TempUnit2 = Portal connected to summoner --------
      • Set TempUnit2 = (Load 0 of (Key TempHandle) in PortalHash)
      • Custom script: set udg_TempHandle2 = udg_TempUnit2
      • -------- Making inactive portal which is connected to dying's unit's portal --------
      • Unit - Remove Sever Connection from (Load 0 of (Key TempHandle2) in PortalHash)
      • Unit - Add Connect gates to (Load 0 of (Key TempHandle2) in PortalHash)
      • Neutral Building - Disable (Load 0 of (Key TempHandle2) in PortalHash)
      • -------- Kill n' clear --------
      • Unit - Kill (Load 0 of (Key TempHandle) in PortalHash)
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Hashtable - Clear all child hashtables of child (Key TempHandle2) in PortalHash
  • Portal dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dimensional Gate (facing southeast)
    • Actions
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • -------- TempUnit2 = Summoner of dying portal --------
      • Set TempUnit2 = (Load 1 of (Key TempHandle) in PortalHash)
      • Custom script: set udg_TempHandle2 = udg_TempUnit2
      • Unit - Remove Sever Connection from (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Add Connect gates to (Load 0 of (Key TempHandle) in PortalHash)
      • Neutral Building - Disable (Load 0 of (Key TempHandle) in PortalHash)
      • -------- Clear n' Change --------
      • Unit - Remove Create Portal [Limited to one condition] from TempUnit2
      • Unit - Add Create Portal to TempUnit2
      • Hashtable - Clear all child hashtables of child (Key TempHandle) in PortalHash
      • Hashtable - Clear all child hashtables of child (Key TempHandle2) in PortalHash
It would be nice if someone could check if there are any other leaks visible that I missed.

Edit:

In the trigger with Sever Connection, I've removed the clearing of hashtables, as that caused problems with the portal summoner being 'unlinked' to portal, and when portal died, the summoner couldn't create a new portal.
  • SeverConnection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sever Connection
    • Actions
      • Unit - Remove Sever Connection from (Triggering unit)
      • Unit - Add Connect gates to (Triggering unit)
      • Neutral Building - Disable (Triggering unit)
      • Set TempUnit = (Triggering unit)
      • Custom script: set udg_TempHandle = udg_TempUnit
      • Neutral Building - Disable (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Remove Sever Connection from (Load 0 of (Key TempHandle) in PortalHash)
      • Unit - Add Connect gates to (Load 0 of (Key TempHandle) in PortalHash)
 

Attachments

  • Gates.w3x
    22.7 KB · Views: 35
Last edited:
Status
Not open for further replies.
Top