Trigger Problem

Status
Not open for further replies.

pevs

P

pevs

I'm trying to make a trigger that goes like this:

A GENERIC unit has 0 mana and HAS an item

The item it has is called "insert a item name here"

If the unit has 0 mana the item is deleted.


I need some help.
 
I'll give ya what I know to aid you.

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--
 
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.
 
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.
 
LOL its creating a unit GROUPE every 0.05 seconds.
Set UnitGroup_VAR = Units matching ((Matching unit) has an item of type (YOURITEMTYPE)) Equal
Units matching returns a UNIT GROUPE and unless you destroy the groupe it WILL leak and the map WILL then lag in under 60 seconds due to leaking.

Triggers like this MUST never leak since they are firing 20 times a second and if even 1 var is leaked the map will become unplayable very fast.
 
@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 :D
 
Waldbär said:
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.

yes I tried it out that way, I think I messed up something when I tried to set the unit group.
 
Thanks for correcting me, Purple Poot and Dr. Super Good! I'm still not very common with this leaking stuff... :oops:
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.
 
JASS:
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

does that answer ur question? x.x
 
Status
Not open for further replies.
Back
Top