Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC.MoveToNPCToGiveItem: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Dota_Lebot push: Updated Page)
 
m (clean up, added deadend tag)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Dead end|date=January 2024}}
{{Note | This page is automatically generated.  Any changes may be overwritten}}
{{Note | This page is automatically generated.  Any changes may be overwritten}}


== Function Description ==
== Function Description ==


 
''' void MoveToNPCToGiveItem(handle ''npc'', handle ''item'') '''
''' void MoveToNPCToGiveItem(handle '''', handle '''') '''


''Give an item to another unit.''
''Give an item to another unit.''


;Example
<source lang="lua">
-- 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)


</source>
== Parameters ==
== Parameters ==
{| class="standard-table" style="width: 50%;"
{| class="standard-table" style="width: 50%;"
Line 17: Line 36:
|-
|-
| handle
| handle
|  
| npc
| No Description Set
| The NPC that should get the item
|-
|-
| handle
| handle
|  
| item
| No Description Set
| The item that should be given to the NPC
|}
|}
[[Category:Dota2Function]]
[[Category:CDOTA_BaseNPC]]

Latest revision as of 09:16, 21 January 2024

Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
Note.pngNote: This page is automatically generated. Any changes may be overwritten

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