From 9d8013636d1623cb45115ac36ed3debf5b22925d Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 16 Nov 2024 18:10:08 +0100 Subject: [PATCH] More Stoneskin feedback --- cdtweaks/languages/english/stoneskin.tra | 2 + cdtweaks/languages/english/weidu.tra | 2 + cdtweaks/languages/italian/stoneskin.tra | 2 + cdtweaks/languages/italian/weidu.tra | 2 + cdtweaks/lib/comp_3430.tpa | 18 +++++ cdtweaks/lib/stoneskin.tph | 24 +++++++ cdtweaks/luke/lua/tool/find_greatest_int.lua | 9 +++ cdtweaks/luke/lua/tweaks/stoneskin.lua | 75 ++++++++++++++++++++ cdtweaks/readme-cdtweaks.html | 6 ++ cdtweaks/setup-cdtweaks.tp2 | 14 ++++ 10 files changed, 154 insertions(+) create mode 100644 cdtweaks/languages/english/stoneskin.tra create mode 100644 cdtweaks/languages/italian/stoneskin.tra create mode 100644 cdtweaks/lib/comp_3430.tpa create mode 100644 cdtweaks/lib/stoneskin.tph create mode 100644 cdtweaks/luke/lua/tool/find_greatest_int.lua create mode 100644 cdtweaks/luke/lua/tweaks/stoneskin.lua diff --git a/cdtweaks/languages/english/stoneskin.tra b/cdtweaks/languages/english/stoneskin.tra new file mode 100644 index 0000000..2928c64 --- /dev/null +++ b/cdtweaks/languages/english/stoneskin.tra @@ -0,0 +1,2 @@ +@0 = ": (Stoneskin): " +@1 = " skin(s) left" \ No newline at end of file diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 06daf4e..fc56df8 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)~ +@343000 = "More Stoneskin Feedback [Luke (EEex)]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/languages/italian/stoneskin.tra b/cdtweaks/languages/italian/stoneskin.tra new file mode 100644 index 0000000..db526f1 --- /dev/null +++ b/cdtweaks/languages/italian/stoneskin.tra @@ -0,0 +1,2 @@ +@0 = ": (Pelle di Pietra): " +@1 = " pelle/i rimanente/i" \ No newline at end of file diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 738ea95..2c07315 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~ +@343000 = "Pelle di Pietra: rendi visibile il numero di pelli rimaste [Luke (EEex)]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/lib/comp_3430.tpa b/cdtweaks/lib/comp_3430.tpa new file mode 100644 index 0000000..33cc12e --- /dev/null +++ b/cdtweaks/lib/comp_3430.tpa @@ -0,0 +1,18 @@ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +///// \\\\\////\\\\//// +///// More Stoneskin feedback \\\\\ +///// \\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\//// + +WITH_SCOPE BEGIN + INCLUDE "cdtweaks\luke\misc.tph" + INCLUDE "cdtweaks\ardanis\functions.tph" + // + INCLUDE "cdtweaks\lib\stoneskin.tph" + // + WITH_TRA "cdtweaks\languages\english\stoneskin.tra" "cdtweaks\languages\%LANGUAGE%\stoneskin.tra" BEGIN + LAF "MORE_STONESKIN_FEEDBACK" END + END +END \ No newline at end of file diff --git a/cdtweaks/lib/stoneskin.tph b/cdtweaks/lib/stoneskin.tph new file mode 100644 index 0000000..428c847 --- /dev/null +++ b/cdtweaks/lib/stoneskin.tph @@ -0,0 +1,24 @@ +DEFINE_ACTION_FUNCTION "MORE_STONESKIN_FEEDBACK" +BEGIN + OUTER_SET "feedback_strref_stoneskin" = RESOLVE_STR_REF (@0) + OUTER_SET "feedback_strref_skins_left" = RESOLVE_STR_REF (@1) + // + WITH_SCOPE BEGIN + CREATE "spl" "gtstnskn" + COPY_EXISTING "gtstnskn.spl" "override" + WRITE_LONG NAME1 "-1" + WRITE_LONG UNIDENTIFIED_DESC "-1" + WRITE_LONG DESC "-1" + WRITE_LONG NAME2 "-1" + WRITE_LONG 0x18 (BIT14 BOR BIT25) // ignore dead/wild magic, castable when silenced + WRITE_SHORT 0x1C 4 // type: innate + WRITE_LONG 0x34 1 // level + // + LPF "ADD_SPELL_HEADER" INT_VAR "target" = 5 "range" = 30 END + // + LPF "ADD_SPELL_EFFECT" INT_VAR "opcode" = 402 "target" = 1 STR_VAR "resource" = "%DEST_RES%" END // invoke lua + BUT_ONLY + END + // + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\tweaks\stoneskin.lua" "destRes" = "m_gttwks" END +END \ No newline at end of file diff --git a/cdtweaks/luke/lua/tool/find_greatest_int.lua b/cdtweaks/luke/lua/tool/find_greatest_int.lua new file mode 100644 index 0000000..21727bb --- /dev/null +++ b/cdtweaks/luke/lua/tool/find_greatest_int.lua @@ -0,0 +1,9 @@ +-- given an array of integers, return the greatest one -- + +function GT_LuaTool_FindGreatestInt(array) + local greatest = array[1] + for i = 2, #array do + greatest = math.max(greatest, array[i]) + end + return greatest +end diff --git a/cdtweaks/luke/lua/tweaks/stoneskin.lua b/cdtweaks/luke/lua/tweaks/stoneskin.lua new file mode 100644 index 0000000..34fc6ac --- /dev/null +++ b/cdtweaks/luke/lua/tweaks/stoneskin.lua @@ -0,0 +1,75 @@ +--[[ ++-------------------------------------------------------------------------------------------------------+ +| cdtweaks: whenever a stoneskinned creature gets hit, inform the player about the number of skins left | ++-------------------------------------------------------------------------------------------------------+ +--]] + +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("gtDisplayStoneskinsLeft", 1) + -- + local effectCodes = { + {["op"] = 0x141}, -- Remove effects by resource (321) + {["op"] = 0xE8}, -- Cast spell on condition (232) + } + -- + for _, attributes in ipairs(effectCodes) do + sprite:applyEffect({ + ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), + ["durationType"] = 1, + ["res"] = "GTSTNSKN", + ["m_sourceRes"] = "GTSTNSKN", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + -- Check if the creature is stoneskinned + local applyCondition = sprite.m_derivedStats.m_nStoneSkins > 0 -- at least one skin + -- + if sprite:getLocalInt("gtDisplayStoneskinsLeft") == 0 then + if applyCondition then + apply() + end + else + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("gtDisplayStoneskinsLeft", 0) + -- + sprite:applyEffect({ + ["effectID"] = 0x141, -- Remove effects by resource (321) + ["res"] = "GTSTNSKN", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end +end) + +-- op402 listener -- + +function GTSTNSKN(CGameEffect, CGameSprite) + local m_lHitter = EEex_GameObject_Get(CGameSprite.m_lHitter.m_Instance) -- CGameSprite + -- sanity check + if m_lHitter ~= nil then + local skins = {} + -- ignore non-weapon attacks + if m_lHitter.m_targetId == CGameSprite.m_id then + EEex_Utility_IterateCPtrList(CGameSprite.m_timedEffectList, function(effect) + if effect.m_effectId == 0xDA then -- Stoneskin effect (218) + table.insert(skins, effect.m_effectAmount) + end + end) + -- + Infinity_DisplayString(CGameSprite:getName() .. Infinity_FetchString(%feedback_strref_stoneskin%) .. GT_LuaTool_FindGreatestInt(skins) .. Infinity_FetchString(%feedback_strref_skins_left%)) + end + end +end diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index 84c933f..7310c95 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 Stoneskin Feedback
    + EEex

    +

    + Whenever a stoneskinned creature gets hit, this component will notify the player about the number of skins left. +

    Joinable NPC Tweaks

    diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 5e97fb6..31c0835 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 Stoneskin feedback \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ + +BEGIN @343000 DESIGNATED 3430 +GROUP @4 +REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet iwdee~ @25 +REQUIRE_PREDICATE MOD_IS_INSTALLED "EEex.tp2" 0 @29 +LABEL ~cd_tweaks_more_stoneskin_feedback~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\