-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from 4Luke4/stoneskin
New component: More Stoneskin feedback
- Loading branch information
Showing
10 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@0 = ": (Stoneskin): " | ||
@1 = " skin(s) left" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@0 = ": (Pelle di Pietra): " | ||
@1 = " pelle/i rimanente/i" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters