Item acquired location

E

Ecstats

Guest
Greetings

I need a way to figure out the location of any items that are picked up. It seems I can't use the item is in region thingie; I guess their position is lost when they are acquired. Also I can't use the position of the unit acquiring the item since it may not be the same (well unless I change the pickup item range but that will bring other problems).
Then I thought of using a trigger with unit is ordered to an object type and condition order equal to "smart" (just why is 'smart' the orderstring for picking up items?) and saving the items location in an array. However I'm not sure this would work and I wonder if there's another, easier, way to do it.
 

oorosco

New Member
Reaction score
23
Here you go

Code:
Untitled Trigger 001
    Events
        Map initialization
    Conditions
    Actions
        Item - Pick every item in (Playable map area) and do (Actions)
            Loop - Actions
                Set array_num = (array_num + 1)
                Set item_position[array_num] = (Position of (Picked item))
                Set item_corresponding_to_points[array_num] = (Picked item)


Code:
pickign item up
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 500, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        item_corresponding_to_points[(Integer A)] Equal to (Item being manipulated)
                    Then - Actions
                        -------- Now you got the coordinates  stored etc. --------
                    Else - Actions
 
E

Ecstats

Guest
Hmm ah yeah that would work out pretty well. I could optimize it a bit by instead of looping the full array I simply loop up until array_num. Then you just sort it whenever an item is removed. Thanks!
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Set item_corresponding_to_points[array_num] = (Picked item)

Well, if instead you used
Item - Set custom value of (Picked item) to array_num

It would remove the loop in the second trigger as you could simply use
item_position[Custom value of (Item being manipulated)]
 
E

Ecstats

Guest
That would be faster yes. However as you can only set one custom value for every item/unit I tend to save that value until I really need it. If I still don't use item custom values for anything else when I complete my map I'll change it though. Thanks.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Well, using the custom value as index into some array works for several arrays too.

Set Owner[Custom value of <item>] = Player number of (Owner of (Hero manipulating item))
Set CustomValue[Custom value of <item>] = 42

Just make sure every item has a unique value, and that you never go over 8191 :p
 

Xenoche

Member
Reaction score
18
I guess their position is lost when they are acquired.

The position of the item is not lost when using the 'acquired' event. I use this trigger in my map (this is simplified, obviously add conditions to your liking) to stop people from picking up items, when they try to pick it up it doesn't move at all. This fact may or may not help you with your problem, but I found it useful.;)
Code:
DropKey
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        Set TEMP_POINT = (Position of (Item being manipulated))
        Item - Move (Item being manipulated) to TEMP_POINT
        Custom script:   call RemoveLocation (udg_TEMP_POINT)
 
E

Ecstats

Guest
The position of the item is not lost when using the 'acquired' event.

I tested this out and you seem to be partially right. It works when just putting that code in, however if you make a check that the item being manipulated should be in a specific region, it does NOT work. Which I find strange.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top