• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] how can i make a unit drop an item before being removed

Status
Not open for further replies.
If you want that unit to drop all items before it is removed use an integer loop and loop through the units item slots and drop picked item. ( as said above.)

  • Set tempUnit = your unit.
  • Set tempLocation = (Position of tempUnit)
  • For each (Integer tempInteger) from 1 to 6, do (Actions)
    • Loop - Actions
      • Unit - Order tempUnit to drop (Item carried by tempUnit in slot tempInteger) at tempLocation
  • Custom script: call RemoveLocation( udg_tempLocation)
  • // Then remove the unit.
 
it's the same but you just stop the loop when you find any item.
  • (Item carried by (Triggering unit) in slot 1) Not equal to No item
so if it isn't "No Item" it means there is some item in that slot, you drop it and stop loop.

You shouldn't stop the loop when no item is found. You can have items in slot 2 through 6 But if you don't have item in slot one it will stop the loop.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
I think there is a option in Object Editor to make unit drop items on death so you could instead of removing the unit, kill it and then remove it in trigger with Unit Dies(maybe store the unit in hashtable if multiple unit types can have this ability) and when the unit dies it should drop all items

this may however be more compicated, but maybe more reliable, because Deathismyfriend's solutions most likely overrides the units channel order with drop event order and if you have this hooked to check event, it may not work(if it is fixed time, it however will)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I misread. That only drops one item then. I believe he wants all items that unit has to be dropped though.
I don't know, he didn't really specify it... though the method will be still the same, except you won't stop the loop :)

I think there is a option in Object Editor to make unit drop items on death ...
... most likely overrides the units channel order with drop event order and if you have this hooked to check event, it may not work(if it is fixed time, it however will)
I just checked it with a trigger that fires upon "Unit starts the effect of an ability" - it doesn't disrupt current order when hero dropped all his items, even when the dropping is delayed by 1 second wait.
 
No, because you used an order, which will have no effect since the unit gets removed the same moment.

Elseway yeah, quite similar.

I forgot about that lol.

@TO
Use this one.
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set tempUnit = Blood Mage 0000 <gen>
      • Set tempLocation = (Position of tempUnit)
      • For each (Integer tempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Create (Item-type of (Item carried by tempUnit in slot tempInteger)) at tempLocation
      • Custom script: call RemoveLocation( udg_tempLocation)
      • Unit - Remove tempUnit from the game
      • Set tempUnit = No unit
 

Attachments

  • test.w3x
    16.7 KB · Views: 48
Here you go. This also loops through all items in each slot. Just pick up the items then press esc to watch this work.

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set tempUnit = Blood Mage 0000 <gen>
      • Set tempLocation = (Position of tempUnit)
      • Unit - Create 1 Archmage for Player 1 (Red) at tempLocation facing (Facing of tempUnit) degrees
      • Set tempUnit2 = (Last created unit)
      • For each (Integer tempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give (Item carried by tempUnit in slot tempInteger) to tempUnit2
      • Unit - Remove tempUnit from the game
      • Custom script: call SetUnitX( udg_tempUnit2, GetLocationX( udg_tempLocation))
      • Custom script: call SetUnitY( udg_tempUnit2, GetLocationY( udg_tempLocation))
      • Custom script: call RemoveLocation( udg_tempLocation)
      • Set tempUnit = No unit
      • Set tempUnit2 = No unit
 

Attachments

  • test.w3x
    16.9 KB · Views: 51
Level 21
Joined
Mar 2, 2010
Messages
3,069
that test map doesnt show what the trigger do directly. the new unit isnt present in the first place either. i dont dare post trigger anymore because people get angry at me for not using tags but i will try to explain how the triggers i have work. the unit activates a spell that replaces the unit with a metapod and then the metapod gets replaced after a wait time.(15 units can do that at the same time.)
 
that test map doesnt show what the trigger do directly. the new unit isnt present in the first place either. i dont dare post trigger anymore because people get angry at me for not using tags but i will try to explain how the triggers i have work. the unit activates a spell that replaces the unit with a metapod and then the metapod gets replaced after a wait time.(15 units can do that at the same time.)

The test map does show what it does do as i have said above and it shows blood mage replaced with the other unit and he has same items.

@dimf - Creating is also unnecessary when you can just use MOVE.

moving item moves the item to a place on the map. You would then need to order the new unit to pickup the item which can be stopped through other triggers.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
you should have told me how to activate the trigger in the first place. that trigger however transferes items from 1 unit to another but what i need is something that transferres items from 1 unit to the third in a replacement trigger.(1 is the original unit, 2 is the metapod and 3 is the final unit.)
 
Look in the first line.....

Here you go. This also loops through all items in each slot. Just pick up the items then press esc to watch this work.

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set tempUnit = Blood Mage 0000 <gen>
      • Set tempLocation = (Position of tempUnit)
      • Unit - Create 1 Archmage for Player 1 (Red) at tempLocation facing (Facing of tempUnit) degrees
      • Set tempUnit2 = (Last created unit)
      • For each (Integer tempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give (Item carried by tempUnit in slot tempInteger) to tempUnit2
      • Unit - Remove tempUnit from the game
      • Custom script: call SetUnitX( udg_tempUnit2, GetLocationX( udg_tempLocation))
      • Custom script: call SetUnitY( udg_tempUnit2, GetLocationY( udg_tempLocation))
      • Custom script: call RemoveLocation( udg_tempLocation)
      • Set tempUnit = No unit
      • Set tempUnit2 = No unit
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
the way the chain works is that the unit in the middle of the chain cant have any items so the item carried by unit 1 need to be transferred to unit 3 somehow. there is also going to be a cancel button to stop the process at a later date so, the item need to somehow be stored so that it can be recalled later. each unit can only carry one item however.
 
  • Set MetaMorph_Index = MetaMorph_Index + 1
  • Set MetaMorph_ItemType = (Item-Type of (Item carried by (Hero) in slot 1))
  • Set MetaMorph_Pod = (Last created unit)
Then for the entering unit(if ever the third unit enters playable map area).
For this, use a unit dies event.
  • For each Integer (A) from 1 to MetaMorph_Index, do (Actions)
  • If/Then/Else - Multiple Conditions
    • If - Conditions
      • (Triggering Unit) equal to MetaMorph_Pod[A]
    • Then - Actions
    • Create third unit
    • Set MetaMorph_Pod[A] = MetaMorph_Pod[MetaMorph_Index]
    • Set MetaMorph_ItemType[A] = MetaMorph_ItemType[MetaMorph_Index]
    • Set MetaMorph_Index = (MetaMorph_Index - 1)
    • Else - Actions
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
you should have studied my earlier posts more closely but since you refuse i will write it again. the unit activates a spell that gets it replaced by a metapod, the metapod is later replaced by the unit indicated by the spell. units that dont require research uses charge gold and lumber, one unit per building uses destroyer form and the rest uses channel.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
you are welcome to take a look at the actual map which i posted in this topic earlier but i can also try to explain. the unit that becomes the metapod is replaced through a replace trigger that reacts to a spell. the amount of time the metapod is present is based what spell is used because each activates a different trigger. when the metapod have been present long enough it becomes a different unit.(also by using a replace trigger.) the metapod itself doesnt have an inventory but the unit it becomes and the unit that becomes a metapod might have.
 
Status
Not open for further replies.
Top