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: Self Concealment #114

Open
wants to merge 4 commits 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
7 changes: 7 additions & 0 deletions cdtweaks/languages/english/self_concealment.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@0 = "Self Concealment"

@10 = "Target Concealed (10%)"
@11 = "Target Concealed (20%)"
@12 = "Target Concealed (30%)"
@13 = "Target Concealed (40%)"
@14 = "Target Concealed (50%)"
10 changes: 10 additions & 0 deletions cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,13 @@ Use Baldur.lua options: a7_interval_ini
@504000 = ~Allow Yeslick to Use Axes~

@505000 = ~Ensure Shar-Teel Doesn't Die in the Original Challenge~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// NWN-ish feats collection \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

@600210 = "Self Concealment class feat for Monks [Luke (EEex)]"
7 changes: 7 additions & 0 deletions cdtweaks/languages/italian/self_concealment.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@0 = "Auto-Occultamento"

@10 = "Bersaglio Occultato (10%)"
@11 = "Bersaglio Occultato (20%)"
@12 = "Bersaglio Occultato (30%)"
@13 = "Bersaglio Occultato (40%)"
@14 = "Bersaglio Occultato (50%)"
10 changes: 10 additions & 0 deletions cdtweaks/languages/italian/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,13 @@ Usa opzioni di Baldur.lua: a7_interval_ini
@504000 = ~Permettere a Yeslick di usare le asce~

@505000 = ~Assicura che Shar-Teel non muoia nella sfida iniziale~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// Raccolta di talenti in stile NWN \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

@600210 = "Aggiungi talento di classe Auto-Occultamento per i Monaci [Luke (EEex)]"
17 changes: 17 additions & 0 deletions cdtweaks/lib/comp_6210.tpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
///// \\\\\////\\\\////
///// Self Concealment class feat for Monks \\\\\
///// \\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////

WITH_SCOPE BEGIN
INCLUDE "cdtweaks\luke\misc.tph"
//
INCLUDE "cdtweaks\lib\self_concealment.tph"
//
WITH_TRA "cdtweaks\languages\english\self_concealment.tra" "cdtweaks\languages\%LANGUAGE%\self_concealment.tra" BEGIN
LAF "SELF_CONCEALMENT" END
END
END
31 changes: 31 additions & 0 deletions cdtweaks/lib/self_concealment.tph
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DEFINE_ACTION_FUNCTION "SELF_CONCEALMENT"
BEGIN
LAF "GT_ADD_SPELL"
INT_VAR
"level" = 8
"type" = 4
STR_VAR
"idsName" = "MONK_SELF_CONCEALMENT"
RET
"MONK_SELF_CONCEALMENT" = "resName"
END
// Listener: run 'func' each time a sprite has finished evaluating its effects
WITH_SCOPE BEGIN
ACTION_TO_LOWER "MONK_SELF_CONCEALMENT"
//
COPY "cdtweaks\luke\bam\class\self_concealment.bam" "override\%MONK_SELF_CONCEALMENT%d.bam"
LAF "ADD_STATDESC_ENTRY" INT_VAR "description" = RESOLVE_STR_REF (@0) STR_VAR "bam_file" = "%MONK_SELF_CONCEALMENT%d" RET "feedback_icon" = "index" END
//
OUTER_SET "strref_10" = RESOLVE_STR_REF (@10)
OUTER_SET "strref_20" = RESOLVE_STR_REF (@11)
OUTER_SET "strref_30" = RESOLVE_STR_REF (@12)
OUTER_SET "strref_40" = RESOLVE_STR_REF (@13)
OUTER_SET "strref_50" = RESOLVE_STR_REF (@14)
//
LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Class/Kit Abilities" "sourceFileSpec" = "cdtweaks\luke\lua\class\self_concealment.lua" "destRes" = "m_gtspcl" END
END
//
ACTION_IF !(FILE_EXISTS_IN_GAME "m_gttbls.lua") BEGIN
COPY "cdtweaks\luke\lua\m_gttbls.lua" "override"
END
END
Binary file added cdtweaks/luke/bam/class/self_concealment.bam
Binary file not shown.
99 changes: 99 additions & 0 deletions cdtweaks/luke/lua/class/self_concealment.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
--[[
+---------------------------------------------------------+
| cdtweaks, NWN-ish Self Concealment class feat for Monks |
+---------------------------------------------------------+
--]]

local cdtweaks_MonkSelfConcealment_FeedbackStrref = {
[10] = %strref_10%,
[20] = %strref_20%,
[30] = %strref_30%,
[40] = %strref_40%,
[50] = %strref_50%,
}

-- Apply ability --

