From 7cfe83017e875dcea4921abb7103db88b0cbecef Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 26 Feb 2024 22:48:11 -0500 Subject: [PATCH 1/3] Replace SavingThrow to avoid double stacking some saves --- TemplePlus/damage.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TemplePlus/damage.cpp b/TemplePlus/damage.cpp index 4706e58f5..beab0e10b 100644 --- a/TemplePlus/damage.cpp +++ b/TemplePlus/damage.cpp @@ -73,8 +73,6 @@ static struct DamageAddresses : temple::AddressTable { int (__cdecl*HealSubdual)(objHndl target, int amount); int (__cdecl*DoSpellDamage)(objHndl victim, objHndl attacker, uint32_t dmgDice, DamageType type, int attackPowerType, int reduction, int damageDescMesKey, int actionType, int spellId, int flags); - - bool (__cdecl *SavingThrow)(objHndl obj, objHndl attacker, int dc, SavingThrowType type, int flags); bool (__cdecl *SavingThrowSpell)(objHndl obj, objHndl attacker, int dc, SavingThrowType type, int flags, int spellId); @@ -110,7 +108,6 @@ static struct DamageAddresses : temple::AddressTable { rebase(HealSpell, 0x100B81D0); rebase(DoSpellDamage, 0x100B7F80); rebase(HealSubdual, 0x100B9030); - rebase(SavingThrow, 0x100B4F20); rebase(SavingThrowSpell, 0x100B83C0); rebase(ReflexSaveAndDamage, 0x100B9500); @@ -161,6 +158,10 @@ class DamageHooks: TempleFix replaceFunction(0x100B7950, [](objHndl attacker, objHndl tgt, int d20Data, D20CAF flags, D20ActionType actionType) { return damage.DealAttackDamage(attacker, tgt, d20Data, flags, actionType); }); + + replaceFunction(0x100B4F20, [](objHndl tgt, objHndl atk, int dc, int saveType, int flags) { + return damage.SavingThrow(tgt, atk, dc, saveType, flags); + }); } } damageHooks; @@ -891,8 +892,6 @@ bool Damage::SavingThrow(objHndl handle, objHndl attacker, int dc, SavingThrowTy return false; // natural 1 - always fails } return saveThrowMod + diceResult >= dc; - - // return addresses.SavingThrow(handle, attacker, dc, saveType, flags); } bool Damage::SavingThrowSpell(objHndl obj, objHndl attacker, int dc, SavingThrowType type, int flags, int spellId) { From 84d42be94c4ce7cec482da5bd376532dd59aee95 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 26 Feb 2024 23:28:35 -0500 Subject: [PATCH 2/3] Typo --- TemplePlus/damage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TemplePlus/damage.cpp b/TemplePlus/damage.cpp index beab0e10b..53ac36bf5 100644 --- a/TemplePlus/damage.cpp +++ b/TemplePlus/damage.cpp @@ -159,7 +159,7 @@ class DamageHooks: TempleFix return damage.DealAttackDamage(attacker, tgt, d20Data, flags, actionType); }); - replaceFunction(0x100B4F20, [](objHndl tgt, objHndl atk, int dc, int saveType, int flags) { + replaceFunction(0x100B4F20, [](objHndl tgt, objHndl atk, int dc, int saveType, int flags) { return damage.SavingThrow(tgt, atk, dc, saveType, flags); }); } From 754e1939f532eef3d11246f1c4c757614cf2d54f Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 26 Feb 2024 23:44:31 -0500 Subject: [PATCH 3/3] Necessary cast --- TemplePlus/damage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TemplePlus/damage.cpp b/TemplePlus/damage.cpp index 53ac36bf5..a92e9f026 100644 --- a/TemplePlus/damage.cpp +++ b/TemplePlus/damage.cpp @@ -160,7 +160,7 @@ class DamageHooks: TempleFix }); replaceFunction(0x100B4F20, [](objHndl tgt, objHndl atk, int dc, int saveType, int flags) { - return damage.SavingThrow(tgt, atk, dc, saveType, flags); + return damage.SavingThrow(tgt, atk, dc, static_cast(saveType), flags); }); } } damageHooks;