| 12-21-2005, 12:35 AM | #1 |
Is it possible to have a trigger that can detect with conditions the number of units found within a transport or any unit with a "cargo hold". I'm trying to make a trigger that has an effect based off of how many units are found within it that it collected. Namely dead bodies like meat wagon. I figured that there would be something possible like : IF "Number of units in unit group (units transported) by triggering unit equal to x" would be what i'd need to look for.. but i couldn't find a unit group for units within another unit. Am i missing something? Or is there no way to detect? Will i have to devise a "trick" instead to get and keep accurate numbers? so after i gave up with a few tries, i ended up with a trigger that just takes a variable and adds var = var+1 whenever the order of the "unit is loaded into a transport" is done. however.. i used up/dropped some of these, it may not be accurate.. when you do a "drop all" because that is an order that has one occurance.. so it cannot be counted accurately to var = var-1 thanks for your time. appreciate any help you can give. |
| 12-21-2005, 10:13 AM | #2 |
I'm not sure if that works, but you might try the following: Code:
local group g = CreateGroup()
local unit u
local integer count = 0
call GroupEnumUnitsInRange(g, GetUnitX(transport), GetUnitY(transport), some range, null) //no filter here, cause we found out, that filters are slower than group iteration
loop
set u = FirstOfGroup(g)
exitwhen (u == null)
if (IsUnitLoaded(u)) then
set count = count + 1
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g = null
set u = null I think you get the picture. Just enum all units in specific range (maybe you need to test a bit to get a good value) and test if they are loaded. If you have more than one transport, it might be good to check in which transport the unit is. IsUnitInTransport can help here. However, you need to know all your transports in advance (you can enum units and check for ability to get transports). Edit: Fixed the infinite loop. Thanks iNfraNe |
| 12-21-2005, 10:43 AM | #3 |
You're creating an infinite loop there starcraft. Since you use firstofgroup without removing the unit from the unit group itll always be the same unit. |
| 12-21-2005, 11:07 AM | #4 |
Damn ![]() But other than that, it would work? I edited the other post. Damn quickedit. Removed codetags so I had to add the again after I noticed it got posted without. |
| 12-21-2005, 01:05 PM | #5 |
I think someone is used with old CODE tags ^^ Use the JASS tag ;) Damit ... what to use CODE for now ^^ hm.. we need a plan... |
| 12-21-2005, 01:23 PM | #6 |
CODE is fine for everything else, such as MDL ;) |
| 12-21-2005, 08:10 PM | #7 |
well, thanks. the code gave me a few ideas, however i dont understand code fully, i can understand some principles. I like to work with the GUI. I dont think i have to worry about the multi-instance conflict. there will be only one possible unit that will have this ability for this map. so that's good. I have another question though. another idea i've had to get a similiar effect. Is it possible to check the slots of a cargo hold like you can check item slots for items? i thought that if maybe i could see how many of the 8 slots are taken up because all i need is the trigger to derive a number out of the used slots. example. If there is 6 units being carried in a 8 slot transport unit. then the value i'd need is just the 6. |
