Beruflich Dokumente
Kultur Dokumente
Intended Audience:
By David Gaider
[Printer Friendly / Syntax Highlight]
object CreateItemOnObject(string sItemTemplate, object oTarget = OBJECT_SELF, int
nStackSize = 1)
//In NWN2 it has two additional possible parameters:
object CreateItemOnObject(string sItemTemplate, object
oTarget=OBJECT_SELF, int nStackSize=1, string sNewTag="", int
bDisplayFeedback=1);
This creates an item (with the tag of the 'sItemTemplate') in the oTarget object's
inventory. We use this often when items are 'given' to a PC... or if, say, an NPC is
supposed to have an object on them only at certain times.
If I'm in dialogue and the NPC rewards the PC he's talking to with a regular longsword, I
would put a script with this line in the 'Actions Taken' section:
CreateItemOnObject ("NW_WSWLS001", GetPCSpeaker());
If I want to put 12 regular arrows into a chest that has the tag "CHEST05":
CreateItemOnObject ("NW_WAMAR001", GetObjectByTag ("CHEST05"), 12);
(NOTE: If you use ActionGiveItem to have an NPC give an inventory item to the PC,
that item must actually exist in the NPC's inventory in order for the action to complete.
ActionGiveItem will transfer the item to the PC's inventory... CreateItemOnObject
creates an entirely new one there.) //I think this isnt the case in NWN2 (im almost
completely sure this isnt the case in NWN2). In NWN2 NPC can give an item to PC
with ActionGiveItem, and he doesnt have to have it in his inventory at all.
(2nd NOTE: I mention that the sItemTemplate used in the command is the item's 'tag'...
this is true ONLY for the standard items that come with the game. Sorry, my bad: this is
all I'm used to using with this command. If you are trying to use the command with
custom items, you must use the blueprint resref for the item... not the tag.)
The 'CreateObject' command is a little bit different. It actually creates the object on the
map... this is often referred to as 'spawning'. The object could be a creature or an item. It's
structure is as follows: