• 🏆 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] Count items in heros inventory of type possible?

Status
Not open for further replies.
Level 4
Joined
Sep 26, 2005
Messages
40
I've been working on this for hours now. i am trying to figure out if there is a way to count the number of items owned by a unit.. not the charges. the amount of individual items.

the only way i've been able to figure out is dropping the items from the hero and then doing a pick every item in playable map area.. then giving it back to the hero but i dont like the result because i need this check performed every single time the hero attacks.. and it's a pain if item slot swapping mid-attack.

there has got to be a way to simply count how many of that type is owned.

or maybe even some way to perform an item slot check in a loop where each time conditions check the type of item i could have a var +1 itself.

so far this is what i got and i dont like it.


---------------------------------------
Caustic Trident
Events
Unit - A unit Is attacked
Conditions
((Attacking unit) has an item of type ITEM) Equal to True
((Owner of (Attacked unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
Actions
Set ItemVarInt = 0
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Hero - Drop (Item carried by (Attacking unit) of type ITEM) from (Attacking unit)
Item - Pick every item in (Playable map area) and do (Actions)
Loop - Actions
Hero - Give (Picked item) to (Attacking unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Attacking unit) has an item of type (Item-type of (Picked item))) Equal to True
((Attacking unit) has (Picked item)) Equal to True
(Item-type of (Picked item)) Equal to ITEM
Then - Actions
Set ItemVarInt = (ItemVarInt + 1)
Else - Actions
Do nothing

-----------------------------------------------------------
 
Level 2
Joined
Dec 31, 2006
Messages
16
here is it

Not sure about the config of the actions but this should look like that:

Events:
- something happen(I don't know what you want for an event)

Conditions:
- Hero has item in inventory slot 1 or 2 or 3 or 4 or 5 or 6

Actions:
-Set variable(integer) = number of items carried by hero
- If-Then-Else:
-If - Hero has 1 item
-Then - something
-Else - If-Then-Else:
-If - Hero has 2 items
-Then - Something
-Else - If-Then-Else:
bla bla bla....

u know
 
Level 11
Joined
Jul 12, 2005
Messages
764
Much easier:

Code:
For each (Integer A) from 1 to 6, do (Actions)
   Loop - Actions
       If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                 (Item-type of (Item carried by <Unit> in slot (Integer A))) Equal to <Item-type>
            Then - Actions
                 Set ItemNum = (ItemNum + 1)
            Else - Actions
 
Status
Not open for further replies.
Top