From 10e711fe01f532cdcbd532732274db5dd97163be Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Mon, 28 Oct 2024 11:12:48 +0100 Subject: [PATCH 1/6] More Sensible Cowled Wizards Cowled Wizards vs. spellcasting opcodes. --- cdtweaks/languages/english/weidu.tra | 2 + cdtweaks/languages/italian/weidu.tra | 2 + cdtweaks/lib/comp_3420.tpa | 15 +++ cdtweaks/lib/cowled_wizards.tph | 52 ++++++++ .../lua/convenience_tweaks/cowled_wizards.lua | 121 ++++++++++++++++++ cdtweaks/readme-cdtweaks.html | 6 + cdtweaks/setup-cdtweaks.tp2 | 14 ++ 7 files changed, 212 insertions(+) create mode 100644 cdtweaks/lib/comp_3420.tpa create mode 100644 cdtweaks/lib/cowled_wizards.tph create mode 100644 cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 06daf4ee..f0f4d034 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -719,6 +719,8 @@ Use Baldur.lua options: a7_interval_ini @341100 = ~Mage, priest, and innate spells only~ @341200 = ~All spells (check readme)~ +@342000 = "More Sensible Cowled Wizards [Luke (EEex)]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 738ea95a..d6250152 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -649,6 +649,8 @@ Usa opzioni di Baldur.lua: a7_interval_ini @336000 = ~Ripristina la nebbia di guerra nei sotterranei di Sigil~ +@342000 = "Gli Stregoni Incappucciati reagiranno in maniera piĆ¹ sensata all'uso della magia senza licenza [Luke (EEex)]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/lib/comp_3420.tpa b/cdtweaks/lib/comp_3420.tpa new file mode 100644 index 00000000..cc066e22 --- /dev/null +++ b/cdtweaks/lib/comp_3420.tpa @@ -0,0 +1,15 @@ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +///// \\\\\////\\\\//// +///// More Sensible Cowled Wizards \\\\\ +///// \\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// + +WITH_SCOPE BEGIN + INCLUDE "cdtweaks\luke\misc.tph" + // + INCLUDE "cdtweaks\lib\cowled_wizards.tph" + // + LAF "COWLED_WIZARDS" END +END \ No newline at end of file diff --git a/cdtweaks/lib/cowled_wizards.tph b/cdtweaks/lib/cowled_wizards.tph new file mode 100644 index 00000000..0e8af0b9 --- /dev/null +++ b/cdtweaks/lib/cowled_wizards.tph @@ -0,0 +1,52 @@ +DEFINE_ACTION_FUNCTION "COWLED_WIZARDS" +BEGIN + // patch relevant area scripts \\ + WITH_SCOPE BEGIN + COPY_EXISTING + "ar0020.bcs" "override" // City Gates + "ar0300.bcs" "override" // The Docks + "ar0400.bcs" "override" // Slums + "ar0500.bcs" "override" // Bridge District + "ar0700.bcs" "override" // Waukeen's Promenade + "ar0900.bcs" "override" // Temple District + "ar1000.bcs" "override" // Government District + // + DECOMPILE_AND_PATCH BEGIN + // first relevant block + SET "found" = INDEX_BUFFER (CASE_SENSITIVE EXACT_MATCH ~CreateCreatureObjectDoor("COWENF2",LastTrigger,0,0,0)~) + // + PATCH_IF ("%found%" >= 0) BEGIN + SET "start" = RINDEX_BUFFER (CASE_SENSITIVE EXACT_MATCH ~SpellCast([PC],0)~ "%found%") + SET "end" = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~$~ "%start%") + // + DELETE_BYTES "%start%" ("%end%" - "%start%") + // + INSERT_BYTES "%start%" STRING_LENGTH ~Global("gt_CowledWizardsTriggered","GLOBAL",1)~ + WRITE_ASCII "%start%" ~Global("gt_CowledWizardsTriggered","GLOBAL",1)~ + // + SET "found" = INDEX_BUFFER (CASE_SENSITIVE EXACT_MATCH ~CreateCreatureObjectDoor("COWENF2",LastTrigger,0,0,0)~) + INSERT_BYTES "%found%" STRING_LENGTH ~SetGlobal("gt_CowledWizardsTriggered","GLOBAL",0)~ + WRITE_ASCII "%found%" ~SetGlobal("gt_CowledWizardsTriggered","GLOBAL",0)~ + END + // second relevant block + SET "found" = INDEX_BUFFER (CASE_SENSITIVE EVALUATE_REGEXP ~[ %TAB%]*GlobalTimerNotExpired("SpellsBad","GLOBAL")~) + // + PATCH_IF ("%found%" >= 0) BEGIN + SET "start" = RINDEX_BUFFER (CASE_SENSITIVE EXACT_MATCH ~SpellCast([PC],0)~) + SET "end" = INDEX_BUFFER (CASE_INSENSITIVE EVALUATE_REGEXP ~$~ "%start%") + // + DELETE_BYTES "%start%" ("%end%" - "%start%") + // + INSERT_BYTES "%start%" STRING_LENGTH ~Global("gt_CowledWizardsTriggered","GLOBAL",1)~ + WRITE_ASCII "%start%" ~Global("gt_CowledWizardsTriggered","GLOBAL",1)~ + // + SET "found" = INDEX_BUFFER (CASE_SENSITIVE EXACT_MATCH ~Wait(1)~ "%start%") + INSERT_BYTES "%found%" STRING_LENGTH ~SetGlobal("gt_CowledWizardsTriggered","GLOBAL",0)~ + WRITE_ASCII "%found%" ~SetGlobal("gt_CowledWizardsTriggered","GLOBAL",0)~ + END + END + BUT_ONLY_IF_IT_CHANGES + END + // lua + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\convenience_tweaks\cowled_wizards.lua" "destRes" = "m_gt#twk" END +END \ No newline at end of file diff --git a/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua b/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua new file mode 100644 index 00000000..67cdba6b --- /dev/null +++ b/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua @@ -0,0 +1,121 @@ +--[[ ++----------------------------------------+ +| cdtweaks, more sensible cowled wizards | ++----------------------------------------+ +--]] + +-- set a GLOBAL var when a PC casts a wizard spell and is in Athkatla -- + +GTCOWENF = { + + ["typeMutator"] = function(context) + local actionSources = { + [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, + [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.decodeSource] then + return + end + end, + + ["projectileMutator"] = function(context) + local actionSources = { + [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, + [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.decodeSource] then + return + end + -- + local originatingSprite = context["originatingSprite"] -- CGameSprite + -- + local areaCheck = EEex_Trigger_ParseConditionalString('OR(7) \n AreaCheck("AR0020") AreaCheck("AR0300") AreaCheck("AR0400") AreaCheck("AR0500") AreaCheck("AR0700") AreaCheck("AR0900") AreaCheck("AR1000")') + -- + local setGlobal = EEex_Action_ParseResponseString('SetGlobal("gt_CowledWizardsTriggered","GLOBAL",1)') + -- + local spellResRef = originatingSprite.m_curAction.m_string1.m_pchData:get() + if spellResRef == "" then + spellResRef = GT_Utility_DecodeSpell(originatingSprite.m_curAction.m_specificID) + end + -- + local spellHeader = EEex_Resource_Demand(spellResRef, "SPL") + -- + if spellHeader.itemType == 1 and areaCheck:evalConditionalAsAIBase(originatingSprite) then -- if wizard spell and in Athkatla ... + setGlobal:executeResponseAsAIBaseInstantly(originatingSprite) + end + -- + setGlobal:free() + areaCheck:free() + end, + + ["effectMutator"] = function(context) + local actionSources = { + [EEex_Projectile_AddEffectSource.CGameSprite_Spell] = true, + [EEex_Projectile_AddEffectSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.addEffectSource] then + return + end + end, +} + +-- + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) then + return + end + -- internal function that applies the actual condition + local apply = function() + -- Mark the creature as 'condition applied' + sprite:setLocalInt("cdtweaksCowledWizards", 1) + -- + local effectCodes = { + {["op"] = 321}, -- Remove effects by resource + {["op"] = 408}, -- Projectile mutator + } + -- + for _, attributes in ipairs(effectCodes) do + sprite:applyEffect({ + ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), + ["durationType"] = 9, + ["res"] = "GTCOWENF", + ["m_sourceRes"] = "GTCOWENF", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + -- Check creature's EA + local applyCondition = sprite.m_typeAI.m_EnemyAlly == 2 -- PC + -- + if sprite:getLocalInt("cdtweaksCowledWizards") == 0 then + if applyCondition then + apply() + end + else + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("cdtweaksCowledWizards", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "GTCOWENF", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end +end) diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index 84c933fc..de4386b7 100644 --- a/cdtweaks/readme-cdtweaks.html +++ b/cdtweaks/readme-cdtweaks.html @@ -1361,6 +1361,12 @@

