diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 4fcc8db5..702ae840 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -558,6 +558,8 @@ The uninstall messages above are normal and expected. @278000 = ~P&P Free Action~ +@279000 = ~Make sure casting spells from scrolls can be interrupted by damage [Luke]~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 5f46d2d3..6562b352 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -546,6 +546,8 @@ I messaggi di disinstallazione sopra riportati sono normali e previsti. @274000 = ~Consenti ai mutaforma di indossare armature ma impedisci la mutazione mentre le indossi~ +@279000 = ~Fai in modo che il lancio di incantesimi da pergamene possa essere interrotto quando si subiscono dei danni [Luke]~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/lib/comp_2790.tpa b/cdtweaks/lib/comp_2790.tpa new file mode 100644 index 00000000..24a0cd19 --- /dev/null +++ b/cdtweaks/lib/comp_2790.tpa @@ -0,0 +1,15 @@ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// Make sure casting spells scrolls can be interrupted by damage \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ + +WITH_SCOPE BEGIN + INCLUDE "cdtweaks\luke\lib\install.tph" + // + INCLUDE "cdtweaks\lib\gt_cast_spells_from_scrolls.tph" + // + LAF "CAST_SPELLS_FROM_SCROLLS" END +END \ No newline at end of file diff --git a/cdtweaks/lib/gt_cast_spells_from_scrolls.tph b/cdtweaks/lib/gt_cast_spells_from_scrolls.tph new file mode 100644 index 00000000..8cc784b9 --- /dev/null +++ b/cdtweaks/lib/gt_cast_spells_from_scrolls.tph @@ -0,0 +1,5 @@ +DEFINE_ACTION_FUNCTION "CAST_SPELLS_FROM_SCROLLS" +BEGIN + LAF "APPEND_LUA_CHUNK" STR_VAR "description" = "Rule Changes" "sourceFileSpec" = "cdtweaks\luke\lua\rule_changes\cast_spells_from_scrolls.lua" "destRes" = "m_gtrule" END +END + diff --git a/cdtweaks/luke/lua/rule_changes/cast_spells_from_scrolls.lua b/cdtweaks/luke/lua/rule_changes/cast_spells_from_scrolls.lua new file mode 100644 index 00000000..04ca749b --- /dev/null +++ b/cdtweaks/luke/lua/rule_changes/cast_spells_from_scrolls.lua @@ -0,0 +1,52 @@ +--[[ ++------------------------------------------------------------------------------+ +| cdtweaks, Make sure casting spells from scrolls can be interrupted by damage | ++------------------------------------------------------------------------------+ +--]] + +EEex_GameState_AddInitializedListener(function() + local itmFileList = Infinity_GetFilesOfType("itm") + -- for some unknown reason, we need two nested loops in order to get the resref... + for _, temp in ipairs(itmFileList) do + for _, res in pairs(temp) do + local pHeader = EEex_Resource_Demand(res, "itm") -- Item_Header_st + -- sanity check + if pHeader then + -- only care for droppable and displayable items + if EEex_IsBitSet(pHeader.itemFlags, 0x2) and EEex_IsBitSet(pHeader.itemFlags, 0x3) then + if pHeader.itemType == 0xB then -- scrolls + local abilitiesCount = pHeader.abilityCount + if abilitiesCount > 0 then + local currentAbilityAddress = EEex_UDToPtr(pHeader) + pHeader.abilityOffset + -- + for i = 1, abilitiesCount do + local pAbility = EEex_PtrToUD(currentAbilityAddress, "Item_ability_st") -- Item_ability_st + if pAbility then -- sanity check + local effectsCount = pAbility.effectCount + if effectsCount > 0 then + local currentEffectAddress = EEex_UDToPtr(pHeader) + pHeader.effectsOffset + pAbility.startingEffect * Item_effect_st.sizeof + -- + for j = 1, effectsCount do + local pEffect = EEex_PtrToUD(currentEffectAddress, "Item_effect_st") -- Item_effect_st + if pEffect then -- sanity check + if (pEffect.effectID == 0x92 or pEffect.effectID == 0x94) and pEffect.dwFlags == 0x0 then -- op146/148 (normal mode) + -- adjust the special field + pEffect.special = EEex_SetBit(pEffect.special, 0x0) -- see "https://github.com/Bubb13/EEex/pull/105" + end + end + -- + currentEffectAddress = currentEffectAddress + Item_effect_st.sizeof + end + end + end + -- + currentAbilityAddress = currentAbilityAddress + Item_ability_st.sizeof + end + end + end + end + end + end + end +end) + diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index b642a03c..bd23fdcd 100644 --- a/cdtweaks/readme-cdtweaks.html +++ b/cdtweaks/readme-cdtweaks.html @@ -1142,6 +1142,12 @@

Rule Changes Make sure casting spells from scrolls can be interrupted by damage [Luke] Link to this component
+ EEex required; available for BGEE, BG2EE, IWDEE, EET

+

+ This component simply makes sure casting spells from scrolls can be interrupted upon taking damage (just like ordinary spellcasting). +

+

Convenience Tweaks and/or Cheats

diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index b765c874..1b4049a8 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -3386,6 +3386,20 @@ GROUP @9 REQUIRE_PREDICATE !GAME_IS ~iwd2 pst pstee iwdee iwd how totlm~ @25 LABEL ~cd_tweaks_pnp_free_action~ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// Make sure casting spells from scrolls can be interrupted by damage \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ + +BEGIN @279000 DESIGNATED 2790 +GROUP @9 +REQUIRE_PREDICATE GAME_IS "bgee bg2ee eet iwdee" @25 +REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 +LABEL ~cd_tweaks_make_sure_casting_spells_from_scrolls_can_be_interrupted_by_damage~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\