![]() |
![]() |
|||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Creating Objects Intended Audience: [Printer Friendly / Syntax Highlight] object CreateItemOnObject(string sItemTemplate, object oTarget = OBJECT_SELF, int nStackSize = 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.) (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: object CreateObject (int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE) The 'nObjectType' is a constant that defines what class of object is being created. OBJECT_TYPE_CREATURE, for example, or OBJECT_TYPE_ITEM. This comes from the list of Constants in your script editor. The 'sTemplate' string is its 'blueprint resref'. Yes, I know... almost every other command uses an object's tag. This one refers to the resref, usually found under the Advanced tab of the object. NOTE: The above is a very common misconception! If you use a tag instead of a resref, it will not work! The location consists of an area, an xyz map co-ordinate (which, itself, is known as a 'vector') and a facing. It is easiest to use a GetLocation(object oObject) command to get all this information from a waypoint or another object (if you use an object such as a creature, then the spawn will occur in the nearest 'valid' location to it). If need be, you can also construct a location using Location(object oArea, vector vPosition, float fOrientation)... though that, quite frankly, is often easily avoided. The default, obviously, is for the standard appearance animation to not be used... you can opt to use it by specifying TRUE for 'bUseAppearAnimation'. So... to create a bugbear at an already-laid waypoint that has the tag "WAYPOINT1"... location spawn1 = GetLocation (GetWaypointByTag ("WAYPOINT1")); To spawn in a wizard (with the tag "wizard01") with the creation effect, facing the nearest PC... ONE LAST THING ABOUT TAGS: Remember that they are case-sensitive! If the tag reads on your creature "wizard01" don't refer to it in your scripts as "WIZARD01" or "Wizard01"... it will not acquire the creature object properly and you will get a badger spawned in. Why a badger? This was simply the 'default summon' used during testing in case an invalid object was referenced for a spawn.
|
|||||||||||||||||||||||
|
|
||
|
Multiplayer Games at Neverwinter Connections
|
||
|
Buy Premium Modules
|
||
|
5,047,091 BioWare-Benutzer:
|
||