Convenience Tw
  • Mage, priest, and innate spells - as above, but adds spells traditionally in the innate and kit ability space such as Lay on Hands or Boon of Lathander
  • All spells - because the game uses spells to perform a lot of different functions, such as traps or cutscene effects,this option may provide more feedback than desired or expose purely internal spell names such as "just 10 damage". It is, however, the best way to guarantee that all spells from mods are caught
  • + +

    More Sensible Cowled Wizards
    + EEex

    +

    As you probably know, party items that cast spell effects that are coded as "Wizard" spells can trigger the Cowled Wizards - even if the player didn't intend to actually cast an ordinary wizard spell. + This component simply makes sure that such items do not trigger the Cowled Wizards. +

    Joinable NPC Tweaks

    diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 5e97fb6f..b641a057 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -4420,6 +4420,20 @@ GROUP @4 SUBCOMPONENT @341000 LABEL ~cd_tweaks_casting_warnings_all~ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// More Sensible Cowled Wizards \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ + +BEGIN @342000 DESIGNATED 3420 +GROUP @4 +REQUIRE_PREDICATE GAME_IS ~bg2ee eet~ @25 +REQUIRE_PREDICATE MOD_IS_INSTALLED "EEex.tp2" 0 @29 +LABEL ~cd_tweaks_more_sensible_cowled_wizards~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ From e707936e6dfd2396d6457fa5478fb4fd57974880 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Mon, 28 Oct 2024 12:21:02 +0100 Subject: [PATCH 2/6] Update cowled_wizards.tph --- cdtweaks/lib/cowled_wizards.tph | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdtweaks/lib/cowled_wizards.tph b/cdtweaks/lib/cowled_wizards.tph index 0e8af0b9..818a3fae 100644 --- a/cdtweaks/lib/cowled_wizards.tph +++ b/cdtweaks/lib/cowled_wizards.tph @@ -48,5 +48,5 @@ BEGIN BUT_ONLY_IF_IT_CHANGES END // lua - LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\convenience_tweaks\cowled_wizards.lua" "destRes" = "m_gt#twk" END + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\tweaks\cowled_wizards.lua" "destRes" = "m_gttwks" END END \ No newline at end of file From f37d3628db7b0529d6fcd7643f1037e0a712dc5a Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Mon, 28 Oct 2024 12:21:10 +0100 Subject: [PATCH 3/6] Delete cowled_wizards.lua --- .../lua/convenience_tweaks/cowled_wizards.lua | 121 ------------------ 1 file changed, 121 deletions(-) delete mode 100644 cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua diff --git a/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua b/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua deleted file mode 100644 index 67cdba6b..00000000 --- a/cdtweaks/luke/lua/convenience_tweaks/cowled_wizards.lua +++ /dev/null @@ -1,121 +0,0 @@ ---[[ -+----------------------------------------+ -| cdtweaks, more sensible cowled wizards | -+----------------------------------------+ ---]] - --- set a GLOBAL var when a PC casts a wizard spell and is in Athkatla -- - -GTCOWENF = { - - ["typeMutator"] = function(context) - local actionSources = { - [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, - [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, - [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, - [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, - } - -- - if not actionSources[context.decodeSource] then - return - end - end, - - ["projectileMutator"] = function(context) - local actionSources = { - [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, - [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, - [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, - [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, - } - -- - if not actionSources[context.decodeSource] then - return - end - -- - local originatingSprite = context["originatingSprite"] -- CGameSprite - -- - local areaCheck = EEex_Trigger_ParseConditionalString('OR(7) \n AreaCheck("AR0020") AreaCheck("AR0300") AreaCheck("AR0400") AreaCheck("AR0500") AreaCheck("AR0700") AreaCheck("AR0900") AreaCheck("AR1000")') - -- - local setGlobal = EEex_Action_ParseResponseString('SetGlobal("gt_CowledWizardsTriggered","GLOBAL",1)') - -- - local spellResRef = originatingSprite.m_curAction.m_string1.m_pchData:get() - if spellResRef == "" then - spellResRef = GT_Utility_DecodeSpell(originatingSprite.m_curAction.m_specificID) - end - -- - local spellHeader = EEex_Resource_Demand(spellResRef, "SPL") - -- - if spellHeader.itemType == 1 and areaCheck:evalConditionalAsAIBase(originatingSprite) then -- if wizard spell and in Athkatla ... - setGlobal:executeResponseAsAIBaseInstantly(originatingSprite) - end - -- - setGlobal:free() - areaCheck:free() - end, - - ["effectMutator"] = function(context) - local actionSources = { - [EEex_Projectile_AddEffectSource.CGameSprite_Spell] = true, - [EEex_Projectile_AddEffectSource.CGameSprite_SpellPoint] = true, - [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpell] = true, - [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpellPoint] = true, - } - -- - if not actionSources[context.addEffectSource] then - return - end - end, -} - --- - -EEex_Opcode_AddListsResolvedListener(function(sprite) - -- Sanity check - if not EEex_GameObject_IsSprite(sprite) then - return - end - -- internal function that applies the actual condition - local apply = function() - -- Mark the creature as 'condition applied' - sprite:setLocalInt("cdtweaksCowledWizards", 1) - -- - local effectCodes = { - {["op"] = 321}, -- Remove effects by resource - {["op"] = 408}, -- Projectile mutator - } - -- - for _, attributes in ipairs(effectCodes) do - sprite:applyEffect({ - ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), - ["durationType"] = 9, - ["res"] = "GTCOWENF", - ["m_sourceRes"] = "GTCOWENF", - ["sourceID"] = sprite.m_id, - ["sourceTarget"] = sprite.m_id, - }) - end - end - -- Check creature's EA - local applyCondition = sprite.m_typeAI.m_EnemyAlly == 2 -- PC - -- - if sprite:getLocalInt("cdtweaksCowledWizards") == 0 then - if applyCondition then - apply() - end - else - if applyCondition then - -- do nothing - else - -- Mark the creature as 'condition removed' - sprite:setLocalInt("cdtweaksCowledWizards", 0) - -- - sprite:applyEffect({ - ["effectID"] = 321, -- Remove effects by resource - ["res"] = "GTCOWENF", - ["sourceID"] = sprite.m_id, - ["sourceTarget"] = sprite.m_id, - }) - end - end -end) From d0c83d518e0d671ed49ccb05c84307689117f8b8 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Mon, 28 Oct 2024 12:21:21 +0100 Subject: [PATCH 4/6] Create cowled_wizards.lua --- cdtweaks/luke/lua/tweaks/cowled_wizards.lua | 121 ++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 cdtweaks/luke/lua/tweaks/cowled_wizards.lua diff --git a/cdtweaks/luke/lua/tweaks/cowled_wizards.lua b/cdtweaks/luke/lua/tweaks/cowled_wizards.lua new file mode 100644 index 00000000..67cdba6b --- /dev/null +++ b/cdtweaks/luke/lua/tweaks/cowled_wizards.lua @@ -0,0 +1,121 @@ +--[[ ++----------------------------------------+ +| cdtweaks, more sensible cowled wizards | ++----------------------------------------+ +--]] + +-- set a GLOBAL var when a PC casts a wizard spell and is in Athkatla -- + +GTCOWENF = { + + ["typeMutator"] = function(context) + local actionSources = { + [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, + [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.decodeSource] then + return + end + end, + + ["projectileMutator"] = function(context) + local actionSources = { + [EEex_Projectile_DecodeSource.CGameSprite_Spell] = true, + [EEex_Projectile_DecodeSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_DecodeSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.decodeSource] then + return + end + -- + local originatingSprite = context["originatingSprite"] -- CGameSprite + -- + local areaCheck = EEex_Trigger_ParseConditionalString('OR(7) \n AreaCheck("AR0020") AreaCheck("AR0300") AreaCheck("AR0400") AreaCheck("AR0500") AreaCheck("AR0700") AreaCheck("AR0900") AreaCheck("AR1000")') + -- + local setGlobal = EEex_Action_ParseResponseString('SetGlobal("gt_CowledWizardsTriggered","GLOBAL",1)') + -- + local spellResRef = originatingSprite.m_curAction.m_string1.m_pchData:get() + if spellResRef == "" then + spellResRef = GT_Utility_DecodeSpell(originatingSprite.m_curAction.m_specificID) + end + -- + local spellHeader = EEex_Resource_Demand(spellResRef, "SPL") + -- + if spellHeader.itemType == 1 and areaCheck:evalConditionalAsAIBase(originatingSprite) then -- if wizard spell and in Athkatla ... + setGlobal:executeResponseAsAIBaseInstantly(originatingSprite) + end + -- + setGlobal:free() + areaCheck:free() + end, + + ["effectMutator"] = function(context) + local actionSources = { + [EEex_Projectile_AddEffectSource.CGameSprite_Spell] = true, + [EEex_Projectile_AddEffectSource.CGameSprite_SpellPoint] = true, + [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpell] = true, + [EEex_Projectile_AddEffectSource.CGameAIBase_ForceSpellPoint] = true, + } + -- + if not actionSources[context.addEffectSource] then + return + end + end, +} + +-- + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) then + return + end + -- internal function that applies the actual condition + local apply = function() + -- Mark the creature as 'condition applied' + sprite:setLocalInt("cdtweaksCowledWizards", 1) + -- + local effectCodes = { + {["op"] = 321}, -- Remove effects by resource + {["op"] = 408}, -- Projectile mutator + } + -- + for _, attributes in ipairs(effectCodes) do + sprite:applyEffect({ + ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), + ["durationType"] = 9, + ["res"] = "GTCOWENF", + ["m_sourceRes"] = "GTCOWENF", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + -- Check creature's EA + local applyCondition = sprite.m_typeAI.m_EnemyAlly == 2 -- PC + -- + if sprite:getLocalInt("cdtweaksCowledWizards") == 0 then + if applyCondition then + apply() + end + else + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("cdtweaksCowledWizards", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "GTCOWENF", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end +end) From 50b9a61ba600c415286699c80340afd3f30269de Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 21 Dec 2024 18:50:05 +0100 Subject: [PATCH 5/6] Update cowled_wizards.lua --- cdtweaks/luke/lua/tweaks/cowled_wizards.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cdtweaks/luke/lua/tweaks/cowled_wizards.lua b/cdtweaks/luke/lua/tweaks/cowled_wizards.lua index 67cdba6b..ea1ae75d 100644 --- a/cdtweaks/luke/lua/tweaks/cowled_wizards.lua +++ b/cdtweaks/luke/lua/tweaks/cowled_wizards.lua @@ -37,8 +37,6 @@ GTCOWENF = { -- local areaCheck = EEex_Trigger_ParseConditionalString('OR(7) \n AreaCheck("AR0020") AreaCheck("AR0300") AreaCheck("AR0400") AreaCheck("AR0500") AreaCheck("AR0700") AreaCheck("AR0900") AreaCheck("AR1000")') -- - local setGlobal = EEex_Action_ParseResponseString('SetGlobal("gt_CowledWizardsTriggered","GLOBAL",1)') - -- local spellResRef = originatingSprite.m_curAction.m_string1.m_pchData:get() if spellResRef == "" then spellResRef = GT_Utility_DecodeSpell(originatingSprite.m_curAction.m_specificID) @@ -47,10 +45,9 @@ GTCOWENF = { local spellHeader = EEex_Resource_Demand(spellResRef, "SPL") -- if spellHeader.itemType == 1 and areaCheck:evalConditionalAsAIBase(originatingSprite) then -- if wizard spell and in Athkatla ... - setGlobal:executeResponseAsAIBaseInstantly(originatingSprite) + EEex_GameState_SetGlobalInt("gt_CowledWizardsTriggered", 1) end -- - setGlobal:free() areaCheck:free() end, From bea631a7ec826ad4fd32c7f37bd7fd4f352e57fe Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sun, 22 Dec 2024 22:52:16 +0100 Subject: [PATCH 6/6] Update cowled_wizards.tph --- cdtweaks/lib/cowled_wizards.tph | 1 + 1 file changed, 1 insertion(+) diff --git a/cdtweaks/lib/cowled_wizards.tph b/cdtweaks/lib/cowled_wizards.tph index 818a3fae..32508e9c 100644 --- a/cdtweaks/lib/cowled_wizards.tph +++ b/cdtweaks/lib/cowled_wizards.tph @@ -48,5 +48,6 @@ BEGIN BUT_ONLY_IF_IT_CHANGES END // lua + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Utility" "sourceFileSpec" = "cdtweaks\luke\lua\utility\decode_spell.lua" "destRes" = "m_gtutil" END LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\tweaks\cowled_wizards.lua" "destRes" = "m_gttwks" END END \ No newline at end of file