From 07dd887de01ba678e69384693aebf7a6e3efb30e Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Wed, 27 Nov 2024 17:17:37 +0100 Subject: [PATCH 1/3] Better Infravision --- cdtweaks/languages/english/infravision.tra | 1 + cdtweaks/languages/english/weidu.tra | 2 +- cdtweaks/languages/italian/infravision.tra | 1 + cdtweaks/languages/italian/weidu.tra | 2 + cdtweaks/lib/comp_2680.tpa | 24 ++++--- cdtweaks/lib/infravision.tph | 16 +++++ .../luke/bam/rule_changes/no_infravision.bam | Bin 0 -> 821 bytes cdtweaks/luke/lua/m_gttbls.lua | 2 +- .../luke/lua/rule_changes/infravision.lua | 67 ++++++++++++++++++ cdtweaks/readme-cdtweaks.html | 19 ++--- cdtweaks/setup-cdtweaks.tp2 | 19 ++--- 11 files changed, 116 insertions(+), 37 deletions(-) create mode 100644 cdtweaks/languages/english/infravision.tra create mode 100644 cdtweaks/languages/italian/infravision.tra create mode 100644 cdtweaks/lib/infravision.tph create mode 100644 cdtweaks/luke/bam/rule_changes/no_infravision.bam create mode 100644 cdtweaks/luke/lua/rule_changes/infravision.lua diff --git a/cdtweaks/languages/english/infravision.tra b/cdtweaks/languages/english/infravision.tra new file mode 100644 index 00000000..af6d452e --- /dev/null +++ b/cdtweaks/languages/english/infravision.tra @@ -0,0 +1 @@ +@0 = "Lack of Infravision" \ No newline at end of file diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 06daf4ee..f522721c 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -463,7 +463,7 @@ The uninstall messages above are normal and expected. @267000 = "Dual-Wield feat for Rangers [Luke]" -@268000 = ~"Force" the Archer kit to use bows [Luke]~ +@268000 = ~PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability [Luke (EEex)]~ @269000 = "NWN-ish Armor vs. Dexterity [Luke]" diff --git a/cdtweaks/languages/italian/infravision.tra b/cdtweaks/languages/italian/infravision.tra new file mode 100644 index 00000000..fa882907 --- /dev/null +++ b/cdtweaks/languages/italian/infravision.tra @@ -0,0 +1 @@ +@0 = "Senza Infravisione" \ No newline at end of file diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 738ea95a..59c1084f 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -416,6 +416,8 @@ o rimpiazzata da - un'altra facente parte di uno dei mods installati.~ @267000 = "Aggiungi talento Doppia-Presa per i Ranger [Luke]" +@268000 = "PnP: -4 ai tiri per colpire nelle aree buie (Dungeon) e di notte se non si ha l'Infravisione [Luke (EEex)]" + @269000 = "Armatura vs. Destrezza in stile NWN [Luke]" @270000 = "Aggiungi talento Tiro Difensivo per i ladri [Luke]" diff --git a/cdtweaks/lib/comp_2680.tpa b/cdtweaks/lib/comp_2680.tpa index d47a86f2..0b3f7af0 100644 --- a/cdtweaks/lib/comp_2680.tpa +++ b/cdtweaks/lib/comp_2680.tpa @@ -1,15 +1,17 @@ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -///// \\\\\ -///// "Force" the Archer kit to use bows \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ WITH_SCOPE BEGIN - INCLUDE "cdtweaks\ardanis\functions.tph" - INCLUDE "cdtweaks\lib\revised_archer.tph" - WITH_TRA "cdtweaks\languages\english\revised_archer.tra" "cdtweaks\languages\%LANGUAGE%\revised_archer.tra" BEGIN - LAF "REVISED_ARCHER" END + INCLUDE "cdtweaks\luke\misc.tph" + // + INCLUDE "cdtweaks\lib\infravision.tph" + // + WITH_TRA "cdtweaks\languages\english\infravision.tra" "cdtweaks\languages\%LANGUAGE%\infravision.tra" BEGIN + LAF "LACK_OF_INFRAVISION" END END END \ No newline at end of file diff --git a/cdtweaks/lib/infravision.tph b/cdtweaks/lib/infravision.tph new file mode 100644 index 00000000..3b8ae155 --- /dev/null +++ b/cdtweaks/lib/infravision.tph @@ -0,0 +1,16 @@ +DEFINE_ACTION_FUNCTION "LACK_OF_INFRAVISION" +BEGIN + WITH_SCOPE BEGIN + COPY "cdtweaks\luke\bam\rule_changes\no_infravision.bam" "override\gtrule02.bam" + END + // + WITH_SCOPE BEGIN + LAF "ADD_STATDESC_ENTRY" INT_VAR "description" = RESOLVE_STR_REF (@0) STR_VAR "bam_file" = "gtrule02" RET "feedback_icon" = "index" END + // Listener: run 'func' each time a sprite has finished evaluating its effects + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks (Rule Changes)" "sourceFileSpec" = "cdtweaks\luke\lua\rule_changes\infravision.lua" "destRes" = "m_gtrule" END + // + ACTION_IF !(FILE_EXISTS_IN_GAME "m_gttbls.lua") BEGIN + COPY "cdtweaks\luke\lua\m_gttbls.lua" "override" + END + END +END \ No newline at end of file diff --git a/cdtweaks/luke/bam/rule_changes/no_infravision.bam b/cdtweaks/luke/bam/rule_changes/no_infravision.bam new file mode 100644 index 0000000000000000000000000000000000000000..b5f4d95528c9b4a03e300388456ae1b907c8535f GIT binary patch literal 821 zcmV-51IqkDK}|zeF(4p<1ONbdoIO-qD5PN+e#Wk}rct}0Ez(?wv6O})qRcqtG!9{M z2vH7^bI!*Iks_m!rnIKfCMg%h#Eo*eF{ad%+;HW>g+sYeiv8bbH~;+K{D<#*pZ9&9 z=ly=8!K5|owOSQa_z6HK<13(1e)9iIxmPK7_)yM|4~&kEa`g80A}A;b{{H^(_4P$` zbTk|e2g1X{5fT!D*w|RKx3{CFrUpetMcCip$H~bFva_?Xy}gZsf&!@3YLu3iGS z3vRa?X0sVLH#exOt3!8pH*#}x5fc-G!oosiWo4nPtc>sb`}@({+)O-^$%MSTJm~d$ z))WvBfRT|A)=*zxkD;LN%3D9b_ zNKH*8hVV^HOoYW^Vcin5y1L4kii!$i$Hm1VEG&$5=j7xNdu(is8ZSm zxwyEP^$Q=tn4X>{rsTW4yhKY&3wiGC?J*`QDhg9mQ<#~VK~GN)`8PB)AUHS}gM)*J zkB=v=T0 zqm7LXl$4YZ!)P>;i{#JD%tUBtC~FpOqP^%aIXOumCCA0Z1>;1wiHQl~tgWq~s;Y{f z34UK+A38cZ=s|ULHRq(~q+gPglc||_Cp{+p6A=+X4x)+ZBz-Bz@bEDG93LO2XM)+* z*7n(F!cA%syv4;ubai!6BhfKEJ)OAX-_Fhs^NY8Qjg2@yKK}Gc`se!k8t3Qde7?K8 znmPfUhw?DL)XS@n literal 0 HcmV?d00001 diff --git a/cdtweaks/luke/lua/m_gttbls.lua b/cdtweaks/luke/lua/m_gttbls.lua index 6861a6c6..4de5ef09 100644 --- a/cdtweaks/luke/lua/m_gttbls.lua +++ b/cdtweaks/luke/lua/m_gttbls.lua @@ -7,7 +7,7 @@ GT_Resource_SymbolToIDS = {} EEex_GameState_AddInitializedListener(function() -- 2DA EEex_Utility_NewScope(function() - local resources = { "STRMOD", "STRMODEX", "DEXMOD", "STYLBONU", "SNEAKATT" } + local resources = { "STRMOD", "STRMODEX", "DEXMOD", "STYLBONU", "SNEAKATT", "RACEFEAT" } -- for _, v in ipairs(resources) do local data = EEex_Resource_Load2DA(v) diff --git a/cdtweaks/luke/lua/rule_changes/infravision.lua b/cdtweaks/luke/lua/rule_changes/infravision.lua new file mode 100644 index 00000000..850e3553 --- /dev/null +++ b/cdtweaks/luke/lua/rule_changes/infravision.lua @@ -0,0 +1,67 @@ +--[[ ++--------------------------------------------------------------------------------+ +| cdtweaks, lack of infravision (-4 to hit in darkness (Dungeon or night areas)) | ++--------------------------------------------------------------------------------+ +--]] + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) then + return + end + -- internal function that applies the actual penalty + local apply = function() + -- Mark the creature as 'condition applied' + sprite:setLocalInt("cdtweaksNoInfravision", 1) + -- + local effectCodes = { + {["op"] = 321, ["res"] = "GTRULE02"}, -- Remove effects by resource + {["op"] = 54, ["p1"] = -4}, -- Base thac0 bonus + {["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"] = "GTRULE02", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + -- Check creature's race / state + local spriteRaceStr = GT_Resource_IDSToSymbol["race"][sprite.m_typeAI.m_Race] + local racefeat = GT_Resource_2DA["racefeat"] + local hasInnateInfravision = (GT_LuaTool_KeyExists(GT_Resource_2DA, "racefeat", spriteRaceStr, "VALUE") and tonumber(racefeat[spriteRaceStr]["VALUE"]) == 1) and true or false + -- 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 spriteGeneralState = sprite.m_derivedStats.m_generalState + -- + local isDungeon = EEex_Trigger_ParseConditionalString('AreaType(DUNGEON)') + local isNight = EEex_Trigger_ParseConditionalString('AreaType(OUTDOOR) \n AreaType(DAYNIGHT) \n TimeOfDay(NIGHT)') + -- + local applyCondition = not (hasInnateInfravision or EEex_IsBitSet(spriteGeneralState, 17)) and (isDungeon:evalConditionalAsAIBase(sprite) or isNight:evalConditionalAsAIBase(sprite)) + -- + if sprite:getLocalInt("cdtweaksNoInfravision") == 0 then + if applyCondition then + apply() + end + else + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("cdtweaksNoInfravision", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "GTRULE02", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end +end) diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index 84c933fc..8103d4b7 100644 --- a/cdtweaks/readme-cdtweaks.html +++ b/cdtweaks/readme-cdtweaks.html @@ -1011,22 +1011,11 @@

