HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Checking if a unit *is carrying* something?

02-04-2006, 09:25 AM#1
Rao Dao Zao
Warcraft has various conditions to check if a unit *is being carried*, but there aren't any, that I can see, to check if a particular transport has a unit within or not.

So, have I just missed something, or can somebody suggest a method of finding out if a unit is carrying another unit? Perhaps some JASS? Any help at all would be appreciated.
02-04-2006, 09:34 AM#2
Jazradel
As far as I know there is no way to check if a unit is inside a transport.

But there may be workarounds, by detecting when a unit gets into a transport.
02-04-2006, 09:45 AM#3
PCPharaoh
Trigger:
Melee Initialization
Events
Collapse Conditions
((Triggering unit) is loaded into variable_transportunit) Equal to True
Actions

Boolean Comparison: "Unit - Unit Is In Transport"
02-04-2006, 02:32 PM#4
Rao Dao Zao
I'm not that stupid.

I want this to check if a *certain transport* contains *a unit.* If I wanted to check if a *specific unit* was in a transport that condition might have worked.
02-04-2006, 04:25 PM#5
johnfn
You're gonna need two vars for this : numTransports (Integer) and unitsCarried (Unitgroup Array)

Trigger:
LoadUnit
Collapse Events
Unit - A unit Is loaded into a transport
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Custom value of (Transporting unit)) Equal to 0
Collapse Then - Actions
Set numTransports = (numTransports + 1)
Unit - Set the custom value of (Transporting unit) to 0
Else - Actions
Unit Group - Add (Loading unit) to (unitsCarried[custom value of (Transporting unit)] )

Now we have a unitgroup corresponding to the custom value of the unit, and thats all we could ever ask for, right?

Trigger:
CheckIfUnitExists
Events
Collapse Conditions
((CheckThisUnitForExistance) is in (unitsCarried[custom value of (ship)]) Equal to True
Actions



PS! I'm not sure exactly what the action is that recognizes when a unit is unloaded. Check out different orders to see if there's a particular order that occurs when it happens, and if all else fails, you can always do something (hackish) like this

Trigger:
Actions
Collapse For each (Integer A) from 1 to numTransports, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in (unitsCarried[numTransports) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Playable map area) contains (Picked unit)) Equal to True
Collapse Then - Actions
Unit Group - Remove (Picked unit) from (unitsCarried)
Else - Actions
Custom script: call DestroyGroup( udg_TempGroup )

That may be a little laggy however. Anyways, hope I helped
02-04-2006, 05:59 PM#6
Rao Dao Zao
You see, the whole unload thing is the main problem with any kind of tracking system such as this; I know how to respond to the Unload ability, but not how to respond to somebody clicking the portrait in the unit info area. It's damnded annoying.
02-04-2006, 06:08 PM#7
PCPharaoh
So you want to check if a specific transport has ANY unit loaded, not a specific one? This condition still works.

Trigger:
Melee Initialization
Events
Collapse Conditions
((No Unit) is loaded into variable_transportunit) Equal to False
Actions

Edit: Woohoo! 100 posts. Go me!
02-04-2006, 06:17 PM#8
Rao Dao Zao
As correct as that may seem, I've just tested it and the trigger ain't firing... But interesting point.
02-04-2006, 07:46 PM#9
johnfn
As a continuation of my other trigger, I did some experimentation with WE just because it was bothering me:

Trigger:
Untitled Trigger 001
Collapse Events
Unit - A unit Is issued an order targeting an object
Collapse Conditions
(Issued order) Equal to (Order(unload))
Collapse Actions
Unit Group - Remove (Target unit of issued order) from (unitsCarried[custom value of(Ordered unit)])


It works. Do I win the prize? :D
02-04-2006, 09:21 PM#10
Vexorian
Quote:
Originally Posted by PCPharaoh
So you want to check if a specific transport has ANY unit loaded, not a specific one? This condition still works.

Trigger:
Melee Initialization
Events
Collapse Conditions
((No Unit) is loaded into variable_transportunit) Equal to False
Actions

Edit: Woohoo! 100 posts. Go me!
I can't see the logic behind that. No Unit is another way of saying null . So if null is loaded into transport? That would always return false.

---
just follow johnfn's way it is the only one known this far
02-05-2006, 09:25 AM#11
Rao Dao Zao
Well, I posted a similar thread on the battle.net forums and they came up with a more convenient way...

Do a check for the number of units in the unit group - units owned by player matching (matching unit) is in (transport).

ON another note, does the Unload order fire when you click the portrait too? If it does, you're getting rep anyway.