BioWare Atari
BioWare Info BioWare Games Support Forums Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

Using Placeable Object Events

Intended Audience: For Builders
By David Gaider

[Printer Friendly / Syntax Highlight]

Like with areas, the thing to remember when writing scripts for placeable objects is that when you using 'action'-type commands (commands that return void) the default performer is the placeable object, itself. If you want the script to tell something other than the placeable object to perform a command, you need to use the AssignCommand action.
Also keep in mind that while placeable objects are capable of performing some actions (such as ActionPlayAnimation with reference to ANIMATION_PLACEABLE_*... although not all placeables open/close or activate/deactivate), telling them to do things that are inherently impossible often causes problems (ActionLockObject, ActionUnlockObject, ActionEquipItem, ActionPickUpItem... these are examples of things you should never tell a placeable object to do).

Placeable Object Event Listing

Event: OnClose, trigger: the placeable has been close (not that only placeables that can be opened or closed will fire this... like a chest or armoire), what triggered it? use GetLastClosedBy() to return the object that closed the placeable.

Example: here is an OnClose script that checks to see if its inventory is empty after it's closed... and, if so, creates 100 gold inside.

NWScript:

Event: OnDamaged, trigger: the placeable object has taken damage, what triggered it? Use GetLastDamager() to return the object that damaged the placeable. Also used here: GetTotalDamageDealt(), GetDamageDealtByType (int nDamageType), GetCurrentHitPoints(), GetMaxHitPoints().

Event: OnDeath, trigger: the object has been destroyed (playing its 'destruction' animation is automatic), what triggered it? GetLastKiller() will return the object that destroyed the placeable.

Event: OnHeartbeat, trigger: there is no trigger for the heartbeat... any script in this location fires automatically once every six seconds. Be careful not to put scripts in this area that will run constantly, as the overhead can be high.

Event: OnDisturbed, trigger: an item has either been added to or removed from the placeable's inventory, what triggered it? Use GetInventoryDisturbType(). This results in one of these constants: INVENTORY_DISTURB_TYPE_ADDED, INVENTORY_DISTURB_TYPE_REMOVED, or INVENTORY_DISTURB_TYPE_STOLEN. Also used here: GetLastDisturbed() returns the object that removed/added the item, GetInventoryDisturbItem() returns the item that was added/removed.

example: here's an OnDisturbed script that sends a UserDefinedEvent #500 signal to a wizard (with the tag "WIZARD1") if anyone removes a particular potion (with the tag "PRECIOUS_POTION") from the placeable.

NWScript:

Event: OnLock, trigger: the placeable has been locked (or relocked), what triggered it? Use GetLastLocked() to return the object that locked the placeable. Also Used Here: GetLockLockDC() returns the DC for locking the placeable. **NOTE** I've had a few reports that this event may not be working.

Event: OnPhysicalAttacked, trigger: the placeable has been physically attacked (but not necessarily damaged), what triggered it? Use GetLastAttacker().

Event: OnOpen, trigger: the placeable object has been opened (for those placeable objects that can be opened and have their 'Has Inventory' box checked), what triggered it? Use GetLastOpenedBy().

Event: OnSpellCastAt, trigger: a spell has been cast at the placeable, what triggered it? Use GetLastSpellCaster(). Also used here: GetLastSpell() will return the constant of the spell used (SPELL_*), GetLastSpellHarmful() will return TRUE or FALSE depending on whether or not the last spell cast was marked hostile.

Event: OnUnlock, trigger: the placeable has been unlocked, what triggered it? Use GetLastUnlocked() to return the object that unlocked the placeable. **NOTE** I've had a few reports that this event may not be working.

Event: OnUsed, trigger: if a placeable object has its 'Useable' box checked, then clicking on the object sets off this event, what triggered it? Use GetLastUsedBy().

example: a script for a placeable object that heals whoever used it.

NWScript:

Event: OnUserDefined, trigger: this event will only occur if someone specifically uses SignalEvent to send a UserDefinedEvent to the placeable object.

 

 

BioWare Store
Neverwinter Nights 2 Forums
Hide/Show

English
Deutsch
Français
Español
Italiano

Hide/Show

View Latest Screenshots 

View Latest Screenshots
Hide/Show

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Current time is: (set time)
Sun, 08 November 2009 12:47AM

Hide/Show

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

Hide/Show

4,825,327 BioWare Users:
  219 Logged In
  11 Hidden
  1355 Guests

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

446 Registered Guilds

8,714,744 posts in forums

Newest Forum Topics:
1. FaceFX problem (Dragon Age Toolset Forum)

2. Last Will and Testament Quest (Dragon Age: Origins Story and Plot (Spoilers) Forum)

3. Preorder codes good on different... (Dragon Age: Origins Technical Assistance (Self Help))

4. Multiplayer game anyone? (Baldur's Gate II: SoA and ToB General Discussion)

5. Weapon/ Damage effect on enemy? (Dragon Age: Origins General Discussion)