Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC.MoveToNPCToGiveItem

From Valve Developer Community
Jump to: navigation, search
Note.png Note:  This page is automatically generated. Any changes may be overwritten

Function Description

void MoveToNPCToGiveItem(handle npc, handle item)

Give an item to another unit.

-- We create a courier and then order player 0's hero to
-- give the item it has in slot 0 to the courier. If the
-- hero does not have an item in slot 0, we give it a blink
-- dagger (in slot 0).

local hero0 = PlayerResource:GetPlayer(0):GetAssignedHero()
if hero0:GetItemInSlot(0) == nil then
  local blink = CreateItem("item_blink", nil, nil)
local callback = function (courier)
  hero0:MoveToNPCToGiveItem(courier, hero0:GetItemInSlot(0))
CreateUnitByNameAsync("npc_dota_courier", Vector(0, 0, 0), true, nil,
                      nil, DOTA_TEAM_GOODGUYS, callback)


Type Name Description
handle npc The NPC that should get the item
handle item The item that should be given to the NPC