One player item pickup

Status
Not open for further replies.
Level 5
Joined
Jan 15, 2018
Messages
129
The goal is for only player "turquoise" to be able to pick up an item. However testing it out and other players could pick it up. Any ideas on what im doing wrong?

  • item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Picked item)) Equal to Mech Suit Plans Part I
      • (Owner of (Triggering unit)) Not equal to Player 15 (Turquoise)
    • Actions
      • Set TempPoint1 = (Center of Mechsuit1 <gen>)
      • Unit - Order (Triggering unit) to drop Mech Suit Plans Part I 0748 <gen> at TempPoint1
 
Level 11
Joined
Jul 4, 2016
Messages
627
It might be possible that the order happens before the unit actually has the item in his inventory. Try putting a turn off and a turn on.
 
Level 13
Joined
May 10, 2009
Messages
868
Picked Item should only be used within item enumeration:
  • Item - Pick every item in (Playable map area) and do (Actions)
    • Loop - Actions
      • Item - Hide (Picked item)
  • -------- Or --------
  • Item - Pick every item in (Playable map area) and do (Item - Set life of (Picked item) to 75.00)
Instead, use (Item being manipulated).

Also, you are ordering the unit to drop a specific pre-placed item, which might not be what you want. I'm assuming you want to make everyone, but player 15, drop any item of that type. Additionally, that action will make the unit walk towards a specific point, and then drop the item, which might have a negative impact because players could issue orders to the unit before the item be dropped.
 
Level 5
Joined
Jan 15, 2018
Messages
129
So i switched it to item being manipulated and it it still doesn't work, so i switched to an item instead of a consumable and it seemed to work at first, but then like you said the item can be picked up and then walked away. How can i make it so it is dropped instantly, not even entering the heroes inventory? What would you recommend?
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
Use the GUI function "Item - Move (Instantly)" to its own position. Though, this will inevitably make the item be in a unit's inventory, and be dropped afterwards, which will fire some events (pick item up / drop it).

EDIT: In order to avoid that behavior, you'll probably have to use "unit - issue order targeting objects" event, and detect if the order is smart, and the target is that specific item type. Then, order the unit to stop. If it doesn't work right away, then pause the unit, stop it, and unpause it.
 
Last edited:
Level 2
Joined
Jan 31, 2019
Messages
27
You have to use the gui equivalent of UnitRemoveItem(unit, itm). This removes it from the units inventory and drops it under them. Either that, or detect the order and issue an immediate stop.
 
Level 5
Joined
Jan 15, 2018
Messages
129
  • itemtry2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Mech Suit Part 1
      • (Owner of (Triggering unit)) Not equal to Player 15 (Turquoise)
    • Actions
      • Item - Move Mech Suit Part 1 0940 <gen> to (Position of (Last created item))
 
hey, there's solution for you
  • ord
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Item-type of (Target item of issued order)) Equal to Ghost Key
      • (Issued order) Equal to (Order(smart))
      • (Owner of (Ordered unit)) Not equal to Player 2 (Blue)
    • Actions
      • Game - Display to (All players) the text: Only Player2 can pi...
      • Unit Group - Add (Ordered unit) to temp_group
      • Countdown Timer - Start temp_timer as a One-shot timer that will expire in 0.00 seconds
  • timer
    • Events
      • Time - temp_timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Stop
 

Attachments

  • ragnar9.w3x
    17.9 KB · Views: 16
Level 2
Joined
Jan 31, 2019
Messages
27
hey, there's solution for you
  • ord
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Item-type of (Target item of issued order)) Equal to Ghost Key
      • (Issued order) Equal to (Order(smart))
      • (Owner of (Ordered unit)) Not equal to Player 2 (Blue)
    • Actions
      • Game - Display to (All players) the text: Only Player2 can pi...
      • Unit Group - Add (Ordered unit) to temp_group
      • Countdown Timer - Start temp_timer as a One-shot timer that will expire in 0.00 seconds
  • timer
    • Events
      • Time - temp_timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Stop
Just interested, did that actually require the timer trick? Im pretty sure I've overridden orders without it
 

Wrda

Spell Reviewer
Level 27
Joined
Nov 18, 2012
Messages
1,951
This is so simple yet you overcomplicate it unnecessarily...
First of all, here's an action to set an item's owner, use it.
  • itemtry2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Mech Suit Part 1
      • (Owner of (Triggering unit)) Not equal to Player 15 (Turquoise)
    • Actions
      • Item - Move Mech Suit Part 1 0940 <gen> to (Position of (Last created item))
Should be Position of (Triggering unit) not last created item...
The solution of ZiBitheWand3r3r fails if the unit is really close to the item.
 
JASS:
function Trig_esc_Actions takes nothing returns nothing
    local unit u=gg_unit_Hgam_0001
    local item itm=gg_item_kygh_0004
   
    call SetUnitX(u, GetWidgetX(itm))
    call SetUnitY(u, GetWidgetY(itm))
    call TriggerSleepAction(1.00)
    call IssueTargetOrder(u, "smart", itm)
   
endfunction
//============================================
function InitTrig_esc takes nothing returns nothing
    set gg_trg_esc = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_esc, Player(0) )
    call TriggerAddAction( gg_trg_esc, function Trig_esc_Actions )
endfunction
@Wrda , unit cannot be closed then in above example and it still cannot pick up an item, test it yourself.
 
Level 5
Joined
Jan 15, 2018
Messages
129
Ok so i got it to work, but it leaks. any idea how i can stop or delete the trigger once the item is picked up?

  • itemtry2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Mech Suit Part 1
      • (Owner of (Triggering unit)) Not equal to Player 15 (Turquoise)
    • Actions
      • Set TempPoint1 = (Center of Mechsuit1 <gen>)
      • Item - Move Mech Suit Part 1 0940 <gen> to TempPoint1
 
Status
Not open for further replies.
Top