NWNX:EE  8193.36.12
Weapon

Readme

Functions exposing additional weapon properties.

Function Documentation and Examples

Allows modifying which feats count as which for the weapon feats. Can be used to add feats like WEAPON_FOCUS_* to custom weapons. All you have to do is:

  1. Create a custom feat and add it to your hak.
  2. Create the new base item ID for your new weapon or use one that already exists.
  3. On the OnModuleLoad event script of your module define the association between the weapon and the feat using the functions defined in the nwnx_weapon script

For example, if you added the FEAT_WEAPON_FOCUS_KATAR on line 3000 of your feat.2da and you added the new BASE_ITEM_KATAR on line 310 of your baseitems.2da, in the OnModuleLoad script just add (don't forget to include the nwnx_weapon script) :

int FEAT_WEAPON_FOCUS_KATAR = 3000;
int BASE_ITEM_KATAR = 310;
NWNX_Weapon_SetWeaponFocusFeat(BASE_ITEM_KATAR, FEAT_WEAPON_FOCUS_KATAR);

Available functions

Script function Description
NWNX_Weapon_SetWeaponFocusFeat() Associate a weapon focus feat to a weapon. You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetWeaponFinesseSize() Define the required creature size for a weapon in order to be finessable
NWNX_Weapon_SetWeaponUnarmed() Set the weapon to be considered unarmed regarding the finesse feat
NWNX_Weapon_SetWeaponImprovedCriticalFeat() Associate a weapon improved critical feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetWeaponSpecializationFeat() Associate a weapon specialization feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetEpicWeaponFocusFeat() Associate an epic weapon focus feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetEpicWeaponSpecializationFeat() Associate an epic weapon specialization feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat() Associate an epic weapon overwhelming critical feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat() Associate an epic weapon devastating critical feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetWeaponOfChoiceFeat() Associate a weapon of choice feat to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetGreaterWeaponFocusFeat() Associate a greater weapon focus feat (default: +1 attack bonus) to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetGreaterWeaponSpecializationFeat() Associate a greater weapon specialization feat (default: +2 damage bonus) to a weapon You may set multiple feats for each weapon and all will function.
NWNX_Weapon_SetWeaponIsMonkWeapon() Set the weapon to be considered a monk weapon (requires activation of CombatModes plugin for Flurry of Blows)
NWNX_Weapon_SetOption() Set different options of the plugin
NWNX_Weapon_SetDevastatingCriticalEventScript() Set a script to be called when a devastating critical event occurs
NWNX_Weapon_GetDevastatingCriticalEventData() Must be called inside the devastating critical event script. Returns a structure with the data of the devastating critical event (weapon, target and damage)
NWNX_Weapon_BypassDevastatingCritical() Must be called inside the devastating critical event script. If called, no devastating critical will occur.
NWNX_Weapon_SetOneHalfStrength() Gives a melee weapon extra damage equal to one-half strength modifier.
NWNX_Weapon_GetOneHalfStrength() Retrieves if a melee weapon is receiving extra strength

The NWNX_Weapon_SetOption() function can be used to define the attack and damage bonusses of the Greater Weapon Focus Feats and Greater Weapon Specialization Feats respectively.

Example for Critical Event Script

This script just prints some info to the log and then bypasses the devastating critical 50% of the time. You have to set your script with NWNX_Weapon_SetDevastatingCriticalEventScript() (in the OnModuleLoad script for example)

Warning
oWeapon in NWNX_Weapon_DevastatingCriticalEvent_Data will be OBJECT_INVALID for Gloves/Unarmed Strike Devastating Critical Events.
#include "nwnx_weapon"
void main()
{
object oAttacker = OBJECT_SELF;
object oWeapon = data.oWeapon;
object oTarget = data.oTarget;
int nDamage = data.nDamage;
WriteTimestampedLogEntry("Devastating Critical Event: Attaker: " + GetName(oAttacker) +
", Weapon: "+ GetName(oWeapon) +
", Target: "+ GetName(oTarget) +
", Damage: " + IntToString(nDamage));
if(d100()>50)
{
WriteTimestampedLogEntry("Devastating Critical Bypassed");
}
}
Note
As of NWN:EE Version 8193.6 builders can define the feats associated with weapons in the new baseitems.2da columns. The following new columns can now have the corresponding feat referenced per baseitem row:
  • WeaponFocusFeat
  • EpicWeaponFocusFeat
  • WeaponSpecializationFeat
  • EpicWeaponSpecializationFeat
  • WeaponImprovedCriticalFeat
  • EpicWeaponOverwhelmingCriticalFeat
  • EpicWeaponDevastatingCriticalFeat
  • WeaponOfChoiceFeat

Files

file  nwnx_weapon.nss
 

Classes

struct  NWNX_Weapon_DevastatingCriticalEvent_Data
 Devastating critical event data. More...
 

Functions

void NWNX_Weapon_SetWeaponFocusFeat (int nBaseItem, int nFeat)
 Set nFeat as weapon focus feat for a base item. More...
 
void NWNX_Weapon_SetWeaponFinesseSize (int nBaseItem, int nSize)
 Set required creature size for a weapon base item to be finessable. More...
 
int NWNX_Weapon_GetWeaponFinesseSize (int nBaseItem)
 Get required creature size for a weapon base item to be finessable. More...
 
void NWNX_Weapon_SetWeaponUnarmed (int nBaseItem)
 Set weapon base item to be considered as unarmed for weapon finesse feat. More...
 
void NWNX_Weapon_SetWeaponImprovedCriticalFeat (int nBaseItem, int nFeat)
 Set a feat as weapon improved critical for a base item. More...
 
void NWNX_Weapon_SetWeaponSpecializationFeat (int nBaseItem, int nFeat)
 Set a feat as weapon specialization for a base item. More...
 
void NWNX_Weapon_SetEpicWeaponFocusFeat (int nBaseItem, int nFeat)
 Set a feat as epic weapon focus for a base item. More...
 
void NWNX_Weapon_SetEpicWeaponSpecializationFeat (int nBaseItem, int nFeat)
 Set a feat as epic weapon specialization for a base item. More...
 
void NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat (int nBaseItem, int nFeat)
 Set a feat as epic weapon overwhelming critical for a base item. More...
 
void NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat (int nBaseItem, int nFeat)
 Set a feat as epic weapon devastating critical for a base item. More...
 
void NWNX_Weapon_SetWeaponOfChoiceFeat (int nBaseItem, int nFeat)
 Set a feat as weapon of choice for a base item. More...
 
void NWNX_Weapon_SetGreaterWeaponSpecializationFeat (int nBaseItem, int nFeat)
 Set a feat as greater weapon specialization for a base item. More...
 
void NWNX_Weapon_SetGreaterWeaponFocusFeat (int nBaseItem, int nFeat)
 Set a feat as greater weapon focus for a base item. More...
 
void NWNX_Weapon_SetWeaponIsMonkWeapon (int nBaseItem)
 Set base item as monk weapon. More...
 
void NWNX_Weapon_SetOption (int nOption, int nVal)
 Set plugin options. More...
 
void NWNX_Weapon_SetDevastatingCriticalEventScript (string sScript)
 Set Devastating Critical Event Script. More...
 
struct NWNX_Weapon_DevastatingCriticalEvent_Data NWNX_Weapon_GetDevastatingCriticalEventData ()
 Get Devastating Critical Event Data. More...
 
void NWNX_Weapon_BypassDevastatingCritical ()
 Bypass Devastating Critical. More...
 
void NWNX_Weapon_SetOneHalfStrength (object oWeapon, int nEnable, int bPersist=FALSE)
 Sets weapon to gain .5 strength bonus. More...
 
int NWNX_Weapon_GetOneHalfStrength (object oWeapon)
 Gets if the weapon is set to gain addition .5 strength bonus. More...
 
void NWNX_Weapon_SetMaxRangedAttackDistanceOverride (int nBaseItem, float fMax, float fMaxPassive, float fPreferred)
 Override the max attack distance of ranged weapons. More...
 

Variables

const int NWNX_WEAPON_GETDATA_DC = 0
 Get Devastating Critical Data. More...
 
const int NWNX_WEAPON_SETDATA_DC_BYPASS = 0
 Set Devastating Critical Bypass. More...
 

Function Documentation

◆ NWNX_Weapon_SetWeaponFocusFeat()

void NWNX_Weapon_SetWeaponFocusFeat ( int  nBaseItem,
int  nFeat 
)

Set nFeat as weapon focus feat for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 139 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponFinesseSize()

void NWNX_Weapon_SetWeaponFinesseSize ( int  nBaseItem,
int  nSize 
)

Set required creature size for a weapon base item to be finessable.

Parameters
nBaseItemThe base item id.
nSizeThe creature size minimum to consider this weapon finessable.

Definition at line 169 of file nwnx_weapon.nss.

◆ NWNX_Weapon_GetWeaponFinesseSize()

int NWNX_Weapon_GetWeaponFinesseSize ( int  nBaseItem)

Get required creature size for a weapon base item to be finessable.

Parameters
nBaseItemThe base item id.

Definition at line 179 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponUnarmed()

void NWNX_Weapon_SetWeaponUnarmed ( int  nBaseItem)

Set weapon base item to be considered as unarmed for weapon finesse feat.

Parameters
nBaseItemThe base item id.

Definition at line 190 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponImprovedCriticalFeat()

void NWNX_Weapon_SetWeaponImprovedCriticalFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as weapon improved critical for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 210 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponSpecializationFeat()

void NWNX_Weapon_SetWeaponSpecializationFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as weapon specialization for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 220 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetEpicWeaponFocusFeat()

void NWNX_Weapon_SetEpicWeaponFocusFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as epic weapon focus for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 149 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetEpicWeaponSpecializationFeat()

void NWNX_Weapon_SetEpicWeaponSpecializationFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as epic weapon specialization for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 240 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat()

void NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as epic weapon overwhelming critical for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 250 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat()

void NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as epic weapon devastating critical for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 260 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponOfChoiceFeat()

void NWNX_Weapon_SetWeaponOfChoiceFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as weapon of choice for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 270 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetGreaterWeaponSpecializationFeat()

void NWNX_Weapon_SetGreaterWeaponSpecializationFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as greater weapon specialization for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 230 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetGreaterWeaponFocusFeat()

void NWNX_Weapon_SetGreaterWeaponFocusFeat ( int  nBaseItem,
int  nFeat 
)

Set a feat as greater weapon focus for a base item.

Parameters
nBaseItemThe base item id.
nFeatThe feat to set.

Definition at line 159 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetWeaponIsMonkWeapon()

void NWNX_Weapon_SetWeaponIsMonkWeapon ( int  nBaseItem)

Set base item as monk weapon.

Parameters
nBaseItemThe base item id.
Deprecated:
Use baseitems.2da. This will be removed in future NWNX releases.

Definition at line 199 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetOption()

void NWNX_Weapon_SetOption ( int  nOption,
int  nVal 
)

Set plugin options.

Parameters
nOptionThe option to change from Weapon Options.
nValThe new value of the option.

Definition at line 280 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetDevastatingCriticalEventScript()

void NWNX_Weapon_SetDevastatingCriticalEventScript ( string  sScript)

Set Devastating Critical Event Script.

Parameters
sScriptThe script to call when a Devastating Critical occurs.

Definition at line 290 of file nwnx_weapon.nss.

◆ NWNX_Weapon_GetDevastatingCriticalEventData()

struct NWNX_Weapon_DevastatingCriticalEvent_Data NWNX_Weapon_GetDevastatingCriticalEventData ( )

Get Devastating Critical Event Data.

Note
This is only for use with the Devastating Critical Event Script.
Returns
An NWNX_Weapon_DevastatingCriticalEvent_Data struct.

Definition at line 309 of file nwnx_weapon.nss.

◆ NWNX_Weapon_BypassDevastatingCritical()

void NWNX_Weapon_BypassDevastatingCritical ( )

Bypass Devastating Critical.

Note
This is only for use with the Devastating Critical Event Script.

Definition at line 299 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetOneHalfStrength()

void NWNX_Weapon_SetOneHalfStrength ( object  oWeapon,
int  nEnable,
int  bPersist = FALSE 
)

Sets weapon to gain .5 strength bonus.

Parameters
oWeaponShould be a melee weapon.
nEnableTRUE for bonus. FALSE to turn off bonus.
bPersistwhether the two hand state should persist to the gff file.

Definition at line 324 of file nwnx_weapon.nss.

◆ NWNX_Weapon_GetOneHalfStrength()

int NWNX_Weapon_GetOneHalfStrength ( object  oWeapon)

Gets if the weapon is set to gain addition .5 strength bonus.

Parameters
oWeaponthe weapon
Returns
FALSE/0 if weapon is not receiving the bonus. TRUE/1 if it does.

Definition at line 333 of file nwnx_weapon.nss.

◆ NWNX_Weapon_SetMaxRangedAttackDistanceOverride()

void NWNX_Weapon_SetMaxRangedAttackDistanceOverride ( int  nBaseItem,
float  fMax,
float  fMaxPassive,
float  fPreferred 
)

Override the max attack distance of ranged weapons.

Parameters
nBaseItemThe baseitem id.
fMaxThe maximum attack distance. Default is 40.0f.
fMaxPassiveThe maximum passive attack distance. Default is 20.0f. Seems to be used by the engine to determine a new nearby target when needed.
fPreferredThe preferred attack distance. See the PrefAttackDist column in baseitems.2da, default seems to be 30.0f for ranged weapons.
Note
fMaxPassive should probably be lower than fMax, half of fMax seems to be a good start. fPreferred should be at least ~0.5f lower than fMax.

Definition at line 342 of file nwnx_weapon.nss.

Variable Documentation

◆ NWNX_WEAPON_OPT_GRTFOCUS_AB_BONUS

const int NWNX_WEAPON_OPT_GRTFOCUS_AB_BONUS = 0

Greater Focus Attack Bonus.

Definition at line 14 of file nwnx_weapon.nss.

◆ NWNX_WEAPON_OPT_GRTSPEC_DAM_BONUS

const int NWNX_WEAPON_OPT_GRTSPEC_DAM_BONUS = 1

Greater Specialization Damage Bonus.

Definition at line 15 of file nwnx_weapon.nss.

◆ NWNX_WEAPON_GETDATA_DC

const int NWNX_WEAPON_GETDATA_DC = 0

Get Devastating Critical Data.

Definition at line 19 of file nwnx_weapon.nss.

◆ NWNX_WEAPON_SETDATA_DC_BYPASS

const int NWNX_WEAPON_SETDATA_DC_BYPASS = 0

Set Devastating Critical Bypass.

Definition at line 22 of file nwnx_weapon.nss.

NWNX_Weapon_BypassDevastatingCritical
void NWNX_Weapon_BypassDevastatingCritical()
Bypass Devastating Critical.
Definition: nwnx_weapon.nss:299
main
void main()
Definition: array_example.nss:133
NWNX_Weapon_DevastatingCriticalEvent_Data::nDamage
int nDamage
The damage points delivered.
Definition: nwnx_weapon.nss:29
NWNX_Weapon_GetDevastatingCriticalEventData
struct NWNX_Weapon_DevastatingCriticalEvent_Data NWNX_Weapon_GetDevastatingCriticalEventData()
Get Devastating Critical Event Data.
Definition: nwnx_weapon.nss:309
NWNX_Weapon_DevastatingCriticalEvent_Data::oTarget
object oTarget
The target hit with a devastating critical.
Definition: nwnx_weapon.nss:28
NWNX_Weapon_DevastatingCriticalEvent_Data
Devastating critical event data.
Definition: nwnx_weapon.nss:25
NWNX_Weapon_DevastatingCriticalEvent_Data::oWeapon
object oWeapon
The weapon used to cause the event.
Definition: nwnx_weapon.nss:27
NWNX_Weapon_SetWeaponFocusFeat
void NWNX_Weapon_SetWeaponFocusFeat(int nBaseItem, int nFeat)
Set nFeat as weapon focus feat for a base item.
Definition: nwnx_weapon.nss:139