• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Issue order to pick item up freezes the unit

Status
Not open for further replies.
Level 4
Joined
Dec 25, 2012
Messages
66
Here is the simple trigger that makes a hero drop random item upon being hit by Rogue(non-hero) with Steals items ability:

Event - A unit is attacked
Condition - level of Steals Items for Attacking unit is 1
- Attacked unit is hero equals 1
Action - Hero - drop (Item carried by Attacked unit in slot (Random integer from 1 to 6)) from Attacked unit
- Unit - Order Attacking unit to Right click Last dropped item

However, Attacking unit (Rogue) is frozen in place after the item has been dropped from the hero. Rogue doesn't even fight back, just stands idle. What is the cause of this behaviour? Thankyou.
 
Level 8
Joined
Jan 28, 2016
Messages
486
Not sure why that happens but does your Rogue have an inventory? You stated it's a non-hero unit and most normal units don't have an inventory so if you try and make it pick up an item that it can't hold, the poor thing will probably have a mental breakdown and just stand there. I can't test this at the moment and just want to make sure that this isn't the problem.

With respect to the trigger, you might want to use a DDS to avoid abusing the "Unit is attacked" event. Also you can use trigger tags to make the triggers you post easier to read and look sexy! Here's a link.
 
Level 4
Joined
Dec 25, 2012
Messages
66
Oh, forgot to mention, the Rogue has Carry bag ability that allows him to carry 2 items, so that is not an issue.

More so, I found out, that adding Wait for 0.5 seconds (realtime) the following way fixes the problem:

Event - A unit is attacked
Condition - level of Steals Items for Attacking unit is 1
- Attacked unit is hero equals 1
Action - Hero - drop (Item carried by Attacked unit in slot (Random integer from 1 to 6)) from Attacked unit
- Wait for 0.5 seconds
- Unit - Order Attacking unit to Right click Last dropped item

However, I'd REALLY like to know how to make it work without the Wait command, as Wait tends to break trigger when it is run for multiple units in a short period of time.

P.S:I have also written a trigger that displays the name of the Stealing unit (Attacking unit) and Last dropped item, and indeed, these are detected correctly.
 
Last edited:
Level 4
Joined
Dec 25, 2012
Messages
66
Things get more weird. Take this simple trigger:

Event - A unit is attacked
Condition - none
Action - Order Attacking unit to Move to (Center of playable map area)

It has the same result - it freezes the attacking unit (the one being issued the move order). There are no other triggers active - I've created an absolutely new map.
 
Level 4
Joined
Dec 25, 2012
Messages
66
Horray, the cure has been found. Well, it's more of a painkiller, but it does the job. However, I'd still like to know why the initial trigger freezes the unit...

Solution:
Event - A unit is attacked
Condition - level of Steals Items for Attacking unit is 1
- Attacked unit is hero equals 1
Action - Hero - drop (Item carried by Attacked unit in slot (Random integer from 1 to 6)) from Attacked unit
- Unit - Order Attacking unit to Right click Last dropped item
- Unit - Pause Attacking unit
- Unit - Unpause Attacking unit


On the side, is there any way to check if a particular item in hero's inventory is droppable/undroppable?
 
Last edited:
Level 4
Joined
Sep 13, 2014
Messages
106
Two different (better?) solutions:

  • Hero - Drop the item from slot (Random integer number between 1 and 6) of (Attacked unit)
  • Custom script: call UnitAddItem( GetAttacker() , bj_lastRemovedItem)
  • Hero - Give (Item carried by (Attacked unit) in slot (Random integer number between 1 and 6)) to (Attacking unit)
The following triggers will only drop the item if it is undroppable, however they will interupt the unit's order queue:

  • Set randomItem = (Item carried by (Attacked unit) in slot (Random integer number between 1 and 6))
  • Unit - Order (Attacked unit) to drop randomItem at (Position of (Attacked unit))
  • Custom script: call UnitAddItem( GetAttacker() , udg_randomItem)
  • Unit - Order (Attacked unit) to give (Item carried by (Attacked unit) in slot (Random integer number between 1 and 6)) to (Attacking unit)
You can test for if an item is undroppable in a similar way.

Presumably the reason why the unit gets stuck like that is that the item is not in an ordinary state, because it is dropped but has only just been dropped this frame. Warcraft 3 is just not equipped to handle that, and so the unit gets stuck.

Also note that all solutions except the last one will give the item no matter how far the units are away from each other, so your solution may be better in that respect.

Also note that the code
  • Unit - A unit Is attacked
runs whenever the animation for an attack starts, and so it would be possible for people to steal items rapidly by constantly cancelling and re-initiating the attack animation.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Like ZerGreenOne said, the dropped item is not really considered as dropped instantly. You would neet to run a timer with 0.00 second expiration time before being able to access the item properly.

You could check if there actually is an item in the slot, item in slot x not equal to no item.
 
Status
Not open for further replies.
Top