HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item Count

01-21-2006, 02:30 AM#1
SortOf
How do i do Count all items of type? i cant seem to find it.
01-21-2006, 02:49 AM#2
Vexorian
where? inside a unit's inventory or in the whole map?
01-21-2006, 02:54 AM#3
johnfn
Trigger:
For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of (Item carried by (Hero) in slot (Integer A))) Equal to Whatever Item
Collapse Then - Actions
itemsCarried = (itemsCarries + 1)
Else - Actions

That's one way of doing it, not sure if it's the best though.
01-21-2006, 05:20 AM#4
SortOf
Whole Map Including Unit Inventory
01-21-2006, 11:09 AM#5
Vexorian
why would you want to do that?

And it is like this:
Trigger:
set count=0
Collapse item - pick every item in (playable map area) and do actions
Collapse loop - actions
set count=count+1
-- next has a memory leak --
Collapse unit group - pick every unit in (Units in (playable map area) and do actions
Collapse loop - actions
Collapse for each integer A from 1 to (Inventory size of (picked unit) ) do actions
Collapse loop - actions
Collapse if (Item in slot (integer A) of (picked unit) not equal to (No Item) then
count=count+1
And count will have the count of items
01-22-2006, 12:46 AM#6
PerfectlyInsane
I guess to reduce memory leaks your better doing this way


a item is created

Add 1 to the itemcount



You also need a custom trigger to detect when items are used. For this to work you need to change the properties of all you items to Perishable (NO)

What happens is, lets say an item has 3 charges.. if you use up three charges the item will have 0 charges but remain in your inventory.

A trigger then removes the item with 0 Charges from game and -1 from itemcount. I suggest first test whether or True permanent items like a ring of protections works properly

A trigger that detects when an item is pawned.
01-22-2006, 12:53 AM#7
Vexorian
seems you are confusing memory leaks with process duration
01-23-2006, 02:40 AM#8
SortOf
Following your insructions Vex it seems to work
However it also caused alot of Compouding lag

i use the On ground and in inventory Numbers as 2 differnt numbers
and that seemed to Resolve that, wondering - over a long period(Guess i could just let the map run for a hour and see for my self) of time
would the lag come back?

Also lets say i have a bunch of Buildings Scatterd threwout the man. theres are units whos Position is Undeterminded and i need these units to walk to The closest one of these Buildings .(makeing a new thred for this)

(thank you)
01-23-2006, 12:44 PM#9
Vexorian
Well it depends. Are you calling that a lot of times, like in a periodic trigger?

If so Why would you do that? And there is a memory leak , before the pick every unit in unit group thing use this:

Trigger:
Custom Script: set bj_wantDestroyGroup=true