Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC.MoveToNPCToGiveItem
< Dota 2 Workshop Tools | Scripting | API
Jump to navigation
Jump to search

This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024


January 2024

Function Description
void MoveToNPCToGiveItem(handle npc, handle item)
Give an item to another unit.
- Example
-- 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)
blink:SetPurchaseTime(0)
hero0:AddItem(blink)
end
local callback = function (courier)
hero0:MoveToNPCToGiveItem(courier, hero0:GetItemInSlot(0))
end
CreateUnitByNameAsync("npc_dota_courier", Vector(0, 0, 0), true, nil,
nil, DOTA_TEAM_GOODGUYS, callback)
Parameters
Type | Name | Description |
---|---|---|
handle | npc | The NPC that should get the item |
handle | item | The item that should be given to the NPC |