Rule Changes

Dual-Wield feat for Rangers [Luke]
EEex

This component simply forces Rangers to wield light armors (or no armor) in order to benefit from Two-Weapon Fighting.

-

NWN-ish Armor vs. Dexterity [Luke]
+

PnP: -4 THAC0 in darkness (Dungeon / night areas) [Luke]
EEex

-

This component simply "forces" characters to wield light armors (or no armor) if they have high Dexterity. - In particular:

-
    -
  • If a character is equipped with a Medium Armor, it will only benefit from half the bonus derived from its Dexterity (see dexmod.2da) -
      -
    • So for instance, a character with 18 DEX equipped with a Chain Mail Armor will suffer a -4 / 2 = -2 AC penalty.
    • -
    -
  • -
  • If a character is equipped with a Heavy Armor, it will not benefit from the bonus derived from its Dexterity (see dexmod.2da) -
      -
    • So for instance, a character with 18 DEX equipped with a Plate Mail will suffer a -4 AC penalty.
    • -
    -
  • -
+

+ All creatures without the Infravision ability will incur a -4 penalty to THAC0 in darkness (Dungeon or night areas), as per AD&D rules. +

Defensive Roll feat for Thieves [Luke]
EEex

This component aims at implementing the NWN feat Defensive Roll. As a result, after installing it, if the character is struck by a potentially lethal blow, he makes a Save vs. Breath. If successful, he takes only half damage from the blow.

diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 5e97fb6f..50e0131a 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -2836,19 +2836,20 @@ REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/dual_wield.tra~ @7 LABEL ~cd_tweaks_dual_wield~ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -///// \\\\\ -///// "Force" the Archer kit to use bows \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ BEGIN @268000 DESIGNATED 2680 GROUP @9 +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%/revised_archer.tra~ @7 -LABEL ~cd_tweaks_revised_archer~ +REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/infravision.tra~ @7 +LABEL ~cd_tweaks_infravision~ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ From 62a36afff0ba9363edfe7f48357d38df0229c176 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 21 Dec 2024 19:07:40 +0100 Subject: [PATCH 2/3] Update infravision.lua --- cdtweaks/luke/lua/rule_changes/infravision.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cdtweaks/luke/lua/rule_changes/infravision.lua b/cdtweaks/luke/lua/rule_changes/infravision.lua index 850e3553..e50780d9 100644 --- a/cdtweaks/luke/lua/rule_changes/infravision.lua +++ b/cdtweaks/luke/lua/rule_changes/infravision.lua @@ -40,10 +40,12 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) -- 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 spriteGeneralState = sprite.m_derivedStats.m_generalState -- - local isDungeon = EEex_Trigger_ParseConditionalString('AreaType(DUNGEON)') - local isNight = EEex_Trigger_ParseConditionalString('AreaType(OUTDOOR) \n AreaType(DAYNIGHT) \n TimeOfDay(NIGHT)') + local isDungeon = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x5) or false + local isOutdoor = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x0) or false + local isDayNight = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x1) or false + local isNight = EEex_Trigger_ParseConditionalString('TimeOfDay(NIGHT)') -- - local applyCondition = not (hasInnateInfravision or EEex_IsBitSet(spriteGeneralState, 17)) and (isDungeon:evalConditionalAsAIBase(sprite) or isNight:evalConditionalAsAIBase(sprite)) + local applyCondition = not (hasInnateInfravision or EEex_IsBitSet(spriteGeneralState, 17)) and (isDungeon or (isOutdoor and isDayNight and isNight:evalConditionalAsAIBase(sprite))) -- if sprite:getLocalInt("cdtweaksNoInfravision") == 0 then if applyCondition then @@ -64,4 +66,6 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) }) end end + -- + isNight:free() end) From abbc1f726ccfdd87905c02b7ae2df77a84f2a0b2 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sun, 22 Dec 2024 12:38:35 +0100 Subject: [PATCH 3/3] Update infravision.lua Restrict to playable races only. --- .../luke/lua/rule_changes/infravision.lua | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/cdtweaks/luke/lua/rule_changes/infravision.lua b/cdtweaks/luke/lua/rule_changes/infravision.lua index e50780d9..d30786ae 100644 --- a/cdtweaks/luke/lua/rule_changes/infravision.lua +++ b/cdtweaks/luke/lua/rule_changes/infravision.lua @@ -6,7 +6,7 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) -- Sanity check - if not EEex_GameObject_IsSprite(sprite) then + if not EEex_GameObject_IsSprite(sprite) or not sprite.m_pArea then return end -- internal function that applies the actual penalty @@ -33,6 +33,16 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) }) end end + -- + local playableRaces = { + ["HUMAN"] = true, + ["ELF"] = true, + ["HALF_ELF"] = true, + ["DWARF"] = true, + ["GNOME"] = true, + ["HALFLING"] = true, + ["HALFORC"] = true, + } -- Check creature's race / state local spriteRaceStr = GT_Resource_IDSToSymbol["race"][sprite.m_typeAI.m_Race] local racefeat = GT_Resource_2DA["racefeat"] @@ -40,30 +50,32 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) -- 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 spriteGeneralState = sprite.m_derivedStats.m_generalState -- - local isDungeon = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x5) or false - local isOutdoor = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x0) or false - local isDayNight = sprite.m_pArea and EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x1) or false + local isDungeon = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x5) + local isOutdoor = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x0) + local isDayNight = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x1) local isNight = EEex_Trigger_ParseConditionalString('TimeOfDay(NIGHT)') -- local applyCondition = not (hasInnateInfravision or EEex_IsBitSet(spriteGeneralState, 17)) and (isDungeon or (isOutdoor and isDayNight and isNight:evalConditionalAsAIBase(sprite))) -- - if sprite:getLocalInt("cdtweaksNoInfravision") == 0 then - if applyCondition then - apply() - end - else - if applyCondition then - -- do nothing + if playableRaces[spriteRaceStr] then + if sprite:getLocalInt("cdtweaksNoInfravision") == 0 then + if applyCondition then + apply() + end else - -- Mark the creature as 'condition removed' - sprite:setLocalInt("cdtweaksNoInfravision", 0) - -- - sprite:applyEffect({ - ["effectID"] = 321, -- Remove effects by resource - ["res"] = "GTRULE02", - ["sourceID"] = sprite.m_id, - ["sourceTarget"] = sprite.m_id, - }) + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("cdtweaksNoInfravision", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "GTRULE02", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end end end --