Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New component: More Stoneskin feedback #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdtweaks/languages/english/stoneskin.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@0 = ": (Stoneskin): "
@1 = " skin(s) left"
2 changes: 2 additions & 0 deletions cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -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)]"

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down
2 changes: 2 additions & 0 deletions cdtweaks/languages/italian/stoneskin.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@0 = ": (Pelle di Pietra): "
@1 = " pelle/i rimanente/i"
2 changes: 2 additions & 0 deletions cdtweaks/languages/italian/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -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)]"

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down
18 changes: 18 additions & 0 deletions cdtweaks/lib/comp_3430.tpa
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions cdtweaks/lib/stoneskin.tph
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions cdtweaks/luke/lua/tool/find_greatest_int.lua
Original file line number Diff line number Diff line change
@@ -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
75 changes: 75 additions & 0 deletions cdtweaks/luke/lua/tweaks/stoneskin.lua
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,12 @@ <h3> <a id="contents_convenience" name="contents_convenience"></a>Convenience Tw
<li><em>Mage, priest, and innate spells</em> - as above, but adds spells traditionally in the innate and kit ability space such as Lay on Hands or Boon of Lathander</li>
<li><em>All spells</em> - 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 &quot;just 10 damage&quot;. It is, however, the best way to guarantee that all spells from mods are caught</li>
</ul>

<p> <strong>More Stoneskin Feedback</strong><br />
<em><abbr title="Baldur's Gate: Enhanced Edition">EEex</abbr></em></p>
<p>
Whenever a stoneskinned creature gets hit, this component will notify the player about the number of skins left.
</p>
</div>
<div class="ribbon_rectangle_h3">
<h3> <a id="contents_npc" name="contents_npc"></a>Joinable <abbr title="Non-Player Character">NPC</abbr> Tweaks </h3>
Expand Down
14 changes: 14 additions & 0 deletions cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -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~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down