Skip to content

Commit

Permalink
Merge pull request #111 from 4Luke4/blind_fight
Browse files Browse the repository at this point in the history
New component: Blind Fight
  • Loading branch information
CamDawg authored Jan 10, 2025
2 parents 794e430 + 000a0e4 commit 0c2125a
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 2 deletions.
1 change: 1 addition & 0 deletions cdtweaks/languages/english/blind_fight.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@0 = "Blind Fight"
2 changes: 2 additions & 0 deletions cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,5 @@ Use Baldur.lua options: a7_interval_ini
@615000 = "Circle Kick class feat for Monks [Luke]"

@616000 = "NWN-ish Barbarian Rage [Luke]"

@618000 = "Blind Fight innate feat for Berserkers [Luke (EEex)]"
1 change: 1 addition & 0 deletions cdtweaks/languages/italian/blind_fight.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@0 = "Combattere alla Cieca"
4 changes: 3 additions & 1 deletion cdtweaks/languages/italian/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -733,4 +733,6 @@ Usa opzioni di Baldur.lua: a7_interval_ini

@615000 = "Aggiungi talento di classe Calcio Rotante per i Monaci [Luke]"

@616000 = "Ira Barbarica in stile NWN [Luke]"
@616000 = "Ira Barbarica in stile NWN [Luke]"

@618000 = "Aggiungi talento innato Combattere alla Cieca per i Berserker [Luke (EEex)]"
26 changes: 26 additions & 0 deletions cdtweaks/lib/blind_fight.tph
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
DEFINE_ACTION_FUNCTION "BLIND_FIGHT"
BEGIN
LAF "GT_ADD_SPELL"
INT_VAR
"type" = 3
STR_VAR
"idsName" = "INNATE_BLIND_FIGHT"
RET
"INNATE_BLIND_FIGHT" = "resName"
END
//
WITH_SCOPE BEGIN
ACTION_TO_LOWER "INNATE_BLIND_FIGHT"
COPY "cdtweaks\luke\bam\innate\blind_fight.bam" "override\%INNATE_BLIND_FIGHT%d.bam"
END
//
WITH_SCOPE BEGIN
LAF "ADD_STATDESC_ENTRY" INT_VAR "description" = RESOLVE_STR_REF (@0) STR_VAR "bam_file" = "%INNATE_BLIND_FIGHT%D" RET "feedback_icon" = "index" END
// Listener: run 'func' each time a sprite has finished evaluating its effects
LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Innate Abilities" "sourceFileSpec" = "cdtweaks\luke\lua\innate\blind_fight.lua" "destRes" = "m_gtspin" END
//
ACTION_IF !(FILE_EXISTS_IN_GAME "m_gttbls.lua") BEGIN
COPY "cdtweaks\luke\lua\m_gttbls.lua" "override"
END
END
END
17 changes: 17 additions & 0 deletions cdtweaks/lib/comp_6180.tpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
///// /////
///// NWN-ish Blind Fight \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////

WITH_SCOPE BEGIN
INCLUDE "cdtweaks\luke\misc.tph"
//
INCLUDE "cdtweaks\lib\blind_fight.tph"
//
WITH_TRA "cdtweaks\languages\english\blind_fight.tra" "cdtweaks\languages\%LANGUAGE%\blind_fight.tra" BEGIN
LAF "BLIND_FIGHT" END
END
END
Binary file added cdtweaks/luke/bam/innate/blind_fight.bam
Binary file not shown.
69 changes: 69 additions & 0 deletions cdtweaks/luke/lua/innate/blind_fight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- cdtweaks, Blind Fight innate feat for Berserkers --

