• 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.

[Solved] Transfer Dropped item for non-hero to townhall building

Status
Not open for further replies.
Level 2
Joined
Nov 17, 2017
Messages
8
Hello, a week ago I started mending in the world editor, I am modifying an original map of the game, copy a dota fusion items system, improved the attack of the creeps and defense towers, increased the gold of the mines, so the normal game longer, and with everything stronger you need to upgrade and make the normal units use items and thus increase the strength of your army, also put inventory in the houses of buildings to store the excess of items collected, until then, okay, the problem is the items lost when the normal units die, I'm trying to create a trigger that takes the items that the non-hero unit drop and move to the inventories of the base building

Trigger.JPG Here my try
 
Last edited by a moderator:
Level 19
Joined
Oct 17, 2012
Messages
860
JASS:
function SwapInventory takes unit u, unit un returns nothing
    local integer i = 0
 
    loop
        exitwhen i == 6
 
        call UnitAddItemToSlotById(un, GetItemTypeId(UnitItemInSlot(u, i)), i)
 
        set i = i + 1
    endloop
endfunction
I use this simple piece of code for easy swapping. You don't even need to drop the items, and you shouldn't with this as it would not work.

Note: The unit un is the one getting the items.
JASS:
Custom script: call SwapInventory(GetTriggerUnit(), udg_YourUnitVariable))
 
Last edited:
Level 2
Joined
Nov 17, 2017
Messages
8
I'm very happy with your help, you did all the work yourself thank you very much, but I put an update for the units with inventory to use the items, I want normal units to use orbs and spell book, this is happening, but I want it when that unit dies in battle and leaves the items on the floor of the enemy base, I want these items to be transferred to the inventory of the constructions of my base
 
Status
Not open for further replies.
Top