Skip to content

Commit

Permalink
Merge pull request #1754 from Daztek/damage-spellid
Browse files Browse the repository at this point in the history
Damage: add iSpellId to the NWNX_Damage_DamageEventData struct
  • Loading branch information
Daztek authored Apr 22, 2024
2 parents 93b3a40 + 7745d16 commit 2f732e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD

### Changed
- Player: added bChatWindow parameter to FloatingTextStringOnCreature()
- Damage: added iSpellId to the NWNX_Damage_DamageEventData struct.

### Deprecated
- N/A
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Damage/Damage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct DamageData
{
uint32_t oidDamager;
int32_t vDamage[MAX_DAMAGE_TYPES];
int32_t nSpellId;
};

struct AttackData
Expand Down Expand Up @@ -57,6 +58,7 @@ static Hooks::Hook s_OnApplyDamageHook = Hooks::HookFunction(&CNWSEffectListHand
{
s_DamageData.oidDamager = pEffect->m_oidCreator;
std::memcpy(s_DamageData.vDamage, pEffect->m_nParamInteger, MAX_DAMAGE_TYPES * sizeof(int32_t));
s_DamageData.nSpellId = pEffect->m_nSpellId;
Utils::ExecuteScript(sScript, pObject->m_idSelf);
std::memcpy(pEffect->m_nParamInteger, s_DamageData.vDamage, MAX_DAMAGE_TYPES * sizeof(int32_t));
}
Expand Down Expand Up @@ -158,6 +160,7 @@ NWNX_EXPORT ArgumentStack GetDamageEventData(ArgumentStack&&)
{
ArgumentStack stack;

ScriptAPI::InsertArgument(stack, s_DamageData.nSpellId);
for (int k = (MAX_DAMAGE_TYPES - 1); k >= 0; k--)
{
ScriptAPI::InsertArgument(stack, s_DamageData.vDamage[k]);
Expand Down
2 changes: 2 additions & 0 deletions Plugins/Damage/NWScript/nwnx_damage.nss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct NWNX_Damage_DamageEventData
int iCustom17; ///< Custom17 damage
int iCustom18; ///< Custom18 damage
int iCustom19; ///< Custom19 damage
int iSpellId; ///< The spell id associated with the damage or -1 if not known.
};

/// @struct NWNX_Damage_AttackEventData
Expand Down Expand Up @@ -222,6 +223,7 @@ struct NWNX_Damage_DamageEventData NWNX_Damage_GetDamageEventData()
data.iCustom17 = NWNX_GetReturnValueInt();
data.iCustom18 = NWNX_GetReturnValueInt();
data.iCustom19 = NWNX_GetReturnValueInt();
data.iSpellId = NWNX_GetReturnValueInt();

return data;
}
Expand Down

0 comments on commit 2f732e7

Please sign in to comment.