BioWare Atari
BioWare Info BioWare Spiele Support Foren Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

Making Unique Items

Intended Audience: For Builders
By David Gaider

[Printer Friendly / Syntax Highlight]

How does one script their own items that go beyond the standard item effects... how do you make an effect conditional, for instance? How would I script a Wand of Wonder or a talking sword?

Well, the first thing to realize is that, unlike other objects and creatures in the game, items do not have their own scripts. You do not pull up an item's properties and specify which scripts it uses... it can't use any.

The way that you can script things that items do has to be on the module level. In the Module Properties, you have three 'events' which affect items. When these events occur, it prompts the module to run whatever scripts are tied to these items.
Two of these events are OnAcquireItem and OnUnAcquireItem. This means every time an item is picked up or dropped, an event is 'fired' which starts the appropriate script. If no script is there, nothing happens.
So if I want to set a certain variable when a particular sword (that has the tag "SWORD01") is picked up, say, I could put this script in the OnAcquireItem section of the module:

NWScript:

That doesn't do much for scripting your own item properties, however, does it? For that, you need to take advantage of the third module event: OnActivateItem().

Activating an item requires a specific 'activation' event. When you make an item, you can assign to it a 'Cast Spell' property... and two of the choices will be Unique Power and Unique Power: Self Only. The difference between these is that the second simply triggers the 'OnActivateItem' event... the first requires you to target the Unique Power, first.

This 'Unique Power' shows up on the radial menu of the item just as any other ability would. If you wanted to specify what that ability was to the user, you could include it in the item's description (of which there is an 'identified' as well as an 'unidentified' description, should you wish to use both).

When writing the script to place in OnActivateItem(), there are only a few references which you will need to keep in mind:

object GetItemActivated()
This returns the item that caused the last OnActivateItem() event.

object GetItemActivatedTarget()
This returns the target of the Unique Power, if it was targeted at a specific object.

location GetItemActivatedTargetLocation()
This returns the target of the Unique Power, if it was targeted at a location rather than a specific object.

object GetItemActivator()
This returns the creature object of whoever activated the item... a bit handier than going through the whole GetItemPossessedBy rigamarole.

And that's all you need. With these, you can script as many activated properties for as many items as you wish. Keep in mind, of course, that these scripts are module-specific. If you take the item to another module that does not have that script (or another that looks for that item) in their OnActivateItem(), then nothing will happen.

NOTE: there is currently a bug with OnActivateItem with regards to single-use items (and this also applies to items on their last charge). When an item is used up, it disappears... the event still fires, but all of the commands such as GetItemActivated and such return an invalid object (because the item in question no longer exists).

 

 

Mass Effect Galaxy
Neverwinter Nights 2 Forums
Anzeigen/Verbergen

English
Deutsch
Français
Español
Italiano

Anzeigen/Verbergen

Neueste Bildschirmfotos anzeigen 

Neueste Bildschirmfotos anzeigen
Anzeigen/Verbergen

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Aktuelle Uhrzeit: (Zeit einstellen)
So, 22 November 2009 03:04

Anzeigen/Verbergen

Buy Premium Modules

Top NWN: HotU Modules:
1. Good vs Evil III
2. More...

Top NWN: SoU Modules:
1. Good vs Evil III
2. More...

Top CEP Modules:
1. The Lord of Terror The Diablo Campa...
2. More...

Top Modules - NWVault:
1. Hall of Fame
2. More...

Total Modules: 4423

Anzeigen/Verbergen

5,049,964 BioWare-Benutzer:
  52 Eingeloggt
  0 Verborgen
  209 Gäste

1318 Playing Online
  100% NWN
  100% NWN: SoU
  100% NWN: HotU

447 Registered Guilds

8,768,603 Einträge in den Foren

Neueste Themen in den Foren:
1. 2 newb problems: Lever puzzle, a... (NWN2: Builders - NWN2 Scripting)

2. Vorcha + Krogans o_0 (Mass Effect 2 General Discussion (No Spoilers Allowed))

3. Video games? (NWN 1: General Discussion (No Spoilers Allowed))

4. How to Change the Death Message (NWN 1: Toolset)

5. Toolset work with Vista? (NWN2: Builders - NWN2 Toolset)