Attack

This module contains ctypes and functions required for interacting with Solstice’s and NWN’s internal combat attack data structures.

ctypes

Warning

The following ctypes must be syncronized with nwnx_solstice. If not bad, bad things will happen. Good news is it’s unlikely that will every be necessary.

DamageResult

Constructor damage_result_t

This struct is used by the combat engine to when determining a damage roll. The length of the arrays is determined by the global DAMAGE_INDEX_NUM constant.

int32_t damages[DAMAGE_INDEX_NUM]

Normal damage.

int32_t damages_unblocked[DAMAGE_INDEX_NUM]

Unblockable damages.

int32_t immunity[DAMAGE_INDEX_NUM]

Damage immunity adjustments.

int32_t resist[DAMAGE_INDEX_NUM]

Damage resistance adjustments.

int32_t resist_remaining[DAMAGE_INDEX_NUM]

Damage resistance remaining. This is to provide feedback for DamageResistance effects with limits.

int32_t reduction

Damage reduction adjustment.

int32_t reduction_remaining

Damage reduction remaining. This is to provide feedback for DamageReduction effects with limits.

int32_t parry

Parry adjustment for servers using the Critical Hit Parry reduction designed by Higher Ground.

Attack

Information for an attack.

CNWSCreature* attacker_nwn

Internal attacker object, unused in Lua.

CNWSObject* target_nwn

Internal target object, unused in Lua.

CNWSCombatAttackData* attack

Internal NWN attack data.

int32_t weapon

EQUIP_TYPE_* of current weapon.

int32_t ranged_type

RANGED_TYPE_*

uint32_t target_state

Target state bitmask.

uint32_t situational_flags

Situational bitmask.

double target_distance

Distance to target.

bool is_offhand

Is offhand attack.

bool is_sneak

Is sneak attack.

bool is_death

Is death attack.

bool is_killing

Is killing blow.

int32_t damage_total

Total damage done.

DamageResult dmg_result

DamageResult ctype.

int32_t effects_to_remove[]
int32_t effects_to_remove_len

Functions

Note

When using these functions in performance critical code, you should cache them in local variables.

AddCCMessage(info, type, objs, ints, str)

Adds combat message to an attack.

Parameters:
  • info (Attack) – Attack info.
AddDamageToResult(info, dmg, mult)

Add damage.

Parameters:
  • info (Attack) – Attack info.
  • dmgDamageRoll
  • mult (int) – Multiplier for crits, etc.
AddEffect(info, attacker, eff)

Adds an onhit effect to an attack.

Parameters:
AddVFX(info, attacker, vfx)
Parameters:
  • info (Attack) – Attack info.
  • attackerCreature
  • vfx (int) – VFX_*
ClearSpecialAttack(info)
Parameters:
  • info (Attack) – Attack info.
CopyDamageToNWNAttackData(info, attacker, target)
Parameters:
GetAttackRoll(info)
Parameters:
  • info (Attack) – Attack info.
GetIsCoupDeGrace(info)
Parameters:
  • info (Attack) – Attack info.
GetIsCriticalHit(info)
Parameters:
  • info (Attack) – Attack info.
GetIsDeathAttack(info)
Parameters:
  • info (Attack) – Attack info.
GetIsHit(info)
Parameters:
  • info (Attack) – Attack info.
GetIsRangedAttack(info)
Parameters:
  • info (Attack) – Attack info.
GetIsSneakAttack(info)
Parameters:
  • info (Attack) – Attack info.
GetIsSpecialAttack(info)
Parameters:
  • info (Attack) – Attack info.
GetResult(info)
Parameters:
  • info (Attack) – Attack info.
GetSpecialAttack(info)
Parameters:
  • info (Attack) – Attack info.
GetType(info)
Parameters:
  • info (Attack) – Attack info.
Return type:

ATTACK_TYPE_*

SetAttackMod(info, ab)
Parameters:
  • info (Attack) – Attack info.
  • ab (int) – Attack modifier.
SetAttackRoll(info, roll)
Parameters:
  • info (Attack) – Attack info.
  • roll (int) – Attack roll.
SetConcealment(info, conceal)
Parameters:
  • info (Attack) – Attack info.
  • conceal (int) – Concealment.
SetCriticalResult(info, threat, result)
Parameters:
  • info (Attack) – Attack info.
  • threat (int) – Critical threat roll.
  • result (boolean) – Is a critical hit.
SetMissedBy(info, roll)
Parameters:
  • info (Attack) – Attack info.
  • roll (int) – Attack roll.
SetResult(info, result)
Parameters:
  • info (Attack) – Attack info.
  • result (int) – Attack result.
SetSneakAttack(info, sneak, death)
Parameters:
  • info (Attack) – Attack info.
  • sneak (boolean) – Is sneak attack.
  • death (boolean) – Is death attack.