EEex_Opcode_AddListsResolvedListener(function(sprite)
-- Sanity check
if not EEex_GameObject_IsSprite(sprite) then
return
end
-- internal function that applies the actual feat (translucency + icon)
local apply = function(percentage)
-- Mark the creature as 'feat applied'
sprite:setLocalInt("cdtweaksSelfConcealment", 1)
-- Update tracking var
sprite:setLocalInt("gtSelfConcealmentAmount", percentage)
--
local effectCodes = {
{["op"] = 321, ["res"] = "%MONK_SELF_CONCEALMENT%"}, -- Remove effects by resource
{["op"] = 66, ["p1"] = math.floor((percentage / 100) * 255)}, -- Translucency
{["op"] = 142, ["p2"] = %feedback_icon%}, -- Display portrait icon
}
--
for _, attributes in ipairs(effectCodes) do
sprite:applyEffect({
["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"),
["effectAmount"] = attributes["p1"] or 0,
["dwFlags"] = attributes["p2"] or 0,
["durationType"] = 9,
["res"] = attributes["res"] or "",
["m_sourceRes"] = "%MONK_SELF_CONCEALMENT%",
["sourceID"] = sprite.m_id,
["sourceTarget"] = sprite.m_id,
})
end
end
-- Check creature's class / level / dexterity
local spriteClassStr = GT_Resource_IDSToSymbol["class"][sprite.m_typeAI.m_Class]
-- since ``EEex_Opcode_AddListsResolvedListener`` is running after the effect lists have been evaluated, ``m_bonusStats`` has already been added to ``m_derivedStats`` by the engine
local spriteLevel1 = sprite.m_derivedStats.m_nLevel1
local spriteDEX = sprite.m_derivedStats.m_nDEX
-- compute concealment percentage
local percentage = math.min(math.floor((spriteLevel1 - 10) / 5) + 1, 5) * 10 -- from 10 to 50
-- lvl 10+ monks; 16+ DEX
local applyAbility = spriteClassStr == "MONK" and spriteLevel1 >= 10 and spriteDEX >= 16
--
if sprite:getLocalInt("cdtweaksSelfConcealment") == 0 then
if applyAbility then
apply(percentage)
end
else
if applyAbility then
if sprite:getLocalInt("gtSelfConcealmentAmount") ~= percentage then
apply(percentage)
end
else
-- Mark the creature as 'feat removed'
sprite:setLocalInt("cdtweaksSelfConcealment", 0)
--
sprite:applyEffect({
["effectID"] = 321, -- Remove effects by resource
["res"] = "%MONK_SELF_CONCEALMENT%",
["sourceID"] = sprite.m_id,
["sourceTarget"] = sprite.m_id,
})
end
end
end)

-- Core listener --

EEex_Sprite_AddBlockWeaponHitListener(function(args)
local targetSprite = args.targetSprite -- CGameSprite
--
if targetSprite:getLocalInt("cdtweaksSelfConcealment") == 1 then
if math.random(100) <= targetSprite:getLocalInt("gtSelfConcealmentAmount") then -- 1d100 roll
-- display some feedback
targetSprite:applyEffect({
["effectID"] = 139, -- Display string
["effectAmount"] = cdtweaks_MonkSelfConcealment_FeedbackStrref[targetSprite:getLocalInt("gtSelfConcealmentAmount")],
["sourceID"] = targetSprite.m_id,
["sourceTarget"] = targetSprite.m_id,
})
-- block base weapon damage + on-hit effects
return true
end
end
end)
36 changes: 36 additions & 0 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,42 @@ <h3> <a id="contents_npc" name="contents_npc"></a>Joinable <abbr title="Non-Play
<p> Internally, Dorn's sword (Rancor +1) relies upon scripting. As modders know, items should not rely upon scripting to work correctly, since it is unreliable and may quickly become messy.
This component simply removes scripting from this weapon (the upshot of which is that the weapon should become a bit more reliable). </p>
</div>

<div class="ribbon_rectangle_h3">
<h3> <a id="NWN-ish_feats" name="NWN-ish_feats"></a>NWN-ish Feats Collection </h3>
</div>
<div class="ribbon_triangle_h3-l"></div>
<div class="ribbon_triangle_h3-r"></div>
<div class="section">
<p> Components in this category are inspired from <a href="https://nwn.beamdog.com/">NWN</a> and are aimed at providing new class/kit abilities.</p>

<p> <strong>Self Concealment class feat for Monks [Luke]</strong><br />
<em><abbr title="Enhanced Edition">EEex</abbr></em></p>
<p>
This component aims at giving Monks the passive feat Self Concealment.
</p>
<p>
Concealment is a defensive trait that causes attacks to miss a certain percent of the time.
So someone attacking a target with 25% concealment will miss a quarter of the time due to the concealment.
This is applied independently of the attack roll; both the attack roll and the concealment roll are made for each attack, and only if the attacker succeeds at both the attack is successful.
Concealment rolls are not themselves displayed on the screen, but if the roll fails, the attacker is told the attack failed because of concealment and is told the amount of concealment.
</p>

<p>
Notes:
<ul>
<li>Use: automatic, but only available to Monks.</li>
<li>
Concealment does not stack. Only the highest concealment is used. The maximum concealment that a monk can have is 50% (level 30+).
<ul>
<li>Starts with 10% at level 10, and gains +10% every 5 levels thereafter.</li>
<li>On top of that, the monk must also have at least 16 Dexterity.</li>
</ul>
</li>
</ul>
</p>
</div>

<div class="ribbon_rectangle_h2"> <a id="Contact" name="Contact"></a>
<h2> Contact Information </h2>
</div>
Expand Down
23 changes: 23 additions & 0 deletions cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -4903,3 +4903,26 @@ GROUP @0
REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet~ @25
REQUIRE_PREDICATE MOD_IS_INSTALLED "EEex.tp2" 0 @29
LABEL ~cd_tweaks_dorns_sword~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// NWN-ish feats collection \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
///// \\\\\////\\\\////
///// Self Concealment class feat for Monks \\\\\
///// \\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////

BEGIN @600210 DESIGNATED 6210
GROUP @30
REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet iwdee~ @25
REQUIRE_PREDICATE MOD_IS_INSTALLED "EEex.tp2" 0 @29
REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/self_concealment.tra~ @7
LABEL ~cd_tweaks_nwn_self_concealment~