• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Trigger Problem

Status
Not open for further replies.
Level 2
Joined
Oct 14, 2006
Messages
8
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.
 
Level 27
Joined
Feb 22, 2006
Messages
3,052
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--
 
Level 2
Joined
Oct 14, 2006
Messages
8
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.
 
Level 10
Joined
Jul 14, 2004
Messages
463
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

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
@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
 
Level 2
Joined
Oct 14, 2006
Messages
8
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.
 
Level 10
Joined
Jul 14, 2004
Messages
463
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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.
Top