EEex_Opcode_AddListsResolvedListener(function(sprite)
-- Sanity check
if not EEex_GameObject_IsSprite(sprite) then
return
end
-- internal function that applies the actual bonus
local apply = function()
-- Mark the creature as 'bonus applied'
sprite:setLocalInt("gtInnateBlindFight", 1)
--
local effectCodes = {
{["op"] = 321, ["res"] = "%INNATE_BLIND_FIGHT%"}, -- Remove effects by resource
{["op"] = 284, ["p1"] = 4}, -- Melee THAC0 bonus (+4)
{["op"] = 0, ["p1"] = 4}, -- AC bonus (+4)
{["op"] = 142, ["p2"] = %feedback_icon%}, -- Display portrait icon
}
--
for _, attributes in ipairs(effectCodes) do
sprite:applyEffect({
["effectID"] = attributes["op"] or -1,
["effectAmount"] = attributes["p1"] or 0,
["dwFlags"] = attributes["p2"] or 0,
["durationType"] = 9,
["res"] = attributes["res"] or "",
["m_sourceRes"] = "%INNATE_BLIND_FIGHT%",
["sourceID"] = sprite.m_id,
["sourceTarget"] = sprite.m_id,
})
end
end
-- Check creature's kit / state
local spriteFlags = sprite.m_baseStats.m_flags
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 spriteKitStr = GT_Resource_IDSToSymbol["kit"][sprite.m_derivedStats.m_nKit]
local spriteLevel1 = sprite.m_derivedStats.m_nLevel1
local spriteLevel2 = sprite.m_derivedStats.m_nLevel2
local spriteGeneralState = sprite.m_derivedStats.m_generalState
-- single/multi/(complete)dual berserkers
local applyAbility = EEex_IsBitSet(spriteGeneralState, 0x12) -- STATE_BLIND
and spriteKitStr == "BERSERKER"
and (spriteClassStr == "FIGHTER"
or (spriteClassStr == "FIGHTER_MAGE" and (EEex_IsBitUnset(spriteFlags, 0x3) or spriteLevel2 > spriteLevel1))
or (spriteClassStr == "FIGHTER_CLERIC" and (EEex_IsBitUnset(spriteFlags, 0x3) or spriteLevel2 > spriteLevel1))
or (spriteClassStr == "FIGHTER_THIEF" and (EEex_IsBitUnset(spriteFlags, 0x3) or spriteLevel2 > spriteLevel1))
or (spriteClassStr == "FIGHTER_DRUID" and (EEex_IsBitUnset(spriteFlags, 0x3) or spriteLevel2 > spriteLevel1)))
--
if sprite:getLocalInt("gtInnateBlindFight") == 0 then
if applyAbility then
apply()
end
else
if applyAbility then
-- do nothing
else
-- Mark the creature as 'bonus removed'
sprite:setLocalInt("gtInnateBlindFight", 0)
--
sprite:applyEffect({
["effectID"] = 321, -- Remove effects by resource
["res"] = "%INNATE_BLIND_FIGHT%",
["sourceID"] = sprite.m_id,
["sourceTarget"] = sprite.m_id,
})
end
end
end)
14 changes: 14 additions & 0 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,20 @@ <h3> <a id="NWN-ish_feats" name="NWN-ish_feats"></a>NWN-ish Feats Collection </h
</ul>
<p>As a result, neutral-aligned Clerics are unaffected by this mechanic. </p>

<p> <strong>Blind Fight class feat for Berserkers [Luke]</strong><br />
<em><abbr title="Enhanced Edition">EEex</abbr></em></p>
<p>
This component aims at giving Berserkers the Blind Fight feat.
</p>
<p>
This feat grants the character the ability to fight well, even if blinded. As a result, whenever the character gets blinded, it does not suffer from the 4 THAC0 / AC penalty.
</p>
<p>
Notes:
<ul>
<li>This feat can only negate the melee THAC0 penalty. If the character is wielding a ranged weapon, only the AC penalty will be negated.</li>
</ul>
</p>
</div>


Expand Down
14 changes: 13 additions & 1 deletion cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -4974,5 +4974,17 @@ REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29
REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/circle_kick.tra~ @7
LABEL ~cd_tweaks_circle_kick~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// Blind Fight innate feat for Berserkers \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\


BEGIN @618000 DESIGNATED 6180
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%/blind_fight.tra~ @7
LABEL ~cd_tweaks_nwn_blind_fight~

0 comments on commit 0c2125a

Please sign in to comment.