Documente Academic
Documente Profesional
Documente Cultură
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).