• 🏆 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!

Item Group problem

Status
Not open for further replies.
Level 6
Joined
Jan 29, 2010
Messages
213
Hi all,
I have one problem here.
I'm creating an ability witch selects all items in the map of type, but I can't find a way how to do that.

1.


There's an "action":
  • Item - Pick every item in (Playable map area) and do (Actions)
But there isn't anything like in Units group with "matching/ of type":
  • Unit Group - Pick every unit in (Units in (Playable map area) matching (condition)) and do (Actions)
2.

There is variables like:
  • Item
  • Item-Class
  • Item-Type
But there isn't any of Item Group like with units:
  • Unit-Group

I need Action like this one:
  • Item - pick every Item in the map of type XXX matching String (Substring((String((Custom value of (Picked item)))), 1, 1)) Equal to (String((Player number of (Owner of (Casting unit)))))
(I have tried picking every item in the map and adding:
  • ((Item-type of (Picked item)) Equal to Doll) and ((Substring((String((Custom value of (Picked item)))), 1, 1)) Equal to (String((Player number of (Owner of (Casting unit))))))
Condition, but that doesn't work :(


I would really appreciate your help
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
This works just fine for me:
  • Item - Pick every item in (Playable map area) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Crown of Kings +5
          • (Custom value of (Picked item)) Equal to (Player number of (Triggering player))
        • Then - Actions
          • -------- Actions --------
        • Else - Actions
There is one thing I do not understand, though: why do you convert the custom value to a string, if it's supposed to be an integer?
I'm talking about these:
String((Custom value of (Picked item),
String((Player number of (Owner of (Casting unit))​
You can just compare Custom value with Player number - no need for the string at all (it's only slowing it down).

Also: "Casting Unit" is obsolete. Use "Triggering Unit" (in this case, you can even use "Triggering Player").
 
Level 6
Joined
Jan 29, 2010
Messages
213
This works just fine for me:
  • Item - Pick every item in (Playable map area) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Crown of Kings +5
          • (Custom value of (Picked item)) Equal to (Player number of (Triggering player))
        • Then - Actions
          • -------- Actions --------
        • Else - Actions
There is one thing I do not understand, though: why do you convert the custom value to a string, if it's supposed to be an integer?
I'm talking about these:
String((Custom value of (Picked item),
String((Player number of (Owner of (Casting unit))​
You can just compare Custom value with Player number - no need for the string at all (it's only slowing it down).
There's two numbers in custom value:
First one shows Player number (Owner of (casting unit))
and second one shows Player number of Player number (Owner of (Targeted unit of ability being cast))



Also: "Casting Unit" is obsolete. Use "Triggering Unit" (in this case, you can even use "Triggering Player").
Yeah I know that, and still I'm not using triggering unit...
_____



Here's whole of the trigger if that would help u to understand what I want to make:
  • Voodoo doll Ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Voodoo Doll
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has an item of type Doll) Equal to False
        • Then - Actions
          • Hero - Create Doll and give it to (Casting unit)
          • Item - Set the custom value of (Last created item) to (((Player number of (Owner of (Casting unit))) x 10) + (Player number of (Owner of (Target unit of ability being cast))))
          • Trigger - Turn on Voodo doll Effect <gen>
        • Else - Actions
          • Item - Pick every item in (Playable map area) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Item-type of (Picked item)) Equal to Doll) and ((Substring((String((Custom value of (Picked item)))), 1, 1)) Equal to (String((Player number of (Owner of (Casting unit))))))
                • Then - Actions
                  • Item - Remove (Picked item)
                  • Hero - Create Doll and give it to (Casting unit)
                  • Item - Set the custom value of (Last created item) to (((Player number of (Owner of (Casting unit))) x 10) + (Player number of (Owner of (Target unit of ability being cast))))
                  • Trigger - Turn on Voodo doll Effect <gen>
                • Else - Actions
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
There's two numbers in custom value:
First one shows Player number (Owner of (casting unit))
and second one shows Player number of Player number (Owner of (Targeted unit of ability being cast))
Still no reason to use a string.
Custom value is an integer, and so is a player number. Since they're both integers, you can use an integer comparison.

The player number of the triggering player would be "Custom value / 10"
The player number of the owner of the target would be "Custom value Modulo 10".
  • If - Conditions
    • (Player number of (Triggering player)) Equal to ((Custom value of (Last created item)) / 10)
    • (Player number of (Owner of (Target unit of ability being cast))) Equal to ((Custom value of (Last created item)) mod 10)
As a rule of thumb: do not use strings, unless you really have to.


I would advise you to not use the "and" operator here, as it makes the trigger more confusing and less editable.
  • If - Conditions
  • ((Item-type of (Picked item)) Equal to Doll) and ((Substring((String((Custom value of (Picked item)))), 1, 1)) Equal to (String((Player number of (Owner of (Casting unit))))))
Yeah I know that, and still I'm not using triggering unit...
Aha... any reason for that, or just feel like being a bit wilful :p?


Now here's the problem: an item carried by a hero is not picked in an Item Group.
You can just use this:
  • Item - Remove (Item carried by (Triggering unit) of type Doll)
No item group required.
 
Level 6
Joined
Jan 29, 2010
Messages
213
Sorry I have fixed it already, thanks for spending your time helping me out.
It wasn't such a big deal just some couple of FAILS, I think it's because I spend a lot of time triggering today.
Taking a break is a good thing after all.

Big thanks for your help ap0calypse!
_______________________________


  • Voodoo doll Ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has an item of type Doll) Equal to True
        • Then - Actions
          • Item - Set the custom value of (Item carried by (Casting unit) of type Doll) to (((Player number of (Owner of (Casting unit))) x 10) + (Player number of (Owner of (Target unit of ability being cast))))
        • Else - Actions
          • Hero - Create Doll and give it to (Casting unit)
          • Item - Set the custom value of (Last created item) to (((Player number of (Owner of (Casting unit))) x 10) + (Player number of (Owner of (Target unit of ability being cast))))
        • Loop - Actions
          • Item - Pick every item in (Playable map area) and do (Actions)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Item-type of (Picked item)) Equal to Doll) and ((Substring((String((Custom value of (Picked item)))), 1, 1)) Equal to (String((Player number of (Owner of (Casting unit))))))
              • Then - Actions
                • Item - Remove (Picked item)
              • Else - Actions
Sorry I added bad trigger (the old one that wasn't working). It was missing of few details (LOL)
 
Last edited:
Level 6
Joined
Jan 29, 2010
Messages
213
Get rid of casting unit and use triggering unit instead. Also anything u use twice or more store it into a temp variable and use that as it is more efficient and faster.

Casting unit isn't used in following triggers so I don't need to set him on variables.
I'm creating triggers in my own way I don't like "triggering unit". It's easier for me to check everything when it's more accurate.
 
Status
Not open for further replies.
Top