Difference between revisions of "OnPlayerUnequipItem"

From NWN Lexicon
Jump to: navigation, search
(Example)
m (Wikified article)
Line 1: Line 1:
=OnPlayerUnEquipItem=
 
 
 
Fires whenever a PC unequips an item. Can be useful for creating truly cursed items that can't even be unequipped.
 
Fires whenever a PC unequips an item. Can be useful for creating truly cursed items that can't even be unequipped.
  
<br />
+
===Trigger===
 
 
====Trigger====
 
 
 
 
PC unequips an item (prior to the item actually being unequipped).
 
PC unequips an item (prior to the item actually being unequipped).
  
<br />
+
===Function(s)===
 
 
====Function(s)====
 
 
 
 
[[GetItemPossessor | GetItemPossessor(oItem) ]] Returns who holds the item that was unequipped
 
[[GetItemPossessor | GetItemPossessor(oItem) ]] Returns who holds the item that was unequipped
  
<br />
+
===Remarks===
 +
With Hordes of the Underdark, BioWare has introduced a generic tag-based system covering all of the module related item events. View the scripts x2_mod_def_equ, x2_mod_def_unequ, x2_mod_def_unaqu, x2_mod_def_aqu, x2_mod_def_act, and IN PARTICULAR, x2_it_example for more information if you wish to use the BioWare way of doing it. It is unknown by the Lexicon's authors, at this time, if the system is available on non-Hordes of the Underdark installations.
  
====Remarks====
+
By using GetItemPossessor(oItem) you can check several things in this event:
 +
#If the PC dropped it or not.
 +
#If he just sold it straight out of his inventory slot.
 +
#If it is in barter (if the item's location is invalid, and the possessor invalid, it is in a barter screen - in limbo).
  
With Hordes of the Underdark, BioWare has introduced a generic tag based system covering all of the module related item events. View the scripts x2_mod_def_equ, x2_mod_def_unequ, x2_mod_def_unaqu, x2_mod_def_aqu, x2_mod_def_act, and IN PARTICULAR, x2_it_example for more information if you wish to use the BioWare way of doing it. It is unknown by the Lexicon's authors, at this time, if the system is available on non-Hordes of the Underdark installations. By using GetItemPossessor(oItem) you can check several things in this event. Firstly, if the PC dropped it or not, secondly, if he just sold it straight out of his inventory slot, and thirdly, if it is in barter (if the items location is invalid, and the possessor invalid, it is in a barter screen - in limbo). Of course, if the possessor is still the PC, then he just moved it into his inventory. Because of how you can drop items/sell items right from slots, the only way to force a PC to never unequip an item is to make sure it has the cursed flag set (so it cannot be sold, or moved out of a creatures inventory). This means any ActionEquipItem()'s will pass sucessfully.
+
Of course, if the possessor is still the PC, then he just moved it into his inventory. Because of how you can drop items/sell items right from slots, the only way to force a PC to never unequip an item is to make sure it has the cursed flag set (so it cannot be sold, or moved out of a creature's inventory). This means any [[ActionEquipItem]]()'s will pass successfully.
 
 
<br />
 
 
 
====Example====
 
  
 +
===Example===
 
<nwscript>
 
<nwscript>
// PC can't take off any cursed necklaces, Ever. *evil grin*
+
// PC can't take off any cursed necklaces, ever. *evil grin*
  
 
// Note: It is best, no, normally required, that the item that cannot
 
// Note: It is best, no, normally required, that the item that cannot
 
// be unequipped to be cursed. This means a PC cannot drop it
 
// be unequipped to be cursed. This means a PC cannot drop it
// from thier inventory slot, right onto the ground, and thus the  
+
// from their inventory slot, right onto the ground, and thus the  
 
// script fail.
 
// script fail.
  
Line 36: Line 29:
 
{
 
{
 
     // Get the objects for use with this event.
 
     // Get the objects for use with this event.
     object oPC=GetPCItemLastUnequippedBy();
+
     object oPC   = GetPCItemLastUnequippedBy();
     object oItem=GetPCItemLastUnequipped();
+
     object oItem = GetPCItemLastUnequipped();
  
 
     // This could be a tag check, but does need to check it is a neck
 
     // This could be a tag check, but does need to check it is a neck
 
     // item, so it can be equipped to the right slot.
 
     // item, so it can be equipped to the right slot.
     if (GetItemCursedFlag(oItem) &amp;&amp;
+
     if (GetItemCursedFlag(oItem) &&
 
         GetBaseItemType(oItem) == BASE_ITEM_AMULET)
 
         GetBaseItemType(oItem) == BASE_ITEM_AMULET)
 
     {
 
     {
Line 50: Line 43:
 
</nwscript>
 
</nwscript>
  
====See Also====
+
===See Also===
 
 
 
{| class="seealso"
 
{| class="seealso"
 
|-
 
|-
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
|
+
| [[GetPCItemLastUnequippedBy]]()
[[GetPCItemLastUnequippedBy | GetPCItemLastUnequippedBy() ]]
+
|}<br />
|}
 
 
 
 
----
 
----
 
[[Category:Module_Events]]
 
[[Category:Module_Events]]
 
[[Category:Events]]
 
[[Category:Events]]

Revision as of 02:58, 6 October 2014

Fires whenever a PC unequips an item. Can be useful for creating truly cursed items that can't even be unequipped.

Trigger

PC unequips an item (prior to the item actually being unequipped).

Function(s)

GetItemPossessor(oItem) Returns who holds the item that was unequipped

Remarks

With Hordes of the Underdark, BioWare has introduced a generic tag-based system covering all of the module related item events. View the scripts x2_mod_def_equ, x2_mod_def_unequ, x2_mod_def_unaqu, x2_mod_def_aqu, x2_mod_def_act, and IN PARTICULAR, x2_it_example for more information if you wish to use the BioWare way of doing it. It is unknown by the Lexicon's authors, at this time, if the system is available on non-Hordes of the Underdark installations.

By using GetItemPossessor(oItem) you can check several things in this event:

  1. If the PC dropped it or not.
  2. If he just sold it straight out of his inventory slot.
  3. If it is in barter (if the item's location is invalid, and the possessor invalid, it is in a barter screen - in limbo).

Of course, if the possessor is still the PC, then he just moved it into his inventory. Because of how you can drop items/sell items right from slots, the only way to force a PC to never unequip an item is to make sure it has the cursed flag set (so it cannot be sold, or moved out of a creature's inventory). This means any ActionEquipItem()'s will pass successfully.

Example

// PC can't take off any cursed necklaces, ever. *evil grin*
 
// Note: It is best, no, normally required, that the item that cannot
// be unequipped to be cursed. This means a PC cannot drop it
// from their inventory slot, right onto the ground, and thus the 
// script fail.
 
void main()
{
    // Get the objects for use with this event.
    object oPC   = GetPCItemLastUnequippedBy();
    object oItem = GetPCItemLastUnequipped();
 
    // This could be a tag check, but does need to check it is a neck
    // item, so it can be equipped to the right slot.
    if (GetItemCursedFlag(oItem) &&
        GetBaseItemType(oItem) == BASE_ITEM_AMULET)
    {
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_NECK));
    }
}

See Also

functions:  GetPCItemLastUnequippedBy()