Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC.MoveToNPCToGiveItem: Difference between revisions
< Dota 2 Workshop Tools | Scripting | API
Jump to navigation
Jump to search
RoyAwesome (talk | contribs) (Dota_Lebot push: Updated Page) |
RoyAwesome (talk | contribs) (Dota_Lebot push: Updated Page) |
||
Line 19: | Line 19: | ||
-- dagger (in slot 0). | -- dagger (in slot 0). | ||
local | local hero0 = PlayerResource:GetPlayer(0):GetAssignedHero() | ||
if hero0:GetItemInSlot(0) == nil then | |||
local blink = CreateItem("item_blink", nil, nil) | local blink = CreateItem("item_blink", nil, nil) | ||
blink:SetPurchaseTime(0) | blink:SetPurchaseTime(0) | ||
hero0:AddItem(blink) | |||
end | end | ||
local callback = function (courier) | local callback = function (courier) | ||
hero0:MoveToNPCToGiveItem(courier, hero0:GetItemInSlot(0)) | |||
end | end | ||
CreateUnitByNameAsync("npc_dota_courier", Vector(0, 0, 0), true, nil, | CreateUnitByNameAsync("npc_dota_courier", Vector(0, 0, 0), true, nil, |
Revision as of 07:12, 18 September 2014

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 |