Unit Group - All Units in Specific Transport

Goober4473

TH.net Regular
Reaction score
7
Is there a way to directly access the unit group of all units inside a specific unit's cargo hold? I could loop through every unit and check if they're in the hold, and if so add them to a group, but that seems like ti could get very laggy, as I'd be doing this every second or so for multiple transport units.
 

Ashlebede

New Member
Reaction score
43
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is loaded into a transport
    • Conditions
      • (Loading unit) Equal to {My unit}
    • Actions
      • Unit Group - Add (Triggering unit) to {Group}


Every time you need to use that group, just check if (Picked unit) is in that transport. If it is, then do whatever actions. Else, remove it from the group so it doesn't get too big (there is no "gets off a transport" event or anything similar).

If you want a specific group for every unit, you'll have to use hashtables.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
there is a vJass system in the "turtorials and resources" sub-forum which adds a "unit is unloaded from transport" event. in combination with the above posted trigger you could keep track of all units inside a transport.

however, doing:
Trigger:
  • set Temp_Group = Units owned by SOMEPLAYER matching (Matching unit is loaded into SOMEUNIT) Equal to true

would work as well.
 

Ashlebede

New Member
Reaction score
43
Accname said:
however, doing:
Trigger:
  • set Temp_Group = Units owned by SOMEPLAYER matching (Matching unit is loaded into SOMEUNIT) Equal to true

would work as well.

I think that's what he had in the first place... :rolleyes:
 

Goober4473

TH.net Regular
Reaction score
7
Ashlebede's idea works. I just forgot about hashtables, since I haven't needed them before. That way, I have a unique unit group attached to each of the transport units.

As Ashlebede said, I also don't need a way to detect units being removed from the transports, since every second I look at all units in the unit group anyways, and I can just see if they're still in the transport, and if not remove them from the group.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top