IPGetIsMeleeWeapon
From NWN Lexicon
Jump to navigationJump to search
IPGetIsMeleeWeapon(object)
Checks if an item is a melee weapon.
Parameters
oItem
Object to check whether is a melee weapon.
Description
Returns TRUE if oItem is a melee weapon.
Remarks
Checks the base item type against the list of types that are known to be melee weapons.
Previously noted was that !GetWeaponRanged() could be used. Of course, this can only be used if the object tested is definitely a weapon of some sort (for example, the object right hand). In some cases (for example, the left hand) this cannot be always tested successfully, and this function can be used instead.
Requirements
#include " x2_inc_itemprop "
Version
1.62
Example
// Speak something if the PC speaker has a melee weapon
// equipped.
// Conversation action.
#include "x2_inc_itemprop"
void main()
{
// Get PC Speaker
object oPC = GetPCSpeaker();
// Get object in right hand
object oObject = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
// Check if melee weapon, or not.
if(IPGetIsMeleeWeapon(oItem))
{
// Speak a (not at all witty) response
SpeakString("Armed for melee fights eh? Well good luck to you! You'll need it!");
}
}
// Kamiryn posted an improved version of this function on the Vault forums that works for custom content. It checks "PropColumn" in baseitems.2da to determine if the item is a melee weapon.
// Column “PropColumn” is used to determine the valid item properties for an item type and links into itemprops.2da. Column 0 in itemprops.2da is “0_Melee”.
int IPGetIsMeleeWeapon(object oItem)
{
return (Get2DAString("baseitems", "PropColumn", GetBaseItemType(oItem)) == "0");
}
// equipped.
// Conversation action.
#include "x2_inc_itemprop"
void main()
{
// Get PC Speaker
object oPC = GetPCSpeaker();
// Get object in right hand
object oObject = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
// Check if melee weapon, or not.
if(IPGetIsMeleeWeapon(oItem))
{
// Speak a (not at all witty) response
SpeakString("Armed for melee fights eh? Well good luck to you! You'll need it!");
}
}
// Kamiryn posted an improved version of this function on the Vault forums that works for custom content. It checks "PropColumn" in baseitems.2da to determine if the item is a melee weapon.
// Column “PropColumn” is used to determine the valid item properties for an item type and links into itemprops.2da. Column 0 in itemprops.2da is “0_Melee”.
int IPGetIsMeleeWeapon(object oItem)
{
return (Get2DAString("baseitems", "PropColumn", GetBaseItemType(oItem)) == "0");
}
See Also
functions: |
author: Lilac Soul, editor: Jasperre, additional contributor(s): wyrmwood