Events Every .05 seconds Conditions Actions Set UnitGroup_VAR = Units matching ((Matching unit) has an item of type (YOURITEMTYPE)) Equal to True Pick every unit in UnitGroup_VAR and do actions If Picked unit's mana is less than 1 Then Remove (Item carried by (Picked Unit) of type (YOURITEMTYPE)) Else Do nothing
You can replace Remove (Item carried by (Picked Unit) of type (YOURITEMTYPE)) with Drop ((Item carried by (Picked Unit) of type (YOURITEMTYPE)) from (Picked Unit) If you want the hero to drop the item and not destroy it. --donut3.5--
Remember to destroy the groupe or else your map will be unplayable in under a minute. Also do not use DoNothing since as it name applies it does nothing but waste processing power and is not needed for an if then action to function.
I couldnt get it to work, could you be a bit more detailing of what triggers Im supposed to use. btw the unit who holds the item is a tower (mechanical) not a hero. I'm sort of new to variables to, any help would be apreciated.
Waldbaer
#5
Donut gave you a complete description of the trigger which is needed - and reading it here, I don't know why this should not work. UnitGroup_VAR should be a unit group variable you have to create in the variables window (just click on the "x" in the trigger editor, "add" in the appearing window and choose unit group as type and a enter a name of your choice). Did you really try it out this way?
@Dr Super Good: Since he uses a unit group variable, there is no group that has to be destroyed. The rest is leaking a little, too, but if this "ability" is not used very often, this should be negligible.
@Dr Super Good: Since he uses a unit group variable, there is no group that has to be destroyed.
You still have to destroy the group, or the next time the trigger runs it will overwrite the reference, but the previous group will still be floating around
...Why does everyone use vars + DestroyGroup for GUI these days? i always use set bj_wantDestroyGroup = true
WaldbärDonut gave you a complete description of the trigger which is needed - and reading it here, I don't know why this should not work. UnitGroup_VAR should be a unit group variable you have to create in the variables window (just click on the "x" in the trigger editor, "add" in the appearing window and choose unit group as type and a enter a name of your choice). Did you really try it out this way?
@Dr Super Good: Since he uses a unit group variable, there is no group that has to be destroyed. The rest is leaking a little, too, but if this "ability" is not used very often, this should be negligible.
yes I tried it out that way, I think I messed up something when I tried to set the unit group.
Waldbaer
#9
Thanks for correcting me, Purple Poot and Dr. Super Good! I'm still not very common with this leaking stuff... What happens if you set bj_wantDestroyGroup = true, actually? Which Groups are destroyed when?
@Pevs: Maybe you can describe a little more in detail what the effect was like? Then we may be able to help you better.
function ForGroupBJ takes group whichGroup, code callback returns nothing
// If the user wants the group destroyed, remember that fact and clear
// the flag, in case it is used again in the callback.
local boolean wantDestroy = bj_wantDestroyGroup
set bj_wantDestroyGroup = false
call ForGroup(whichGroup, callback)
// If the user wants the group destroyed, do so now.
if (wantDestroy) then
call DestroyGroup(whichGroup)
endif
endfunction